@pisell/pisellos 2.2.264 → 2.2.266

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 (126) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  15. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  16. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  17. package/dist/modules/Discount/index.d.ts +5 -2
  18. package/dist/modules/Discount/index.js +30 -7
  19. package/dist/modules/Discount/types.d.ts +4 -0
  20. package/dist/modules/Order/index.d.ts +41 -10
  21. package/dist/modules/Order/index.js +1379 -810
  22. package/dist/modules/Order/payment-utils.d.ts +26 -0
  23. package/dist/modules/Order/payment-utils.js +225 -0
  24. package/dist/modules/Order/types.d.ts +49 -1
  25. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  26. package/dist/modules/Order/utils/orderCollectionIdentity.js +410 -0
  27. package/dist/modules/Order/utils.d.ts +4 -3
  28. package/dist/modules/Order/utils.js +61 -64
  29. package/dist/modules/Payment/index.d.ts +2 -0
  30. package/dist/modules/Payment/index.js +78 -49
  31. package/dist/modules/Payment/types.d.ts +26 -24
  32. package/dist/modules/Payment/types.js +2 -0
  33. package/dist/modules/Product/types.d.ts +22 -0
  34. package/dist/modules/ProductList/index.d.ts +1 -1
  35. package/dist/modules/ProductList/index.js +4 -2
  36. package/dist/modules/ProductList/types.d.ts +2 -0
  37. package/dist/modules/Rules/index.d.ts +2 -8
  38. package/dist/modules/Rules/index.js +55 -9
  39. package/dist/modules/Rules/types.d.ts +10 -1
  40. package/dist/server/index.d.ts +71 -0
  41. package/dist/server/index.js +2504 -1187
  42. package/dist/server/modules/order/index.d.ts +56 -5
  43. package/dist/server/modules/order/index.js +1718 -834
  44. package/dist/server/modules/order/types.d.ts +15 -3
  45. package/dist/server/modules/order/types.js +1 -1
  46. package/dist/server/modules/products/index.d.ts +31 -8
  47. package/dist/server/modules/products/index.js +549 -390
  48. package/dist/server/modules/products/types.d.ts +18 -0
  49. package/dist/solution/BaseSales/index.d.ts +67 -4
  50. package/dist/solution/BaseSales/index.js +1476 -792
  51. package/dist/solution/BaseSales/types.d.ts +6 -1
  52. package/dist/solution/BaseSales/types.js +1 -1
  53. package/dist/solution/BaseSales/utils/cartPromotion.js +19 -7
  54. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  55. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  56. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  57. package/dist/solution/BookingByStep/index.d.ts +1 -1
  58. package/dist/solution/BookingTicket/index.js +94 -54
  59. package/dist/solution/BookingTicket/types.d.ts +2 -0
  60. package/dist/solution/Sales/index.d.ts +1 -0
  61. package/dist/solution/Sales/index.js +10 -2
  62. package/dist/solution/ShopDiscount/index.js +15 -14
  63. package/dist/utils/payment-number.d.ts +9 -0
  64. package/dist/utils/payment-number.js +69 -0
  65. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  66. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  67. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  68. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  69. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  70. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  71. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  72. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  73. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  74. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  75. package/lib/model/strategy/adapter/index.d.ts +4 -0
  76. package/lib/model/strategy/adapter/index.js +13 -2
  77. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  78. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  79. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  80. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  81. package/lib/modules/Discount/index.d.ts +5 -2
  82. package/lib/modules/Discount/index.js +23 -3
  83. package/lib/modules/Discount/types.d.ts +4 -0
  84. package/lib/modules/Order/index.d.ts +41 -10
  85. package/lib/modules/Order/index.js +514 -122
  86. package/lib/modules/Order/payment-utils.d.ts +26 -0
  87. package/lib/modules/Order/payment-utils.js +224 -0
  88. package/lib/modules/Order/types.d.ts +49 -1
  89. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  90. package/lib/modules/Order/utils/orderCollectionIdentity.js +418 -0
  91. package/lib/modules/Order/utils.d.ts +4 -3
  92. package/lib/modules/Order/utils.js +26 -20
  93. package/lib/modules/Payment/index.d.ts +2 -0
  94. package/lib/modules/Payment/index.js +33 -12
  95. package/lib/modules/Payment/types.d.ts +26 -24
  96. package/lib/modules/Product/types.d.ts +22 -0
  97. package/lib/modules/ProductList/index.d.ts +1 -1
  98. package/lib/modules/ProductList/index.js +4 -2
  99. package/lib/modules/ProductList/types.d.ts +2 -0
  100. package/lib/modules/Rules/index.d.ts +2 -8
  101. package/lib/modules/Rules/index.js +57 -6
  102. package/lib/modules/Rules/types.d.ts +10 -1
  103. package/lib/server/index.d.ts +71 -0
  104. package/lib/server/index.js +1002 -52
  105. package/lib/server/modules/order/index.d.ts +56 -5
  106. package/lib/server/modules/order/index.js +798 -148
  107. package/lib/server/modules/order/types.d.ts +15 -3
  108. package/lib/server/modules/products/index.d.ts +31 -8
  109. package/lib/server/modules/products/index.js +134 -35
  110. package/lib/server/modules/products/types.d.ts +18 -0
  111. package/lib/solution/BaseSales/index.d.ts +67 -4
  112. package/lib/solution/BaseSales/index.js +496 -50
  113. package/lib/solution/BaseSales/types.d.ts +6 -1
  114. package/lib/solution/BaseSales/utils/cartPromotion.js +13 -1
  115. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +9 -4
  116. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  117. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  118. package/lib/solution/BookingByStep/index.d.ts +1 -1
  119. package/lib/solution/BookingTicket/index.js +39 -11
  120. package/lib/solution/BookingTicket/types.d.ts +2 -0
  121. package/lib/solution/Sales/index.d.ts +1 -0
  122. package/lib/solution/Sales/index.js +5 -3
  123. package/lib/solution/ShopDiscount/index.js +2 -1
  124. package/lib/utils/payment-number.d.ts +9 -0
  125. package/lib/utils/payment-number.js +64 -0
  126. package/package.json +1 -1
@@ -1,10 +1,7 @@
1
- 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; } } }; }
2
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
3
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
4
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
6
- 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; }
7
- 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; }
8
5
  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; }
9
6
  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); } }
10
7
  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); }); }; }
@@ -20,15 +17,18 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
20
17
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
21
18
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
22
19
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
23
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
20
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
27
21
  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."); }
28
- 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); }
29
22
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
30
23
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
24
+ 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; } } }; }
25
+ 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); }
31
26
  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; }
27
+ 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; }
28
+ 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; }
29
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
31
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
32
32
  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); }
33
33
  import { BaseModule } from "../../modules/BaseModule";
34
34
  import { BaseSalesHookNames } from "./types";
@@ -37,6 +37,9 @@ import Decimal from 'decimal.js';
37
37
  import { cloneDeep, mergeWith } from 'lodash-es';
38
38
  import { createModule } from "../BookingByStep/types";
39
39
  import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
40
+ import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
41
+ import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
42
+ import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
40
43
  import dayjs from 'dayjs';
41
44
  export * from "./types";
42
45
  import { QuotationModule } from "../../modules/Quotation";
@@ -73,7 +76,17 @@ function isBaseSalesHistoricalDiscountEntry(discount) {
73
76
  }
74
77
  function getBaseSalesUniqueArrayMetadataKey(key) {
75
78
  if (key === 'products' || key === 'bookings') return 'unique_identification_number';
76
- if (key === 'payments' || key === 'payment') return 'unique_payment_number';
79
+ return null;
80
+ }
81
+ var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
82
+ product: 'order_detail_id',
83
+ booking: 'schedule_event_id',
84
+ payment: 'order_payment_id'
85
+ };
86
+ function getBaseSalesOrderCollectionKind(key) {
87
+ if (key === 'products') return 'product';
88
+ if (key === 'bookings') return 'booking';
89
+ if (key === 'payments' || key === 'payment') return 'payment';
77
90
  return null;
78
91
  }
79
92
  function isSameBaseSalesOrderRecord(left, right) {
@@ -86,6 +99,111 @@ function isSameBaseSalesOrderRecord(left, right) {
86
99
  return value !== undefined && value !== null && value !== '' && leftIdentities.has(String(value));
87
100
  });
88
101
  }
102
+ function isBaseSalesBlankValue(value) {
103
+ return value === undefined || value === null || value === '';
104
+ }
105
+ function mergeBaseSalesProductSnapshotFields(currentItem, loadedItem) {
106
+ var _currentItem$metadata, _mergedItem$metadata, _mergedItem$metadata2;
107
+ var mergedItem = cloneDeep(loadedItem);
108
+ if (isBaseSalesBlankValue(mergedItem.product_cover) && !isBaseSalesBlankValue(currentItem === null || currentItem === void 0 ? void 0 : currentItem.product_cover)) {
109
+ mergedItem.product_cover = currentItem.product_cover;
110
+ }
111
+ var currentHolderConfig = currentItem === null || currentItem === void 0 || (_currentItem$metadata = currentItem.metadata) === null || _currentItem$metadata === void 0 ? void 0 : _currentItem$metadata.holder_config;
112
+ if ((((_mergedItem$metadata = mergedItem.metadata) === null || _mergedItem$metadata === void 0 ? void 0 : _mergedItem$metadata.holder_config) === undefined || ((_mergedItem$metadata2 = mergedItem.metadata) === null || _mergedItem$metadata2 === void 0 ? void 0 : _mergedItem$metadata2.holder_config) === null) && currentHolderConfig !== undefined && currentHolderConfig !== null) {
113
+ mergedItem.metadata = _objectSpread(_objectSpread({}, mergedItem.metadata || {}), {}, {
114
+ holder_config: currentHolderConfig
115
+ });
116
+ }
117
+ return mergedItem;
118
+ }
119
+ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps) {
120
+ var currentReferenceUid = getOrderCollectionReferenceUid(kind, currentItem);
121
+ var incomingReferenceUid = getOrderCollectionReferenceUid(kind, incomingItem);
122
+ var identityMergedItem = mergeOrderCollectionItems(kind, currentItem, incomingItem);
123
+ var mergedUid = getOrderCollectionUid(kind, identityMergedItem);
124
+ if (mergedUid) {
125
+ var _iterator = _createForOfIteratorHelper(new Set([currentReferenceUid, incomingReferenceUid])),
126
+ _step;
127
+ try {
128
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
129
+ var from = _step.value;
130
+ if (!from || from === mergedUid) continue;
131
+ uidRemaps.push({
132
+ kind: kind,
133
+ from: from,
134
+ to: mergedUid,
135
+ persistentId: getOrderCollectionPersistentId(kind, incomingItem) || getOrderCollectionPersistentId(kind, currentItem)
136
+ });
137
+ }
138
+ } catch (err) {
139
+ _iterator.e(err);
140
+ } finally {
141
+ _iterator.f();
142
+ }
143
+ }
144
+ var mergedItem = mergedUid ? setOrderCollectionUid(kind, incomingItem, mergedUid) : cloneDeep(incomingItem);
145
+ var persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
146
+ if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
147
+ mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
148
+ }
149
+ return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
150
+ }
151
+ function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
152
+ if (kind === 'payment') {
153
+ return mergeOrderPaymentListsByIdentity(currentValue, incomingValue, strategy === 'preserve-local' ? {
154
+ preserveUnmatchedExisting: true
155
+ } : {
156
+ preserveUnmatchedExistingWhen: function preserveUnmatchedExistingWhen(payment) {
157
+ return isIdentifiedPendingOrderPayment(payment) || !getOrderCollectionPersistentId('payment', payment);
158
+ }
159
+ });
160
+ }
161
+ var currentItems = normalizeOrderCollection(kind, currentValue, {
162
+ ensureUid: false
163
+ }).items;
164
+ var incomingItems = normalizeOrderCollection(kind, incomingValue, {
165
+ ensureUid: false
166
+ }).items;
167
+ if (strategy === 'authoritative-incoming') {
168
+ var _result = cloneDeep(incomingItems);
169
+ currentItems.forEach(function (currentItem) {
170
+ var incomingIndex = _result.findIndex(function (incomingItem) {
171
+ return isSameOrderCollectionItem(kind, currentItem, incomingItem);
172
+ });
173
+ if (incomingIndex !== -1) {
174
+ _result[incomingIndex] = mergeBaseSalesCollectionItem(kind, currentItem, _result[incomingIndex], uidRemaps);
175
+ return;
176
+ }
177
+
178
+ // 完整服务端快照负责已落库行;仅保留尚未提交的本地新行。
179
+ if (!getOrderCollectionPersistentId(kind, currentItem)) {
180
+ _result.push(cloneDeep(currentItem));
181
+ }
182
+ });
183
+ return _result;
184
+ }
185
+ var result = cloneDeep(currentItems);
186
+ incomingItems.forEach(function (incomingItem) {
187
+ var currentIndex = result.findIndex(function (currentItem) {
188
+ return isSameOrderCollectionItem(kind, currentItem, incomingItem);
189
+ });
190
+ if (currentIndex !== -1) {
191
+ result[currentIndex] = mergeBaseSalesCollectionItem(kind, result[currentIndex], incomingItem, uidRemaps);
192
+ return;
193
+ }
194
+ result.push(cloneDeep(incomingItem));
195
+ });
196
+ return result;
197
+ }
198
+ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
199
+ var normalizedRecord = normalizeOrderCollections(cloneDeep(sourceRecord || {}), options).order;
200
+
201
+ // 兼容旧调用方偶尔使用的单数 payment 字段。
202
+ if (Array.isArray(normalizedRecord.payment)) {
203
+ normalizedRecord.payment = normalizeOrderCollection('payment', normalizedRecord.payment, options).items;
204
+ }
205
+ return normalizedRecord;
206
+ }
89
207
  function getBaseSalesMetadataUid(item, metadataKey) {
90
208
  var _item$metadata$metada, _item$metadata;
91
209
  var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
@@ -114,10 +232,28 @@ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
114
232
  loadedValue.forEach(appendOrReplaceByUid);
115
233
  return result;
116
234
  }
117
- function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
118
- if (!currentTempOrder) return loadedRecord;
119
- var mergedRecord = mergeWith(cloneDeep(currentTempOrder), cloneDeep(loadedRecord || {}), function (currentValue, loadedValue, key) {
235
+ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
236
+ var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
237
+ ensureUid: false
238
+ });
239
+ if (!currentTempOrder) {
240
+ return normalizeBaseSalesRecordCollections(normalizedLoadedRecord);
241
+ }
242
+ var normalizedCurrentTempOrder = normalizeBaseSalesRecordCollections(currentTempOrder, {
243
+ ensureUid: false
244
+ });
245
+ var uidRemaps = [];
246
+ var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
247
+ var collectionKind = getBaseSalesOrderCollectionKind(key);
248
+ if (collectionKind && Array.isArray(loadedValue)) {
249
+ return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
250
+ }
120
251
  if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
252
+ if (key === 'payments' || key === 'payment') {
253
+ return mergeOrderPaymentListsByIdentity(currentValue, loadedValue, {
254
+ preserveUnmatchedExisting: true
255
+ });
256
+ }
121
257
  var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
122
258
  if (metadataKey) {
123
259
  return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
@@ -131,7 +267,23 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
131
267
  return undefined;
132
268
  });
133
269
  delete mergedRecord.request_unique_idempotency_token;
134
- return mergedRecord;
270
+ return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
271
+ }
272
+ function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
273
+ if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
274
+ var record = _objectSpread({}, sourceRecord);
275
+ if (Array.isArray(sourceRecord.payments)) {
276
+ record.payments = sourceRecord.payments.filter(function (payment) {
277
+ return !isPendingOrderPayment(payment);
278
+ });
279
+ }
280
+ // 兼容少量历史详情数据使用的单数 payment 字段。
281
+ if (Array.isArray(sourceRecord.payment)) {
282
+ record.payment = sourceRecord.payment.filter(function (payment) {
283
+ return !isPendingOrderPayment(payment);
284
+ });
285
+ }
286
+ return record;
135
287
  }
136
288
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
137
289
  _inherits(BaseSalesImpl, _BaseModule);
@@ -152,6 +304,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
152
304
  });
