@pisell/pisellos 2.2.163 → 2.2.165

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 (124) hide show
  1. package/dist/modules/BookingContext/index.d.ts +37 -0
  2. package/dist/modules/BookingContext/index.js +436 -0
  3. package/dist/modules/BookingContext/types.d.ts +102 -0
  4. package/dist/modules/BookingContext/types.js +51 -0
  5. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  6. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +157 -0
  7. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  8. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
  9. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
  10. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +191 -0
  11. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  12. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  13. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  14. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  15. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  16. package/dist/modules/BookingContext/utils/index.js +11 -0
  17. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  18. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  19. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  20. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  21. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  22. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  23. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  24. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  25. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  26. package/dist/modules/BookingContext/utils/resources.js +486 -0
  27. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  28. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  29. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  30. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  31. package/dist/modules/Customer/index.js +23 -22
  32. package/dist/modules/Discount/index.js +4 -3
  33. package/dist/modules/Order/index.d.ts +25 -7
  34. package/dist/modules/Order/index.js +608 -291
  35. package/dist/modules/Order/types.d.ts +46 -14
  36. package/dist/modules/Order/types.js +2 -0
  37. package/dist/modules/Order/utils.d.ts +10 -0
  38. package/dist/modules/Order/utils.js +76 -23
  39. package/dist/modules/SalesSummary/index.js +4 -2
  40. package/dist/modules/index.d.ts +1 -0
  41. package/dist/modules/index.js +2 -1
  42. package/dist/solution/BaseSales/index.d.ts +46 -7
  43. package/dist/solution/BaseSales/index.js +928 -312
  44. package/dist/solution/BaseSales/types.d.ts +51 -1
  45. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  46. package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
  47. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
  48. package/dist/solution/BaseSales/utils.js +36 -7
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingTicket/index.d.ts +124 -1
  51. package/dist/solution/BookingTicket/index.js +488 -90
  52. package/dist/solution/BookingTicket/types.d.ts +2 -0
  53. package/dist/solution/BookingTicket/types.js +3 -0
  54. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  55. package/dist/solution/BookingTicket/utils/addProductDecision.js +334 -0
  56. package/dist/solution/ScanOrder/index.d.ts +9 -3
  57. package/dist/solution/ScanOrder/index.js +231 -128
  58. package/dist/solution/ScanOrder/utils.js +36 -7
  59. package/dist/solution/VenueBooking/index.d.ts +4 -2
  60. package/dist/solution/VenueBooking/index.js +103 -55
  61. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  62. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
  63. package/lib/modules/BookingContext/index.d.ts +37 -0
  64. package/lib/modules/BookingContext/index.js +297 -0
  65. package/lib/modules/BookingContext/types.d.ts +102 -0
  66. package/lib/modules/BookingContext/types.js +34 -0
  67. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  68. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +174 -0
  69. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  70. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
  71. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
  72. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +177 -0
  73. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  74. package/lib/modules/BookingContext/utils/flexible.js +80 -0
  75. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  76. package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
  77. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  78. package/lib/modules/BookingContext/utils/index.js +43 -0
  79. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  80. package/lib/modules/BookingContext/utils/noResource.js +90 -0
  81. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  82. package/lib/modules/BookingContext/utils/productExtend.js +283 -0
  83. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  84. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  85. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  86. package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
  87. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  88. package/lib/modules/BookingContext/utils/resources.js +377 -0
  89. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  90. package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
  91. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  92. package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
  93. package/lib/modules/Customer/index.js +8 -8
  94. package/lib/modules/Discount/index.js +5 -1
  95. package/lib/modules/Order/index.d.ts +25 -7
  96. package/lib/modules/Order/index.js +268 -72
  97. package/lib/modules/Order/types.d.ts +46 -14
  98. package/lib/modules/Order/utils.d.ts +10 -0
  99. package/lib/modules/Order/utils.js +66 -15
  100. package/lib/modules/SalesSummary/index.js +4 -2
  101. package/lib/modules/index.d.ts +1 -0
  102. package/lib/modules/index.js +3 -1
  103. package/lib/solution/BaseSales/index.d.ts +46 -7
  104. package/lib/solution/BaseSales/index.js +369 -17
  105. package/lib/solution/BaseSales/types.d.ts +51 -1
  106. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
  107. package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
  108. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
  109. package/lib/solution/BaseSales/utils.js +37 -5
  110. package/lib/solution/BookingByStep/index.d.ts +1 -1
  111. package/lib/solution/BookingTicket/index.d.ts +124 -1
  112. package/lib/solution/BookingTicket/index.js +255 -8
  113. package/lib/solution/BookingTicket/types.d.ts +2 -0
  114. package/lib/solution/BookingTicket/types.js +6 -0
  115. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
  116. package/lib/solution/BookingTicket/utils/addProductDecision.js +308 -0
  117. package/lib/solution/ScanOrder/index.d.ts +9 -3
  118. package/lib/solution/ScanOrder/index.js +147 -66
  119. package/lib/solution/ScanOrder/utils.js +37 -5
  120. package/lib/solution/VenueBooking/index.d.ts +4 -2
  121. package/lib/solution/VenueBooking/index.js +50 -14
  122. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
  123. package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
  124. package/package.json +1 -1
@@ -1,10 +1,14 @@
1
1
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ 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."); }
2
4
  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); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
3
7
  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; }
4
8
  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); }
5
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
6
9
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
+ 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; }
8
12
  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); } }
9
13
  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); }); }; }
10
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -29,7 +33,9 @@ import { createModule } from "../BookingByStep/types";
29
33
  import { composeLinePrice, sumOptionUnitPrice } from "../../modules/Order/utils";
30
34
  import dayjs from 'dayjs';
31
35
  export * from "./types";
36
+ import { QuotationModule } from "../../modules/Quotation";
32
37
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
38
+ import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
33
39
  export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
34
40
  _inherits(BaseSalesImpl, _BaseModule);
35
41
  var _super = _createSuper(BaseSalesImpl);
@@ -43,6 +49,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
43
49
  _defineProperty(_assertThisInitialized(_this), "initializeOptions", {});
44
50
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
45
51
  // LoggerManager 实例
52
+ _defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
46
53
  _defineProperty(_assertThisInitialized(_this), "store", {
47
54
  order: undefined
48
55
  });
@@ -61,12 +68,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
61
68
 
62
69
  /**
63
70
  * 子类可覆盖此方法以追加/收敛要注册的子模块。
64
- * 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
71
+ * 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation
65
72
  */
