@pisell/pisellos 2.1.172 → 2.1.174

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 (238) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +0 -1
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
  6. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  7. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
  8. package/dist/model/strategy/adapter/walletPass/evaluator.js +12 -63
  9. package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
  10. package/dist/model/strategy/engine.d.ts +5 -18
  11. package/dist/model/strategy/engine.js +45 -145
  12. package/dist/model/strategy/type.d.ts +0 -17
  13. package/dist/model/strategy/type.js +0 -4
  14. package/dist/modules/Cart/types.d.ts +0 -2
  15. package/dist/modules/Cart/utils/cartProduct.js +25 -56
  16. package/dist/modules/Cart/utils/changePrice.js +16 -9
  17. package/dist/modules/Discount/availability.d.ts +7 -0
  18. package/dist/modules/Discount/availability.js +52 -0
  19. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  20. package/dist/modules/Discount/entitlementPass.js +147 -0
  21. package/dist/modules/Discount/entitlementState.d.ts +8 -0
  22. package/dist/modules/Discount/entitlementState.js +205 -0
  23. package/dist/modules/Discount/index.d.ts +12 -3
  24. package/dist/modules/Discount/index.js +211 -17
  25. package/dist/modules/Discount/types.d.ts +42 -22
  26. package/dist/modules/Holder/index.d.ts +48 -0
  27. package/dist/modules/Holder/index.js +640 -0
  28. package/dist/modules/Holder/types.d.ts +123 -0
  29. package/dist/modules/Holder/types.js +1 -0
  30. package/dist/modules/Holder/utils.d.ts +13 -0
  31. package/dist/modules/Holder/utils.js +34 -0
  32. package/dist/modules/OpenData/index.d.ts +24 -0
  33. package/dist/modules/OpenData/index.js +173 -0
  34. package/dist/modules/OpenData/types.d.ts +73 -0
  35. package/dist/modules/OpenData/types.js +1 -0
  36. package/dist/modules/OpenData/utils.d.ts +2 -0
  37. package/dist/modules/OpenData/utils.js +75 -0
  38. package/dist/modules/Order/index.d.ts +67 -1
  39. package/dist/modules/Order/index.js +923 -30
  40. package/dist/modules/Order/types.d.ts +176 -12
  41. package/dist/modules/Order/types.js +2 -0
  42. package/dist/modules/Order/utils.d.ts +128 -0
  43. package/dist/modules/Order/utils.js +621 -5
  44. package/dist/modules/Payment/index.d.ts +1 -2
  45. package/dist/modules/Payment/index.js +7 -10
  46. package/dist/modules/Payment/utils.js +0 -3
  47. package/dist/modules/Payment/walletpass.d.ts +0 -23
  48. package/dist/modules/Payment/walletpass.js +95 -191
  49. package/dist/modules/Product/types.d.ts +7 -0
  50. package/dist/modules/Product/utils.js +2 -2
  51. package/dist/modules/ProductList/index.d.ts +1 -1
  52. package/dist/modules/ProductList/index.js +4 -3
  53. package/dist/modules/Quotation/index.d.ts +48 -0
  54. package/dist/modules/Quotation/index.js +248 -0
  55. package/dist/modules/Quotation/types.d.ts +42 -0
  56. package/dist/modules/Quotation/types.js +1 -0
  57. package/dist/modules/Rules/entitlementLines.d.ts +8 -0
  58. package/dist/modules/Rules/entitlementLines.js +157 -0
  59. package/dist/modules/Rules/index.d.ts +17 -11
  60. package/dist/modules/Rules/index.js +495 -726
  61. package/dist/modules/Rules/types.d.ts +2 -4
  62. package/dist/modules/SalesSummary/index.d.ts +63 -0
  63. package/dist/modules/SalesSummary/index.js +174 -0
  64. package/dist/modules/SalesSummary/types.d.ts +60 -0
  65. package/dist/modules/SalesSummary/types.js +1 -0
  66. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  67. package/dist/modules/SalesSummary/utils.js +480 -0
  68. package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
  69. package/dist/modules/ScanOrderLogger/index.js +174 -0
  70. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  71. package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
  72. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  73. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  74. package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
  75. package/dist/modules/ScanOrderLogger/types.js +1 -0
  76. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  77. package/dist/modules/Schedule/utils.d.ts +1 -1
  78. package/dist/modules/Summary/types.d.ts +0 -2
  79. package/dist/modules/Summary/utils.d.ts +3 -9
  80. package/dist/modules/Summary/utils.js +67 -57
  81. package/dist/modules/index.d.ts +5 -0
  82. package/dist/modules/index.js +6 -1
  83. package/dist/plugins/window.d.ts +3 -2
  84. package/dist/solution/BookingByStep/index.d.ts +17 -3
  85. package/dist/solution/BookingByStep/index.js +322 -247
  86. package/dist/solution/BookingByStep/types.d.ts +4 -1
  87. package/dist/solution/BookingByStep/types.js +7 -1
  88. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  89. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  90. package/dist/solution/Checkout/index.js +0 -2
  91. package/dist/solution/ScanOrder/index.d.ts +158 -0
  92. package/dist/solution/ScanOrder/index.js +3474 -0
  93. package/dist/solution/ScanOrder/types.d.ts +307 -0
  94. package/dist/solution/ScanOrder/types.js +35 -0
  95. package/dist/solution/ScanOrder/utils.d.ts +172 -0
  96. package/dist/solution/ScanOrder/utils.js +796 -0
  97. package/dist/solution/ShopDiscount/index.d.ts +6 -2
  98. package/dist/solution/ShopDiscount/index.js +194 -110
  99. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  100. package/dist/solution/ShopDiscount/types.js +1 -2
  101. package/dist/solution/ShopDiscount/utils.d.ts +1 -0
  102. package/dist/solution/ShopDiscount/utils.js +52 -27
  103. package/dist/solution/VenueBooking/index.d.ts +225 -0
  104. package/dist/solution/VenueBooking/index.js +3749 -0
  105. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  106. package/dist/solution/VenueBooking/types.d.ts +156 -0
  107. package/dist/solution/VenueBooking/types.js +21 -0
  108. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  109. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  110. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  111. package/dist/solution/VenueBooking/utils/resource.js +131 -0
  112. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  113. package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
  114. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  115. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  116. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  117. package/dist/solution/VenueBooking/utils.js +1 -0
  118. package/dist/solution/index.d.ts +2 -0
  119. package/dist/solution/index.js +3 -1
  120. package/dist/types/index.d.ts +1 -0
  121. package/lib/apis/picoding.d.ts +0 -0
  122. package/lib/apis/picoding.js +0 -0
  123. package/lib/index.d.ts +0 -1
  124. package/lib/index.js +1 -3
  125. package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
  126. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  127. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
  128. package/lib/model/strategy/adapter/walletPass/evaluator.js +7 -36
  129. package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
  130. package/lib/model/strategy/engine.d.ts +5 -18
  131. package/lib/model/strategy/engine.js +21 -85
  132. package/lib/model/strategy/type.d.ts +0 -17
  133. package/lib/modules/Cart/types.d.ts +0 -2
  134. package/lib/modules/Cart/utils/cartProduct.js +12 -39
  135. package/lib/modules/Cart/utils/changePrice.js +13 -9
  136. package/lib/modules/Discount/availability.d.ts +7 -0
  137. package/lib/modules/Discount/availability.js +91 -0
  138. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  139. package/lib/modules/Discount/entitlementPass.js +184 -0
  140. package/lib/modules/Discount/entitlementState.d.ts +8 -0
  141. package/lib/modules/Discount/entitlementState.js +206 -0
  142. package/lib/modules/Discount/index.d.ts +12 -3
  143. package/lib/modules/Discount/index.js +123 -12
  144. package/lib/modules/Discount/types.d.ts +42 -22
  145. package/lib/modules/Holder/index.d.ts +48 -0
  146. package/lib/modules/Holder/index.js +402 -0
  147. package/lib/modules/Holder/types.d.ts +123 -0
  148. package/lib/modules/Holder/types.js +17 -0
  149. package/lib/modules/Holder/utils.d.ts +13 -0
  150. package/lib/modules/Holder/utils.js +71 -0
  151. package/lib/modules/OpenData/index.d.ts +24 -0
  152. package/lib/modules/OpenData/index.js +119 -0
  153. package/lib/modules/OpenData/types.d.ts +73 -0
  154. package/lib/modules/OpenData/types.js +17 -0
  155. package/lib/modules/OpenData/utils.d.ts +2 -0
  156. package/lib/modules/OpenData/utils.js +111 -0
  157. package/lib/modules/Order/index.d.ts +67 -1
  158. package/lib/modules/Order/index.js +529 -1
  159. package/lib/modules/Order/types.d.ts +176 -12
  160. package/lib/modules/Order/utils.d.ts +128 -0
  161. package/lib/modules/Order/utils.js +514 -2
  162. package/lib/modules/Payment/index.d.ts +1 -2
  163. package/lib/modules/Payment/index.js +0 -1
  164. package/lib/modules/Payment/utils.js +0 -3
  165. package/lib/modules/Payment/walletpass.d.ts +0 -23
  166. package/lib/modules/Payment/walletpass.js +17 -94
  167. package/lib/modules/Product/types.d.ts +7 -0
  168. package/lib/modules/Product/utils.js +2 -2
  169. package/lib/modules/ProductList/index.d.ts +1 -1
  170. package/lib/modules/ProductList/index.js +5 -4
  171. package/lib/modules/Quotation/index.d.ts +48 -0
  172. package/lib/modules/Quotation/index.js +152 -0
  173. package/lib/modules/Quotation/types.d.ts +42 -0
  174. package/lib/modules/Quotation/types.js +17 -0
  175. package/lib/modules/Rules/entitlementLines.d.ts +8 -0
  176. package/lib/modules/Rules/entitlementLines.js +158 -0
  177. package/lib/modules/Rules/index.d.ts +17 -11
  178. package/lib/modules/Rules/index.js +548 -798
  179. package/lib/modules/Rules/types.d.ts +2 -4
  180. package/lib/modules/SalesSummary/index.d.ts +63 -0
  181. package/lib/modules/SalesSummary/index.js +105 -0
  182. package/lib/modules/SalesSummary/types.d.ts +60 -0
  183. package/lib/modules/SalesSummary/types.js +17 -0
  184. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  185. package/lib/modules/SalesSummary/utils.js +420 -0
  186. package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
  187. package/lib/modules/ScanOrderLogger/index.js +147 -0
  188. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  189. package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
  190. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  191. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  192. package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
  193. package/lib/modules/ScanOrderLogger/types.js +17 -0
  194. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  195. package/lib/modules/Schedule/utils.d.ts +1 -1
  196. package/lib/modules/Summary/types.d.ts +0 -2
  197. package/lib/modules/Summary/utils.d.ts +3 -9
  198. package/lib/modules/Summary/utils.js +45 -34
  199. package/lib/modules/index.d.ts +5 -0
  200. package/lib/modules/index.js +11 -1
  201. package/lib/plugins/window.d.ts +3 -2
  202. package/lib/solution/BookingByStep/index.d.ts +17 -3
  203. package/lib/solution/BookingByStep/index.js +45 -4
  204. package/lib/solution/BookingByStep/types.d.ts +4 -1
  205. package/lib/solution/BookingByStep/types.js +15 -0
  206. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  207. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  208. package/lib/solution/Checkout/index.js +0 -2
  209. package/lib/solution/ScanOrder/index.d.ts +158 -0
  210. package/lib/solution/ScanOrder/index.js +2135 -0
  211. package/lib/solution/ScanOrder/types.d.ts +307 -0
  212. package/lib/solution/ScanOrder/types.js +36 -0
  213. package/lib/solution/ScanOrder/utils.d.ts +172 -0
  214. package/lib/solution/ScanOrder/utils.js +658 -0
  215. package/lib/solution/ShopDiscount/index.d.ts +6 -2
  216. package/lib/solution/ShopDiscount/index.js +94 -50
  217. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  218. package/lib/solution/ShopDiscount/utils.d.ts +1 -0
  219. package/lib/solution/ShopDiscount/utils.js +48 -11
  220. package/lib/solution/VenueBooking/index.d.ts +225 -0
  221. package/lib/solution/VenueBooking/index.js +2073 -0
  222. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  223. package/lib/solution/VenueBooking/types.d.ts +156 -0
  224. package/lib/solution/VenueBooking/types.js +44 -0
  225. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  226. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  227. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  228. package/lib/solution/VenueBooking/utils/resource.js +92 -0
  229. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
  230. package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
  231. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  232. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  233. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  234. package/lib/solution/VenueBooking/utils.js +69 -0
  235. package/lib/solution/index.d.ts +2 -0
  236. package/lib/solution/index.js +5 -1
  237. package/lib/types/index.d.ts +1 -0
  238. package/package.json +1 -1
