@pisell/pisellos 2.1.38 → 2.2.1

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 (135) hide show
  1. package/dist/core/index.d.ts +8 -1
  2. package/dist/core/index.js +116 -42
  3. package/dist/effects/index.d.ts +1 -0
  4. package/dist/effects/index.js +29 -6
  5. package/dist/modules/Account/index.js +2 -3
  6. package/dist/modules/BaseModule.d.ts +3 -0
  7. package/dist/modules/BaseModule.js +15 -0
  8. package/dist/modules/Customer/index.js +9 -10
  9. package/dist/modules/Customer/types.d.ts +2 -2
  10. package/dist/modules/Customer/types.js +2 -2
  11. package/dist/modules/Discount/index.js +1 -1
  12. package/dist/modules/Guests/index.js +9 -9
  13. package/dist/modules/Order/index.js +1 -1
  14. package/dist/modules/Payment/index.js +63 -73
  15. package/dist/modules/Payment/walletpass.js +4 -1
  16. package/dist/modules/Product/index.d.ts +1 -1
  17. package/dist/modules/Product/types.d.ts +19 -0
  18. package/dist/modules/ProductList/index.js +5 -14
  19. package/dist/modules/Resource/index.js +1 -1
  20. package/dist/modules/Rules/index.js +2 -3
  21. package/dist/modules/Schedule/types.d.ts +2 -0
  22. package/dist/plugins/request.d.ts +1 -0
  23. package/dist/server/index.d.ts +152 -0
  24. package/dist/server/index.js +946 -0
  25. package/dist/server/modules/index.d.ts +16 -0
  26. package/dist/server/modules/index.js +21 -0
  27. package/dist/server/modules/menu/index.d.ts +63 -0
  28. package/dist/server/modules/menu/index.js +476 -0
  29. package/dist/server/modules/menu/types.d.ts +68 -0
  30. package/dist/server/modules/menu/types.js +16 -0
  31. package/dist/server/modules/products/index.d.ts +141 -0
  32. package/dist/server/modules/products/index.js +768 -0
  33. package/dist/server/modules/products/types.d.ts +94 -0
  34. package/dist/server/modules/products/types.js +43 -0
  35. package/dist/server/modules/quotation/index.d.ts +47 -0
  36. package/dist/server/modules/quotation/index.js +367 -0
  37. package/dist/server/modules/quotation/types.d.ts +50 -0
  38. package/dist/server/modules/quotation/types.js +20 -0
  39. package/dist/server/modules/schedule/index.d.ts +62 -0
  40. package/dist/server/modules/schedule/index.js +431 -0
  41. package/dist/server/modules/schedule/types.d.ts +1 -0
  42. package/dist/server/modules/schedule/types.js +2 -0
  43. package/dist/server/modules/schedule/utils.d.ts +32 -0
  44. package/dist/server/modules/schedule/utils.js +747 -0
  45. package/dist/server/types.d.ts +64 -0
  46. package/dist/server/types.js +1 -0
  47. package/dist/server/utils/index.d.ts +5 -0
  48. package/dist/server/utils/index.js +6 -0
  49. package/dist/server/utils/product.d.ts +18 -0
  50. package/dist/server/utils/product.js +339 -0
  51. package/dist/server/utils/schedule.d.ts +14 -0
  52. package/dist/server/utils/schedule.js +108 -0
  53. package/dist/server/utils/time.d.ts +18 -0
  54. package/dist/server/utils/time.js +53 -0
  55. package/dist/solution/BookingByStep/index.d.ts +1 -17
  56. package/dist/solution/BookingByStep/index.js +23 -468
  57. package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
  58. package/dist/solution/BookingByStep/utils/capacity.js +8 -24
  59. package/dist/solution/BookingTicket/index.d.ts +12 -0
  60. package/dist/solution/BookingTicket/index.js +122 -79
  61. package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  62. package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
  63. package/dist/solution/BuyTickets/index.js +7 -8
  64. package/dist/solution/Checkout/index.d.ts +1 -46
  65. package/dist/solution/Checkout/index.js +530 -850
  66. package/dist/solution/ShopDiscount/index.js +9 -10
  67. package/dist/types/index.d.ts +27 -0
  68. package/lib/core/index.d.ts +8 -1
  69. package/lib/core/index.js +48 -1
  70. package/lib/effects/index.d.ts +1 -0
  71. package/lib/effects/index.js +13 -0
  72. package/lib/modules/Account/index.js +2 -3
  73. package/lib/modules/BaseModule.d.ts +3 -0
  74. package/lib/modules/BaseModule.js +9 -0
  75. package/lib/modules/Customer/index.js +9 -10
  76. package/lib/modules/Customer/types.d.ts +2 -2
  77. package/lib/modules/Customer/types.js +2 -2
  78. package/lib/modules/Discount/index.js +1 -1
  79. package/lib/modules/Guests/index.js +9 -9
  80. package/lib/modules/Order/index.js +1 -1
  81. package/lib/modules/Payment/index.js +56 -43
  82. package/lib/modules/Payment/walletpass.js +3 -1
  83. package/lib/modules/Product/index.d.ts +1 -1
  84. package/lib/modules/Product/types.d.ts +19 -0
  85. package/lib/modules/ProductList/index.js +4 -13
  86. package/lib/modules/Resource/index.js +1 -1
  87. package/lib/modules/Rules/index.js +2 -3
  88. package/lib/modules/Schedule/types.d.ts +2 -0
  89. package/lib/plugins/request.d.ts +1 -0
  90. package/lib/server/index.d.ts +152 -0
  91. package/lib/server/index.js +555 -0
  92. package/lib/server/modules/index.d.ts +16 -0
  93. package/lib/server/modules/index.js +47 -0
  94. package/lib/server/modules/menu/index.d.ts +63 -0
  95. package/lib/server/modules/menu/index.js +234 -0
  96. package/lib/server/modules/menu/types.d.ts +68 -0
  97. package/lib/server/modules/menu/types.js +33 -0
  98. package/lib/server/modules/products/index.d.ts +141 -0
  99. package/lib/server/modules/products/index.js +434 -0
  100. package/lib/server/modules/products/types.d.ts +94 -0
  101. package/lib/server/modules/products/types.js +35 -0
  102. package/lib/server/modules/quotation/index.d.ts +47 -0
  103. package/lib/server/modules/quotation/index.js +177 -0
  104. package/lib/server/modules/quotation/types.d.ts +50 -0
  105. package/lib/server/modules/quotation/types.js +33 -0
  106. package/lib/server/modules/schedule/index.d.ts +62 -0
  107. package/lib/server/modules/schedule/index.js +231 -0
  108. package/lib/server/modules/schedule/types.d.ts +1 -0
  109. package/lib/server/modules/schedule/types.js +23 -0
  110. package/lib/server/modules/schedule/utils.d.ts +32 -0
  111. package/lib/server/modules/schedule/utils.js +451 -0
  112. package/lib/server/types.d.ts +64 -0
  113. package/lib/server/types.js +17 -0
  114. package/lib/server/utils/index.d.ts +5 -0
  115. package/lib/server/utils/index.js +25 -0
  116. package/lib/server/utils/product.d.ts +18 -0
  117. package/lib/server/utils/product.js +262 -0
  118. package/lib/server/utils/schedule.d.ts +14 -0
  119. package/lib/server/utils/schedule.js +88 -0
  120. package/lib/server/utils/time.d.ts +18 -0
  121. package/lib/server/utils/time.js +70 -0
  122. package/lib/solution/BookingByStep/index.d.ts +1 -17
  123. package/lib/solution/BookingByStep/index.js +40 -312
  124. package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
  125. package/lib/solution/BookingByStep/utils/capacity.js +8 -21
  126. package/lib/solution/BookingTicket/index.d.ts +12 -0
  127. package/lib/solution/BookingTicket/index.js +25 -6
  128. package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  129. package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
  130. package/lib/solution/BuyTickets/index.js +7 -8
  131. package/lib/solution/Checkout/index.d.ts +1 -46
  132. package/lib/solution/Checkout/index.js +92 -289
  133. package/lib/solution/ShopDiscount/index.js +10 -11
  134. package/lib/types/index.d.ts +27 -0
  135. package/package.json +2 -2