66
73
  _createClass(BaseSalesImpl, [{
67
74
  key: "getRegisteredModuleNames",
68
75
  value: function getRegisteredModuleNames() {
69
- return ['products', 'order', 'salesSummary', 'schedule', 'payment'];
76
+ return ['products', 'order', 'salesSummary', 'schedule', 'payment', 'quotation'];
70
77
  }
71
78
 
72
79
  /**
@@ -121,6 +128,63 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
121
128
  get: function get() {
122
129
  return this.store.payment;
123
130
  }
131
+ }, {
132
+ key: "getCurrentOrderCustomerId",
133
+ value: function getCurrentOrderCustomerId() {
134
+ var _this$store$order, _this$store$order$get;
135
+ var tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
136
+ var customerId = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
137
+ if (customerId === null || customerId === undefined) return undefined;
138
+ return customerId;
139
+ }
140
+ }, {
141
+ key: "applyQuotationScheduleResolver",
142
+ value: function applyQuotationScheduleResolver(quotation) {
143
+ var scheduleModule = this.store.schedule;
144
+ if (!scheduleModule) return;
145
+ quotation.setScheduleResolver(function (id) {
146
+ var _scheduleModule$getSc;
147
+ var schedules = ((_scheduleModule$getSc = scheduleModule.getScheduleListByIds) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule, [id])) || [];
148
+ return schedules[0];
149
+ });
150
+ }
151
+ }, {
152
+ key: "loadQuotationForPriceQuery",
153
+ value: function () {
154
+ var _loadQuotationForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
155
+ var _this$otherParams;
156
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
157
+ while (1) switch (_context.prev = _context.next) {
158
+ case 0:
159
+ if (params.quotation) {
160
+ _context.next = 2;
161
+ break;
162
+ }
163
+ return _context.abrupt("return");
164
+ case 2:
165
+ this.applyQuotationScheduleResolver(params.quotation);
166
+ _context.next = 5;
167
+ return params.quotation.loadQuotations({
168
+ channel: params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel),
169
+ customer_id: params.customer_id
170
+ });
171
+ case 5:
172
+ case "end":
173
+ return _context.stop();
174
+ }
175
+ }, _callee, this);
176
+ }));
177
+ function loadQuotationForPriceQuery(_x) {
178
+ return _loadQuotationForPriceQuery.apply(this, arguments);
179
+ }
180
+ return loadQuotationForPriceQuery;
181
+ }()
182
+ }, {
183
+ key: "getSubmitOrderSalesChannel",
184
+ value: function getSubmitOrderSalesChannel() {
185
+ var _this$otherParams2;
186
+ return (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel;
187
+ }
124
188
 
125
189
  /**
126
190
  * 工厂入口:根据子模块名实例化对应模块。
@@ -130,6 +194,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
130
194
  }, {
131
195
  key: "createSubModule",
132
196
  value: function createSubModule(moduleName) {
197
+ if (moduleName === 'quotation') {
198
+ return new QuotationModule("".concat(this.name, "_quotation"));
199
+ }
133
200
  return createModule(moduleName, this.name);
134
201
  }
135
202
  }, {
@@ -163,39 +230,78 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
163
230
  return {};
164
231
  }
165
232
  }
233
+ }, {
234
+ key: "getAppData",
235
+ value: function getAppData(key) {
236
+ var _this$appPlugin$getDa, _this$appPlugin, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
237
+ var getData = (_this$appPlugin$getDa = (_this$appPlugin = this.appPlugin).getData) === null || _this$appPlugin$getDa === void 0 ? void 0 : _this$appPlugin$getDa.call(_this$appPlugin);
238
+ if (typeof getData === 'function') return getData(key);
239
+ var app = this.appPlugin.getApp();
240
+ var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
241
+ return coreData === null || coreData === void 0 ? void 0 : coreData[key];
242
+ }
243
+ }, {
244
+ key: "syncAppDataToTempOrder",
245
+ value: function syncAppDataToTempOrder(tempOrder) {
246
+ var taxCountryCode = this.getAppData('tax_country_code');
247
+ var currencyCode = this.getAppData('shop_currency_code');
248
+ var currencySymbol = this.getAppData('shop_symbol');
249
+ var isChanged = false;
250
+ if (taxCountryCode !== undefined) {
251
+ var nextTaxCountryCode = String(taxCountryCode || '');
252
+ if (tempOrder.tax_country_code !== nextTaxCountryCode) {
253
+ tempOrder.tax_country_code = nextTaxCountryCode;
254
+ isChanged = true;
255
+ }
256
+ }
257
+ if (currencyCode !== undefined) {
258
+ var nextCurrencyCode = String(currencyCode || '');
259
+ if (tempOrder.currency_code !== nextCurrencyCode) {
260
+ tempOrder.currency_code = nextCurrencyCode;
261
+ isChanged = true;
262
+ }
263
+ }
264
+ if (currencySymbol !== undefined) {
265
+ var nextCurrencySymbol = String(currencySymbol || '');
266
+ if (tempOrder.currency_symbol !== nextCurrencySymbol) {
267
+ tempOrder.currency_symbol = nextCurrencySymbol;
268
+ isChanged = true;
269
+ }
270
+ }
271
+ return isChanged;
272
+ }
166
273
  }, {
167
274
  key: "initialize",
168
275
  value: function () {
169
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
170
- var _this$otherParams,
276
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(core) {
277
+ var _this$otherParams3,
171
278
  _this2 = this;
172
279
  var options,
173
- appPlugin,
174
280
  app,
175
281
  targetCacheData,
176
282
  moduleNames,
177
- _args = arguments;
178
- return _regeneratorRuntime().wrap(function _callee$(_context) {
179
- while (1) switch (_context.prev = _context.next) {
283
+ _args2 = arguments;
284
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
285
+ while (1) switch (_context2.prev = _context2.next) {
180
286
  case 0:
181
- options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
287
+ options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
182
288
  this.core = core;
183
289
  this.initializeOptions = options || {};
184
290
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
185
291
  this.otherParams = options.otherParams || {};
186
- this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
292
+ this.cacheId = (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.cacheId;
187
293
  this.window = core.getPlugin('window');
188
294
  this.request = core.getPlugin('request');
189
295
 
190
296
  // 获取 logger 实例
191
- appPlugin = core.getPlugin('app');
192
- if (appPlugin) {
193
- _context.next = 10;
297
+ this.appPlugin = core.getPlugin('app');
298
+ if (this.appPlugin) {
299
+ _context2.next = 10;
194
300
  break;
195
301
  }
196
302
  throw new Error('Checkout 解决方案需要 app 插件支持');
197
303
  case 10:
198
- app = appPlugin.getApp();
304
+ app = this.appPlugin.getApp();
199
305
  this.logger = app.logger;
200
306
  targetCacheData = this.readSessionCacheData();
201
307
  moduleNames = this.getRegisteredModuleNames();
@@ -220,20 +326,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
220
326
  }));
221
327
  });
222
328
  if (!this.store.schedule) {
223
- _context.next = 18;
329
+ _context2.next = 18;
224
330
  break;
225
331
  }
226
- _context.next = 18;
332
+ _context2.next = 18;
227
333
  return this.store.schedule.loadAllSchedule();
228
334
  case 18:
229
335
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
230
336
  case 19:
231
337
  case "end":
232
- return _context.stop();
338
+ return _context2.stop();
233
339
  }
234
- }, _callee, this);
340
+ }, _callee2, this);
235
341
  }));
236
- function initialize(_x) {
342
+ function initialize(_x2) {
237
343
  return _initialize.apply(this, arguments);
238
344
  }
239
345
  return initialize;
@@ -241,10 +347,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
241
347
  }, {
242
348
  key: "destroy",
243
349
  value: function () {
244
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
350
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
245
351
  var _this3 = this;
246
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
247
- while (1) switch (_context2.prev = _context2.next) {
352
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
353
+ while (1) switch (_context3.prev = _context3.next) {
248
354
  case 0:
249
355
  Object.keys(this.store).forEach(function (key) {
250
356
  var sub = _this3.store[key];
@@ -257,15 +363,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
257
363
  }
258
364
  });
259
365
  this.currentSalesDetail = null;
260
- _context2.next = 4;
366
+ _context3.next = 4;
261
367
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
262
368
  case 4:
263
369
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
264
370
  case 5:
265
371
  case "end":
266
- return _context2.stop();
372
+ return _context3.stop();
267
373
  }
268
- }, _callee2, this);
374
+ }, _callee3, this);
269
375
  }));
270
376
  function destroy() {
271
377
  return _destroy.apply(this, arguments);
@@ -282,13 +388,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
282
388
  }, {
283
389
  key: "loadSalesDetail",
284
390
  value: (function () {
285
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(orderIdOrParams) {
391
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(orderIdOrParams) {
286
392
  var params, externalSaleNumber, localRecord, _sales, res, message, sales;
287
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
288
- while (1) switch (_context3.prev = _context3.next) {
393
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
394
+ while (1) switch (_context4.prev = _context4.next) {
289
395
  case 0:
290
396
  if (this.store.order) {
291
- _context3.next = 2;
397
+ _context4.next = 2;
292
398
  break;
293
399
  }
294
400
  throw new Error('order 模块未初始化');
@@ -298,107 +404,107 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
298
404
  };
299
405
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
300
406
  if (params.forceRemote) {
301
- _context3.next = 35;
407
+ _context4.next = 35;
302
408
  break;
303
409
  }
304
410
  if (!(params.orderId !== undefined)) {
305
- _context3.next = 11;
411
+ _context4.next = 11;
306
412
  break;
307
413
  }
308
- _context3.next = 8;
414
+ _context4.next = 8;
309
415
  return this.store.order.getLocalOrderByOrderId(params.orderId);
310
416
  case 8:
311
- _context3.t0 = _context3.sent;
312
- _context3.next = 26;
417
+ _context4.t0 = _context4.sent;
418
+ _context4.next = 26;
313
419
  break;
314
420
  case 11:
315
421
  if (!externalSaleNumber) {
316
- _context3.next = 17;
422
+ _context4.next = 17;
317
423
  break;
318
424
  }
319
- _context3.next = 14;
425
+ _context4.next = 14;
320
426
  return this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber);
321
427
  case 14:
322
- _context3.t1 = _context3.sent;
323
- _context3.next = 25;
428
+ _context4.t1 = _context4.sent;
429
+ _context4.next = 25;
324
430
  break;
325
431
  case 17:
326
432
  if (!params.orderNumber) {
327
- _context3.next = 23;
433
+ _context4.next = 23;
328
434
  break;
329
435
  }
330
- _context3.next = 20;
436
+ _context4.next = 20;
331
437
  return this.store.order.getLocalOrderByOrderNumber(params.orderNumber);
332
438
  case 20:
333
- _context3.t2 = _context3.sent;
334
- _context3.next = 24;
439
+ _context4.t2 = _context4.sent;
440
+ _context4.next = 24;
335
441
  break;
336
442
  case 23:
337
- _context3.t2 = null;
443
+ _context4.t2 = null;
338
444
  case 24:
339
- _context3.t1 = _context3.t2;
445
+ _context4.t1 = _context4.t2;
340
446
  case 25:
341
- _context3.t0 = _context3.t1;
447
+ _context4.t0 = _context4.t1;
342
448
  case 26:
343
- localRecord = _context3.t0;
449
+ localRecord = _context4.t0;
344
450
  if (!localRecord) {
345
- _context3.next = 35;
451
+ _context4.next = 35;
346
452
  break;
347
453
  }
348
- _context3.next = 30;
454
+ _context4.next = 30;
349
455
  return this.store.order.hydrateTempOrderFromRecord(localRecord, {
350
456
  recalcOnHydrate: false
351
457
  });
352
458
  case 30:
353
- _sales = _context3.sent;
459
+ _sales = _context4.sent;
354
460
  this.currentSalesDetail = _sales;
355
- _context3.next = 34;
461
+ _context4.next = 34;
356
462
  return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
357
463
  sales: _sales
358
464
  });
359
465
  case 34:
360
- return _context3.abrupt("return", _sales);
466
+ return _context4.abrupt("return", _sales);
361
467
  case 35:
362
468
  if (!(params.orderId === undefined || params.orderId === null)) {
363
- _context3.next = 37;
469
+ _context4.next = 37;
364
470
  break;
365
471
  }
366
472
  throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
367
473
  case 37:
368
- _context3.next = 39;
474
+ _context4.next = 39;
369
475
  return this.store.order.getOrderInfoByRemote(Number(params.orderId));
370
476
  case 39:
371
- res = _context3.sent;
477
+ res = _context4.sent;
372
478
  if (!(!res || res.code !== 200)) {
373
- _context3.next = 43;
479
+ _context4.next = 43;
374
480
  break;
375
481
  }
376
482
  message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(params.orderId);
377
483
  throw new Error(message);
378
484
  case 43:
379
- _context3.next = 45;
485
+ _context4.next = 45;
380
486
  return this.store.order.hydrateTempOrderFromRecord(res.data, {
381
487
  recalcOnHydrate: false
382
488
  });
383
489
  case 45:
384
- sales = _context3.sent;
385
- _context3.next = 48;
490
+ sales = _context4.sent;
491
+ _context4.next = 48;
386
492
  return this.store.order.saveDraft();
387
493
  case 48:
388
494
  this.currentSalesDetail = sales;
389
- _context3.next = 51;
495
+ _context4.next = 51;
390
496
  return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
391
497
  sales: sales
392
498
  });
393
499
  case 51:
394
- return _context3.abrupt("return", sales);
500
+ return _context4.abrupt("return", sales);
395
501
  case 52:
396
502
  case "end":
397
- return _context3.stop();
503
+ return _context4.stop();
398
504
  }
399
- }, _callee3, this);
505
+ }, _callee4, this);
400
506
  }));
401
- function loadSalesDetail(_x2) {
507
+ function loadSalesDetail(_x3) {
402
508
  return _loadSalesDetail.apply(this, arguments);
403
509
  }
404
510
  return loadSalesDetail;
@@ -471,10 +577,45 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
471
577
  }, {
472
578
  key: "getTempOrder",
473
579
  value: function getTempOrder() {
474
- var _this$store$order;
475
- var result = ((_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.getTempOrder()) || null;
580
+ var _this$store$order2;
581
+ var result = ((_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.getTempOrder()) || null;
476
582
  return result;
477
583
  }
584
+ }, {
585
+ key: "replaceTempOrder",
586
+ value: function () {
587
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
588
+ var nextTempOrder;
589
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
590
+ while (1) switch (_context5.prev = _context5.next) {
591
+ case 0:
592
+ if (this.store.order) {
593
+ _context5.next = 2;
594
+ break;
595
+ }
596
+ throw new Error('order 模块未初始化');
597
+ case 2:
598
+ _context5.next = 4;
599
+ return this.store.order.replaceTempOrder(tempOrder);
600
+ case 4:
601
+ nextTempOrder = _context5.sent;
602
+ _context5.next = 7;
603
+ return this.effectsEmit('onTempOrderReplaced', {
604
+ tempOrder: nextTempOrder
605
+ });
606
+ case 7:
607
+ return _context5.abrupt("return", nextTempOrder);
608
+ case 8:
609
+ case "end":
610
+ return _context5.stop();
611
+ }
612
+ }, _callee5, this);
613
+ }));
614
+ function replaceTempOrder(_x4) {
615
+ return _replaceTempOrder.apply(this, arguments);
616
+ }
617
+ return replaceTempOrder;
618
+ }()
478
619
  }, {
479
620
  key: "getOrderIdentity",
480
621
  value: function getOrderIdentity() {
@@ -508,14 +649,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
508
649
  }, {
509
650
  key: "updateTempOrderNote",
510
651
  value: function updateTempOrderNote(note) {
652
+ var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
511
653
  try {
512
654
  if (!this.store.order) throw new Error('order 模块未初始化');
513
- var result = this.store.order.updateTempOrderNote(note);
655
+ var result = this.store.order.updateTempOrderNote(note, sync);
514
656
  return result;
515
657
  } catch (error) {
516
658
  throw error;
517
659
  }
518
660
  }
661
+ }, {
662
+ key: "updateRemoteOrderNote",
663
+ value: function updateRemoteOrderNote(orderId, note) {
664
+ if (!this.store.order) throw new Error('order 模块未初始化');
665
+ this.store.order.syncTempOrderNoteToRemote(orderId, note);
666
+ }
519
667
  }, {
520
668
  key: "updateTempOrderShopDiscount",
521
669
  value: function updateTempOrderShopDiscount(amount) {
@@ -539,32 +687,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
539
687
  }, {
540
688
  key: "addNewOrder",
541
689
  value: function () {
542
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
690
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
543
691
  var tempOrder;
544
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
545
- while (1) switch (_context4.prev = _context4.next) {
692
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
693
+ while (1) switch (_context6.prev = _context6.next) {
546
694
  case 0:
547
- _context4.prev = 0;
695
+ _context6.prev = 0;
548
696
  if (this.store.order) {
549
- _context4.next = 3;
697
+ _context6.next = 3;
550
698
  break;
551
699
  }
552
700
  throw new Error('order 模块未初始化');
553
701
  case 3:
554
- _context4.next = 5;
702
+ _context6.next = 5;
555
703
  return this.store.order.addNewOrder();
556
704
  case 5:
557
- tempOrder = _context4.sent;
558
- return _context4.abrupt("return", tempOrder);
559
- case 9:
560
- _context4.prev = 9;
561
- _context4.t0 = _context4["catch"](0);
562
- throw _context4.t0;
563
- case 12:
705
+ tempOrder = _context6.sent;
706
+ if (!this.syncAppDataToTempOrder(tempOrder)) {
707
+ _context6.next = 10;
708
+ break;
709
+ }
710
+ this.store.order.persistTempOrder();
711
+ _context6.next = 10;
712
+ return this.store.order.saveDraft();
713
+ case 10:
714
+ return _context6.abrupt("return", tempOrder);
715
+ case 13:
716
+ _context6.prev = 13;
717
+ _context6.t0 = _context6["catch"](0);
718
+ throw _context6.t0;
719
+ case 16:
564
720
  case "end":
565
- return _context4.stop();
721
+ return _context6.stop();
566
722
  }
567
- }, _callee4, this, [[0, 9]]);
723
+ }, _callee6, this, [[0, 13]]);
568
724
  }));
569
725
  function addNewOrder() {
570
726
  return _addNewOrder.apply(this, arguments);
@@ -574,22 +730,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
574
730
  }, {
575
731
  key: "saveDraft",
576
732
  value: function () {
577
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
578
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
579
- while (1) switch (_context5.prev = _context5.next) {
733
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
734
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
735
+ while (1) switch (_context7.prev = _context7.next) {
580
736
  case 0:
581
737
  if (this.store.order) {
582
- _context5.next = 2;
738
+ _context7.next = 2;
583
739
  break;
584
740
  }
585
741
  throw new Error('order 模块未初始化');
586
742
  case 2:
587
- return _context5.abrupt("return", this.store.order.saveDraft());
743
+ return _context7.abrupt("return", this.store.order.saveDraft());
588
744
  case 3:
589
745
  case "end":
590
- return _context5.stop();
746
+ return _context7.stop();
591
747
  }
592
- }, _callee5, this);
748
+ }, _callee7, this);
593
749
  }));
594
750
  function saveDraft() {
595
751
  return _saveDraft.apply(this, arguments);
@@ -600,36 +756,111 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
600
756
  }, {
601
757
  key: "restoreOrder",
602
758
  value: function () {
603
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
759
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
604
760
  var tempOrder;
605
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
606
- while (1) switch (_context6.prev = _context6.next) {
761
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
762
+ while (1) switch (_context8.prev = _context8.next) {
607
763
  case 0:
608
- _context6.prev = 0;
764
+ _context8.prev = 0;
609
765
  if (this.store.order) {
610
- _context6.next = 3;
766
+ _context8.next = 3;
611
767
  break;
612
768
  }
613
769
  throw new Error('scanOrder 解决方案需要 order 模块支持');
614
770
  case 3:
615
771
  // this.store.resource = null;
616
772
  tempOrder = this.store.order.restoreOrder();
617
- return _context6.abrupt("return", tempOrder);
773
+ this.currentSalesDetail = null;
774
+ _context8.next = 7;
775
+ return this.effectsEmit('onTempOrderReplaced', {
776
+ tempOrder: tempOrder
777
+ });
618
778
  case 7:
619
- _context6.prev = 7;
620
- _context6.t0 = _context6["catch"](0);
621
- throw _context6.t0;
622
- case 10:
779
+ if (!this.syncAppDataToTempOrder(tempOrder)) {
780
+ _context8.next = 11;
781
+ break;
782
+ }
783
+ this.store.order.persistTempOrder();
784
+ _context8.next = 11;
785
+ return this.store.order.saveDraft();
786
+ case 11:
787
+ return _context8.abrupt("return", tempOrder);
788
+ case 14:
789
+ _context8.prev = 14;
790
+ _context8.t0 = _context8["catch"](0);
791
+ throw _context8.t0;
792
+ case 17:
623
793
  case "end":
624
- return _context6.stop();
794
+ return _context8.stop();
625
795
  }
626
- }, _callee6, this, [[0, 7]]);
796
+ }, _callee8, this, [[0, 14]]);
627
797
  }));
628
798
  function restoreOrder() {
629
799
  return _restoreOrder.apply(this, arguments);
630
800
  }
631
801
  return restoreOrder;
632
802
  }()
803
+ /**
804
+ * 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
805
+ * 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
806
+ */
807
+ }, {
808
+ key: "clearOrderCartLines",
809
+ value: (function () {
810
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
811
+ var tempOrder;
812
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
813
+ while (1) switch (_context9.prev = _context9.next) {
814
+ case 0:
815
+ _context9.prev = 0;
816
+ if (this.store.order) {
817
+ _context9.next = 3;
818
+ break;
819
+ }
820
+ throw new Error('order 模块未初始化');
821
+ case 3:
822
+ _context9.next = 5;
823
+ return this.store.order.clearOrderCartLines();
824
+ case 5:
825
+ tempOrder = _context9.sent;
826
+ if (this.currentSalesDetail) {
827
+ this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
828
+ products: [],
829
+ bookings: [],
830
+ rootBooking: null,
831
+ bookingsByProductUid: {},
832
+ discount_list: []
833
+ });
834
+ }
835
+ _context9.next = 9;
836
+ return this.effectsEmit('onTempOrderReplaced', {
837
+ tempOrder: tempOrder
838
+ });
839
+ case 9:
840
+ if (!this.syncAppDataToTempOrder(tempOrder)) {
841
+ _context9.next = 13;
842
+ break;
843
+ }
844
+ this.store.order.persistTempOrder();
845
+ _context9.next = 13;
846
+ return this.store.order.saveDraft();
847
+ case 13:
848
+ return _context9.abrupt("return", tempOrder);
849
+ case 16:
850
+ _context9.prev = 16;
851
+ _context9.t0 = _context9["catch"](0);
852
+ throw _context9.t0;
853
+ case 19:
854
+ case "end":
855
+ return _context9.stop();
856
+ }
857
+ }, _callee9, this, [[0, 16]]);
858
+ }));
859
+ function clearOrderCartLines() {
860
+ return _clearOrderCartLines.apply(this, arguments);
861
+ }
862
+ return clearOrderCartLines;
863
+ }())
633
864
  }, {
634
865
  key: "getOrderProducts",
635
866
  value: function getOrderProducts() {
@@ -640,38 +871,272 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
640
871
  }, {
641
872
  key: "getSummary",
642
873
  value: function () {
643
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
874
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
644
875
  var summary;
645
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
646
- while (1) switch (_context7.prev = _context7.next) {
876
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
877
+ while (1) switch (_context10.prev = _context10.next) {
647
878
  case 0:
648
- _context7.prev = 0;
879
+ _context10.prev = 0;
649
880
  if (this.store.order) {
650
- _context7.next = 3;
881
+ _context10.next = 3;
651
882
  break;
652
883
  }
653
884
  throw new Error('order 模块未初始化');
654
885
  case 3:
655
- _context7.next = 5;
886
+ _context10.next = 5;
656
887
  return this.store.order.getOrderSummary();
657
888
  case 5:
658
- summary = _context7.sent;
659
- return _context7.abrupt("return", summary);
889
+ summary = _context10.sent;
890
+ return _context10.abrupt("return", summary);
660
891
  case 9:
661
- _context7.prev = 9;
662
- _context7.t0 = _context7["catch"](0);
663
- throw _context7.t0;
892
+ _context10.prev = 9;
893
+ _context10.t0 = _context10["catch"](0);
894
+ throw _context10.t0;
664
895
  case 12:
665
896
  case "end":
666
- return _context7.stop();
897
+ return _context10.stop();
667
898
  }
668
- }, _callee7, this, [[0, 9]]);
899
+ }, _callee10, this, [[0, 9]]);
669
900
  }));