@@ -1,10 +1,11 @@
1
- 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); }
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
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
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."); }
4
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
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
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; }
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); }
8
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; }
9
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; }
10
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; }
@@ -24,14 +25,17 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
24
25
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
26
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
26
27
  import { BaseModule } from "../BaseModule";
27
- import { generateDuration, getAllDiscountList, mergeRelationForms } from "./utils";
28
+ import { generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, filterProductsForScanOrderMore, isTempOrder } from "./utils";
28
29
  import { isNormalProduct } from "../Product/utils";
29
30
  import dayjs from 'dayjs';
31
+ import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
32
+ import { DiscountModule } from "../Discount";
33
+ import { RulesModule } from "../Rules";
34
+ import { UnavailableReason } from "../Rules/types";
35
+ import Decimal from 'decimal.js';
30
36
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
31
37
  _inherits(OrderModule, _BaseModule);
32
38
  var _super = _createSuper(OrderModule);
33
- // LoggerManager 实例
34
-
35
39
  function OrderModule(name, version) {
36
40
  var _this;
37
41
  _classCallCheck(this, OrderModule);
@@ -41,30 +45,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
41
45
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
42
46
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
43
47
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
48
+ // LoggerManager 实例
49
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
50
+ _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
51
+ _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
52
+ _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
44
53
  return _this;
45
54
  }
