@pisell/pisellos 0.10.7 → 0.10.9
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.
- package/dist/core/index.js +0 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +18 -12
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +32 -6
- package/dist/modules/Order/index.js +1165 -819
- package/dist/modules/Order/types.d.ts +32 -4
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/dist/modules/Order/utils/virtualSettlement.js +271 -0
- package/dist/modules/Order/utils.js +89 -48
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/modules/Payment/utils.js +4 -1
- package/dist/modules/Payment/walletpass.d.ts +11 -0
- package/dist/modules/Payment/walletpass.js +235 -60
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +15 -2
- package/dist/modules/ProductList/index.js +92 -13
- package/dist/modules/Rules/index.js +125 -52
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +28 -2
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +894 -781
- package/dist/server/modules/order/index.d.ts +2 -0
- package/dist/server/modules/order/index.js +261 -96
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +41 -7
- package/dist/solution/BaseSales/index.js +1405 -974
- package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +79 -13
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +3 -3
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- package/dist/solution/BookingTicket/index.js +221 -162
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/index.js +25 -64
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +51 -39
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +6 -1
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +37 -3
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +32 -6
- package/lib/modules/Order/index.js +518 -148
- package/lib/modules/Order/types.d.ts +32 -4
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
- package/lib/modules/Order/utils/virtualSettlement.js +300 -0
- package/lib/modules/Order/utils.js +65 -21
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/utils.js +5 -1
- package/lib/modules/Payment/walletpass.d.ts +11 -0
- package/lib/modules/Payment/walletpass.js +198 -17
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +15 -2
- package/lib/modules/ProductList/index.js +85 -3
- package/lib/modules/Rules/index.js +100 -20
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +10 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +30 -2
- package/lib/server/index.d.ts +15 -0
- package/lib/server/index.js +105 -14
- package/lib/server/modules/order/index.d.ts +2 -0
- package/lib/server/modules/order/index.js +75 -5
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +41 -7
- package/lib/solution/BaseSales/index.js +325 -39
- package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +62 -12
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +3 -3
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +31 -6
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/index.js +17 -54
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +35 -26
- package/package.json +1 -1
|
@@ -18,6 +18,19 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
18
18
|
* productList.updateOtherParams({ channel: 'pos' });
|
|
19
19
|
*/
|
|
20
20
|
updateOtherParams(params: Record<string, any>): void;
|
|
21
|
+
/**
|
|
22
|
+
* 判断当前商品查询是否会被本地 OS Server 接管。
|
|
23
|
+
*
|
|
24
|
+
* 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
|
|
25
|
+
* 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
|
|
26
|
+
* Data Variant 评估。
|
|
27
|
+
*/
|
|
28
|
+
private isProductQueryHandledByOsServer;
|
|
29
|
+
/**
|
|
30
|
+
* 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
|
|
31
|
+
* OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
|
|
32
|
+
*/
|
|
33
|
+
private resolveClientDataVariants;
|
|
21
34
|
storeChange(path?: string, value?: any): Promise<void>;
|
|
22
35
|
/**
|
|
23
36
|
* 获取加时商品列表。
|
|
@@ -25,11 +38,11 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
25
38
|
* @example
|
|
26
39
|
* const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
|
|
27
40
|
*/
|
|
28
|
-
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<
|
|
41
|
+
getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<ProductData[]>;
|
|
29
42
|
loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
|
|
30
43
|
callback?: (result: any) => void;
|
|
31
44
|
subscriberId?: string;
|
|
32
|
-
}): Promise<
|
|
45
|
+
}): Promise<ProductData[]>;
|
|
33
46
|
loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
|
|
34
47
|
ids?: number[];
|
|
35
48
|
customer_id?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
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
1
|
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; }
|
|
3
2
|
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; }
|
|
3
|
+
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); }
|
|
4
4
|
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; }
|
|
5
5
|
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
6
|
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); }); }; }
|
|
@@ -78,6 +78,64 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
78
78
|
value: function updateOtherParams(params) {
|
|
79
79
|
this.otherParams = params || {};
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 判断当前商品查询是否会被本地 OS Server 接管。
|
|
84
|
+
*
|
|
85
|
+
* 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
|
|
86
|
+
* 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
|
|
87
|
+
* Data Variant 评估。
|
|
88
|
+
*/
|
|
89
|
+
}, {
|
|
90
|
+
key: "isProductQueryHandledByOsServer",
|
|
91
|
+
value: function isProductQueryHandledByOsServer() {
|
|
92
|
+
var _this$core, _this$request;
|
|
93
|
+
var server = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.server;
|
|
94
|
+
if (!server || typeof server.hasRoute !== 'function') return false;
|
|
95
|
+
var requestBaseUrl = String(((_this$request = this.request) === null || _this$request === void 0 ? void 0 : _this$request.baseUrl) || '/shop').replace(/\/+$/, '');
|
|
96
|
+
var routePath = "".concat(requestBaseUrl, "/product/query");
|
|
97
|
+
return server.hasRoute('post', routePath) === true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
|
|
102
|
+
* OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
|
|
103
|
+
*/
|
|
104
|
+
}, {
|
|
105
|
+
key: "resolveClientDataVariants",
|
|
106
|
+
value: function resolveClientDataVariants(products, queryPayload, handledByOsServer) {
|
|
107
|
+
var _this$core2, _this$otherParams, _scheduleModule$getSc, _this$core3, _this$core4, _this$otherParams2, _strategyContext$busi;
|
|
108
|
+
if (handledByOsServer || products.length === 0) return products;
|
|
109
|
+
var evaluator = (_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.context) === null || _this$core2 === void 0 ? void 0 : _this$core2.dataVariantEvaluator;
|
|
110
|
+
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
111
|
+
return products;
|
|
112
|
+
}
|
|
113
|
+
var strategyContext = queryPayload.strategy_context && _typeof(queryPayload.strategy_context) === 'object' ? queryPayload.strategy_context : {};
|
|
114
|
+
var fatherModule = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.fatherModule) || '').trim();
|
|
115
|
+
var scheduleModule = (fatherModule ? this.core.getModule("".concat(fatherModule, "_schedule")) : null) || this.core.getModule('schedule');
|
|
116
|
+
var scheduleList = scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule);
|
|
117
|
+
var contextScheduleList = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.scheduleList;
|
|
118
|
+
var contextMenuList = (_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.menuList;
|
|
119
|
+
var businessData = {
|
|
120
|
+
products: products,
|
|
121
|
+
scheduleDateTime: queryPayload.schedule_datetime || queryPayload.schedule_date,
|
|
122
|
+
scheduleList: Array.isArray(scheduleList) ? scheduleList : Array.isArray(contextScheduleList) ? contextScheduleList : [],
|
|
123
|
+
menuList: Array.isArray((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.menuList) ? this.otherParams.menuList : Array.isArray(contextMenuList) ? contextMenuList : [],
|
|
124
|
+
customerId: queryPayload.customer_id,
|
|
125
|
+
channel: strategyContext.channel,
|
|
126
|
+
orderType: strategyContext.orderType || strategyContext.order_type,
|
|
127
|
+
businessCode: (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : strategyContext.businessCode,
|
|
128
|
+
availableWalletIds: strategyContext.available_wallet_ids,
|
|
129
|
+
custom: strategyContext
|
|
130
|
+
};
|
|
131
|
+
try {
|
|
132
|
+
var _result = evaluator.resolveProducts(businessData);
|
|
133
|
+
return Array.isArray(_result === null || _result === void 0 ? void 0 : _result.products) ? _result.products : products;
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error('[ProductList] Data Variant 客户端解析失败', error);
|
|
136
|
+
return products;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
81
139
|
}, {
|
|
82
140
|
key: "storeChange",
|
|
83
141
|
value: function () {
|
|
@@ -132,7 +190,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
132
190
|
key: "loadProducts",
|
|
133
191
|
value: function () {
|
|
134
192
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
135
|
-
var _this$
|
|
193
|
+
var _this$otherParams3,
|
|
194
|
+
_this2 = this;
|
|
136
195
|
var _ref,
|
|
137
196
|
_ref$category_ids,
|
|
138
197
|
category_ids,
|
|
@@ -161,7 +220,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
161
220
|
rawApplicationCode,
|
|
162
221
|
mappedApplicationCode,
|
|
163
222
|
queryPayload,
|
|
223
|
+
handledByOsServer,
|
|
224
|
+
callback,
|
|
164
225
|
productsData,
|
|
226
|
+
resolvedList,
|
|
165
227
|
sortedList,
|
|
166
228
|
_args4 = arguments;
|
|
167
229
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
@@ -196,7 +258,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
258
|
scan_to_order_2: 'mobile_order',
|
|
197
259
|
scan_to_order_3: 'scantoorder3'
|
|
198
260
|
};
|
|
199
|
-
rawApplicationCode = (_this$
|
|
261
|
+
rawApplicationCode = (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
|
|
200
262
|
mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
|
|
201
263
|
queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
202
264
|
open_quotation: 1,
|
|
@@ -225,18 +287,35 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
225
287
|
is_eject: 1,
|
|
226
288
|
with_schedule: with_schedule,
|
|
227
289
|
schedule_datetime: schedule_datetime,
|
|
228
|
-
extension_type: extension_type
|
|
290
|
+
extension_type: extension_type,
|
|
291
|
+
strategy_context: strategy_context
|
|
229
292
|
});
|
|
230
|
-
|
|
293
|
+
handledByOsServer = this.isProductQueryHandledByOsServer();
|
|
294
|
+
callback = !handledByOsServer && typeof (options === null || options === void 0 ? void 0 : options.callback) === 'function' ? function (result) {
|
|
295
|
+
var _result$data, _options$callback2;
|
|
296
|
+
var callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
|
|
297
|
+
if (!Array.isArray(callbackList)) {
|
|
298
|
+
var _options$callback;
|
|
299
|
+
(_options$callback = options.callback) === null || _options$callback === void 0 || _options$callback.call(options, result);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
(_options$callback2 = options.callback) === null || _options$callback2 === void 0 || _options$callback2.call(options, _objectSpread(_objectSpread({}, result), {}, {
|
|
303
|
+
data: _objectSpread(_objectSpread({}, result.data), {}, {
|
|
304
|
+
list: _this2.resolveClientDataVariants(callbackList, queryPayload, false)
|
|
305
|
+
})
|
|
306
|
+
}));
|
|
307
|
+
} : options === null || options === void 0 ? void 0 : options.callback;
|
|
308
|
+
_context4.next = 13;
|
|
231
309
|
return this.request.post("/product/query", queryPayload, {
|
|
232
310
|
osServer: true,
|
|
233
|
-
callback:
|
|
311
|
+
callback: callback,
|
|
234
312
|
subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
|
|
235
313
|
customToast: function customToast() {}
|
|
236
314
|
});
|
|
237
|
-
case
|
|
315
|
+
case 13:
|
|
238
316
|
productsData = _context4.sent;
|
|
239
|
-
|
|
317
|
+
resolvedList = this.resolveClientDataVariants(productsData.data.list || [], queryPayload, handledByOsServer);
|
|
318
|
+
sortedList = resolvedList.slice().sort(function (a, b) {
|
|
240
319
|
return Number(b.sort) - Number(a.sort);
|
|
241
320
|
}); // if (sortedList.length) {
|
|
242
321
|
// sortedList.forEach((n: any) => {
|
|
@@ -247,7 +326,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
247
326
|
// }
|
|
248
327
|
this.addProduct(sortedList);
|
|
249
328
|
return _context4.abrupt("return", sortedList);
|
|
250
|
-
case
|
|
329
|
+
case 18:
|
|
251
330
|
case "end":
|
|
252
331
|
return _context4.stop();
|
|
253
332
|
}
|
|
@@ -368,7 +447,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
368
447
|
key: "addProduct",
|
|
369
448
|
value: function () {
|
|
370
449
|
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
|
|
371
|
-
var
|
|
450
|
+
var _this3 = this;
|
|
372
451
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
373
452
|
while (1) switch (_context9.prev = _context9.next) {
|
|
374
453
|
case 0:
|
|
@@ -377,13 +456,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
377
456
|
this.store.list = [];
|
|
378
457
|
}
|
|
379
458
|
products.forEach(function (n) {
|
|
380
|
-
var index =
|
|
459
|
+
var index = _this3.store.list.findIndex(function (m) {
|
|
381
460
|
return m.id === n.id;
|
|
382
461
|
});
|
|
383
462
|
if (index === -1) {
|
|
384
|
-
|
|
463
|
+
_this3.store.list.push(n);
|
|
385
464
|
} else {
|
|
386
|
-
|
|
465
|
+
_this3.store.list[index] = n;
|
|
387
466
|
}
|
|
388
467
|
});
|
|
389
468
|
// 根据 sort 值做降序排序(数字越大越靠前)
|
|
@@ -366,7 +366,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
366
366
|
var discountType = selectedDiscount.tag || selectedDiscount.type;
|
|
367
367
|
return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
368
368
|
};
|
|
369
|
-
var
|
|
369
|
+
var resolveReapplyBookingDiscountPercent = function resolveReapplyBookingDiscountPercent(originProduct, selectedDiscount) {
|
|
370
370
|
var _discount2;
|
|
371
371
|
if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
|
|
372
372
|
var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
|
|
@@ -454,6 +454,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
454
454
|
bundleIndex: bundleIndex,
|
|
455
455
|
// 虚拟商品属性
|
|
456
456
|
price: Number(bundleItem.price || 0),
|
|
457
|
+
// 新增商品运行态通常带 _bundle_product_id;订单 hydrate 后只有
|
|
458
|
+
// bundle_product_id。Change time 必须兼容两种结构,否则 bundle
|
|
459
|
+
// 子项无法命中折扣卡的 limited_relation_product_data.product_ids。
|
|
457
460
|
id: (_ref3 = (_bundleItem$bundle_pr = bundleItem.bundle_product_id) !== null && _bundleItem$bundle_pr !== void 0 ? _bundleItem$bundle_pr : bundleItem._bundle_product_id) !== null && _ref3 !== void 0 ? _ref3 : bundleItem.product_id,
|
|
458
461
|
_id: "".concat(product._id, "_bundle_").concat(bundleIndex),
|
|
459
462
|
parentId: product._id,
|
|
@@ -1095,11 +1098,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1095
1098
|
if (isPersistedProduct && hasExistingWalletDiscount) {
|
|
1096
1099
|
if (flatItem.type === 'main') {
|
|
1097
1100
|
processedProductsMap.set(product._id, [originProduct]);
|
|
1098
|
-
} else {
|
|
1099
|
-
processedFlatItemsMap.set(flatItem._id, [_objectSpread(_objectSpread({}, flatItem), {}, {
|
|
1100
|
-
processed: true
|
|
1101
|
-
})]);
|
|
1102
1101
|
}
|
|
1102
|
+
// bundle 虚拟项没有携带完整的历史价格字段。这里不写入 processed map,
|
|
1103
|
+
// 重组阶段会直接保留原始 bundleItem,避免把 bundle_selling_price
|
|
1104
|
+
// 覆盖为未折扣的 price,导致已支付金额再次进入应付。
|
|
1103
1105
|
return;
|
|
1104
1106
|
}
|
|
1105
1107
|
|
|
@@ -1184,19 +1186,42 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1184
1186
|
return false;
|
|
1185
1187
|
});
|
|
1186
1188
|
|
|
1187
|
-
//
|
|
1189
|
+
// 用户显式点击某张卡券时,本次选择优先于自动排序和扫码默认选择。
|
|
1188
1190
|
// 目标仍必须在当前商品的 applicableDiscounts 中,因此不会绕过 Holder、时间或商品范围校验。
|
|
1189
|
-
var
|
|
1191
|
+
var explicitlySelectedDiscount = (options === null || options === void 0 ? void 0 : options.isSelected) === true && options.discountId !== undefined ? applicableDiscounts.find(function (discount) {
|
|
1190
1192
|
var discountType = discount.tag || discount.type;
|
|
1191
|
-
return String(discount.id) === String(options.discountId) && ['discount_card', 'product_discount_card'].includes(discountType);
|
|
1193
|
+
return String(discount.id) === String(options.discountId) && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
|
|
1192
1194
|
}) : undefined;
|
|
1195
|
+
// 折扣卡会复用于整条商品行;商品券必须继续按单张拆分,不能复用该分支。
|
|
1196
|
+
var explicitlySelectedDiscountCard = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) !== 'good_pass' ? explicitlySelectedDiscount : undefined;
|
|
1197
|
+
|
|
1198
|
+
// 商品数量等变化会触发无 discountId 的重算。只要当前行已应用的折扣卡仍在
|
|
1199
|
+
// applicableDiscounts 中,就应保留该行选择,避免被自动排序中力度更大的卡替换。
|
|
1200
|
+
var appliedDiscountCardIds = new Set((product.discount_list || []).filter(function (item) {
|
|
1201
|
+
return ['discount_card', 'product_discount_card'].includes((item === null || item === void 0 ? void 0 : item.tag) || (item === null || item === void 0 ? void 0 : item.type));
|
|
1202
|
+
}).map(function (item) {
|
|
1203
|
+
var _ref12, _item$discount$resour, _item$discount;
|
|
1204
|
+
return (_ref12 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref12 !== void 0 ? _ref12 : item === null || item === void 0 ? void 0 : item.id;
|
|
1205
|
+
}).filter(function (id) {
|
|
1206
|
+
return id !== undefined && id !== null;
|
|
1207
|
+
}).map(String));
|
|
1208
|
+
var appliedDiscountCard = options !== null && options !== void 0 && options.scan ? undefined : applicableDiscounts.find(function (discount) {
|
|
1209
|
+
var discountType = discount.tag || discount.type;
|
|
1210
|
+
return discount.isSelected === true && ['discount_card', 'product_discount_card'].includes(discountType) && appliedDiscountCardIds.has(String(discount.id));
|
|
1211
|
+
});
|
|
1193
1212
|
|
|
1194
|
-
//
|
|
1213
|
+
// 优先级:本次显式选择 > 当前行既有选择 > 扫码选择 > 自动排序第一项。
|
|
1195
1214
|
var scannedSelectedDiscountCard = applicableDiscounts.find(function (n) {
|
|
1196
1215
|
return n.isScan && n.isSelected && (n.tag || n.type) !== 'good_pass';
|
|
1197
1216
|
});
|
|
1198
|
-
var selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
1199
|
-
var selectedDiscount = selectedDiscountCard || applicableDiscounts[0];
|
|
1217
|
+
var selectedDiscountCard = explicitlySelectedDiscountCard || appliedDiscountCard || scannedSelectedDiscountCard;
|
|
1218
|
+
var selectedDiscount = explicitlySelectedDiscount || selectedDiscountCard || applicableDiscounts[0];
|
|
1219
|
+
var prioritizedApplicableDiscounts = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) === 'good_pass' ? [explicitlySelectedDiscount].concat(_toConsumableArray(applicableDiscounts.filter(function (discount) {
|
|
1220
|
+
var discountType = discount.tag || discount.type;
|
|
1221
|
+
return discountType === 'good_pass' && String(discount.id) !== String(explicitlySelectedDiscount.id);
|
|
1222
|
+
})), _toConsumableArray(applicableDiscounts.filter(function (discount) {
|
|
1223
|
+
return (discount.tag || discount.type) !== 'good_pass';
|
|
1224
|
+
}))) : applicableDiscounts;
|
|
1200
1225
|
|
|
1201
1226
|
// 如果是手动折扣,则不适用优惠券
|
|
1202
1227
|
var isManualDiscount = false;
|
|
@@ -1207,8 +1232,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1207
1232
|
isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : ((_product$discount_lis5 = product.discount_list) === null || _product$discount_lis5 === void 0 ? void 0 : _product$discount_lis5.some(function (item) {
|
|
1208
1233
|
return item.type === 'product';
|
|
1209
1234
|
})) || product.total != product.origin_total && (product.bundle || []).every(function (item) {
|
|
1210
|
-
var
|
|
1211
|
-
return !((
|
|
1235
|
+
var _ref13;
|
|
1236
|
+
return !((_ref13 = item.discount_list || []) !== null && _ref13 !== void 0 && _ref13.length);
|
|
1212
1237
|
}) && (!((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
|
|
1213
1238
|
return item.type === 'product';
|
|
1214
1239
|
})));
|
|
@@ -1224,8 +1249,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1224
1249
|
isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : ((_parentProduct$discou = parentProduct.discount_list) === null || _parentProduct$discou === void 0 ? void 0 : _parentProduct$discou.some(function (item) {
|
|
1225
1250
|
return item.type === 'product';
|
|
1226
1251
|
})) || parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
|
|
1227
|
-
var
|
|
1228
|
-
return !((
|
|
1252
|
+
var _ref14;
|
|
1253
|
+
return !((_ref14 = item.discount_list || []) !== null && _ref14 !== void 0 && _ref14.length);
|
|
1229
1254
|
}) && (!((_parentProduct$discou2 = parentProduct.discount_list) !== null && _parentProduct$discou2 !== void 0 && _parentProduct$discou2.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou3 = parentProduct.discount_list) === null || _parentProduct$discou3 === void 0 || (_parentProduct$discou4 = _parentProduct$discou3.every) === null || _parentProduct$discou4 === void 0 ? void 0 : _parentProduct$discou4.call(_parentProduct$discou3, function (item) {
|
|
1230
1255
|
return item.type === 'product';
|
|
1231
1256
|
})));
|
|
@@ -1237,8 +1262,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1237
1262
|
var _product$discount_lis7;
|
|
1238
1263
|
// 主商品:检查自己的 discount_list
|
|
1239
1264
|
if (flatItem.type === 'main' && (_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
|
|
1240
|
-
var _item$
|
|
1241
|
-
return ((_item$
|
|
1265
|
+
var _item$discount2;
|
|
1266
|
+
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
1242
1267
|
})) {
|
|
1243
1268
|
isManualDiscount = false;
|
|
1244
1269
|
}
|
|
@@ -1246,11 +1271,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1246
1271
|
if (flatItem.type === 'bundle') {
|
|
1247
1272
|
var _product$discount_lis8, _flatItem$parentProdu7;
|
|
1248
1273
|
if ((_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
|
|
1249
|
-
var _item$discount2;
|
|
1250
|
-
return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
|
|
1251
|
-
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1252
1274
|
var _item$discount3;
|
|
1253
1275
|
return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
|
|
1276
|
+
}) || (_flatItem$parentProdu7 = flatItem.parentProduct) !== null && _flatItem$parentProdu7 !== void 0 && (_flatItem$parentProdu7 = _flatItem$parentProdu7.discount_list) !== null && _flatItem$parentProdu7 !== void 0 && _flatItem$parentProdu7.some(function (item) {
|
|
1277
|
+
var _item$discount4;
|
|
1278
|
+
return ((_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.resource_id) === options.discountId;
|
|
1254
1279
|
})) {
|
|
1255
1280
|
isManualDiscount = false;
|
|
1256
1281
|
}
|
|
@@ -1262,8 +1287,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1262
1287
|
if (flatItem.type === 'main' && (_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
|
|
1263
1288
|
var _options$selectedList2;
|
|
1264
1289
|
return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
|
|
1265
|
-
var _item$
|
|
1266
|
-
return n.discountId === ((_item$
|
|
1290
|
+
var _item$discount5;
|
|
1291
|
+
return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
|
|
1267
1292
|
});
|
|
1268
1293
|
})) {
|
|
1269
1294
|
isManualDiscount = false;
|
|
@@ -1274,14 +1299,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1274
1299
|
if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.some(function (item) {
|
|
1275
1300
|
var _options$selectedList3;
|
|
1276
1301
|
return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
|
|
1277
|
-
var _item$
|
|
1278
|
-
return n.discountId === ((_item$
|
|
1302
|
+
var _item$discount6;
|
|
1303
|
+
return n.discountId === ((_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.resource_id);
|
|
1279
1304
|
});
|
|
1280
1305
|
}) || (_flatItem$parentProdu8 = flatItem.parentProduct) !== null && _flatItem$parentProdu8 !== void 0 && (_flatItem$parentProdu8 = _flatItem$parentProdu8.discount_list) !== null && _flatItem$parentProdu8 !== void 0 && _flatItem$parentProdu8.some(function (item) {
|
|
1281
1306
|
var _options$selectedList4;
|
|
1282
1307
|
return options === null || options === void 0 || (_options$selectedList4 = options.selectedList) === null || _options$selectedList4 === void 0 ? void 0 : _options$selectedList4.some(function (n) {
|
|
1283
|
-
var _item$
|
|
1284
|
-
return n.discountId === ((_item$
|
|
1308
|
+
var _item$discount7;
|
|
1309
|
+
return n.discountId === ((_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.resource_id);
|
|
1285
1310
|
});
|
|
1286
1311
|
})) {
|
|
1287
1312
|
isManualDiscount = false;
|
|
@@ -1318,8 +1343,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1318
1343
|
discount_list: isManualDiscount ? _this4.resolveDiscountListForManualOverride(product.discount_list) : _this4.filterDiscountListByType(product.discount_list, 'promotion')
|
|
1319
1344
|
}))]);
|
|
1320
1345
|
} else {
|
|
1321
|
-
var
|
|
1322
|
-
var total = product.inPromotion ? (
|
|
1346
|
+
var _ref15, _product$_promotion$f, _product12, _product$origin_total;
|
|
1347
|
+
var total = product.inPromotion ? (_ref15 = (_product$_promotion$f = (_product12 = product) === null || _product12 === void 0 || (_product12 = _product12._promotion) === null || _product12 === void 0 ? void 0 : _product12.finalPrice) !== null && _product$_promotion$f !== void 0 ? _product$_promotion$f : product.origin_total) !== null && _ref15 !== void 0 ? _ref15 : product.total : (_product$origin_total = product.origin_total) !== null && _product$origin_total !== void 0 ? _product$origin_total : product.total;
|
|
1323
1348
|
var main_product_selling_price = product.price;
|
|
1324
1349
|
if ((product.discount_list || []).some(function (item) {
|
|
1325
1350
|
return item.type === 'promotion';
|
|
@@ -1380,7 +1405,44 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1380
1405
|
if (flatItem.type === 'main') {
|
|
1381
1406
|
// 主商品:保持原有逻辑
|
|
1382
1407
|
if (splitCount < totalQuantity && isNeedSplit) {
|
|
1383
|
-
var _product$origin_total2;
|
|
1408
|
+
var _product$origin_total2, _product$main_product2;
|
|
1409
|
+
var remainingQuantity = totalQuantity - splitCount;
|
|
1410
|
+
var applicableNonGoodPassById = new Map(applicableDiscounts.filter(function (discount) {
|
|
1411
|
+
return (discount.tag || discount.type) !== 'good_pass';
|
|
1412
|
+
}).map(function (discount) {
|
|
1413
|
+
return [String(discount.id), discount];
|
|
1414
|
+
}));
|
|
1415
|
+
var remainderDiscountList = (product.discount_list || []).filter(function (discount) {
|
|
1416
|
+
var _discount$discount$re, _discount$discount5;
|
|
1417
|
+
var discountType = discount.tag || discount.type;
|
|
1418
|
+
if (discountType === 'promotion') return true;
|
|
1419
|
+
if (discountType === 'good_pass') return false;
|
|
1420
|
+
var resourceId = (_discount$discount$re = (_discount$discount5 = discount.discount) === null || _discount$discount5 === void 0 ? void 0 : _discount$discount5.resource_id) !== null && _discount$discount$re !== void 0 ? _discount$discount$re : discount.id;
|
|
1421
|
+
return resourceId !== undefined && resourceId !== null && applicableNonGoodPassById.has(String(resourceId));
|
|
1422
|
+
}).map(function (discount) {
|
|
1423
|
+
var _discount$discount$re2, _discount$discount6;
|
|
1424
|
+
if ((discount.tag || discount.type) === 'promotion') return discount;
|
|
1425
|
+
var resourceId = (_discount$discount$re2 = (_discount$discount6 = discount.discount) === null || _discount$discount6 === void 0 ? void 0 : _discount$discount6.resource_id) !== null && _discount$discount$re2 !== void 0 ? _discount$discount$re2 : discount.id;
|
|
1426
|
+
var matchedDiscount = applicableNonGoodPassById.get(String(resourceId));
|
|
1427
|
+
if (matchedDiscount) {
|
|
1428
|
+
// 实际场景:3 件折扣卡商品中拆出 1 件改用商品券后,
|
|
1429
|
+
// 剩余 2 件仍在使用原折扣卡;必须同步登记折扣卡的使用状态,
|
|
1430
|
+
// 否则 updatedDiscountList 会把它改成未选中并清空 savedAmount。
|
|
1431
|
+
usedDiscounts.set(matchedDiscount.id, true);
|
|
1432
|
+
var appliedProducts = appliedDiscountProducts.get(matchedDiscount.id) || [];
|
|
1433
|
+
appliedProducts.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
1434
|
+
_num: remainingQuantity
|
|
1435
|
+
}));
|
|
1436
|
+
appliedDiscountProducts.set(matchedDiscount.id, appliedProducts);
|
|
1437
|
+
}
|
|
1438
|
+
return _objectSpread(_objectSpread({}, discount), {}, {
|
|
1439
|
+
// _num 是 Rules 运行态的行数量;Order 写回 tempOrder 时会裁剪该字段。
|
|
1440
|
+
_num: remainingQuantity
|
|
1441
|
+
});
|
|
1442
|
+
});
|
|
1443
|
+
var hasRetainedWalletDiscount = remainderDiscountList.some(function (discount) {
|
|
1444
|
+
return !['promotion', 'good_pass'].includes(discount.tag || discount.type);
|
|
1445
|
+
});
|
|
1384
1446
|
var _total = (_product$origin_total2 = product.origin_total) !== null && _product$origin_total2 !== void 0 ? _product$origin_total2 : product.total;
|
|
1385
1447
|
if ((product.discount_list || []).some(function (item) {
|
|
1386
1448
|
return item.type === 'promotion';
|
|
@@ -1388,17 +1450,20 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1388
1450
|
var _product$total2;
|
|
1389
1451
|
_total = (_product$total2 = product.total) !== null && _product$total2 !== void 0 ? _product$total2 : product.origin_total;
|
|
1390
1452
|
}
|
|
1391
|
-
arr.push(_this4.hooks.setProduct(originProduct, {
|
|
1392
|
-
|
|
1393
|
-
|
|
1453
|
+
arr.push(_this4.hooks.setProduct(originProduct, _objectSpread({
|
|
1454
|
+
// 商品券只替换被拆出的 splitCount 件。余量行原本仍有效的折扣卡
|
|
1455
|
+
// 不能随 good_pass 拆分一起清除;已取消或已失效的折扣不会进入此列表。
|
|
1456
|
+
discount_list: remainderDiscountList,
|
|
1457
|
+
quantity: remainingQuantity,
|
|
1394
1458
|
_id: product._id.split('___')[0],
|
|
1395
1459
|
total: _total
|
|
1396
|
-
}
|
|
1460
|
+
}, hasRetainedWalletDiscount ? {
|
|
1461
|
+
main_product_selling_price: (_product$main_product2 = product.main_product_selling_price) !== null && _product$main_product2 !== void 0 ? _product$main_product2 : product.price
|
|
1462
|
+
} : {})));
|
|
1397
1463
|
}
|
|
1398
1464
|
for (var i = 0; i < splitCount; i++) {
|
|
1399
1465
|
var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2, _reapplyDiscountPerce;
|
|
1400
|
-
|
|
1401
|
-
var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
|
|
1466
|
+
var _selectedDiscount = isNeedSplit ? prioritizedApplicableDiscounts[i] : selectedDiscountCard || applicableDiscounts[i];
|
|
1402
1467
|
// 标记优惠券为已使用
|
|
1403
1468
|
usedDiscounts.set(_selectedDiscount.id, true);
|
|
1404
1469
|
// 🔥 更新 product_id 使用计数
|
|
@@ -1440,9 +1505,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1440
1505
|
amount = productAllocation.discountAmount;
|
|
1441
1506
|
productDiscountDifference = productAllocation.difference;
|
|
1442
1507
|
mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
|
|
1443
|
-
} else if (
|
|
1508
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
|
|
1444
1509
|
// Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
|
|
1445
|
-
var percent =
|
|
1510
|
+
var percent = resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount);
|
|
1446
1511
|
reapplyDiscountPercent = new Decimal(percent).toFixed(2);
|
|
1447
1512
|
mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1448
1513
|
amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
|
|
@@ -1543,7 +1608,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1543
1608
|
// 生成有折扣的商品(每张商品券对应 num: 1)
|
|
1544
1609
|
for (var _i = 0; _i < discountNum; _i++) {
|
|
1545
1610
|
var _selectedDiscount2$me;
|
|
1546
|
-
var _selectedDiscount2 =
|
|
1611
|
+
var _selectedDiscount2 = prioritizedApplicableDiscounts[_i];
|
|
1547
1612
|
usedDiscounts.set(_selectedDiscount2.id, true);
|
|
1548
1613
|
// 🔥 更新 product_id 使用计数
|
|
1549
1614
|
if ((_selectedDiscount2.tag || _selectedDiscount2.type) === 'good_pass') {
|
|
@@ -1610,7 +1675,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1610
1675
|
}));
|
|
1611
1676
|
}
|
|
1612
1677
|
} else {
|
|
1613
|
-
var _selectedDiscount3$me, _selectedDiscount3$me2, _flatItem$parentProdu9;
|
|
1678
|
+
var _selectedDiscount3$me, _selectedDiscount3$me2, _reapplyDiscountPerce2, _flatItem$parentProdu9;
|
|
1614
1679
|
// 折扣卡:不拆分数量,直接应用
|
|
1615
1680
|
var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
|
|
1616
1681
|
usedDiscounts.set(_selectedDiscount3.id, true);
|
|
@@ -1628,11 +1693,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1628
1693
|
var targetProductTotal;
|
|
1629
1694
|
var fixedAmountPerItem;
|
|
1630
1695
|
var _productDiscountDifference;
|
|
1696
|
+
var _reapplyDiscountPercent;
|
|
1631
1697
|
if (_isOrderLevel && _productAllocation) {
|
|
1632
1698
|
// order_level:使用预计算的单价折扣金额(已经是单价,无需再除以数量)
|
|
1633
1699
|
fixedAmountPerItem = _productAllocation.discountAmount;
|
|
1634
1700
|
_productDiscountDifference = _productAllocation.difference;
|
|
1635
1701
|
targetProductTotal = Math.max(new Decimal(_productOriginTotal).minus(fixedAmountPerItem).toNumber(), 0);
|
|
1702
|
+
} else if (resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount3) !== undefined) {
|
|
1703
|
+
// hydrate 后 par_value 可能是余额/原值(例如 3500),百分比口径以
|
|
1704
|
+
// 后端折扣快照 discount.percent 为准,与主商品重套逻辑保持一致。
|
|
1705
|
+
var _percent = resolveReapplyBookingDiscountPercent(originProduct, _selectedDiscount3);
|
|
1706
|
+
_reapplyDiscountPercent = new Decimal(_percent).toFixed(2);
|
|
1707
|
+
targetProductTotal = new Decimal(_productOriginTotal).mul(new Decimal(100).minus(_percent)).div(100).toDecimalPlaces(2).toNumber();
|
|
1708
|
+
fixedAmountPerItem = new Decimal(_productOriginTotal).minus(targetProductTotal).toNumber();
|
|
1636
1709
|
} else {
|
|
1637
1710
|
// item_level 或其他类型:使用原有逻辑
|
|
1638
1711
|
targetProductTotal = getDiscountAmount(_selectedDiscount3, _productOriginTotal, _productOriginTotal);
|
|
@@ -1653,7 +1726,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1653
1726
|
title: _selectedDiscount3.format_title,
|
|
1654
1727
|
original_amount: product.original_price,
|
|
1655
1728
|
product_id: product.id || product.product_id,
|
|
1656
|
-
percent: _selectedDiscount3.par_value,
|
|
1729
|
+
percent: (_reapplyDiscountPerce2 = _reapplyDiscountPercent) !== null && _reapplyDiscountPerce2 !== void 0 ? _reapplyDiscountPerce2 : _selectedDiscount3.par_value,
|
|
1657
1730
|
discount_product_id: _selectedDiscount3.product_id
|
|
1658
1731
|
},
|
|
1659
1732
|
metadata: _objectSpread({
|
|
@@ -1969,7 +2042,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1969
2042
|
} else {
|
|
1970
2043
|
// 🔥 没有子商品被拆分,使用原有逻辑
|
|
1971
2044
|
mainProductArr.forEach(function (mainProduct) {
|
|
1972
|
-
var
|
|
2045
|
+
var _ref17, _mainProductData$main, _mainProductData$disc, _mainProductData$disc2, _mainProductData$disc3;
|
|
1973
2046
|
var mainProductData = _this4.hooks.getProduct(mainProduct);
|
|
1974
2047
|
|
|
1975
2048
|
// 重组bundle
|
|
@@ -1984,9 +2057,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1984
2057
|
} else {
|
|
1985
2058
|
// 🔥 关键:拆分后的bundle item
|
|
1986
2059
|
processedBundleItems.forEach(function (item) {
|
|
1987
|
-
var _item$price,
|
|
2060
|
+
var _item$price, _ref16, _item$bundle_selling_;
|
|
1988
2061
|
var nextBundlePrice = (_item$price = item.price) !== null && _item$price !== void 0 ? _item$price : bundleItem.price;
|
|
1989
|
-
var nextBundleSellingPrice = (
|
|
2062
|
+
var nextBundleSellingPrice = (_ref16 = (_item$bundle_selling_ = item.bundle_selling_price) !== null && _item$bundle_selling_ !== void 0 ? _item$bundle_selling_ : item.price) !== null && _ref16 !== void 0 ? _ref16 : bundleItem.bundle_selling_price;
|
|
1990
2063
|
// 🔥 更新 discount_list 中的 num,使其与拆分后的 item.num 一致
|
|
1991
2064
|
var updatedDiscountList = (item.discount_list || []).map(function (discount) {
|
|
1992
2065
|
var _discount$metadata10;
|
|
@@ -2013,7 +2086,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2013
2086
|
|
|
2014
2087
|
// 主商品已经在前面的 setProduct 中应用过折扣;这里只替换 bundle,
|
|
2015
2088
|
// 避免把主商品 discount_list 再扣一次。
|
|
2016
|
-
var mainSellingPrice = (
|
|
2089
|
+
var mainSellingPrice = (_ref17 = (_mainProductData$main = mainProductData.main_product_selling_price) !== null && _mainProductData$main !== void 0 ? _mainProductData$main : mainProductData.price) !== null && _ref17 !== void 0 ? _ref17 : 0;
|
|
2017
2090
|
var newTotal = Number(mainSellingPrice || 0);
|
|
2018
2091
|
var newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
|
|
2019
2092
|
|
|
@@ -2162,14 +2235,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2162
2235
|
var ruleType = usageRules.type;
|
|
2163
2236
|
// 套餐适用范围配置
|
|
2164
2237
|
var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
|
|
2165
|
-
var
|
|
2166
|
-
scopeType =
|
|
2167
|
-
|
|
2168
|
-
exclude_bundle_product_ids =
|
|
2169
|
-
|
|
2170
|
-
include_bundle_product_ids =
|
|
2171
|
-
|
|
2172
|
-
filter =
|
|
2238
|
+
var _ref18 = packageScope || {},
|
|
2239
|
+
scopeType = _ref18.type,
|
|
2240
|
+
_ref18$exclude_bundle = _ref18.exclude_bundle_product_ids,
|
|
2241
|
+
exclude_bundle_product_ids = _ref18$exclude_bundle === void 0 ? [] : _ref18$exclude_bundle,
|
|
2242
|
+
_ref18$include_bundle = _ref18.include_bundle_product_ids,
|
|
2243
|
+
include_bundle_product_ids = _ref18$include_bundle === void 0 ? [] : _ref18$include_bundle,
|
|
2244
|
+
_ref18$filter = _ref18.filter,
|
|
2245
|
+
filter = _ref18$filter === void 0 ? 0 : _ref18$filter;
|
|
2173
2246
|
var isMainProduct = flatItem.type === 'main'; // 单独购买
|
|
2174
2247
|
var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
|
|
2175
2248
|
var bundleMainProductId = (_flatItem$product = flatItem.product) === null || _flatItem$product === void 0 ? void 0 : _flatItem$product.product_id;
|
|
@@ -30,6 +30,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
30
30
|
taxRate?: number;
|
|
31
31
|
shopDiscount?: string | number;
|
|
32
32
|
channel?: string;
|
|
33
|
+
virtualSettlementMode?: boolean;
|
|
33
34
|
}): Promise<{
|
|
34
35
|
tax_title: string;
|
|
35
36
|
tax_rate: number | undefined;
|