670
901
  function getSummary() {
671
902
  return _getSummary.apply(this, arguments);
672
903
  }
673
904
  return getSummary;
674
905
  }()
906
+ }, {
907
+ key: "getHistoricalProductDiscountList",
908
+ value: function getHistoricalProductDiscountList(products) {
909
+ var _this4 = this;
910
+ var historyDiscountList = [];
911
+ products.forEach(function (item) {
912
+ if (!_this4.isPersistedOrderProduct(item)) return;
913
+ (item.discount_list || []).forEach(function (discount) {
914
+ var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
915
+ var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
916
+ if (!discountId || !['good_pass', 'discount_card'].includes(discount.type)) return;
917
+ var quantity = item.quantity || item.num || item.product_quantity || 1;
918
+ var savedAmount = new Decimal(discount.amount || 0).times(quantity).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
919
+ var index = historyDiscountList.findIndex(function (n) {
920
+ return n.id === discountId;
921
+ });
922
+ if (index !== -1) {
923
+ historyDiscountList[index] = _objectSpread(_objectSpread({}, historyDiscountList[index]), {}, {
924
+ amount: new Decimal(historyDiscountList[index].amount || 0).plus(discount.amount || 0).toNumber(),
925
+ savedAmount: savedAmount.plus(historyDiscountList[index].savedAmount || 0).toNumber()
926
+ });
927
+ return;
928
+ }
929
+ historyDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
930
+ id: discountId,
931
+ tag: discount.tag || discount.type,
932
+ name: discount.name || ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 || (_discount$discount2 = _discount$discount2.title) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.auto),
933
+ format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
934
+ isEditMode: true,
935
+ limited_relation_product_data: {},
936
+ savedAmount: savedAmount.toNumber(),
937
+ isAvailable: true,
938
+ isDisabled: true,
939
+ isSelected: true,
940
+ product_id: ((_discount$discount4 = discount.discount) === null || _discount$discount4 === void 0 ? void 0 : _discount$discount4.product_id) || discount.product_id
941
+ }));
942
+ });
943
+ });
944
+ return historyDiscountList;
945
+ }
946
+ }, {
947
+ key: "isPersistedOrderProduct",
948
+ value: function isPersistedOrderProduct(product) {
949
+ var _product$order_detail, _product$booking_id;
950
+ var orderDetailId = (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : product.orderDetailId;
951
+ if (orderDetailId !== undefined && orderDetailId !== null && orderDetailId !== '') {
952
+ return true;
953
+ }
954
+ var bookingId = (_product$booking_id = product.booking_id) !== null && _product$booking_id !== void 0 ? _product$booking_id : product.bookingId;
955
+ return bookingId !== undefined && bookingId !== null && bookingId !== '';
956
+ }
957
+ }, {
958
+ key: "mergeHistoricalDiscountList",
959
+ value: function mergeHistoricalDiscountList(discountList, products) {
960
+ var historyDiscountList = this.getHistoricalProductDiscountList(products);
961
+ var historyIds = new Set(historyDiscountList.map(function (discount) {
962
+ return discount.id;
963
+ }));
964
+ return [].concat(_toConsumableArray(historyDiscountList), _toConsumableArray((discountList || []).filter(function (discount) {
965
+ return !historyIds.has(discount.id);
966
+ })));
967
+ }
968
+ }, {
969
+ key: "loadDiscountConfig",
970
+ value: function () {
971
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
972
+ var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi;
973
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, preparedDiscountList, _discountModule$setOr, nextDiscountList, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result;
974
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
975
+ while (1) switch (_context11.prev = _context11.next) {
976
+ case 0:
977
+ if (this.store.order) {
978
+ _context11.next = 2;
979
+ break;
980
+ }
981
+ throw new Error('order 模块未初始化');
982
+ case 2:
983
+ tempOrder = this.store.order.ensureTempOrder();
984
+ orderStore = this.store.order.store || {};
985
+ discountModule = orderStore.discount;
986
+ rulesModule = orderStore.rules;
987
+ orderId = tempOrder.order_id || ((_this$getOrderIdentit = this.getOrderIdentity) === null || _this$getOrderIdentit === void 0 || (_this$getOrderIdentit = _this$getOrderIdentit.call(this)) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.orderId);
988
+ customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
989
+ preparedDiscountList = [];
990
+ if (!(customerId && customerId !== 1)) {
991
+ _context11.next = 15;
992
+ break;
993
+ }
994
+ _context11.next = 12;
995
+ return this.store.order.loadDiscountConfig({
996
+ customerId: customerId,
997
+ action: (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create'),
998
+ orderId: Number(orderId) || undefined,
999
+ apply: false
1000
+ });
1001
+ case 12:
1002
+ preparedDiscountList = _context11.sent;
1003
+ _context11.next = 15;
1004
+ return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
1005
+ case 15:
1006
+ nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [], tempOrder.products || []);
1007
+ _context11.next = 18;
1008
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1009
+ case 18:
1010
+ if (!rulesModule) {
1011
+ _context11.next = 28;
1012
+ break;
1013
+ }
1014
+ holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
1015
+ form_record_id: tempOrder.holder.form_record_id
1016
+ }] : [];
1017
+ result = rulesModule.calcDiscount({
1018
+ productList: tempOrder.products,
1019
+ discountList: nextDiscountList,
1020
+ holders: holders,
1021
+ isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form',
1022
+ orderTotalAmount: Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0)
1023
+ }) || {
1024
+ productList: tempOrder.products,
1025
+ discountList: nextDiscountList
1026
+ };
1027
+ if (result.productList) {
1028
+ tempOrder.products = result.productList;
1029
+ }
1030
+ if (!result.discountList) {
1031
+ _context11.next = 28;
1032
+ break;
1033
+ }
1034
+ nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1035
+ OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1036
+ _context11.next = 27;
1037
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1038
+ case 27:
1039
+ tempOrder.discount_list = nextDiscountList.filter(function (discount) {
1040
+ return discount.isSelected;
1041
+ });
1042
+ case 28:
1043
+ this.store.order.persistTempOrder();
1044
+ return _context11.abrupt("return", {
1045
+ productList: tempOrder.products || [],
1046
+ discountList: nextDiscountList
1047
+ });
1048
+ case 30:
1049
+ case "end":
1050
+ return _context11.stop();
1051
+ }
1052
+ }, _callee11, this);
1053
+ }));
1054
+ function loadDiscountConfig(_x5) {
1055
+ return _loadDiscountConfig.apply(this, arguments);
1056
+ }
1057
+ return loadDiscountConfig;
1058
+ }()
1059
+ }, {
1060
+ key: "bestDiscount",
1061
+ value: function () {
1062
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(cb) {
1063
+ var _discountModule$getOr;
1064
+ var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, nextDiscountList, result, _tempOrder$holder3, _tempOrder$holder4, _orderStore$summary2, holders;
1065
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1066
+ while (1) switch (_context12.prev = _context12.next) {
1067
+ case 0:
1068
+ if (this.store.order) {
1069
+ _context12.next = 2;
1070
+ break;
1071
+ }
1072
+ throw new Error('order 模块未初始化');
1073
+ case 2:
1074
+ tempOrder = this.store.order.ensureTempOrder();
1075
+ orderStore = this.store.order.store || {};
1076
+ discountModule = orderStore.discount;
1077
+ rulesModule = orderStore.rules;
1078
+ originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || this.getDiscountList();
1079
+ nextDiscountList = this.mergeHistoricalDiscountList(originalDiscountList || [], tempOrder.products || []);
1080
+ result = {
1081
+ productList: tempOrder.products || [],
1082
+ discountList: nextDiscountList
1083
+ };
1084
+ _context12.next = 11;
1085
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1086
+ case 11:
1087
+ if (!rulesModule) {
1088
+ _context12.next = 22;
1089
+ break;
1090
+ }
1091
+ holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
1092
+ form_record_id: tempOrder.holder.form_record_id
1093
+ }] : [];
1094
+ result = rulesModule.calcDiscount({
1095
+ productList: tempOrder.products,
1096
+ discountList: nextDiscountList,
1097
+ holders: holders,
1098
+ isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form',
1099
+ orderTotalAmount: Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0)
1100
+ }) || result;
1101
+ if (result.productList) {
1102
+ tempOrder.products = result.productList;
1103
+ }
1104
+ if (!result.discountList) {
1105
+ _context12.next = 22;
1106
+ break;
1107
+ }
1108
+ nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
1109
+ OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1110
+ _context12.next = 20;
1111
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1112
+ case 20:
1113
+ tempOrder.discount_list = nextDiscountList.filter(function (discount) {
1114
+ return discount.isSelected;
1115
+ });
1116
+ result = {
1117
+ productList: tempOrder.products,
1118
+ discountList: nextDiscountList
1119
+ };
1120
+ case 22:
1121
+ _context12.next = 24;
1122
+ return this.store.order.recalculateSummary({
1123
+ createIfMissing: true
1124
+ });
1125
+ case 24:
1126
+ this.store.order.persistTempOrder();
1127
+ cb === null || cb === void 0 || cb(result);
1128
+ return _context12.abrupt("return", result);
1129
+ case 27:
1130
+ case "end":
1131
+ return _context12.stop();
1132
+ }
1133
+ }, _callee12, this);
1134
+ }));
1135
+ function bestDiscount(_x6) {
1136
+ return _bestDiscount.apply(this, arguments);
1137
+ }
1138
+ return bestDiscount;
1139
+ }()
675
1140
  }, {
676
1141
  key: "getDiscountList",
677
1142
  value: function getDiscountList() {
@@ -681,49 +1146,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
681
1146
  }, {
682
1147
  key: "scanPromotionCode",
683
1148
  value: function () {
684
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(code, customerId) {
1149
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(code, customerId) {
685
1150
  var raw;
686
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
687
- while (1) switch (_context8.prev = _context8.next) {
1151
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1152
+ while (1) switch (_context13.prev = _context13.next) {
688
1153
  case 0:
689
- _context8.prev = 0;
1154
+ _context13.prev = 0;
690
1155
  if (this.store.order) {
691
- _context8.next = 3;
1156
+ _context13.next = 3;
692
1157
  break;
693
1158
  }
694
1159
  throw new Error('order 模块未初始化');
695
1160
  case 3:
696
- _context8.next = 5;
1161
+ _context13.next = 5;
697
1162
  return this.store.order.scanCode(code, customerId);
698
1163
  case 5:
699
- raw = _context8.sent;
1164
+ raw = _context13.sent;
700
1165
  if (!raw.isAvailable) {
701
- _context8.next = 10;
1166
+ _context13.next = 10;
702
1167
  break;
703
1168
  }
704
- _context8.next = 9;
1169
+ _context13.next = 9;
705
1170
  return this.store.order.recalculateSummary({
706
1171
  createIfMissing: true
707
1172
  });
708
1173
  case 9:
709
1174
  this.store.order.persistTempOrder();
710
1175
  case 10:
711
- return _context8.abrupt("return", {
1176
+ return _context13.abrupt("return", {
712
1177
  isAvailable: raw.isAvailable,
713
1178
  type: raw.type,
714
1179
  unavailableReason: raw.unavailableReason
715
1180
  });
716
1181
  case 13:
717
- _context8.prev = 13;
718
- _context8.t0 = _context8["catch"](0);
719
- throw _context8.t0;
1182
+ _context13.prev = 13;
1183
+ _context13.t0 = _context13["catch"](0);
1184
+ throw _context13.t0;
720
1185
  case 16:
721
1186
  case "end":
722
- return _context8.stop();
1187
+ return _context13.stop();
723
1188
  }
724
- }, _callee8, this, [[0, 13]]);
1189
+ }, _callee13, this, [[0, 13]]);
725
1190
  }));
726
- function scanPromotionCode(_x3, _x4) {
1191
+ function scanPromotionCode(_x7, _x8) {
727
1192
  return _scanPromotionCode.apply(this, arguments);
728
1193
  }
729
1194
  return scanPromotionCode;
@@ -731,14 +1196,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
731
1196
  }, {
732
1197
  key: "setDiscountSelected",
733
1198
  value: function () {
734
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
735
- var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator, _step, d, selectedResourceIds, _iterator2, _step2, _product$metadata, _tempOrder$_extend, _product$metadata2, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
736
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
737
- while (1) switch (_context9.prev = _context9.next) {
1199
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1200
+ var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator, _step, d, selectedResourceIds, _iterator2, _step2, _product$metadata, _tempOrder$_extend3, _product$metadata2, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
1201
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1202
+ while (1) switch (_context14.prev = _context14.next) {
738
1203
  case 0:
739
- _context9.prev = 0;
1204
+ _context14.prev = 0;
740
1205
  if (this.store.order) {
741
- _context9.next = 3;
1206
+ _context14.next = 3;
742
1207
  break;
743
1208
  }
744
1209
  throw new Error('order 模块未初始化');
@@ -754,11 +1219,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
754
1219
  orderStore = this.store.order.store || {};
755
1220
  discountModule = orderStore.discount;
756
1221
  rulesModule = orderStore.rules;
757
- holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
1222
+ holders = (_tempOrder$holder5 = tempOrder.holder) !== null && _tempOrder$holder5 !== void 0 && _tempOrder$holder5.form_record_id ? [{
758
1223
  form_record_id: tempOrder.holder.form_record_id
759
1224
  }] : [];
760
1225
  nextDiscountList = updated;
761
- _context9.next = 13;
1226
+ _context14.next = 13;
762
1227
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
763
1228
  case 13:
764
1229
  if (rulesModule) {
@@ -766,7 +1231,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
766
1231
  productList: tempOrder.products,
767
1232
  discountList: updated,
768
1233
  holders: holders,
769
- isFormSubject: !!((_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
1234
+ isFormSubject: !!((_tempOrder$holder6 = tempOrder.holder) !== null && _tempOrder$holder6 !== void 0 && _tempOrder$holder6.type) && tempOrder.holder.type === 'form'
770
1235
  }, {
771
1236
  discountId: params.discountId,
772
1237
  isSelected: params.isSelected
@@ -807,21 +1272,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
807
1272
  return d.id;
808
1273
  }));
809
1274
  _iterator2 = _createForOfIteratorHelper(tempOrder.products);
810
- _context9.prev = 16;
1275
+ _context14.prev = 16;
811
1276
  _iterator2.s();
812
1277
  case 18:
813
1278
  if ((_step2 = _iterator2.n()).done) {
814
- _context9.next = 34;
1279
+ _context14.next = 34;
815
1280
  break;
816
1281
  }
817
1282
  product = _step2.value;
818
1283
  productUid = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number;
819
- runtimeOrigin = productUid ? (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.productsByUid) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend[productUid]) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.origin : undefined;
1284
+ 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;
820
1285
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.is_manual_discount)) {
821
- _context9.next = 24;
1286
+ _context14.next = 24;
822
1287
  break;
823
1288
  }
824
- return _context9.abrupt("continue", 32);
1289
+ return _context14.abrupt("continue", 32);
825
1290
  case 24:
826
1291
  product.discount_list = (product.discount_list || []).filter(function (pd) {
827
1292
  var _pd$discount$resource, _pd$discount;
@@ -847,65 +1312,127 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
847
1312
  bundle: product.product_bundle
848
1313
  });
849
1314
  case 32:
850
- _context9.next = 18;
1315
+ _context14.next = 18;
851
1316
  break;
852
1317
  case 34:
853
- _context9.next = 39;
1318
+ _context14.next = 39;
854
1319
  break;
855
1320
  case 36:
856
- _context9.prev = 36;
857
- _context9.t0 = _context9["catch"](16);
858
- _iterator2.e(_context9.t0);
1321
+ _context14.prev = 36;
1322
+ _context14.t0 = _context14["catch"](16);
1323
+ _iterator2.e(_context14.t0);
859
1324
  case 39:
860
- _context9.prev = 39;
1325
+ _context14.prev = 39;
861
1326
  _iterator2.f();
862
- return _context9.finish(39);
1327
+ return _context14.finish(39);
863
1328
  case 42:
864
1329
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
865
- _context9.next = 45;
1330
+ _context14.next = 45;
866
1331
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
867
1332
  case 45:
868
1333
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
869
1334
  return d.isSelected;
870
1335
  });
