@pisell/pisellos 2.2.262 → 2.2.264

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 (131) hide show
  1. package/dist/model/strategy/adapter/index.d.ts +0 -4
  2. package/dist/model/strategy/adapter/index.js +1 -5
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  11. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -16
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  14. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  15. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +1 -32
  16. package/dist/modules/Discount/index.d.ts +2 -5
  17. package/dist/modules/Discount/index.js +7 -30
  18. package/dist/modules/Discount/types.d.ts +0 -4
  19. package/dist/modules/Order/index.d.ts +2 -14
  20. package/dist/modules/Order/index.js +736 -1035
  21. package/dist/modules/Order/types.d.ts +0 -16
  22. package/dist/modules/Order/utils.d.ts +3 -4
  23. package/dist/modules/Order/utils.js +61 -54
  24. package/dist/modules/Product/types.d.ts +0 -22
  25. package/dist/modules/ProductList/index.d.ts +1 -1
  26. package/dist/modules/ProductList/index.js +2 -4
  27. package/dist/modules/ProductList/types.d.ts +0 -2
  28. package/dist/modules/Rules/index.d.ts +9 -2
  29. package/dist/modules/Rules/index.js +43 -69
  30. package/dist/modules/Rules/types.d.ts +1 -10
  31. package/dist/server/index.d.ts +0 -55
  32. package/dist/server/index.js +742 -1161
  33. package/dist/server/modules/order/index.d.ts +4 -10
  34. package/dist/server/modules/order/index.js +399 -404
  35. package/dist/server/modules/order/types.d.ts +0 -4
  36. package/dist/server/modules/products/index.d.ts +8 -31
  37. package/dist/server/modules/products/index.js +390 -549
  38. package/dist/server/modules/products/types.d.ts +0 -18
  39. package/dist/solution/BaseSales/index.d.ts +1 -21
  40. package/dist/solution/BaseSales/index.js +789 -1136
  41. package/dist/solution/BaseSales/types.d.ts +1 -6
  42. package/dist/solution/BaseSales/types.js +1 -1
  43. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  44. package/dist/solution/BaseSales/utils/cartPromotion.js +97 -50
  45. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  46. package/dist/solution/BaseSales/utils/parseSalesResponse.js +8 -6
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -14
  48. package/dist/solution/BookingByStep/index.d.ts +1 -1
  49. package/dist/solution/BookingTicket/index.js +25 -59
  50. package/dist/solution/BookingTicket/types.d.ts +0 -2
  51. package/dist/solution/ScanOrder/index.js +31 -20
  52. package/dist/solution/ShopDiscount/index.js +14 -15
  53. package/dist/solution/VenueBooking/index.js +30 -19
  54. package/lib/model/strategy/adapter/index.d.ts +0 -4
  55. package/lib/model/strategy/adapter/index.js +2 -13
  56. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  57. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  58. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  59. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  60. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  61. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  62. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  63. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  64. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  65. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  66. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -5
  67. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -1
  68. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  69. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +2 -23
  70. package/lib/modules/Discount/index.d.ts +2 -5
  71. package/lib/modules/Discount/index.js +3 -23
  72. package/lib/modules/Discount/types.d.ts +0 -4
  73. package/lib/modules/Order/index.d.ts +2 -14
  74. package/lib/modules/Order/index.js +60 -326
  75. package/lib/modules/Order/types.d.ts +0 -16
  76. package/lib/modules/Order/utils.d.ts +3 -4
  77. package/lib/modules/Order/utils.js +23 -22
  78. package/lib/modules/Product/types.d.ts +0 -22
  79. package/lib/modules/ProductList/index.d.ts +1 -1
  80. package/lib/modules/ProductList/index.js +2 -4
  81. package/lib/modules/ProductList/types.d.ts +0 -2
  82. package/lib/modules/Rules/index.d.ts +9 -2
  83. package/lib/modules/Rules/index.js +29 -61
  84. package/lib/modules/Rules/types.d.ts +1 -10
  85. package/lib/server/index.d.ts +0 -55
  86. package/lib/server/index.js +31 -327
  87. package/lib/server/modules/order/index.d.ts +4 -10
  88. package/lib/server/modules/order/index.js +139 -198
  89. package/lib/server/modules/order/types.d.ts +0 -4
  90. package/lib/server/modules/products/index.d.ts +8 -31
  91. package/lib/server/modules/products/index.js +35 -134
  92. package/lib/server/modules/products/types.d.ts +0 -18
  93. package/lib/solution/BaseSales/index.d.ts +1 -21
  94. package/lib/solution/BaseSales/index.js +72 -313
  95. package/lib/solution/BaseSales/types.d.ts +1 -6
  96. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  97. package/lib/solution/BaseSales/utils/cartPromotion.js +64 -25
  98. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  99. package/lib/solution/BaseSales/utils/parseSalesResponse.js +5 -4
  100. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -8
  101. package/lib/solution/BookingByStep/index.d.ts +1 -1
  102. package/lib/solution/BookingTicket/index.js +8 -33
  103. package/lib/solution/BookingTicket/types.d.ts +0 -2
  104. package/lib/solution/ScanOrder/index.js +8 -0
  105. package/lib/solution/ShopDiscount/index.js +1 -2
  106. package/lib/solution/VenueBooking/index.js +8 -0
  107. package/package.json +1 -1
  108. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  109. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  110. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  111. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  112. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  113. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  114. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  115. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  116. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  117. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  118. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
  119. package/dist/modules/Order/utils/orderCollectionIdentity.js +0 -405
  120. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  121. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  122. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  123. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  124. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  125. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  126. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  127. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  128. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  129. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  130. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +0 -53
  131. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -415
@@ -1,7 +1,10 @@
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; } } }; }
1
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
3
  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."); }
3
4
  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; } }
4
5
  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; }
5
8
  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; }
6
9
  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); } }
7
10
  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); }); }; }
@@ -17,18 +20,15 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
17
20
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
21
  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; } }
19
22
  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); }
20
26
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
27
  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); }
22
29
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
30
  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); }
26
31
  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,7 +37,6 @@ 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 { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
41
40
  import dayjs from 'dayjs';
42
41
  export * from "./types";
43
42
  import { QuotationModule } from "../../modules/Quotation";
@@ -72,15 +71,9 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
72
71
  function isBaseSalesHistoricalDiscountEntry(discount) {
73
72
  return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
74
73
  }
75
- var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
76
- product: 'order_detail_id',
77
- booking: 'schedule_event_id',
78
- payment: 'order_payment_id'
79
- };
80
- function getBaseSalesOrderCollectionKind(key) {
81
- if (key === 'products') return 'product';
82
- if (key === 'bookings') return 'booking';
83
- if (key === 'payments' || key === 'payment') return 'payment';
74
+ function getBaseSalesUniqueArrayMetadataKey(key) {
75
+ if (key === 'products' || key === 'bookings') return 'unique_identification_number';
76
+ if (key === 'payments' || key === 'payment') return 'unique_payment_number';
84
77
  return null;
85
78
  }
86
79
  function isSameBaseSalesOrderRecord(left, right) {
@@ -93,119 +86,42 @@ function isSameBaseSalesOrderRecord(left, right) {
93
86
  return value !== undefined && value !== null && value !== '' && leftIdentities.has(String(value));
94
87
  });
95
88
  }
96
- function isBaseSalesBlankValue(value) {
97
- return value === undefined || value === null || value === '';
98
- }
99
- function mergeBaseSalesProductSnapshotFields(currentItem, loadedItem) {
100
- var _currentItem$metadata, _mergedItem$metadata, _mergedItem$metadata2;
101
- var mergedItem = cloneDeep(loadedItem);
102
- if (isBaseSalesBlankValue(mergedItem.product_cover) && !isBaseSalesBlankValue(currentItem === null || currentItem === void 0 ? void 0 : currentItem.product_cover)) {
103
- mergedItem.product_cover = currentItem.product_cover;
104
- }
105
- var currentHolderConfig = currentItem === null || currentItem === void 0 || (_currentItem$metadata = currentItem.metadata) === null || _currentItem$metadata === void 0 ? void 0 : _currentItem$metadata.holder_config;
106
- 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) {
107
- mergedItem.metadata = _objectSpread(_objectSpread({}, mergedItem.metadata || {}), {}, {
108
- holder_config: currentHolderConfig
109
- });
110
- }
111
- return mergedItem;
89
+ function getBaseSalesMetadataUid(item, metadataKey) {
90
+ var _item$metadata$metada, _item$metadata;
91
+ 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];
92
+ if (uid === undefined || uid === null || uid === '') return null;
93
+ return String(uid);
112
94
  }
113
- function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps) {
114
- var currentReferenceUid = getOrderCollectionReferenceUid(kind, currentItem);
115
- var incomingReferenceUid = getOrderCollectionReferenceUid(kind, incomingItem);
116
- var identityMergedItem = mergeOrderCollectionItems(kind, currentItem, incomingItem);
117
- var mergedUid = getOrderCollectionUid(kind, identityMergedItem);
118
- if (mergedUid) {
119
- var _iterator = _createForOfIteratorHelper(new Set([currentReferenceUid, incomingReferenceUid])),
120
- _step;
121
- try {
122
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
123
- var from = _step.value;
124
- if (!from || from === mergedUid) continue;
125
- uidRemaps.push({
126
- kind: kind,
127
- from: from,
128
- to: mergedUid,
129
- persistentId: getOrderCollectionPersistentId(kind, incomingItem) || getOrderCollectionPersistentId(kind, currentItem)
130
- });
131
- }
132
- } catch (err) {
133
- _iterator.e(err);
134
- } finally {
135
- _iterator.f();
95
+ function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
96
+ var result = [];
97
+ var indexByUid = new Map();
98
+ var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
99
+ var clonedItem = cloneDeep(item);
100
+ var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
101
+ if (!uid) {
102
+ result.push(clonedItem);
103
+ return;
136
104
  }
137
- }
138
- var mergedItem = mergedUid ? setOrderCollectionUid(kind, incomingItem, mergedUid) : cloneDeep(incomingItem);
139
- var persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
140
- if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
141
- mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
142
- }
143
- return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
144
- }
145
- function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
146
- var currentItems = normalizeOrderCollection(kind, currentValue, {
147
- ensureUid: false
148
- }).items;
149
- var incomingItems = normalizeOrderCollection(kind, incomingValue, {
150
- ensureUid: false
151
- }).items;
152
- if (strategy === 'authoritative-incoming') {
153
- var _result = cloneDeep(incomingItems);
154
- currentItems.forEach(function (currentItem) {
155
- var incomingIndex = _result.findIndex(function (incomingItem) {
156
- return isSameOrderCollectionItem(kind, currentItem, incomingItem);
157
- });
158
- if (incomingIndex !== -1) {
159
- _result[incomingIndex] = mergeBaseSalesCollectionItem(kind, currentItem, _result[incomingIndex], uidRemaps);
160
- return;
161
- }
162
-
163
- // 完整服务端快照负责已落库行;仅保留尚未提交的本地新行。
164
- if (!getOrderCollectionPersistentId(kind, currentItem)) {
165
- _result.push(cloneDeep(currentItem));
166
- }
167
- });
168
- return _result;
169
- }
170
- var result = cloneDeep(currentItems);
171
- incomingItems.forEach(function (incomingItem) {
172
- var currentIndex = result.findIndex(function (currentItem) {
173
- return isSameOrderCollectionItem(kind, currentItem, incomingItem);
174
- });
175
- if (currentIndex !== -1) {
176
- result[currentIndex] = mergeBaseSalesCollectionItem(kind, result[currentIndex], incomingItem, uidRemaps);
105
+ var existingIndex = indexByUid.get(uid);
106
+ if (existingIndex !== undefined) {
107
+ result[existingIndex] = clonedItem;
177
108
  return;
178
109
  }
179
- result.push(cloneDeep(incomingItem));
180
- });
110
+ indexByUid.set(uid, result.length);
111
+ result.push(clonedItem);
112
+ };
113
+ currentValue.forEach(appendOrReplaceByUid);
114
+ loadedValue.forEach(appendOrReplaceByUid);
181
115
  return result;
182
116
  }
183
- function normalizeBaseSalesRecordCollections(sourceRecord, options) {
184
- var normalizedRecord = normalizeOrderCollections(cloneDeep(sourceRecord || {}), options).order;
185
-
186
- // 兼容旧调用方偶尔使用的单数 payment 字段。
187
- if (Array.isArray(normalizedRecord.payment)) {
188
- normalizedRecord.payment = normalizeOrderCollection('payment', normalizedRecord.payment, options).items;
189
- }
190
- return normalizedRecord;
191
- }
192
- function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
193
- var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
194
- ensureUid: false
195
- });
196
- if (!currentTempOrder) {
197
- return normalizeBaseSalesRecordCollections(normalizedLoadedRecord);
198
- }
199
- var normalizedCurrentTempOrder = normalizeBaseSalesRecordCollections(currentTempOrder, {
200
- ensureUid: false
201
- });
202
- var uidRemaps = [];
203
- var mergedRecord = mergeWith(normalizedCurrentTempOrder, normalizedLoadedRecord, function (currentValue, loadedValue, key) {
204
- var collectionKind = getBaseSalesOrderCollectionKind(key);
205
- if (collectionKind && Array.isArray(loadedValue)) {
206
- return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
207
- }
117
+ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord) {
118
+ if (!currentTempOrder) return loadedRecord;
119
+ var mergedRecord = mergeWith(cloneDeep(currentTempOrder), cloneDeep(loadedRecord || {}), function (currentValue, loadedValue, key) {
208
120
  if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
121
+ var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
122
+ if (metadataKey) {
123
+ return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
124
+ }
209
125
  return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
210
126
  }
211
127
  if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
@@ -215,7 +131,7 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
215
131
  return undefined;
216
132
  });
217
133
  delete mergedRecord.request_unique_idempotency_token;
218
- return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
134
+ return mergedRecord;
219
135
  }
220
136
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
221
137
  _inherits(BaseSalesImpl, _BaseModule);
@@ -251,13 +167,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
251
167
  _defineProperty(_assertThisInitialized(_this), "queuedAutoPaymentSync", false);
252
168
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncFlushing", false);
253
169
  _defineProperty(_assertThisInitialized(_this), "autoPaymentSyncTimer", null);
254
- _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlightCount", 0);
255
- _defineProperty(_assertThisInitialized(_this), "salesDetailLoadSequence", 0);
256
- _defineProperty(_assertThisInitialized(_this), "salesDetailHydrateQueue", Promise.resolve());
170
+ _defineProperty(_assertThisInitialized(_this), "salesDetailLoadInFlight", false);
257
171
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeUnsubscribe", null);
258
172
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
259
- _defineProperty(_assertThisInitialized(_this), "queuedServerOrderChanges", []);
260
- _defineProperty(_assertThisInitialized(_this), "serverOrderChangeSyncEnabled", false);
261
173
  return _this;
262
174
  }
263
175
 
@@ -347,143 +259,71 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
347
259
  return isSameBaseSalesOrderRecord(record, order);
348
260
  });
349
261
  }