153
305
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
154
306
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
307
+ /**
308
+ * 由已在初始化阶段解析过设备短号的业务解决方案写入。
309
+ * 未设置时,支付编号仍按原逻辑实时读取设备信息。
310
+ */
311
+ _defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
155
312
  /**
156
313
  * window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
157
314
  * `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
@@ -167,9 +324,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
167
324
  _defineProperty(_assertThisInitialized(_this), "queuedAutoPaymentSync", false);
168
325
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncFlushing", false);
169
326
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
170
- _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlight", false);
327
+ _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
328
+ _defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
329
+ _defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
171
330
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
172
331
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
332
+ _defineProperty(_assertThisInitialized(_this), "queuedServerOrderChanges", []);
333
+ _defineProperty(_assertThisInitialized(_this), "serverOrderChangeSyncEnabled", false);
173
334
  return _this;
174
335
  }
175
336
 
@@ -259,71 +420,143 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
259
420
  return isSameBaseSalesOrderRecord(record, order);
260
421
  });
261
422
  }
423
+ }, {
424
+ key: "setServerOrderChangeSyncEnabled",
425
+ value: function setServerOrderChangeSyncEnabled(enabled) {
426
+ this.serverOrderChangeSyncEnabled = enabled;
427
+ if (!enabled) this.queuedServerOrderChanges = [];
428
+ }
429
+ }, {
430
+ key: "queueLatestServerOrderChange",
431
+ value: function queueLatestServerOrderChange(order) {
432
+ var snapshot = cloneDeep(order);
433
+ var existingIndex = this.queuedServerOrderChanges.findIndex(function (queued) {
434
+ return isSameBaseSalesOrderRecord(queued, snapshot);
435
+ });
436
+ if (existingIndex >= 0) {
437
+ this.queuedServerOrderChanges[existingIndex] = snapshot;
438
+ return;
439
+ }
440
+ this.queuedServerOrderChanges.push(snapshot);
441
+ }
442
+ }, {
443
+ key: "drainQueuedServerOrderChanges",
444
+ value: function () {
445
+ var _drainQueuedServerOrderChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
446
+ var changedOrders;
447
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
448
+ while (1) switch (_context.prev = _context.next) {
449
+ case 0:
450
+ if (!(!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlightCount > 0 || this.serverOrderChangeHydrateInFlight || this.queuedServerOrderChanges.length === 0)) {
451
+ _context.next = 2;
452
+ break;
453
+ }
454
+ return _context.abrupt("return");
455
+ case 2:
456
+ changedOrders = this.queuedServerOrderChanges;
457
+ this.queuedServerOrderChanges = [];
458
+ _context.next = 6;
459
+ return this.syncCurrentSalesDetailFromServerOrderChange({
460
+ changedOrders: changedOrders
461
+ });
462
+ case 6:
463
+ case "end":
464
+ return _context.stop();
465
+ }
466
+ }, _callee, this);
467
+ }));
468
+ function drainQueuedServerOrderChanges() {
469
+ return _drainQueuedServerOrderChanges.apply(this, arguments);
470
+ }
471
+ return drainQueuedServerOrderChanges;
472
+ }()
262
473
  }, {
263
474
  key: "syncCurrentSalesDetailFromServerOrderChange",
264
475
  value: function () {
265
- var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
476
+ var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
266
477
  var _this2 = this;
267
478
  var changedOrders, changedOrder;
268
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
269
- while (1) switch (_context2.prev = _context2.next) {
479
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
480
+ while (1) switch (_context3.prev = _context3.next) {
270
481
  case 0:
271
482
  changedOrders = Array.isArray(payload) ? payload : Array.isArray(payload === null || payload === void 0 ? void 0 : payload.changedOrders) ? payload.changedOrders : payload !== null && payload !== void 0 && payload.data && _typeof(payload.data) === 'object' ? [payload.data] : [];
272
- if (!(this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)) {
273
- _context2.next = 3;
483
+ if (this.serverOrderChangeSyncEnabled) {
484
+ _context3.next = 3;
274
485
  break;
275
486
  }
276
- return _context2.abrupt("return");
487
+ return _context3.abrupt("return");
277
488
  case 3:
489
+ if (!(this.salesDetailLoadInFlightCount > 0)) {
490
+ _context3.next = 6;
491
+ break;
492
+ }
493
+ changedOrders.forEach(function (order) {
494
+ return _this2.queueLatestServerOrderChange(order);
495
+ });
496
+ return _context3.abrupt("return");
497
+ case 6:
278
498
  changedOrder = changedOrders.find(function (order) {
279
499
  return _this2.isCurrentSalesOrderRecord(order);
280
500
  });
281
501
  if (changedOrder) {
282
- _context2.next = 6;
502
+ _context3.next = 9;
283
503
  break;
284
504
  }
285
- return _context2.abrupt("return");
286
- case 6:
505
+ return _context3.abrupt("return");
506
+ case 9:
507
+ if (!this.serverOrderChangeHydrateInFlight) {
508
+ _context3.next = 12;
509
+ break;
510
+ }
511
+ this.queueLatestServerOrderChange(changedOrder);
512
+ return _context3.abrupt("return");
513
+ case 12:
287
514
  if (this.store.order) {
288
- _context2.next = 8;
515
+ _context3.next = 14;
289
516
  break;
290
517
  }
291
- return _context2.abrupt("return");
292
- case 8:
293
- this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
294
- var sales;
295
- return _regeneratorRuntime().wrap(function _callee$(_context) {
296
- while (1) switch (_context.prev = _context.next) {
518
+ return _context3.abrupt("return");
519
+ case 14:
520
+ this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
521
+ var _getTempOrder, _ref2;
522
+ var currentTempOrder, record, sales;
523
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
524
+ while (1) switch (_context2.prev = _context2.next) {
297
525
  case 0:
298
- _context.next = 2;
299
- return _this2.store.order.hydrateTempOrderFromRecord(changedOrder, {
526
+ currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
527
+ record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
528
+ _context2.next = 4;
529
+ return _this2.store.order.hydrateTempOrderFromRecord(record, {
300
530
  recalcOnHydrate: false
301
531
  });
302
- case 2:
303
- sales = _context.sent;
532
+ case 4:
533
+ sales = _context2.sent;
304
534
  _this2.currentSalesDetail = sales;
305
- _context.next = 6;
535
+ _context2.next = 8;
306
536
  return _this2.core.effects.emit("".concat(_this2.name, ":onSalesOrderLoaded"), {
307
537
  sales: sales
308
538
  });
309
- case 6:
539
+ case 8:
310
540
  case "end":
311
- return _context.stop();
541
+ return _context2.stop();
312
542
  }
313
- }, _callee);
543
+ }, _callee2);
314
544
  }))();
315
- _context2.prev = 9;
316
- _context2.next = 12;
545
+ _context3.prev = 15;
546
+ _context3.next = 18;
317
547
  return this.serverOrderChangeHydrateInFlight;
318
- case 12:
319
- _context2.prev = 12;
548
+ case 18:
549
+ _context3.prev = 18;
320
550
  this.serverOrderChangeHydrateInFlight = null;
321
- return _context2.finish(12);
322
- case 15:
551
+ _context3.next = 22;
552
+ return this.drainQueuedServerOrderChanges();
553
+ case 22:
554
+ return _context3.finish(18);
555
+ case 23:
323
556
  case "end":
324
- return _context2.stop();
557
+ return _context3.stop();
325
558
  }
326
- }, _callee2, this, [[9,, 12, 15]]);
559
+ }, _callee3, this, [[15,, 18, 23]]);
327
560
  }));
328
561
  function syncCurrentSalesDetailFromServerOrderChange(_x) {
329
562
  return _syncCurrentSalesDetailFromServerOrderChange.apply(this, arguments);
@@ -340,13 +573,100 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
340
573
  var effects = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.effects;
341
574
  if (!effects || typeof effects.on !== 'function') return;
342
575
  this.serverOrderChangeUnsubscribe = effects.on(SERVER_ORDER_CHANGED_EVENT, function (payload) {
343
- void _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
576
+ return _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
344
577
  _this3.logError('sync sales detail from server order change failed', {
345
578
  error: error instanceof Error ? error.message : String(error)
346
579
  });
347
580
  });
348
581
  });
349
582
  }
583
+ }, {
584
+ key: "hydrateLatestLoadedSalesDetail",
585
+ value: function () {
586
+ var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence) {
587
+ var _this4 = this;
588
+ var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
589
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
590
+ while (1) switch (_context5.prev = _context5.next) {
591
+ case 0:
592
+ hydratedSales = null;
593
+ skippedBeforeHydrate = false;
594
+ hydrateTask = /*#__PURE__*/function () {
595
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
596
+ var sales;
597
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
598
+ while (1) switch (_context4.prev = _context4.next) {
599
+ case 0:
600
+ if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
601
+ _context4.next = 3;
602
+ break;
603
+ }
604
+ skippedBeforeHydrate = true;
605
+ return _context4.abrupt("return");
606
+ case 3:
607
+ if (_this4.store.order) {
608
+ _context4.next = 5;
609
+ break;
610
+ }
611
+ throw new Error('order 模块未初始化');
612
+ case 5:
613
+ _context4.next = 7;
614
+ return _this4.store.order.hydrateTempOrderFromRecord(record, {
615
+ recalcOnHydrate: false
616
+ });
617
+ case 7:
618
+ sales = _context4.sent;
619
+ hydratedSales = sales;
620
+
621
+ // hydrate 期间可能又发起了更新请求;后续任务已串行排队,将负责最终状态。
622
+ if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
623
+ _context4.next = 11;
624
+ break;
625
+ }
626
+ return _context4.abrupt("return");
627
+ case 11:
628
+ _this4.currentSalesDetail = sales;
629
+ _context4.next = 14;
630
+ return _this4.core.effects.emit("".concat(_this4.name, ":onSalesOrderLoaded"), {
631
+ sales: sales
632
+ });
633
+ case 14:
634
+ case "end":
635
+ return _context4.stop();
636
+ }
637
+ }, _callee4);
638
+ }));
639
+ return function hydrateTask() {
640
+ return _ref3.apply(this, arguments);
641
+ };
642
+ }();
643
+ queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
644
+ this.salesDetailHydrateQueue = queuedTask.then(function () {
645
+ return undefined;
646
+ }, function () {
647
+ return undefined;
648
+ });
649
+ _context5.next = 7;
650
+ return queuedTask;
651
+ case 7:
652
+ if (!skippedBeforeHydrate) {
653
+ _context5.next = 9;
654
+ break;
655
+ }
656
+ return _context5.abrupt("return", record);
657
+ case 9:
658
+ return _context5.abrupt("return", hydratedSales || this.currentSalesDetail || record);
659
+ case 10:
660
+ case "end":
661
+ return _context5.stop();
662
+ }
663
+ }, _callee5, this);
664
+ }));
665
+ function hydrateLatestLoadedSalesDetail(_x2, _x3) {
666
+ return _hydrateLatestLoadedSalesDetail.apply(this, arguments);
667
+ }
668
+ return hydrateLatestLoadedSalesDetail;
669
+ }()
350
670
  }, {
351
671
  key: "hydrateOrderPaymentNames",
352
672
  value: function hydrateOrderPaymentNames(payments) {
@@ -411,10 +731,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
411
731
  });
412
732
  }
413
733
  quotation.setScheduleResolver(function (id) {
414
- var _scheduleModule$getSc, _getScheduleByIds, _ref2;
734
+ var _scheduleModule$getSc, _getScheduleByIds, _ref4;
415
735
  var scheduleId = String(id);
416
736
  if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
417
- var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref2 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref2, [id])) || [];
737
+ var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || ((_getScheduleByIds = (_ref4 = scheduleModule).getScheduleByIds) === null || _getScheduleByIds === void 0 ? void 0 : _getScheduleByIds.call(_ref4, [id])) || [];
418
738
  if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
419
739
  return schedules[0];
420
740
  });
@@ -422,30 +742,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
422
742
  }, {
423
743
  key: "loadQuotationForPriceQuery",
424
744
  value: function () {
425
- var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
745
+ var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
426
746
  var _this$otherParams;
427
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
428
- while (1) switch (_context3.prev = _context3.next) {
747
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
748
+ while (1) switch (_context6.prev = _context6.next) {
429
749
  case 0:
430
750
  if (params.quotation) {
431
- _context3.next = 2;
751
+ _context6.next = 2;
432
752
  break;
433
753
  }
434
- return _context3.abrupt("return");
754
+ return _context6.abrupt("return");
435
755
  case 2:
436
756
  this.applyQuotationScheduleResolver(params.quotation);
437
- _context3.next = 5;
757
+ _context6.next = 5;
438
758
  return params.quotation.loadQuotations({
439
759
  channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
440
760
  customer_id: params.customer_id
441
761
  });
442
762
  case 5:
443
763
  case "end":
444
- return _context3.stop();
764
+ return _context6.stop();
445
765
  }
446
- }, _callee3, this);
766
+ }, _callee6, this);
447
767
  }));
448
- function loadQuotationForPriceQuery(_x2) {
768
+ function loadQuotationForPriceQuery(_x4) {
449
769
  return _loadQuotationForPriceQuery.apply(this, arguments);
450
770
  }
451
771
  return loadQuotationForPriceQuery;
@@ -489,23 +809,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
489
809
  }, {
490
810
  key: "loadProductsForPriceQuery",
491
811
  value: function () {
492
- var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
812
+ var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
493
813
  var ids, productsById, _this$otherParams2, _response$data, response, list;
494
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
495
- while (1) switch (_context4.prev = _context4.next) {
814
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
815
+ while (1) switch (_context7.prev = _context7.next) {
496
816
  case 0:
497
817
  ids = Array.from(new Set(params.ids.filter(function (id) {
498
818
  return Number.isFinite(id);
499
819
  })));
500
820
  productsById = new Map();
501
821
  if (!(!ids.length || !this.request)) {
502
- _context4.next = 4;
822
+ _context7.next = 4;
503
823
  break;
504
824
  }
505
- return _context4.abrupt("return", productsById);
825
+ return _context7.abrupt("return", productsById);
506
826
  case 4:
507
- _context4.prev = 4;
508
- _context4.next = 7;
827
+ _context7.prev = 4;
828
+ _context7.next = 7;
509
829
  return this.request.post('/product/query', {
510
830
  ids: ids,
511
831
  open_quotation: 1,
@@ -522,35 +842,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
522
842
  customToast: function customToast() {}
523
843
  });
524
844
  case 7:
525
- response = _context4.sent;
845
+ response = _context7.sent;
526
846
  list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
527
847
  if (Array.isArray(list)) {
528
- _context4.next = 11;
848
+ _context7.next = 11;
529
849
  break;
530
850
  }
531
- return _context4.abrupt("return", productsById);
851
+ return _context7.abrupt("return", productsById);
532
852
  case 11:
533
853
  list.forEach(function (item) {
534
854
  var _item$id;
535
855
  var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
536
856
  if (Number.isFinite(productId)) productsById.set(productId, item);
537
857
  });
538
- return _context4.abrupt("return", productsById);
858
+ return _context7.abrupt("return", productsById);
539
859
  case 15:
540
- _context4.prev = 15;
541
- _context4.t0 = _context4["catch"](4);
860
+ _context7.prev = 15;
861
+ _context7.t0 = _context7["catch"](4);
542
862
  this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
543
863
  ids: ids,
544
- error: _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0)
864
+ error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
545
865
  });
546
- return _context4.abrupt("return", productsById);
866
+ return _context7.abrupt("return", productsById);
547
867
  case 19:
548
868
  case "end":
549
- return _context4.stop();
869
+ return _context7.stop();
550
870
  }
551
- }, _callee4, this, [[4, 15]]);
871
+ }, _callee7, this, [[4, 15]]);
552
872
  }));
553
- function loadProductsForPriceQuery(_x3) {
873
+ function loadProductsForPriceQuery(_x5) {
554
874
  return _loadProductsForPriceQuery.apply(this, arguments);
555
875
  }
556
876
  return loadProductsForPriceQuery;
@@ -558,21 +878,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
558
878
  }, {
559
879
  key: "loadProductForPriceQuery",
560
880
  value: function () {
561
- var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params, customerId) {
881
+ var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, customerId) {
562
882
  var product, productId, schedule, productsById;
563
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
564
- while (1) switch (_context5.prev = _context5.next) {
883
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
884
+ while (1) switch (_context8.prev = _context8.next) {
565
885
  case 0:
566
886
  product = params.product || {};
567
887
  productId = this.getPriceQueryProductId(product);
568
888
  if (!(productId === null || !this.request)) {
569
- _context5.next = 4;
889
+ _context8.next = 4;
570
890
  break;
571
891
  }
572
- return _context5.abrupt("return", null);
892
+ return _context8.abrupt("return", null);
573
893
  case 4:
574
894
  schedule = this.getPriceQuerySchedule(params);
575
- _context5.next = 7;
895
+ _context8.next = 7;
576
896
  return this.loadProductsForPriceQuery({
577
897
  ids: [productId],
578
898
  schedule: schedule,
@@ -580,15 +900,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
580
900
  channel: params.channel
581
901
  });
582
902
  case 7:
583
- productsById = _context5.sent;
584
- return _context5.abrupt("return", productsById.get(productId) || null);
903
+ productsById = _context8.sent;
904
+ return _context8.abrupt("return", productsById.get(productId) || null);
585
905
  case 9:
586
906
  case "end":
587
- return _context5.stop();
907
+ return _context8.stop();
588
908
  }
589
- }, _callee5, this);
909
+ }, _callee8, this);
590
910
  }));