46
55
  _createClass(OrderModule, [{
47
56
  key: "initialize",
48
57
  value: function () {
49
58
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
50
- var appPlugin, app;
59
+ var _otherParams$rules;
60
+ var otherParams, appPlugin, app;
51
61
  return _regeneratorRuntime().wrap(function _callee$(_context) {
52
62
  while (1) switch (_context.prev = _context.next) {
53
63
  case 0:
54
64
  this.core = core;
55
65
  this.store = options.store;
66
+ if (!this.store.tempOrder) {
67
+ this.store.tempOrder = null;
68
+ }
56
69
  this.request = this.core.getPlugin('request');
70
+ this.window = this.core.getPlugin('window');
71
+ otherParams = options.otherParams || {};
72
+ this.cacheId = otherParams.cacheId;
73
+ this.salesSummaryModuleName = otherParams.salesSummaryModuleName;
74
+ this.rulesHooksOverride = (_otherParams$rules = otherParams.rules) === null || _otherParams$rules === void 0 ? void 0 : _otherParams$rules.hooks;
75
+ this.registerDiscountModules(options);
76
+ this.restoreTempOrderFromStorage();
57
77
  appPlugin = this.core.getPlugin('app');
58
78
  if (appPlugin) {
59
- _context.next = 6;
79
+ _context.next = 14;
60
80
  break;
61
81
  }
62
82
  throw new Error('Order 模块需要 app 插件支持');
63
- case 6:
83
+ case 14:
64
84
  app = appPlugin.getApp();
65
85
  this.logger = app.logger;
66
86
  this.logInfo('OrderModule initialized successfully');
67
- case 9:
87
+ case 17:
68
88
  case "end":
69
89
  return _context.stop();
70
90
  }
@@ -119,9 +139,738 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
119
139
  });
120
140
  }
121
141
  }
142
+
143
+ // ─── Discount: 子模块注册 ───
144
+ }, {
145
+ key: "registerDiscountModules",
146
+ value: function registerDiscountModules(options) {
147
+ var _targetCacheData;
148
+ var targetCacheData = {};
149
+ if (this.cacheId && this.window) {
150
+ var sessionData = this.window.sessionStorage.getItem(this.name);
151
+ if (sessionData) {
152
+ try {
153
+ var data = JSON.parse(sessionData);
154
+ targetCacheData = (data === null || data === void 0 ? void 0 : data[this.cacheId]) || {};
155
+ } catch (_unused) {
156
+ // sessionStorage 损坏则忽略,按空 initialState 走
157
+ }
158
+ }
159
+ }
160
+ var discount = new DiscountModule("".concat(this.name, "_discount"));
161
+ this.core.registerModule(discount, {
162
+ initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[discount.name],
163
+ otherParams: {
164
+ fatherModule: this.name,
165
+ openCache: !!this.cacheId,
166
+ cacheId: this.cacheId
167
+ }
168
+ });
169
+ this.store.discount = discount;
170
+ var rules = new RulesModule("".concat(this.name, "_rules"));
171
+ this.core.registerModule(rules, {
172
+ hooks: this.rulesHooksOverride || this.createDefaultRulesHooks()
173
+ });
174
+ this.store.rules = rules;
175
+ }
176
+ }, {
177
+ key: "createDefaultRulesHooks",
178
+ value: function createDefaultRulesHooks() {
179
+ return createDefaultOrderRulesHooks();
180
+ }
181
+
182
+ // ─── Discount: 公共 API ───
183
+ }, {
184
+ key: "loadDiscountConfig",
185
+ value: function () {
186
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
187
+ var _this$store$discount, _this$store$tempOrder;
188
+ var discountList, _this$store$discount2;
189
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
190
+ while (1) switch (_context2.prev = _context2.next) {
191
+ case 0:
192
+ _context2.next = 2;
193
+ return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig({
194
+ customer_id: params.customerId,
195
+ action: params.action || 'create',
196
+ with_good_pass: 1,
197
+ with_discount_card: 1,
198
+ with_wallet_pass_holder: 1,
199
+ request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
200
+ });
201
+ case 2:
202
+ discountList = _context2.sent;
203
+ if (discountList) {
204
+ (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 || _this$store$discount2.setDiscountList(discountList);
205
+ }
206
+ if ((_this$store$tempOrder = this.store.tempOrder) !== null && _this$store$tempOrder !== void 0 && (_this$store$tempOrder = _this$store$tempOrder.products) !== null && _this$store$tempOrder !== void 0 && _this$store$tempOrder.length) {
207
+ this.applyDiscount();
208
+ }
209
+ case 5:
210
+ case "end":
211
+ return _context2.stop();
212
+ }
213
+ }, _callee2, this);
214
+ }));
215
+ function loadDiscountConfig(_x3) {
216
+ return _loadDiscountConfig.apply(this, arguments);
217
+ }
218
+ return loadDiscountConfig;
219
+ }()
220
+ }, {
221
+ key: "getDiscountList",
222
+ value: function getDiscountList() {
223
+ var _this$store$discount3;
224
+ return ((_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.getDiscountList()) || [];
225
+ }
226
+ }, {
227
+ key: "scanCode",
228
+ value: function () {
229
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
230
+ var _this$store$discount4, _tempOrder$holder, _tempOrder$holder2;
231
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount5;
232
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
233
+ while (1) switch (_context3.prev = _context3.next) {
234
+ case 0:
235
+ _context3.next = 2;
236
+ return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.batchSearch(code, {
237
+ customerId: customerId
238
+ });
239
+ case 2:
240
+ _context3.t0 = _context3.sent;
241
+ if (_context3.t0) {
242
+ _context3.next = 5;
243
+ break;
244
+ }
245
+ _context3.t0 = {
246
+ discountList: [],
247
+ unavailableReasonKey: null
248
+ };
249
+ case 5:
250
+ resultDiscountWithReason = _context3.t0;
251
+ resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
252
+ rulesModule = this.store.rules;
253
+ if (rulesModule) {
254
+ _context3.next = 10;
255
+ break;
256
+ }
257
+ return _context3.abrupt("return", {
258
+ type: 'clientCalc',
259
+ isAvailable: false,
260
+ discountList: this.getDiscountList(),
261
+ unavailableReason: UnavailableReason.Unknown
262
+ });
263
+ case 10:
264
+ if (resultDiscountList.length) {
265
+ _context3.next = 12;
266
+ break;
267
+ }
268
+ return _context3.abrupt("return", {
269
+ type: 'server',
270
+ isAvailable: false,
271
+ discountList: this.getDiscountList(),
272
+ unavailableReasonKey: unavailableReasonKey
273
+ });
274
+ case 12:
275
+ withScanList = resultDiscountList.map(function (item) {
276
+ return _objectSpread(_objectSpread({}, item), {}, {
277
+ isScan: true
278
+ });
279
+ });
280
+ currentSelected = this.getDiscountList().filter(function (n) {
281
+ return n.isSelected;
282
+ });
283
+ if (!(currentSelected.length && currentSelected.some(function (n) {
284
+ return withScanList.some(function (m) {
285
+ return m.id === n.id;
286
+ });
287
+ }))) {
288
+ _context3.next = 16;
289
+ break;
290
+ }
291
+ return _context3.abrupt("return", {
292
+ type: 'clientCalc',
293
+ isAvailable: true,
294
+ discountList: this.getDiscountList()
295
+ });
296
+ case 16:
297
+ tempOrder = this.store.tempOrder;
298
+ holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
299
+ form_record_id: tempOrder.holder.form_record_id
300
+ }] : [];
301
+ _ref = rulesModule.isDiscountListAvailable({
302
+ productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
303
+ oldDiscountList: this.getDiscountList(),
304
+ newDiscountList: withScanList,
305
+ holders: holders,
306
+ isFormSubject: !!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder2 = tempOrder.holder) !== null && _tempOrder$holder2 !== void 0 && _tempOrder$holder2.type) && tempOrder.holder.type === 'form'
307
+ }) || {
308
+ isAvailable: false,
309
+ discountList: this.getDiscountList()
310
+ }, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
311
+ if (isAvailable && newDiscountList) {
312
+ (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 || _this$store$discount5.setDiscountList(newDiscountList);
313
+ this.applyDiscount();
314
+ }
315
+ return _context3.abrupt("return", {
316
+ type: 'clientCalc',
317
+ isAvailable: isAvailable || false,
318
+ discountList: newDiscountList || this.getDiscountList(),
319
+ unavailableReason: unavailableReason
320
+ });
321
+ case 21:
322
+ case "end":
323
+ return _context3.stop();
324
+ }
325
+ }, _callee3, this);
326
+ }));
327
+ function scanCode(_x4, _x5) {
328
+ return _scanCode.apply(this, arguments);
329
+ }
330
+ return scanCode;
331
+ }()
332
+ }, {
333
+ key: "applyDiscount",
334
+ value: function applyDiscount() {
335
+ var _this$store$discount6, _tempOrder$holder3, _tempOrder$holder4;
336
+ var tempOrder = this.store.tempOrder;
337
+ // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
338
+ // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
339
+ // appliedProductDetails / savedAmount 以及 tempOrder.discount_list 复位。
340
+ if (!tempOrder) return;
341
+ var rulesModule = this.store.rules;
342
+ if (!rulesModule) return;
343
+ var discountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
344
+ var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
345
+ form_record_id: tempOrder.holder.form_record_id
346
+ }] : [];
347
+ var result = rulesModule.calcDiscount({
348
+ productList: tempOrder.products,
349
+ discountList: discountList,
350
+ holders: holders,
351
+ isFormSubject: !!((_tempOrder$holder4 = tempOrder.holder) !== null && _tempOrder$holder4 !== void 0 && _tempOrder$holder4.type) && tempOrder.holder.type === 'form'
352
+ });
353
+ if (result !== null && result !== void 0 && result.productList) {
354
+ tempOrder.products = result.productList;
355
+ }
356
+ if (result !== null && result !== void 0 && result.discountList) {
357
+ var _this$store$discount7;
358
+ OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
359
+ (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 || _this$store$discount7.setDiscountList(result.discountList);
360
+ tempOrder.discount_list = result.discountList.filter(function (d) {
361
+ return d.isSelected;
362
+ });
363
+ }
364
+ }
365
+
366
+ // ─── TempOrder: 初始化入口 ───
367
+ }, {
368
+ key: "initTempOrder",
369
+ value: function initTempOrder(params) {
370
+ if (params.cacheId !== undefined) this.cacheId = params.cacheId;
371
+ if (params.salesSummaryModuleName !== undefined) this.salesSummaryModuleName = params.salesSummaryModuleName;
372
+ this.restoreTempOrderFromStorage();
373
+ }
374
+
375
+ // ─── TempOrder: localStorage 持久化 ───
376
+ }, {
377
+ key: "getTempOrderStorageKey",
378
+ value: function getTempOrderStorageKey() {
379
+ if (!this.cacheId) return null;
380
+ return "scanOrder:tempOrder:".concat(this.cacheId);
381
+ }
382
+ }, {
383
+ key: "restoreTempOrderFromStorage",
384
+ value: function restoreTempOrderFromStorage() {
385
+ var key = this.getTempOrderStorageKey();
386
+ if (!key) return;
387
+ if (!this.window) return;
388
+ var cachedData = this.window.localStorage.getItem(key);
389
+ if (!cachedData) return;
390
+ try {
391
+ var parsedData = JSON.parse(cachedData);
392
+ if (!isTempOrder(parsedData)) {
393
+ this.window.localStorage.removeItem(key);
394
+ return;
395
+ }
396
+ if (Array.isArray(parsedData.products)) {
397
+ for (var i = 0; i < parsedData.products.length; i++) {
398
+ var p = parsedData.products[i];
399
+ if (!p || _typeof(p) !== 'object') continue;
400
+ if (!Array.isArray(p.product_option_item)) {
401
+ p.product_option_item = [];
402
+ }
403
+ if (!Array.isArray(p.product_bundle)) {
404
+ p.product_bundle = [];
405
+ }
406
+ // 不透明 identity 契约:旧缓存里可能没有 identity_key,
407
+ // 此处统一回填 UUID 并同步 metadata.unique_identification_number,
408
+ // 避免升级后 UI 侧持有的 rowKey 找不到对应行。
409
+ var row = p;
410
+ if (typeof row.identity_key !== 'string' || row.identity_key.length === 0) {
411
+ var newKey = createUuidV4();
412
+ row.identity_key = newKey;
413
+ if (!row.metadata || _typeof(row.metadata) !== 'object') {
414
+ row.metadata = {};
415
+ }
416
+ if (!row.metadata.unique_identification_number) {
417
+ row.metadata.unique_identification_number = newKey;
418
+ }
419
+ }
420
+ // 价格 schema 迁移:重跑 normalizeOrderProduct。
421
+ // `metadata.price_schema_version === 2` → 已是新语义,保留现有 main_product_* 折扣;
422
+ // 否则(v1 或无 metadata)→ 走 legacyDiscount 反推分支,基于新的 source + options
423
+ // 重算出含 option 的 main_product_*,并打上 price_schema_version: 2。
424
+ // 幂等:多次 restore 不会重复叠加 option/bundle。
425
+ parsedData.products[i] = normalizeOrderProduct(row);
426
+ }
427
+ }
428
+ this.store.tempOrder = parsedData;
429
+ } catch (_unused2) {
430
+ var _this$window;
431
+ (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
432
+ }
433
+ }
434
+ }, {
435
+ key: "persistTempOrder",
436
+ value: function persistTempOrder() {
437
+ var key = this.getTempOrderStorageKey();
438
+ if (!key || !this.store.tempOrder) return;
439
+ if (!this.window) return;
440
+ this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
441
+ }
442
+ }, {
443
+ key: "notifyTempOrderChanged",
444
+ value: function notifyTempOrderChanged() {
445
+ if (!this.store.tempOrder) return;
446
+ this.store.tempOrder = _objectSpread(_objectSpread({}, this.store.tempOrder), {}, {
447
+ products: _toConsumableArray(this.store.tempOrder.products),
448
+ bookings: this.store.tempOrder.bookings ? _toConsumableArray(this.store.tempOrder.bookings) : []
449
+ });
450
+ this.persistTempOrder();
451
+ }
452
+
453
+ // ─── TempOrder: 创建 & 获取 ───
454
+ }, {
455
+ key: "createDefaultTempOrderInstance",
456
+ value: function createDefaultTempOrderInstance() {
457
+ return createDefaultTempOrder({
458
+ now: formatDateTime(new Date()),
459
+ summary: createEmptySummary()
460
+ });
461
+ }
462
+ }, {
463
+ key: "ensureTempOrder",
464
+ value: function ensureTempOrder() {
465
+ if (this.store.tempOrder) return this.store.tempOrder;
466
+ var newOrder = this.createDefaultTempOrderInstance();
467
+ this.store.tempOrder = newOrder;
468
+ this.persistTempOrder();
469
+ return newOrder;
470
+ }
471
+ }, {
472
+ key: "restoreOrder",
473
+ value: function restoreOrder() {
474
+ var freshTempOrder = this.createDefaultTempOrderInstance();
475
+ this.store.tempOrder = freshTempOrder;
476
+ this.persistTempOrder();
477
+ return freshTempOrder;
478
+ }
479
+ }, {
480
+ key: "getTempOrder",
481
+ value: function getTempOrder() {
482
+ return this.store.tempOrder;
483
+ }
484
+ }, {
485
+ key: "addNewOrder",
486
+ value: function () {
487
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
488
+ var tempOrder;
489
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
490
+ while (1) switch (_context4.prev = _context4.next) {
491
+ case 0:
492
+ tempOrder = this.ensureTempOrder();
493
+ _context4.next = 3;
494
+ return this.recalculateSummary({
495
+ createIfMissing: true
496
+ });
497
+ case 3:
498
+ this.persistTempOrder();
499
+ return _context4.abrupt("return", tempOrder);
500
+ case 5:
501
+ case "end":
502
+ return _context4.stop();
503
+ }
504
+ }, _callee4, this);
505
+ }));
506
+ function addNewOrder() {
507
+ return _addNewOrder.apply(this, arguments);
508
+ }
509
+ return addNewOrder;
510
+ }()
511
+ }, {
512
+ key: "getOrderProducts",
513
+ value: function getOrderProducts() {
514
+ var tempOrder = this.ensureTempOrder();
515
+ return tempOrder.products;
516
+ }
517
+
518
+ // ─── TempOrder: 金额汇总 ───
519
+ }, {
520
+ key: "getSalesSummary",
521
+ value: function getSalesSummary() {
522
+ if (!this.salesSummaryModuleName) return null;
523
+ return this.core.getModule(this.salesSummaryModuleName);
524
+ }
525
+ }, {
526
+ key: "recalculateSummary",
527
+ value: function () {
528
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
529
+ var tempOrder, salesSummary, summary;
530
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
531
+ while (1) switch (_context5.prev = _context5.next) {
532
+ case 0:
533
+ tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
534
+ if (tempOrder) {
535
+ _context5.next = 3;
536
+ break;
537
+ }
538
+ return _context5.abrupt("return", null);
539
+ case 3:
540
+ salesSummary = this.getSalesSummary();
541
+ if (salesSummary) {
542
+ _context5.next = 8;
543
+ break;
544
+ }
545
+ tempOrder.summary = createEmptySummary();
546
+ tempOrder.surcharge_fee = tempOrder.summary.surcharge_fee;
547
+ return _context5.abrupt("return", tempOrder.summary);
548
+ case 8:
549
+ _context5.next = 10;
550
+ return salesSummary.getSummary({
551
+ products: tempOrder.products
552
+ });
553
+ case 10:
554
+ summary = _context5.sent;
555
+ tempOrder.summary = summary;
556
+ if (summary.is_price_include_tax !== undefined) {
557
+ tempOrder.is_price_include_tax = summary.is_price_include_tax;
558
+ }
559
+ if (typeof summary.tax_title === 'string') {
560
+ tempOrder.tax_title = summary.tax_title;
561
+ }
562
+ tempOrder.surcharge_fee = summary.surcharge_fee;
563
+ tempOrder.surcharges = summary.surcharges || [];
564
+ tempOrder.deposit_amount = summary.deposit_amount || '0.00';
565
+ tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
566
+ tempOrder.shop_discount = summary.discount_amount || '0.00';
567
+ return _context5.abrupt("return", tempOrder.summary);
568
+ case 20:
569
+ case "end":
570
+ return _context5.stop();
571
+ }
572
+ }, _callee5, this);
573
+ }));
574
+ function recalculateSummary(_x6) {
575
+ return _recalculateSummary.apply(this, arguments);
576
+ }
577
+ return recalculateSummary;
578
+ }()
579
+ }, {
580
+ key: "getScanOrderSummary",
581
+ value: function () {
582
+ var _getScanOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
583
+ var summary;
584
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
585
+ while (1) switch (_context6.prev = _context6.next) {
586
+ case 0:
587
+ _context6.next = 2;
588
+ return this.recalculateSummary({
589
+ createIfMissing: true
590
+ });
591
+ case 2:
592
+ summary = _context6.sent;
593
+ if (summary) {
594
+ _context6.next = 5;
595
+ break;
596
+ }
597
+ return _context6.abrupt("return", createEmptySummary());
598
+ case 5:
599
+ this.persistTempOrder();
600
+ return _context6.abrupt("return", summary);
601
+ case 7:
602
+ case "end":
603
+ return _context6.stop();
604
+ }
605
+ }, _callee6, this);
606
+ }));
607
+ function getScanOrderSummary() {
608
+ return _getScanOrderSummary.apply(this, arguments);
609
+ }
610
+ return getScanOrderSummary;
611
+ }() // ─── TempOrder: 备注 ───
612
+ }, {
613
+ key: "updateTempOrderNote",
614
+ value: function updateTempOrderNote(note) {
615
+ var tempOrder = this.ensureTempOrder();
616
+ tempOrder.note = String(note || '');
617
+ this.persistTempOrder();
618
+ return tempOrder.note;
619
+ }
620
+ }, {
621
+ key: "updateTempOrderBuzzer",
622
+ value: function updateTempOrderBuzzer(buzzer) {
623
+ var tempOrder = this.ensureTempOrder();
624
+ tempOrder.buzzer = String(buzzer || '');
625
+ this.persistTempOrder();
626
+ return tempOrder.buzzer;
627
+ }
628
+ }, {
629
+ key: "updateTempOrderContactsInfo",
630
+ value: function updateTempOrderContactsInfo(contactsInfo) {
631
+ var tempOrder = this.ensureTempOrder();
632
+ tempOrder.contacts_info = Array.isArray(contactsInfo) ? contactsInfo : [];
633
+ this.persistTempOrder();
634
+ return tempOrder.contacts_info;
635
+ }
636
+
637
+ // ─── TempOrder: 商品 CRUD ───
638
+ }, {
639
+ key: "addProductToOrder",
640
+ value: function () {
641
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(product) {
642
+ var tempOrder, hasExplicitIdentityKey, normalizedProduct, productIndex, targetProduct, incomingFingerprint, matchedIndex, _normalizedProduct, _targetProduct, _normalizedProduct2;
643
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
644
+ while (1) switch (_context7.prev = _context7.next) {
645
+ case 0:
646
+ tempOrder = this.ensureTempOrder();
647
+ hasExplicitIdentityKey = typeof product.identity_key === 'string' && product.identity_key.length > 0;
648
+ if (hasExplicitIdentityKey) {
649
+ // 调用方自持 identity_key(如 VenueBooking 外部生成)→ 走严格 identity 合并。
650
+ normalizedProduct = normalizeOrderProduct(product);
651
+ productIndex = getProductIdentityIndex(tempOrder.products, normalizedProduct);
652
+ if (productIndex === -1) {
653
+ tempOrder.products.push(normalizedProduct);
654
+ } else {
655
+ targetProduct = tempOrder.products[productIndex];
656
+ tempOrder.products[productIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
657
+ num: getSafeProductNum(targetProduct.num + normalizedProduct.num),
658
+ _origin: normalizedProduct._origin || targetProduct._origin
659
+ });
660
+ }
661
+ } else {
662
+ // 无 identity_key:按 SKU + 内容指纹(options + bundle)匹配既有行以累加数量;
663
+ // 命中时保留已有 identity_key,未命中才由 normalizeOrderProduct 自动生成 UUID。
664
+ incomingFingerprint = buildProductLineFingerprint(product.product_option_item, product.product_bundle);
665
+ matchedIndex = tempOrder.products.findIndex(function (item) {
666
+ if (item.product_id !== product.product_id) return false;
667
+ if (item.product_variant_id !== product.product_variant_id) return false;
668
+ var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
669
+ return existedFingerprint === incomingFingerprint;
670
+ });
671
+ if (matchedIndex === -1) {
672
+ _normalizedProduct = normalizeOrderProduct(product);
673
+ tempOrder.products.push(_normalizedProduct);
674
+ } else {
675
+ _targetProduct = tempOrder.products[matchedIndex];
676
+ _normalizedProduct2 = normalizeOrderProduct(_objectSpread(_objectSpread({}, product), {}, {
677
+ identity_key: _targetProduct.identity_key
678
+ }));
679
+ tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, _targetProduct), _normalizedProduct2), {}, {
680
+ identity_key: _targetProduct.identity_key,
681
+ num: getSafeProductNum(_targetProduct.num + _normalizedProduct2.num),
682
+ _origin: _normalizedProduct2._origin || _targetProduct._origin
683
+ });
684
+ }
685
+ }
686
+ this.applyDiscount();
687
+ _context7.next = 6;
688
+ return this.recalculateSummary({
689
+ createIfMissing: true
690
+ });
691
+ case 6:
692
+ this.persistTempOrder();
693
+ return _context7.abrupt("return", tempOrder.products);
694
+ case 8:
695
+ case "end":
696
+ return _context7.stop();
697
+ }
698
+ }, _callee7, this);
699
+ }));
700
+ function addProductToOrder(_x7) {
701
+ return _addProductToOrder.apply(this, arguments);
702
+ }
703
+ return addProductToOrder;
704
+ }()
705
+ }, {
706
+ key: "updateProductInOrder",
707
+ value: function () {
708
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
709
+ var _metadata, _metadata2, _metadata3;
710
+ var product_id, product_variant_id, updates, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta;
711
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
712
+ while (1) switch (_context8.prev = _context8.next) {
713
+ case 0:
714
+ product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, identity_key = params.identity_key, product_option_item = params.product_option_item, product_bundle = params.product_bundle;
715
+ tempOrder = this.ensureTempOrder();
716
+ identityLookup = {
717
+ product_id: product_id,
718
+ product_variant_id: product_variant_id
719
+ };
720
+ if (identity_key !== undefined) identityLookup.identity_key = identity_key;
721
+ if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
722
+ if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
723
+ productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
724
+ if (!(productIndex === -1)) {
725
+ _context8.next = 9;
726
+ break;
727
+ }
728
+ throw new Error('[Order] 目标商品不存在,无法更新');
729
+ case 9:
730
+ targetProduct = tempOrder.products[productIndex];
731
+ nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
732
+ product_id: product_id,
733
+ product_variant_id: product_variant_id
734
+ });
735
+ nextProduct.num = getSafeProductNum(nextProduct.num);
736
+ // 兜底:caller 通过 updates 直接改了 selling_price / original_price 时,
737
+ // 视为 "重新给 source-level 主价"(caller 侧旧约定仍是 main-only 单价)。
738
+ // 清掉 metadata 里的 source_product_price / main_product_* / price_schema_version,
739
+ // 让 normalize 把顶层 selling_price 当作 source 来重算 main_original(=source+options) /
740
+ // main_selling / composite;否则旧 metadata 会反压顶层新值,触发口径不一致。
741
+ // 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
742
+ callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
743
+ callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata = updates.metadata) === null || _metadata === void 0 ? void 0 : _metadata.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.source_product_price) !== undefined;
744
+ if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
745
+ existedMeta = nextProduct.metadata || {};
746
+ nextProduct.metadata = _objectSpread({}, existedMeta);
747
+ delete nextProduct.metadata.source_product_price;
748
+ delete nextProduct.metadata.main_product_selling_price;
749
+ delete nextProduct.metadata.main_product_original_price;
750
+ delete nextProduct.metadata.price_schema_version;
751
+ }
752
+ // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
753
+ // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
754
+ tempOrder.products[productIndex] = normalizeOrderProduct(nextProduct);
755
+ this.applyDiscount();
756
+ _context8.next = 19;
757
+ return this.recalculateSummary({
758
+ createIfMissing: true
759
+ });
760
+ case 19:
761
+ this.persistTempOrder();
762
+ return _context8.abrupt("return", tempOrder.products);
763
+ case 21:
764
+ case "end":
765
+ return _context8.stop();
766
+ }
767
+ }, _callee8, this);
768
+ }));
769
+ function updateProductInOrder(_x8) {
770
+ return _updateProductInOrder.apply(this, arguments);
771
+ }
772
+ return updateProductInOrder;
773
+ }()
774
+ }, {
775
+ key: "removeProductFromOrder",
776
+ value: function () {
777
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(identity) {
778
+ var tempOrder;
779
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
780
+ while (1) switch (_context9.prev = _context9.next) {
781
+ case 0:
782
+ tempOrder = this.ensureTempOrder();
783
+ tempOrder.products = tempOrder.products.filter(function (item) {
784
+ return !isIdentityMatch(item, identity);
785
+ });
786
+ this.applyDiscount();
787
+ _context9.next = 5;
788
+ return this.recalculateSummary({
789
+ createIfMissing: true
790
+ });
791
+ case 5:
792
+ this.persistTempOrder();
793
+ return _context9.abrupt("return", tempOrder.products);
794
+ case 7:
795
+ case "end":
796
+ return _context9.stop();
797
+ }
798
+ }, _callee9, this);
799
+ }));
800
+ function removeProductFromOrder(_x9) {
801
+ return _removeProductFromOrder.apply(this, arguments);
802
+ }
803
+ return removeProductFromOrder;
804
+ }() // ─── TempOrder: 提交 ───
805
+ }, {
806
+ key: "submitTempOrder",
807
+ value: function () {
808
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
809
+ var _params$cacheId;
810
+ var tempOrder, effectiveCacheId, payload, result, products, moreResult;
811
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
812
+ while (1) switch (_context10.prev = _context10.next) {
813
+ case 0:
814
+ tempOrder = this.ensureTempOrder();
815
+ this.persistTempOrder();
816
+ effectiveCacheId = (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId;
817
+ payload = buildSubmitPayload({
818
+ tempOrder: tempOrder,
819
+ cacheId: effectiveCacheId,
820
+ platform: params === null || params === void 0 ? void 0 : params.platform,
821
+ businessCode: params === null || params === void 0 ? void 0 : params.businessCode,
822
+ channel: params === null || params === void 0 ? void 0 : params.channel,
823
+ type: params === null || params === void 0 ? void 0 : params.type,
824
+ enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
825
+ });
826
+ if (!tempOrder.order_id) {
827
+ _context10.next = 12;
828
+ break;
829
+ }
830
+ products = filterProductsForScanOrderMore(payload.products);
831
+ _context10.next = 8;
832
+ return this.scanOrderMore({
833
+ query: {
834
+ order_id: tempOrder.order_id,
835
+ products: products,
836
+ request_unique_idempotency_token: payload.request_unique_idempotency_token
837
+ }
838
+ });
839
+ case 8:
840
+ moreResult = _context10.sent;
841
+ if (moreResult.code === 200) {
842
+ result = {
843
+ data: {
844
+ order_id: tempOrder.order_id
845
+ }
846
+ };
847
+ }
848
+ _context10.next = 15;
849
+ break;
850
+ case 12:
851
+ _context10.next = 14;
852
+ return this.submitScanOrder({
853
+ query: payload
854
+ });
855
+ case 14:
856
+ result = _context10.sent;
857
+ case 15:
858
+ return _context10.abrupt("return", result);
859
+ case 16:
860
+ case "end":
861
+ return _context10.stop();
862
+ }
863
+ }, _callee10, this);
864
+ }));
865
+ function submitTempOrder(_x10) {
866
+ return _submitTempOrder.apply(this, arguments);
867
+ }
868
+ return submitTempOrder;
869
+ }()
122
870
  }, {
123
871
  key: "createOrder",
124
872
  value: function createOrder(params) {
873
+ var _this2 = this;
125
874
  var order = _objectSpread({
126
875
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
127
876
  // 要从外面拿,virtual
@@ -139,6 +888,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
139
888
  var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
140
889
  if (params.cartItems.length > 0) {
141
890
  params.cartItems.forEach(function (item) {
891
+ var _params$extraData;
142
892
  if (!item._origin.duration) {
143
893
  var _generateDuration = generateDuration(item),
144
894
  duration = _generateDuration.duration,
@@ -149,6 +899,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
149
899
  var discountList = getAllDiscountList(item);
150
900
  item._origin.product.discount_list = discountList;
151
901
 
902
+ // 为预约补齐 holder 信息
903
+ if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
904
+ ensureCartItemOriginHolder(item, _this2.window);
905
+ }
906
+
152
907
  // 购物车是否为普通商品
153
908
  if (isNormalProduct(item._origin)) {
154
909
  var _order$relation_forms;
@@ -203,11 +958,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
203
958
  }, {
204
959
  key: "submitOrder",
205
960
  value: function () {
206
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
961
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(order) {
207
962
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
208
963
  var url, query, fetchUrl, params;
209
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
210
- while (1) switch (_context2.prev = _context2.next) {
964
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
965
+ while (1) switch (_context11.prev = _context11.next) {
211
966
  case 0:
212
967
  this.logInfo('submitOrder called', {
213
968
  url: order.url,
@@ -227,14 +982,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
227
982
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
228
983
  scheduleDate: params.schedule_date
229
984
  });
230
- return _context2.abrupt("return", this.request.post(fetchUrl, params));
985
+ return _context11.abrupt("return", this.request.post(fetchUrl, params));
231
986
  case 6:
232
987
  case "end":
233
- return _context2.stop();
988
+ return _context11.stop();
234
989
  }
235
- }, _callee2, this);
990
+ }, _callee11, this);
236
991
  }));
237
- function submitOrder(_x3) {
992
+ function submitOrder(_x11) {
238
993
  return _submitOrder.apply(this, arguments);
239
994
  }
240
995
  return submitOrder;
@@ -252,11 +1007,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
252
1007
  }, {
253
1008
  key: "createOrderByCheckout",
254
1009
  value: (function () {
255
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
1010
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
256
1011
  var _params$bookings2, _params$relation_prod2, _params$payments, _params$payments2, _params$bookings3, _params$relation_prod3, _params$payments3;
257
1012
  var _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
258
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
259
- while (1) switch (_context3.prev = _context3.next) {
1013
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1014
+ while (1) switch (_context12.prev = _context12.next) {
260
1015
  case 0:
261
1016
  this.logInfo('createOrderByCheckout called', {
262
1017
  type: params.type,
@@ -285,7 +1040,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
285
1040
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
286
1041
  paymentsCount: ((_params$payments3 = params.payments) === null || _params$payments3 === void 0 ? void 0 : _params$payments3.length) || 0
287
1042
  });
288
- _context3.prev = 2;
1043
+ _context12.prev = 2;
289
1044
  // 构建订单数据,设置默认值并允许 params 覆盖
290
1045
  orderData = _objectSpread({
291
1046
  sales_channel: 'my_pisel',
@@ -349,10 +1104,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
349
1104
  });
350
1105
 
351
1106
  // 调用后端接口
352
- _context3.next = 10;
1107
+ _context12.next = 10;
353
1108
  return this.request.post('/order/checkout', orderData);
354
1109
  case 10:
355
- response = _context3.sent;
1110
+ response = _context12.sent;
356
1111
  this.logInfo('Order API called successfully', {
357
1112
  response: response
358
1113
  });
@@ -360,26 +1115,164 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
360
1115
  success: !!response,
361
1116
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
362
1117
  });
363
- return _context3.abrupt("return", response);
1118
+ return _context12.abrupt("return", response);
364
1119
  case 16:
365
- _context3.prev = 16;
366
- _context3.t0 = _context3["catch"](2);
367
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
1120
+ _context12.prev = 16;
1121
+ _context12.t0 = _context12["catch"](2);
1122
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context12.t0);
368
1123
  this.logInfo('Order API called failed', {
369
- error: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
1124
+ error: _context12.t0 instanceof Error ? _context12.t0.message : String(_context12.t0)
370
1125
  });
371
- throw _context3.t0;
1126
+ throw _context12.t0;
372
1127
  case 21:
373
1128
  case "end":
374
- return _context3.stop();
1129
+ return _context12.stop();
375
1130
  }
376
- }, _callee3, this, [[2, 16]]);
1131
+ }, _callee12, this, [[2, 16]]);
377
1132
  }));