350
- }, {
351
- key: "setServerOrderChangeSyncEnabled",
352
- value: function setServerOrderChangeSyncEnabled(enabled) {
353
- this.serverOrderChangeSyncEnabled = enabled;
354
- if (!enabled) this.queuedServerOrderChanges = [];
355
- }
356
- }, {
357
- key: "queueLatestServerOrderChange",
358
- value: function queueLatestServerOrderChange(order) {
359
- var snapshot = cloneDeep(order);
360
- var existingIndex = this.queuedServerOrderChanges.findIndex(function (queued) {
361
- return isSameBaseSalesOrderRecord(queued, snapshot);
362
- });
363
- if (existingIndex >= 0) {
364
- this.queuedServerOrderChanges[existingIndex] = snapshot;
365
- return;
366
- }
367
- this.queuedServerOrderChanges.push(snapshot);
368
- }
369
- }, {
370
- key: "drainQueuedServerOrderChanges",
371
- value: function () {
372
- var _drainQueuedServerOrderChanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
373
- var changedOrders;
374
- return _regeneratorRuntime().wrap(function _callee$(_context) {
375
- while (1) switch (_context.prev = _context.next) {
376
- case 0:
377
- if (!(!this.serverOrderChangeSyncEnabled || this.salesDetailLoadInFlightCount > 0 || this.serverOrderChangeHydrateInFlight || this.queuedServerOrderChanges.length === 0)) {
378
- _context.next = 2;
379
- break;
380
- }
381
- return _context.abrupt("return");
382
- case 2:
383
- changedOrders = this.queuedServerOrderChanges;
384
- this.queuedServerOrderChanges = [];
385
- _context.next = 6;
386
- return this.syncCurrentSalesDetailFromServerOrderChange({
387
- changedOrders: changedOrders
388
- });
389
- case 6:
390
- case "end":
391
- return _context.stop();
392
- }
393
- }, _callee, this);
394
- }));
395
- function drainQueuedServerOrderChanges() {
396
- return _drainQueuedServerOrderChanges.apply(this, arguments);
397
- }
398
- return drainQueuedServerOrderChanges;
399
- }()
400
262
  }, {
401
263
  key: "syncCurrentSalesDetailFromServerOrderChange",
402
264
  value: function () {
403
- var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
265
+ var _syncCurrentSalesDetailFromServerOrderChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(payload) {
404
266
  var _this2 = this;
405
267
  var changedOrders, changedOrder;
406
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
407
- while (1) switch (_context3.prev = _context3.next) {
268
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
269
+ while (1) switch (_context2.prev = _context2.next) {
408
270
  case 0:
409
271
  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] : [];
410
- if (this.serverOrderChangeSyncEnabled) {
411
- _context3.next = 3;
272
+ if (!(this.salesDetailLoadInFlight || this.serverOrderChangeHydrateInFlight)) {
273
+ _context2.next = 3;
412
274
  break;
413
275
  }
414
- return _context3.abrupt("return");
276
+ return _context2.abrupt("return");
415
277
  case 3:
416
- if (!(this.salesDetailLoadInFlightCount > 0)) {
417
- _context3.next = 6;
418
- break;
419
- }
420
- changedOrders.forEach(function (order) {
421
- return _this2.queueLatestServerOrderChange(order);
422
- });
423
- return _context3.abrupt("return");
424
- case 6:
425
278
  changedOrder = changedOrders.find(function (order) {
426
279
  return _this2.isCurrentSalesOrderRecord(order);
427
280
  });
428
281
  if (changedOrder) {
429
- _context3.next = 9;
430
- break;
431
- }
432
- return _context3.abrupt("return");
433
- case 9:
434
- if (!this.serverOrderChangeHydrateInFlight) {
435
- _context3.next = 12;
282
+ _context2.next = 6;
436
283
  break;
437
284
  }
438
- this.queueLatestServerOrderChange(changedOrder);
439
- return _context3.abrupt("return");
440
- case 12:
285
+ return _context2.abrupt("return");
286
+ case 6:
441
287
  if (this.store.order) {
442
- _context3.next = 14;
288
+ _context2.next = 8;
443
289
  break;
444
290
  }
445
- return _context3.abrupt("return");
446
- case 14:
447
- this.serverOrderChangeHydrateInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
448
- var _getTempOrder, _ref2;
449
- var currentTempOrder, record, sales;
450
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
451
- while (1) switch (_context2.prev = _context2.next) {
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) {
452
297
  case 0:
453
- currentTempOrder = (_getTempOrder = (_ref2 = _this2.store.order).getTempOrder) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.call(_ref2);
454
- record = mergeSalesDetailRecordWithTempOrder(currentTempOrder, changedOrder, 'authoritative-incoming');
455
- _context2.next = 4;
456
- return _this2.store.order.hydrateTempOrderFromRecord(record, {
298
+ _context.next = 2;
299
+ return _this2.store.order.hydrateTempOrderFromRecord(changedOrder, {
457
300
  recalcOnHydrate: false
458
301
  });
459
- case 4:
460
- sales = _context2.sent;
302
+ case 2:
303
+ sales = _context.sent;
461
304
  _this2.currentSalesDetail = sales;
462
- _context2.next = 8;
305
+ _context.next = 6;
463
306
  return _this2.core.effects.emit("".concat(_this2.name, ":onSalesOrderLoaded"), {
464
307
  sales: sales
465
308
  });
466
- case 8:
309
+ case 6:
467
310
  case "end":
468
- return _context2.stop();
311
+ return _context.stop();
469
312
  }
470
- }, _callee2);
313
+ }, _callee);
471
314
  }))();
472
- _context3.prev = 15;
473
- _context3.next = 18;
315
+ _context2.prev = 9;
316
+ _context2.next = 12;
474
317
  return this.serverOrderChangeHydrateInFlight;
475
- case 18:
476
- _context3.prev = 18;
318
+ case 12:
319
+ _context2.prev = 12;
477
320
  this.serverOrderChangeHydrateInFlight = null;
478
- _context3.next = 22;
479
- return this.drainQueuedServerOrderChanges();
480
- case 22:
481
- return _context3.finish(18);
482
- case 23:
321
+ return _context2.finish(12);
322
+ case 15:
483
323
  case "end":
484
- return _context3.stop();
324
+ return _context2.stop();
485
325
  }
486
- }, _callee3, this, [[15,, 18, 23]]);
326
+ }, _callee2, this, [[9,, 12, 15]]);
487
327
  }));
488
328
  function syncCurrentSalesDetailFromServerOrderChange(_x) {
489
329
  return _syncCurrentSalesDetailFromServerOrderChange.apply(this, arguments);
@@ -500,100 +340,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
500
340
  var effects = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.effects;
501
341
  if (!effects || typeof effects.on !== 'function') return;
502
342
  this.serverOrderChangeUnsubscribe = effects.on(SERVER_ORDER_CHANGED_EVENT, function (payload) {
503
- return _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
343
+ void _this3.syncCurrentSalesDetailFromServerOrderChange(payload).catch(function (error) {
504
344
  _this3.logError('sync sales detail from server order change failed', {
505
345
  error: error instanceof Error ? error.message : String(error)
506
346
  });
507
347
  });
508
348
  });
509
349
  }
510
- }, {
511
- key: "hydrateLatestLoadedSalesDetail",
512
- value: function () {
513
- var _hydrateLatestLoadedSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(record, loadSequence) {
514
- var _this4 = this;
515
- var hydratedSales, skippedBeforeHydrate, hydrateTask, queuedTask;
516
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
517
- while (1) switch (_context5.prev = _context5.next) {
518
- case 0:
519
- hydratedSales = null;
520
- skippedBeforeHydrate = false;
521
- hydrateTask = /*#__PURE__*/function () {
522
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
523
- var sales;
524
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
525
- while (1) switch (_context4.prev = _context4.next) {
526
- case 0:
527
- if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
528
- _context4.next = 3;
529
- break;
530
- }
531
- skippedBeforeHydrate = true;
532
- return _context4.abrupt("return");
533
- case 3:
534
- if (_this4.store.order) {
535
- _context4.next = 5;
536
- break;
537
- }
538
- throw new Error('order 模块未初始化');
539
- case 5:
540
- _context4.next = 7;
541
- return _this4.store.order.hydrateTempOrderFromRecord(record, {
542
- recalcOnHydrate: false
543
- });
544
- case 7:
545
- sales = _context4.sent;
546
- hydratedSales = sales;
547
-
548
- // hydrate 期间可能又发起了更新请求;后续任务已串行排队,将负责最终状态。
549
- if (!(loadSequence !== _this4.salesDetailLoadSequence)) {
550
- _context4.next = 11;
551
- break;
552
- }
553
- return _context4.abrupt("return");
554
- case 11:
555
- _this4.currentSalesDetail = sales;
556
- _context4.next = 14;
557
- return _this4.core.effects.emit("".concat(_this4.name, ":onSalesOrderLoaded"), {
558
- sales: sales
559
- });
560
- case 14:
561
- case "end":
562
- return _context4.stop();
563
- }
564
- }, _callee4);
565
- }));
566
- return function hydrateTask() {
567
- return _ref3.apply(this, arguments);
568
- };
569
- }();
570
- queuedTask = this.salesDetailHydrateQueue.then(hydrateTask, hydrateTask);
571
- this.salesDetailHydrateQueue = queuedTask.then(function () {
572
- return undefined;
573
- }, function () {
574
- return undefined;
575
- });
576
- _context5.next = 7;
577
- return queuedTask;
578
- case 7:
579
- if (!skippedBeforeHydrate) {
580
- _context5.next = 9;
581
- break;
582
- }
583
- return _context5.abrupt("return", record);
584
- case 9:
585
- return _context5.abrupt("return", hydratedSales || this.currentSalesDetail || record);
586
- case 10:
587
- case "end":
588
- return _context5.stop();
589
- }
590
- }, _callee5, this);
591
- }));
592
- function hydrateLatestLoadedSalesDetail(_x2, _x3) {
593
- return _hydrateLatestLoadedSalesDetail.apply(this, arguments);
594
- }
595
- return hydrateLatestLoadedSalesDetail;
596
- }()
597
350
  }, {
598
351
  key: "hydrateOrderPaymentNames",
599
352
  value: function hydrateOrderPaymentNames(payments) {
@@ -658,10 +411,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
658
411
  });
659
412
  }
660
413
  quotation.setScheduleResolver(function (id) {
661
- var _scheduleModule$getSc, _getScheduleByIds, _ref4;
414
+ var _scheduleModule$getSc, _getScheduleByIds, _ref2;
662
415
  var scheduleId = String(id);
663
416
  if (scheduleById.has(scheduleId)) return scheduleById.get(scheduleId);
664
- 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])) || [];
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])) || [];
665
418
  if (schedules[0]) scheduleById.set(scheduleId, schedules[0]);
666
419
  return schedules[0];
667
420
  });
@@ -669,30 +422,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
669
422
  }, {
670
423
  key: "loadQuotationForPriceQuery",
671
424
  value: function () {
672
- var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
425
+ var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
673
426
  var _this$otherParams;
674
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
675
- while (1) switch (_context6.prev = _context6.next) {
427
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
428
+ while (1) switch (_context3.prev = _context3.next) {
676
429
  case 0:
677
430
  if (params.quotation) {
678
- _context6.next = 2;
431
+ _context3.next = 2;
679
432
  break;
680
433
  }
681
- return _context6.abrupt("return");
434
+ return _context3.abrupt("return");
682
435
  case 2:
683
436
  this.applyQuotationScheduleResolver(params.quotation);
684
- _context6.next = 5;
437
+ _context3.next = 5;
685
438
  return params.quotation.loadQuotations({
686
439
  channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
687
440
  customer_id: params.customer_id
688
441
  });
689
442
  case 5:
690
443
  case "end":
691
- return _context6.stop();
444
+ return _context3.stop();
692
445
  }
693
- }, _callee6, this);
446
+ }, _callee3, this);
694
447
  }));
695
- function loadQuotationForPriceQuery(_x4) {
448
+ function loadQuotationForPriceQuery(_x2) {
696
449
  return _loadQuotationForPriceQuery.apply(this, arguments);
697
450
  }
698
451
  return loadQuotationForPriceQuery;
@@ -736,23 +489,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
736
489
  }, {
737
490
  key: "loadProductsForPriceQuery",
738
491
  value: function () {
739
- var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
492
+ var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
740
493
  var ids, productsById, _this$otherParams2, _response$data, response, list;
741
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
742
- while (1) switch (_context7.prev = _context7.next) {
494
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
495
+ while (1) switch (_context4.prev = _context4.next) {
743
496
  case 0:
744
497
  ids = Array.from(new Set(params.ids.filter(function (id) {
745
498
  return Number.isFinite(id);
746
499
  })));
747
500
  productsById = new Map();
748
501
  if (!(!ids.length || !this.request)) {
749
- _context7.next = 4;
502
+ _context4.next = 4;
750
503
  break;
751
504
  }
752
- return _context7.abrupt("return", productsById);
505
+ return _context4.abrupt("return", productsById);
753
506
  case 4:
754
- _context7.prev = 4;
755
- _context7.next = 7;
507
+ _context4.prev = 4;
508
+ _context4.next = 7;
756
509
  return this.request.post('/product/query', {
757
510
  ids: ids,
758
511
  open_quotation: 1,
@@ -769,35 +522,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
769
522
  customToast: function customToast() {}
770
523
  });
771
524
  case 7:
772
- response = _context7.sent;
525
+ response = _context4.sent;
773
526
  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) || [];
774
527
  if (Array.isArray(list)) {
775
- _context7.next = 11;
528
+ _context4.next = 11;
776
529
  break;
777
530
  }
778
- return _context7.abrupt("return", productsById);
531
+ return _context4.abrupt("return", productsById);
779
532
  case 11:
780
533
  list.forEach(function (item) {
781
534
  var _item$id;
782
535
  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);
783
536
  if (Number.isFinite(productId)) productsById.set(productId, item);
784
537
  });
785
- return _context7.abrupt("return", productsById);
538
+ return _context4.abrupt("return", productsById);
786
539
  case 15:
787
- _context7.prev = 15;
788
- _context7.t0 = _context7["catch"](4);
540
+ _context4.prev = 15;
541
+ _context4.t0 = _context4["catch"](4);
789
542
  this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
790
543
  ids: ids,
791
- error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
544
+ error: _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0)
792
545
  });
793
- return _context7.abrupt("return", productsById);
546
+ return _context4.abrupt("return", productsById);
794
547
  case 19:
795
548
  case "end":
796
- return _context7.stop();
549
+ return _context4.stop();
797
550
  }
798
- }, _callee7, this, [[4, 15]]);
551
+ }, _callee4, this, [[4, 15]]);
799
552
  }));
800
- function loadProductsForPriceQuery(_x5) {
553
+ function loadProductsForPriceQuery(_x3) {
801
554
  return _loadProductsForPriceQuery.apply(this, arguments);
802
555
  }
803
556
  return loadProductsForPriceQuery;
@@ -805,21 +558,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
805
558
  }, {
806
559
  key: "loadProductForPriceQuery",
807
560
  value: function () {
808
- var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, customerId) {
561
+ var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params, customerId) {
809
562
  var product, productId, schedule, productsById;
810
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
811
- while (1) switch (_context8.prev = _context8.next) {
563
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
564
+ while (1) switch (_context5.prev = _context5.next) {
812
565
  case 0:
813
566
  product = params.product || {};
814
567
  productId = this.getPriceQueryProductId(product);
815
568
  if (!(productId === null || !this.request)) {
816
- _context8.next = 4;
569
+ _context5.next = 4;
817
570
  break;
818
571
  }
819
- return _context8.abrupt("return", null);
572
+ return _context5.abrupt("return", null);
820
573
  case 4:
821
574
  schedule = this.getPriceQuerySchedule(params);
822
- _context8.next = 7;
575
+ _context5.next = 7;
823
576
  return this.loadProductsForPriceQuery({
824
577
  ids: [productId],
825
578
  schedule: schedule,
@@ -827,15 +580,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
827
580
  channel: params.channel
828
581
  });
829
582
  case 7:
830
- productsById = _context8.sent;
831
- return _context8.abrupt("return", productsById.get(productId) || null);
583
+ productsById = _context5.sent;
584
+ return _context5.abrupt("return", productsById.get(productId) || null);
832
585
  case 9:
833
586
  case "end":
834
- return _context8.stop();
587
+ return _context5.stop();
835
588
  }
836
- }, _callee8, this);
589
+ }, _callee5, this);
837
590
  }));