591
- function loadProductForPriceQuery(_x4, _x5) {
911
+ function loadProductForPriceQuery(_x6, _x7) {
592
912
  return _loadProductForPriceQuery.apply(this, arguments);
593
913
  }
594
914
  return loadProductForPriceQuery;
@@ -601,10 +921,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
601
921
  return groups.flatMap(function (group) {
602
922
  var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
603
923
  return items.map(function (item) {
604
- var _item$group_id, _ref3, _item$bundle_group_id;
924
+ var _item$group_id, _ref5, _item$bundle_group_id;
605
925
  return _objectSpread(_objectSpread({}, item), {}, {
606
926
  group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
607
- bundle_group_id: (_ref3 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref3 !== void 0 ? _ref3 : group === null || group === void 0 ? void 0 : group.id
927
+ bundle_group_id: (_ref5 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref5 !== void 0 ? _ref5 : group === null || group === void 0 ? void 0 : group.id
608
928
  });
609
929
  });
610
930
  });
@@ -635,21 +955,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
635
955
  }, {
636
956
  key: "getAuthoritativeBundleUnitPrice",
637
957
  value: function getAuthoritativeBundleUnitPrice(bundle) {
638
- var _ref4, _ref5, _ref6, _bundle$price;
639
- return (_ref4 = (_ref5 = (_ref6 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.custom_price) !== null && _ref5 !== void 0 ? _ref5 : bundle.product_price) !== null && _ref4 !== void 0 ? _ref4 : bundle.base_price;
958
+ var _ref6, _ref7, _ref8, _bundle$price;
959
+ return (_ref6 = (_ref7 = (_ref8 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref8 !== void 0 ? _ref8 : bundle.custom_price) !== null && _ref7 !== void 0 ? _ref7 : bundle.product_price) !== null && _ref6 !== void 0 ? _ref6 : bundle.base_price;
640
960
  }
641
961
  }, {
642
962
  key: "mergeProductForPriceQuery",
643
963
  value: function mergeProductForPriceQuery(product, authoritativeProduct) {
644
- var _this4 = this,
964
+ var _this5 = this,
645
965
  _product$id,
646
- _ref7,
966
+ _ref9,
647
967
  _product$product_id2,
648
- _ref8,
968
+ _ref10,
649
969
  _product$product_vari,
650
- _ref9,
970
+ _ref11,
651
971
  _product$num,
652
- _ref10,
972
+ _ref12,
653
973
  _product$quantity,
654
974
  _product$metadata4;
655
975
  if (!authoritativeProduct) return product;
@@ -657,8 +977,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
657
977
  var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
658
978
  var productBundle = selectedBundles.map(function (bundle) {
659
979
  var _authoritativeBundle$, _authoritativeBundle$2;
660
- var authoritativeBundle = _this4.findAuthoritativeBundleItem(bundle, authoritativeBundles);
661
- var unitPrice = authoritativeBundle ? _this4.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
980
+ var authoritativeBundle = _this5.findAuthoritativeBundleItem(bundle, authoritativeBundles);
981
+ var unitPrice = authoritativeBundle ? _this5.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
662
982
  if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
663
983
  return _objectSpread(_objectSpread({}, bundle), {}, {
664
984
  price: unitPrice,
@@ -669,10 +989,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
669
989
  });
670
990
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
671
991
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
672
- product_id: (_ref7 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref7 !== void 0 ? _ref7 : authoritativeProduct.id,
673
- product_variant_id: (_ref8 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
674
- num: (_ref9 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.num,
675
- quantity: (_ref10 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref10 !== void 0 ? _ref10 : authoritativeProduct.quantity,
992
+ product_id: (_ref9 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref9 !== void 0 ? _ref9 : authoritativeProduct.id,
993
+ product_variant_id: (_ref10 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
994
+ num: (_ref11 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.num,
995
+ quantity: (_ref12 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.quantity,
676
996
  product_sku: function () {
677
997
  var authoritativeSku = ensureProductSku(authoritativeProduct);
678
998
  var productSku = ensureProductSku(product);
@@ -746,61 +1066,61 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
746
1066
  }, {
747
1067
  key: "syncOtherParamsToSubModules",
748
1068
  value: (function () {
749
- var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(changedParams) {
750
- var _this5 = this;
751
- var _ref11,
752
- _ref11$cover,
1069
+ var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
1070
+ var _this6 = this;
1071
+ var _ref13,
1072
+ _ref13$cover,
753
1073
  cover,
754
1074
  nextSubModuleOtherParams,
755
- _args7 = arguments;
756
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
757
- while (1) switch (_context7.prev = _context7.next) {
1075
+ _args10 = arguments;
1076
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1077
+ while (1) switch (_context10.prev = _context10.next) {
758
1078
  case 0:
759
- _ref11 = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {}, _ref11$cover = _ref11.cover, cover = _ref11$cover === void 0 ? false : _ref11$cover;
1079
+ _ref13 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
760
1080
  nextSubModuleOtherParams = this.buildSubModuleOtherParams();
761
- _context7.next = 4;
1081
+ _context10.next = 4;
762
1082
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
763
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref12) {
764
- var _ref14, moduleName, subModule, targetModule;
765
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
766
- while (1) switch (_context6.prev = _context6.next) {
1083
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref14) {
1084
+ var _ref16, moduleName, subModule, targetModule;
1085
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1086
+ while (1) switch (_context9.prev = _context9.next) {
767
1087
  case 0:
768
- _ref14 = _slicedToArray(_ref12, 2), moduleName = _ref14[0], subModule = _ref14[1];
769
- if (!_this5.reusedSharedSubModuleNames.has(moduleName)) {
770
- _context6.next = 3;
1088
+ _ref16 = _slicedToArray(_ref14, 2), moduleName = _ref16[0], subModule = _ref16[1];
1089
+ if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1090
+ _context9.next = 3;
771
1091
  break;
772
1092
  }
773
- return _context6.abrupt("return");
1093
+ return _context9.abrupt("return");
774
1094
  case 3:
775
1095
  targetModule = subModule;
776
1096
  if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
777
- _context6.next = 6;
1097
+ _context9.next = 6;
778
1098
  break;
779
1099
  }
780
- return _context6.abrupt("return");
1100
+ return _context9.abrupt("return");
781
1101
  case 6:
782
- _context6.next = 8;
1102
+ _context9.next = 8;
783
1103
  return targetModule.updateOtherParams(nextSubModuleOtherParams, {
784
1104
  changedParams: changedParams,
785
1105
  cover: cover
786
1106
  });
787
1107
  case 8:
788
1108
  case "end":
789
- return _context6.stop();
1109
+ return _context9.stop();
790
1110
  }
791
- }, _callee6);
1111
+ }, _callee9);
792
1112
  }));
793
- return function (_x7) {
794
- return _ref13.apply(this, arguments);
1113
+ return function (_x9) {
1114
+ return _ref15.apply(this, arguments);
795
1115
  };
796
1116
  }()));
797
1117
  case 4:
798
1118
  case "end":
799
- return _context7.stop();
1119
+ return _context10.stop();
800
1120
  }
801
- }, _callee7, this);
1121
+ }, _callee10, this);
802
1122
  }));
803
- function syncOtherParamsToSubModules(_x6) {
1123
+ function syncOtherParamsToSubModules(_x8) {
804
1124
  return _syncOtherParamsToSubModules.apply(this, arguments);
805
1125
  }
806
1126
  return syncOtherParamsToSubModules;
@@ -833,6 +1153,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
833
1153
  var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
834
1154
  return coreData === null || coreData === void 0 ? void 0 : coreData[key];
835
1155
  }
1156
+
1157
+ /**
1158
+ * 复用业务解决方案初始化时已解析的支付设备短号。
1159
+ * 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
1160
+ */
1161
+ }, {
1162
+ key: "setPaymentNumberDevicePrefix",
1163
+ value: function setPaymentNumberDevicePrefix(prefix) {
1164
+ var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
1165
+ this.paymentNumberDevicePrefix = normalized || null;
1166
+ }
1167
+ }, {
1168
+ key: "getPaymentNumberDevicePrefixSync",
1169
+ value: function getPaymentNumberDevicePrefixSync() {
1170
+ var _this7 = this;
1171
+ if (!this.appPlugin) return 'LOCAL';
1172
+ return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1173
+ return _this7.getAppData(key);
1174
+ });
1175
+ }
1176
+ }, {
1177
+ key: "getPaymentNumberDevicePrefixAsync",
1178
+ value: function getPaymentNumberDevicePrefixAsync() {
1179
+ var _this8 = this;
1180
+ if (!this.appPlugin) return Promise.resolve('LOCAL');
1181
+ if (this.paymentNumberDevicePrefix) {
1182
+ return Promise.resolve(this.paymentNumberDevicePrefix);
1183
+ }
1184
+ return resolvePaymentNumberDevicePrefix(function (key) {
1185
+ return _this8.getAppData(key);
1186
+ });
1187
+ }
836
1188
  }, {
837
1189
  key: "syncAppDataToTempOrder",
838
1190
  value: function syncAppDataToTempOrder(tempOrder) {
@@ -874,21 +1226,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
874
1226
  }, {
875
1227
  key: "initialize",
876
1228
  value: function () {
877
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(core) {
1229
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
878
1230
  var _this$otherParams4,
879
- _this6 = this,
1231
+ _this9 = this,
880
1232
  _this$otherParams5;
881
1233
  var options,
882
1234
  app,
883
1235
  targetCacheData,
884
1236
  moduleNames,
885
- _args8 = arguments;
886
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
887
- while (1) switch (_context8.prev = _context8.next) {
1237
+ _args11 = arguments;
1238
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1239
+ while (1) switch (_context11.prev = _context11.next) {
888
1240
  case 0:
889
- options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
1241
+ options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
890
1242
  this.core = core;
891
1243
  this.initializeOptions = options || {};
1244
+ this.paymentNumberDevicePrefix = null;
892
1245
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
893
1246
  this.otherParams = options.otherParams || {};
894
1247
  this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
@@ -899,58 +1252,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
899
1252
  // 获取 logger 实例
900
1253
  this.appPlugin = core.getPlugin('app');
901
1254
  if (this.appPlugin) {
902
- _context8.next = 11;
1255
+ _context11.next = 12;
903
1256
  break;
904
1257
  }
905
1258
  throw new Error('Checkout 解决方案需要 app 插件支持');
906
- case 11:
1259
+ case 12:
907
1260
  app = this.appPlugin.getApp();
908
1261
  this.logger = app.logger;
909
1262
  targetCacheData = this.readSessionCacheData();
910
1263
  moduleNames = this.getRegisteredModuleNames();
911
1264
  moduleNames.forEach(function (step) {
912
- var reusedModule = _this6.getReusableSharedSubModule(step);
1265
+ var reusedModule = _this9.getReusableSharedSubModule(step);
913
1266
  if (reusedModule) {
914
- _this6.store[step] = reusedModule;
915
- _this6.reusedSharedSubModuleNames.add(step);
1267
+ _this9.store[step] = reusedModule;
1268
+ _this9.reusedSharedSubModuleNames.add(step);
916
1269
  return;
917
1270
  }
918
- var targetModule = _this6.createSubModule(step);
1271
+ var targetModule = _this9.createSubModule(step);
919
1272
  if (!targetModule) {
920
1273
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
921
1274
  }
922
- var hooks = _this6.getSubModuleHooks(step);
923
- _this6.store[step] = targetModule;
924
- _this6.core.registerModule(targetModule, _objectSpread(_objectSpread({
1275
+ var hooks = _this9.getSubModuleHooks(step);
1276
+ _this9.store[step] = targetModule;
1277
+ _this9.core.registerModule(targetModule, _objectSpread(_objectSpread({
925
1278
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
926
1279
  }, hooks ? {
927
1280
  hooks: hooks
928
1281
  } : {}), {}, {
929
- otherParams: _this6.buildSubModuleOtherParams()
1282
+ otherParams: _this9.buildSubModuleOtherParams()
930
1283
  }));
931
1284
  });
932
1285
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
933
- _context8.next = 19;
1286
+ _context11.next = 20;
934
1287
  break;
935
1288
  }
936
- _context8.next = 19;
1289
+ _context11.next = 20;
937
1290
  return this.store.schedule.loadAllSchedule();
938
- case 19:
1291
+ case 20:
939
1292
  if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
940
1293
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
941
1294
  }
942
- _context8.next = 22;
1295
+ _context11.next = 23;
943
1296
  return this.getPaymentMethodsAsync();
944
- case 22:
1297
+ case 23:
945
1298
  this.registerServerOrderChangeSync();
946
1299
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
947
- case 24:
1300
+ case 25:
948
1301
  case "end":
949
- return _context8.stop();
1302
+ return _context11.stop();
950
1303
  }
951
- }, _callee8, this);
1304
+ }, _callee11, this);
952
1305
  }));
953
- function initialize(_x8) {
1306
+ function initialize(_x10) {
954
1307
  return _initialize.apply(this, arguments);
955
1308
  }
956
1309
  return initialize;
@@ -958,17 +1311,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
958
1311
  }, {
959
1312
  key: "destroy",
960
1313
  value: function () {
961
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1314
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
962
1315
  var _this$serverOrderChan2,
963
- _this7 = this;
964
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
965
- while (1) switch (_context9.prev = _context9.next) {
1316
+ _this10 = this;
1317
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1318
+ while (1) switch (_context12.prev = _context12.next) {
966
1319
  case 0:
967
1320
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
968
1321
  this.serverOrderChangeUnsubscribe = null;
969
1322
  Object.keys(this.store).forEach(function (key) {
970
- if (_this7.reusedSharedSubModuleNames.has(key)) return;
971
- var sub = _this7.store[key];
1323
+ if (_this10.reusedSharedSubModuleNames.has(key)) return;
1324
+ var sub = _this10.store[key];
972
1325
  if (sub && typeof sub.destroy === 'function') {
973
1326
  try {
974
1327
  sub.destroy();
@@ -978,15 +1331,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
978
1331
  }
979
1332
  });
980
1333
  this.currentSalesDetail = null;
981
- _context9.next = 6;
1334
+ this.paymentNumberDevicePrefix = null;
1335
+ this.queuedServerOrderChanges = [];
1336
+ this.salesDetailLoadSequence += 1;
1337
+ _context12.next = 9;
982
1338
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
983
- case 6:
1339
+ case 9:
984
1340
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
985
- case 7:
1341
+ case 10:
986
1342
  case "end":
987
- return _context9.stop();
1343
+ return _context12.stop();
988
1344
  }
989
- }, _callee9, this);
1345
+ }, _callee12, this);
990
1346
  }));
991
1347
  function destroy() {
992
1348
  return _destroy.apply(this, arguments);
@@ -1003,82 +1359,92 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1003
1359
  }, {
1004
1360
  key: "loadSalesDetail",
1005
1361
  value: (function () {
1006
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderIdOrParams) {
1007
- var _ref15, _ref16, _ref17, _ref18, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record, sales;
1008
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1009
- while (1) switch (_context10.prev = _context10.next) {
1362
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1363
+ var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, mergedRecord, record;
1364
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1365
+ while (1) switch (_context13.prev = _context13.next) {
1010
1366
  case 0:
1011
1367
  if (this.store.order) {
1012
- _context10.next = 2;
1368
+ _context13.next = 2;
1013
1369
  break;
1014
1370
  }
1015
1371
  throw new Error('order 模块未初始化');
1016
1372
  case 2:
1017
- this.salesDetailLoadInFlight = true;
1018
- _context10.prev = 3;
1373
+ loadSequence = ++this.salesDetailLoadSequence;
1374
+ this.salesDetailLoadInFlightCount += 1;
1375
+ _context13.prev = 4;
1019
1376
  params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
1020
1377
  orderId: orderIdOrParams
1021
1378
  };
1022
1379
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1023
1380
  preloadedSalesDetail = params.preloadedSalesDetail;
1024
- lookup = (_ref15 = (_ref16 = (_ref17 = (_ref18 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref18 !== void 0 ? _ref18 : params.orderNumber) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref16 !== void 0 ? _ref16 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref15 !== void 0 ? _ref15 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1381
+ lookup = (_ref17 = (_ref18 = (_ref19 = (_ref20 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref20 !== void 0 ? _ref20 : params.orderNumber) !== null && _ref19 !== void 0 ? _ref19 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref18 !== void 0 ? _ref18 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref17 !== void 0 ? _ref17 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
1025
1382
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1026
- _context10.next = 10;
1383
+ _context13.next = 11;
1027
1384
  break;
1028
1385
  }
1029
1386
  throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
1030
- case 10:
1387
+ case 11:
1031
1388
  if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
1032
- _context10.next = 14;
1389
+ _context13.next = 15;
1033
1390
  break;
1034
1391
  }
1035
- _context10.t0 = preloadedSalesDetail;
1036
- _context10.next = 17;
1392
+ _context13.t0 = preloadedSalesDetail;
1393
+ _context13.next = 18;
1037
1394
  break;
1038
- case 14:
1039
- _context10.next = 16;
1395
+ case 15:
1396
+ _context13.next = 17;
1040
1397
  return this.store.order.getSalesOrderByLookup({
1041
1398
  lookup: lookup,
1042
1399
  forceRemote: params.forceRemote
1043
1400
  });
1044
- case 16:
1045
- _context10.t0 = _context10.sent;
1046
1401
  case 17:
1047
- loadedRecord = _context10.t0;
1402
+ _context13.t0 = _context13.sent;
1403
+ case 18:
1404
+ loadedRecord = _context13.t0;
1048
1405
  if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
1049
- _context10.next = 21;
1406
+ _context13.next = 22;
1050
1407
  break;
1051
1408
  }
1052
1409
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1053
1410
  throw new Error(message);
1054
- case 21:
1055
- remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
1411
+ case 22:
1412
+ remoteRecord = filterPendingPaymentsFromLoadedSalesDetail(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data);
1056
1413
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1057
- record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
1058
- _context10.next = 26;
1059
- return this.store.order.hydrateTempOrderFromRecord(record, {
1060
- recalcOnHydrate: false
1061
- });
1062
- case 26:
1063
- sales = _context10.sent;
1064
- this.currentSalesDetail = sales;
1065
- _context10.next = 30;
1066
- return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
1067
- sales: sales
1414
+ mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1415
+ record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
1416
+ _context13.next = 28;
1417
+ return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1418
+ case 28:
1419
+ return _context13.abrupt("return", _context13.sent);
1420
+ case 29:
1421
+ _context13.prev = 29;
1422
+ this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1423
+ if (!(this.salesDetailLoadInFlightCount === 0)) {
1424
+ _context13.next = 40;
1425
+ break;
1426
+ }
1427
+ _context13.prev = 32;
1428
+ _context13.next = 35;
1429
+ return this.drainQueuedServerOrderChanges();
1430
+ case 35:
1431
+ _context13.next = 40;
1432
+ break;
1433
+ case 37:
1434
+ _context13.prev = 37;
1435
+ _context13.t1 = _context13["catch"](32);
1436
+ this.logError('drain queued server order changes failed', {
1437
+ error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1068
1438
  });
1069
- case 30:
1070
- return _context10.abrupt("return", sales);
1071
- case 31:
1072
- _context10.prev = 31;
1073
- this.salesDetailLoadInFlight = false;
1074
- return _context10.finish(31);
1075
- case 34:
1439
+ case 40:
1440
+ return _context13.finish(29);
1441
+ case 41:
1076
1442
  case "end":
1077
- return _context10.stop();
1443
+ return _context13.stop();
1078
1444
  }
1079
- }, _callee10, this, [[3,, 31, 34]]);
1445
+ }, _callee13, this, [[4,, 29, 41], [32, 37]]);
1080
1446
  }));
1081
- function loadSalesDetail(_x9) {
1447
+ function loadSalesDetail(_x11) {
1082
1448
  return _loadSalesDetail.apply(this, arguments);
1083
1449
  }
1084
1450
  return loadSalesDetail;
@@ -1158,34 +1524,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1158
1524
  }, {
1159
1525
  key: "replaceTempOrder",
1160
1526
  value: function () {
1161
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder) {
1527
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
1162
1528
  var nextTempOrder;
1163
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1164
- while (1) switch (_context11.prev = _context11.next) {
1529
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1530
+ while (1) switch (_context14.prev = _context14.next) {
1165
1531
  case 0:
1166
1532
  if (this.store.order) {
1167
- _context11.next = 2;
1533
+ _context14.next = 2;
1168
1534
  break;
1169
1535
  }
1170
1536
  throw new Error('order 模块未初始化');
1171
1537
  case 2:
1172
- _context11.next = 4;
1538
+ _context14.next = 4;
1173
1539
  return this.store.order.replaceTempOrder(tempOrder);
1174
1540
  case 4:
1175
- nextTempOrder = _context11.sent;
1176
- _context11.next = 7;
1541
+ nextTempOrder = _context14.sent;
1542
+ _context14.next = 7;
1177
1543
  return this.effectsEmit('onTempOrderReplaced', {
1178
1544
  tempOrder: nextTempOrder
1179
1545
  });
1180
1546
  case 7:
1181
- return _context11.abrupt("return", nextTempOrder);
1547
+ return _context14.abrupt("return", nextTempOrder);
1182
1548
  case 8:
1183
1549
  case "end":
1184
- return _context11.stop();
1550
+ return _context14.stop();
1185
1551
  }
1186
- }, _callee11, this);
1552
+ }, _callee14, this);
1187
1553
  }));
1188
- function replaceTempOrder(_x10) {
1554
+ function replaceTempOrder(_x12) {
1189
1555
  return _replaceTempOrder.apply(this, arguments);
1190
1556
  }
1191
1557
  return replaceTempOrder;
@@ -1283,40 +1649,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1283
1649
  }, {
1284
1650
  key: "addNewOrder",
1285
1651
  value: function () {
1286
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1652
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1287
1653
  var tempOrder;
1288
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1289
- while (1) switch (_context12.prev = _context12.next) {
1654
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1655
+ while (1) switch (_context15.prev = _context15.next) {
1290
1656
  case 0:
1291
- _context12.prev = 0;
1657
+ _context15.prev = 0;
1292
1658
  if (this.store.order) {
1293
- _context12.next = 3;
1659
+ _context15.next = 3;
1294
1660
  break;
1295
1661
  }
1296
1662
  throw new Error('order 模块未初始化');
1297
1663
  case 3:
1298
- _context12.next = 5;
1664
+ _context15.next = 5;
1299
1665
  return this.store.order.addNewOrder();
1300
1666
  case 5:
1301
- tempOrder = _context12.sent;
1667
+ tempOrder = _context15.sent;
1302
1668
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1303
- _context12.next = 10;
1669
+ _context15.next = 10;
1304
1670
  break;
1305
1671
  }
1306
1672
  this.store.order.persistTempOrder();
1307
- _context12.next = 10;
1673
+ _context15.next = 10;
1308
1674
  return this.store.order.saveDraft();
1309
1675
  case 10:
1310
- return _context12.abrupt("return", tempOrder);
1676
+ return _context15.abrupt("return", tempOrder);
1311
1677
  case 13:
1312
- _context12.prev = 13;
1313
- _context12.t0 = _context12["catch"](0);
1314
- throw _context12.t0;
1678
+ _context15.prev = 13;
1679
+ _context15.t0 = _context15["catch"](0);
1680
+ throw _context15.t0;
1315
1681
  case 16:
1316
1682
  case "end":
1317
- return _context12.stop();
1683
+ return _context15.stop();
1318
1684
  }
1319
- }, _callee12, this, [[0, 13]]);
1685
+ }, _callee15, this, [[0, 13]]);
1320
1686
  }));
1321
1687
  function addNewOrder() {
1322
1688
  return _addNewOrder.apply(this, arguments);
@@ -1326,22 +1692,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1326
1692
  }, {
1327
1693
  key: "saveDraft",
1328
1694
  value: function () {
1329
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1330
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1331
- while (1) switch (_context13.prev = _context13.next) {
1695
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1696
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1697
+ while (1) switch (_context16.prev = _context16.next) {
1332
1698
  case 0:
1333
1699
  if (this.store.order) {
1334
- _context13.next = 2;
1700
+ _context16.next = 2;
1335
1701
  break;
1336
1702
  }
1337
1703
  throw new Error('order 模块未初始化');
1338
1704
  case 2:
1339
- return _context13.abrupt("return", this.store.order.saveDraft());
1705
+ return _context16.abrupt("return", this.store.order.saveDraft());
1340
1706
  case 3:
1341
1707
  case "end":
1342
- return _context13.stop();
1708
+ return _context16.stop();
1343
1709
  }
1344
- }, _callee13, this);
1710
+ }, _callee16, this);
1345
1711
  }));
