@pisell/pisellos 2.3.17 → 2.3.19

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 (37) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Order/index.d.ts +4 -1
  3. package/dist/modules/Order/index.js +56 -29
  4. package/dist/modules/Order/types.d.ts +13 -0
  5. package/dist/modules/Product/index.d.ts +1 -1
  6. package/dist/modules/Rules/index.d.ts +2 -8
  7. package/dist/modules/Rules/index.js +55 -9
  8. package/dist/modules/Rules/types.d.ts +10 -1
  9. package/dist/modules/SalesSummary/index.d.ts +7 -3
  10. package/dist/modules/SalesSummary/index.js +67 -39
  11. package/dist/modules/SalesSummary/types.d.ts +1 -0
  12. package/dist/modules/SurchargeList/index.d.ts +6 -4
  13. package/dist/modules/SurchargeList/index.js +62 -39
  14. package/dist/modules/SurchargeList/types.d.ts +6 -2
  15. package/dist/server/modules/order/index.js +1 -2
  16. package/dist/solution/BaseSales/index.d.ts +6 -0
  17. package/dist/solution/BaseSales/index.js +782 -658
  18. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
  19. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  20. package/lib/modules/Order/index.d.ts +4 -1
  21. package/lib/modules/Order/index.js +39 -16
  22. package/lib/modules/Order/types.d.ts +13 -0
  23. package/lib/modules/Product/index.d.ts +1 -1
  24. package/lib/modules/Rules/index.d.ts +2 -8
  25. package/lib/modules/Rules/index.js +57 -6
  26. package/lib/modules/Rules/types.d.ts +10 -1
  27. package/lib/modules/SalesSummary/index.d.ts +7 -3
  28. package/lib/modules/SalesSummary/index.js +28 -11
  29. package/lib/modules/SalesSummary/types.d.ts +1 -0
  30. package/lib/modules/SurchargeList/index.d.ts +6 -4
  31. package/lib/modules/SurchargeList/index.js +41 -21
  32. package/lib/modules/SurchargeList/types.d.ts +6 -2
  33. package/lib/server/modules/order/index.js +1 -2
  34. package/lib/solution/BaseSales/index.d.ts +6 -0
  35. package/lib/solution/BaseSales/index.js +103 -29
  36. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
  37. package/package.json +1 -1
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -84,7 +84,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  unavailableReasonKey?: string | null;
85
85
  scannedDiscountList?: Discount[];
86
86
  }>;