838
- function loadProductForPriceQuery(_x6, _x7) {
591
+ function loadProductForPriceQuery(_x4, _x5) {
839
592
  return _loadProductForPriceQuery.apply(this, arguments);
840
593
  }
841
594
  return loadProductForPriceQuery;
@@ -848,10 +601,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
848
601
  return groups.flatMap(function (group) {
849
602
  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 : [];
850
603
  return items.map(function (item) {
851
- var _item$group_id, _ref5, _item$bundle_group_id;
604
+ var _item$group_id, _ref3, _item$bundle_group_id;
852
605
  return _objectSpread(_objectSpread({}, item), {}, {
853
606
  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,
854
- 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
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
855
608
  });
856
609
  });
857
610
  });
@@ -882,21 +635,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
882
635
  }, {
883
636
  key: "getAuthoritativeBundleUnitPrice",
884
637
  value: function getAuthoritativeBundleUnitPrice(bundle) {
885
- var _ref6, _ref7, _ref8, _bundle$price;
886
- 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;
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;
887
640
  }
888
641
  }, {
889
642
  key: "mergeProductForPriceQuery",
890
643
  value: function mergeProductForPriceQuery(product, authoritativeProduct) {
891
- var _this5 = this,
644
+ var _this4 = this,
892
645
  _product$id,
893
- _ref9,
646
+ _ref7,
894
647
  _product$product_id2,
895
- _ref10,
648
+ _ref8,
896
649
  _product$product_vari,
897
- _ref11,
650
+ _ref9,
898
651
  _product$num,
899
- _ref12,
652
+ _ref10,
900
653
  _product$quantity,
901
654
  _product$metadata4;
902
655
  if (!authoritativeProduct) return product;
@@ -904,8 +657,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
904
657
  var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
905
658
  var productBundle = selectedBundles.map(function (bundle) {
906
659
  var _authoritativeBundle$, _authoritativeBundle$2;
907
- var authoritativeBundle = _this5.findAuthoritativeBundleItem(bundle, authoritativeBundles);
908
- var unitPrice = authoritativeBundle ? _this5.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
660
+ var authoritativeBundle = _this4.findAuthoritativeBundleItem(bundle, authoritativeBundles);
661
+ var unitPrice = authoritativeBundle ? _this4.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
909
662
  if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
910
663
  return _objectSpread(_objectSpread({}, bundle), {}, {
911
664
  price: unitPrice,
@@ -916,10 +669,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
916
669
  });
917
670
  return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
918
671
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
919
- 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,
920
- 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,
921
- num: (_ref11 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref11 !== void 0 ? _ref11 : authoritativeProduct.num,
922
- quantity: (_ref12 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.quantity,
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,
923
676
  product_sku: function () {
924
677
  var authoritativeSku = ensureProductSku(authoritativeProduct);
925
678
  var productSku = ensureProductSku(product);
@@ -993,61 +746,61 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
993
746
  }, {
994
747
  key: "syncOtherParamsToSubModules",
995
748
  value: (function () {
996
- var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
997
- var _this6 = this;
998
- var _ref13,
999
- _ref13$cover,
749
+ var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(changedParams) {
750
+ var _this5 = this;
751
+ var _ref11,
752
+ _ref11$cover,
1000
753
  cover,
1001
754
  nextSubModuleOtherParams,
1002
- _args10 = arguments;
1003
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1004
- while (1) switch (_context10.prev = _context10.next) {
755
+ _args7 = arguments;
756
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
757
+ while (1) switch (_context7.prev = _context7.next) {
1005
758
  case 0:
1006
- _ref13 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
759
+ _ref11 = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {}, _ref11$cover = _ref11.cover, cover = _ref11$cover === void 0 ? false : _ref11$cover;
1007
760
  nextSubModuleOtherParams = this.buildSubModuleOtherParams();
1008
- _context10.next = 4;
761
+ _context7.next = 4;
1009
762
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1010
- var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref14) {
1011
- var _ref16, moduleName, subModule, targetModule;
1012
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1013
- while (1) switch (_context9.prev = _context9.next) {
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) {
1014
767
  case 0:
1015
- _ref16 = _slicedToArray(_ref14, 2), moduleName = _ref16[0], subModule = _ref16[1];
1016
- if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
1017
- _context9.next = 3;
768
+ _ref14 = _slicedToArray(_ref12, 2), moduleName = _ref14[0], subModule = _ref14[1];
769
+ if (!_this5.reusedSharedSubModuleNames.has(moduleName)) {
770
+ _context6.next = 3;
1018
771
  break;
1019
772
  }
1020
- return _context9.abrupt("return");
773
+ return _context6.abrupt("return");
1021
774
  case 3:
1022
775
  targetModule = subModule;
1023
776
  if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
1024
- _context9.next = 6;
777
+ _context6.next = 6;
1025
778
  break;
1026
779
  }
1027
- return _context9.abrupt("return");
780
+ return _context6.abrupt("return");
1028
781
  case 6:
1029
- _context9.next = 8;
782
+ _context6.next = 8;
1030
783
  return targetModule.updateOtherParams(nextSubModuleOtherParams, {
1031
784
  changedParams: changedParams,
1032
785
  cover: cover
1033
786
  });
1034
787
  case 8:
1035
788
  case "end":
1036
- return _context9.stop();
789
+ return _context6.stop();
1037
790
  }
1038
- }, _callee9);
791
+ }, _callee6);
1039
792
  }));
1040
- return function (_x9) {
1041
- return _ref15.apply(this, arguments);
793
+ return function (_x7) {
794
+ return _ref13.apply(this, arguments);
1042
795
  };
1043
796
  }()));
1044
797
  case 4:
1045
798
  case "end":
1046
- return _context10.stop();
799
+ return _context7.stop();
1047
800
  }
1048
- }, _callee10, this);
801
+ }, _callee7, this);
1049
802
  }));
1050
- function syncOtherParamsToSubModules(_x8) {
803
+ function syncOtherParamsToSubModules(_x6) {
1051
804
  return _syncOtherParamsToSubModules.apply(this, arguments);
1052
805
  }
1053
806
  return syncOtherParamsToSubModules;
@@ -1121,19 +874,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1121
874
  }, {
1122
875
  key: "initialize",
1123
876
  value: function () {
1124
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
877
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(core) {
1125
878
  var _this$otherParams4,
1126
- _this7 = this,
879
+ _this6 = this,
1127
880
  _this$otherParams5;
1128
881
  var options,
1129
882
  app,
1130
883
  targetCacheData,
1131
884
  moduleNames,
1132
- _args11 = arguments;
1133
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1134
- while (1) switch (_context11.prev = _context11.next) {
885
+ _args8 = arguments;
886
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
887
+ while (1) switch (_context8.prev = _context8.next) {
1135
888
  case 0:
1136
- options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
889
+ options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
1137
890
  this.core = core;
1138
891
  this.initializeOptions = options || {};
1139
892
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
@@ -1146,7 +899,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1146
899
  // 获取 logger 实例
1147
900
  this.appPlugin = core.getPlugin('app');
1148
901
  if (this.appPlugin) {
1149
- _context11.next = 11;
902
+ _context8.next = 11;
1150
903
  break;
1151
904
  }
1152
905
  throw new Error('Checkout 解决方案需要 app 插件支持');
@@ -1156,48 +909,48 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1156
909
  targetCacheData = this.readSessionCacheData();
1157
910
  moduleNames = this.getRegisteredModuleNames();
1158
911
  moduleNames.forEach(function (step) {
1159
- var reusedModule = _this7.getReusableSharedSubModule(step);
912
+ var reusedModule = _this6.getReusableSharedSubModule(step);
1160
913
  if (reusedModule) {
1161
- _this7.store[step] = reusedModule;
1162
- _this7.reusedSharedSubModuleNames.add(step);
914
+ _this6.store[step] = reusedModule;
915
+ _this6.reusedSharedSubModuleNames.add(step);
1163
916
  return;
1164
917
  }
1165
- var targetModule = _this7.createSubModule(step);
918
+ var targetModule = _this6.createSubModule(step);
1166
919
  if (!targetModule) {
1167
920
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
1168
921
  }
1169
- var hooks = _this7.getSubModuleHooks(step);
1170
- _this7.store[step] = targetModule;
1171
- _this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
922
+ var hooks = _this6.getSubModuleHooks(step);
923
+ _this6.store[step] = targetModule;
924
+ _this6.core.registerModule(targetModule, _objectSpread(_objectSpread({
1172
925
  initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
1173
926
  }, hooks ? {
1174
927
  hooks: hooks
1175
928
  } : {}), {}, {
1176
- otherParams: _this7.buildSubModuleOtherParams()
929
+ otherParams: _this6.buildSubModuleOtherParams()
1177
930
  }));
1178
931
  });
1179
932
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1180
- _context11.next = 19;
933
+ _context8.next = 19;
1181
934
  break;
1182
935
  }
1183
- _context11.next = 19;
936
+ _context8.next = 19;
1184
937
  return this.store.schedule.loadAllSchedule();
1185
938
  case 19:
1186
939
  if (this.store.order && typeof ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.enableTempOrderPersist) === 'boolean') {
1187
940
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1188
941
  }
1189
- _context11.next = 22;
942
+ _context8.next = 22;
1190
943
  return this.getPaymentMethodsAsync();
1191
944
  case 22:
1192
945
  this.registerServerOrderChangeSync();
1193
946
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1194
947
  case 24:
1195
948
  case "end":
1196
- return _context11.stop();
949
+ return _context8.stop();
1197
950
  }
1198
- }, _callee11, this);
951
+ }, _callee8, this);
1199
952
  }));
1200
- function initialize(_x10) {
953
+ function initialize(_x8) {
1201
954
  return _initialize.apply(this, arguments);
1202
955
  }
1203
956
  return initialize;
@@ -1205,17 +958,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1205
958
  }, {
1206
959
  key: "destroy",
1207
960
  value: function () {
1208
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
961
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1209
962
  var _this$serverOrderChan2,
1210
- _this8 = this;
1211
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1212
- while (1) switch (_context12.prev = _context12.next) {
963
+ _this7 = this;
964
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
965
+ while (1) switch (_context9.prev = _context9.next) {
1213
966
  case 0:
1214
967
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
1215
968
  this.serverOrderChangeUnsubscribe = null;
1216
969
  Object.keys(this.store).forEach(function (key) {
1217
- if (_this8.reusedSharedSubModuleNames.has(key)) return;
1218
- var sub = _this8.store[key];
970
+ if (_this7.reusedSharedSubModuleNames.has(key)) return;
971
+ var sub = _this7.store[key];
1219
972
  if (sub && typeof sub.destroy === 'function') {
1220
973
  try {
1221
974
  sub.destroy();
@@ -1225,17 +978,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1225
978
  }
1226
979
  });
1227
980
  this.currentSalesDetail = null;
1228
- this.queuedServerOrderChanges = [];
1229
- this.salesDetailLoadSequence += 1;
1230
- _context12.next = 8;
981
+ _context9.next = 6;
1231
982
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
1232
- case 8:
983
+ case 6:
1233
984
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
1234
- case 9:
985
+ case 7:
1235
986
  case "end":
1236
- return _context12.stop();
987
+ return _context9.stop();
1237
988
  }
1238
- }, _callee12, this);
989
+ }, _callee9, this);
1239
990
  }));
1240
991
  function destroy() {
1241
992
  return _destroy.apply(this, arguments);
@@ -1252,91 +1003,82 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1252
1003
  }, {
1253
1004
  key: "loadSalesDetail",
1254
1005
  value: (function () {
1255
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
1256
- var loadSequence, _ref17, _ref18, _ref19, _ref20, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
1257
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1258
- while (1) switch (_context13.prev = _context13.next) {
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) {
1259
1010
  case 0:
1260
1011
  if (this.store.order) {
1261
- _context13.next = 2;
1012
+ _context10.next = 2;
1262
1013
  break;
1263
1014
  }
1264
1015
  throw new Error('order 模块未初始化');
1265
1016
  case 2:
1266
- loadSequence = ++this.salesDetailLoadSequence;
1267
- this.salesDetailLoadInFlightCount += 1;
1268
- _context13.prev = 4;
1017
+ this.salesDetailLoadInFlight = true;
1018
+ _context10.prev = 3;
1269
1019
  params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
1270
1020
  orderId: orderIdOrParams
1271
1021
  };
1272
1022
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
1273
1023
  preloadedSalesDetail = params.preloadedSalesDetail;
1274
- 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;
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;
1275
1025
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
1276
- _context13.next = 11;
1026
+ _context10.next = 10;
1277
1027
  break;
1278
1028
  }
1279
1029
  throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
1280
- case 11:
1030
+ case 10:
1281
1031
  if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
1282
- _context13.next = 15;
1032
+ _context10.next = 14;
1283
1033
  break;
1284
1034
  }
1285
- _context13.t0 = preloadedSalesDetail;
1286
- _context13.next = 18;
1035
+ _context10.t0 = preloadedSalesDetail;
1036
+ _context10.next = 17;
1287
1037
  break;
1288
- case 15:
1289
- _context13.next = 17;
1038
+ case 14:
1039
+ _context10.next = 16;
1290
1040
  return this.store.order.getSalesOrderByLookup({
1291
1041
  lookup: lookup,
1292
1042
  forceRemote: params.forceRemote
1293
1043
  });
1044
+ case 16:
1045
+ _context10.t0 = _context10.sent;
1294
1046
  case 17:
1295
- _context13.t0 = _context13.sent;
1296
- case 18:
1297
- loadedRecord = _context13.t0;
1047
+ loadedRecord = _context10.t0;
1298
1048
  if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
1299
- _context13.next = 22;
1049
+ _context10.next = 21;
1300
1050
  break;
1301
1051
  }
1302
1052
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
1303
1053
  throw new Error(message);
1304
- case 22:
1054
+ case 21:
1305
1055
  remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
1306
1056
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
1307
- record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
1308
- _context13.next = 27;
1309
- return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
1310
- case 27:
1311
- return _context13.abrupt("return", _context13.sent);
1312
- case 28:
1313
- _context13.prev = 28;
1314
- this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
1315
- if (!(this.salesDetailLoadInFlightCount === 0)) {
1316
- _context13.next = 39;
1317
- break;
1318
- }
1319
- _context13.prev = 31;
1320
- _context13.next = 34;
1321
- return this.drainQueuedServerOrderChanges();
1322
- case 34:
1323
- _context13.next = 39;
1324
- break;
1325
- case 36:
1326
- _context13.prev = 36;
1327
- _context13.t1 = _context13["catch"](31);
1328
- this.logError('drain queued server order changes failed', {
1329
- error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
1057
+ record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord) : remoteRecord;
1058
+ _context10.next = 26;
1059
+ return this.store.order.hydrateTempOrderFromRecord(record, {
1060
+ recalcOnHydrate: false
1330
1061
  });
1331
- case 39:
1332
- return _context13.finish(28);
1333
- case 40:
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
1068
+ });
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:
1334
1076
  case "end":
1335
- return _context13.stop();
1077
+ return _context10.stop();
1336
1078
  }
1337
- }, _callee13, this, [[4,, 28, 40], [31, 36]]);
1079
+ }, _callee10, this, [[3,, 31, 34]]);
1338
1080
  }));
1339
- function loadSalesDetail(_x11) {
1081
+ function loadSalesDetail(_x9) {
1340
1082
  return _loadSalesDetail.apply(this, arguments);
1341
1083
  }
1342
1084
  return loadSalesDetail;
@@ -1416,34 +1158,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1416
1158
  }, {
1417
1159
  key: "replaceTempOrder",
1418
1160
  value: function () {
1419
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
1161
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(tempOrder) {
1420
1162
  var nextTempOrder;
1421
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1422
- while (1) switch (_context14.prev = _context14.next) {
1163
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1164
+ while (1) switch (_context11.prev = _context11.next) {
1423
1165
  case 0:
1424
1166
  if (this.store.order) {
1425
- _context14.next = 2;
1167
+ _context11.next = 2;
1426
1168
  break;
1427
1169
  }
1428
1170
  throw new Error('order 模块未初始化');
1429
1171
  case 2:
1430
- _context14.next = 4;
1172
+ _context11.next = 4;
1431
1173
  return this.store.order.replaceTempOrder(tempOrder);
1432
1174
  case 4:
1433
- nextTempOrder = _context14.sent;
1434
- _context14.next = 7;
1175
+ nextTempOrder = _context11.sent;
1176
+ _context11.next = 7;
1435
1177
  return this.effectsEmit('onTempOrderReplaced', {
1436
1178
  tempOrder: nextTempOrder
1437
1179
  });
1438
1180
  case 7:
1439
- return _context14.abrupt("return", nextTempOrder);
1181
+ return _context11.abrupt("return", nextTempOrder);
1440
1182
  case 8:
1441
1183
  case "end":
1442
- return _context14.stop();
1184
+ return _context11.stop();
1443
1185
  }
1444
- }, _callee14, this);
1186
+ }, _callee11, this);
1445
1187
  }));
1446
- function replaceTempOrder(_x12) {
1188
+ function replaceTempOrder(_x10) {
1447
1189
  return _replaceTempOrder.apply(this, arguments);
1448
1190
  }
1449
1191
  return replaceTempOrder;
@@ -1541,40 +1283,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1541
1283
  }, {
1542
1284
  key: "addNewOrder",
1543
1285
  value: function () {
1544
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1286
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1545
1287
  var tempOrder;
1546
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1547
- while (1) switch (_context15.prev = _context15.next) {
1288
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1289
+ while (1) switch (_context12.prev = _context12.next) {
1548
1290
  case 0:
1549
- _context15.prev = 0;
1291
+ _context12.prev = 0;
1550
1292
  if (this.store.order) {
1551
- _context15.next = 3;
1293
+ _context12.next = 3;
1552
1294
  break;
1553
1295
  }
1554
1296
  throw new Error('order 模块未初始化');
1555
1297
  case 3:
1556
- _context15.next = 5;
1298
+ _context12.next = 5;
1557
1299
  return this.store.order.addNewOrder();
1558
1300
  case 5:
1559
- tempOrder = _context15.sent;
1301
+ tempOrder = _context12.sent;
1560
1302
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1561
- _context15.next = 10;
1303
+ _context12.next = 10;
1562
1304
  break;
1563
1305
  }
1564
1306
  this.store.order.persistTempOrder();
1565
- _context15.next = 10;
1307
+ _context12.next = 10;
1566
1308
  return this.store.order.saveDraft();
1567
1309
  case 10:
1568
- return _context15.abrupt("return", tempOrder);
1310
+ return _context12.abrupt("return", tempOrder);
1569
1311
  case 13:
1570
- _context15.prev = 13;
1571
- _context15.t0 = _context15["catch"](0);
1572
- throw _context15.t0;
1312
+ _context12.prev = 13;
1313
+ _context12.t0 = _context12["catch"](0);
1314
+ throw _context12.t0;
1573
1315
  case 16:
1574
1316
  case "end":
1575
- return _context15.stop();
1317
+ return _context12.stop();
1576
1318
  }
1577
- }, _callee15, this, [[0, 13]]);
1319
+ }, _callee12, this, [[0, 13]]);
1578
1320
  }));