1346
1712
  function saveDraft() {
1347
1713
  return _saveDraft.apply(this, arguments);
@@ -1352,14 +1718,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1352
1718
  }, {
1353
1719
  key: "restoreOrder",
1354
1720
  value: function () {
1355
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1721
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1356
1722
  var tempOrder;
1357
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1358
- while (1) switch (_context14.prev = _context14.next) {
1723
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1724
+ while (1) switch (_context17.prev = _context17.next) {
1359
1725
  case 0:
1360
- _context14.prev = 0;
1726
+ _context17.prev = 0;
1361
1727
  if (this.store.order) {
1362
- _context14.next = 3;
1728
+ _context17.next = 3;
1363
1729
  break;
1364
1730
  }
1365
1731
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -1369,29 +1735,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1369
1735
  this.currentSalesDetail = null;
1370
1736
  this.discountConfigCacheKey = null;
1371
1737
  this.hasManualDiscountSelection = false;
1372
- _context14.next = 9;
1738
+ _context17.next = 9;
1373
1739
  return this.effectsEmit('onTempOrderReplaced', {
1374
1740
  tempOrder: tempOrder
1375
1741
  });
1376
1742
  case 9:
1377
1743
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1378
- _context14.next = 13;
1744
+ _context17.next = 13;
1379
1745
  break;
1380
1746
  }
1381
1747
  this.store.order.persistTempOrder();
1382
- _context14.next = 13;
1748
+ _context17.next = 13;
1383
1749
  return this.store.order.saveDraft();
1384
1750
  case 13:
1385
- return _context14.abrupt("return", tempOrder);
1751
+ return _context17.abrupt("return", tempOrder);
1386
1752
  case 16:
1387
- _context14.prev = 16;
1388
- _context14.t0 = _context14["catch"](0);
1389
- throw _context14.t0;
1753
+ _context17.prev = 16;
1754
+ _context17.t0 = _context17["catch"](0);
1755
+ throw _context17.t0;
1390
1756
  case 19:
1391
1757
  case "end":
1392
- return _context14.stop();
1758
+ return _context17.stop();
1393
1759
  }
1394
- }, _callee14, this, [[0, 16]]);
1760
+ }, _callee17, this, [[0, 16]]);
1395
1761
  }));
1396
1762
  function restoreOrder() {
1397
1763
  return _restoreOrder.apply(this, arguments);
@@ -1405,22 +1771,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1405
1771
  }, {
1406
1772
  key: "clearOrderCartLines",
1407
1773
  value: (function () {
1408
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1774
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1409
1775
  var tempOrder;
1410
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1411
- while (1) switch (_context15.prev = _context15.next) {
1776
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1777
+ while (1) switch (_context18.prev = _context18.next) {
1412
1778
  case 0:
1413
- _context15.prev = 0;
1779
+ _context18.prev = 0;
1414
1780
  if (this.store.order) {
1415
- _context15.next = 3;
1781
+ _context18.next = 3;
1416
1782
  break;
1417
1783
  }
1418
1784
  throw new Error('order 模块未初始化');
1419
1785
  case 3:
1420
- _context15.next = 5;
1786
+ _context18.next = 5;
1421
1787
  return this.store.order.clearOrderCartLines();
1422
1788
  case 5:
1423
- tempOrder = _context15.sent;
1789
+ tempOrder = _context18.sent;
1424
1790
  if (this.currentSalesDetail) {
1425
1791
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
1426
1792
  products: [],
@@ -1430,29 +1796,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1430
1796
  discount_list: []
1431
1797
  });
1432
1798
  }
1433
- _context15.next = 9;
1799
+ _context18.next = 9;
1434
1800
  return this.effectsEmit('onTempOrderReplaced', {
1435
1801
  tempOrder: tempOrder
1436
1802
  });
1437
1803
  case 9:
1438
1804
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1439
- _context15.next = 13;
1805
+ _context18.next = 13;
1440
1806
  break;
1441
1807
  }
1442
1808
  this.store.order.persistTempOrder();
1443
- _context15.next = 13;
1809
+ _context18.next = 13;
1444
1810
  return this.store.order.saveDraft();
1445
1811
  case 13:
1446
- return _context15.abrupt("return", tempOrder);
1812
+ return _context18.abrupt("return", tempOrder);
1447
1813
  case 16:
1448
- _context15.prev = 16;
1449
- _context15.t0 = _context15["catch"](0);
1450
- throw _context15.t0;
1814
+ _context18.prev = 16;
1815
+ _context18.t0 = _context18["catch"](0);
1816
+ throw _context18.t0;
1451
1817
  case 19:
1452
1818
  case "end":
1453
- return _context15.stop();
1819
+ return _context18.stop();
1454
1820
  }
1455
- }, _callee15, this, [[0, 16]]);
1821
+ }, _callee18, this, [[0, 16]]);
1456
1822
  }));
1457
1823
  function clearOrderCartLines() {
1458
1824
  return _clearOrderCartLines.apply(this, arguments);
@@ -1469,32 +1835,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1469
1835
  }, {
1470
1836
  key: "getSummary",
1471
1837
  value: function () {
1472
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1838
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1473
1839
  var summary;
1474
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1475
- while (1) switch (_context16.prev = _context16.next) {
1840
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1841
+ while (1) switch (_context19.prev = _context19.next) {
1476
1842
  case 0:
1477
- _context16.prev = 0;
1843
+ _context19.prev = 0;
1478
1844
  if (this.store.order) {
1479
- _context16.next = 3;
1845
+ _context19.next = 3;
1480
1846
  break;
1481
1847
  }
1482
1848
  throw new Error('order 模块未初始化');
1483
1849
  case 3:
1484
- _context16.next = 5;
1850
+ _context19.next = 5;
1485
1851
  return this.store.order.getOrderSummary();
1486
1852
  case 5:
1487
- summary = _context16.sent;
1488
- return _context16.abrupt("return", summary);
1853
+ summary = _context19.sent;
1854
+ return _context19.abrupt("return", summary);
1489
1855
  case 9:
1490
- _context16.prev = 9;
1491
- _context16.t0 = _context16["catch"](0);
1492
- throw _context16.t0;
1856
+ _context19.prev = 9;
1857
+ _context19.t0 = _context19["catch"](0);
1858
+ throw _context19.t0;
1493
1859
  case 12:
1494
1860
  case "end":
1495
- return _context16.stop();
1861
+ return _context19.stop();
1496
1862
  }
1497
- }, _callee16, this, [[0, 9]]);
1863
+ }, _callee19, this, [[0, 9]]);
1498
1864
  }));
1499
1865
  function getSummary() {
1500
1866
  return _getSummary.apply(this, arguments);
@@ -1504,10 +1870,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1504
1870
  }, {
1505
1871
  key: "getHistoricalProductDiscountList",
1506
1872
  value: function getHistoricalProductDiscountList(products) {
1507
- var _this8 = this;
1873
+ var _this11 = this;
1508
1874
  var historyDiscountList = [];
1509
1875
  products.forEach(function (item) {
1510
- if (!_this8.isPersistedOrderProduct(item)) return;
1876
+ if (!_this11.isPersistedOrderProduct(item)) return;
1511
1877
  (item.discount_list || []).forEach(function (discount) {
1512
1878
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1513
1879
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -1567,11 +1933,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1567
1933
  }, {
1568
1934
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1569
1935
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1570
- var _this9 = this;
1936
+ var _this12 = this;
1571
1937
  if (params.discountAction !== 'edit') return false;
1572
1938
  if (!params.products.length) return false;
1573
1939
  var hasDraftProduct = params.products.some(function (product) {
1574
- return !_this9.isPersistedOrderProduct(product);
1940
+ return !_this12.isPersistedOrderProduct(product);
1575
1941
  });
1576
1942
  if (hasDraftProduct) return false;
1577
1943
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -1611,14 +1977,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1611
1977
  }, {
1612
1978
  key: "loadDiscountConfig",
1613
1979
  value: function () {
1614
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1980
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1615
1981
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
1616
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _tempOrder$holder, _orderStore$summary, holders, orderTotalAmount, result, _iterator, _step, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
1617
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1618
- while (1) switch (_context17.prev = _context17.next) {
1982
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _summary, _orderStore$summary, orderTotalAmount, result, _iterator2, _step2, _product$metadata5, _tempOrder$_extend3, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
1983
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1984
+ while (1) switch (_context20.prev = _context20.next) {
1619
1985
  case 0:
1620
1986
  if (this.store.order) {
1621
- _context17.next = 2;
1987
+ _context20.next = 2;
1622
1988
  break;
1623
1989
  }
1624
1990
  throw new Error('order 模块未初始化');
@@ -1638,18 +2004,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1638
2004
  discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
1639
2005
  preparedDiscountList = [];
1640
2006
  if (!(customerId && customerId !== 1)) {
1641
- _context17.next = 25;
2007
+ _context20.next = 25;
1642
2008
  break;
1643
2009
  }
1644
2010
  if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
1645
- _context17.next = 19;
2011
+ _context20.next = 19;
1646
2012
  break;
1647
2013
  }
1648
2014
  preparedDiscountList = originalDiscountList;
1649
- _context17.next = 25;
2015
+ _context20.next = 25;
1650
2016
  break;
1651
2017
  case 19:
1652
- _context17.next = 21;
2018
+ _context20.next = 21;
1653
2019
  return this.store.order.loadDiscountConfig({
1654
2020
  customerId: customerId,
1655
2021
  action: discountAction,
@@ -1657,23 +2023,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1657
2023
  apply: false
1658
2024
  });
1659
2025
  case 21:
1660
- preparedDiscountList = _context17.sent;
2026
+ preparedDiscountList = _context20.sent;
1661
2027
  this.discountConfigCacheKey = discountConfigCacheKey;
1662
- _context17.next = 25;
2028
+ _context20.next = 25;
1663
2029
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
1664
2030
  case 25:
1665
2031
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
1666
- _context17.next = 27;
2032
+ _context20.next = 27;
1667
2033
  break;
1668
2034
  }
1669
- return _context17.abrupt("return", {
2035
+ return _context20.abrupt("return", {
1670
2036
  productList: tempOrder.products || [],
1671
- discountList: currentDiscountList
2037
+ discountList: currentDiscountList,
2038
+ availableWalletIds: this.getAvailableWalletIds()
1672
2039
  });
1673
2040
  case 27:
1674
2041
  nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
1675
2042
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
1676
- _context17.next = 31;
2043
+ _context20.next = 31;
1677
2044
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1678
2045
  case 31:
1679
2046
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
@@ -1683,17 +2050,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1683
2050
  nextDiscountList: nextDiscountList
1684
2051
  });
1685
2052
  if (!shouldSkipAutoApplyFetchedDiscounts) {
1686
- _context17.next = 40;
2053
+ _context20.next = 40;
1687
2054
  break;
1688
2055
  }
1689
- _context17.next = 35;
2056
+ _context20.next = 35;
1690
2057
  return this.store.order.recalculateSummary({
1691
2058
  createIfMissing: true
1692
2059
  });
1693
2060
  case 35:
1694
- _summary = _context17.sent;
2061
+ _summary = _context20.sent;
1695
2062
  this.store.order.persistTempOrder();
1696
- _context17.next = 39;
2063
+ _context20.next = 39;
1697
2064
  return this.effectsEmit('onDiscountApplied', {
1698
2065
  productList: tempOrder.products || [],
1699
2066
  discountList: nextDiscountList,
@@ -1701,22 +2068,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1701
2068
  tempOrder: tempOrder
1702
2069
  });
1703
2070
  case 39:
1704
- return _context17.abrupt("return", {
2071
+ return _context20.abrupt("return", {
1705
2072
  productList: tempOrder.products || [],
1706
- discountList: nextDiscountList
2073
+ discountList: nextDiscountList,
2074
+ availableWalletIds: this.getAvailableWalletIds()
1707
2075
  });
1708
2076
  case 40:
1709
2077
  if (!rulesModule) {
1710
- _context17.next = 78;
2078
+ _context20.next = 77;
1711
2079
  break;
1712
2080
  }
1713
- holders = ((_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
1714
2081
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
1715
2082
  console.log('[BaseSales.applyDiscountConfig.calcDiscount]');
1716
2083
  result = rulesModule.calcDiscount({
1717
2084
  productList: tempOrder.products,
1718
2085
  discountList: nextDiscountList,
1719
- holders: holders,
2086
+ holders: [],
1720
2087
  isFormSubject: function isFormSubject(product) {
1721
2088
  return resolveIsFormSubject(tempOrder, product);
1722
2089
  },
@@ -1728,23 +2095,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1728
2095
  if (result.productList) {
1729
2096
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1730
2097
  }
1731
- _iterator = _createForOfIteratorHelper(tempOrder.products || []);
1732
- _context17.prev = 47;
1733
- _iterator.s();
1734
- case 49:
1735
- if ((_step = _iterator.n()).done) {
1736
- _context17.next = 64;
2098
+ _iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
2099
+ _context20.prev = 46;
2100
+ _iterator2.s();
2101
+ case 48:
2102
+ if ((_step2 = _iterator2.n()).done) {
2103
+ _context20.next = 63;
1737
2104
  break;
1738
2105
  }
1739
- product = _step.value;
2106
+ product = _step2.value;
1740
2107
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
1741
2108
  runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
1742
2109
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
1743
- _context17.next = 55;
2110
+ _context20.next = 54;
1744
2111
  break;
1745
2112
  }
1746
- return _context17.abrupt("continue", 62);
1747
- case 55:
2113
+ return _context20.abrupt("continue", 61);
2114
+ case 54:
1748
2115
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
1749
2116
  return sum + Number(pd.amount || 0);
1750
2117
  }, 0);
@@ -1760,75 +2127,83 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1760
2127
  mainPrice: newMainSellingPrice,
1761
2128
  bundle: product.product_bundle
1762
2129
  });
1763
- case 62:
1764
- _context17.next = 49;
2130
+ case 61:
2131
+ _context20.next = 48;
1765
2132
  break;
1766
- case 64:
1767
- _context17.next = 69;
2133
+ case 63:
2134
+ _context20.next = 68;
1768
2135
  break;
1769
- case 66:
1770
- _context17.prev = 66;
1771
- _context17.t0 = _context17["catch"](47);
1772
- _iterator.e(_context17.t0);
1773
- case 69:
1774
- _context17.prev = 69;
1775
- _iterator.f();
1776
- return _context17.finish(69);
1777
- case 72:
2136
+ case 65:
2137
+ _context20.prev = 65;
2138
+ _context20.t0 = _context20["catch"](46);
2139
+ _iterator2.e(_context20.t0);
2140
+ case 68:
2141
+ _context20.prev = 68;
2142
+ _iterator2.f();
2143
+ return _context20.finish(68);
2144
+ case 71:
1778
2145
  if (!result.discountList) {
1779
- _context17.next = 78;
2146
+ _context20.next = 77;
1780
2147
  break;
1781
2148
  }
1782
2149
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1783
2150
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1784
- _context17.next = 77;
2151
+ _context20.next = 76;
1785
2152
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1786
- case 77:
2153
+ case 76:
1787
2154
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
1788
2155
  return discount.isSelected;
1789
2156
  });
1790
- case 78:
1791
- _context17.next = 80;
2157
+ case 77:
2158
+ _context20.next = 79;
1792
2159
  return this.store.order.recalculateSummary({
1793
2160
  createIfMissing: true
1794
2161
  });
1795
- case 80:
1796
- summary = _context17.sent;
2162
+ case 79:
2163
+ summary = _context20.sent;
1797
2164
  this.store.order.persistTempOrder();
1798
- _context17.next = 84;
2165
+ _context20.next = 83;
1799
2166
  return this.effectsEmit('onDiscountApplied', {
1800
2167
  productList: tempOrder.products || [],
1801
2168
  discountList: nextDiscountList,
1802
2169
  selectedDiscountList: tempOrder.discount_list || [],
1803
2170
  tempOrder: tempOrder
1804
2171
  });
1805
- case 84:
1806
- return _context17.abrupt("return", {
2172
+ case 83:
2173
+ return _context20.abrupt("return", {
1807
2174
  productList: tempOrder.products || [],
1808
- discountList: nextDiscountList
2175
+ discountList: nextDiscountList,
2176
+ availableWalletIds: this.getAvailableWalletIds()
1809
2177
  });
1810
- case 85:
2178
+ case 84:
1811
2179
  case "end":
1812
- return _context17.stop();
2180
+ return _context20.stop();
1813
2181
  }
1814
- }, _callee17, this, [[47, 66, 69, 72]]);
2182
+ }, _callee20, this, [[46, 65, 68, 71]]);
1815
2183
  }));
1816
- function loadDiscountConfig(_x11) {
2184
+ function loadDiscountConfig(_x13) {
1817
2185
  return _loadDiscountConfig.apply(this, arguments);
1818
2186
  }
1819
2187
  return loadDiscountConfig;
1820
2188
  }()
2189
+ }, {
2190
+ key: "getAvailableWalletIds",
2191
+ value: function getAvailableWalletIds() {
2192
+ var _this$store$order4;
2193
+ if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
2194
+ return this.store.order.getAvailableWalletIds();
2195
+ }
1821
2196
  }, {
1822
2197
  key: "bestDiscount",
1823
2198
  value: function () {
1824
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(cb) {
2199
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cb) {
1825
2200
  var _discountModule$getOr2, _discountModule$getDi3;
1826
- var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _tempOrder$holder2, _orderStore$summary2, holders, orderTotalAmount;
1827
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1828
- while (1) switch (_context18.prev = _context18.next) {
2201
+ var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
2202
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2203
+ while (1) switch (_context21.prev = _context21.next) {
1829
2204
  case 0:
1830
2205
  if (this.store.order) {
1831
- _context18.next = 2;
2206
+ _context21.next = 2;
1832
2207
  break;
1833
2208
  }
1834
2209
  throw new Error('order 模块未初始化');
@@ -1844,20 +2219,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1844
2219
  productList: tempOrder.products || [],
1845
2220
  discountList: nextDiscountList
1846
2221
  };
1847
- _context18.next = 12;
2222
+ _context21.next = 12;
1848
2223
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1849
2224
  case 12:
1850
2225
  if (!rulesModule) {
1851
- _context18.next = 25;
2226
+ _context21.next = 24;
1852
2227
  break;
1853
2228
  }
1854
- holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
1855
2229
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
1856
2230
  console.log('[BaseSales.bestDiscount.calcDiscount]');
1857
2231
  result = rulesModule.calcDiscount({
1858
2232
  productList: tempOrder.products,
1859
2233
  discountList: nextDiscountList,
1860
- holders: holders,
2234
+ holders: [],
1861
2235
  isFormSubject: function isFormSubject(product) {
1862
2236
  return resolveIsFormSubject(tempOrder, product);
1863
2237
  },
@@ -1867,14 +2241,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1867
2241
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1868
2242
  }
1869
2243
  if (!result.discountList) {
1870
- _context18.next = 25;
2244
+ _context21.next = 24;
1871
2245
  break;
1872
2246
  }
1873
2247
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1874
2248
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1875
- _context18.next = 23;
2249
+ _context21.next = 22;
1876
2250
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1877
- case 23:
2251
+ case 22:
1878
2252
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
1879
2253
  return discount.isSelected;
1880
2254
  });
@@ -1882,22 +2256,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1882
2256
  productList: tempOrder.products,
1883
2257
  discountList: nextDiscountList
1884
2258
  };
1885
- case 25:
1886
- _context18.next = 27;
2259
+ case 24:
2260
+ _context21.next = 26;
1887
2261
  return this.store.order.recalculateSummary({
1888
2262
  createIfMissing: true
1889
2263
  });
1890
- case 27:
2264
+ case 26:
1891
2265
  this.store.order.persistTempOrder();
2266
+ _context21.next = 29;
2267
+ return this.effectsEmit('onDiscountApplied', {
2268
+ productList: tempOrder.products || [],
2269
+ discountList: nextDiscountList,
2270
+ selectedDiscountList: tempOrder.discount_list || [],
2271
+ tempOrder: tempOrder
2272
+ });
2273
+ case 29:
1892
2274
  cb === null || cb === void 0 || cb(result);
1893
- return _context18.abrupt("return", result);
1894
- case 30:
2275
+ return _context21.abrupt("return", result);
2276
+ case 31:
1895
2277
  case "end":
1896
- return _context18.stop();
2278
+ return _context21.stop();
1897
2279
  }
1898
- }, _callee18, this);
2280
+ }, _callee21, this);
1899
2281
  }));