871
- _context9.next = 48;
1336
+ _context14.next = 48;
872
1337
  return this.store.order.recalculateSummary({
873
1338
  createIfMissing: true
874
1339
  });
875
1340
  case 48:
876
1341
  this.store.order.persistTempOrder();
877
- _context9.next = 54;
1342
+ _context14.next = 54;
878
1343
  break;
879
1344
  case 51:
880
- _context9.prev = 51;
881
- _context9.t1 = _context9["catch"](0);
882
- throw _context9.t1;
1345
+ _context14.prev = 51;
1346
+ _context14.t1 = _context14["catch"](0);
1347
+ throw _context14.t1;
883
1348
  case 54:
884
1349
  case "end":
885
- return _context9.stop();
1350
+ return _context14.stop();
886
1351
  }
887
- }, _callee9, this, [[0, 51], [16, 36, 39, 42]]);
1352
+ }, _callee14, this, [[0, 51], [16, 36, 39, 42]]);
888
1353
  }));
889
- function setDiscountSelected(_x5) {
1354
+ function setDiscountSelected(_x9) {
890
1355
  return _setDiscountSelected.apply(this, arguments);
891
1356
  }
892
1357
  return setDiscountSelected;
893
1358
  }()
1359
+ }, {
1360
+ key: "applyDiscountCalculationResult",
1361
+ value: function () {
1362
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(result) {
1363
+ var tempOrder, orderStore, discountModule;
1364
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1365
+ while (1) switch (_context15.prev = _context15.next) {
1366
+ case 0:
1367
+ _context15.prev = 0;
1368
+ if (this.store.order) {
1369
+ _context15.next = 3;
1370
+ break;
1371
+ }
1372
+ throw new Error('order 模块未初始化');
1373
+ case 3:
1374
+ if (result) {
1375
+ _context15.next = 5;
1376
+ break;
1377
+ }
1378
+ return _context15.abrupt("return");
1379
+ case 5:
1380
+ tempOrder = this.store.order.ensureTempOrder();
1381
+ orderStore = this.store.order.store || {};
1382
+ discountModule = orderStore.discount;
1383
+ if (result.productList) {
1384
+ tempOrder.products = result.productList;
1385
+ }
1386
+ if (!result.discountList) {
1387
+ _context15.next = 14;
1388
+ break;
1389
+ }
1390
+ OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
1391
+ _context15.next = 13;
1392
+ return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
1393
+ case 13:
1394
+ tempOrder.discount_list = result.discountList.filter(function (discount) {
1395
+ return discount.isSelected;
1396
+ });
1397
+ case 14:
1398
+ _context15.next = 16;
1399
+ return this.store.order.recalculateSummary({
1400
+ createIfMissing: true
1401
+ });
1402
+ case 16:
1403
+ this.store.order.persistTempOrder();
1404
+ _context15.next = 22;
1405
+ break;
1406
+ case 19:
1407
+ _context15.prev = 19;
1408
+ _context15.t0 = _context15["catch"](0);
1409
+ throw _context15.t0;
1410
+ case 22:
1411
+ case "end":
1412
+ return _context15.stop();
1413
+ }
1414
+ }, _callee15, this, [[0, 19]]);
1415
+ }));
1416
+ function applyDiscountCalculationResult(_x10) {
1417
+ return _applyDiscountCalculationResult.apply(this, arguments);
1418
+ }
1419
+ return applyDiscountCalculationResult;
1420
+ }()
894
1421
  }, {
895
1422
  key: "submitScanOrder",
896
1423
  value: function () {
897
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
898
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
899
- while (1) switch (_context10.prev = _context10.next) {
1424
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1425
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1426
+ while (1) switch (_context16.prev = _context16.next) {
900
1427
  case 0:
901
- return _context10.abrupt("return", this.submitSalesOrder(params));
1428
+ return _context16.abrupt("return", this.submitSalesOrder(params));
902
1429
  case 1:
903
1430
  case "end":
904
- return _context10.stop();
1431
+ return _context16.stop();
905
1432
  }
906
- }, _callee10, this);
1433
+ }, _callee16, this);
907
1434
  }));