1579
1321
  function addNewOrder() {
1580
1322
  return _addNewOrder.apply(this, arguments);
@@ -1584,22 +1326,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1584
1326
  }, {
1585
1327
  key: "saveDraft",
1586
1328
  value: function () {
1587
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1588
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1589
- while (1) switch (_context16.prev = _context16.next) {
1329
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1330
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1331
+ while (1) switch (_context13.prev = _context13.next) {
1590
1332
  case 0:
1591
1333
  if (this.store.order) {
1592
- _context16.next = 2;
1334
+ _context13.next = 2;
1593
1335
  break;
1594
1336
  }
1595
1337
  throw new Error('order 模块未初始化');
1596
1338
  case 2:
1597
- return _context16.abrupt("return", this.store.order.saveDraft());
1339
+ return _context13.abrupt("return", this.store.order.saveDraft());
1598
1340
  case 3:
1599
1341
  case "end":
1600
- return _context16.stop();
1342
+ return _context13.stop();
1601
1343
  }
1602
- }, _callee16, this);
1344
+ }, _callee13, this);
1603
1345
  }));
1604
1346
  function saveDraft() {
1605
1347
  return _saveDraft.apply(this, arguments);
@@ -1610,14 +1352,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1610
1352
  }, {
1611
1353
  key: "restoreOrder",
1612
1354
  value: function () {
1613
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1355
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1614
1356
  var tempOrder;
1615
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1616
- while (1) switch (_context17.prev = _context17.next) {
1357
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1358
+ while (1) switch (_context14.prev = _context14.next) {
1617
1359
  case 0:
1618
- _context17.prev = 0;
1360
+ _context14.prev = 0;
1619
1361
  if (this.store.order) {
1620
- _context17.next = 3;
1362
+ _context14.next = 3;
1621
1363
  break;
1622
1364
  }
1623
1365
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -1627,29 +1369,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1627
1369
  this.currentSalesDetail = null;
1628
1370
  this.discountConfigCacheKey = null;
1629
1371
  this.hasManualDiscountSelection = false;
1630
- _context17.next = 9;
1372
+ _context14.next = 9;
1631
1373
  return this.effectsEmit('onTempOrderReplaced', {
1632
1374
  tempOrder: tempOrder
1633
1375
  });
1634
1376
  case 9:
1635
1377
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1636
- _context17.next = 13;
1378
+ _context14.next = 13;
1637
1379
  break;
1638
1380
  }
1639
1381
  this.store.order.persistTempOrder();
1640
- _context17.next = 13;
1382
+ _context14.next = 13;
1641
1383
  return this.store.order.saveDraft();
1642
1384
  case 13:
1643
- return _context17.abrupt("return", tempOrder);
1385
+ return _context14.abrupt("return", tempOrder);
1644
1386
  case 16:
1645
- _context17.prev = 16;
1646
- _context17.t0 = _context17["catch"](0);
1647
- throw _context17.t0;
1387
+ _context14.prev = 16;
1388
+ _context14.t0 = _context14["catch"](0);
1389
+ throw _context14.t0;
1648
1390
  case 19:
1649
1391
  case "end":
1650
- return _context17.stop();
1392
+ return _context14.stop();
1651
1393
  }
1652
- }, _callee17, this, [[0, 16]]);
1394
+ }, _callee14, this, [[0, 16]]);
1653
1395
  }));
1654
1396
  function restoreOrder() {
1655
1397
  return _restoreOrder.apply(this, arguments);
@@ -1663,22 +1405,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1663
1405
  }, {
1664
1406
  key: "clearOrderCartLines",
1665
1407
  value: (function () {
1666
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1408
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1667
1409
  var tempOrder;
1668
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1669
- while (1) switch (_context18.prev = _context18.next) {
1410
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1411
+ while (1) switch (_context15.prev = _context15.next) {
1670
1412
  case 0:
1671
- _context18.prev = 0;
1413
+ _context15.prev = 0;
1672
1414
  if (this.store.order) {
1673
- _context18.next = 3;
1415
+ _context15.next = 3;
1674
1416
  break;
1675
1417
  }
1676
1418
  throw new Error('order 模块未初始化');
1677
1419
  case 3:
1678
- _context18.next = 5;
1420
+ _context15.next = 5;
1679
1421
  return this.store.order.clearOrderCartLines();
1680
1422
  case 5:
1681
- tempOrder = _context18.sent;
1423
+ tempOrder = _context15.sent;
1682
1424
  if (this.currentSalesDetail) {
1683
1425
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
1684
1426
  products: [],
@@ -1688,29 +1430,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1688
1430
  discount_list: []
1689
1431
  });
1690
1432
  }
1691
- _context18.next = 9;
1433
+ _context15.next = 9;
1692
1434
  return this.effectsEmit('onTempOrderReplaced', {
1693
1435
  tempOrder: tempOrder
1694
1436
  });
1695
1437
  case 9:
1696
1438
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
1697
- _context18.next = 13;
1439
+ _context15.next = 13;
1698
1440
  break;
1699
1441
  }
1700
1442
  this.store.order.persistTempOrder();
1701
- _context18.next = 13;
1443
+ _context15.next = 13;
1702
1444
  return this.store.order.saveDraft();
1703
1445
  case 13:
1704
- return _context18.abrupt("return", tempOrder);
1446
+ return _context15.abrupt("return", tempOrder);
1705
1447
  case 16:
1706
- _context18.prev = 16;
1707
- _context18.t0 = _context18["catch"](0);
1708
- throw _context18.t0;
1448
+ _context15.prev = 16;
1449
+ _context15.t0 = _context15["catch"](0);
1450
+ throw _context15.t0;
1709
1451
  case 19:
1710
1452
  case "end":
1711
- return _context18.stop();
1453
+ return _context15.stop();
1712
1454
  }
1713
- }, _callee18, this, [[0, 16]]);
1455
+ }, _callee15, this, [[0, 16]]);
1714
1456
  }));
1715
1457
  function clearOrderCartLines() {
1716
1458
  return _clearOrderCartLines.apply(this, arguments);
@@ -1727,32 +1469,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1727
1469
  }, {
1728
1470
  key: "getSummary",
1729
1471
  value: function () {
1730
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1472
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1731
1473
  var summary;
1732
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1733
- while (1) switch (_context19.prev = _context19.next) {
1474
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1475
+ while (1) switch (_context16.prev = _context16.next) {
1734
1476
  case 0:
1735
- _context19.prev = 0;
1477
+ _context16.prev = 0;
1736
1478
  if (this.store.order) {
1737
- _context19.next = 3;
1479
+ _context16.next = 3;
1738
1480
  break;
1739
1481
  }
1740
1482
  throw new Error('order 模块未初始化');
1741
1483
  case 3:
1742
- _context19.next = 5;
1484
+ _context16.next = 5;
1743
1485
  return this.store.order.getOrderSummary();
1744
1486
  case 5:
1745
- summary = _context19.sent;
1746
- return _context19.abrupt("return", summary);
1487
+ summary = _context16.sent;
1488
+ return _context16.abrupt("return", summary);
1747
1489
  case 9:
1748
- _context19.prev = 9;
1749
- _context19.t0 = _context19["catch"](0);
1750
- throw _context19.t0;
1490
+ _context16.prev = 9;
1491
+ _context16.t0 = _context16["catch"](0);
1492
+ throw _context16.t0;
1751
1493
  case 12:
1752
1494
  case "end":
1753
- return _context19.stop();
1495
+ return _context16.stop();
1754
1496
  }
1755
- }, _callee19, this, [[0, 9]]);
1497
+ }, _callee16, this, [[0, 9]]);
1756
1498
  }));
1757
1499
  function getSummary() {
1758
1500
  return _getSummary.apply(this, arguments);
@@ -1762,10 +1504,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1762
1504
  }, {
1763
1505
  key: "getHistoricalProductDiscountList",
1764
1506
  value: function getHistoricalProductDiscountList(products) {
1765
- var _this9 = this;
1507
+ var _this8 = this;
1766
1508
  var historyDiscountList = [];
1767
1509
  products.forEach(function (item) {
1768
- if (!_this9.isPersistedOrderProduct(item)) return;
1510
+ if (!_this8.isPersistedOrderProduct(item)) return;
1769
1511
  (item.discount_list || []).forEach(function (discount) {
1770
1512
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
1771
1513
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -1825,11 +1567,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1825
1567
  }, {
1826
1568
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
1827
1569
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
1828
- var _this10 = this;
1570
+ var _this9 = this;
1829
1571
  if (params.discountAction !== 'edit') return false;
1830
1572
  if (!params.products.length) return false;
1831
1573
  var hasDraftProduct = params.products.some(function (product) {
1832
- return !_this10.isPersistedOrderProduct(product);
1574
+ return !_this9.isPersistedOrderProduct(product);
1833
1575
  });
1834
1576
  if (hasDraftProduct) return false;
1835
1577
  var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
@@ -1869,14 +1611,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1869
1611
  }, {
1870
1612
  key: "loadDiscountConfig",
1871
1613
  value: function () {
1872
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1614
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1873
1615
  var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
1874
- 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;
1875
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1876
- while (1) switch (_context20.prev = _context20.next) {
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) {
1877
1619
  case 0:
1878
1620
  if (this.store.order) {
1879
- _context20.next = 2;
1621
+ _context17.next = 2;
1880
1622
  break;
1881
1623
  }
1882
1624
  throw new Error('order 模块未初始化');
@@ -1896,18 +1638,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1896
1638
  discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
1897
1639
  preparedDiscountList = [];
1898
1640
  if (!(customerId && customerId !== 1)) {
1899
- _context20.next = 25;
1641
+ _context17.next = 25;
1900
1642
  break;
1901
1643
  }
1902
1644
  if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
1903
- _context20.next = 19;
1645
+ _context17.next = 19;
1904
1646
  break;
1905
1647
  }
1906
1648
  preparedDiscountList = originalDiscountList;
1907
- _context20.next = 25;
1649
+ _context17.next = 25;
1908
1650
  break;
1909
1651
  case 19:
1910
- _context20.next = 21;
1652
+ _context17.next = 21;
1911
1653
  return this.store.order.loadDiscountConfig({
1912
1654
  customerId: customerId,
1913
1655
  action: discountAction,
@@ -1915,24 +1657,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1915
1657
  apply: false
1916
1658
  });
1917
1659
  case 21:
1918
- preparedDiscountList = _context20.sent;
1660
+ preparedDiscountList = _context17.sent;
1919
1661
  this.discountConfigCacheKey = discountConfigCacheKey;
1920
- _context20.next = 25;
1662
+ _context17.next = 25;
1921
1663
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
1922
1664
  case 25:
1923
1665
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
1924
- _context20.next = 27;
1666
+ _context17.next = 27;
1925
1667
  break;
1926
1668
  }
1927
- return _context20.abrupt("return", {
1669
+ return _context17.abrupt("return", {
1928
1670
  productList: tempOrder.products || [],
1929
- discountList: currentDiscountList,
1930
- availableWalletIds: this.getAvailableWalletIds()
1671
+ discountList: currentDiscountList
1931
1672
  });
1932
1673
  case 27:
1933
1674
  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 || []);
1934
1675
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
1935
- _context20.next = 31;
1676
+ _context17.next = 31;
1936
1677
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1937
1678
  case 31:
1938
1679
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
@@ -1942,17 +1683,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1942
1683
  nextDiscountList: nextDiscountList
1943
1684
  });
1944
1685
  if (!shouldSkipAutoApplyFetchedDiscounts) {
1945
- _context20.next = 40;
1686
+ _context17.next = 40;
1946
1687
  break;
1947
1688
  }
1948
- _context20.next = 35;
1689
+ _context17.next = 35;
1949
1690
  return this.store.order.recalculateSummary({
1950
1691
  createIfMissing: true
1951
1692
  });
1952
1693
  case 35:
1953
- _summary = _context20.sent;
1694
+ _summary = _context17.sent;
1954
1695
  this.store.order.persistTempOrder();
1955
- _context20.next = 39;
1696
+ _context17.next = 39;
1956
1697
  return this.effectsEmit('onDiscountApplied', {
1957
1698
  productList: tempOrder.products || [],
1958
1699
  discountList: nextDiscountList,
@@ -1960,22 +1701,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1960
1701
  tempOrder: tempOrder
1961
1702
  });
1962
1703
  case 39:
1963
- return _context20.abrupt("return", {
1704
+ return _context17.abrupt("return", {
1964
1705
  productList: tempOrder.products || [],
1965
- discountList: nextDiscountList,
1966
- availableWalletIds: this.getAvailableWalletIds()
1706
+ discountList: nextDiscountList
1967
1707
  });
1968
1708
  case 40:
1969
1709
  if (!rulesModule) {
1970
- _context20.next = 77;
1710
+ _context17.next = 78;
1971
1711
  break;
1972
1712
  }
1713
+ holders = ((_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
1973
1714
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
1974
1715
  console.log('[BaseSales.applyDiscountConfig.calcDiscount]');
1975
1716
  result = rulesModule.calcDiscount({
1976
1717
  productList: tempOrder.products,
1977
1718
  discountList: nextDiscountList,
1978
- holders: [],
1719
+ holders: holders,
1979
1720
  isFormSubject: function isFormSubject(product) {
1980
1721
  return resolveIsFormSubject(tempOrder, product);
1981
1722
  },
@@ -1987,23 +1728,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1987
1728
  if (result.productList) {
1988
1729
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
1989
1730
  }
1990
- _iterator2 = _createForOfIteratorHelper(tempOrder.products || []);
1991
- _context20.prev = 46;
1992
- _iterator2.s();
1993
- case 48:
1994
- if ((_step2 = _iterator2.n()).done) {
1995
- _context20.next = 63;
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;
1996
1737
  break;
1997
1738
  }
1998
- product = _step2.value;
1739
+ product = _step.value;
1999
1740
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
2000
1741
  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;
2001
1742
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2002
- _context20.next = 54;
1743
+ _context17.next = 55;
2003
1744
  break;
2004
1745
  }
2005
- return _context20.abrupt("continue", 61);
2006
- case 54:
1746
+ return _context17.abrupt("continue", 62);
1747
+ case 55:
2007
1748
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2008
1749
  return sum + Number(pd.amount || 0);
2009
1750
  }, 0);
@@ -2019,83 +1760,75 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2019
1760
  mainPrice: newMainSellingPrice,
2020
1761
  bundle: product.product_bundle
2021
1762
  });
2022
- case 61:
2023
- _context20.next = 48;
1763
+ case 62:
1764
+ _context17.next = 49;
2024
1765
  break;
2025
- case 63:
2026
- _context20.next = 68;
1766
+ case 64:
1767
+ _context17.next = 69;
2027
1768
  break;
2028
- case 65:
2029
- _context20.prev = 65;
2030
- _context20.t0 = _context20["catch"](46);
2031
- _iterator2.e(_context20.t0);
2032
- case 68:
2033
- _context20.prev = 68;
2034
- _iterator2.f();
2035
- return _context20.finish(68);
2036
- case 71:
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:
2037
1778
  if (!result.discountList) {
2038
- _context20.next = 77;
1779
+ _context17.next = 78;
2039
1780
  break;
2040
1781
  }
2041
1782
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2042
1783
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2043
- _context20.next = 76;
1784
+ _context17.next = 77;
2044
1785
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2045
- case 76:
1786
+ case 77:
2046
1787
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2047
1788
  return discount.isSelected;
2048
1789
  });
2049
- case 77:
2050
- _context20.next = 79;
1790
+ case 78:
1791
+ _context17.next = 80;
2051
1792
  return this.store.order.recalculateSummary({
2052
1793
  createIfMissing: true
2053
1794
  });
2054
- case 79:
2055
- summary = _context20.sent;
1795
+ case 80:
1796
+ summary = _context17.sent;
2056
1797
  this.store.order.persistTempOrder();
2057
- _context20.next = 83;
1798
+ _context17.next = 84;
2058
1799
  return this.effectsEmit('onDiscountApplied', {
2059
1800
  productList: tempOrder.products || [],
2060
1801
  discountList: nextDiscountList,
2061
1802
  selectedDiscountList: tempOrder.discount_list || [],
2062
1803
  tempOrder: tempOrder
2063
1804
  });
2064
- case 83:
2065
- return _context20.abrupt("return", {
1805
+ case 84:
1806
+ return _context17.abrupt("return", {
2066
1807
  productList: tempOrder.products || [],
2067
- discountList: nextDiscountList,
2068
- availableWalletIds: this.getAvailableWalletIds()
1808
+ discountList: nextDiscountList
2069
1809
  });
2070
- case 84:
1810
+ case 85:
2071
1811
  case "end":
2072
- return _context20.stop();
1812
+ return _context17.stop();
2073
1813
  }
2074
- }, _callee20, this, [[46, 65, 68, 71]]);
1814
+ }, _callee17, this, [[47, 66, 69, 72]]);
2075
1815
  }));