1900
- function bestDiscount(_x12) {
2282
+ function bestDiscount(_x14) {
1901
2283
  return _bestDiscount.apply(this, arguments);
1902
2284
  }
1903
2285
  return bestDiscount;
@@ -1908,52 +2290,118 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1908
2290
  if (!this.store.order) return [];
1909
2291
  return this.store.order.getDiscountList();
1910
2292
  }
2293
+
2294
+ /** 读取 Discount 模块原始券列表(未经过 bookingTime 等过滤)。 */
2295
+ }, {
2296
+ key: "getOriginalDiscountList",
2297
+ value: function getOriginalDiscountList() {
2298
+ var _store, _discountModule$getOr3;
2299
+ if (!this.store.order) return [];
2300
+ var discountModule = (_store = this.store.order.store) === null || _store === void 0 ? void 0 : _store.discount;
2301
+ return (discountModule === null || discountModule === void 0 || (_discountModule$getOr3 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr3 === void 0 ? void 0 : _discountModule$getOr3.call(discountModule)) || [];
2302
+ }
2303
+
2304
+ /**
2305
+ * 同步写入 Discount 模块的 discountList / originalDiscountList。
2306
+ * 供 Holder 补全等场景在 OS store 层更新 machinecode holder 字段。
2307
+ */
2308
+ }, {
2309
+ key: "replaceDiscountStoreLists",
2310
+ value: (function () {
2311
+ var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2312
+ var _store2;
2313
+ var discountModule;
2314
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2315
+ while (1) switch (_context22.prev = _context22.next) {
2316
+ case 0:
2317
+ if (this.store.order) {
2318
+ _context22.next = 2;
2319
+ break;
2320
+ }
2321
+ throw new Error('order 模块未初始化');
2322
+ case 2:
2323
+ discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
2324
+ if (discountModule) {
2325
+ _context22.next = 5;
2326
+ break;
2327
+ }
2328
+ return _context22.abrupt("return");
2329
+ case 5:
2330
+ if (!params.originalDiscountList) {
2331
+ _context22.next = 8;
2332
+ break;
2333
+ }
2334
+ _context22.next = 8;
2335
+ return discountModule.setOriginalDiscountList(params.originalDiscountList);
2336
+ case 8:
2337
+ _context22.next = 10;
2338
+ return discountModule.setDiscountList(params.discountList);
2339
+ case 10:
2340
+ case "end":
2341
+ return _context22.stop();
2342
+ }
2343
+ }, _callee22, this);
2344
+ }));
2345
+ function replaceDiscountStoreLists(_x15) {
2346
+ return _replaceDiscountStoreLists.apply(this, arguments);
2347
+ }
2348
+ return replaceDiscountStoreLists;
2349
+ }())
1911
2350
  }, {
1912
2351
  key: "scanPromotionCode",
1913
2352
  value: function () {
1914
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(code, customerId) {
1915
- var raw;
1916
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1917
- while (1) switch (_context19.prev = _context19.next) {
2353
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, customerId) {
2354
+ var raw, tempOrder;
2355
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2356
+ while (1) switch (_context23.prev = _context23.next) {
1918
2357
  case 0:
1919
- _context19.prev = 0;
2358
+ _context23.prev = 0;
1920
2359
  if (this.store.order) {
1921
- _context19.next = 3;
2360
+ _context23.next = 3;
1922
2361
  break;
1923
2362
  }
1924
2363
  throw new Error('order 模块未初始化');
1925
2364
  case 3:
1926
- _context19.next = 5;
2365
+ _context23.next = 5;
1927
2366
  return this.store.order.scanCode(code, customerId);
1928
2367
  case 5:
1929
- raw = _context19.sent;
2368
+ raw = _context23.sent;
1930
2369
  if (!raw.isAvailable) {
1931
- _context19.next = 10;
2370
+ _context23.next = 13;
1932
2371
  break;
1933
2372
  }
1934
- _context19.next = 9;
2373
+ _context23.next = 9;
1935
2374
  return this.store.order.recalculateSummary({
1936
2375
  createIfMissing: true
1937
2376
  });
1938
2377
  case 9:
1939
2378
  this.store.order.persistTempOrder();
1940
- case 10:
1941
- return _context19.abrupt("return", {
2379
+ tempOrder = this.store.order.ensureTempOrder();
2380
+ _context23.next = 13;
2381
+ return this.effectsEmit('onDiscountApplied', {
2382
+ productList: tempOrder.products || [],
2383
+ discountList: this.store.order.getDiscountList(),
2384
+ selectedDiscountList: tempOrder.discount_list || [],
2385
+ tempOrder: tempOrder
2386
+ });
2387
+ case 13:
2388
+ return _context23.abrupt("return", {
1942
2389
  isAvailable: raw.isAvailable,
1943
2390
  type: raw.type,
1944
- unavailableReason: raw.unavailableReason
2391
+ unavailableReason: raw.unavailableReason,
2392
+ scannedDiscountList: raw.scannedDiscountList
1945
2393
  });
1946
- case 13:
1947
- _context19.prev = 13;
1948
- _context19.t0 = _context19["catch"](0);
1949
- throw _context19.t0;
1950
2394
  case 16:
2395
+ _context23.prev = 16;
2396
+ _context23.t0 = _context23["catch"](0);
2397
+ throw _context23.t0;
2398
+ case 19:
1951
2399
  case "end":
1952
- return _context19.stop();
2400
+ return _context23.stop();
1953
2401
  }
1954
- }, _callee19, this, [[0, 13]]);
2402
+ }, _callee23, this, [[0, 16]]);
1955
2403
  }));
1956
- function scanPromotionCode(_x13, _x14) {
2404
+ function scanPromotionCode(_x16, _x17) {
1957
2405
  return _scanPromotionCode.apply(this, arguments);
1958
2406
  }
1959
2407
  return scanPromotionCode;
@@ -1961,14 +2409,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1961
2409
  }, {
1962
2410
  key: "setDiscountSelected",
1963
2411
  value: function () {
1964
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1965
- var _tempOrder$holder3, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator3, _step3, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
1966
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1967
- while (1) switch (_context20.prev = _context20.next) {
2412
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2413
+ var list, updated, tempOrder, orderStore, discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator3, _step3, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator4, _step4, _product$metadata8, _tempOrder$_extend4, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
2414
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2415
+ while (1) switch (_context24.prev = _context24.next) {
1968
2416
  case 0:
1969
- _context20.prev = 0;
2417
+ _context24.prev = 0;
1970
2418
  if (this.store.order) {
1971
- _context20.next = 3;
2419
+ _context24.next = 3;
1972
2420
  break;
1973
2421
  }
1974
2422
  throw new Error('order 模块未初始化');
@@ -1985,18 +2433,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1985
2433
  orderStore = this.store.order.store || {};
1986
2434
  discountModule = orderStore.discount;
1987
2435
  rulesModule = orderStore.rules;
1988
- holders = ((_tempOrder$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_record) || [];
1989
2436
  nextDiscountList = updated;
1990
- _context20.next = 14;
2437
+ _context24.next = 13;
1991
2438
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
1992
- case 14:
2439
+ case 13:
1993
2440
  if (rulesModule) {
1994
2441
  orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
1995
2442
  console.log('[BaseSales.setDiscountSelected.calcDiscount]');
1996
2443
  result = rulesModule.calcDiscount({
1997
2444
  productList: tempOrder.products,
1998
2445
  discountList: updated,
1999
- holders: holders,
2446
+ holders: [],
2000
2447
  isFormSubject: function isFormSubject(product) {
2001
2448
  return resolveIsFormSubject(tempOrder, product);
2002
2449
  },
@@ -2019,10 +2466,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2019
2466
  }).map(function (d) {
2020
2467
  return d.id;
2021
2468
  }));
2022
- _iterator2 = _createForOfIteratorHelper(nextDiscountList);
2469
+ _iterator3 = _createForOfIteratorHelper(nextDiscountList);
2023
2470
  try {
2024
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2025
- d = _step2.value;
2471
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2472
+ d = _step3.value;
2026
2473
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
2027
2474
  d.isSelected = false;
2028
2475
  d.isManualSelect = true;
@@ -2030,9 +2477,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2030
2477
  }
2031
2478
  }
2032
2479
  } catch (err) {
2033
- _iterator2.e(err);
2480
+ _iterator3.e(err);
2034
2481
  } finally {
2035
- _iterator2.f();
2482
+ _iterator3.f();
2036
2483
  }
2037
2484
  }
2038
2485
  }
@@ -2049,30 +2496,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2049
2496
  return rid != null && selectedResourceIds.has(rid);
2050
2497
  });
2051
2498
  };
2052
- _iterator3 = _createForOfIteratorHelper(tempOrder.products);
2053
- _context20.prev = 18;
2054
- _iterator3.s();
2055
- case 20:
2056
- if ((_step3 = _iterator3.n()).done) {
2057
- _context20.next = 37;
2499
+ _iterator4 = _createForOfIteratorHelper(tempOrder.products);
2500
+ _context24.prev = 17;
2501
+ _iterator4.s();
2502
+ case 19:
2503
+ if ((_step4 = _iterator4.n()).done) {
2504
+ _context24.next = 36;
2058
2505
  break;
2059
2506
  }
2060
- product = _step3.value;
2507
+ product = _step4.value;
2061
2508
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
2062
2509
  runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
2063
2510
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2064
- _context20.next = 26;
2511
+ _context24.next = 25;
2065
2512
  break;
2066
2513
  }
2067
- return _context20.abrupt("continue", 35);
2068
- case 26:
2514
+ return _context24.abrupt("continue", 34);
2515
+ case 25:
2069
2516
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2070
2517
  if (Array.isArray(product.product_bundle)) {
2071
2518
  product.product_bundle = product.product_bundle.map(function (bundle) {
2072
- var _ref19, _bundle$original_pric;
2519
+ var _ref21, _bundle$original_pric;
2073
2520
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
2074
2521
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
2075
- var restoredBundlePrice = (_ref19 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref19 !== void 0 ? _ref19 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2522
+ var restoredBundlePrice = (_ref21 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref21 !== void 0 ? _ref21 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
2076
2523
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
2077
2524
  price: restoredBundlePrice,
2078
2525
  bundle_selling_price: restoredBundlePrice
@@ -2099,33 +2546,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2099
2546
  mainPrice: newMainSellingPrice,
2100
2547
  bundle: product.product_bundle
2101
2548
  });
2102
- case 35:
2103
- _context20.next = 20;
2549
+ case 34:
2550
+ _context24.next = 19;
2104
2551
  break;
2105
- case 37:
2106
- _context20.next = 42;
2552
+ case 36:
2553
+ _context24.next = 41;
2107
2554
  break;
2108
- case 39:
2109
- _context20.prev = 39;
2110
- _context20.t0 = _context20["catch"](18);
2111
- _iterator3.e(_context20.t0);
2112
- case 42:
2113
- _context20.prev = 42;
2114
- _iterator3.f();
2115
- return _context20.finish(42);
2116
- case 45:
2555
+ case 38:
2556
+ _context24.prev = 38;
2557
+ _context24.t0 = _context24["catch"](17);
2558
+ _iterator4.e(_context24.t0);
2559
+ case 41:
2560
+ _context24.prev = 41;
2561
+ _iterator4.f();
2562
+ return _context24.finish(41);
2563
+ case 44:
2117
2564
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2118
- _context20.next = 48;
2565
+ _context24.next = 47;
2119
2566
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2120
- case 48:
2567
+ case 47:
2121
2568
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2122
2569
  return d.isSelected;
2123
2570
  });
2124
- _context20.next = 51;
2571
+ _context24.next = 50;
2125
2572
  return this.store.order.recalculateSummary({
2126
2573
  createIfMissing: true
2127
2574
  });
2128
- case 51:
2575
+ case 50:
2129
2576
  this.store.order.persistTempOrder();
2130
2577
  this.effectsEmit('onDiscountApplied', {
2131
2578
  productList: tempOrder.products,
@@ -2133,19 +2580,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2133
2580
  selectedDiscountList: tempOrder.discount_list,
2134
2581
  tempOrder: tempOrder
2135
2582
  });
2136
- _context20.next = 58;
2583
+ _context24.next = 57;
2137
2584
  break;
2138
- case 55:
2139
- _context20.prev = 55;
2140
- _context20.t1 = _context20["catch"](0);
2141
- throw _context20.t1;
2142
- case 58:
2585
+ case 54:
2586
+ _context24.prev = 54;
2587
+ _context24.t1 = _context24["catch"](0);
2588
+ throw _context24.t1;
2589
+ case 57:
2143
2590
  case "end":
2144
- return _context20.stop();
2591
+ return _context24.stop();
2145
2592
  }
2146
- }, _callee20, this, [[0, 55], [18, 39, 42, 45]]);
2593
+ }, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
2147
2594
  }));
2148
- function setDiscountSelected(_x15) {
2595
+ function setDiscountSelected(_x18) {
2149
2596
  return _setDiscountSelected.apply(this, arguments);
2150
2597
  }
2151
2598
  return setDiscountSelected;
@@ -2153,23 +2600,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2153
2600
  }, {
2154
2601
  key: "applyDiscountCalculationResult",
2155
2602
  value: function () {
2156
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(result) {
2603
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(result) {
2157
2604
  var tempOrder, orderStore, discountModule;
2158
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2159
- while (1) switch (_context21.prev = _context21.next) {
2605
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2606
+ while (1) switch (_context25.prev = _context25.next) {
2160
2607
  case 0:
2161
- _context21.prev = 0;
2608
+ _context25.prev = 0;
2162
2609
  if (this.store.order) {
2163
- _context21.next = 3;
2610
+ _context25.next = 3;
2164
2611
  break;
2165
2612
  }
2166
2613
  throw new Error('order 模块未初始化');
2167
2614
  case 3:
2168
2615
  if (result) {
2169
- _context21.next = 5;
2616
+ _context25.next = 5;
2170
2617
  break;
2171
2618
  }
2172
- return _context21.abrupt("return");
2619
+ return _context25.abrupt("return");
2173
2620
  case 5:
2174
2621
  tempOrder = this.store.order.ensureTempOrder();
2175
2622
  orderStore = this.store.order.store || {};
@@ -2178,36 +2625,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2178
2625
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2179
2626
  }
2180
2627
  if (!result.discountList) {
2181
- _context21.next = 14;
2628
+ _context25.next = 14;
2182
2629
  break;
2183
2630
  }
2184
2631
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
2185
- _context21.next = 13;
2632
+ _context25.next = 13;
2186
2633
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
2187
2634
  case 13:
2188
2635
  tempOrder.discount_list = result.discountList.filter(function (discount) {
2189
2636
  return discount.isSelected;
2190
2637
  });
2191
2638
  case 14:
2192
- _context21.next = 16;
2639
+ _context25.next = 16;
2193
2640
  return this.store.order.recalculateSummary({
2194
2641
  createIfMissing: true
2195
2642
  });
2196
2643
  case 16:
2197
2644
  this.store.order.persistTempOrder();
2198
- _context21.next = 22;
2199
- break;
2645
+ _context25.next = 19;
2646
+ return this.effectsEmit('onDiscountApplied', {
2647
+ productList: tempOrder.products || [],
2648
+ discountList: result.discountList || [],
2649
+ selectedDiscountList: tempOrder.discount_list || [],
2650
+ tempOrder: tempOrder
2651
+ });
2200
2652
  case 19:
2201
- _context21.prev = 19;
2202
- _context21.t0 = _context21["catch"](0);
2203
- throw _context21.t0;
2204
- case 22:
2653
+ _context25.next = 24;
2654
+ break;
2655
+ case 21:
2656
+ _context25.prev = 21;
2657
+ _context25.t0 = _context25["catch"](0);
2658
+ throw _context25.t0;
2659
+ case 24:
2205
2660
  case "end":
2206
- return _context21.stop();
2661
+ return _context25.stop();
2207
2662
  }
2208
- }, _callee21, this, [[0, 19]]);
2663
+ }, _callee25, this, [[0, 21]]);
2209
2664
  }));
2210
- function applyDiscountCalculationResult(_x16) {
2665
+ function applyDiscountCalculationResult(_x19) {
2211
2666
  return _applyDiscountCalculationResult.apply(this, arguments);
2212
2667
  }
2213
2668
  return applyDiscountCalculationResult;
@@ -2215,18 +2670,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2215
2670
  }, {
2216
2671
  key: "submitScanOrder",
2217
2672
  value: function () {
2218
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2219
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2220
- while (1) switch (_context22.prev = _context22.next) {
2673
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2674
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2675
+ while (1) switch (_context26.prev = _context26.next) {
2221
2676
  case 0:
2222
- return _context22.abrupt("return", this.submitSalesOrder(params));
2677
+ return _context26.abrupt("return", this.submitSalesOrder(params));
2223
2678
  case 1:
2224
2679
  case "end":
2225
- return _context22.stop();
2680
+ return _context26.stop();
2226
2681
  }
2227
- }, _callee22, this);
2682
+ }, _callee26, this);
2228
2683
  }));
2229
- function submitScanOrder(_x17) {
2684
+ function submitScanOrder(_x20) {
2230
2685
  return _submitScanOrder.apply(this, arguments);
2231
2686
  }
2232
2687
  return submitScanOrder;
@@ -2240,14 +2695,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2240
2695
  }, {
2241
2696
  key: "submitSalesOrder",
2242
2697
  value: (function () {
2243
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2698
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2244
2699
  var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
2245
2700
  var inferredPaymentStatus, submitParams;
2246
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2247
- while (1) switch (_context23.prev = _context23.next) {
2701
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2702
+ while (1) switch (_context27.prev = _context27.next) {
2248
2703
  case 0:
2249
2704
  if (this.store.order) {
2250
- _context23.next = 2;
2705
+ _context27.next = 2;
2251
2706
  break;
2252
2707
  }
2253
2708
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2272,29 +2727,63 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2272
2727
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2273
2728
  enhancePayload: params.enhancePayload
2274
2729
  } : {});
2275
- return _context23.abrupt("return", this.store.order.submitTempOrder(submitParams));
2730
+ return _context27.abrupt("return", this.store.order.submitTempOrder(submitParams));
2276
2731
  case 5:
2277
2732
  case "end":
2278
- return _context23.stop();
2733
+ return _context27.stop();
2279
2734
  }
2280
- }, _callee23, this);
2735
+ }, _callee27, this);
2281
2736
  }));
2282
- function submitSalesOrder(_x18) {
2737
+ function submitSalesOrder(_x21) {
2283
2738
  return _submitSalesOrder.apply(this, arguments);
2284
2739
  }
2285
2740
  return submitSalesOrder;
2286
2741
  }())