378
- function createOrderByCheckout(_x4) {
1133
+ function createOrderByCheckout(_x12) {
379
1134
  return _createOrderByCheckout.apply(this, arguments);
380
1135
  }
381
1136
  return createOrderByCheckout;
382
1137
  }())
1138
+ }, {
1139
+ key: "submitScanOrder",
1140
+ value: function () {
1141
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
1142
+ var url, query, fetchUrl;
1143
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1144
+ while (1) switch (_context13.prev = _context13.next) {
1145
+ case 0:
1146
+ url = params.url, query = params.query;
1147
+ fetchUrl = url || '/order/sales/checkout';
1148
+ return _context13.abrupt("return", this.request.post(fetchUrl, query, {
1149
+ customToast: function customToast() {}
1150
+ }));
1151
+ case 3:
1152
+ case "end":
1153
+ return _context13.stop();
1154
+ }
1155
+ }, _callee13, this);
1156
+ }));
1157
+ function submitScanOrder(_x13) {
1158
+ return _submitScanOrder.apply(this, arguments);
1159
+ }
1160
+ return submitScanOrder;
1161
+ }()
1162
+ }, {
1163
+ key: "scanOrderMore",
1164
+ value: function () {
1165
+ var _scanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1166
+ var url, query, fetchUrl, requestBody;
1167
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1168
+ while (1) switch (_context14.prev = _context14.next) {
1169
+ case 0:
1170
+ url = params.url, query = params.query;
1171
+ fetchUrl = url || "/order/order/product/".concat(query.order_id);
1172
+ requestBody = {
1173
+ products: query.products,
1174
+ request_unique_idempotency_token: query.request_unique_idempotency_token
1175
+ };
1176
+ return _context14.abrupt("return", this.request.put(fetchUrl, requestBody, {
1177
+ customToast: function customToast() {}
1178
+ }));
1179
+ case 4:
1180
+ case "end":
1181
+ return _context14.stop();
1182
+ }
1183
+ }, _callee14, this);
1184
+ }));
1185
+ function scanOrderMore(_x14) {
1186
+ return _scanOrderMore.apply(this, arguments);
1187
+ }
1188
+ return scanOrderMore;
1189
+ }() // TODO 获取详情的接口
1190
+ }, {
1191
+ key: "getOrderInfoByRemote",
1192
+ value: function () {
1193
+ var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(order_id) {
1194
+ var res;
1195
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1196
+ while (1) switch (_context15.prev = _context15.next) {
1197
+ case 0:
1198
+ _context15.next = 2;
1199
+ return this.request.get("/order/sales/".concat(order_id), {
1200
+ with: ['products', 'scheduleEvents']
1201
+ });
1202
+ case 2:
1203
+ res = _context15.sent;
1204
+ if (res.code === 200 && this.store.tempOrder) {
1205
+ this.store.tempOrder.lastOrderInfo = res.data;
1206
+ }
1207
+ return _context15.abrupt("return", res);
1208
+ case 5:
1209
+ case "end":
1210
+ return _context15.stop();
1211
+ }
1212
+ }, _callee15, this);
1213
+ }));
1214
+ function getOrderInfoByRemote(_x15) {
1215
+ return _getOrderInfoByRemote.apply(this, arguments);
1216
+ }
1217
+ return getOrderInfoByRemote;
1218
+ }()
1219
+ }, {
1220
+ key: "getLastOrderInfo",
1221
+ value: function getLastOrderInfo() {
1222
+ var _this$store;
1223
+ return (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.tempOrder) === null || _this$store === void 0 ? void 0 : _this$store.lastOrderInfo;
1224
+ }
1225
+ }], [{
1226
+ key: "populateSavedAmounts",
1227
+ value:
1228
+ /**
1229
+ * Populate `savedAmount` on each discount based on product-level discount details.
1230
+ * Only selected discounts get a non-zero value.
1231
+ */
1232
+ function populateSavedAmounts(productList, discountList) {
1233
+ var savedMap = new Map();
1234
+ var _iterator = _createForOfIteratorHelper(productList),
1235
+ _step;
1236
+ try {
1237
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1238
+ var product = _step.value;
1239
+ var qty = product.num || 1;
1240
+ var _iterator3 = _createForOfIteratorHelper(product.discount_list || []),
1241
+ _step3;
1242
+ try {
1243
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1244
+ var _pd$discount, _pd$metadata;
1245
+ var pd = _step3.value;
1246
+ var discountKey = ((_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) || pd.id;
1247
+ if (discountKey == null) continue;
1248
+ var amount = new Decimal(pd.amount || 0).times(qty).plus(((_pd$metadata = pd.metadata) === null || _pd$metadata === void 0 ? void 0 : _pd$metadata.product_discount_difference) || 0);
1249
+ savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
1250
+ }
1251
+ } catch (err) {
1252
+ _iterator3.e(err);
1253
+ } finally {
1254
+ _iterator3.f();
1255
+ }
1256
+ }
1257
+ } catch (err) {
1258
+ _iterator.e(err);
1259
+ } finally {
1260
+ _iterator.f();
1261
+ }
1262
+ var _iterator2 = _createForOfIteratorHelper(discountList),
1263
+ _step2;
1264
+ try {
1265
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1266
+ var d = _step2.value;
1267
+ var key = d.id;
1268
+ d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
1269
+ }
1270
+ } catch (err) {
1271
+ _iterator2.e(err);
1272
+ } finally {
1273
+ _iterator2.f();
1274
+ }
1275
+ }
383
1276
  }]);
384
1277
  return OrderModule;
385
1278
  }(BaseModule);