@pisell/pisellos 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/core/index.js +4 -1
  2. package/dist/effects/index.d.ts +1 -1
  3. package/dist/effects/index.js +3 -3
  4. package/dist/modules/Account/index.d.ts +5 -3
  5. package/dist/modules/Account/index.js +23 -36
  6. package/dist/modules/Account/types.d.ts +2 -1
  7. package/dist/modules/AccountList/index.d.ts +2 -0
  8. package/dist/modules/AccountList/index.js +34 -11
  9. package/dist/modules/Cart/index.d.ts +17 -11
  10. package/dist/modules/Cart/index.js +179 -121
  11. package/dist/modules/Cart/types.d.ts +98 -9
  12. package/dist/modules/Cart/types.js +8 -0
  13. package/dist/modules/Cart/utils.d.ts +114 -0
  14. package/dist/modules/Cart/utils.js +345 -0
  15. package/dist/modules/Date/index.d.ts +11 -12
  16. package/dist/modules/Date/index.js +104 -60
  17. package/dist/modules/Date/types.d.ts +51 -20
  18. package/dist/modules/Date/types.js +2 -5
  19. package/dist/modules/Date/utils.d.ts +35 -0
  20. package/dist/modules/Date/utils.js +211 -0
  21. package/dist/modules/Discount/index.d.ts +26 -0
  22. package/dist/modules/Discount/index.js +234 -0
  23. package/dist/modules/Discount/types.d.ts +66 -0
  24. package/dist/modules/Discount/types.js +5 -0
  25. package/dist/modules/Order/index.d.ts +16 -12
  26. package/dist/modules/Order/index.js +38 -166
  27. package/dist/modules/Order/types.d.ts +18 -41
  28. package/dist/modules/Order/types.js +0 -14
  29. package/dist/modules/Payment/index.d.ts +0 -2
  30. package/dist/modules/Payment/index.js +45 -76
  31. package/dist/modules/Payment/types.d.ts +0 -2
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Product/types.d.ts +50 -1
  34. package/dist/modules/ProductList/index.d.ts +1 -0
  35. package/dist/modules/ProductList/index.js +23 -2
  36. package/dist/modules/ProductList/types.d.ts +1 -0
  37. package/dist/modules/Resource/types.d.ts +6 -2
  38. package/dist/modules/Rules/index.d.ts +32 -0
  39. package/dist/modules/Rules/index.js +423 -0
  40. package/dist/modules/Rules/types.d.ts +46 -0
  41. package/dist/modules/Rules/types.js +5 -0
  42. package/dist/modules/Summary/index.d.ts +13 -0
  43. package/dist/modules/Summary/index.js +80 -0
  44. package/dist/modules/Summary/types.d.ts +13 -0
  45. package/dist/modules/Summary/types.js +1 -0
  46. package/dist/modules/Summary/utils.d.ts +19 -0
  47. package/dist/modules/Summary/utils.js +56 -0
  48. package/dist/plugins/index.d.ts +3 -2
  49. package/dist/plugins/index.js +2 -1
  50. package/dist/plugins/request.d.ts +4 -3
  51. package/dist/plugins/request.js +30 -30
  52. package/dist/plugins/shopStore.d.ts +4 -0
  53. package/dist/plugins/shopStore.js +1 -0
  54. package/dist/solution/BookingByStep/index.d.ts +73 -10
  55. package/dist/solution/BookingByStep/index.js +641 -74
  56. package/dist/solution/BookingByStep/types.d.ts +2 -0
  57. package/dist/solution/BookingByStep/types.js +11 -8
  58. package/dist/solution/BookingByStep/utils/products.d.ts +11 -0
  59. package/dist/solution/BookingByStep/utils/products.js +47 -0
  60. package/dist/solution/BookingByStep/utils/resources.d.ts +59 -10
  61. package/dist/solution/BookingByStep/utils/resources.js +144 -79
  62. package/dist/solution/ShopDiscount/index.d.ts +50 -0
  63. package/dist/solution/ShopDiscount/index.js +546 -0
  64. package/dist/solution/ShopDiscount/types.d.ts +24 -0
  65. package/dist/solution/ShopDiscount/types.js +10 -0
  66. package/dist/solution/ShopDiscount/utils.d.ts +1 -0
  67. package/dist/solution/ShopDiscount/utils.js +7 -0
  68. package/dist/solution/index.d.ts +1 -0
  69. package/dist/solution/index.js +2 -1
  70. package/lib/core/index.js +1 -1
  71. package/lib/effects/index.d.ts +1 -1
  72. package/lib/effects/index.js +1 -1
  73. package/lib/modules/Account/index.d.ts +5 -3
  74. package/lib/modules/Account/index.js +14 -3
  75. package/lib/modules/Account/types.d.ts +2 -1
  76. package/lib/modules/AccountList/index.d.ts +2 -0
  77. package/lib/modules/AccountList/index.js +17 -0
  78. package/lib/modules/Cart/index.d.ts +17 -11
  79. package/lib/modules/Cart/index.js +72 -21
  80. package/lib/modules/Cart/types.d.ts +98 -9
  81. package/lib/modules/Cart/utils.d.ts +114 -0
  82. package/lib/modules/Cart/utils.js +320 -0
  83. package/lib/modules/Date/index.d.ts +11 -12
  84. package/lib/modules/Date/index.js +50 -31
  85. package/lib/modules/Date/types.d.ts +51 -20
  86. package/lib/modules/Date/types.js +0 -4
  87. package/lib/modules/Date/utils.d.ts +35 -0
  88. package/lib/modules/Date/utils.js +167 -0
  89. package/lib/modules/Discount/index.d.ts +26 -0
  90. package/lib/modules/Discount/index.js +118 -0
  91. package/lib/modules/Discount/types.d.ts +66 -0
  92. package/lib/modules/Discount/types.js +33 -0
  93. package/lib/modules/Order/index.d.ts +16 -12
  94. package/lib/modules/Order/index.js +23 -51
  95. package/lib/modules/Order/types.d.ts +18 -41
  96. package/lib/modules/Payment/index.d.ts +0 -2
  97. package/lib/modules/Payment/index.js +6 -17
  98. package/lib/modules/Payment/types.d.ts +0 -2
  99. package/lib/modules/Product/types.d.ts +50 -1
  100. package/lib/modules/ProductList/index.d.ts +1 -0
  101. package/lib/modules/ProductList/index.js +6 -1
  102. package/lib/modules/ProductList/types.d.ts +1 -0
  103. package/lib/modules/Resource/types.d.ts +6 -2
  104. package/lib/modules/Rules/index.d.ts +32 -0
  105. package/lib/modules/Rules/index.js +283 -0
  106. package/lib/modules/Rules/types.d.ts +46 -0
  107. package/lib/modules/Rules/types.js +33 -0
  108. package/lib/modules/Summary/index.d.ts +13 -0
  109. package/lib/modules/Summary/index.js +49 -0
  110. package/lib/modules/Summary/types.d.ts +13 -0
  111. package/lib/modules/Summary/types.js +17 -0
  112. package/lib/modules/Summary/utils.d.ts +19 -0
  113. package/lib/modules/Summary/utils.js +79 -0
  114. package/lib/plugins/index.d.ts +3 -2
  115. package/lib/plugins/index.js +3 -1
  116. package/lib/plugins/request.d.ts +4 -3
  117. package/lib/plugins/request.js +4 -20
  118. package/lib/plugins/shopStore.d.ts +4 -0
  119. package/lib/plugins/shopStore.js +17 -0
  120. package/lib/solution/BookingByStep/index.d.ts +73 -10
  121. package/lib/solution/BookingByStep/index.js +452 -20
  122. package/lib/solution/BookingByStep/types.d.ts +2 -0
  123. package/lib/solution/BookingByStep/types.js +3 -0
  124. package/lib/solution/BookingByStep/utils/products.d.ts +11 -0
  125. package/lib/solution/BookingByStep/utils/products.js +60 -0
  126. package/lib/solution/BookingByStep/utils/resources.d.ts +59 -10
  127. package/lib/solution/BookingByStep/utils/resources.js +106 -49
  128. package/lib/solution/ShopDiscount/index.d.ts +50 -0
  129. package/lib/solution/ShopDiscount/index.js +321 -0
  130. package/lib/solution/ShopDiscount/types.d.ts +24 -0
  131. package/lib/solution/ShopDiscount/types.js +38 -0
  132. package/lib/solution/ShopDiscount/utils.d.ts +1 -0
  133. package/lib/solution/ShopDiscount/utils.js +32 -0
  134. package/lib/solution/index.d.ts +1 -0
  135. package/lib/solution/index.js +3 -1
  136. package/package.json +8 -7