2742
+ }, {
2743
+ key: "saveSalesOrderDraft",
2744
+ value: function () {
2745
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2746
+ var _params$platform, _this$otherParams10, _ref22, _params$businessCode, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2747
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2748
+ while (1) switch (_context28.prev = _context28.next) {
2749
+ case 0:
2750
+ if (this.store.order) {
2751
+ _context28.next = 2;
2752
+ break;
2753
+ }
2754
+ throw new Error('BaseSales 解决方案需要 order 模块支持');
2755
+ case 2:
2756
+ return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2757
+ cacheId: this.cacheId,
2758
+ platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2759
+ businessCode: (_ref22 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
2760
+ channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2761
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2762
+ }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2763
+ enhancePayload: params.enhancePayload
2764
+ } : {})));
2765
+ case 3:
2766
+ case "end":
2767
+ return _context28.stop();
2768
+ }
2769
+ }, _callee28, this);
2770
+ }));
2771
+ function saveSalesOrderDraft(_x22) {
2772
+ return _saveSalesOrderDraft.apply(this, arguments);
2773
+ }
2774
+ return saveSalesOrderDraft;
2775
+ }()
2287
2776
  }, {
2288
2777
  key: "submitTempOrderAsync",
2289
2778
  value: function () {
2290
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2291
- var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
2779
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
2780
+ var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2292
2781
  var inferredPaymentStatus, submitParams;
2293
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2294
- while (1) switch (_context24.prev = _context24.next) {
2782
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2783
+ while (1) switch (_context29.prev = _context29.next) {
2295
2784
  case 0:
2296
2785
  if (this.store.order) {
2297
- _context24.next = 2;
2786
+ _context29.next = 2;
2298
2787
  break;
2299
2788
  }
2300
2789
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2302,10 +2791,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2302
2791
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
2303
2792
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
2304
2793
  cacheId: this.cacheId,
2305
- platform: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2306
- businessCode: ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
2794
+ platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2795
+ businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
2307
2796
  channel: this.getSubmitOrderSalesChannel(),
2308
- type: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2797
+ type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2309
2798
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
2310
2799
  payments: params.payments
2311
2800
  } : {}), inferredPaymentStatus !== undefined ? {
@@ -2317,14 +2806,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2317
2806
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2318
2807
  enhancePayload: params.enhancePayload
2319
2808
  } : {});
2320
- return _context24.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2809
+ return _context29.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2321
2810
  case 5:
2322
2811
  case "end":
2323
- return _context24.stop();
2812
+ return _context29.stop();
2324
2813
  }
2325
- }, _callee24, this);
2814
+ }, _callee29, this);
2326
2815
  }));
2327
- function submitTempOrderAsync(_x19) {
2816
+ function submitTempOrderAsync(_x23) {
2328
2817
  return _submitTempOrderAsync.apply(this, arguments);
2329
2818
  }
2330
2819
  return submitTempOrderAsync;
@@ -2332,14 +2821,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2332
2821
  }, {
2333
2822
  key: "printLocalOrderReceipt",
2334
2823
  value: function () {
2335
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(lookup) {
2336
- var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2337
- var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order4, _data;
2338
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2339
- while (1) switch (_context25.prev = _context25.next) {
2824
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(lookup) {
2825
+ var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
2826
+ var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2827
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2828
+ while (1) switch (_context30.prev = _context30.next) {
2340
2829
  case 0:
2341
2830
  if (this.store.order) {
2342
- _context25.next = 2;
2831
+ _context30.next = 2;
2343
2832
  break;
2344
2833
  }
2345
2834
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2351,10 +2840,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2351
2840
  external_sale_number: lookup
2352
2841
  };
2353
2842
  context = {
2354
- platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
2355
- businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
2843
+ platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
2844
+ businessCode: ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
2356
2845
  channel: this.getSubmitOrderSalesChannel(),
2357
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type
2846
+ type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
2358
2847
  };
2359
2848
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
2360
2849
  lookup_order_from_db: 1,
@@ -2370,28 +2859,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2370
2859
  channel: context.channel,
2371
2860
  type: context.type
2372
2861
  });
2373
- _context25.next = 8;
2862
+ _context30.next = 8;
2374
2863
  return this.request.post('/local/print-order', payload, {
2375
2864
  osServer: true,
2376
2865
  customToast: function customToast() {}
2377
2866
  });
2378
2867
  case 8:
2379
- response = _context25.sent;
2868
+ response = _context30.sent;
2380
2869
  if (hasLookup) {
2381
- _context25.next = 12;
2870
+ _context30.next = 12;
2382
2871
  break;
2383
2872
  }
2384
- _context25.next = 12;
2385
- return (_this$store$order$app = (_this$store$order4 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order4, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2873
+ _context30.next = 12;
2874
+ return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
2386
2875
  case 12:
2387
- return _context25.abrupt("return", response);
2876
+ return _context30.abrupt("return", response);
2388
2877
  case 13:
2389
2878
  case "end":
2390
- return _context25.stop();
2879
+ return _context30.stop();
2391
2880
  }
2392
- }, _callee25, this);
2881
+ }, _callee30, this);
2393
2882
  }));
2394
- function printLocalOrderReceipt(_x20) {
2883
+ function printLocalOrderReceipt(_x24) {
2395
2884
  return _printLocalOrderReceipt.apply(this, arguments);
2396
2885
  }
2397
2886
  return printLocalOrderReceipt;
@@ -2399,9 +2888,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2399
2888
  }, {
2400
2889
  key: "getSubmitPaymentStatus",
2401
2890
  value: function getSubmitPaymentStatus(paymentStatus) {
2402
- var _this$store$order5, _this$store$order5$ge;
2891
+ var _this$store$order6, _this$store$order6$ge;
2403
2892
  if (paymentStatus !== undefined) return paymentStatus;
2404
- var amountSnapshot = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getOrderAmountSnapshot) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
2893
+ var amountSnapshot = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderAmountSnapshot) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
2405
2894
  if (!amountSnapshot) return undefined;
2406
2895
  try {
2407
2896
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -2412,20 +2901,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2412
2901
  }, {
2413
2902
  key: "syncPaymentsToOrder",
2414
2903
  value: function () {
2415
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2416
- var _ref20, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2904
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2905
+ var _ref23, _params$businessCode2, _this$otherParams22, _this$otherParams23, _params$channel2;
2417
2906
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2418
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2419
- while (1) switch (_context26.prev = _context26.next) {
2907
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2908
+ while (1) switch (_context31.prev = _context31.next) {
2420
2909
  case 0:
2421
2910
  if (this.store.order) {
2422
- _context26.next = 2;
2911
+ _context31.next = 2;
2423
2912
  break;
2424
2913
  }
2425
2914
  throw new Error('order 模块未初始化');
2426
2915
  case 2:
2427
- businessCode = (_ref20 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _ref20 !== void 0 ? _ref20 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
2428
- channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
2916
+ businessCode = (_ref23 = (_params$businessCode2 = params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref23 !== void 0 ? _ref23 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
2917
+ channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
2429
2918
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2430
2919
  businessCode: businessCode
2431
2920
  } : {}), channel !== undefined ? {
@@ -2433,14 +2922,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2433
2922
  } : {});
2434
2923
  syncState = this.store.order.getOrderSyncState();
2435
2924
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
2436
- _context26.next = 9;
2925
+ _context31.next = 9;
2437
2926
  break;
2438
2927
  }
2439
2928
  this.queueLatestAutoPaymentSync();
2440
- return _context26.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2929
+ return _context31.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2441
2930
  case 9:
2442
2931
  payments = params.payments || [];
2443
- _context26.next = 12;
2932
+ _context31.next = 12;
2444
2933
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2445
2934
  payments: payments,
2446
2935
  params: syncParams,
@@ -2448,11 +2937,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2448
2937
  orderSnapshot: this.store.order.getOrderSnapshot()
2449
2938
  });
2450
2939
  case 12:
2451
- _context26.prev = 12;
2452
- _context26.next = 15;
2940
+ _context31.prev = 12;
2941
+ _context31.next = 15;
2453
2942
  return this.store.order.syncPaymentsToOrder(syncParams);
2454
2943
  case 15:
2455
- syncResult = _context26.sent;
2944
+ syncResult = _context31.sent;
2456
2945
  latestPayments = this.store.order.getOrderPayments();
2457
2946
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
2458
2947
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -2470,25 +2959,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2470
2959
  depositAmount: syncResult.depositAmount,
2471
2960
  orderExpectedAmount: syncResult.orderExpectedAmount
2472
2961
  };
2473
- _context26.next = 22;
2962
+ _context31.next = 22;
2474
2963
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2475
2964
  case 22:
2476
2965
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2477
- _context26.next = 25;
2966
+ _context31.next = 25;
2478
2967
  break;
2479
2968
  }
2480
- _context26.next = 25;
2969
+ _context31.next = 25;
2481
2970
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2482
2971
  case 25:
2483
2972
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2484
- return _context26.abrupt("return", syncResult);
2973
+ return _context31.abrupt("return", syncResult);
2485
2974
  case 29:
2486
- _context26.prev = 29;
2487
- _context26.t0 = _context26["catch"](12);
2488
- _context26.next = 33;
2975
+ _context31.prev = 29;
2976
+ _context31.t0 = _context31["catch"](12);
2977
+ _context31.next = 33;
2489
2978
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2490
2979
  ok: false,
2491
- error: _context26.t0,
2980
+ error: _context31.t0,
2492
2981
  payments: this.store.order.getOrderPayments(),
2493
2982
  params: syncParams,
2494
2983
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -2496,14 +2985,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2496
2985
  });
2497
2986
  case 33:
2498
2987
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2499
- throw _context26.t0;
2988
+ throw _context31.t0;
2500
2989
  case 35:
2501
2990
  case "end":
2502
- return _context26.stop();
2991
+ return _context31.stop();
2503
2992
  }
2504
- }, _callee26, this, [[12, 29]]);
2993
+ }, _callee31, this, [[12, 29]]);
2505
2994
  }));
2506
- function syncPaymentsToOrder(_x21) {
2995
+ function syncPaymentsToOrder(_x25) {
2507
2996
  return _syncPaymentsToOrder.apply(this, arguments);
2508
2997
  }
2509
2998
  return syncPaymentsToOrder;
@@ -2540,58 +3029,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2540
3029
  }, {
2541
3030
  key: "scheduleQueuedAutoPaymentSyncFlush",
2542
3031
  value: function scheduleQueuedAutoPaymentSyncFlush() {
2543
- var _this10 = this;
3032
+ var _this13 = this;
2544
3033
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
2545
3034
  if (!this.queuedAutoPaymentSync) return;
2546
3035
  if (this.autoPaymentSyncTimer) return;
2547
3036
  this.autoPaymentSyncTimer = setTimeout(function () {
2548
- _this10.autoPaymentSyncTimer = null;
2549
- void _this10.flushQueuedAutoPaymentSync();
3037
+ _this13.autoPaymentSyncTimer = null;
3038
+ void _this13.flushQueuedAutoPaymentSync();
2550
3039
  }, delay);
2551
3040
  }
2552
3041
  }, {
2553
3042
  key: "flushQueuedAutoPaymentSync",
2554
3043
  value: function () {
2555
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
3044
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2556
3045
  var payments;
2557
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2558
- while (1) switch (_context27.prev = _context27.next) {
3046
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3047
+ while (1) switch (_context32.prev = _context32.next) {
2559
3048
  case 0:
2560
3049
  if (this.store.order) {
2561
- _context27.next = 2;
3050
+ _context32.next = 2;
2562
3051
  break;
2563
3052
  }
2564
- return _context27.abrupt("return");
3053
+ return _context32.abrupt("return");
2565
3054
  case 2:
2566
3055
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
2567
- _context27.next = 4;
3056
+ _context32.next = 4;
2568
3057
  break;
2569
3058
  }
2570
- return _context27.abrupt("return");
3059
+ return _context32.abrupt("return");
2571
3060
  case 4:
2572
3061
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
2573
- _context27.next = 7;
3062
+ _context32.next = 7;
2574
3063
  break;
2575
3064
  }
2576
3065
  this.scheduleQueuedAutoPaymentSyncFlush();
2577
- return _context27.abrupt("return");
3066
+ return _context32.abrupt("return");
2578
3067
  case 7:
2579
3068
  this.autoPaymentSyncFlushing = true;
2580
- _context27.prev = 8;
3069
+ _context32.prev = 8;
2581
3070
  case 9:
2582
3071
  if (!this.queuedAutoPaymentSync) {
2583
- _context27.next = 18;
3072
+ _context32.next = 18;
2584
3073
  break;
2585
3074
  }
2586
3075
  this.queuedAutoPaymentSync = false;
2587
3076
  payments = this.store.order.getOrderPayments();
2588
3077
  if (payments.length) {
2589
- _context27.next = 14;
3078
+ _context32.next = 14;
2590
3079
  break;
2591
3080
  }
2592
- return _context27.abrupt("continue", 9);
3081
+ return _context32.abrupt("continue", 9);
2593
3082
  case 14:
2594
- _context27.next = 16;
3083
+ _context32.next = 16;
2595
3084
  return this.syncPaymentsToOrder({
2596
3085
  payments: payments,
2597
3086
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -2599,44 +3088,94 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2599
3088
  smallTicketDataFlag: 1
2600
3089
  });
2601
3090
  case 16:
2602
- _context27.next = 9;
3091
+ _context32.next = 9;
2603
3092
  break;
2604
3093
  case 18:
2605
- _context27.next = 23;
3094
+ _context32.next = 23;
2606
3095
  break;
2607
3096
  case 20:
2608
- _context27.prev = 20;
2609
- _context27.t0 = _context27["catch"](8);
3097
+ _context32.prev = 20;
3098
+ _context32.t0 = _context32["catch"](8);
2610
3099
  this.logError('queued auto sync payments failed', {
2611
- error: _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0)
3100
+ error: _context32.t0 instanceof Error ? _context32.t0.message : String(_context32.t0)
2612
3101
  });
2613
3102
  case 23:
2614
- _context27.prev = 23;
3103
+ _context32.prev = 23;
2615
3104
  this.autoPaymentSyncFlushing = false;
2616
3105
  if (this.queuedAutoPaymentSync) {
2617
3106
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2618
3107
  }
2619
- return _context27.finish(23);
3108
+ return _context32.finish(23);
2620
3109
  case 27:
2621
3110
  case "end":
2622
- return _context27.stop();
3111
+ return _context32.stop();
2623
3112
  }
2624
- }, _callee27, this, [[8, 20, 23, 27]]);
3113
+ }, _callee32, this, [[8, 20, 23, 27]]);
2625
3114
  }));
2626
3115
  function flushQueuedAutoPaymentSync() {
2627
3116
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
2628
3117
  }
2629
3118
  return flushQueuedAutoPaymentSync;
2630
- }() /** 追加单个支付项到当前订单。 */
3119
+ }()
3120
+ /**
3121
+ * 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
3122
+ */
2631
3123
  }, {
2632
3124
  key: "addOrderPayment",
2633
3125
  value: function addOrderPayment(payment) {
2634
- var _this$otherParams20,
3126
+ var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
3127
+ return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
3128
+ }
3129
+
3130
+ /**
3131
+ * 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
3132
+ * 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
3133
+ */
3134
+ }, {
3135
+ key: "addOrderPaymentAsync",
3136
+ value: (function () {
3137
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
3138
+ var paymentRecord, hasPaymentNumber, devicePrefix;
3139
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3140
+ while (1) switch (_context33.prev = _context33.next) {
3141
+ case 0:
3142
+ paymentRecord = payment;
3143
+ hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
3144
+ if (!hasPaymentNumber) {
3145
+ _context33.next = 6;
3146
+ break;
3147
+ }
3148
+ _context33.t0 = 'LOCAL';
3149
+ _context33.next = 9;
3150
+ break;
3151
+ case 6:
3152
+ _context33.next = 8;
3153
+ return this.getPaymentNumberDevicePrefixAsync();
3154
+ case 8:
3155
+ _context33.t0 = _context33.sent;
3156
+ case 9:
3157
+ devicePrefix = _context33.t0;
3158
+ return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
3159
+ case 11:
3160
+ case "end":
3161
+ return _context33.stop();
3162
+ }
3163
+ }, _callee33, this);
3164
+ }));
3165
+ function addOrderPaymentAsync(_x26) {
3166
+ return _addOrderPaymentAsync.apply(this, arguments);
3167
+ }
3168
+ return addOrderPaymentAsync;
3169
+ }())
3170
+ }, {
3171
+ key: "addOrderPaymentWithDevicePrefix",
3172
+ value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
3173
+ var _this$otherParams24,
2635
3174
  _paymentRecord$paymen,
2636
3175
  _paymentRecord$create,
2637
- _ref21,
3176
+ _ref24,
2638
3177
  _paymentRecord$origin,
2639
- _this11 = this;
3178
+ _this14 = this;
2640
3179
  if (!this.store.order) throw new Error('order 模块未初始化');
2641
3180
  var paymentRecord = payment;
2642
3181
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -2647,25 +3186,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2647
3186
  return this.store.order.getOrderPayments();
2648
3187
  }
2649
3188
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
2650
- var shopWalletPassId = (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.shop_wallet_pass_id;
3189
+ var shopWalletPassId = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.shop_wallet_pass_id;
2651
3190
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
2652
3191
  metadata.shop_wallet_pass_id = shopWalletPassId;
2653
3192
  }
2654
- if (!metadata.unique_payment_number) {
2655
- metadata.unique_payment_number = createUuidV4();
2656
- }
3193
+ var normalizedPaymentRecord = ensureOrderPaymentNumber(paymentRecord, devicePrefix, createUuidV4);
2657
3194
  var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
2658
3195
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
2659
3196
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
2660
3197
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
2661
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref21 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref21 !== void 0 ? _ref21 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
2662
- var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
3198
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref24 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref24 !== void 0 ? _ref24 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3199
+ var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
2663
3200
  service_fee: calculatedServiceFee
2664
3201
  } : {}), {}, {
2665
3202
  metadata: metadata,
2666
3203
  payment_time: paymentTime,
2667
3204
  created_at: createdAt
2668
3205
  }));
3206
+ if (paymentRecord.status === 'payment_pending') {
3207
+ return payments;
3208
+ }
2669
3209
  var amountSnapshot = this.store.order.getOrderAmountSnapshot();
2670
3210
  var syncState = this.store.order.getOrderSyncState();