2076
- function loadDiscountConfig(_x13) {
1816
+ function loadDiscountConfig(_x11) {
2077
1817
  return _loadDiscountConfig.apply(this, arguments);
2078
1818
  }
2079
1819
  return loadDiscountConfig;
2080
1820
  }()
2081
- }, {
2082
- key: "getAvailableWalletIds",
2083
- value: function getAvailableWalletIds() {
2084
- var _this$store$order4;
2085
- if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && _this$store$order4.getAvailableWalletIds)) return [];
2086
- return this.store.order.getAvailableWalletIds();
2087
- }
2088
1821
  }, {
2089
1822
  key: "bestDiscount",
2090
1823
  value: function () {
2091
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(cb) {
1824
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(cb) {
2092
1825
  var _discountModule$getOr2, _discountModule$getDi3;
2093
- var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
2094
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2095
- while (1) switch (_context21.prev = _context21.next) {
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) {
2096
1829
  case 0:
2097
1830
  if (this.store.order) {
2098
- _context21.next = 2;
1831
+ _context18.next = 2;
2099
1832
  break;
2100
1833
  }
2101
1834
  throw new Error('order 模块未初始化');
@@ -2111,19 +1844,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2111
1844
  productList: tempOrder.products || [],
2112
1845
  discountList: nextDiscountList
2113
1846
  };
2114
- _context21.next = 12;
1847
+ _context18.next = 12;
2115
1848
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2116
1849
  case 12:
2117
1850
  if (!rulesModule) {
2118
- _context21.next = 24;
1851
+ _context18.next = 25;
2119
1852
  break;
2120
1853
  }
1854
+ holders = ((_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_record) || [];
2121
1855
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
2122
1856
  console.log('[BaseSales.bestDiscount.calcDiscount]');
2123
1857
  result = rulesModule.calcDiscount({
2124
1858
  productList: tempOrder.products,
2125
1859
  discountList: nextDiscountList,
2126
- holders: [],
1860
+ holders: holders,
2127
1861
  isFormSubject: function isFormSubject(product) {
2128
1862
  return resolveIsFormSubject(tempOrder, product);
2129
1863
  },
@@ -2133,14 +1867,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2133
1867
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2134
1868
  }
2135
1869
  if (!result.discountList) {
2136
- _context21.next = 24;
1870
+ _context18.next = 25;
2137
1871
  break;
2138
1872
  }
2139
1873
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
2140
1874
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2141
- _context21.next = 22;
1875
+ _context18.next = 23;
2142
1876
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2143
- case 22:
1877
+ case 23:
2144
1878
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
2145
1879
  return discount.isSelected;
2146
1880
  });
@@ -2148,30 +1882,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2148
1882
  productList: tempOrder.products,
2149
1883
  discountList: nextDiscountList
2150
1884
  };
2151
- case 24:
2152
- _context21.next = 26;
1885
+ case 25:
1886
+ _context18.next = 27;
2153
1887
  return this.store.order.recalculateSummary({
2154
1888
  createIfMissing: true
2155
1889
  });
2156
- case 26:
1890
+ case 27:
2157
1891
  this.store.order.persistTempOrder();
2158
- _context21.next = 29;
2159
- return this.effectsEmit('onDiscountApplied', {
2160
- productList: tempOrder.products || [],
2161
- discountList: nextDiscountList,
2162
- selectedDiscountList: tempOrder.discount_list || [],
2163
- tempOrder: tempOrder
2164
- });
2165
- case 29:
2166
1892
  cb === null || cb === void 0 || cb(result);
2167
- return _context21.abrupt("return", result);
2168
- case 31:
1893
+ return _context18.abrupt("return", result);
1894
+ case 30:
2169
1895
  case "end":
2170
- return _context21.stop();
1896
+ return _context18.stop();
2171
1897
  }
2172
- }, _callee21, this);
1898
+ }, _callee18, this);
2173
1899
  }));
2174
- function bestDiscount(_x14) {
1900
+ function bestDiscount(_x12) {
2175
1901
  return _bestDiscount.apply(this, arguments);
2176
1902
  }
2177
1903
  return bestDiscount;
@@ -2182,118 +1908,52 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2182
1908
  if (!this.store.order) return [];
2183
1909
  return this.store.order.getDiscountList();
2184
1910
  }
2185
-
2186
- /** 读取 Discount 模块原始券列表(未经过 bookingTime 等过滤)。 */
2187
- }, {
2188
- key: "getOriginalDiscountList",
2189
- value: function getOriginalDiscountList() {
2190
- var _store, _discountModule$getOr3;
2191
- if (!this.store.order) return [];
2192
- var discountModule = (_store = this.store.order.store) === null || _store === void 0 ? void 0 : _store.discount;
2193
- return (discountModule === null || discountModule === void 0 || (_discountModule$getOr3 = discountModule.getOriginalDiscountList) === null || _discountModule$getOr3 === void 0 ? void 0 : _discountModule$getOr3.call(discountModule)) || [];
2194
- }
2195
-
2196
- /**
2197
- * 同步写入 Discount 模块的 discountList / originalDiscountList。
2198
- * 供 Holder 补全等场景在 OS store 层更新 machinecode holder 字段。
2199
- */
2200
- }, {
2201
- key: "replaceDiscountStoreLists",
2202
- value: (function () {
2203
- var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2204
- var _store2;
2205
- var discountModule;
2206
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2207
- while (1) switch (_context22.prev = _context22.next) {
2208
- case 0:
2209
- if (this.store.order) {
2210
- _context22.next = 2;
2211
- break;
2212
- }
2213
- throw new Error('order 模块未初始化');
2214
- case 2:
2215
- discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
2216
- if (discountModule) {
2217
- _context22.next = 5;
2218
- break;
2219
- }
2220
- return _context22.abrupt("return");
2221
- case 5:
2222
- if (!params.originalDiscountList) {
2223
- _context22.next = 8;
2224
- break;
2225
- }
2226
- _context22.next = 8;
2227
- return discountModule.setOriginalDiscountList(params.originalDiscountList);
2228
- case 8:
2229
- _context22.next = 10;
2230
- return discountModule.setDiscountList(params.discountList);
2231
- case 10:
2232
- case "end":
2233
- return _context22.stop();
2234
- }
2235
- }, _callee22, this);
2236
- }));
2237
- function replaceDiscountStoreLists(_x15) {
2238
- return _replaceDiscountStoreLists.apply(this, arguments);
2239
- }
2240
- return replaceDiscountStoreLists;
2241
- }())
2242
1911
  }, {
2243
1912
  key: "scanPromotionCode",
2244
1913
  value: function () {
2245
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, customerId) {
2246
- var raw, tempOrder;
2247
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2248
- while (1) switch (_context23.prev = _context23.next) {
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) {
2249
1918
  case 0:
2250
- _context23.prev = 0;
1919
+ _context19.prev = 0;
2251
1920
  if (this.store.order) {
2252
- _context23.next = 3;
1921
+ _context19.next = 3;
2253
1922
  break;
2254
1923
  }
2255
1924
  throw new Error('order 模块未初始化');
2256
1925
  case 3:
2257
- _context23.next = 5;
1926
+ _context19.next = 5;
2258
1927
  return this.store.order.scanCode(code, customerId);
2259
1928
  case 5:
2260
- raw = _context23.sent;
1929
+ raw = _context19.sent;
2261
1930
  if (!raw.isAvailable) {
2262
- _context23.next = 13;
1931
+ _context19.next = 10;
2263
1932
  break;
2264
1933
  }
2265
- _context23.next = 9;
1934
+ _context19.next = 9;
2266
1935
  return this.store.order.recalculateSummary({
2267
1936
  createIfMissing: true
2268
1937
  });
2269
1938
  case 9:
2270
1939
  this.store.order.persistTempOrder();
2271
- tempOrder = this.store.order.ensureTempOrder();
2272
- _context23.next = 13;
2273
- return this.effectsEmit('onDiscountApplied', {
2274
- productList: tempOrder.products || [],
2275
- discountList: this.store.order.getDiscountList(),
2276
- selectedDiscountList: tempOrder.discount_list || [],
2277
- tempOrder: tempOrder
2278
- });
2279
- case 13:
2280
- return _context23.abrupt("return", {
1940
+ case 10:
1941
+ return _context19.abrupt("return", {
2281
1942
  isAvailable: raw.isAvailable,
2282
1943
  type: raw.type,
2283
- unavailableReason: raw.unavailableReason,
2284
- scannedDiscountList: raw.scannedDiscountList
1944
+ unavailableReason: raw.unavailableReason
2285
1945
  });
1946
+ case 13:
1947
+ _context19.prev = 13;
1948
+ _context19.t0 = _context19["catch"](0);
1949
+ throw _context19.t0;
2286
1950
  case 16:
2287
- _context23.prev = 16;
2288
- _context23.t0 = _context23["catch"](0);
2289
- throw _context23.t0;
2290
- case 19:
2291
1951
  case "end":
2292
- return _context23.stop();
1952
+ return _context19.stop();
2293
1953
  }
2294
- }, _callee23, this, [[0, 16]]);
1954
+ }, _callee19, this, [[0, 13]]);
2295
1955
  }));
2296
- function scanPromotionCode(_x16, _x17) {
1956
+ function scanPromotionCode(_x13, _x14) {
2297
1957
  return _scanPromotionCode.apply(this, arguments);
2298
1958
  }
2299
1959
  return scanPromotionCode;
@@ -2301,14 +1961,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2301
1961
  }, {
2302
1962
  key: "setDiscountSelected",
2303
1963
  value: function () {
2304
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2305
- 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;
2306
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2307
- while (1) switch (_context24.prev = _context24.next) {
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) {
2308
1968
  case 0:
2309
- _context24.prev = 0;
1969
+ _context20.prev = 0;
2310
1970
  if (this.store.order) {
2311
- _context24.next = 3;
1971
+ _context20.next = 3;
2312
1972
  break;
2313
1973
  }
2314
1974
  throw new Error('order 模块未初始化');
@@ -2325,17 +1985,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2325
1985
  orderStore = this.store.order.store || {};
2326
1986
  discountModule = orderStore.discount;
2327
1987
  rulesModule = orderStore.rules;
1988
+ holders = ((_tempOrder$holder3 = tempOrder.holder) === null || _tempOrder$holder3 === void 0 ? void 0 : _tempOrder$holder3.form_record) || [];
2328
1989
  nextDiscountList = updated;
2329
- _context24.next = 13;
1990
+ _context20.next = 14;
2330
1991
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
2331
- case 13:
1992
+ case 14:
2332
1993
  if (rulesModule) {
2333
1994
  orderTotalAmount = Number(((_orderStore$summary3 = orderStore.summary) === null || _orderStore$summary3 === void 0 ? void 0 : _orderStore$summary3.total_amount) || 0);
2334
1995
  console.log('[BaseSales.setDiscountSelected.calcDiscount]');
2335
1996
  result = rulesModule.calcDiscount({
2336
1997
  productList: tempOrder.products,
2337
1998
  discountList: updated,
2338
- holders: [],
1999
+ holders: holders,
2339
2000
  isFormSubject: function isFormSubject(product) {
2340
2001
  return resolveIsFormSubject(tempOrder, product);
2341
2002
  },
@@ -2358,10 +2019,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2358
2019
  }).map(function (d) {
2359
2020
  return d.id;
2360
2021
  }));
2361
- _iterator3 = _createForOfIteratorHelper(nextDiscountList);
2022
+ _iterator2 = _createForOfIteratorHelper(nextDiscountList);
2362
2023
  try {
2363
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2364
- d = _step3.value;
2024
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2025
+ d = _step2.value;
2365
2026
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
2366
2027
  d.isSelected = false;
2367
2028
  d.isManualSelect = true;
@@ -2369,9 +2030,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2369
2030
  }
2370
2031
  }
2371
2032
  } catch (err) {
2372
- _iterator3.e(err);
2033
+ _iterator2.e(err);
2373
2034
  } finally {
2374
- _iterator3.f();
2035
+ _iterator2.f();
2375
2036
  }
2376
2037
  }
2377
2038
  }
@@ -2388,30 +2049,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2388
2049
  return rid != null && selectedResourceIds.has(rid);
2389
2050
  });
2390
2051
  };
2391
- _iterator4 = _createForOfIteratorHelper(tempOrder.products);
2392
- _context24.prev = 17;
2393
- _iterator4.s();
2394
- case 19:
2395
- if ((_step4 = _iterator4.n()).done) {
2396
- _context24.next = 36;
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;
2397
2058
  break;
2398
2059
  }
2399
- product = _step4.value;
2060
+ product = _step3.value;
2400
2061
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
2401
2062
  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;
2402
2063
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
2403
- _context24.next = 25;
2064
+ _context20.next = 26;
2404
2065
  break;
2405
2066
  }
2406
- return _context24.abrupt("continue", 34);
2407
- case 25:
2067
+ return _context20.abrupt("continue", 35);
2068
+ case 26:
2408
2069
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
2409
2070
  if (Array.isArray(product.product_bundle)) {
2410
2071
  product.product_bundle = product.product_bundle.map(function (bundle) {
2411
- var _ref21, _bundle$original_pric;
2072
+ var _ref19, _bundle$original_pric;
2412
2073
  var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
2413
2074
  var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
2414
- 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;
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;
2415
2076
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
2416
2077
  price: restoredBundlePrice,
2417
2078
  bundle_selling_price: restoredBundlePrice
@@ -2438,33 +2099,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2438
2099
  mainPrice: newMainSellingPrice,
2439
2100
  bundle: product.product_bundle
2440
2101
  });
2441
- case 34:
2442
- _context24.next = 19;
2102
+ case 35:
2103
+ _context20.next = 20;
2443
2104
  break;
2444
- case 36:
2445
- _context24.next = 41;
2105
+ case 37:
2106
+ _context20.next = 42;
2446
2107
  break;
2447
- case 38:
2448
- _context24.prev = 38;
2449
- _context24.t0 = _context24["catch"](17);
2450
- _iterator4.e(_context24.t0);
2451
- case 41:
2452
- _context24.prev = 41;
2453
- _iterator4.f();
2454
- return _context24.finish(41);
2455
- case 44:
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:
2456
2117
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2457
- _context24.next = 47;
2118
+ _context20.next = 48;
2458
2119
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2459
- case 47:
2120
+ case 48:
2460
2121
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2461
2122
  return d.isSelected;
2462
2123
  });
2463
- _context24.next = 50;
2124
+ _context20.next = 51;
2464
2125
  return this.store.order.recalculateSummary({
2465
2126
  createIfMissing: true
2466
2127
  });
2467
- case 50:
2128
+ case 51:
2468
2129
  this.store.order.persistTempOrder();
2469
2130
  this.effectsEmit('onDiscountApplied', {
2470
2131
  productList: tempOrder.products,
@@ -2472,19 +2133,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2472
2133
  selectedDiscountList: tempOrder.discount_list,
2473
2134
  tempOrder: tempOrder
2474
2135
  });
2475
- _context24.next = 57;
2136
+ _context20.next = 58;
2476
2137
  break;
2477
- case 54:
2478
- _context24.prev = 54;
2479
- _context24.t1 = _context24["catch"](0);
2480
- throw _context24.t1;
2481
- case 57:
2138
+ case 55:
2139
+ _context20.prev = 55;
2140
+ _context20.t1 = _context20["catch"](0);
2141
+ throw _context20.t1;
2142
+ case 58:
2482
2143
  case "end":
2483
- return _context24.stop();
2144
+ return _context20.stop();
2484
2145
  }
2485
- }, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
2146
+ }, _callee20, this, [[0, 55], [18, 39, 42, 45]]);
2486
2147
  }));