@@ -0,0 +1,66 @@
1
+ export declare enum DiscountHooks {
2
+ OnDiscountListChange = "discount:onDiscountListChange",
3
+ OnDestroy = "discount:onDestroy"
4
+ }
5
+ interface Product {
6
+ id: number;
7
+ title: string;
8
+ is_charge_tax: number;
9
+ base_price: string;
10
+ }
11
+ interface Formattitle {
12
+ auto: string;
13
+ original: string;
14
+ en?: any;
15
+ 'zh-CN'?: any;
16
+ 'zh-HK'?: any;
17
+ }
18
+ interface Limitedrelationproductdata {
19
+ id: number;
20
+ type: 'product_all' | 'products' | 'product_collection';
21
+ product_ids: number[];
22
+ product_collection_id: number[];
23
+ }
24
+ interface ApplicableProductDetails {
25
+ amount: string;
26
+ type: string;
27
+ resource_id: number;
28
+ title: string;
29
+ original_amount: string;
30
+ }
31
+ export interface Discount {
32
+ id: number;
33
+ product_name: string;
34
+ encoded: string;
35
+ code: string;
36
+ tag: string;
37
+ expire_time?: string;
38
+ product_id: number;
39
+ relation_type: string;
40
+ par_value: string;
41
+ used_par_value: string;
42
+ limit_status: string;
43
+ limited_relation_product_data: Limitedrelationproductdata;
44
+ balance: string;
45
+ format_title: Formattitle;
46
+ product: Product;
47
+ resource_id?: number;
48
+ savedAmount?: number;
49
+ isEditMode?: boolean;
50
+ isManualSelect?: boolean;
51
+ isDisabled?: boolean;
52
+ isSelected?: boolean;
53
+ isAvailable?: boolean;
54
+ isUsed?: boolean;
55
+ applicableProductIds?: number[];
56
+ applicableProductDetails: ApplicableProductDetails[];
57
+ appliedProductDetails: ApplicableProductDetails[];
58
+ }
59
+ export interface DiscountState {
60
+ discountList: Discount[];
61
+ }
62
+ export interface DiscountModuleAPI {
63
+ setDiscountList: (discountList: Discount[]) => Promise<void>;
64
+ clear: () => Promise<void>;
65
+ }
66
+ export {};
@@ -0,0 +1,5 @@
1
+ export var DiscountHooks = /*#__PURE__*/function (DiscountHooks) {
2
+ DiscountHooks["OnDiscountListChange"] = "discount:onDiscountListChange";
3
+ DiscountHooks["OnDestroy"] = "discount:onDestroy";
4
+ return DiscountHooks;
5
+ }({});
@@ -1,17 +1,21 @@
1
- import { Module, PisellCore, ModuleOptions } from '../../types';
2
- import { BaseModule } from '../BaseModule';
3
- import { Order, OrderItem, OrderModuleAPI, OrderStatus } from './types';
1
+ import { Module, PisellCore, ModuleOptions } from "../../types";
2
+ import { BaseModule } from "../BaseModule";
3
+ import { OrderModuleAPI, CommitOrderParams } from "./types";
4
4
  export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
