@pisell/pisellos 2.2.264 → 2.2.265

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