2487
- function setDiscountSelected(_x18) {
2148
+ function setDiscountSelected(_x15) {
2488
2149
  return _setDiscountSelected.apply(this, arguments);
2489
2150
  }
2490
2151
  return setDiscountSelected;
@@ -2492,23 +2153,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2492
2153
  }, {
2493
2154
  key: "applyDiscountCalculationResult",
2494
2155
  value: function () {
2495
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(result) {
2156
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(result) {
2496
2157
  var tempOrder, orderStore, discountModule;
2497
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2498
- while (1) switch (_context25.prev = _context25.next) {
2158
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2159
+ while (1) switch (_context21.prev = _context21.next) {
2499
2160
  case 0:
2500
- _context25.prev = 0;
2161
+ _context21.prev = 0;
2501
2162
  if (this.store.order) {
2502
- _context25.next = 3;
2163
+ _context21.next = 3;
2503
2164
  break;
2504
2165
  }
2505
2166
  throw new Error('order 模块未初始化');
2506
2167
  case 3:
2507
2168
  if (result) {
2508
- _context25.next = 5;
2169
+ _context21.next = 5;
2509
2170
  break;
2510
2171
  }
2511
- return _context25.abrupt("return");
2172
+ return _context21.abrupt("return");
2512
2173
  case 5:
2513
2174
  tempOrder = this.store.order.ensureTempOrder();
2514
2175
  orderStore = this.store.order.store || {};
@@ -2517,44 +2178,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2517
2178
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
2518
2179
  }
2519
2180
  if (!result.discountList) {
2520
- _context25.next = 14;
2181
+ _context21.next = 14;
2521
2182
  break;
2522
2183
  }
2523
2184
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
2524
- _context25.next = 13;
2185
+ _context21.next = 13;
2525
2186
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
2526
2187
  case 13:
2527
2188
  tempOrder.discount_list = result.discountList.filter(function (discount) {
2528
2189
  return discount.isSelected;
2529
2190
  });
2530
2191
  case 14:
2531
- _context25.next = 16;
2192
+ _context21.next = 16;
2532
2193
  return this.store.order.recalculateSummary({
2533
2194
  createIfMissing: true
2534
2195
  });
2535
2196
  case 16:
2536
2197
  this.store.order.persistTempOrder();
2537
- _context25.next = 19;
2538
- return this.effectsEmit('onDiscountApplied', {
2539
- productList: tempOrder.products || [],
2540
- discountList: result.discountList || [],
2541
- selectedDiscountList: tempOrder.discount_list || [],
2542
- tempOrder: tempOrder
2543
- });
2544
- case 19:
2545
- _context25.next = 24;
2198
+ _context21.next = 22;
2546
2199
  break;
2547
- case 21:
2548
- _context25.prev = 21;
2549
- _context25.t0 = _context25["catch"](0);
2550
- throw _context25.t0;
2551
- case 24:
2200
+ case 19:
2201
+ _context21.prev = 19;
2202
+ _context21.t0 = _context21["catch"](0);
2203
+ throw _context21.t0;
2204
+ case 22:
2552
2205
  case "end":
2553
- return _context25.stop();
2206
+ return _context21.stop();
2554
2207
  }
2555
- }, _callee25, this, [[0, 21]]);
2208
+ }, _callee21, this, [[0, 19]]);
2556
2209
  }));
2557
- function applyDiscountCalculationResult(_x19) {
2210
+ function applyDiscountCalculationResult(_x16) {
2558
2211
  return _applyDiscountCalculationResult.apply(this, arguments);
2559
2212
  }
2560
2213
  return applyDiscountCalculationResult;
@@ -2562,18 +2215,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2562
2215
  }, {
2563
2216
  key: "submitScanOrder",
2564
2217
  value: function () {
2565
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2566
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2567
- while (1) switch (_context26.prev = _context26.next) {
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) {
2568
2221
  case 0:
2569
- return _context26.abrupt("return", this.submitSalesOrder(params));
2222
+ return _context22.abrupt("return", this.submitSalesOrder(params));
2570
2223
  case 1:
2571
2224
  case "end":
2572
- return _context26.stop();
2225
+ return _context22.stop();
2573
2226
  }
2574
- }, _callee26, this);
2227
+ }, _callee22, this);
2575
2228
  }));
2576
- function submitScanOrder(_x20) {
2229
+ function submitScanOrder(_x17) {
2577
2230
  return _submitScanOrder.apply(this, arguments);
2578
2231
  }
2579
2232
  return submitScanOrder;
@@ -2587,14 +2240,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2587
2240
  }, {
2588
2241
  key: "submitSalesOrder",
2589
2242
  value: (function () {
2590
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
2243
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2591
2244
  var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
2592
2245
  var inferredPaymentStatus, submitParams;
2593
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2594
- while (1) switch (_context27.prev = _context27.next) {
2246
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2247
+ while (1) switch (_context23.prev = _context23.next) {
2595
2248
  case 0:
2596
2249
  if (this.store.order) {
2597
- _context27.next = 2;
2250
+ _context23.next = 2;
2598
2251
  break;
2599
2252
  }
2600
2253
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2619,14 +2272,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2619
2272
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2620
2273
  enhancePayload: params.enhancePayload
2621
2274
  } : {});
2622
- return _context27.abrupt("return", this.store.order.submitTempOrder(submitParams));
2275
+ return _context23.abrupt("return", this.store.order.submitTempOrder(submitParams));
2623
2276
  case 5:
2624
2277
  case "end":
2625
- return _context27.stop();
2278
+ return _context23.stop();
2626
2279
  }
2627
- }, _callee27, this);
2280
+ }, _callee23, this);
2628
2281
  }));
2629
- function submitSalesOrder(_x21) {
2282
+ function submitSalesOrder(_x18) {
2630
2283
  return _submitSalesOrder.apply(this, arguments);
2631
2284
  }
2632
2285
  return submitSalesOrder;
@@ -2634,14 +2287,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2634
2287
  }, {
2635
2288
  key: "submitTempOrderAsync",
2636
2289
  value: function () {
2637
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2290
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
2638
2291
  var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13;
2639
2292
  var inferredPaymentStatus, submitParams;
2640
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2641
- while (1) switch (_context28.prev = _context28.next) {
2293
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2294
+ while (1) switch (_context24.prev = _context24.next) {
2642
2295
  case 0:
2643
2296
  if (this.store.order) {
2644
- _context28.next = 2;
2297
+ _context24.next = 2;
2645
2298
  break;
2646
2299
  }
2647
2300
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2664,14 +2317,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2664
2317
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
2665
2318
  enhancePayload: params.enhancePayload
2666
2319
  } : {});
2667
- return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2320
+ return _context24.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
2668
2321
  case 5:
2669
2322
  case "end":
2670
- return _context28.stop();
2323
+ return _context24.stop();
2671
2324
  }
2672
- }, _callee28, this);
2325
+ }, _callee24, this);
2673
2326
  }));
2674
- function submitTempOrderAsync(_x22) {
2327
+ function submitTempOrderAsync(_x19) {
2675
2328
  return _submitTempOrderAsync.apply(this, arguments);
2676
2329
  }
2677
2330
  return submitTempOrderAsync;
@@ -2679,14 +2332,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2679
2332
  }, {
2680
2333
  key: "printLocalOrderReceipt",
2681
2334
  value: function () {
2682
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
2335
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(lookup) {
2683
2336
  var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
2684
- var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
2685
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2686
- while (1) switch (_context29.prev = _context29.next) {
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) {
2687
2340
  case 0:
2688
2341
  if (this.store.order) {
2689
- _context29.next = 2;
2342
+ _context25.next = 2;
2690
2343
  break;
2691
2344
  }
2692
2345
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -2717,28 +2370,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2717
2370
  channel: context.channel,
2718
2371
  type: context.type
2719
2372
  });
2720
- _context29.next = 8;
2373
+ _context25.next = 8;
2721
2374
  return this.request.post('/local/print-order', payload, {
2722
2375
  osServer: true,
2723
2376
  customToast: function customToast() {}
2724
2377
  });
2725
2378
  case 8:
2726
- response = _context29.sent;
2379
+ response = _context25.sent;
2727
2380
  if (hasLookup) {
2728
- _context29.next = 12;
2381
+ _context25.next = 12;
2729
2382
  break;
2730
2383
  }
2731
- _context29.next = 12;
2732
- 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);
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);
2733
2386
  case 12:
2734
- return _context29.abrupt("return", response);
2387
+ return _context25.abrupt("return", response);
2735
2388
  case 13:
2736
2389
  case "end":
2737
- return _context29.stop();
2390
+ return _context25.stop();
2738
2391
  }
2739
- }, _callee29, this);
2392
+ }, _callee25, this);
2740
2393
  }));
2741
- function printLocalOrderReceipt(_x23) {
2394
+ function printLocalOrderReceipt(_x20) {
2742
2395
  return _printLocalOrderReceipt.apply(this, arguments);
2743
2396
  }
2744
2397
  return printLocalOrderReceipt;
@@ -2746,9 +2399,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2746
2399
  }, {
2747
2400
  key: "getSubmitPaymentStatus",
2748
2401
  value: function getSubmitPaymentStatus(paymentStatus) {
2749
- var _this$store$order6, _this$store$order6$ge;
2402
+ var _this$store$order5, _this$store$order5$ge;
2750
2403
  if (paymentStatus !== undefined) return paymentStatus;
2751
- 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);
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);
2752
2405
  if (!amountSnapshot) return undefined;
2753
2406
  try {
2754
2407
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -2759,19 +2412,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2759
2412
  }, {
2760
2413
  key: "syncPaymentsToOrder",
2761
2414
  value: function () {
2762
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
2763
- var _ref22, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2415
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2416
+ var _ref20, _params$businessCode, _this$otherParams18, _this$otherParams19, _params$channel;
2764
2417
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2765
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2766
- while (1) switch (_context30.prev = _context30.next) {
2418
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2419
+ while (1) switch (_context26.prev = _context26.next) {
2767
2420
  case 0:
2768
2421
  if (this.store.order) {
2769
- _context30.next = 2;
2422
+ _context26.next = 2;
2770
2423
  break;
2771
2424
  }
2772
2425
  throw new Error('order 模块未初始化');
2773
2426
  case 2:
2774
- businessCode = (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code;
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;
2775
2428
  channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
2776
2429
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2777
2430
  businessCode: businessCode
@@ -2780,14 +2433,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2780
2433
  } : {});
2781
2434
  syncState = this.store.order.getOrderSyncState();
2782
2435
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
2783
- _context30.next = 9;
2436
+ _context26.next = 9;
2784
2437
  break;
2785
2438
  }
2786
2439
  this.queueLatestAutoPaymentSync();
2787
- return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2440
+ return _context26.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
2788
2441
  case 9:
2789
2442
  payments = params.payments || [];
2790
- _context30.next = 12;
2443
+ _context26.next = 12;
2791
2444
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
2792
2445
  payments: payments,
2793
2446
  params: syncParams,
@@ -2795,11 +2448,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2795
2448
  orderSnapshot: this.store.order.getOrderSnapshot()
2796
2449
  });
2797
2450
  case 12:
2798
- _context30.prev = 12;
2799
- _context30.next = 15;
2451
+ _context26.prev = 12;
2452
+ _context26.next = 15;
2800
2453
  return this.store.order.syncPaymentsToOrder(syncParams);
2801
2454
  case 15:
2802
- syncResult = _context30.sent;
2455
+ syncResult = _context26.sent;
2803
2456
  latestPayments = this.store.order.getOrderPayments();
2804
2457
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
2805
2458
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -2817,25 +2470,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2817
2470
  depositAmount: syncResult.depositAmount,
2818
2471
  orderExpectedAmount: syncResult.orderExpectedAmount
2819
2472
  };
2820
- _context30.next = 22;
2473
+ _context26.next = 22;
2821
2474
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
2822
2475
  case 22:
2823
2476
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
2824
- _context30.next = 25;
2477
+ _context26.next = 25;
2825
2478
  break;
2826
2479
  }
2827
- _context30.next = 25;
2480
+ _context26.next = 25;
2828
2481
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
2829
2482
  case 25:
2830
2483
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2831
- return _context30.abrupt("return", syncResult);
2484
+ return _context26.abrupt("return", syncResult);
2832
2485
  case 29:
2833
- _context30.prev = 29;
2834
- _context30.t0 = _context30["catch"](12);
2835
- _context30.next = 33;
2486
+ _context26.prev = 29;
2487
+ _context26.t0 = _context26["catch"](12);
2488
+ _context26.next = 33;
2836
2489
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
2837
2490
  ok: false,
2838
- error: _context30.t0,
2491
+ error: _context26.t0,
2839
2492
  payments: this.store.order.getOrderPayments(),
2840
2493
  params: syncParams,
2841
2494
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -2843,14 +2496,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2843
2496
  });
2844
2497
  case 33:
2845
2498
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2846
- throw _context30.t0;
2499
+ throw _context26.t0;
2847
2500
  case 35:
2848
2501
  case "end":
2849
- return _context30.stop();
2502
+ return _context26.stop();
2850
2503
  }
2851
- }, _callee30, this, [[12, 29]]);
2504
+ }, _callee26, this, [[12, 29]]);
2852
2505
  }));
2853
- function syncPaymentsToOrder(_x24) {
2506
+ function syncPaymentsToOrder(_x21) {
2854
2507
  return _syncPaymentsToOrder.apply(this, arguments);
2855
2508
  }
2856
2509
  return syncPaymentsToOrder;
@@ -2887,58 +2540,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2887
2540
  }, {
2888
2541
  key: "scheduleQueuedAutoPaymentSyncFlush",
2889
2542
  value: function scheduleQueuedAutoPaymentSyncFlush() {
2890
- var _this11 = this;
2543
+ var _this10 = this;
2891
2544
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
2892
2545
  if (!this.queuedAutoPaymentSync) return;
2893
2546
  if (this.autoPaymentSyncTimer) return;
2894
2547
  this.autoPaymentSyncTimer = setTimeout(function () {
2895
- _this11.autoPaymentSyncTimer = null;
2896
- void _this11.flushQueuedAutoPaymentSync();
2548
+ _this10.autoPaymentSyncTimer = null;
2549
+ void _this10.flushQueuedAutoPaymentSync();
2897
2550
  }, delay);
2898
2551
  }
2899
2552
  }, {
2900
2553
  key: "flushQueuedAutoPaymentSync",
2901
2554
  value: function () {
2902
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2555
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2903
2556
  var payments;
2904
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2905
- while (1) switch (_context31.prev = _context31.next) {
2557
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2558
+ while (1) switch (_context27.prev = _context27.next) {
2906
2559
  case 0:
2907
2560
  if (this.store.order) {
2908
- _context31.next = 2;
2561
+ _context27.next = 2;
2909
2562
  break;
2910
2563
  }
2911
- return _context31.abrupt("return");
2564
+ return _context27.abrupt("return");
2912
2565
  case 2:
2913
2566
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
2914
- _context31.next = 4;
2567
+ _context27.next = 4;
2915
2568
  break;
2916
2569
  }
2917
- return _context31.abrupt("return");
2570
+ return _context27.abrupt("return");
2918
2571
  case 4:
2919
2572
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
2920
- _context31.next = 7;
2573
+ _context27.next = 7;
2921
2574
  break;
2922
2575
  }
2923
2576
  this.scheduleQueuedAutoPaymentSyncFlush();
2924
- return _context31.abrupt("return");
2577
+ return _context27.abrupt("return");
2925
2578
  case 7:
2926
2579
  this.autoPaymentSyncFlushing = true;
2927
- _context31.prev = 8;
2580
+ _context27.prev = 8;
2928
2581
  case 9:
2929
2582
  if (!this.queuedAutoPaymentSync) {
2930
- _context31.next = 18;
2583
+ _context27.next = 18;
2931
2584
  break;
2932
2585
  }
2933
2586
  this.queuedAutoPaymentSync = false;
2934
2587
  payments = this.store.order.getOrderPayments();
2935
2588
  if (payments.length) {
2936
- _context31.next = 14;
2589
+ _context27.next = 14;
2937
2590
  break;
2938
2591
  }
2939
- return _context31.abrupt("continue", 9);
2592
+ return _context27.abrupt("continue", 9);
2940
2593
  case 14:
2941
- _context31.next = 16;
2594
+ _context27.next = 16;
2942
2595
  return this.syncPaymentsToOrder({
2943
2596
  payments: payments,
2944
2597
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -2946,29 +2599,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2946
2599
  smallTicketDataFlag: 1
2947
2600
  });
2948
2601
  case 16:
2949
- _context31.next = 9;
2602
+ _context27.next = 9;
2950
2603
  break;
2951
2604
  case 18:
2952
- _context31.next = 23;
2605
+ _context27.next = 23;
2953
2606
  break;
2954
2607
  case 20:
2955
- _context31.prev = 20;
2956
- _context31.t0 = _context31["catch"](8);
2608
+ _context27.prev = 20;
2609
+ _context27.t0 = _context27["catch"](8);
2957
2610
  this.logError('queued auto sync payments failed', {
2958
- error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
2611
+ error: _context27.t0 instanceof Error ? _context27.t0.message : String(_context27.t0)
2959
2612
  });
2960
2613
  case 23:
2961
- _context31.prev = 23;
2614
+ _context27.prev = 23;
2962
2615
  this.autoPaymentSyncFlushing = false;
2963
2616
  if (this.queuedAutoPaymentSync) {
2964
2617
  this.scheduleQueuedAutoPaymentSyncFlush(0);
2965
2618
  }
2966
- return _context31.finish(23);
2619
+ return _context27.finish(23);
2967
2620
  case 27:
2968
2621
  case "end":
2969
- return _context31.stop();
2622
+ return _context27.stop();
2970
2623
  }
2971
- }, _callee31, this, [[8, 20, 23, 27]]);
2624
+ }, _callee27, this, [[8, 20, 23, 27]]);
2972
2625
  }));