7
- private state;
7
+ private store;
8
+ private request;
8
9
  constructor(name?: string, version?: string);
9
- initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
10
- createOrder(items: OrderItem[]): Promise<Order>;
11
- getOrder(orderId: string): Promise<Order>;
12
- updateOrderStatus(orderId: string, status: OrderStatus): Promise<void>;
13
- cancelOrder(orderId: string): Promise<void>;
14
- getOrderHistory(): Promise<Order[]>;
15
- getCurrentOrder(): Order | null;
16
- calculateTotalAmount(items: OrderItem[]): number;
10
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
11
+ createOrder(params: CommitOrderParams["query"]): {
12
+ type: string;
13
+ platform: string;
14
+ sales_channel: string;
15
+ order_sales_channel: string;
16
+ bookings: any[];
17
+ shop_note: string;
18
+ schedule_date: string;
19
+ };
20
+ commitOrder(order: CommitOrderParams): Promise<void>;
17
21
  }
@@ -1,7 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -18,7 +16,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
18
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
18
  import { BaseModule } from "../BaseModule";
21
- import { OrderHooks } from "./types";
22
19
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
23
20
  _inherits(OrderModule, _BaseModule);
24
21
  var _super = _createSuper(OrderModule);
@@ -26,12 +23,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
26
23
  var _this;