908
- function submitScanOrder(_x6) {
1435
+ function submitScanOrder(_x11) {
909
1436
  return _submitScanOrder.apply(this, arguments);
910
1437
  }
911
1438
  return submitScanOrder;
@@ -919,14 +1446,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
919
1446
  }, {
920
1447
  key: "submitSalesOrder",
921
1448
  value: (function () {
922
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
923
- var _this$otherParams2, _this$otherParams3, _this$otherParams4, _this$otherParams5;
1449
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1450
+ var _this$otherParams4, _this$otherParams5, _this$otherParams6;
924
1451
  var submitParams;
925
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
926
- while (1) switch (_context11.prev = _context11.next) {
1452
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1453
+ while (1) switch (_context17.prev = _context17.next) {
927
1454
  case 0:
928
1455
  if (this.store.order) {
929
- _context11.next = 2;
1456
+ _context17.next = 2;
930
1457
  break;
931
1458
  }
932
1459
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -934,10 +1461,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
934
1461
  this.store.order.persistTempOrder();
935
1462
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
936
1463
  cacheId: this.cacheId,
937
- platform: (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform,
938
- businessCode: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode,
939
- channel: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.channel,
940
- type: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.type
1464
+ platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
1465
+ businessCode: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
1466
+ channel: this.getSubmitOrderSalesChannel(),
1467
+ type: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.type
941
1468
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
942
1469
  payments: params.payments
943
1470
  } : {}), (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined ? {
@@ -947,14 +1474,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
947
1474
  } : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
948
1475
  enhancePayload: params.enhancePayload
949
1476
  } : {});
950
- return _context11.abrupt("return", this.store.order.submitTempOrder(submitParams));
951
- case 5:
1477
+ console.log(submitParams, 'submitParams123');
1478
+ return _context17.abrupt("return", this.store.order.submitTempOrder(submitParams));
1479
+ case 6:
952
1480
  case "end":
953
- return _context11.stop();
1481
+ return _context17.stop();
954
1482
  }
955
- }, _callee11, this);
1483
+ }, _callee17, this);
956
1484
  }));