87
- applyDiscount(): void;
87
+ applyDiscount(options?: {
88
+ reapplyBookingDiscountProductUids?: string[];
89
+ }): void;
88
90
  /**
89
91
  * 注入促销评估器。
90
92
  *
@@ -197,6 +199,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
197
199
  private clearManualDepositOverride;
198
200
  private getOriginalSalesSnapshot;
199
201
  private isSnapshotPayableAmountUnchanged;
202
+ private hasShopDiscountChangedFromSnapshot;
200
203
  private restoreOriginalSnapshotIfProductsUnchanged;
201
204
  private clearPersistedAmountFieldsForFullRecalc;
202
205
  private getPaymentTargetAmount;
@@ -6,12 +6,12 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
6
  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; }
7
7
  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); } }
8
8
  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); }); }; }
9
- 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; }
10
- 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; }
11
9
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
10
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
+ 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; }
14
+ 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; }
15
15
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
16
16
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
17
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -158,9 +158,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
158
158
  };
159
159
  var existed = discountMap.get(key);
160
160
  if (existed) {
161
+ var _existed$limited_rela;
161
162
  existed.amount = Number(existed.amount || 0) + amount;
162
163
  existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
163
164
  existed.balance = String(Number(existed.balance || 0) + amount);
165
+ var productIds = Array.isArray((_existed$limited_rela = existed.limited_relation_product_data) === null || _existed$limited_rela === void 0 ? void 0 : _existed$limited_rela.product_ids) ? existed.limited_relation_product_data.product_ids : [];
166
+ if ((product === null || product === void 0 ? void 0 : product.product_id) !== undefined && (product === null || product === void 0 ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
167
+ existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
168
+ product_ids: [].concat(_toConsumableArray(productIds), [product.product_id])
169
+ });
170
+ }
164
171
  existed.applicableProductDetails = [].concat(_toConsumableArray(existed.applicableProductDetails || []), [detail]);
165
172
  existed.appliedProductDetails = [].concat(_toConsumableArray(existed.appliedProductDetails || []), [detail]);
166
173
  continue;
@@ -702,7 +709,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
702
709
  }()
703
710
  }, {
704
711
  key: "applyDiscount",
705
- value: function applyDiscount() {
712
+ value: function applyDiscount(options) {
706
713
  var _this$store$discount9,
707
714
  _tempOrder$holder2,
708
715
  _this$store$summary2,
@@ -728,6 +735,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
728
735
  return resolveIsFormSubject(tempOrder, product);
729
736
  },
730
737
  orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
738
+ }, {
739
+ reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
731
740
  });
732
741
  if (result !== null && result !== void 0 && result.productList) {
733
742
  var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
@@ -1995,11 +2004,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1995
2004
  });
1996
2005
  return currentAmountGap === snapshotAmountGap;
1997
2006
  }
2007
+ }, {
2008
+ key: "hasShopDiscountChangedFromSnapshot",
2009
+ value: function hasShopDiscountChangedFromSnapshot(tempOrder, snapshot) {
2010
+ var _snapshot$shop_discou;
2011
+ var snapshotSummary = snapshot.summary && _typeof(snapshot.summary) === 'object' ? snapshot.summary : {};
2012
+ var snapshotShopDiscount = (_snapshot$shop_discou = snapshot.shop_discount) !== null && _snapshot$shop_discou !== void 0 ? _snapshot$shop_discou : snapshotSummary.shop_discount;
2013
+ if (snapshotShopDiscount === undefined || snapshotShopDiscount === null || snapshotShopDiscount === '') {
2014
+ return !new Decimal(tempOrder.shop_discount || 0).equals(0);
2015
+ }
2016
+ return !new Decimal(tempOrder.shop_discount || 0).equals(snapshotShopDiscount || 0);
2017
+ }
1998
2018
  }, {
1999
2019
  key: "restoreOriginalSnapshotIfProductsUnchanged",
2000
- value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder) {
2001
- var snapshot = this.getOriginalSalesSnapshot(tempOrder);
2002
- if (!snapshot) return null;
2020
+ value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
2003
2021
  var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
2004
2022
  if (currentFingerprint !== snapshot.productFingerprint) {
2005
2023
  var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
@@ -2660,8 +2678,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2660
2678
  key: "recalculateSummary",
2661
2679
  value: function () {
2662
2680
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2663
- var _ref47, _salesSummaryResult$e;
2664
- var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2681
+ var _this$otherParams2, _ref47, _salesSummaryResult$e;
2682
+ var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2665
2683
  return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2666
2684
  while (1) switch (_context13.prev = _context13.next) {
2667
2685
  case 0:
@@ -2673,14 +2691,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2673
2691
  return _context13.abrupt("return", null);
2674
2692
  case 3:
2675
2693
  this.sanitizeTempOrderProducts(tempOrder);
2676
- snapshotSummary = this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder);
2694
+ originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
2695
+ hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
2696
+ shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
2697
+ snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
2677
2698
  if (!snapshotSummary) {
2678
- _context13.next = 7;
2699
+ _context13.next = 10;
2679
2700
  break;
2680
2701
  }
2681
2702
  return _context13.abrupt("return", snapshotSummary);
2682
- case 7:
2683
- shouldFullRecalculateFromSnapshot = Boolean(this.getOriginalSalesSnapshot(tempOrder));
2703
+ case 10:
2704
+ shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
2684
2705
  summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
2685
2706
  if (shouldFullRecalculateFromSnapshot) {
2686
2707
  this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
@@ -2690,7 +2711,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2690
2711
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
2691
2712
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2692
2713
  if (salesSummary) {
2693
- _context13.next = 23;
2714
+ _context13.next = 26;
2694
2715
  break;
2695
2716
  }
2696
2717
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -2717,14 +2738,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2717
2738
  summary: emptySummary
2718
2739
  });
2719
2740
  return _context13.abrupt("return", this.store.summary);
2720
- case 23:
2721
- _context13.next = 25;
2722
- return salesSummary.getSummary({
2741
+ case 26:
2742
+ _context13.next = 28;
2743
+ return salesSummary.getSummary(_objectSpread({
2723
2744
  products: summaryProducts,
2724
2745
  isPriceIncludeTax: tempOrder.is_price_include_tax,
2725
2746
  shopDiscount: tempOrder.shop_discount
2726
- });
2727
- case 25:
2747
+ }, (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.channel ? {
2748
+ channel: this.otherParams.channel
2749
+ } : {}));
2750
+ case 28:
2728
2751
  salesSummaryResult = _context13.sent;
2729
2752
  if (shouldFullRecalculateFromSnapshot) {
2730
2753
  tempOrder.products = summaryProducts;
@@ -2771,7 +2794,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2771
2794
  summary: summary
2772
2795
  });
2773
2796
  return _context13.abrupt("return", this.store.summary);
2774
- case 43:
2797
+ case 46:
2775
2798
  case "end":
2776
2799
  return _context13.stop();
2777
2800
  }
@@ -3894,7 +3917,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3894
3917
  }, {
3895
3918
  key: "applyOrderProductUpdateToTempOrder",
3896
3919
  value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
3897
- var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p;
3920
+ var _targetProduct$metada2, _product_sku, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _metadata7, _nextProduct$metadata, _targetProduct$metada8, _tempOrder$products$p, _tempOrder$products$p2;
3898
3921
  var product_id = params.product_id,
3899
3922
  product_variant_id = params.product_variant_id,
3900
3923
  updates = params.updates,
@@ -4025,21 +4048,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4025
4048
  tempOrder.products[productIndex] = normalizedProduct;
4026
4049
  this.syncTempOrderHolderFromBookings(tempOrder);
4027
4050
  this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
4051
+ return (_tempOrder$products$p2 = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p2 === void 0 ? void 0 : _tempOrder$products$p2.unique_identification_number;
4028
4052
  }
4029
4053
  }, {
4030
4054
  key: "updateOrderProduct",
4031
4055
  value: function () {
4032
4056
  var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
4033
- var tempOrder;
4057
+ var tempOrder, updatedProductUid;
4034
4058
  return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4035
4059
  while (1) switch (_context21.prev = _context21.next) {
4036
4060
  case 0:
4037
4061
  tempOrder = this.ensureTempOrder();
4038
- this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4062
+ updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4039
4063
  _context21.next = 4;
4040
4064
  return this.applyPromotion();
4041
4065
  case 4:
4042
- this.applyDiscount();
4066
+ this.applyDiscount({
4067
+ reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4068
+ });
4043
4069
  this.sanitizeTempOrderProducts(tempOrder);
4044
4070
  _context21.next = 8;
4045
4071
  return this.recalculateSummary({
@@ -4439,14 +4465,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4439
4465
  }, {
4440
4466
  key: "buildCurrentSubmitPayloadForLocalPrint",
4441
4467
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
4442
- var _params$cacheId, _this$otherParams2, _ref68, _params$businessCode, _this$otherParams3, _this$otherParams4;
4468
+ var _params$cacheId, _this$otherParams3, _ref68, _params$businessCode, _this$otherParams4, _this$otherParams5;
4443
4469
  var tempOrder = this.ensureTempOrder();
4444
4470
  this.persistTempOrder();
4445
4471
  var payload = buildSubmitPayload({
4446
4472
  tempOrder: tempOrder,
4447
4473
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
4448
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform),
4449
- businessCode: (_ref68 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) !== null && _ref68 !== void 0 ? _ref68 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.business_code,
4474
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
4475
+ businessCode: (_ref68 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref68 !== void 0 ? _ref68 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
4450
4476
  channel: params === null || params === void 0 ? void 0 : params.channel,
4451
4477
  type: params === null || params === void 0 ? void 0 : params.type,
4452
4478
  summary: this.store.summary || createEmptySummary(),
@@ -4552,7 +4578,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4552
4578
  key: "runSubmitTempOrder",
4553
4579
  value: function () {
4554
4580
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4555
- var _params$cacheId2, _this$otherParams5, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams6, _this$otherParams7, _submitSnapshot$type;
4581
+ var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4556
4582
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4557
4583
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4558
4584
  while (1) switch (_context32.prev = _context32.next) {
@@ -4613,8 +4639,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4613
4639
  payload = buildSubmitPayload({
4614
4640
  tempOrder: tempOrder,
4615
4641
  cacheId: effectiveCacheId,
4616
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
4617
- businessCode: (_ref72 = (_ref73 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
4642
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4643
+ businessCode: (_ref72 = (_ref73 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
4618
4644
  channel: params === null || params === void 0 ? void 0 : params.channel,
4619
4645
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
4620
4646
  summary: latestSummary,
@@ -5371,6 +5397,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5371
5397
  products: cloneDeep(nextTempOrder.products || []),
5372
5398
  payments: cloneDeep(nextTempOrder.payments || []),
5373
5399
  surcharges: cloneDeep(nextTempOrder.surcharges || []),
5400
+ shop_discount: nextTempOrder.shop_discount || '0.00',
5374
5401
  productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
5375
5402
  }
5376
5403
  });
@@ -340,6 +340,19 @@ export interface UpdateOrderProductParams {
340
340
  * });
341
341
  */