@@ -0,0 +1,94 @@
1
+ import { ProductData } from '../../../modules/Product/types';
2
+ /**
3
+ * Products 模块状态
4
+ */
5
+ export interface ProductsState {
6
+ /** 完整商品列表 */
7
+ list: ProductData[];
8
+ /** 商品 Map 缓存(以 id 为 key,加速查询) */
9
+ map: Map<number, ProductData>;
10
+ }
11
+ /**
12
+ * 商品格式化后数据
13
+ */
14
+ export interface FormattedProductData extends ProductData {
15
+ /** 是否打开详情弹窗 */
16
+ isOpenDetailModal?: boolean;
17
+ /** 购物车详情值 */
18
+ cartDetailValue?: any;
19
+ }
20
+ /**
21
+ * 加载报价单商品价格参数
22
+ */
23
+ export interface LoadProductsPriceParams {
24
+ ids: number[];
25
+ schedule_date: string;
26
+ customer_id?: number;
27
+ }
28
+ /**
29
+ * 加载报价单商品价格返回数据
30
+ */
31
+ export interface LoadProductsPriceData {
32
+ id: number;
33
+ price: string;
34
+ base_price: string;
35
+ variant: {
36
+ id: number;
37
+ product_id: number;
38
+ base_price: number;
39
+ price: number;
40
+ }[];
41
+ bundle_group: {
42
+ id: number;
43
+ bundle_item: {
44
+ id: number;
45
+ product_id: number;
46
+ group_id: number;
47
+ bundle_product_id: number;
48
+ bundle_variant_id: number;
49
+ price: number;
50
+ price_type: string;
51
+ price_type_ext: string;
52
+ }[];
53
+ }[];
54
+ }
55
+ /**
56
+ * 加载报价单商品价格返回数据
57
+ */
58
+ export interface LoadProductsPriceResponse {
59
+ code: number;
60
+ data: LoadProductsPriceData[];
61
+ message: string;
62
+ status: boolean;
63
+ }
64
+ /**
65
+ * Products 模块状态
66
+ */
67
+ export interface ProductsState {
68
+ /** 完整商品列表 */
69
+ list: ProductData[];
70
+ /** 商品 Map 缓存(以 id 为 key,加速查询) */
71
+ map: Map<number, ProductData>;
72
+ }
73
+ /**
74
+ * Products 模块钩子
75
+ */
76
+ export declare enum ProductsHooks {
77
+ onProductsLoaded = "products:onProductsLoaded",
78
+ onProductsChanged = "products:onProductsChanged",
79
+ onProductSelected = "products:onProductSelected",
80
+ onProductsPriceApplied = "products:onProductsPriceApplied"
81
+ }
82
+ /**
83
+ * 商品格式化器上下文
84
+ */
85
+ export interface ProductFormatterContext {
86
+ schedule_date: string;
87
+ priceData?: LoadProductsPriceData[];
88
+ scheduleModule?: any;
89
+ }
90
+ /**
91
+ * 商品格式化器类型
92
+ * 用于对商品数据进行处理和格式化(包括价格应用、字段扩展等)
93
+ */
94
+ export type ProductFormatter = (products: ProductData[], context: ProductFormatterContext) => ProductData[] | Promise<ProductData[]>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Products 模块状态
3
+ */
4
+
5
+ /**
6
+ * 商品格式化后数据
7
+ */
8
+
9
+ /**
10
+ * 加载报价单商品价格参数
11
+ */
12
+
13
+ /**
14
+ * 加载报价单商品价格返回数据
15
+ */
16
+
17
+ /**
18
+ * 加载报价单商品价格返回数据
19
+ */
20
+
21
+ /**
22
+ * Products 模块状态
23
+ */
24
+
25
+ /**
26
+ * Products 模块钩子
27
+ */
28
+ export var ProductsHooks = /*#__PURE__*/function (ProductsHooks) {
29
+ ProductsHooks["onProductsLoaded"] = "products:onProductsLoaded";
30
+ ProductsHooks["onProductsChanged"] = "products:onProductsChanged";
31
+ ProductsHooks["onProductSelected"] = "products:onProductSelected";
32
+ ProductsHooks["onProductsPriceApplied"] = "products:onProductsPriceApplied";
33
+ return ProductsHooks;
34
+ }({});
35
+
36
+ /**
37
+ * 商品格式化器上下文
38
+ */
39
+
40
+ /**
41
+ * 商品格式化器类型
42
+ * 用于对商品数据进行处理和格式化(包括价格应用、字段扩展等)
43
+ */
@@ -0,0 +1,47 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../../types';
2
+ import { BaseModule } from '../../../modules/BaseModule';
3
+ import { QuotationData } from './types';
4
+ /**
5
+ * 报价单模块 - 用于管理报价单数据和计算商品价格
6
+ */
7
+ export declare class QuotationModule extends BaseModule implements Module {
8
+ protected defaultName: string;
9
+ protected defaultVersion: string;
10
+ private request;
11
+ private store;
12
+ private dbManager;
13
+ constructor(name?: string, version?: string);
14
+ initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
+ /**
16
+ * 加载报价单列表(从服务器)
17
+ * TODO: 接口地址待定
18
+ */
19
+ loadQuotationList(): Promise<QuotationData[]>;
20
+ /**
21
+ * 设置报价单列表
22
+ */
23
+ setQuotationList(quotationList: QuotationData[]): Promise<void>;
24
+ /**
25
+ * 获取报价单列表
26
+ */
27
+ getQuotationList(): QuotationData[];
28
+ /**
29
+ * 清空缓存
30
+ */
31
+ clear(): Promise<void>;
32
+ /**
33
+ * 从 IndexDB 加载报价单数据
34
+ * @private
35
+ */
36
+ private loadQuotationFromIndexDB;
37
+ /**
38
+ * 保存报价单数据到 IndexDB
39
+ * @private
40
+ */
41
+ private saveQuotationToIndexDB;
42
+ /**
43
+ * 预加载模块数据(统一接口)
44
+ * 在模块注册后自动调用
45
+ */
46
+ preload(): Promise<void>;
47
+ }
@@ -0,0 +1,367 @@
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
+ 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 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); } }
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); }); }; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
9
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
10
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
12
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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); }
18
+ import { cloneDeep } from 'lodash-es';
19
+ import { BaseModule } from "../../../modules/BaseModule";
20
+ import { QuotationHooks } from "./types";
21
+
22
+ /**
23
+ * IndexDB 存储名称
24
+ */
25
+ var INDEXDB_STORE_NAME = 'quotation';
26
+
27
+ /**
28
+ * 报价单模块 - 用于管理报价单数据和计算商品价格
29
+ */
30
+ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
31
+ _inherits(QuotationModule, _BaseModule);
32
+ var _super = _createSuper(QuotationModule);
33
+ // IndexDBManager 实例
34
+
35
+ function QuotationModule(name, version) {
36
+ var _this;
37
+ _classCallCheck(this, QuotationModule);
38
+ _this = _super.call(this, name, version);
39
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'quotation');
40
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
41
+ _defineProperty(_assertThisInitialized(_this), "request", void 0);
42
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
43
+ _defineProperty(_assertThisInitialized(_this), "dbManager", void 0);
44
+ return _this;
45
+ }
46
+ _createClass(QuotationModule, [{
47
+ key: "initialize",
48
+ value: function () {
49
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
50
+ var _options$initialState;
51
+ var appPlugin, app;
52
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
53
+ while (1) switch (_context.prev = _context.next) {
54
+ case 0:
55
+ this.core = core;
56
+ this.store = options === null || options === void 0 ? void 0 : options.store;
57
+ if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.quotationList)) {
58
+ this.store.quotationList = options === null || options === void 0 ? void 0 : options.initialState.quotationList;
59
+ this.core.effects.emit(QuotationHooks.onQuotationChanged, this.store.quotationList);
60
+ } else {
61
+ this.store.quotationList = [];
62
+ }
63
+
64
+ // 获取依赖的插件
65
+ this.request = core.getPlugin('request');
66
+ if (this.request) {
67
+ _context.next = 6;
68
+ break;
69
+ }
70
+ throw new Error('QuotationModule 需要 request 插件支持');
71
+ case 6:
72
+ // 获取并存储 dbManager
73
+ appPlugin = core.getPlugin('app');
74
+ if (appPlugin) {
75
+ app = appPlugin.getApp();
76
+ this.dbManager = app.dbManager;
77
+ if (this.dbManager) {
78
+ console.log('[Quotation] IndexDB Manager 已初始化');
79
+ } else {
80
+ console.warn('[Quotation] IndexDB Manager 未找到');
81
+ }
82
+ }
83
+ case 8:
84
+ case "end":
85
+ return _context.stop();
86
+ }
87
+ }, _callee, this);
88
+ }));
89
+ function initialize(_x, _x2) {
90
+ return _initialize.apply(this, arguments);
91
+ }
92
+ return initialize;
93
+ }()
94
+ /**
95
+ * 加载报价单列表(从服务器)
96
+ * TODO: 接口地址待定
97
+ */
98
+ }, {
99
+ key: "loadQuotationList",
100
+ value: (function () {
101
+ var _loadQuotationList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
102
+ var _response$data, response, quotationList;
103
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
104
+ while (1) switch (_context2.prev = _context2.next) {
105
+ case 0:
106
+ _context2.prev = 0;
107
+ _context2.next = 3;
108
+ return this.request.get("/quotation", {
109
+ num: 999,
110
+ skip: 1,
111
+ status: 'published'
112
+ });
113
+ case 3:
114
+ response = _context2.sent;
115
+ quotationList = ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || []; // 保存到 IndexDB
116
+ _context2.next = 7;
117
+ return this.saveQuotationToIndexDB(quotationList);
118
+ case 7:
119
+ _context2.next = 9;
120
+ return this.setQuotationList(quotationList);
121
+ case 9:
122
+ return _context2.abrupt("return", quotationList);
123
+ case 12:
124
+ _context2.prev = 12;
125
+ _context2.t0 = _context2["catch"](0);
126
+ console.error('[Quotation] 加载报价单数据失败:', _context2.t0);
127
+ return _context2.abrupt("return", []);
128
+ case 16:
129
+ case "end":
130
+ return _context2.stop();
131
+ }
132
+ }, _callee2, this, [[0, 12]]);
133
+ }));
134
+ function loadQuotationList() {
135
+ return _loadQuotationList.apply(this, arguments);
136
+ }
137
+ return loadQuotationList;
138
+ }()
139
+ /**
140
+ * 设置报价单列表
141
+ */
142
+ )
143
+ }, {
144
+ key: "setQuotationList",
145
+ value: (function () {
146
+ var _setQuotationList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(quotationList) {
147
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
148
+ while (1) switch (_context3.prev = _context3.next) {
149
+ case 0:
150
+ this.store.quotationList = quotationList;
151
+ _context3.next = 3;
152
+ return this.core.effects.emit(QuotationHooks.onQuotationLoaded, quotationList);
153
+ case 3:
154
+ case "end":
155
+ return _context3.stop();
156
+ }
157
+ }, _callee3, this);
158
+ }));
159
+ function setQuotationList(_x3) {
160
+ return _setQuotationList.apply(this, arguments);
161
+ }
162
+ return setQuotationList;
163
+ }()
164
+ /**
165
+ * 获取报价单列表
166
+ */
167
+ )
168
+ }, {
169
+ key: "getQuotationList",
170
+ value: function getQuotationList() {
171
+ return this.store.quotationList;
172
+ }
173
+ /**
174
+ * 清空缓存
175
+ */
176
+ }, {
177
+ key: "clear",
178
+ value: (function () {
179
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
180
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
181
+ while (1) switch (_context4.prev = _context4.next) {
182
+ case 0:
183
+ this.store.quotationList = [];
184
+
185
+ // 同时清空 IndexDB 中的数据
186
+ if (!this.dbManager) {
187
+ _context4.next = 11;
188
+ break;
189
+ }
190
+ _context4.prev = 2;
191
+ _context4.next = 5;
192
+ return this.dbManager.clear(INDEXDB_STORE_NAME);
193
+ case 5:
194
+ console.log('[Quotation] IndexDB 缓存已清空');
195
+ _context4.next = 11;
196
+ break;
197
+ case 8:
198
+ _context4.prev = 8;
199
+ _context4.t0 = _context4["catch"](2);
200
+ console.error('[Quotation] 清空 IndexDB 缓存失败:', _context4.t0);
201
+ case 11:
202
+ console.log('[Quotation] 缓存已清空');
203
+ case 12:
204
+ case "end":
205
+ return _context4.stop();
206
+ }
207
+ }, _callee4, this, [[2, 8]]);
208
+ }));
209
+ function clear() {
210
+ return _clear.apply(this, arguments);
211
+ }
212
+ return clear;
213
+ }()
214
+ /**
215
+ * 从 IndexDB 加载报价单数据
216
+ * @private
217
+ */
218
+ )
219
+ }, {
220
+ key: "loadQuotationFromIndexDB",
221
+ value: (function () {
222
+ var _loadQuotationFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
223
+ var quotationList;
224
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
225
+ while (1) switch (_context5.prev = _context5.next) {
226
+ case 0:
227
+ if (this.dbManager) {
228
+ _context5.next = 2;
229
+ break;
230
+ }
231
+ return _context5.abrupt("return", []);
232
+ case 2:
233
+ _context5.prev = 2;
234
+ _context5.next = 5;
235
+ return this.dbManager.getAll(INDEXDB_STORE_NAME);
236
+ case 5:
237
+ quotationList = _context5.sent;
238
+ return _context5.abrupt("return", quotationList || []);
239
+ case 9:
240
+ _context5.prev = 9;
241
+ _context5.t0 = _context5["catch"](2);
242
+ console.error('[Quotation] 从 IndexDB 读取数据失败:', _context5.t0);
243
+ return _context5.abrupt("return", []);
244
+ case 13:
245
+ case "end":
246
+ return _context5.stop();
247
+ }
248
+ }, _callee5, this, [[2, 9]]);
249
+ }));
250
+ function loadQuotationFromIndexDB() {
251
+ return _loadQuotationFromIndexDB.apply(this, arguments);
252
+ }
253
+ return loadQuotationFromIndexDB;
254
+ }()
255
+ /**
256
+ * 保存报价单数据到 IndexDB
257
+ * @private
258
+ */
259
+ )
260
+ }, {
261
+ key: "saveQuotationToIndexDB",
262
+ value: (function () {
263
+ var _saveQuotationToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(quotationList) {
264
+ var _this2 = this;
265
+ var savePromises;
266
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
267
+ while (1) switch (_context6.prev = _context6.next) {
268
+ case 0:
269
+ if (this.dbManager) {
270
+ _context6.next = 2;
271
+ break;
272
+ }
273
+ return _context6.abrupt("return");
274
+ case 2:
275
+ _context6.prev = 2;
276
+ _context6.next = 5;
277
+ return this.dbManager.clear(INDEXDB_STORE_NAME);
278
+ case 5:
279
+ // 逐个保存报价单(每个报价单是独立的记录)
280
+ savePromises = quotationList.map(function (quotation) {
281
+ return _this2.dbManager.add(INDEXDB_STORE_NAME, quotation);
282
+ });
283
+ _context6.next = 8;
284
+ return Promise.all(savePromises);
285
+ case 8:
286
+ console.log("[Quotation] \u5DF2\u5C06 ".concat(quotationList.length, " \u6761\u62A5\u4EF7\u5355\u6570\u636E\u4FDD\u5B58\u5230 IndexDB"));
287
+ _context6.next = 14;
288
+ break;
289
+ case 11:
290
+ _context6.prev = 11;
291
+ _context6.t0 = _context6["catch"](2);
292
+ console.error('[Quotation] 保存数据到 IndexDB 失败:', _context6.t0);
293
+ case 14:
294
+ case "end":
295
+ return _context6.stop();
296
+ }
297
+ }, _callee6, this, [[2, 11]]);
298
+ }));
299
+ function saveQuotationToIndexDB(_x4) {
300
+ return _saveQuotationToIndexDB.apply(this, arguments);
301
+ }
302
+ return saveQuotationToIndexDB;
303
+ }()
304
+ /**
305
+ * 预加载模块数据(统一接口)
306
+ * 在模块注册后自动调用
307
+ */
308
+ )
309
+ }, {
310
+ key: "preload",
311
+ value: (function () {
312
+ var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
313
+ var cachedData, quotationList;
314
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
315
+ while (1) switch (_context7.prev = _context7.next) {
316
+ case 0:
317
+ console.log('[Quotation] 开始预加载数据...');
318
+ _context7.prev = 1;
319
+ _context7.next = 4;
320
+ return this.loadQuotationFromIndexDB();
321
+ case 4:
322
+ cachedData = _context7.sent;
323
+ if (!(cachedData && cachedData.length > 0)) {
324
+ _context7.next = 10;
325
+ break;
326
+ }
327
+ console.log("[Quotation] \u4ECE IndexDB \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u6761\u62A5\u4EF7\u5355\u6570\u636E"));
328
+ // 将缓存数据放入 store
329
+ this.store.quotationList = cloneDeep(cachedData);
330
+ this.core.effects.emit(QuotationHooks.onQuotationChanged, this.store.quotationList);
331
+ return _context7.abrupt("return");
332
+ case 10:
333
+ console.log('[Quotation] IndexDB 中没有缓存数据,从服务器加载...');
334
+ _context7.next = 16;
335
+ break;
336
+ case 13:
337
+ _context7.prev = 13;
338
+ _context7.t0 = _context7["catch"](1);
339
+ console.warn('[Quotation] 从 IndexDB 加载数据失败:', _context7.t0);
340
+ case 16:
341
+ _context7.next = 18;
342
+ return this.loadQuotationList();
343
+ case 18:
344
+ quotationList = _context7.sent;
345
+ if (!(quotationList && quotationList.length > 0)) {
346
+ _context7.next = 24;
347
+ break;
348
+ }
349
+ _context7.next = 22;
350
+ return this.saveQuotationToIndexDB(quotationList);
351
+ case 22:
352
+ this.store.quotationList = cloneDeep(quotationList);
353
+ this.core.effects.emit(QuotationHooks.onQuotationChanged, this.store.quotationList);
354
+ case 24:
355
+ case "end":
356
+ return _context7.stop();
357
+ }
358
+ }, _callee7, this, [[1, 13]]);
359
+ }));
360
+ function preload() {
361
+ return _preload.apply(this, arguments);
362
+ }
363
+ return preload;
364
+ }())
365
+ }]);
366
+ return QuotationModule;
367
+ }(BaseModule);
@@ -0,0 +1,50 @@
1
+ /**
2
+ * 报价单模块状态
3
+ */
4
+ export interface QuotationState {
5
+ /** 报价单列表 */
6
+ quotationList: QuotationData[];
7
+ }
8
+ /**
9
+ * 报价单数据结构
10
+ */
11
+ export interface QuotationData {
12
+ /** 报价单 ID */
13
+ id: number;
14
+ /** 报价单名称 */
15
+ name: string;
16
+ /** 绑定的日程 ID 列表 */
17
+ schedule_ids: number[];
18
+ /** 商品价格配置列表 */
19
+ product_prices: QuotationProductPrice[];
20
+ /** 状态 */
21
+ status: 'active' | 'inactive';
22
+ /** 优先级(多个报价单同时生效时使用) */
23
+ priority: number;
24
+ /** 创建时间 */
25
+ created_at: string;
26
+ /** 更新时间 */
27
+ updated_at: string;
28
+ }
29
+ /**
30
+ * 报价单商品价格配置
31
+ */
32
+ export interface QuotationProductPrice {
33
+ /** 商品 ID */
34
+ product_id: number;
35
+ /** 规格 ID(可选,针对有规格的商品) */
36
+ variant_id?: number;
37
+ /** 折扣类型:fixed 固定价格,percentage 百分比折扣 */
38
+ discount_type: 'fixed' | 'percentage';
39
+ /** 折扣价格或百分比 */
40
+ discount_value: string;
41
+ /** 最终价格(仅当 discount_type 为 fixed 时) */
42
+ final_price?: string;
43
+ }
44
+ /**
45
+ * 报价单模块钩子
46
+ */
47
+ export declare enum QuotationHooks {
48
+ onQuotationLoaded = "quotation:onQuotationLoaded",
49
+ onQuotationChanged = "quotation:onQuotationChanged"
50
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 报价单模块状态
3
+ */
4
+
5
+ /**
6
+ * 报价单数据结构
7
+ */
8
+
9
+ /**
10
+ * 报价单商品价格配置
11
+ */
12
+
13
+ /**
14
+ * 报价单模块钩子
15
+ */
16
+ export var QuotationHooks = /*#__PURE__*/function (QuotationHooks) {
17
+ QuotationHooks["onQuotationLoaded"] = "quotation:onQuotationLoaded";
18
+ QuotationHooks["onQuotationChanged"] = "quotation:onQuotationChanged";
19
+ return QuotationHooks;
20
+ }({});