2973
2626
  function flushQueuedAutoPaymentSync() {
2974
2627
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -2981,9 +2634,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2981
2634
  var _this$otherParams20,
2982
2635
  _paymentRecord$paymen,
2983
2636
  _paymentRecord$create,
2984
- _ref23,
2637
+ _ref21,
2985
2638
  _paymentRecord$origin,
2986
- _this12 = this;
2639
+ _this11 = this;
2987
2640
  if (!this.store.order) throw new Error('order 模块未初始化');
2988
2641
  var paymentRecord = payment;
2989
2642
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -3005,7 +2658,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3005
2658
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3006
2659
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3007
2660
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3008
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref23 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref23 !== void 0 ? _ref23 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
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;
3009
2662
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
3010
2663
  service_fee: calculatedServiceFee
3011
2664
  } : {}), {}, {
@@ -3026,7 +2679,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3026
2679
  submitWhenPaid: true,
3027
2680
  smallTicketDataFlag: 1
3028
2681
  }).catch(function (error) {
3029
- _this12.logError('auto sync payments failed', {
2682
+ _this11.logError('auto sync payments failed', {
3030
2683
  error: error instanceof Error ? error.message : String(error)
3031
2684
  });
3032
2685
  });
@@ -3072,8 +2725,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3072
2725
  }, {
3073
2726
  key: "getWalletProductList",
3074
2727
  value: function getWalletProductList() {
3075
- var _this$store$order7, _tempOrder$products;
3076
- var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
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();
3077
2730
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
3078
2731
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
3079
2732
  // debugger
@@ -3133,20 +2786,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3133
2786
  }, {
3134
2787
  key: "initWalletData",
3135
2788
  value: function () {
3136
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3137
- var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
2789
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2790
+ var _params$order_wait_pa, _ref22, _tempOrder$is_price_i;
3138
2791
  var snapshot, tempOrder, amount, walletBusinessData, result;
3139
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3140
- while (1) switch (_context32.prev = _context32.next) {
2792
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2793
+ while (1) switch (_context28.prev = _context28.next) {
3141
2794
  case 0:
3142
2795
  if (this.store.order) {
3143
- _context32.next = 2;
2796
+ _context28.next = 2;
3144
2797
  break;
3145
2798
  }
3146
2799
  throw new Error('order 模块未初始化');
3147
2800
  case 2:
3148
2801
  if (this.store.payment) {
3149
- _context32.next = 4;
2802
+ _context28.next = 4;
3150
2803
  break;
3151
2804
  }
3152
2805
  throw new Error('payment 模块未初始化');
@@ -3155,10 +2808,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3155
2808
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
3156
2809
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
3157
2810
  if (!(!tempOrder || !amount)) {
3158
- _context32.next = 9;
2811
+ _context28.next = 9;
3159
2812
  break;
3160
2813
  }
3161
- return _context32.abrupt("return", {
2814
+ return _context28.abrupt("return", {
3162
2815
  walletRecommendList: [],
3163
2816
  userIdentificationCodes: [],
3164
2817
  transformList: [],
@@ -3177,15 +2830,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3177
2830
  },
3178
2831
  products: this.getWalletProductList(),
3179
2832
  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),
3180
- is_price_include_tax: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : 1
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
3181
2834
  }, snapshot.identity.orderId ? {
3182
2835
  payment_order_id: String(snapshot.identity.orderId)
3183
2836
  } : {});
3184
- _context32.next = 12;
2837
+ _context28.next = 12;
3185
2838
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
3186
2839
  case 12:
3187
- result = _context32.sent;
3188
- _context32.next = 15;
2840
+ result = _context28.sent;
2841
+ _context28.next = 15;
3189
2842
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
3190
2843
  orderId: snapshot.identity.orderId,
3191
2844
  customerId: walletBusinessData.customer_id,
@@ -3197,14 +2850,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3197
2850
  timestamp: Date.now()
3198
2851
  });
3199
2852
  case 15:
3200
- return _context32.abrupt("return", result);
2853
+ return _context28.abrupt("return", result);
3201
2854
  case 16:
3202
2855
  case "end":
3203
- return _context32.stop();
2856
+ return _context28.stop();
3204
2857
  }
3205
- }, _callee32, this);
2858
+ }, _callee28, this);
3206
2859
  }));
3207
- function initWalletData(_x25) {
2860
+ function initWalletData(_x22) {
3208
2861
  return _initWalletData.apply(this, arguments);
3209
2862
  }
3210
2863
  return initWalletData;
@@ -3231,35 +2884,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3231
2884
  }, {
3232
2885
  key: "getPaymentMethodsAsync",
3233
2886
  value: (function () {
3234
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2887
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
3235
2888
  var response, paymentMethods;
3236
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3237
- while (1) switch (_context33.prev = _context33.next) {
2889
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2890
+ while (1) switch (_context29.prev = _context29.next) {
3238
2891
  case 0:
3239
- _context33.prev = 0;
3240
- _context33.next = 3;
2892
+ _context29.prev = 0;
2893
+ _context29.next = 3;
3241
2894
  return this.request.get('/pay/custom-payment/all', {
3242
2895
  filterPaymentMethods: true
3243
2896
  }, {
3244
2897
  osServer: true
3245
2898
  });
3246
2899
  case 3:
3247
- response = _context33.sent;
2900
+ response = _context29.sent;
3248
2901
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
3249
2902
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
3250
- return _context33.abrupt("return", this.getPaymentMethods());
2903
+ return _context29.abrupt("return", this.getPaymentMethods());
3251
2904
  case 9:
3252
- _context33.prev = 9;
3253
- _context33.t0 = _context33["catch"](0);
2905
+ _context29.prev = 9;
2906
+ _context29.t0 = _context29["catch"](0);
3254
2907
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
3255
- error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
2908
+ error: _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0)
3256
2909
  });
3257
- return _context33.abrupt("return", this.getPaymentMethods());
2910
+ return _context29.abrupt("return", this.getPaymentMethods());
3258
2911
  case 13:
3259
2912
  case "end":
3260
- return _context33.stop();
2913
+ return _context29.stop();
3261
2914
  }
3262
- }, _callee33, this, [[0, 9]]);
2915
+ }, _callee29, this, [[0, 9]]);
3263
2916
  }));
3264
2917
  function getPaymentMethodsAsync() {
3265
2918
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -3307,49 +2960,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3307
2960
  }, {
3308
2961
  key: "sendCustomerPayLink",
3309
2962
  value: (function () {
3310
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3311
- var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3312
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3313
- while (1) switch (_context34.prev = _context34.next) {
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) {
3314
2967
  case 0:
3315
2968
  if (this.store.order) {
3316
- _context34.next = 2;
2969
+ _context30.next = 2;
3317
2970
  break;
3318
2971
  }
3319
2972
  throw new Error('order 模块未初始化');
3320
2973
  case 2:
3321
2974
  orderIds = params.order_ids || params.orderIds || [];
3322
2975
  if (!(!orderIds.length || params.submitBeforeSend)) {
3323
- _context34.next = 11;
2976
+ _context30.next = 11;
3324
2977
  break;
3325
2978
  }
3326
- _context34.next = 6;
2979
+ _context30.next = 6;
3327
2980
  return this.submitSalesOrder({
3328
2981
  smallTicketDataFlag: 1
3329
2982
  });
3330
2983
  case 6:
3331
- submitResult = _context34.sent;
3332
- orderId = (_ref25 = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
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;
3333
2986
  if (orderId) {
3334
- _context34.next = 10;
2987
+ _context30.next = 10;
3335
2988
  break;
3336
2989
  }
3337
2990
  throw new Error('本地订单提交云端失败,无法发送支付链接');
3338
2991
  case 10:
3339
2992
  orderIds = [orderId];
3340
2993
  case 11:
3341
- return _context34.abrupt("return", this.store.order.sendCustomerPayLink({
2994
+ return _context30.abrupt("return", this.store.order.sendCustomerPayLink({
3342
2995
  emails: params.emails,
3343
2996
  notify_action: params.notify_action,
3344
2997
  order_ids: orderIds
3345
2998
  }));
3346
2999
  case 12:
3347
3000
  case "end":
3348
- return _context34.stop();
3001
+ return _context30.stop();
3349
3002
  }
3350
- }, _callee34, this);
3003
+ }, _callee30, this);
3351
3004
  }));
3352
- function sendCustomerPayLink(_x26) {
3005
+ function sendCustomerPayLink(_x23) {
3353
3006
  return _sendCustomerPayLink.apply(this, arguments);
3354
3007
  }
3355
3008
  return sendCustomerPayLink;
@@ -3362,27 +3015,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3362
3015
  }, {
3363
3016
  key: "calculateProductBookingPrice",
3364
3017
  value: function () {
3365
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3018
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3366
3019
  var _params$customer_id;
3367
3020
  var quotation, customerId, authoritativeProduct, product;
3368
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3369
- while (1) switch (_context35.prev = _context35.next) {
3021
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3022
+ while (1) switch (_context31.prev = _context31.next) {
3370
3023
  case 0:
3371
3024
  quotation = this.store.quotation;
3372
3025
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
3373
- _context35.next = 4;
3026
+ _context31.next = 4;
3374
3027
  return this.loadProductForPriceQuery(params, customerId);
3375
3028
  case 4:
3376
- authoritativeProduct = _context35.sent;
3029
+ authoritativeProduct = _context31.sent;
3377
3030
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
3378
- _context35.next = 8;
3031
+ _context31.next = 8;
3379
3032
  return this.loadQuotationForPriceQuery({
3380
3033
  quotation: quotation,
3381
3034
  customer_id: customerId,
3382
3035
  channel: params.channel
3383
3036
  });
3384
3037
  case 8:
3385
- return _context35.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3038
+ return _context31.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3386
3039
  product: product,
3387
3040
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
3388
3041
  customer_id: customerId,
@@ -3390,11 +3043,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3390
3043
  })));
3391
3044
  case 9:
3392
3045
  case "end":
3393
- return _context35.stop();
3046
+ return _context31.stop();
3394
3047
  }
3395
- }, _callee35, this);
3048
+ }, _callee31, this);
3396
3049
  }));
3397
- function calculateProductBookingPrice(_x27) {
3050
+ function calculateProductBookingPrice(_x24) {
3398
3051
  return _calculateProductBookingPrice.apply(this, arguments);
3399
3052
  }
3400
3053
  return calculateProductBookingPrice;
@@ -3402,7 +3055,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3402
3055
  }, {
3403
3056
  key: "getQuotationCustomerScopeInfo",
3404
3057
  value: function getQuotationCustomerScopeInfo() {
3405
- var _this13 = this;
3058
+ var _this12 = this;
3406
3059
  var quotation = this.store.quotation;
3407
3060
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
3408
3061
  return quotation.getQuotationCustomerScopeInfo();
@@ -3414,7 +3067,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3414
3067
  }).map(function (item) {
3415
3068
  var localSeen = new Set();
3416
3069
  var customers = item.customer.filter(function (customer) {
3417
- var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3070
+ var customerId = _this12.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
3418
3071
  if (!customerId || localSeen.has(customerId)) return false;
3419
3072
  localSeen.add(customerId);
3420
3073
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -3464,32 +3117,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3464
3117
  }, {
3465
3118
  key: "calculateProductBookingPrices",
3466
3119
  value: function () {
3467
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(paramsList) {
3120
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(paramsList) {
3468
3121
  var _paramsList$0$custome,
3469
3122
  _paramsList$,
3470
- _this14 = this,
3123
+ _this13 = this,
3471
3124
  _paramsList$2;
3472
3125
  var quotation, customerId, productMapsByGroup, groups;
3473
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3474
- while (1) switch (_context37.prev = _context37.next) {
3126
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3127
+ while (1) switch (_context33.prev = _context33.next) {
3475
3128
  case 0:
3476
3129
  if (paramsList.length) {
3477
- _context37.next = 2;
3130
+ _context33.next = 2;
3478
3131
  break;
3479
3132
  }
3480
- return _context37.abrupt("return", []);
3133
+ return _context33.abrupt("return", []);
3481
3134
  case 2:
3482
3135
  quotation = this.store.quotation;
3483
3136
  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();
3484
3137
  productMapsByGroup = new Map();
3485
3138
  groups = new Map();
3486
3139
  paramsList.forEach(function (params) {
3487
- var _this14$otherParams;
3140
+ var _this13$otherParams;
3488
3141
  var product = params.product || {};
3489
- var productId = _this14.getPriceQueryProductId(product);
3142
+ var productId = _this13.getPriceQueryProductId(product);
3490
3143
  if (productId === null) return;
3491
- var schedule = _this14.getPriceQuerySchedule(params);
3492
- var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
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);
3493
3146
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3494
3147
  var group = groups.get(groupKey) || {
3495
3148
  ids: new Set(),
@@ -3499,51 +3152,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3499
3152
  group.ids.add(productId);
3500
3153
  groups.set(groupKey, group);
3501
3154
  });
3502
- _context37.next = 9;
3155
+ _context33.next = 9;
3503
3156
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3504
- var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(_ref27) {
3505
- var _ref29, groupKey, group, productsById;
3506
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3507
- while (1) switch (_context36.prev = _context36.next) {
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) {
3508
3161
  case 0:
3509
- _ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
3510
- _context36.next = 3;
3511
- return _this14.loadProductsForPriceQuery({
3162
+ _ref27 = _slicedToArray(_ref25, 2), groupKey = _ref27[0], group = _ref27[1];
3163
+ _context32.next = 3;
3164
+ return _this13.loadProductsForPriceQuery({
3512
3165
  ids: Array.from(group.ids),
3513
3166
  schedule: group.schedule,
3514
3167
  customerId: customerId,
3515
3168
  channel: group.channel
3516
3169
  });
3517
3170
  case 3:
3518
- productsById = _context36.sent;
3171
+ productsById = _context32.sent;
3519
3172
  productMapsByGroup.set(groupKey, productsById);
3520
3173
  case 5:
3521
3174
  case "end":
3522
- return _context36.stop();
3175
+ return _context32.stop();
3523
3176
  }
3524
- }, _callee36);
3177
+ }, _callee32);
3525
3178
  }));
3526
- return function (_x29) {
3527
- return _ref28.apply(this, arguments);
3179
+ return function (_x26) {
3180
+ return _ref26.apply(this, arguments);
3528
3181
  };
3529
3182
  }()));
3530
3183
  case 9:
3531
- _context37.next = 11;
3184
+ _context33.next = 11;
3532
3185
  return this.loadQuotationForPriceQuery({
3533
3186
  quotation: quotation,
3534
3187
  customer_id: customerId,
3535
3188
  channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
3536
3189
  });
3537
3190
  case 11:
3538
- return _context37.abrupt("return", paramsList.map(function (params) {
3539
- var _this14$otherParams2, _productMapsByGroup$g;
3191
+ return _context33.abrupt("return", paramsList.map(function (params) {
3192
+ var _this13$otherParams2, _productMapsByGroup$g;
3540
3193
  var productInput = params.product || {};
3541
- var productId = _this14.getPriceQueryProductId(productInput);
3542
- var schedule = _this14.getPriceQuerySchedule(params);
3543
- var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
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);
3544
3197
  var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
3545
3198
  var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
3546
- var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
3199
+ var product = _this13.mergeProductForPriceQuery(productInput, authoritativeProduct);
3547
3200
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
3548
3201
  product: product,
3549
3202
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -3553,11 +3206,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3553
3206
  }));
3554
3207
  case 12:
3555
3208
  case "end":
3556
- return _context37.stop();
3209
+ return _context33.stop();
3557
3210
  }
3558
- }, _callee37, this);
3211
+ }, _callee33, this);
3559
3212
  }));
