ActionOrderFind.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import {actionPromise} from "../reducers/PromiseReducer";
  2. import {gql} from "./PathDB";
  3. import {actionMyOrder} from "../reducers/MyOrdersReducer";
  4. //OrderFind
  5. const actionOrderFind = (count, limit) => {
  6. return actionPromise('orderFind', gql(`query orderFind($query: String!) {
  7. OrderFind(query: $query) {
  8. _id total createdAt orderGoods{
  9. _id count price good{
  10. _id name description images{
  11. _id url
  12. }
  13. }
  14. }
  15. }
  16. }`,
  17. {
  18. query: JSON.stringify([{}, { sort: [{ ["createdAt"]: -1 }], skip: [count || 0], limit: [limit] }])
  19. }
  20. )
  21. )
  22. }
  23. export const actionFullOrderFind = (count=0, limit=100) =>
  24. async dispatch => {
  25. let value = await dispatch(actionOrderFind(count, limit))
  26. if (value){
  27. dispatch(actionMyOrder(value))
  28. }
  29. }
  30. //OrderCount
  31. export const actionOrderCount = () => {
  32. return actionPromise('orderCount', gql(`query orderCount{
  33. OrderCount(query: "[{}]")
  34. }`)
  35. )
  36. }
  37. //OrderFindOne
  38. export const actionOrderFindOne = (_id) => {
  39. return actionPromise('orderFindOne', gql(`query orderFindOne($q: String){
  40. OrderFindOne(query: $q) {
  41. _id createdAt total orderGoods {
  42. _id price count total good {
  43. _id createdAt name images {
  44. _id url
  45. }
  46. }
  47. }
  48. }
  49. }`, {q: JSON.stringify([{_id}])})
  50. )
  51. }