您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

288 行
5.2 KiB

  1. import apollo from "../../lib/apollo.js";
  2. async function getTransaction(token = "") {
  3. var res = await apollo.query(
  4. `
  5. query {
  6. transactions{
  7. id
  8. order_id
  9. cust_name
  10. cust_telp
  11. cust_address
  12. product_img{
  13. url
  14. }
  15. product_name
  16. product_color
  17. product_quantity
  18. product_courier
  19. product_price
  20. }
  21. }`,
  22. token
  23. );
  24. return res;
  25. }
  26. async function getTransactionUnpaid(token = "") {
  27. var res = await apollo.query(
  28. `
  29. query {
  30. transactions(where: { status: "1" }){
  31. id
  32. order_id
  33. cust_name
  34. cust_telp
  35. cust_address
  36. product_img{
  37. url
  38. }
  39. product_name
  40. product_color
  41. product_quantity
  42. product_courier
  43. product_price
  44. }
  45. }`,
  46. token
  47. );
  48. return res;
  49. }
  50. async function PayTransactionUnpaid(token = "") {
  51. var res = await apollo.query(
  52. `
  53. query{
  54. transactions(where: { status: "1" }){
  55. id
  56. order_id
  57. cust_name
  58. cust_telp
  59. cust_address
  60. product_img{
  61. url
  62. }
  63. product_name
  64. product_color
  65. product_quantity
  66. product_courier
  67. product_price
  68. }
  69. }
  70. `,
  71. token
  72. );
  73. return res;
  74. }
  75. async function getTransactionPrepared(token = "") {
  76. var res = await apollo.query(
  77. `
  78. query {
  79. transactions(where: { status: "2" }){
  80. id
  81. order_id
  82. cust_name
  83. cust_telp
  84. cust_address
  85. product_img{
  86. url
  87. }
  88. product_name
  89. product_color
  90. product_quantity
  91. product_courier
  92. product_price
  93. }
  94. }`,
  95. token
  96. );
  97. return res;
  98. }
  99. async function getTransactionSending(token = "") {
  100. var res = await apollo.query(
  101. `
  102. query {
  103. transactions(where: { status: "3" }){
  104. id
  105. order_id
  106. cust_name
  107. cust_telp
  108. cust_address
  109. product_img{
  110. url
  111. }
  112. product_name
  113. product_color
  114. product_quantity
  115. product_courier
  116. product_price
  117. }
  118. }`,
  119. token
  120. );
  121. return res;
  122. }
  123. async function getTransactionFinished(token = "") {
  124. var res = await apollo.query(
  125. `
  126. query {
  127. transactions(where: { status: "4" }){
  128. id
  129. order_id
  130. cust_name
  131. cust_telp
  132. cust_address
  133. product_img{
  134. url
  135. }
  136. product_name
  137. product_color
  138. product_quantity
  139. product_courier
  140. product_price
  141. }
  142. }`,
  143. token
  144. );
  145. return res;
  146. }
  147. async function AddToCart(content, token = "") {
  148. var res = await apollo.mutation(
  149. `
  150. mutation($input : CartInput!){
  151. createCart( input:{data:$input} )
  152. {
  153. cart{
  154. id
  155. }
  156. }
  157. }
  158. `,
  159. token,
  160. {
  161. input: content,
  162. }
  163. );
  164. return res;
  165. }
  166. async function AddToCheckout(content, token = "") {
  167. var res = await apollo.mutation(
  168. `
  169. mutation($input: CheckoutInput!) {
  170. createCheckout(input: { data: $input }) {
  171. checkout {
  172. id
  173. }
  174. }
  175. }
  176. `,
  177. token,
  178. {
  179. input: content,
  180. }
  181. );
  182. return res;
  183. }
  184. async function newTransactionYamaha(content, token = "") {
  185. var res = await apollo.mutation(
  186. `
  187. mutation($input : TransactionInput!){
  188. createTransaction( input:{data:$input} )
  189. {
  190. transaction{
  191. id
  192. }
  193. }
  194. }
  195. `,
  196. token,
  197. {
  198. input: content,
  199. }
  200. );
  201. return res;
  202. }
  203. async function newTransactionSuzuki(content, token = "") {
  204. var res = await apollo.mutation(
  205. `
  206. mutation($input : TransactionInput!){
  207. createTransaction( input:{data:$input} )
  208. {
  209. transactionSuzuki{
  210. id
  211. }
  212. }
  213. }
  214. `,
  215. token,
  216. {
  217. input: content,
  218. }
  219. );
  220. return res;
  221. }
  222. async function newTransactionHonda(content, token = "") {
  223. var res = await apollo.mutation(
  224. `
  225. mutation($input : TransactionInput!){
  226. createTransaction( input:{data:$input} )
  227. {
  228. transactionHonda{
  229. id
  230. }
  231. }
  232. }
  233. `,
  234. token,
  235. {
  236. input: content,
  237. }
  238. );
  239. return res;
  240. }
  241. async function newTransactionHino(content, token = "") {
  242. var res = await apollo.mutation(
  243. `
  244. mutation($input : TransactionInput!){
  245. createTransaction( input:{data:$input} )
  246. {
  247. transactionHino{
  248. id
  249. }
  250. }
  251. }
  252. `,
  253. token,
  254. {
  255. input: content,
  256. }
  257. );
  258. return res;
  259. }
  260. module.exports = {
  261. newTransactionYamaha: newTransactionYamaha,
  262. newTransactionSuzuki: newTransactionSuzuki,
  263. newTransactionHonda: newTransactionHonda,
  264. newTransactionHino: newTransactionHino,
  265. getTransaction: getTransaction,
  266. getTransactionUnpaid: getTransactionUnpaid,
  267. PayTransactionUnpaid: PayTransactionUnpaid,
  268. getTransactionPrepared: getTransactionPrepared,
  269. getTransactionSending: getTransactionSending,
  270. getTransactionFinished: getTransactionFinished,
  271. AddToCart: AddToCart,
  272. AddToCheckout:AddToCheckout,
  273. };