3560
- function calculateProductBookingPrices(_x28) {
3213
+ function calculateProductBookingPrices(_x25) {
3561
3214
  return _calculateProductBookingPrices.apply(this, arguments);
3562
3215
  }
3563
3216
  return calculateProductBookingPrices;
@@ -3565,34 +3218,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3565
3218
  }, {
3566
3219
  key: "addProductToOrder",
3567
3220
  value: function () {
3568
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(product, booking) {
3221
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(product, booking) {
3569
3222
  var products;
3570
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3571
- while (1) switch (_context38.prev = _context38.next) {
3223
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3224
+ while (1) switch (_context34.prev = _context34.next) {
3572
3225
  case 0:
3573
- _context38.prev = 0;
3226
+ _context34.prev = 0;
3574
3227
  if (this.store.order) {
3575
- _context38.next = 3;
3228
+ _context34.next = 3;
3576
3229
  break;
3577
3230
  }
3578
3231
  throw new Error('order 模块未初始化');
3579
3232
  case 3:
3580
- _context38.next = 5;
3233
+ _context34.next = 5;
3581
3234
  return this.store.order.addProductToOrder(product, booking);
3582
3235
  case 5:
3583
- products = _context38.sent;
3584
- return _context38.abrupt("return", products);
3236
+ products = _context34.sent;
3237
+ return _context34.abrupt("return", products);
3585
3238
  case 9:
3586
- _context38.prev = 9;
3587
- _context38.t0 = _context38["catch"](0);
3588
- throw _context38.t0;
3239
+ _context34.prev = 9;
3240
+ _context34.t0 = _context34["catch"](0);
3241
+ throw _context34.t0;
3589
3242
  case 12:
3590
3243
  case "end":
3591
- return _context38.stop();
3244
+ return _context34.stop();
3592
3245
  }
3593
- }, _callee38, this, [[0, 9]]);
3246
+ }, _callee34, this, [[0, 9]]);
3594
3247
  }));
3595
- function addProductToOrder(_x30, _x31) {
3248
+ function addProductToOrder(_x27, _x28) {
3596
3249
  return _addProductToOrder.apply(this, arguments);
3597
3250
  }
3598
3251
  return addProductToOrder;
@@ -3600,34 +3253,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3600
3253
  }, {
3601
3254
  key: "updateOrderProduct",
3602
3255
  value: function () {
3603
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3256
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
3604
3257
  var products;
3605
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3606
- while (1) switch (_context39.prev = _context39.next) {
3258
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3259
+ while (1) switch (_context35.prev = _context35.next) {
3607
3260
  case 0:
3608
- _context39.prev = 0;
3261
+ _context35.prev = 0;
3609
3262
  if (this.store.order) {
3610
- _context39.next = 3;
3263
+ _context35.next = 3;
3611
3264
  break;
3612
3265
  }
3613
3266
  throw new Error('order 模块未初始化');
3614
3267
  case 3:
3615
- _context39.next = 5;
3268
+ _context35.next = 5;
3616
3269
  return this.store.order.updateOrderProduct(params);
3617
3270
  case 5:
3618
- products = _context39.sent;
3619
- return _context39.abrupt("return", products);
3271
+ products = _context35.sent;
3272
+ return _context35.abrupt("return", products);
3620
3273
  case 9:
3621
- _context39.prev = 9;
3622
- _context39.t0 = _context39["catch"](0);
3623
- throw _context39.t0;
3274
+ _context35.prev = 9;
3275
+ _context35.t0 = _context35["catch"](0);
3276
+ throw _context35.t0;
3624
3277
  case 12:
3625
3278
  case "end":
3626
- return _context39.stop();
3279
+ return _context35.stop();
3627
3280
  }
3628
- }, _callee39, this, [[0, 9]]);
3281
+ }, _callee35, this, [[0, 9]]);
3629
3282
  }));
3630
- function updateOrderProduct(_x32) {
3283
+ function updateOrderProduct(_x29) {
3631
3284
  return _updateOrderProduct.apply(this, arguments);
3632
3285
  }
3633
3286
  return updateOrderProduct;
@@ -3635,34 +3288,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3635
3288
  }, {
3636
3289
  key: "updateOrderProducts",
3637
3290
  value: function () {
3638
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paramsList) {
3291
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(paramsList) {
3639
3292
  var products;
3640
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3641
- while (1) switch (_context40.prev = _context40.next) {
3293
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3294
+ while (1) switch (_context36.prev = _context36.next) {
3642
3295
  case 0:
3643
- _context40.prev = 0;
3296
+ _context36.prev = 0;
3644
3297
  if (this.store.order) {
3645
- _context40.next = 3;
3298
+ _context36.next = 3;
3646
3299
  break;
3647
3300
  }
3648
3301
  throw new Error('order 模块未初始化');
3649
3302
  case 3:
3650
- _context40.next = 5;
3303
+ _context36.next = 5;
3651
3304
  return this.store.order.updateOrderProducts(paramsList);
3652
3305
  case 5:
3653
- products = _context40.sent;
3654
- return _context40.abrupt("return", products);
3306
+ products = _context36.sent;
3307
+ return _context36.abrupt("return", products);
3655
3308
  case 9:
3656
- _context40.prev = 9;
3657
- _context40.t0 = _context40["catch"](0);
3658
- throw _context40.t0;
3309
+ _context36.prev = 9;
3310
+ _context36.t0 = _context36["catch"](0);
3311
+ throw _context36.t0;
3659
3312
  case 12:
3660
3313
  case "end":
3661
- return _context40.stop();
3314
+ return _context36.stop();
3662
3315
  }
3663
- }, _callee40, this, [[0, 9]]);
3316
+ }, _callee36, this, [[0, 9]]);
3664
3317
  }));
3665
- function updateOrderProducts(_x33) {
3318
+ function updateOrderProducts(_x30) {
3666
3319
  return _updateOrderProducts.apply(this, arguments);
3667
3320
  }
3668
3321
  return updateOrderProducts;
@@ -3670,34 +3323,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3670
3323
  }, {
3671
3324
  key: "updateOrderProductQuantity",
3672
3325
  value: function () {
3673
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3326
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
3674
3327
  var products;
3675
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3676
- while (1) switch (_context41.prev = _context41.next) {
3328
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3329
+ while (1) switch (_context37.prev = _context37.next) {
3677
3330
  case 0:
3678
- _context41.prev = 0;
3331
+ _context37.prev = 0;
3679
3332
  if (this.store.order) {
3680
- _context41.next = 3;
3333
+ _context37.next = 3;
3681
3334
  break;
3682
3335
  }
3683
3336
  throw new Error('order 模块未初始化');
3684
3337
  case 3:
3685
- _context41.next = 5;
3338
+ _context37.next = 5;
3686
3339
  return this.store.order.updateOrderProductQuantity(params);
3687
3340
  case 5:
3688
- products = _context41.sent;
3689
- return _context41.abrupt("return", products);
3341
+ products = _context37.sent;
3342
+ return _context37.abrupt("return", products);
3690
3343
  case 9:
3691
- _context41.prev = 9;
3692
- _context41.t0 = _context41["catch"](0);
3693
- throw _context41.t0;
3344
+ _context37.prev = 9;
3345
+ _context37.t0 = _context37["catch"](0);
3346
+ throw _context37.t0;
3694
3347
  case 12:
3695
3348
  case "end":
3696
- return _context41.stop();
3349
+ return _context37.stop();
3697
3350
  }
3698
- }, _callee41, this, [[0, 9]]);
3351
+ }, _callee37, this, [[0, 9]]);
3699
3352
  }));
3700
- function updateOrderProductQuantity(_x34) {
3353
+ function updateOrderProductQuantity(_x31) {
3701
3354
  return _updateOrderProductQuantity.apply(this, arguments);
3702
3355
  }
3703
3356
  return updateOrderProductQuantity;
@@ -3720,12 +3373,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3720
3373
  }, {
3721
3374
  key: "setOrderProductLineNote",
3722
3375
  value: (function () {
3723
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(identity, note) {
3376
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(identity, note) {
3724
3377
  var params, products;
3725
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3726
- while (1) switch (_context42.prev = _context42.next) {
3378
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3379
+ while (1) switch (_context38.prev = _context38.next) {
3727
3380
  case 0:
3728
- _context42.prev = 0;
3381
+ _context38.prev = 0;
3729
3382
  params = {
3730
3383
  product_id: identity.product_id,
3731
3384
  product_variant_id: identity.product_variant_id,
@@ -3740,22 +3393,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3740
3393
  params.product_sku = identity.product_sku;
3741
3394
  }
3742
3395
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
3743
- _context42.next = 7;
3396
+ _context38.next = 7;
3744
3397
  return this.updateOrderProduct(params);
3745
3398
  case 7:
3746
- products = _context42.sent;
3747
- return _context42.abrupt("return", products);
3399
+ products = _context38.sent;
3400
+ return _context38.abrupt("return", products);
3748
3401
  case 11:
3749
- _context42.prev = 11;
3750
- _context42.t0 = _context42["catch"](0);
3751
- throw _context42.t0;
3402
+ _context38.prev = 11;
3403
+ _context38.t0 = _context38["catch"](0);
3404
+ throw _context38.t0;
3752
3405
  case 14:
3753
3406
  case "end":
3754
- return _context42.stop();
3407
+ return _context38.stop();
3755
3408
  }
3756
- }, _callee42, this, [[0, 11]]);
3409
+ }, _callee38, this, [[0, 11]]);
3757
3410
  }));
3758
- function setOrderProductLineNote(_x35, _x36) {
3411
+ function setOrderProductLineNote(_x32, _x33) {
3759
3412
  return _setOrderProductLineNote.apply(this, arguments);
3760
3413
  }
3761
3414
  return setOrderProductLineNote;
@@ -3770,32 +3423,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3770
3423
  }, {
3771
3424
  key: "removeProductsFromOrder",
3772
3425
  value: (function () {
3773
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identities) {
3774
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3775
- while (1) switch (_context43.prev = _context43.next) {
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) {
3776
3429
  case 0:
3777
- _context43.prev = 0;
3430
+ _context39.prev = 0;
3778
3431
  if (this.store.order) {
3779
- _context43.next = 3;
3432
+ _context39.next = 3;
3780
3433
  break;
3781
3434
  }
3782
3435
  throw new Error('order 模块未初始化');
3783
3436
  case 3:
3784
- _context43.next = 5;
3437
+ _context39.next = 5;
3785
3438
  return this.store.order.removeProductsFromOrder(identities);
3786
3439
  case 5:
3787
- return _context43.abrupt("return", _context43.sent);
3440
+ return _context39.abrupt("return", _context39.sent);
3788
3441
  case 8:
3789
- _context43.prev = 8;
3790
- _context43.t0 = _context43["catch"](0);
3791
- throw _context43.t0;
3442
+ _context39.prev = 8;
3443
+ _context39.t0 = _context39["catch"](0);
3444
+ throw _context39.t0;
3792
3445
  case 11:
3793
3446
  case "end":
3794
- return _context43.stop();
3447
+ return _context39.stop();
3795
3448
  }
3796
- }, _callee43, this, [[0, 8]]);
3449
+ }, _callee39, this, [[0, 8]]);
3797
3450
  }));
3798
- function removeProductsFromOrder(_x37) {
3451
+ function removeProductsFromOrder(_x34) {
3799
3452
  return _removeProductsFromOrder.apply(this, arguments);
3800
3453
  }
3801
3454
  return removeProductsFromOrder;
@@ -3803,18 +3456,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3803
3456
  }, {
3804
3457
  key: "removeProductFromOrder",
3805
3458
  value: function () {
3806
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identity) {
3807
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3808
- while (1) switch (_context44.prev = _context44.next) {
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) {
3809
3462
  case 0:
3810
- return _context44.abrupt("return", this.removeProductsFromOrder([identity]));
3463
+ return _context40.abrupt("return", this.removeProductsFromOrder([identity]));
3811
3464
  case 1:
3812
3465
  case "end":
3813
- return _context44.stop();
3466
+ return _context40.stop();
3814
3467
  }
3815
- }, _callee44, this);
3468
+ }, _callee40, this);
3816
3469
  }));
3817
- function removeProductFromOrder(_x38) {
3470
+ function removeProductFromOrder(_x35) {
3818
3471
  return _removeProductFromOrder.apply(this, arguments);
3819
3472
  }
3820
3473
  return removeProductFromOrder;
@@ -3864,23 +3517,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3864
3517
  }, {
3865
3518
  key: "applyPromotion",
3866
3519
  value: (function () {
3867
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3868
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3869
- while (1) switch (_context45.prev = _context45.next) {
3520
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3521
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3522
+ while (1) switch (_context41.prev = _context41.next) {
3870
3523
  case 0:
3871
3524
  if (this.store.order) {
3872
- _context45.next = 2;
3525
+ _context41.next = 2;
3873
3526
  break;
3874
3527
  }
3875
3528
  throw new Error('order 模块未初始化');
3876
3529
  case 2:
3877
- _context45.next = 4;
3530
+ _context41.next = 4;
3878
3531
  return this.store.order.applyPromotion();
3879
3532
  case 4:
3880
3533
  case "end":
3881
- return _context45.stop();
3534
+ return _context41.stop();
3882
3535
  }
3883
- }, _callee45, this);
3536
+ }, _callee41, this);
3884
3537
  }));
3885
3538
  function applyPromotion() {
3886
3539
  return _applyPromotion.apply(this, arguments);
@@ -3890,16 +3543,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3890
3543
  }, {
3891
3544
  key: "getUnfulfilledPromotions",
3892
3545
  value: function getUnfulfilledPromotions() {
3893
- var _this$store$order8;
3894
- return ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.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()) || [];
3895
3548
  }
3896
3549
 
3897
3550
  /** 最近一次促销计算输出的赠品操作 diff。 */
3898
3551
  }, {
3899
3552
  key: "getLastGiftActions",
3900
3553
  value: function getLastGiftActions() {
3901
- var _this$store$order9;
3902
- return ((_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 ? void 0 : _this$store$order9.getLastGiftActions()) || null;
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;
3903
3556
  }
3904
3557
 
3905
3558
  // 获取商品列表
@@ -3907,18 +3560,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3907
3560
  }, {
3908
3561
  key: "getProductList",
3909
3562
  value: function () {
3910
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3563
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3911
3564
  var _this$otherParams21;
3912
3565
  var menu_list_ids, _this$store$products, res;
3913
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3914
- while (1) switch (_context46.prev = _context46.next) {
3566
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3567
+ while (1) switch (_context42.prev = _context42.next) {
3915
3568
  case 0:
3916
3569
  // 可以直接通过配置里的 menu 读取
3917
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) {
3918
3571
  return Number(n.value);
3919
3572
  })) || [];
3920
- _context46.prev = 1;
3921
- _context46.next = 4;
3573
+ _context42.prev = 1;
3574
+ _context42.next = 4;
3922
3575
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
3923
3576
  menu_list_ids: menu_list_ids,
3924
3577
  cacheId: this.cacheId,
@@ -3926,17 +3579,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3926
3579
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3927
3580
  });
3928
3581
  case 4:
3929
- res = _context46.sent;
3930
- return _context46.abrupt("return", res);
3582
+ res = _context42.sent;
3583
+ return _context42.abrupt("return", res);
3931
3584
  case 8:
3932
- _context46.prev = 8;
3933
- _context46.t0 = _context46["catch"](1);
3934
- throw _context46.t0;
3585
+ _context42.prev = 8;
3586
+ _context42.t0 = _context42["catch"](1);
3587
+ throw _context42.t0;
3935
3588
  case 11:
3936
3589
  case "end":
3937
- return _context46.stop();
3590
+ return _context42.stop();
3938
3591
  }
3939
- }, _callee46, this, [[1, 8]]);
3592
+ }, _callee42, this, [[1, 8]]);
3940
3593
  }));
3941
3594
  function getProductList() {
3942
3595
  return _getProductList.apply(this, arguments);
@@ -3951,33 +3604,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3951
3604
  }, {
3952
3605
  key: "setOtherParams",
3953
3606
  value: function () {
3954
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
3607
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
3955
3608
  var _this$otherParams22;
3956
- var _ref30,
3957
- _ref30$cover,
3609
+ var _ref28,
3610
+ _ref28$cover,
3958
3611
  cover,
3959
- _args47 = arguments;
3960
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3961
- while (1) switch (_context47.prev = _context47.next) {
3612
+ _args43 = arguments;
3613
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3614
+ while (1) switch (_context43.prev = _context43.next) {
3962
3615
  case 0:
3963
- _ref30 = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
3616
+ _ref28 = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : {}, _ref28$cover = _ref28.cover, cover = _ref28$cover === void 0 ? false : _ref28$cover;
3964
3617
  if (cover) {
3965
3618
  this.otherParams = _objectSpread({}, params);
3966
3619
  } else {
3967
3620
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
3968
3621
  }
3969
3622
  this.cacheId = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.cacheId;
3970
- _context47.next = 5;
3623
+ _context43.next = 5;
3971
3624
  return this.syncOtherParamsToSubModules(params, {
3972
3625
  cover: cover
3973
3626
  });
3974
3627
  case 5:
3975
3628
  case "end":
3976
- return _context47.stop();
3629
+ return _context43.stop();
3977
3630
  }
3978
- }, _callee47, this);
3631
+ }, _callee43, this);
3979
3632
  }));
3980
- function setOtherParams(_x39) {
3633
+ function setOtherParams(_x36) {
3981
3634
  return _setOtherParams.apply(this, arguments);
3982
3635
  }
3983
3636
  return setOtherParams;