957
- function submitSalesOrder(_x7) {
1485
+ function submitSalesOrder(_x12) {
958
1486
  return _submitSalesOrder.apply(this, arguments);
959
1487
  }
960
1488
  return submitSalesOrder;
@@ -962,24 +1490,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
962
1490
  }, {
963
1491
  key: "syncPaymentsToOrder",
964
1492
  value: function () {
965
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
966
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
967
- while (1) switch (_context12.prev = _context12.next) {
1493
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
1494
+ var _params$channel;
1495
+ var channel;
1496
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1497
+ while (1) switch (_context18.prev = _context18.next) {
968
1498
  case 0:
969
1499
  if (this.store.order) {
970
- _context12.next = 2;
1500
+ _context18.next = 2;
971
1501
  break;
972
1502
  }
973
1503
  throw new Error('order 模块未初始化');
974
1504
  case 2:
975
- return _context12.abrupt("return", this.store.order.syncPaymentsToOrder(params));
976
- case 3:
1505
+ channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
1506
+ return _context18.abrupt("return", this.store.order.syncPaymentsToOrder(_objectSpread(_objectSpread({}, params), channel !== undefined ? {
1507
+ channel: channel
1508
+ } : {})));
1509
+ case 4:
977
1510
  case "end":
978
- return _context12.stop();
1511
+ return _context18.stop();
979
1512
  }
980
- }, _callee12, this);
1513
+ }, _callee18, this);
981
1514
  }));
