order.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import BaseStore from '@src/stores/base';
  2. export default class OrderStore extends BaseStore {
  3. allCheckout() {
  4. return this.apiGet('/order/checkout/all')
  5. .then(result => {
  6. this.setState({ number: result.checkouts.length });
  7. return result;
  8. });
  9. }
  10. addCheckout({ productType, productId, service, param, number }) {
  11. return this.apiPost('/order/checkout/add', { productType, productId, service, param, number })
  12. .then(result => {
  13. this.setState({ number: result });
  14. return result;
  15. });
  16. }
  17. changeCheckout(id, number) {
  18. return this.apiPut('/order/checkout/number', { id, number })
  19. .then(result => {
  20. this.setState({ number: result });
  21. return result;
  22. });
  23. }
  24. selectCheckout(id, select) {
  25. return this.apiPut('/order/checkout/select', { id, select })
  26. .then(result => {
  27. this.setState({ number: result });
  28. return result;
  29. });
  30. }
  31. removeCheckout(id) {
  32. return this.apiDel('/order/checkout/delete', { id })
  33. .then(result => {
  34. this.setState({ number: result });
  35. return result;
  36. });
  37. }
  38. confirmPay(courseId) {
  39. return this.apiPost('/order/pay/confirm', { courseId });
  40. }
  41. speedPay({ productType, productId, service, param, number }) {
  42. return this.apiPost('/order/pay/speed', { productType, productId, service, param, number });
  43. }
  44. wechatQr(orderId) {
  45. return this.apiPost('/order/pay/wechat/qr', { orderId });
  46. }
  47. wechatJs(orderId) {
  48. return this.apiPost('/order/pay/wechat/js', { orderId });
  49. }
  50. alipayQr(orderId) {
  51. return this.apiPost('/order/pay/alipay/qr', { orderId });
  52. }
  53. query(orderId) {
  54. return this.apiGet('/order/pay/query', { orderId });
  55. }
  56. list({ page, size }) {
  57. return this.apiGet('/order/list', { page, size });
  58. }
  59. getOrder(id) {
  60. return this.apiGet('/order/detail', { id });
  61. }
  62. /**
  63. * 获取所有已购记录
  64. * @param {*} param0
  65. */
  66. listRecord({ page, size, productType, productId, service, isUsed, isExpire, filterChildren }) {
  67. return this.apiGet('/order/record/list', { page, size, productType, productId, service, isUsed, isExpire, filterChildren });
  68. }
  69. /**
  70. * 获取订单记录
  71. * @param {*} id
  72. */
  73. getRecord(id) {
  74. return this.apiGet('/order/record/detail', { id });
  75. }
  76. /**
  77. * 开通服务、课程等
  78. * @param {*} id
  79. */
  80. useRecord(recordId, isSubscribe) {
  81. return this.apiPost('/order/record/use', { recordId, isSubscribe });
  82. }
  83. openInvoice({ orderId, invoiceType, title, identity }) {
  84. return this.apiPost('/order/invoice/open', { orderId, invoiceType, title, identity });
  85. }
  86. }
  87. export const Order = new OrderStore({ key: 'order', local: true });