2671
3211
  if (amountSnapshot) {
@@ -2679,7 +3219,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2679
3219
  submitWhenPaid: true,
2680
3220
  smallTicketDataFlag: 1
2681
3221
  }).catch(function (error) {
2682
- _this11.logError('auto sync payments failed', {
3222
+ _this14.logError('auto sync payments failed', {
2683
3223
  error: error instanceof Error ? error.message : String(error)
2684
3224
  });
2685
3225
  });
@@ -2690,12 +3230,131 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2690
3230
  /** 更新当前订单中的指定支付项。 */
2691
3231
  }, {
2692
3232
  key: "updateOrderPayment",
2693
- value: function updateOrderPayment(paymentIdentity, updates) {
2694
- if (!this.store.order) throw new Error('order 模块未初始化');
2695
- return this.store.order.updateOrderPayment(paymentIdentity, updates);
2696
- }
2697
-
2698
- /** 删除当前订单中的指定支付项。 */
3233
+ value: (function () {
3234
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paymentIdentity, updates) {
3235
+ var _result$payment, _result$payment2;
3236
+ var options,
3237
+ matchMode,
3238
+ previousMatch,
3239
+ previousPayment,
3240
+ _this$store$order$get2,
3241
+ currentPayments,
3242
+ _syncResult,
3243
+ _options$smallTicketD,
3244
+ result,
3245
+ draftResult,
3246
+ draftError,
3247
+ becamePaid,
3248
+ shouldSubmit,
3249
+ syncResult,
3250
+ _options$smallTicketD2,
3251
+ _args34 = arguments;
3252
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3253
+ while (1) switch (_context34.prev = _context34.next) {
3254
+ case 0:
3255
+ options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
3256
+ if (this.store.order) {
3257
+ _context34.next = 3;
3258
+ break;
3259
+ }
3260
+ throw new Error('order 模块未初始化');
3261
+ case 3:
3262
+ matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
3263
+ previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
3264
+ previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
3265
+ if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
3266
+ _context34.next = 13;
3267
+ break;
3268
+ }
3269
+ currentPayments = this.store.order.getOrderPayments();
3270
+ if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
3271
+ _context34.next = 12;
3272
+ break;
3273
+ }
3274
+ _context34.next = 11;
3275
+ return this.syncPaymentsToOrder({
3276
+ payments: currentPayments,
3277
+ paymentStatus: this.getPaymentStatusForSync(currentPayments),
3278
+ submitWhenPaid: true,
3279
+ smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
3280
+ });
3281
+ case 11:
3282
+ _syncResult = _context34.sent;
3283
+ case 12:
3284
+ return _context34.abrupt("return", _objectSpread({
3285
+ updated: false,
3286
+ payment: previousPayment,
3287
+ payments: currentPayments,
3288
+ summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
3289
+ }, _syncResult !== undefined ? {
3290
+ syncResult: _syncResult
3291
+ } : {}));
3292
+ case 13:
3293
+ _context34.next = 15;
3294
+ return this.store.order.updateOrderPayment(paymentIdentity, updates, {
3295
+ matchBy: matchMode
3296
+ });
3297
+ case 15:
3298
+ result = _context34.sent;
3299
+ if (!(options.persistDraft !== false)) {
3300
+ _context34.next = 29;
3301
+ break;
3302
+ }
3303
+ _context34.prev = 17;
3304
+ _context34.next = 20;
3305
+ return this.saveSalesOrderDraft();
3306
+ case 20:
3307
+ draftResult = _context34.sent;
3308
+ _context34.next = 29;
3309
+ break;
3310
+ case 23:
3311
+ _context34.prev = 23;
3312
+ _context34.t0 = _context34["catch"](17);
3313
+ draftError = _context34.t0;
3314
+ this.logError('updateOrderPayment: 保存支付草稿失败', {
3315
+ paymentIdentity: paymentIdentity,
3316
+ error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
3317
+ });
3318
+ if (options.submitWhenPaid) {
3319
+ _context34.next = 29;
3320
+ break;
3321
+ }
3322
+ throw _context34.t0;
3323
+ case 29:
3324
+ becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
3325
+ shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
3326
+ if (!shouldSubmit) {
3327
+ _context34.next = 35;
3328
+ break;
3329
+ }
3330
+ _context34.next = 34;
3331
+ return this.syncPaymentsToOrder({
3332
+ payments: result.payments,
3333
+ paymentStatus: this.getPaymentStatusForSync(result.payments),
3334
+ submitWhenPaid: true,
3335
+ smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
3336
+ });
3337
+ case 34:
3338
+ syncResult = _context34.sent;
3339
+ case 35:
3340
+ return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
3341
+ draftResult: draftResult
3342
+ } : {}), draftError !== undefined ? {
3343
+ draftError: draftError
3344
+ } : {}), syncResult !== undefined ? {
3345
+ syncResult: syncResult
3346
+ } : {}));
3347
+ case 36:
3348
+ case "end":
3349
+ return _context34.stop();
3350
+ }
3351
+ }, _callee34, this, [[17, 23]]);
3352
+ }));
3353
+ function updateOrderPayment(_x27, _x28) {
3354
+ return _updateOrderPayment.apply(this, arguments);
3355
+ }
3356
+ return updateOrderPayment;
3357
+ }() /** 删除当前订单中的指定支付项。 */)
2699
3358
  }, {
2700
3359
  key: "deleteOrderPayment",
2701
3360
  value: function deleteOrderPayment(paymentIdentity) {
@@ -2710,6 +3369,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2710
3369
  if (!this.store.order) throw new Error('order 模块未初始化');
2711
3370
  return this.store.order.updateVoucherOrderPayments(payments, options);
2712
3371
  }
3372
+ }, {
3373
+ key: "updateVoucherOrderPaymentsAsync",
3374
+ value: function () {
3375
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
3376
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3377
+ while (1) switch (_context35.prev = _context35.next) {
3378
+ case 0:
3379
+ if (this.store.order) {
3380
+ _context35.next = 2;
3381
+ break;
3382
+ }
3383
+ throw new Error('order 模块未初始化');
3384
+ case 2:
3385
+ return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
3386
+ case 3:
3387
+ case "end":
3388
+ return _context35.stop();
3389
+ }
3390
+ }, _callee35, this);
3391
+ }));
3392
+ function updateVoucherOrderPaymentsAsync(_x29, _x30) {
3393
+ return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
3394
+ }
3395
+ return updateVoucherOrderPaymentsAsync;
3396
+ }()
2713
3397
  }, {
2714
3398
  key: "confirmPendingVoucherPayments",
2715
3399
  value: function confirmPendingVoucherPayments() {
@@ -2725,8 +3409,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2725
3409
  }, {
2726
3410
  key: "getWalletProductList",
2727
3411
  value: function getWalletProductList() {
2728
- var _this$store$order6, _tempOrder$products;
2729
- var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
3412
+ var _this$store$order7, _tempOrder$products;
3413
+ var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
2730
3414
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
2731
3415
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
2732
3416
  // debugger
@@ -2786,20 +3470,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2786
3470
  }, {
2787
3471
  key: "initWalletData",
2788
3472
  value: function () {
2789
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2790
- var _params$order_wait_pa, _ref22, _tempOrder$is_price_i;
3473
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3474
+ var _params$order_wait_pa, _ref25, _tempOrder$is_price_i;
2791
3475
  var snapshot, tempOrder, amount, walletBusinessData, result;
2792
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2793
- while (1) switch (_context28.prev = _context28.next) {
3476
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3477
+ while (1) switch (_context36.prev = _context36.next) {
2794
3478
  case 0:
2795
3479
  if (this.store.order) {
2796
- _context28.next = 2;
3480
+ _context36.next = 2;
2797
3481
  break;
2798
3482
  }
2799
3483
  throw new Error('order 模块未初始化');
2800
3484
  case 2:
2801
3485
  if (this.store.payment) {
2802
- _context28.next = 4;
3486
+ _context36.next = 4;
2803
3487
  break;
2804
3488
  }
2805
3489
  throw new Error('payment 模块未初始化');
@@ -2808,10 +3492,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2808
3492
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
2809
3493
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
2810
3494
  if (!(!tempOrder || !amount)) {
2811
- _context28.next = 9;
3495
+ _context36.next = 9;
2812
3496
  break;
2813
3497
  }
2814
- return _context28.abrupt("return", {
3498
+ return _context36.abrupt("return", {
2815
3499
  walletRecommendList: [],
2816
3500
  userIdentificationCodes: [],
2817
3501
  transformList: [],
@@ -2830,15 +3514,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2830
3514
  },
2831
3515
  products: this.getWalletProductList(),
2832
3516
  order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
2833
- is_price_include_tax: (_ref22 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref22 !== void 0 ? _ref22 : 1
3517
+ is_price_include_tax: (_ref25 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref25 !== void 0 ? _ref25 : 1
2834
3518
  }, snapshot.identity.orderId ? {
2835
3519
  payment_order_id: String(snapshot.identity.orderId)
2836
3520
  } : {});
2837
- _context28.next = 12;
3521
+ _context36.next = 12;
2838
3522
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
2839
3523
  case 12:
2840
- result = _context28.sent;
2841
- _context28.next = 15;
3524
+ result = _context36.sent;
3525
+ _context36.next = 15;
2842
3526
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
2843
3527
  orderId: snapshot.identity.orderId,
2844
3528
  customerId: walletBusinessData.customer_id,
@@ -2850,14 +3534,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2850
3534
  timestamp: Date.now()
2851
3535
  });
2852
3536
  case 15:
2853
- return _context28.abrupt("return", result);
3537
+ return _context36.abrupt("return", result);
2854
3538
  case 16:
2855
3539
  case "end":
2856
- return _context28.stop();
3540
+ return _context36.stop();
2857
3541
  }
2858
- }, _callee28, this);
3542
+ }, _callee36, this);
2859
3543
  }));
2860
- function initWalletData(_x22) {
3544
+ function initWalletData(_x31) {
2861
3545
  return _initWalletData.apply(this, arguments);
2862
3546
  }
2863
3547
  return initWalletData;
@@ -2884,35 +3568,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2884
3568
  }, {
2885
3569
  key: "getPaymentMethodsAsync",
2886
3570
  value: (function () {
2887
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
3571
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
2888
3572
  var response, paymentMethods;
2889
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2890
- while (1) switch (_context29.prev = _context29.next) {
3573
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3574
+ while (1) switch (_context37.prev = _context37.next) {
2891
3575
  case 0:
2892
- _context29.prev = 0;
2893
- _context29.next = 3;
3576
+ _context37.prev = 0;
3577
+ _context37.next = 3;
2894
3578
  return this.request.get('/pay/custom-payment/all', {
2895
3579
  filterPaymentMethods: true
2896
3580
  }, {
2897
3581
  osServer: true
2898
3582
  });
2899
3583
  case 3:
2900
- response = _context29.sent;
3584
+ response = _context37.sent;
2901
3585
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
2902
3586
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
2903
- return _context29.abrupt("return", this.getPaymentMethods());
3587
+ return _context37.abrupt("return", this.getPaymentMethods());
2904
3588
  case 9:
2905
- _context29.prev = 9;
2906
- _context29.t0 = _context29["catch"](0);
3589
+ _context37.prev = 9;
3590
+ _context37.t0 = _context37["catch"](0);
2907
3591
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
2908
- error: _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0)
3592
+ error: _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0)
2909
3593
  });
2910
- return _context29.abrupt("return", this.getPaymentMethods());
3594
+ return _context37.abrupt("return", this.getPaymentMethods());
2911
3595
  case 13:
2912
3596
  case "end":
2913
- return _context29.stop();
3597
+ return _context37.stop();
2914
3598
  }
2915
- }, _callee29, this, [[0, 9]]);
3599
+ }, _callee37, this, [[0, 9]]);
2916
3600
  }));
2917
3601
  function getPaymentMethodsAsync() {
2918
3602
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -2960,49 +3644,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2960
3644
  }, {
2961
3645
  key: "sendCustomerPayLink",
2962
3646
  value: (function () {
2963
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2964
- var orderIds, _ref23, _ref24, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
2965
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2966
- while (1) switch (_context30.prev = _context30.next) {
3647
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3648
+ var orderIds, _ref26, _ref27, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3649
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3650
+ while (1) switch (_context38.prev = _context38.next) {
2967
3651
  case 0:
2968
3652
  if (this.store.order) {
2969
- _context30.next = 2;
3653
+ _context38.next = 2;
2970
3654
  break;
2971
3655
  }
2972
3656
  throw new Error('order 模块未初始化');
2973
3657
  case 2:
2974
3658
  orderIds = params.order_ids || params.orderIds || [];
2975
3659
  if (!(!orderIds.length || params.submitBeforeSend)) {
2976
- _context30.next = 11;
3660
+ _context38.next = 11;
2977
3661
  break;
2978
3662
  }
2979
- _context30.next = 6;
3663
+ _context38.next = 6;
2980
3664
  return this.submitSalesOrder({
2981
3665
  smallTicketDataFlag: 1
2982
3666
  });
2983
3667
  case 6:
2984
- submitResult = _context30.sent;
2985
- orderId = (_ref23 = (_ref24 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref24 !== void 0 ? _ref24 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref23 !== void 0 ? _ref23 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3668
+ submitResult = _context38.sent;
3669
+ orderId = (_ref26 = (_ref27 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref27 !== void 0 ? _ref27 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
2986
3670
  if (orderId) {
2987
- _context30.next = 10;
3671
+ _context38.next = 10;
2988
3672
  break;
2989
3673
  }
2990
3674
  throw new Error('本地订单提交云端失败,无法发送支付链接');
2991
3675
  case 10:
2992
3676
  orderIds = [orderId];
2993
3677
  case 11:
2994
- return _context30.abrupt("return", this.store.order.sendCustomerPayLink({
3678
+ return _context38.abrupt("return", this.store.order.sendCustomerPayLink({
2995
3679
  emails: params.emails,
2996
3680
  notify_action: params.notify_action,
2997
3681
  order_ids: orderIds
2998
3682
  }));
2999
3683
  case 12:
3000
3684
  case "end":
3001
- return _context30.stop();
3685
+ return _context38.stop();
3002
3686
  }
3003
- }, _callee30, this);
3687
+ }, _callee38, this);
3004
3688
  }));
3005
- function sendCustomerPayLink(_x23) {
3689
+ function sendCustomerPayLink(_x32) {
3006
3690
  return _sendCustomerPayLink.apply(this, arguments);
3007
3691
  }
3008
3692
  return sendCustomerPayLink;
@@ -3015,27 +3699,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3015
3699
  }, {
3016
3700
  key: "calculateProductBookingPrice",
3017
3701
  value: function () {
3018
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3702
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3019
3703
  var _params$customer_id;
3020
3704
  var quotation, customerId, authoritativeProduct, product;
3021
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3022
- while (1) switch (_context31.prev = _context31.next) {
3705
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3706
+ while (1) switch (_context39.prev = _context39.next) {
3023
3707
  case 0:
3024
3708
  quotation = this.store.quotation;
3025
3709
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3026
- _context31.next = 4;
3710
+ _context39.next = 4;
3027
3711
  return this.loadProductForPriceQuery(params, customerId);
3028
3712
  case 4:
3029
- authoritativeProduct = _context31.sent;
3713
+ authoritativeProduct = _context39.sent;
3030
3714
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3031
- _context31.next = 8;
3715
+ _context39.next = 8;
3032
3716
  return this.loadQuotationForPriceQuery({
3033
3717
  quotation: quotation,
3034
3718
  customer_id: customerId,
3035
3719
  channel: params.channel
3036
3720
  });
3037
3721
  case 8:
3038
- return _context31.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3722
+ return _context39.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3039
3723
  product: product,
3040
3724
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3041
3725
  customer_id: customerId,
@@ -3043,11 +3727,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3043
3727
  })));
3044
3728
  case 9:
3045
3729
  case "end":
3046
- return _context31.stop();
3730
+ return _context39.stop();
3047
3731
  }
3048
- }, _callee31, this);
3732
+ }, _callee39, this);
3049
3733
  }));
3050
- function calculateProductBookingPrice(_x24) {
3734
+ function calculateProductBookingPrice(_x33) {
3051
3735
  return _calculateProductBookingPrice.apply(this, arguments);
3052
3736
  }
3053
3737
  return calculateProductBookingPrice;
@@ -3055,7 +3739,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3055
3739
  }, {
3056
3740
  key: "getQuotationCustomerScopeInfo",
3057
3741
  value: function getQuotationCustomerScopeInfo() {
3058
- var _this12 = this;
3742
+ var _this15 = this;
3059
3743
  var quotation = this.store.quotation;
3060
3744
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
3061
3745
  return quotation.getQuotationCustomerScopeInfo();
@@ -3067,7 +3751,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3067
3751
  }).map(function (item) {
3068
3752
  var localSeen = new Set();
3069
3753
  var customers = item.customer.filter(function (customer) {
3070
- var customerId = _this12.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3754
+ var customerId = _this15.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3071
3755
  if (!customerId || localSeen.has(customerId)) return false;
3072
3756
  localSeen.add(customerId);
3073
3757
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -3117,32 +3801,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3117
3801
  }, {
3118
3802
  key: "calculateProductBookingPrices",
3119
3803
  value: function () {
3120
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(paramsList) {
3804
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
3121
3805
  var _paramsList$0$custome,
3122
3806
  _paramsList$,
3123
- _this13 = this,
3807
+ _this16 = this,
3124
3808
  _paramsList$2;
3125
3809
  var quotation, customerId, productMapsByGroup, groups;
3126
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3127
- while (1) switch (_context33.prev = _context33.next) {
3810
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3811
+ while (1) switch (_context41.prev = _context41.next) {
3128
3812
  case 0:
3129
3813
  if (paramsList.length) {
3130
- _context33.next = 2;
3814
+ _context41.next = 2;
3131
3815
  break;
3132
3816
  }
3133
- return _context33.abrupt("return", []);
3817
+ return _context41.abrupt("return", []);
3134
3818
  case 2:
3135
3819
  quotation = this.store.quotation;
3136
3820
  customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
3137
3821
  productMapsByGroup = new Map();
3138
3822
  groups = new Map();
3139
3823
  paramsList.forEach(function (params) {
3140
- var _this13$otherParams;
3824
+ var _this16$otherParams;
3141
3825
  var product = params.product || {};
3142
- var productId = _this13.getPriceQueryProductId(product);
3826
+ var productId = _this16.getPriceQueryProductId(product);
3143
3827
  if (productId === null) return;
3144
- var schedule = _this13.getPriceQuerySchedule(params);
3145
- var channel = params.channel || ((_this13$otherParams = _this13.otherParams) === null || _this13$otherParams === void 0 ? void 0 : _this13$otherParams.channel);
3828
+ var schedule = _this16.getPriceQuerySchedule(params);
3829
+ var channel = params.channel || ((_this16$otherParams = _this16.otherParams) === null || _this16$otherParams === void 0 ? void 0 : _this16$otherParams.channel);
3146
3830
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3147
3831
  var group = groups.get(groupKey) || {
3148
3832
  ids: new Set(),
@@ -3152,51 +3836,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3152
3836
  group.ids.add(productId);
3153
3837
  groups.set(groupKey, group);
3154
3838
  });
3155
- _context33.next = 9;
3839
+ _context41.next = 9;
3156
3840
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3157
- var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(_ref25) {
3158
- var _ref27, groupKey, group, productsById;
3159
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3160
- while (1) switch (_context32.prev = _context32.next) {
3841
+ var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(_ref28) {
3842
+ var _ref30, groupKey, group, productsById;
3843
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3844
+ while (1) switch (_context40.prev = _context40.next) {
3161
3845
  case 0:
3162
- _ref27 = _slicedToArray(_ref25, 2), groupKey = _ref27[0], group = _ref27[1];
3163
- _context32.next = 3;
3164
- return _this13.loadProductsForPriceQuery({
3846
+ _ref30 = _slicedToArray(_ref28, 2), groupKey = _ref30[0], group = _ref30[1];
3847
+ _context40.next = 3;
3848
+ return _this16.loadProductsForPriceQuery({
3165
3849
  ids: Array.from(group.ids),
3166
3850
  schedule: group.schedule,
3167
3851
  customerId: customerId,
3168
3852
  channel: group.channel
3169
3853
  });
3170
3854
  case 3:
3171
- productsById = _context32.sent;
3855
+ productsById = _context40.sent;
3172
3856
  productMapsByGroup.set(groupKey, productsById);
3173
3857
  case 5:
3174
3858
  case "end":
3175
- return _context32.stop();
3859
+ return _context40.stop();
3176
3860
  }
3177
- }, _callee32);
3861
+ }, _callee40);
3178
3862
  }));
3179
- return function (_x26) {
3180
- return _ref26.apply(this, arguments);
3863
+ return function (_x35) {
3864
+ return _ref29.apply(this, arguments);
3181
3865
  };
3182
3866
  }()));
3183
3867
  case 9:
3184
- _context33.next = 11;
3868
+ _context41.next = 11;
3185
3869
  return this.loadQuotationForPriceQuery({
3186
3870
  quotation: quotation,
3187
3871
  customer_id: customerId,
3188
3872
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3189
3873
  });
3190
3874
  case 11:
3191
- return _context33.abrupt("return", paramsList.map(function (params) {
3192
- var _this13$otherParams2, _productMapsByGroup$g;
3875
+ return _context41.abrupt("return", paramsList.map(function (params) {
3876
+ var _this16$otherParams2, _productMapsByGroup$g;
3193
3877
  var productInput = params.product || {};
3194
- var productId = _this13.getPriceQueryProductId(productInput);
3195
- var schedule = _this13.getPriceQuerySchedule(params);
3196
- var channel = params.channel || ((_this13$otherParams2 = _this13.otherParams) === null || _this13$otherParams2 === void 0 ? void 0 : _this13$otherParams2.channel);
3878
+ var productId = _this16.getPriceQueryProductId(productInput);
3879
+ var schedule = _this16.getPriceQuerySchedule(params);
3880
+ var channel = params.channel || ((_this16$otherParams2 = _this16.otherParams) === null || _this16$otherParams2 === void 0 ? void 0 : _this16$otherParams2.channel);
3197
3881
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3198
3882
  var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
3199
- var product = _this13.mergeProductForPriceQuery(productInput, authoritativeProduct);
3883
+ var product = _this16.mergeProductForPriceQuery(productInput, authoritativeProduct);
3200
3884
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3201
3885
  product: product,
3202
3886
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -3206,11 +3890,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3206
3890
  }));
3207
3891
  case 12:
3208
3892
  case "end":
3209
- return _context33.stop();
3893
+ return _context41.stop();
3210
3894
  }
3211
- }, _callee33, this);
3895
+ }, _callee41, this);
3212
3896
  }));