27
24
  _classCallCheck(this, OrderModule);
28
25
  _this = _super.call(this, name, version);
29
- _defineProperty(_assertThisInitialized(_this), "defaultName", 'order');
30
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
31
- _defineProperty(_assertThisInitialized(_this), "state", {
32
- currentOrder: null,
33
- orderHistory: []
34
- });
26
+ _defineProperty(_assertThisInitialized(_this), "defaultName", "order");
27
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
28
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
29
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
35
30
  return _this;
36
31
  }
37
32
  _createClass(OrderModule, [{
@@ -42,10 +37,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
42
37
  while (1) switch (_context.prev = _context.next) {
43
38
  case 0:
44
39
  this.core = core;
45
- if (options !== null && options !== void 0 && options.initialState) {
46
- this.state = _objectSpread(_objectSpread({}, this.state), options.initialState);
47
- }
48
- case 2:
40
+ this.store = options.store;
41
+ this.request = this.core.getPlugin("request");
42
+ case 3:
49
43
  case "end":
50
44
  return _context.stop();
51
45
  }
@@ -58,171 +52,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
58
52
  }()
59
53
  }, {
60
54
  key: "createOrder",
55
+ value: function createOrder(params) {
56
+ var order = {
57
+ type: "appointment_booking",
58
+ platform: "H5",
59
+ sales_channel: "my_pisel",
60
+ order_sales_channel: "online_store",
61
+ bookings: [],
62
+ shop_note: "",
63
+ schedule_date: ""
64
+ };
65
+ if (params.cartItems.length > 0) {
66
+ params.cartItems.forEach(function (item) {
67
+ order.bookings.push(item._origin);
68
+ });
69
+ var firstCartItem = params.cartItems[0];
70
+ order.schedule_date = firstCartItem.start_date + " " + firstCartItem.start_time + ":00";
71
+ }
72
+ return order;
73
+ }
74
+ }, {
75
+ key: "commitOrder",
61
76
  value: function () {
62
- var _createOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(items) {
63
- var order;
77
+ var _commitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
78
+ var url, query, fetchUrl, params;
64
79
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
65
80
  while (1) switch (_context2.prev = _context2.next) {
66
81
  case 0:
67
- order = {
68
- id: Date.now().toString(),
69
- // 实际应该使用更可靠的 ID 生成方式
70
- orderNumber: "ORD-".concat(Date.now()),
71
- status: 'pending',
72
- items: items,
73
- totalAmount: this.calculateTotalAmount(items),
74
- createdAt: new Date(),
75
- updatedAt: new Date()
76
- };
77
- this.state.currentOrder = order;
78
- _context2.next = 4;
79
- return this.core.effects.emit(OrderHooks.OnOrderCreate, order);
80
- case 4:
81
- return _context2.abrupt("return", order);
82
+ url = order.url, query = order.query;
83
+ fetchUrl = url || "/order/appointment";
84
+ params = this.createOrder(query);
85
+ console.log(params);
86
+ return _context2.abrupt("return", this.request.post(fetchUrl, params));
82
87
  case 5:
83
88
  case "end":
84
89
  return _context2.stop();
85
90
  }
86
91
  }, _callee2, this);
87
92
  }));
