ActionOrderFind.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 }],
  19. skip: [count || 0], limit: [limit] }])
  20. }
  21. )
  22. )
  23. }
  24. export const actionFullOrderFind = (count=0, limit=100) =>
  25. async dispatch => {
  26. let value = await dispatch(actionOrderFind(count, limit))
  27. if (value){
  28. dispatch(actionMyOrder(value))
  29. }
  30. }
  31. //OrderCount
  32. export const actionOrderCount = () => {
  33. return actionPromise('orderCount', gql(`query orderCount{
  34. OrderCount(query: "[{}]")
  35. }`)
  36. )
  37. }
  38. //OrderFindOne
  39. export const actionOrderFindOne = (_id) => {
  40. return actionPromise('orderFindOne', gql(`query orderFindOne($q: String){
  41. OrderFindOne(query: $q) {
  42. _id createdAt total orderGoods {
  43. _id price count total good {
  44. _id createdAt name images {
  45. _id url
  46. }
  47. }
  48. }
  49. }
  50. }`, {q: JSON.stringify([{_id}])})
  51. )
  52. }