982
- function syncPaymentsToOrder(_x8) {
1515
+ function syncPaymentsToOrder(_x13) {
983
1516
  return _syncPaymentsToOrder.apply(this, arguments);
984
1517
  }
985
1518
  return syncPaymentsToOrder;
@@ -1033,8 +1566,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1033
1566
  }, {
1034
1567
  key: "getWalletProductList",
1035
1568
  value: function getWalletProductList() {
1036
- var _this$store$order2, _tempOrder$products;
1037
- var tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.getTempOrder();
1569
+ var _this$store$order3, _tempOrder$products;
1570
+ var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
1038
1571
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
1039
1572
  return tempOrder.products.map(function (product) {
1040
1573
  var _product$product_vari, _product$is_charge_ta, _product$holder_id, _metadata$main_produc, _metadata$main_produc2;
@@ -1047,6 +1580,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1047
1580
  is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
1048
1581
  tax_fee: product.tax_fee,
1049
1582
  selling_price: Number(product.selling_price || 0),
1583
+ discount_list: product.discount_list || [],
1050
1584
  holder_id: (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id,
1051
1585
  original_price: product.original_price,
1052
1586
  main_product_original_price: (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : product.original_price,
@@ -1057,11 +1591,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1057
1591
  surcharge_rounding_remainder: metadata.surcharge_rounding_remainder
1058
1592
  },
1059
1593
  product_bundle: (product.product_bundle || []).map(function (bundle) {
1594
+ var _bundle$bundle_id, _bundle$bundle_produc, _bundle$bundle_group_;
1060
1595
  var bundleMetadata = bundle.metadata || {};
1061
1596
  return {
1062
1597
  is_price_include_tax: tempOrder.is_price_include_tax,
1063
- bundle_id: bundle.bundle_id,
1064
- bundle_product_id: bundle.bundle_product_id,
1598
+ // 套餐子项在 tempOrder 上常为 id(如 1718),prepare/deduction 协议要求 bundle_id
1599
+ bundle_id: (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id,
1600
+ bundle_product_id: (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id,
1601
+ bundle_group_id: (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id,
1065
1602
  bundle_variant_id: bundle.bundle_variant_id,
1066
1603
  price_type: bundle.price_type,
1067
1604
  price_type_ext: bundle.price_type_ext,
@@ -1082,20 +1619,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1082
1619
  }, {
1083
1620
  key: "initWalletData",
1084
1621
  value: function () {
1085
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
1622
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1086
1623
  var _params$order_wait_pa, _ref, _tempOrder$is_price_i;
1087
1624
  var snapshot, tempOrder, amount, walletBusinessData, result;
1088
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1089
- while (1) switch (_context13.prev = _context13.next) {
1625
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1626
+ while (1) switch (_context19.prev = _context19.next) {
1090
1627
  case 0:
1091
1628
  if (this.store.order) {
1092
- _context13.next = 2;
1629
+ _context19.next = 2;
1093
1630
  break;
1094
1631
  }
1095
1632
  throw new Error('order 模块未初始化');
1096
1633
  case 2:
1097
1634
  if (this.store.payment) {
1098
- _context13.next = 4;
1635
+ _context19.next = 4;
1099
1636
  break;
1100
1637
  }
1101
1638
  throw new Error('payment 模块未初始化');
@@ -1104,10 +1641,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1104
1641
  tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
1105
1642
  amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
1106
1643
  if (!(!tempOrder || !amount)) {
1107
- _context13.next = 9;
1644
+ _context19.next = 9;
1108
1645
  break;
1109
1646
  }
1110
- return _context13.abrupt("return", {
1647
+ return _context19.abrupt("return", {
1111
1648
  walletRecommendList: [],
1112
1649
  userIdentificationCodes: [],
1113
1650
  transformList: [],
@@ -1130,11 +1667,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1130
1667
  }, snapshot.identity.orderId ? {
1131
1668
  payment_order_id: String(snapshot.identity.orderId)
1132
1669
  } : {});
1133
- _context13.next = 12;
1670
+ _context19.next = 12;
1134
1671
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
1135
1672
  case 12:
1136
- result = _context13.sent;
1137
- _context13.next = 15;
1673
+ result = _context19.sent;
1674
+ _context19.next = 15;
1138
1675
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
1139
1676
  orderId: snapshot.identity.orderId,
1140
1677
  customerId: walletBusinessData.customer_id,
@@ -1146,14 +1683,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1146
1683
  timestamp: Date.now()
1147
1684
  });
1148
1685
  case 15:
1149
- return _context13.abrupt("return", result);
1686
+ return _context19.abrupt("return", result);
1150
1687
  case 16:
1151
1688
  case "end":
1152
- return _context13.stop();
1689
+ return _context19.stop();
1153
1690
  }
1154
- }, _callee13, this);
1691
+ }, _callee19, this);
1155
1692
  }));
1156
- function initWalletData(_x9) {
1693
+ function initWalletData(_x14) {
1157
1694
  return _initWalletData.apply(this, arguments);
1158
1695
  }
1159
1696
  return initWalletData;
@@ -1180,27 +1717,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1180
1717
  }, {
1181
1718
  key: "getPaymentMethodsAsync",
1182
1719
  value: (function () {
1183
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1720
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1184
1721
  var response;
1185
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1186
- while (1) switch (_context14.prev = _context14.next) {
1722
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1723
+ while (1) switch (_context20.prev = _context20.next) {
1187
1724
  case 0:
1188
1725
  if (!this.store.payment) {
1189
- _context14.next = 2;
1726
+ _context20.next = 2;
1190
1727
  break;
1191
1728
  }
1192
- return _context14.abrupt("return", this.store.payment.getPayMethodListAsync());
1729
+ return _context20.abrupt("return", this.store.payment.getPayMethodListAsync());
1193
1730
  case 2:
1194
- _context14.next = 4;
1731
+ _context20.next = 4;
1195
1732
  return this.request.get('/pay/custom-payment/all');
1196
1733
  case 4:
1197
- response = _context14.sent;
1198
- return _context14.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || []);
1734
+ response = _context20.sent;
1735
+ return _context20.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || []);
1199
1736
  case 6:
1200
1737
  case "end":
1201
- return _context14.stop();
1738
+ return _context20.stop();
1202
1739
  }
1203
- }, _callee14, this);
1740
+ }, _callee20, this);
1204
1741
  }));
1205
1742
  function getPaymentMethodsAsync() {
1206
1743
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -1241,49 +1778,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1241
1778
  }, {
1242
1779
  key: "sendCustomerPayLink",
1243
1780
  value: (function () {
1244
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1781
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
1245
1782
  var orderIds, _ref2, _ref3, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
1246
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1247
- while (1) switch (_context15.prev = _context15.next) {
1783
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1784
+ while (1) switch (_context21.prev = _context21.next) {
1248
1785
  case 0:
1249
1786
  if (this.store.order) {
1250
- _context15.next = 2;
1787
+ _context21.next = 2;
1251
1788
  break;
1252
1789
  }
1253
1790
  throw new Error('order 模块未初始化');
1254
1791
  case 2:
1255
1792
  orderIds = params.order_ids || params.orderIds || [];
1256
1793
  if (!(!orderIds.length || params.submitBeforeSend)) {
1257
- _context15.next = 11;
1794
+ _context21.next = 11;
1258
1795
  break;
1259
1796
  }
1260
- _context15.next = 6;
1797
+ _context21.next = 6;
1261
1798
  return this.submitSalesOrder({
1262
1799
  smallTicketDataFlag: 1
1263
1800
  });
1264
1801
  case 6:
1265
- submitResult = _context15.sent;
1802
+ submitResult = _context21.sent;
1266
1803
  orderId = (_ref2 = (_ref3 = (_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 && _ref3 !== void 0 ? _ref3 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref2 !== void 0 ? _ref2 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
1267
1804
  if (orderId) {
1268
- _context15.next = 10;
1805
+ _context21.next = 10;
1269
1806
  break;
1270
1807
  }
1271
1808
  throw new Error('本地订单提交云端失败,无法发送支付链接');
1272
1809
  case 10:
1273
1810
  orderIds = [orderId];
1274
1811
  case 11:
1275
- return _context15.abrupt("return", this.store.order.sendCustomerPayLink({
1812
+ return _context21.abrupt("return", this.store.order.sendCustomerPayLink({
1276
1813
  emails: params.emails,
1277
1814
  notify_action: params.notify_action,
1278
1815
  order_ids: orderIds
1279
1816
  }));
1280
1817
  case 12:
1281
1818
  case "end":
1282
- return _context15.stop();
1819
+ return _context21.stop();
1283
1820
  }
1284
- }, _callee15, this);
1821
+ }, _callee21, this);
1285
1822
  }));
1286
- function sendCustomerPayLink(_x10) {
1823
+ function sendCustomerPayLink(_x15) {
1287
1824
  return _sendCustomerPayLink.apply(this, arguments);
1288
1825
  }
1289
1826
  return sendCustomerPayLink;
@@ -1293,76 +1830,155 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1293
1830
  value: function transformBaseProductToOrderProduct(params) {
1294
1831
  return _transformBaseProductToOrderProduct(params);
1295
1832
  }
1833
+ }, {
1834
+ key: "calculateProductBookingPrice",
1835
+ value: function () {
1836
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
1837
+ var _params$customer_id;
1838
+ var quotation, customerId;
1839
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1840
+ while (1) switch (_context22.prev = _context22.next) {
1841
+ case 0:
1842
+ quotation = this.store.quotation;
1843
+ customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
1844
+ _context22.next = 4;
1845
+ return this.loadQuotationForPriceQuery({
1846
+ quotation: quotation,
1847
+ customer_id: customerId,
1848
+ channel: params.channel
1849
+ });
1850
+ case 4:
1851
+ return _context22.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
1852
+ customer_id: customerId,
1853
+ quotation: quotation
1854
+ })));
1855
+ case 5:
1856
+ case "end":
1857
+ return _context22.stop();
1858
+ }
1859
+ }, _callee22, this);
1860
+ }));
1861
+ function calculateProductBookingPrice(_x16) {
1862
+ return _calculateProductBookingPrice.apply(this, arguments);
1863
+ }
1864
+ return calculateProductBookingPrice;
1865
+ }()
1296
1866
  }, {
1297
1867
  key: "addProductToOrder",
1298
1868
  value: function () {
1299
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(product, booking) {
1869
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking) {
1300
1870
  var products;
1301
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1302
- while (1) switch (_context16.prev = _context16.next) {
1871
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1872
+ while (1) switch (_context23.prev = _context23.next) {
1303
1873
  case 0:
1304
- _context16.prev = 0;
1874
+ _context23.prev = 0;
1305
1875
  if (this.store.order) {
1306
- _context16.next = 3;
1876
+ _context23.next = 3;
1307
1877
  break;
1308
1878
  }
1309
1879
  throw new Error('order 模块未初始化');
1310
1880
  case 3:
1311
- _context16.next = 5;
1881
+ _context23.next = 5;
1312
1882
  return this.store.order.addProductToOrder(product, booking);
1313
1883
  case 5:
1314
- products = _context16.sent;
1315
- return _context16.abrupt("return", products);
1884
+ products = _context23.sent;
1885
+ return _context23.abrupt("return", products);
1316
1886
  case 9:
1317
- _context16.prev = 9;
1318
- _context16.t0 = _context16["catch"](0);
1319
- throw _context16.t0;
1887
+ _context23.prev = 9;
1888
+ _context23.t0 = _context23["catch"](0);
1889
+ throw _context23.t0;
1320
1890
  case 12:
1321
1891
  case "end":
1322
- return _context16.stop();
1892
+ return _context23.stop();
1323
1893
  }
1324
- }, _callee16, this, [[0, 9]]);
1894
+ }, _callee23, this, [[0, 9]]);
1325
1895
  }));
1326
- function addProductToOrder(_x11, _x12) {
1896
+ function addProductToOrder(_x17, _x18) {
1327
1897
  return _addProductToOrder.apply(this, arguments);
1328
1898
  }
1329
1899
  return addProductToOrder;
1330
1900
  }()