88
- function createOrder(_x3) {
89
- return _createOrder.apply(this, arguments);
90
- }
91
- return createOrder;
92
- }()
93
- }, {
94
- key: "getOrder",
95
- value: function () {
96
- var _getOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(orderId) {
97
- var order;
98
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
99
- while (1) switch (_context3.prev = _context3.next) {
100
- case 0:
101
- order = this.state.orderHistory.find(function (o) {
102
- return o.id === orderId;
103
- });
104
- if (order) {
105
- _context3.next = 3;
106
- break;
107
- }
108
- throw new Error('Order not found');
109
- case 3:
110
- return _context3.abrupt("return", order);
111
- case 4:
112
- case "end":
113
- return _context3.stop();
114
- }
115
- }, _callee3, this);
116
- }));
117
- function getOrder(_x4) {
118
- return _getOrder.apply(this, arguments);
119
- }
120
- return getOrder;
121
- }()
122
- }, {
123
- key: "updateOrderStatus",
124
- value: function () {
125
- var _updateOrderStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(orderId, status) {
126
- var order;
127
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
128
- while (1) switch (_context4.prev = _context4.next) {
129
- case 0:
130
- order = this.state.orderHistory.find(function (o) {
131
- return o.id === orderId;
132
- });
133
- if (order) {
134
- _context4.next = 3;
135
- break;
136
- }
137
- return _context4.abrupt("return");
138
- case 3:
139
- order.status = status;
140
- order.updatedAt = new Date();
141
- _context4.next = 7;
142
- return this.core.effects.emit(OrderHooks.OnOrderStatusChange, {
143
- orderId: orderId,
144
- status: status
145
- });
146
- case 7:
147
- _context4.next = 9;
148
- return this.core.effects.emit(OrderHooks.OnOrderUpdate, order);
149
- case 9:
150
- case "end":
151
- return _context4.stop();
152
- }
153
- }, _callee4, this);
154
- }));
155
- function updateOrderStatus(_x5, _x6) {
156
- return _updateOrderStatus.apply(this, arguments);
93
+ function commitOrder(_x3) {
94
+ return _commitOrder.apply(this, arguments);
157
95
  }
158
- return updateOrderStatus;
96
+ return commitOrder;
159
97
  }()
160
- }, {
161
- key: "cancelOrder",
162
- value: function () {
163
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(orderId) {
164
- var order;
165
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
166
- while (1) switch (_context5.prev = _context5.next) {
167
- case 0:
168
- order = this.state.orderHistory.find(function (o) {
169
- return o.id === orderId;
170
- });
171
- if (order) {
172
- _context5.next = 3;
173
- break;
174
- }
175
- return _context5.abrupt("return");
176
- case 3:
177
- order.status = 'cancelled';
178
- order.updatedAt = new Date();
179
- _context5.next = 7;
180
- return this.core.effects.emit(OrderHooks.OnOrderCancel, order);
181
- case 7:
182
- _context5.next = 9;
183
- return this.core.effects.emit(OrderHooks.OnOrderUpdate, order);
184
- case 9:
185
- case "end":
186
- return _context5.stop();
187
- }
188
- }, _callee5, this);
189
- }));
190
- function cancelOrder(_x7) {
191
- return _cancelOrder.apply(this, arguments);
192
- }
193
- return cancelOrder;
194
- }()
195
- }, {
196
- key: "getOrderHistory",
197
- value: function () {
198
- var _getOrderHistory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
199
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
200
- while (1) switch (_context6.prev = _context6.next) {
201
- case 0:
202
- return _context6.abrupt("return", this.state.orderHistory);
203
- case 1:
204
- case "end":
205
- return _context6.stop();
206
- }
207
- }, _callee6, this);
208
- }));
209
- function getOrderHistory() {
210
- return _getOrderHistory.apply(this, arguments);
211
- }
212
- return getOrderHistory;
213
- }()
214
- }, {
215
- key: "getCurrentOrder",
216
- value: function getCurrentOrder() {
217
- return this.state.currentOrder;
218
- }
219
- }, {
220
- key: "calculateTotalAmount",
221
- value: function calculateTotalAmount(items) {
222
- return items.reduce(function (total, item) {
223
- return total + item.price * item.quantity;
224
- }, 0);
225
- }
226
98
  }]);