3213
- function calculateProductBookingPrices(_x25) {
3897
+ function calculateProductBookingPrices(_x34) {
3214
3898
  return _calculateProductBookingPrices.apply(this, arguments);
3215
3899
  }
3216
3900
  return calculateProductBookingPrices;
@@ -3218,34 +3902,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3218
3902
  }, {
3219
3903
  key: "addProductToOrder",
3220
3904
  value: function () {
3221
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(product, booking) {
3905
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(product, booking) {
3222
3906
  var products;
3223
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3224
- while (1) switch (_context34.prev = _context34.next) {
3907
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3908
+ while (1) switch (_context42.prev = _context42.next) {
3225
3909
  case 0:
3226
- _context34.prev = 0;
3910
+ _context42.prev = 0;
3227
3911
  if (this.store.order) {
3228
- _context34.next = 3;
3912
+ _context42.next = 3;
3229
3913
  break;
3230
3914
  }
3231
3915
  throw new Error('order 模块未初始化');
3232
3916
  case 3:
3233
- _context34.next = 5;
3917
+ _context42.next = 5;
3234
3918
  return this.store.order.addProductToOrder(product, booking);
3235
3919
  case 5:
3236
- products = _context34.sent;
3237
- return _context34.abrupt("return", products);
3920
+ products = _context42.sent;
3921
+ return _context42.abrupt("return", products);
3238
3922
  case 9:
3239
- _context34.prev = 9;
3240
- _context34.t0 = _context34["catch"](0);
3241
- throw _context34.t0;
3923
+ _context42.prev = 9;
3924
+ _context42.t0 = _context42["catch"](0);
3925
+ throw _context42.t0;
3242
3926
  case 12:
3243
3927
  case "end":
3244
- return _context34.stop();
3928
+ return _context42.stop();
3245
3929
  }
3246
- }, _callee34, this, [[0, 9]]);
3930
+ }, _callee42, this, [[0, 9]]);
3247
3931
  }));
3248
- function addProductToOrder(_x27, _x28) {
3932
+ function addProductToOrder(_x36, _x37) {
3249
3933
  return _addProductToOrder.apply(this, arguments);
3250
3934
  }
3251
3935
  return addProductToOrder;
@@ -3253,34 +3937,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3253
3937
  }, {
3254
3938
  key: "updateOrderProduct",
3255
3939
  value: function () {
3256
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3940
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3257
3941
  var products;
3258
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3259
- while (1) switch (_context35.prev = _context35.next) {
3942
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3943
+ while (1) switch (_context43.prev = _context43.next) {
3260
3944
  case 0:
3261
- _context35.prev = 0;
3945
+ _context43.prev = 0;
3262
3946
  if (this.store.order) {
3263
- _context35.next = 3;
3947
+ _context43.next = 3;
3264
3948
  break;
3265
3949
  }
3266
3950
  throw new Error('order 模块未初始化');
3267
3951
  case 3:
3268
- _context35.next = 5;
3952
+ _context43.next = 5;
3269
3953
  return this.store.order.updateOrderProduct(params);
3270
3954
  case 5:
3271
- products = _context35.sent;
3272
- return _context35.abrupt("return", products);
3955
+ products = _context43.sent;
3956
+ return _context43.abrupt("return", products);
3273
3957
  case 9:
3274
- _context35.prev = 9;
3275
- _context35.t0 = _context35["catch"](0);
3276
- throw _context35.t0;
3958
+ _context43.prev = 9;
3959
+ _context43.t0 = _context43["catch"](0);
3960
+ throw _context43.t0;
3277
3961
  case 12:
3278
3962
  case "end":
3279
- return _context35.stop();
3963
+ return _context43.stop();
3280
3964
  }
3281
- }, _callee35, this, [[0, 9]]);
3965
+ }, _callee43, this, [[0, 9]]);
3282
3966
  }));
3283
- function updateOrderProduct(_x29) {
3967
+ function updateOrderProduct(_x38) {
3284
3968
  return _updateOrderProduct.apply(this, arguments);
3285
3969
  }
3286
3970
  return updateOrderProduct;
@@ -3288,34 +3972,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3288
3972
  }, {
3289
3973
  key: "updateOrderProducts",
3290
3974
  value: function () {
3291
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(paramsList) {
3975
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(paramsList) {
3292
3976
  var products;
3293
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3294
- while (1) switch (_context36.prev = _context36.next) {
3977
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3978
+ while (1) switch (_context44.prev = _context44.next) {
3295
3979
  case 0:
3296
- _context36.prev = 0;
3980
+ _context44.prev = 0;
3297
3981
  if (this.store.order) {
3298
- _context36.next = 3;
3982
+ _context44.next = 3;
3299
3983
  break;
3300
3984
  }
3301
3985
  throw new Error('order 模块未初始化');
3302
3986
  case 3:
3303
- _context36.next = 5;
3987
+ _context44.next = 5;
3304
3988
  return this.store.order.updateOrderProducts(paramsList);
3305
3989
  case 5:
3306
- products = _context36.sent;
3307
- return _context36.abrupt("return", products);
3990
+ products = _context44.sent;
3991
+ return _context44.abrupt("return", products);
3308
3992
  case 9:
3309
- _context36.prev = 9;
3310
- _context36.t0 = _context36["catch"](0);
3311
- throw _context36.t0;
3993
+ _context44.prev = 9;
3994
+ _context44.t0 = _context44["catch"](0);
3995
+ throw _context44.t0;
3312
3996
  case 12:
3313
3997
  case "end":
3314
- return _context36.stop();
3998
+ return _context44.stop();
3315
3999
  }
3316
- }, _callee36, this, [[0, 9]]);
4000
+ }, _callee44, this, [[0, 9]]);
3317
4001
  }));
3318
- function updateOrderProducts(_x30) {
4002
+ function updateOrderProducts(_x39) {
3319
4003
  return _updateOrderProducts.apply(this, arguments);
3320
4004
  }
3321
4005
  return updateOrderProducts;
@@ -3323,34 +4007,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3323
4007
  }, {
3324
4008
  key: "updateOrderProductQuantity",
3325
4009
  value: function () {
3326
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4010
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
3327
4011
  var products;
3328
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3329
- while (1) switch (_context37.prev = _context37.next) {
4012
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
4013
+ while (1) switch (_context45.prev = _context45.next) {
3330
4014
  case 0:
3331
- _context37.prev = 0;
4015
+ _context45.prev = 0;
3332
4016
  if (this.store.order) {
3333
- _context37.next = 3;
4017
+ _context45.next = 3;
3334
4018
  break;
3335
4019
  }
3336
4020
  throw new Error('order 模块未初始化');
3337
4021
  case 3:
3338
- _context37.next = 5;
4022
+ _context45.next = 5;
3339
4023
  return this.store.order.updateOrderProductQuantity(params);
3340
4024
  case 5:
3341
- products = _context37.sent;
3342
- return _context37.abrupt("return", products);
4025
+ products = _context45.sent;
4026
+ return _context45.abrupt("return", products);
3343
4027
  case 9:
3344
- _context37.prev = 9;
3345
- _context37.t0 = _context37["catch"](0);
3346
- throw _context37.t0;
4028
+ _context45.prev = 9;
4029
+ _context45.t0 = _context45["catch"](0);
4030
+ throw _context45.t0;
3347
4031
  case 12:
3348
4032
  case "end":
3349
- return _context37.stop();
4033
+ return _context45.stop();
3350
4034
  }
3351
- }, _callee37, this, [[0, 9]]);
4035
+ }, _callee45, this, [[0, 9]]);
3352
4036
  }));
3353
- function updateOrderProductQuantity(_x31) {
4037
+ function updateOrderProductQuantity(_x40) {
3354
4038
  return _updateOrderProductQuantity.apply(this, arguments);
3355
4039
  }
3356
4040
  return updateOrderProductQuantity;
@@ -3373,12 +4057,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3373
4057
  }, {
3374
4058
  key: "setOrderProductLineNote",
3375
4059
  value: (function () {
3376
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(identity, note) {
4060
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(identity, note) {
3377
4061
  var params, products;
3378
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3379
- while (1) switch (_context38.prev = _context38.next) {
4062
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
4063
+ while (1) switch (_context46.prev = _context46.next) {
3380
4064
  case 0:
3381
- _context38.prev = 0;
4065
+ _context46.prev = 0;
3382
4066
  params = {
3383
4067
  product_id: identity.product_id,
3384
4068
  product_variant_id: identity.product_variant_id,
@@ -3393,22 +4077,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3393
4077
  params.product_sku = identity.product_sku;
3394
4078
  }
3395
4079
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
3396
- _context38.next = 7;
4080
+ _context46.next = 7;
3397
4081
  return this.updateOrderProduct(params);
3398
4082
  case 7:
3399
- products = _context38.sent;
3400
- return _context38.abrupt("return", products);
4083
+ products = _context46.sent;
4084
+ return _context46.abrupt("return", products);
3401
4085
  case 11:
3402
- _context38.prev = 11;
3403
- _context38.t0 = _context38["catch"](0);
3404
- throw _context38.t0;
4086
+ _context46.prev = 11;
4087
+ _context46.t0 = _context46["catch"](0);
4088
+ throw _context46.t0;
3405
4089
  case 14:
3406
4090
  case "end":
3407
- return _context38.stop();
4091
+ return _context46.stop();
3408
4092
  }
3409
- }, _callee38, this, [[0, 11]]);
4093
+ }, _callee46, this, [[0, 11]]);
3410
4094
  }));
3411
- function setOrderProductLineNote(_x32, _x33) {
4095
+ function setOrderProductLineNote(_x41, _x42) {
3412
4096
  return _setOrderProductLineNote.apply(this, arguments);
3413
4097
  }
3414
4098
  return setOrderProductLineNote;
@@ -3423,32 +4107,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3423
4107
  }, {
3424
4108
  key: "removeProductsFromOrder",
3425
4109
  value: (function () {
3426
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(identities) {
3427
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3428
- while (1) switch (_context39.prev = _context39.next) {
4110
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(identities) {
4111
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
4112
+ while (1) switch (_context47.prev = _context47.next) {
3429
4113
  case 0:
3430
- _context39.prev = 0;
4114
+ _context47.prev = 0;
3431
4115
  if (this.store.order) {
3432
- _context39.next = 3;
4116
+ _context47.next = 3;
3433
4117
  break;
3434
4118
  }
3435
4119
  throw new Error('order 模块未初始化');
3436
4120
  case 3:
3437
- _context39.next = 5;
4121
+ _context47.next = 5;
3438
4122
  return this.store.order.removeProductsFromOrder(identities);
3439
4123
  case 5:
3440
- return _context39.abrupt("return", _context39.sent);
4124
+ return _context47.abrupt("return", _context47.sent);
3441
4125
  case 8:
3442
- _context39.prev = 8;
3443
- _context39.t0 = _context39["catch"](0);
3444
- throw _context39.t0;
4126
+ _context47.prev = 8;
4127
+ _context47.t0 = _context47["catch"](0);
4128
+ throw _context47.t0;
3445
4129
  case 11:
3446
4130
  case "end":
3447
- return _context39.stop();
4131
+ return _context47.stop();
3448
4132
  }
3449
- }, _callee39, this, [[0, 8]]);
4133
+ }, _callee47, this, [[0, 8]]);
3450
4134
  }));
3451
- function removeProductsFromOrder(_x34) {
4135
+ function removeProductsFromOrder(_x43) {
3452
4136
  return _removeProductsFromOrder.apply(this, arguments);
3453
4137
  }
3454
4138
  return removeProductsFromOrder;
@@ -3456,18 +4140,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3456
4140
  }, {
3457
4141
  key: "removeProductFromOrder",
3458
4142
  value: function () {
3459
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(identity) {
3460
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3461
- while (1) switch (_context40.prev = _context40.next) {
4143
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(identity) {
4144
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
4145
+ while (1) switch (_context48.prev = _context48.next) {
3462
4146
  case 0:
3463
- return _context40.abrupt("return", this.removeProductsFromOrder([identity]));
4147
+ return _context48.abrupt("return", this.removeProductsFromOrder([identity]));
3464
4148
  case 1:
3465
4149
  case "end":
3466
- return _context40.stop();
4150
+ return _context48.stop();
3467
4151
  }
3468
- }, _callee40, this);
4152
+ }, _callee48, this);
3469
4153
  }));
3470
- function removeProductFromOrder(_x35) {
4154
+ function removeProductFromOrder(_x44) {
3471
4155
  return _removeProductFromOrder.apply(this, arguments);
3472
4156
  }
3473
4157
  return removeProductFromOrder;
@@ -3517,23 +4201,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3517
4201
  }, {
3518
4202
  key: "applyPromotion",
3519
4203
  value: (function () {
3520
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3521
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3522
- while (1) switch (_context41.prev = _context41.next) {
4204
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
4205
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
4206
+ while (1) switch (_context49.prev = _context49.next) {
3523
4207
  case 0:
3524
4208
  if (this.store.order) {
3525
- _context41.next = 2;
4209
+ _context49.next = 2;
3526
4210
  break;
3527
4211
  }
3528
4212
  throw new Error('order 模块未初始化');
3529
4213
  case 2:
3530
- _context41.next = 4;
4214
+ _context49.next = 4;
3531
4215
  return this.store.order.applyPromotion();
3532
4216
  case 4:
3533
4217
  case "end":
3534
- return _context41.stop();
4218
+ return _context49.stop();
3535
4219
  }
3536
- }, _callee41, this);
4220
+ }, _callee49, this);
3537
4221
  }));
3538
4222
  function applyPromotion() {
3539
4223
  return _applyPromotion.apply(this, arguments);
@@ -3543,16 +4227,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3543
4227
  }, {
3544
4228
  key: "getUnfulfilledPromotions",
3545
4229
  value: function getUnfulfilledPromotions() {
3546
- var _this$store$order7;
3547
- return ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getUnfulfilledPromotions()) || [];
4230
+ var _this$store$order8;
4231
+ return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getUnfulfilledPromotions()) || [];
3548
4232
  }
3549
4233
 
3550
4234
  /** 最近一次促销计算输出的赠品操作 diff。 */
3551
4235
  }, {
3552
4236
  key: "getLastGiftActions",
3553
4237
  value: function getLastGiftActions() {
3554
- var _this$store$order8;
3555
- return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getLastGiftActions()) || null;
4238
+ var _this$store$order9;
4239
+ return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
3556
4240
  }
3557
4241
 
3558
4242
  // 获取商品列表
@@ -3560,18 +4244,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3560
4244
  }, {
3561
4245
  key: "getProductList",
3562
4246
  value: function () {
3563
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3564
- var _this$otherParams21;
4247
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
4248
+ var _this$otherParams25;
3565
4249
  var menu_list_ids, _this$store$products, res;
3566
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3567
- while (1) switch (_context42.prev = _context42.next) {
4250
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4251
+ while (1) switch (_context50.prev = _context50.next) {
3568
4252
  case 0:
3569
4253
  // 可以直接通过配置里的 menu 读取
3570
- menu_list_ids = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 || (_this$otherParams21 = _this$otherParams21.dineInConfig) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21['menu.associated_menus'].map(function (n) {
4254
+ menu_list_ids = ((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 || (_this$otherParams25 = _this$otherParams25.dineInConfig) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25['menu.associated_menus'].map(function (n) {
3571
4255
  return Number(n.value);
3572
4256
  })) || [];
3573
- _context42.prev = 1;
3574
- _context42.next = 4;
4257
+ _context50.prev = 1;
4258
+ _context50.next = 4;
3575
4259
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
3576
4260
  menu_list_ids: menu_list_ids,
3577
4261
  cacheId: this.cacheId,
@@ -3579,17 +4263,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3579
4263
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3580
4264
  });
3581
4265
  case 4:
3582
- res = _context42.sent;
3583
- return _context42.abrupt("return", res);
4266
+ res = _context50.sent;
4267
+ return _context50.abrupt("return", res);
3584
4268
  case 8:
3585
- _context42.prev = 8;
3586
- _context42.t0 = _context42["catch"](1);
3587
- throw _context42.t0;
4269
+ _context50.prev = 8;
4270
+ _context50.t0 = _context50["catch"](1);
4271
+ throw _context50.t0;
3588
4272
  case 11:
3589
4273
  case "end":
3590
- return _context42.stop();
4274
+ return _context50.stop();
3591
4275
  }
3592
- }, _callee42, this, [[1, 8]]);
4276
+ }, _callee50, this, [[1, 8]]);
3593
4277
  }));
3594
4278
  function getProductList() {
3595
4279
  return _getProductList.apply(this, arguments);
@@ -3604,33 +4288,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3604
4288
  }, {
3605
4289
  key: "setOtherParams",
3606
4290
  value: function () {
3607
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3608
- var _this$otherParams22;
3609
- var _ref28,
3610
- _ref28$cover,
4291
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4292
+ var _this$otherParams26;
4293
+ var _ref31,
4294
+ _ref31$cover,
3611
4295
  cover,
3612
- _args43 = arguments;
3613
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3614
- while (1) switch (_context43.prev = _context43.next) {
4296
+ _args51 = arguments;
4297
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4298
+ while (1) switch (_context51.prev = _context51.next) {
3615
4299
  case 0:
3616
- _ref28 = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : {}, _ref28$cover = _ref28.cover, cover = _ref28$cover === void 0 ? false : _ref28$cover;
4300
+ _ref31 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
3617
4301
  if (cover) {
3618
4302
  this.otherParams = _objectSpread({}, params);
3619
4303
  } else {
3620
4304
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3621
4305
  }
3622
- this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3623
- _context43.next = 5;
4306
+ this.cacheId = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.cacheId;
4307
+ _context51.next = 5;
3624
4308
  return this.syncOtherParamsToSubModules(params, {
3625
4309
  cover: cover
3626
4310
  });
3627
4311
  case 5:
3628
4312
  case "end":
3629
- return _context43.stop();
4313
+ return _context51.stop();
3630
4314
  }
3631
- }, _callee43, this);
4315
+ }, _callee51, this);
3632
4316
  }));
3633
- function setOtherParams(_x36) {
4317
+ function setOtherParams(_x45) {
3634
4318
  return _setOtherParams.apply(this, arguments);
3635
4319
  }
3636
4320
  return setOtherParams;