342
342
  allow_booking_reprice?: boolean;
343
+ /**
344
+ * Change time 重报价后,允许当前预约商品行重新应用已选编辑态折扣卡。
345
+ *
346
+ * @example
347
+ * await order.updateOrderProduct({
348
+ * product_id: 1,
349
+ * product_variant_id: 0,
350
+ * updates: { discount_list: [] },
351
+ * booking: { duration: 2 },
352
+ * allow_booking_discount_reapply: true,
353
+ * });
354
+ */
355
+ allow_booking_discount_reapply?: boolean;
343
356
  }
344
357
  /** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
345
358
  export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -1,8 +1,7 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, UnavailableReason } from './types';
3
+ import { Rules, RulesModuleAPI, DiscountResult, RulesFormSubject, RulesCalcDiscountOptions, UnavailableReason } from './types';
4
4
  import { Discount } from '../Discount/types';
5
- import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
6
5
  import { WindowPlugin } from '../../plugins';
7
6
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
8
7
  protected defaultName: string;
@@ -45,12 +44,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
45
44
  }[];
46
45
  isFormSubject: RulesFormSubject;
47
46
  orderTotalAmount: number;
48
- }, options?: {
49
- isSelected?: boolean;
50
- discountId?: number;
51
- selectedList?: SetDiscountSelectedParams[];
52
- scan?: boolean;
53
- }): DiscountResult;
47
+ }, options?: RulesCalcDiscountOptions): DiscountResult;
54
48
  /**
55
49
  * 检查优惠是否符合 PackageSubItemUsageRules 配置
56
50
  * @param discount 优惠券
@@ -335,6 +335,32 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
335
335
  }) && productList.find(function (n) {
336
336
  return !n.booking_id;
337
337
  });
338
+ var reapplyBookingDiscountProductUids = new Set(((options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids) || []).filter(function (uid) {
339
+ return uid !== undefined && uid !== null && uid !== '';
340
+ }).map(String));
341
+ var getOriginProductUid = function getOriginProductUid(originProduct) {
342
+ var _originProduct$metada, _originProduct$metada2;
343
+ var uid = (_originProduct$metada = originProduct === null || originProduct === void 0 || (_originProduct$metada2 = originProduct.metadata) === null || _originProduct$metada2 === void 0 ? void 0 : _originProduct$metada2.unique_identification_number) !== null && _originProduct$metada !== void 0 ? _originProduct$metada : originProduct === null || originProduct === void 0 ? void 0 : originProduct.unique_identification_number;
344
+ if (uid === undefined || uid === null || uid === '') return undefined;
345
+ return String(uid);
346
+ };
347
+ var shouldReapplyBookingDiscount = function shouldReapplyBookingDiscount(originProduct, selectedDiscount) {
348
+ if (!selectedDiscount) return false;
349
+ var uid = getOriginProductUid(originProduct);
350
+ if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
351
+ var discountType = selectedDiscount.tag || selectedDiscount.type;
352
+ return selectedDiscount.isEditMode === true && selectedDiscount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
353
+ };
354
+ var resolveReapplyEditModeDiscountPercent = function resolveReapplyEditModeDiscountPercent(originProduct, selectedDiscount) {
355
+ var _discount2;
356
+ if (!shouldReapplyBookingDiscount(originProduct, selectedDiscount)) return undefined;
357
+ var discountType = (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.tag) || (selectedDiscount === null || selectedDiscount === void 0 ? void 0 : selectedDiscount.type);
358
+ if (discountType !== 'discount_card' && discountType !== 'product_discount_card') {
359
+ return undefined;
360
+ }
361
+ var percent = Number((_discount2 = selectedDiscount.discount) === null || _discount2 === void 0 ? void 0 : _discount2.percent);
362
+ return Number.isFinite(percent) ? percent : undefined;
363
+ };
338
364
  var editModeDiscount = [];
339
365
  var addModeDiscount = [];
340
366
  discountList.forEach(function (discount) {
@@ -363,11 +389,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
363
389
  }
364
390
  });
365
391
  }
366
-
367
- // 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑
368
- var filteredDiscountList = addModeDiscount.filter(function (discount) {
369
- return !discount.isManualSelect;
370
- });
371
392
  var hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options === null || options === void 0 ? void 0 : options.discountId) || Boolean(options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.length) || Boolean(options === null || options === void 0 ? void 0 : options.scan);
372
393
  if (!hasDiscountInput) {
373
394
  return {
@@ -375,6 +396,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
375
396
  productList: productList
376
397
  };
377
398
  }
399
+ var canUseEditModeDiscountForReapply = function canUseEditModeDiscountForReapply(discount) {
400
+ var discountType = discount.tag || discount.type;
401
+ return reapplyBookingDiscountProductUids.size > 0 && discount.isEditMode === true && discount.isSelected === true && ['good_pass', 'discount_card', 'product_discount_card'].includes(discountType);
402
+ };
403
+
404
+ // 过滤掉手动取消false的优惠券,但仅用于应用优惠逻辑。
405
+ // Change time 重报价需要把已选编辑态折扣卡重新放入候选,再由目标 uid 限定作用范围。
406
+ var filteredDiscountList = [].concat(_toConsumableArray(addModeDiscount.filter(function (discount) {
407
+ return !discount.isManualSelect;
408
+ })), _toConsumableArray(editModeDiscount.filter(canUseEditModeDiscountForReapply)));
378
409
 
379
410
  // 🔥 扁平化商品列表:将 bundle 子商品展开为虚拟商品
380
411
  var flattenProductsWithBundle = function flattenProductsWithBundle(productList) {
@@ -1056,7 +1087,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1056
1087
  var _product$discount_lis3, _product$discount_lis4;
1057
1088
  // 🔥 检查策略可用性(针对 good_pass 和折扣卡)
1058
1089
  var discountType = discount.tag || discount.type;
1059
- if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType)) {
1090
+ var currentOriginUid = getOriginProductUid(originProduct);
1091
+ var isReapplyEditModeDiscountForProduct = discount.isEditMode && reapplyBookingDiscountProductUids.size > 0 && currentOriginUid && reapplyBookingDiscountProductUids.has(String(currentOriginUid)) && discount.isSelected === true;
1092
+ if (discount.isEditMode && reapplyBookingDiscountProductUids.size > 0) {
1093
+ var uid = currentOriginUid;
1094
+ if (!uid || !reapplyBookingDiscountProductUids.has(uid)) return false;
1095
+ if (!discount.isSelected) return false;
1096
+ }
1097
+ if (['good_pass', 'discount_card', 'product_discount_card'].includes(discountType) && !isReapplyEditModeDiscountForProduct) {
1060
1098
  var _discount$config2;
1061
1099
  // 如果策略检查后没有config,说明不可用
1062
1100
  if (discount.config === undefined || !(discount !== null && discount !== void 0 && (_discount$config2 = discount.config) !== null && _discount$config2 !== void 0 && _discount$config2.isAvailable)) {
@@ -1284,7 +1322,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1284
1322
  }
1285
1323
  return;
1286
1324
  }
1287
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct) {
1325
+ var shouldReapplyBookingDiscountForProduct = shouldReapplyBookingDiscount(originProduct, selectedDiscount);
1326
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan) && !isEditModeAddNewProduct && !shouldReapplyBookingDiscountForProduct) {
1288
1327
  return;
1289
1328
  }
1290
1329
 
@@ -1325,7 +1364,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1325
1364
  }));
1326
1365
  }
1327
1366
  for (var i = 0; i < splitCount; i++) {
1328
- var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2;
1367
+ var _originProduct4, _selectedDiscount$con, _product$options, _product$options2, _selectedDiscount$met, _selectedDiscount$met2, _reapplyDiscountPerce;
1329
1368
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
1330
1369
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
1331
1370
  // 标记优惠券为已使用
@@ -1363,11 +1402,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1363
1402
  var productDiscountDifference = void 0;
1364
1403
  var discountedOptions = product.options;
1365
1404
  var optionDiscountAmount = 0;
1405
+ var reapplyDiscountPercent = void 0;
1366
1406
  if (isOrderLevel && productAllocation) {
1367
1407
  // order_level:使用预计算的分摊金额
1368
1408
  amount = productAllocation.discountAmount;
1369
1409
  productDiscountDifference = productAllocation.difference;
1370
1410
  mainProductSellingPrice = Math.max(new Decimal(product.price).minus(amount).toNumber(), 0);
1411
+ } else if (resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount) !== undefined) {
1412
+ // Change time 重套编辑态折扣卡时,历史 par_value 不是运行时折扣口径,优先使用后端快照里的 percent。
1413
+ var percent = resolveReapplyEditModeDiscountPercent(originProduct, _selectedDiscount);
1414
+ reapplyDiscountPercent = new Decimal(percent).toFixed(2);
1415
+ mainProductSellingPrice = new Decimal(product.price || 0).mul(new Decimal(100).minus(percent)).div(100).toDecimalPlaces(2).toNumber();
1416
+ amount = new Decimal(product.price).minus(mainProductSellingPrice).toNumber();
1371
1417
  } else {
1372
1418
  // item_level 或其他类型:使用原有逻辑
1373
1419
  mainProductSellingPrice = getDiscountAmount(_selectedDiscount, product.price, product.price);
@@ -1400,7 +1446,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1400
1446
  title: _selectedDiscount.format_title,
1401
1447
  original_amount: product.price,
1402
1448
  product_id: originProduct.id || originProduct.product_id,
1403
- percent: _selectedDiscount.par_value,
1449
+ percent: (_reapplyDiscountPerce = reapplyDiscountPercent) !== null && _reapplyDiscountPerce !== void 0 ? _reapplyDiscountPerce : _selectedDiscount.par_value,
1404
1450
  discount_product_id: _selectedDiscount.product_id
1405
1451
  },
1406
1452
  // 前端使用的num数量,为了计算优惠金额
@@ -1,4 +1,5 @@
1
1
  import { Discount } from '../Discount/types';
2
+ import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
2
3
  export declare enum UnavailableReason {
3
4
  TimeLimit = "time_limit",
4
5
  ProductNotApplicable = "product_not_applicable",
@@ -23,6 +24,14 @@ export interface DiscountResult {
23
24
  discountList: any[];
24
25
  }
25
26
  export type RulesFormSubject = boolean | ((product: any) => boolean);
27
+ export interface RulesCalcDiscountOptions {
28
+ isSelected?: boolean;
29
+ discountId?: number;
30
+ selectedList?: SetDiscountSelectedParams[];
31
+ scan?: boolean;
32
+ /** Change time 重报价目标行:允许已选编辑态折扣卡重新应用到这些 booking 商品。 */
33
+ reapplyBookingDiscountProductUids?: string[];
34
+ }
26
35
  export interface RulesModuleAPI {
27
36
  setRulesList: (rulesList: Rules[]) => Promise<void>;
28
37
  clear: () => Promise<void>;
@@ -34,7 +43,7 @@ export interface RulesModuleAPI {
34
43
  }[];
35
44
  isFormSubject: RulesFormSubject;
36
45
  orderTotalAmount: number;
37
- }) => DiscountResult;
46
+ }, options?: RulesCalcDiscountOptions) => DiscountResult;
38
47
  }
39
48
  type ProductDetail = {
40
49
  isClient?: boolean;
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
9
9
  private store;
10
10
  private request;
11
11
  private surchargeListModuleName;
12
+ private otherParams;
13
+ private surchargeListChannel;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
16
  /**
15
- * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名变化时刷新附加费列表。
17
+ * 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
16
18
  *
17
19
  * @example
18
- * await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
20
+ * await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
19
21
  */
20
22
  updateOtherParams(params: Record<string, any>): Promise<void>;
21
- getSurchargeList(): Promise<void>;
23
+ private resolveChannel;
24
+ getSurchargeList(channel?: string): Promise<void>;
22
25
  private getAppData;
23
26
  private getTaxConfig;
24
27
  getSummary(params: {
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
26
29
  isPriceIncludeTax?: number;
27
30
  taxRate?: number;
28
31
  shopDiscount?: string | number;
32
+ channel?: string;
29
33
  }): Promise<{
30
34
  tax_title: string;
31
35
  tax_rate: number | undefined;