227
99
  return OrderModule;
228
100
  }(BaseModule);
@@ -1,57 +1,34 @@
1
- import { Guest } from '../Guests/types';
2
- import { Resource } from '../Resource/types';
3
- import { TimeSlot } from '../Date/types';
1
+ import { CartItem } from "../Cart/types";
4
2
  export declare enum OrderHooks {
5
3
  OnOrderCreate = "order:onOrderCreate",
6
4
  OnOrderUpdate = "order:onOrderUpdate",
7
5
  OnOrderCancel = "order:onOrderCancel",
8
6
  OnOrderStatusChange = "order:onOrderStatusChange"
9
7
  }
10
- /**
11
- * 订单状态
12
- */
13
- export type OrderStatus = 'pending' | 'paid' | 'confirmed' | 'completed' | 'cancelled' | 'refunded';
14
- /**
15
- * 订单项
16
- */
17
- export interface OrderItem {
18
- id: string;
19
- productId: string;
20
- quantity: number;
21
- price: number;
22
- guest: Guest;
23
- resource: Resource;
24
- timeSlot: TimeSlot;
8
+ export interface OrderState {
25
9
  }
26
10
  /**
27
11
  * 订单信息
28
12
  */
29
- export interface Order {
30
- id: string;
31
- orderNumber: string;
32
- status: OrderStatus;
33
- items: OrderItem[];
34
- totalAmount: number;
35
- createdAt: Date;
36
- updatedAt: Date;
37
- metadata?: Record<string, any>;
38
- }
39
- /**
40
- * 订单模块状态
41
- */
42
- export interface OrderState {
43
- currentOrder: Order | null;
44
- orderHistory: Order[];
13
+ export interface CommitOrderParams {
14
+ url?: string;
15
+ query: {
16
+ cartItems: CartItem[];
17
+ };
45
18
  }
46
19
  /**
47
20
  * 订单模块 API
48
21
  */
49
22
  export interface OrderModuleAPI {
50
- createOrder: (items: OrderItem[]) => Promise<Order>;
51
- getOrder: (orderId: string) => Promise<Order>;
52
- updateOrderStatus: (orderId: string, status: OrderStatus) => Promise<void>;
53
- cancelOrder: (orderId: string) => Promise<void>;
54
- getOrderHistory: () => Promise<Order[]>;
55
- getCurrentOrder: () => Order | null;
56
- calculateTotalAmount: (items: OrderItem[]) => number;
23
+ /**
24
+ * 创建订单
25
+ * @param params 订单信息
26
+ * @returns 订单信息
27
+ */
28
+ createOrder: (params: CommitOrderParams["query"]) => any;
29
+ /**
30
+ * 提交订单
31
+ * @param params 订单信息
32
+ */
33
+ commitOrder: (params: CommitOrderParams) => Promise<void>;
57
34
  }
@@ -6,24 +6,10 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
6
6
  return OrderHooks;
7
7
  }({});
8
8
 
9
- /**
10
- * 订单状态
11
- */
12
-
13
- // 已退款
14
-
15
- /**
16
- * 订单项
17
- */
18
-
19
9
  /**
20
10
  * 订单信息
21
11
  */
22
12
 
23
- /**
24
- * 订单模块状态
25
- */
26
-
27
13
  /**
28
14
  * 订单模块 API
29
15
  */
@@ -1,14 +1,12 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
3
  import { Payment, PaymentModuleAPI, PaymentMethod, PaymentStatus } from './types';
4
- import { Order } from '../Order/types';
5
4
  export declare class PaymentModule extends BaseModule implements Module, PaymentModuleAPI {
6
5
  protected defaultName: string;
7
6
  protected defaultVersion: string;
8
7
  private state;
9
8
  constructor(name?: string, version?: string);
10
9
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
11
- initPayment(order: Order, method: PaymentMethod): Promise<Payment>;
12
10
  processPayment(paymentId: string): Promise<void>;
13
11
  getPayment(paymentId: string): Promise<Payment>;
14
12
  getPaymentHistory(): Promise<Payment[]>;