1331
1901
  }, {
1332
- key: "updateProductInOrder",
1902
+ key: "updateOrderProduct",
1333
1903
  value: function () {
1334
- var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1904
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
1335
1905
  var products;
1336
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1337
- while (1) switch (_context17.prev = _context17.next) {
1906
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1907
+ while (1) switch (_context24.prev = _context24.next) {
1338
1908
  case 0:
1339
- _context17.prev = 0;
1909
+ _context24.prev = 0;
1340
1910
  if (this.store.order) {
1341
- _context17.next = 3;
1911
+ _context24.next = 3;
1342
1912
  break;
1343
1913
  }
1344
1914
  throw new Error('order 模块未初始化');
1345
1915
  case 3:
1346
- _context17.next = 5;
1347
- return this.store.order.updateProductInOrder(params);
1916
+ _context24.next = 5;
1917
+ return this.store.order.updateOrderProduct(params);
1348
1918
  case 5:
1349
- products = _context17.sent;
1350
- return _context17.abrupt("return", products);
1919
+ products = _context24.sent;
1920
+ return _context24.abrupt("return", products);
1351
1921
  case 9:
1352
- _context17.prev = 9;
1353
- _context17.t0 = _context17["catch"](0);
1354
- throw _context17.t0;
1922
+ _context24.prev = 9;
1923
+ _context24.t0 = _context24["catch"](0);
1924
+ throw _context24.t0;
1355
1925
  case 12:
1356
1926
  case "end":
1357
- return _context17.stop();
1927
+ return _context24.stop();
1928
+ }
1929
+ }, _callee24, this, [[0, 9]]);
1930
+ }));
1931
+ function updateOrderProduct(_x19) {
1932
+ return _updateOrderProduct.apply(this, arguments);
1933
+ }
1934
+ return updateOrderProduct;
1935
+ }()
1936
+ }, {
1937
+ key: "updateOrderProductQuantity",
1938
+ value: function () {
1939
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
1940
+ var products;
1941
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1942
+ while (1) switch (_context25.prev = _context25.next) {
1943
+ case 0:
1944
+ _context25.prev = 0;
1945
+ if (this.store.order) {
1946
+ _context25.next = 3;
1947
+ break;
1948
+ }
1949
+ throw new Error('order 模块未初始化');
1950
+ case 3:
1951
+ _context25.next = 5;
1952
+ return this.store.order.updateOrderProductQuantity(params);
1953
+ case 5:
1954
+ products = _context25.sent;
1955
+ return _context25.abrupt("return", products);
1956
+ case 9:
1957
+ _context25.prev = 9;
1958
+ _context25.t0 = _context25["catch"](0);
1959
+ throw _context25.t0;
1960
+ case 12:
1961
+ case "end":
1962
+ return _context25.stop();
1358
1963
  }
1359
- }, _callee17, this, [[0, 9]]);
1964
+ }, _callee25, this, [[0, 9]]);
1360
1965
  }));
1361
- function updateProductInOrder(_x13) {
1362
- return _updateProductInOrder.apply(this, arguments);
1966
+ function updateOrderProductQuantity(_x20) {
1967
+ return _updateOrderProductQuantity.apply(this, arguments);
1363
1968
  }
1364
- return updateProductInOrder;
1969
+ return updateOrderProductQuantity;
1365
1970
  }()
1971
+ }, {
1972
+ key: "updateOrderBooking",
1973
+ value: function updateOrderBooking(params) {
1974
+ try {
1975
+ if (!this.store.order) throw new Error('order 模块未初始化');
1976
+ return this.store.order.updateOrderBooking(params);
1977
+ } catch (error) {
1978
+ throw error;
1979
+ }
1980
+ }
1981
+
1366
1982
  /**
1367
1983
  * 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
1368
1984
  * 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
@@ -1370,12 +1986,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1370
1986
  }, {
1371
1987
  key: "setOrderProductLineNote",
1372
1988
  value: (function () {
1373
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity, note) {
1989
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(identity, note) {
1374
1990
  var params, products;
1375
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1376
- while (1) switch (_context18.prev = _context18.next) {
1991
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1992
+ while (1) switch (_context26.prev = _context26.next) {
1377
1993
  case 0:
1378
- _context18.prev = 0;
1994
+ _context26.prev = 0;
1379
1995
  params = {
1380
1996
  product_id: identity.product_id,
1381
1997
  product_variant_id: identity.product_variant_id,
@@ -1390,22 +2006,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1390
2006
  params.product_option_item = identity.product_option_item;
1391
2007
  }
1392
2008
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
1393
- _context18.next = 7;
1394
- return this.updateProductInOrder(params);
2009
+ _context26.next = 7;
2010
+ return this.updateOrderProduct(params);
1395
2011
  case 7:
1396
- products = _context18.sent;
1397
- return _context18.abrupt("return", products);
2012
+ products = _context26.sent;
2013
+ return _context26.abrupt("return", products);
1398
2014
  case 11:
1399
- _context18.prev = 11;
1400
- _context18.t0 = _context18["catch"](0);
1401
- throw _context18.t0;
2015
+ _context26.prev = 11;
2016
+ _context26.t0 = _context26["catch"](0);
2017
+ throw _context26.t0;
1402
2018
  case 14:
1403
2019
  case "end":
1404
- return _context18.stop();
2020
+ return _context26.stop();
1405
2021
  }
1406
- }, _callee18, this, [[0, 11]]);
2022
+ }, _callee26, this, [[0, 11]]);
1407
2023
  }));
1408
- function setOrderProductLineNote(_x14, _x15) {
2024
+ function setOrderProductLineNote(_x21, _x22) {
1409
2025
  return _setOrderProductLineNote.apply(this, arguments);
1410
2026
  }
1411
2027
  return setOrderProductLineNote;
@@ -1413,34 +2029,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1413
2029
  }, {
1414
2030
  key: "removeProductFromOrder",
1415
2031
  value: function () {
1416
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(identity) {
2032
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identity) {
1417
2033
  var products;
1418
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1419
- while (1) switch (_context19.prev = _context19.next) {
2034
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2035
+ while (1) switch (_context27.prev = _context27.next) {
1420
2036
  case 0:
1421
- _context19.prev = 0;
2037
+ _context27.prev = 0;
1422
2038
  if (this.store.order) {
1423
- _context19.next = 3;
2039
+ _context27.next = 3;
1424
2040
  break;
1425
2041
  }
1426
2042
  throw new Error('order 模块未初始化');
1427
2043
  case 3:
1428
- _context19.next = 5;
2044
+ _context27.next = 5;
1429
2045
  return this.store.order.removeProductFromOrder(identity);
1430
2046
  case 5:
1431
- products = _context19.sent;
1432
- return _context19.abrupt("return", products);
2047
+ products = _context27.sent;
2048
+ return _context27.abrupt("return", products);
1433
2049
  case 9:
1434
- _context19.prev = 9;
1435
- _context19.t0 = _context19["catch"](0);
1436
- throw _context19.t0;
2050
+ _context27.prev = 9;
2051
+ _context27.t0 = _context27["catch"](0);
2052
+ throw _context27.t0;
1437
2053
  case 12:
1438
2054
  case "end":
1439
- return _context19.stop();
2055
+ return _context27.stop();
1440
2056
  }
1441
- }, _callee19, this, [[0, 9]]);
2057
+ }, _callee27, this, [[0, 9]]);
1442
2058
  }));
1443
- function removeProductFromOrder(_x16) {
2059
+ function removeProductFromOrder(_x23) {
1444
2060
  return _removeProductFromOrder.apply(this, arguments);
1445
2061
  }
1446
2062
  return removeProductFromOrder;
@@ -1449,18 +2065,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1449
2065
  }, {
1450
2066
  key: "getProductList",
1451
2067
  value: function () {
1452
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1453
- var _this$otherParams6;
2068
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2069
+ var _this$otherParams7;
1454
2070
  var menu_list_ids, _this$store$products, res;
1455
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1456
- while (1) switch (_context20.prev = _context20.next) {
2071
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2072
+ while (1) switch (_context28.prev = _context28.next) {
1457
2073
  case 0:
1458
2074
  // 可以直接通过配置里的 menu 读取
1459
- menu_list_ids = ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 || (_this$otherParams6 = _this$otherParams6.dineInConfig) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6['menu.associated_menus'].map(function (n) {
2075
+ menu_list_ids = ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 || (_this$otherParams7 = _this$otherParams7.dineInConfig) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7['menu.associated_menus'].map(function (n) {
1460
2076
  return Number(n.value);
1461
2077
  })) || [];
1462
- _context20.prev = 1;
1463
- _context20.next = 4;
2078
+ _context28.prev = 1;
2079
+ _context28.next = 4;
1464
2080
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
1465
2081
  menu_list_ids: menu_list_ids,
1466
2082
  cacheId: this.cacheId,
@@ -1468,17 +2084,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1468
2084
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
1469
2085
  });
1470
2086
  case 4:
1471
- res = _context20.sent;
1472
- return _context20.abrupt("return", res);
2087
+ res = _context28.sent;
2088
+ return _context28.abrupt("return", res);
1473
2089
  case 8:
1474
- _context20.prev = 8;
1475
- _context20.t0 = _context20["catch"](1);
1476
- throw _context20.t0;
2090
+ _context28.prev = 8;
2091
+ _context28.t0 = _context28["catch"](1);
2092
+ throw _context28.t0;
1477
2093
  case 11:
1478
2094
  case "end":
1479
- return _context20.stop();
2095
+ return _context28.stop();
1480
2096
  }
1481
- }, _callee20, this, [[1, 8]]);
2097
+ }, _callee28, this, [[1, 8]]);
1482
2098
  }));
1483
2099
  function getProductList() {
1484
2100
  return _getProductList.apply(this, arguments);
@@ -1493,15 +2109,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1493
2109
  }, {
1494
2110
  key: "setOtherParams",
1495
2111
  value: function () {
1496
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2112
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
1497
2113
  var _ref4,
1498
2114
  _ref4$cover,
1499
2115
  cover,
1500
- _args21 = arguments;
1501
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1502
- while (1) switch (_context21.prev = _context21.next) {
2116
+ _args29 = arguments;
2117
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2118
+ while (1) switch (_context29.prev = _context29.next) {
1503
2119
  case 0:
1504
- _ref4 = _args21.length > 1 && _args21[1] !== undefined ? _args21[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
2120
+ _ref4 = _args29.length > 1 && _args29[1] !== undefined ? _args29[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
1505
2121
  if (cover) {
1506
2122
  this.otherParams = params;
1507
2123
  } else {
@@ -1509,11 +2125,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1509
2125
  }
1510
2126
  case 2:
1511
2127
  case "end":
1512
- return _context21.stop();
2128
+ return _context29.stop();
1513
2129
  }
1514
- }, _callee21, this);
2130
+ }, _callee29, this);
1515
2131
  }));
1516
- function setOtherParams(_x17) {
2132
+ function setOtherParams(_x24) {
1517
2133
  return _setOtherParams.apply(this, arguments);
1518
2134
  }
1519
2135
  return setOtherParams;