@pisell/pisellos 2.3.39 → 2.3.41

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 (226) hide show
  1. package/dist/core/index.d.ts +2 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  4. package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
  8. package/dist/model/strategy/adapter/promotion/examples.js +99 -0
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
  12. package/dist/model/strategy/adapter/promotion/type.js +45 -0
  13. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  14. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  15. package/dist/modules/Discount/index.d.ts +0 -1
  16. package/dist/modules/Discount/index.js +11 -40
  17. package/dist/modules/Discount/types.d.ts +0 -1
  18. package/dist/modules/OpenData/index.d.ts +2 -0
  19. package/dist/modules/OpenData/index.js +10 -2
  20. package/dist/modules/Order/index.d.ts +29 -12
  21. package/dist/modules/Order/index.js +750 -509
  22. package/dist/modules/Order/payment-utils.d.ts +26 -0
  23. package/dist/modules/Order/payment-utils.js +225 -0
  24. package/dist/modules/Order/types.d.ts +33 -10
  25. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  26. package/dist/modules/Order/utils.d.ts +0 -10
  27. package/dist/modules/Order/utils.js +13 -41
  28. package/dist/modules/Payment/index.d.ts +2 -0
  29. package/dist/modules/Payment/index.js +79 -50
  30. package/dist/modules/Payment/types.d.ts +99 -28
  31. package/dist/modules/Payment/types.js +20 -3
  32. package/dist/modules/Payment/walletpass.d.ts +25 -1
  33. package/dist/modules/Payment/walletpass.js +707 -157
  34. package/dist/modules/Product/types.d.ts +0 -1
  35. package/dist/modules/ProductList/index.js +14 -33
  36. package/dist/modules/Quotation/index.d.ts +1 -1
  37. package/dist/modules/Quotation/index.js +2 -2
  38. package/dist/modules/Rules/index.d.ts +1 -0
  39. package/dist/modules/Rules/index.js +89 -96
  40. package/dist/modules/SalesSummary/index.js +13 -12
  41. package/dist/modules/ScanOrderLogger/index.d.ts +0 -2
  42. package/dist/modules/ScanOrderLogger/index.js +2 -15
  43. package/dist/modules/ScanOrderLogger/providers/feishu.js +27 -45
  44. package/dist/modules/ScanOrderLogger/types.d.ts +0 -1
  45. package/dist/modules/Schedule/index.d.ts +1 -3
  46. package/dist/modules/Schedule/index.js +16 -21
  47. package/dist/modules/Summary/utils.js +13 -38
  48. package/dist/modules/index.d.ts +0 -2
  49. package/dist/modules/index.js +1 -3
  50. package/dist/plugins/window.d.ts +0 -1
  51. package/dist/server/index.d.ts +16 -14
  52. package/dist/server/index.js +1925 -1143
  53. package/dist/server/modules/order/index.d.ts +54 -4
  54. package/dist/server/modules/order/index.js +1600 -700
  55. package/dist/server/modules/order/types.d.ts +11 -3
  56. package/dist/server/modules/order/types.js +1 -1
  57. package/dist/solution/BaseSales/index.d.ts +109 -20
  58. package/dist/solution/BaseSales/index.js +1800 -480
  59. package/dist/solution/BaseSales/types.d.ts +52 -0
  60. package/dist/solution/BaseSales/types.js +2 -1
  61. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  62. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  63. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  64. package/dist/solution/BookingByStep/index.d.ts +2 -17
  65. package/dist/solution/BookingByStep/index.js +215 -294
  66. package/dist/solution/BookingByStep/types.d.ts +1 -2
  67. package/dist/solution/BookingByStep/types.js +1 -3
  68. package/dist/solution/BookingByStep/utils/capacity.js +1 -17
  69. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  70. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  71. package/dist/solution/BookingTicket/index.d.ts +7 -3
  72. package/dist/solution/BookingTicket/index.js +132 -49
  73. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  74. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  75. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +172 -82
  76. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  77. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  78. package/dist/solution/Sales/index.d.ts +1 -0
  79. package/dist/solution/Sales/index.js +10 -2
  80. package/dist/solution/ScanOrder/index.d.ts +14 -26
  81. package/dist/solution/ScanOrder/index.js +756 -1148
  82. package/dist/solution/ScanOrder/types.d.ts +1 -21
  83. package/dist/solution/ScanOrder/utils.d.ts +0 -8
  84. package/dist/solution/ScanOrder/utils.js +25 -66
  85. package/dist/solution/ShopDiscount/index.d.ts +0 -1
  86. package/dist/solution/ShopDiscount/index.js +87 -125
  87. package/dist/solution/VenueBooking/index.d.ts +11 -39
  88. package/dist/solution/VenueBooking/index.js +860 -1176
  89. package/dist/solution/VenueBooking/types.d.ts +0 -3
  90. package/dist/solution/VenueBooking/utils/resource.js +0 -1
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +5 -10
  93. package/dist/solution/index.d.ts +0 -1
  94. package/dist/solution/index.js +1 -2
  95. package/dist/types/index.d.ts +1 -1
  96. package/dist/utils/payment-number.d.ts +9 -0
  97. package/dist/utils/payment-number.js +69 -0
  98. package/lib/core/index.d.ts +2 -0
  99. package/lib/core/index.js +4 -0
  100. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  101. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  102. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  103. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  104. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  105. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  106. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  107. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  108. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  109. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  110. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  111. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  112. package/lib/modules/Discount/index.d.ts +0 -1
  113. package/lib/modules/Discount/index.js +0 -9
  114. package/lib/modules/Discount/types.d.ts +0 -1
  115. package/lib/modules/OpenData/index.d.ts +2 -0
  116. package/lib/modules/OpenData/index.js +6 -1
  117. package/lib/modules/Order/index.d.ts +29 -12
  118. package/lib/modules/Order/index.js +196 -86
  119. package/lib/modules/Order/payment-utils.d.ts +26 -0
  120. package/lib/modules/Order/payment-utils.js +224 -0
  121. package/lib/modules/Order/types.d.ts +33 -10
  122. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  123. package/lib/modules/Order/utils.d.ts +0 -10
  124. package/lib/modules/Order/utils.js +16 -40
  125. package/lib/modules/Payment/index.d.ts +2 -0
  126. package/lib/modules/Payment/index.js +34 -13
  127. package/lib/modules/Payment/types.d.ts +99 -28
  128. package/lib/modules/Payment/types.js +4 -3
  129. package/lib/modules/Payment/walletpass.d.ts +25 -1
  130. package/lib/modules/Payment/walletpass.js +470 -21
  131. package/lib/modules/Product/types.d.ts +0 -1
  132. package/lib/modules/ProductList/index.js +31 -40
  133. package/lib/modules/Quotation/index.d.ts +1 -1
  134. package/lib/modules/Quotation/index.js +2 -2
  135. package/lib/modules/Rules/index.d.ts +1 -0
  136. package/lib/modules/Rules/index.js +47 -40
  137. package/lib/modules/SalesSummary/index.js +7 -6
  138. package/lib/modules/ScanOrderLogger/index.d.ts +0 -2
  139. package/lib/modules/ScanOrderLogger/index.js +1 -13
  140. package/lib/modules/ScanOrderLogger/providers/feishu.js +6 -15
  141. package/lib/modules/ScanOrderLogger/types.d.ts +0 -1
  142. package/lib/modules/Schedule/index.d.ts +1 -3
  143. package/lib/modules/Schedule/index.js +8 -10
  144. package/lib/modules/Summary/utils.js +1 -21
  145. package/lib/modules/index.d.ts +0 -2
  146. package/lib/modules/index.js +1 -5
  147. package/lib/plugins/window.d.ts +0 -1
  148. package/lib/server/index.d.ts +16 -14
  149. package/lib/server/index.js +675 -83
  150. package/lib/server/modules/order/index.d.ts +54 -4
  151. package/lib/server/modules/order/index.js +679 -66
  152. package/lib/server/modules/order/types.d.ts +11 -3
  153. package/lib/solution/BaseSales/index.d.ts +109 -20
  154. package/lib/solution/BaseSales/index.js +883 -70
  155. package/lib/solution/BaseSales/types.d.ts +52 -0
  156. package/lib/solution/BaseSales/types.js +2 -1
  157. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  158. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  159. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  160. package/lib/solution/BookingByStep/index.d.ts +2 -17
  161. package/lib/solution/BookingByStep/index.js +18 -60
  162. package/lib/solution/BookingByStep/types.d.ts +1 -2
  163. package/lib/solution/BookingByStep/types.js +0 -5
  164. package/lib/solution/BookingByStep/utils/capacity.js +1 -20
  165. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  166. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  167. package/lib/solution/BookingTicket/index.d.ts +7 -3
  168. package/lib/solution/BookingTicket/index.js +62 -9
  169. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  170. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  171. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +36 -4
  172. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  173. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  174. package/lib/solution/Sales/index.d.ts +1 -0
  175. package/lib/solution/Sales/index.js +5 -3
  176. package/lib/solution/ScanOrder/index.d.ts +14 -26
  177. package/lib/solution/ScanOrder/index.js +190 -449
  178. package/lib/solution/ScanOrder/types.d.ts +1 -21
  179. package/lib/solution/ScanOrder/utils.d.ts +0 -8
  180. package/lib/solution/ScanOrder/utils.js +0 -31
  181. package/lib/solution/ShopDiscount/index.d.ts +0 -1
  182. package/lib/solution/ShopDiscount/index.js +0 -14
  183. package/lib/solution/VenueBooking/index.d.ts +11 -39
  184. package/lib/solution/VenueBooking/index.js +123 -328
  185. package/lib/solution/VenueBooking/types.d.ts +0 -3
  186. package/lib/solution/VenueBooking/utils/resource.js +0 -1
  187. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  188. package/lib/solution/VenueBooking/utils/slotMerge.js +4 -6
  189. package/lib/solution/index.d.ts +0 -1
  190. package/lib/solution/index.js +1 -3
  191. package/lib/types/index.d.ts +1 -1
  192. package/lib/utils/payment-number.d.ts +9 -0
  193. package/lib/utils/payment-number.js +64 -0
  194. package/package.json +1 -1
  195. package/dist/modules/Holder/index.d.ts +0 -48
  196. package/dist/modules/Holder/index.js +0 -640
  197. package/dist/modules/Holder/types.d.ts +0 -123
  198. package/dist/modules/Holder/types.js +0 -1
  199. package/dist/modules/Holder/utils.d.ts +0 -13
  200. package/dist/modules/Holder/utils.js +0 -34
  201. package/dist/modules/ResourcePlanner/index.d.ts +0 -24
  202. package/dist/modules/ResourcePlanner/index.js +0 -181
  203. package/dist/modules/ResourcePlanner/planner.d.ts +0 -14
  204. package/dist/modules/ResourcePlanner/planner.js +0 -1069
  205. package/dist/modules/ResourcePlanner/types.d.ts +0 -227
  206. package/dist/modules/ResourcePlanner/types.js +0 -1
  207. package/dist/solution/UnifiedBookingSales/index.d.ts +0 -183
  208. package/dist/solution/UnifiedBookingSales/index.js +0 -1871
  209. package/dist/solution/UnifiedBookingSales/types.d.ts +0 -143
  210. package/dist/solution/UnifiedBookingSales/types.js +0 -11
  211. package/lib/modules/Holder/index.d.ts +0 -48
  212. package/lib/modules/Holder/index.js +0 -402
  213. package/lib/modules/Holder/types.d.ts +0 -123
  214. package/lib/modules/Holder/types.js +0 -17
  215. package/lib/modules/Holder/utils.d.ts +0 -13
  216. package/lib/modules/Holder/utils.js +0 -71
  217. package/lib/modules/ResourcePlanner/index.d.ts +0 -24
  218. package/lib/modules/ResourcePlanner/index.js +0 -148
  219. package/lib/modules/ResourcePlanner/planner.d.ts +0 -14
  220. package/lib/modules/ResourcePlanner/planner.js +0 -933
  221. package/lib/modules/ResourcePlanner/types.d.ts +0 -227
  222. package/lib/modules/ResourcePlanner/types.js +0 -17
  223. package/lib/solution/UnifiedBookingSales/index.d.ts +0 -183
  224. package/lib/solution/UnifiedBookingSales/index.js +0 -1076
  225. package/lib/solution/UnifiedBookingSales/types.d.ts +0 -143
  226. package/lib/solution/UnifiedBookingSales/types.js +0 -33
@@ -1,27 +1,88 @@
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 _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; }
2
+ 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); } }
3
+ 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); }); }; }
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
2
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
9
  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."); }
10
+ 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); }
4
11
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
12
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
- 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); }
9
13
  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; }
10
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
- 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; }
13
- 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; }
14
- 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; }
15
- 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); } }
16
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
17
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
15
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
19
16
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
+ 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; }
18
+ 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; }
20
19
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
20
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
21
  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); }
22
+ 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); }
23
23
  import { WalletPassHooks } from "./types";
24
24
  import { formatWalletPassList2PreparePayments as formatWalletPassList2PreparePaymentsUtils, sortUserIdentificationCodeList } from "./utils";
25
+ var WALLET_PAYMENT_ASSET_TAGS = new Set(['product_voucher', 'gift_card', 'point_card']);
26
+ function isWalletPaymentAsset(asset) {
27
+ return WALLET_PAYMENT_ASSET_TAGS.has(String((asset === null || asset === void 0 ? void 0 : asset.tag) || '').toLowerCase());
28
+ }
29
+ function getWalletAssetId(asset) {
30
+ var _ref, _asset$id;
31
+ return (_ref = (_asset$id = asset === null || asset === void 0 ? void 0 : asset.id) !== null && _asset$id !== void 0 ? _asset$id : asset === null || asset === void 0 ? void 0 : asset.voucher_id) !== null && _ref !== void 0 ? _ref : asset === null || asset === void 0 ? void 0 : asset.code;
32
+ }
33
+ function getWalletAssetKey(assetOrId) {
34
+ var id = assetOrId && _typeof(assetOrId) === 'object' ? getWalletAssetId(assetOrId) : assetOrId;
35
+ return id === undefined || id === null ? '' : String(id);
36
+ }
37
+ function isWalletAssetAvailable(asset) {
38
+ if (!asset) return false;
39
+ if (asset.unified_available_status !== undefined && Number(asset.unified_available_status) !== 1) {
40
+ return false;
41
+ }
42
+ if (asset._unified_available_status !== undefined && Number(asset._unified_available_status) !== 1) {
43
+ return false;
44
+ }
45
+ if (asset.available === false || asset.isDisabled === true) return false;
46
+ return true;
47
+ }
48
+ function getWalletAssetDeductionAmount(asset) {
49
+ var _ref2, _ref3, _ref4, _ref5, _ref6, _asset$actualDeductio;
50
+ var value = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_ref6 = (_asset$actualDeductio = asset === null || asset === void 0 ? void 0 : asset.actualDeduction) !== null && _asset$actualDeductio !== void 0 ? _asset$actualDeductio : asset === null || asset === void 0 ? void 0 : asset._available_max_amount) !== null && _ref6 !== void 0 ? _ref6 : asset === null || asset === void 0 ? void 0 : asset.edit_current_amount) !== null && _ref5 !== void 0 ? _ref5 : asset === null || asset === void 0 ? void 0 : asset.recommended_usage_amount) !== null && _ref4 !== void 0 ? _ref4 : asset === null || asset === void 0 ? void 0 : asset.available_max_amount) !== null && _ref3 !== void 0 ? _ref3 : asset === null || asset === void 0 ? void 0 : asset.amount) !== null && _ref2 !== void 0 ? _ref2 : 0;
51
+ var amount = Number(value);
52
+ return Number.isFinite(amount) && amount > 0 ? amount : 0;
53
+ }
54
+ function mergeWalletAssets() {
55
+ var merged = [];
56
+ var indexByKey = new Map();
57
+ for (var _len = arguments.length, groups = new Array(_len), _key = 0; _key < _len; _key++) {
58
+ groups[_key] = arguments[_key];
59
+ }
60
+ groups.flat().forEach(function (asset) {
61
+ var key = getWalletAssetKey(asset);
62
+ if (!key) return;
63
+ var existedIndex = indexByKey.get(key);
64
+ if (existedIndex === undefined) {
65
+ indexByKey.set(key, merged.length);
66
+ merged.push(asset);
67
+ return;
68
+ }
69
+ merged[existedIndex] = _objectSpread(_objectSpread({}, merged[existedIndex]), asset);
70
+ });
71
+ return merged;
72
+ }
73
+ function createInitialWalletAssetsState() {
74
+ return {
75
+ status: 'idle',
76
+ items: [],
77
+ selectedIds: [],
78
+ selectedItems: [],
79
+ committedIds: [],
80
+ selectionSources: {},
81
+ totalSelectedAmount: 0,
82
+ error: null,
83
+ revision: 0
84
+ };
85
+ }
25
86
 
26
87
  /**
27
88
  * 钱包支付实现
@@ -34,6 +95,12 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
34
95
  _defineProperty(this, "searchResults", []);
35
96
  _defineProperty(this, "walletParams", null);
36
97
  _defineProperty(this, "walletInitData", null);
98
+ _defineProperty(this, "walletAssetsState", createInitialWalletAssetsState());
99
+ _defineProperty(this, "walletAssetsRequestSequence", 0);
100
+ _defineProperty(this, "walletAssetsCalculationContext", {
101
+ orderTotalAmount: 0,
102
+ products: []
103
+ });
37
104
  this.paymentModule = paymentModule;
38
105
  }
39
106
 
@@ -55,11 +122,188 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
55
122
  });
56
123
  }
57
124
  }
125
+ }, {
126
+ key: "publishWalletAssetsState",
127
+ value: function publishWalletAssetsState(patch) {
128
+ var _patch$items, _patch$selectedIds, _patch$selectedItems, _patch$committedIds, _patch$selectionSourc;
129
+ this.walletAssetsState = _objectSpread(_objectSpread(_objectSpread({}, this.walletAssetsState), patch), {}, {
130
+ items: _toConsumableArray((_patch$items = patch.items) !== null && _patch$items !== void 0 ? _patch$items : this.walletAssetsState.items),
131
+ selectedIds: _toConsumableArray((_patch$selectedIds = patch.selectedIds) !== null && _patch$selectedIds !== void 0 ? _patch$selectedIds : this.walletAssetsState.selectedIds),
132
+ selectedItems: _toConsumableArray((_patch$selectedItems = patch.selectedItems) !== null && _patch$selectedItems !== void 0 ? _patch$selectedItems : this.walletAssetsState.selectedItems),
133
+ committedIds: _toConsumableArray((_patch$committedIds = patch.committedIds) !== null && _patch$committedIds !== void 0 ? _patch$committedIds : this.walletAssetsState.committedIds),
134
+ selectionSources: _objectSpread({}, (_patch$selectionSourc = patch.selectionSources) !== null && _patch$selectionSourc !== void 0 ? _patch$selectionSourc : this.walletAssetsState.selectionSources),
135
+ revision: this.walletAssetsState.revision + 1
136
+ });
137
+ var state = this.getWalletAssetsState();
138
+ this.emitEvent(WalletPassHooks.OnWalletAssetsStateChanged, {
139
+ state: state
140
+ });
141
+ return state;
142
+ }
143
+ }, {
144
+ key: "recalculateWalletAssets",
145
+ value: function recalculateWalletAssets(items, requestedIds, selectionSources) {
146
+ var _this$paymentModule$w, _this$paymentModule$w2;
147
+ var committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
148
+ return String(id);
149
+ }));
150
+ var requestedKeys = new Set(requestedIds.map(function (id) {
151
+ return String(id);
152
+ }).filter(function (id) {
153
+ return !committedKeys.has(id);
154
+ }));
155
+ var requested = items.filter(function (item) {
156
+ return requestedKeys.has(getWalletAssetKey(item)) && isWalletAssetAvailable(item);
157
+ });
158
+ var nextItems = items;
159
+ var selectedItems = requested;
160
+ var evaluator = (_this$paymentModule$w = this.paymentModule.window) === null || _this$paymentModule$w === void 0 || (_this$paymentModule$w2 = _this$paymentModule$w.getWalletPassEvaluator) === null || _this$paymentModule$w2 === void 0 ? void 0 : _this$paymentModule$w2.call(_this$paymentModule$w);
161
+ if (evaluator !== null && evaluator !== void 0 && evaluator.recalculateVouchers) {
162
+ try {
163
+ var result = evaluator.recalculateVouchers(items, requested, this.walletAssetsCalculationContext.orderTotalAmount, this.walletAssetsCalculationContext.products);
164
+ nextItems = mergeWalletAssets(items, (result === null || result === void 0 ? void 0 : result.allWithUpdatedStatus) || []);
165
+ selectedItems = ((result === null || result === void 0 ? void 0 : result.selectedWithDetails) || []).filter(function (item) {
166
+ return isWalletAssetAvailable(item) && getWalletAssetDeductionAmount(item) > 0;
167
+ });
168
+ } catch (error) {
169
+ this.paymentModule.logWarning('[WalletPass] 共享钱包资产重新计算失败,回退接口可用状态', {
170
+ error: error instanceof Error ? error.message : String(error)
171
+ });
172
+ }
173
+ }
174
+ var selectedIds = selectedItems.map(function (item) {
175
+ return getWalletAssetId(item);
176
+ }).filter(function (id) {
177
+ return id !== undefined && id !== null;
178
+ });
179
+ var selectedKeys = new Set(selectedIds.map(function (id) {
180
+ return String(id);
181
+ }));
182
+ var nextSources = Object.entries(selectionSources).reduce(function (result, _ref7) {
183
+ var _ref8 = _slicedToArray(_ref7, 2),
184
+ key = _ref8[0],
185
+ source = _ref8[1];
186
+ if (selectedKeys.has(key)) result[key] = source;
187
+ return result;
188
+ }, {});
189
+ var totalSelectedAmount = selectedItems.reduce(function (total, item) {
190
+ return total + getWalletAssetDeductionAmount(item);
191
+ }, 0);
192
+ return this.publishWalletAssetsState({
193
+ status: 'ready',
194
+ items: nextItems,
195
+ selectedIds: selectedIds,
196
+ selectedItems: selectedItems,
197
+ selectionSources: nextSources,
198
+ totalSelectedAmount: totalSelectedAmount,
199
+ error: null
200
+ });
201
+ }
58
202
 
203
+ /**
204
+ * 使用最新订单参数重验扫码搜索过的支付类 Wallet 资产。
205
+ * 请求失败或暂时无匹配结果时保留旧资产,避免商品变化造成列表闪空。
206
+ */
207
+ }, {
208
+ key: "revalidateSearchedWalletAssets",
209
+ value: (function () {
210
+ var _revalidateSearchedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(requestSequence) {
211
+ var _this = this;
212
+ var cachedAssets, searchCodes, preparePayments, refreshedGroups, replacedCodes, refreshedAssets;
213
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
214
+ while (1) switch (_context2.prev = _context2.next) {
215
+ case 0:
216
+ cachedAssets = this.searchResults.filter(isWalletPaymentAsset);
217
+ searchCodes = _toConsumableArray(new Set(cachedAssets.map(function (item) {
218
+ return String((item === null || item === void 0 ? void 0 : item.code) || '').trim();
219
+ }).filter(Boolean)));
220
+ if (!(searchCodes.length === 0)) {
221
+ _context2.next = 4;
222
+ break;
223
+ }
224
+ return _context2.abrupt("return", cachedAssets);
225
+ case 4:
226
+ preparePayments = this.formatWalletPassList2PreparePayments(this.walletAssetsState.selectedItems);
227
+ _context2.next = 7;
228
+ return Promise.all(searchCodes.map( /*#__PURE__*/function () {
229
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(searchCode) {
230
+ var result;
231
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
232
+ while (1) switch (_context.prev = _context.next) {
233
+ case 0:
234
+ _context.prev = 0;
235
+ _context.next = 3;
236
+ return _this.searchIdentificationCodeAsync(_objectSpread(_objectSpread({}, _this.walletParams || {}), {}, {
237
+ code: searchCode,
238
+ prepare_payments: preparePayments
239
+ }), {
240
+ noCache: true
241
+ });
242
+ case 3:
243
+ result = _context.sent;
244
+ return _context.abrupt("return", {
245
+ searchCode: searchCode,
246
+ items: result.type === 'normalCode' ? result.data.filter(isWalletPaymentAsset) : []
247
+ });
248
+ case 7:
249
+ _context.prev = 7;
250
+ _context.t0 = _context["catch"](0);
251
+ _this.paymentModule.logWarning('[WalletPass] 重验扫码 Wallet 资产失败,保留旧结果', {
252
+ code: searchCode,
253
+ error: _context.t0 instanceof Error ? _context.t0.message : String(_context.t0)
254
+ });
255
+ return _context.abrupt("return", {
256
+ searchCode: searchCode,
257
+ items: []
258
+ });
259
+ case 11:
260
+ case "end":
261
+ return _context.stop();
262
+ }
263
+ }, _callee, null, [[0, 7]]);
264
+ }));
265
+ return function (_x2) {
266
+ return _ref9.apply(this, arguments);
267
+ };
268
+ }()));
269
+ case 7:
270
+ refreshedGroups = _context2.sent;
271
+ if (!(requestSequence !== this.walletAssetsRequestSequence)) {
272
+ _context2.next = 10;
273
+ break;
274
+ }
275
+ return _context2.abrupt("return", cachedAssets);
276
+ case 10:
277
+ replacedCodes = new Set(refreshedGroups.filter(function (group) {
278
+ return group.items.length > 0;
279
+ }).map(function (group) {
280
+ return group.searchCode.toUpperCase();
281
+ }));
282
+ refreshedAssets = refreshedGroups.flatMap(function (group) {
283
+ return group.items;
284
+ });
285
+ if (refreshedAssets.length > 0) {
286
+ this.searchResults = [].concat(_toConsumableArray(this.searchResults.filter(function (item) {
287
+ return !replacedCodes.has(String((item === null || item === void 0 ? void 0 : item.code) || '').trim().toUpperCase());
288
+ })), _toConsumableArray(refreshedAssets));
289
+ }
290
+ return _context2.abrupt("return", mergeWalletAssets(cachedAssets, refreshedAssets));
291
+ case 14:
292
+ case "end":
293
+ return _context2.stop();
294
+ }
295
+ }, _callee2, this);
296
+ }));
297
+ function revalidateSearchedWalletAssets(_x) {
298
+ return _revalidateSearchedWalletAssets.apply(this, arguments);
299
+ }
300
+ return revalidateSearchedWalletAssets;
301
+ }()
59
302
  /**
60
303
  * 生成钱包API默认参数
61
304
  * 根据业务数据生成标准的钱包API参数,并存储在模块中
62
305
  */
306
+ )
63
307
  }, {
64
308
  key: "generateWalletParams",
65
309
  value: function generateWalletParams(businessData) {
@@ -85,7 +329,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
85
329
  // 订单小计金额
86
330
  order_product_amount: subTotal,
87
331
  // 订单待支付金额
88
- order_wait_pay_amount: order_wait_pay_amount || (amountInfo !== null && amountInfo !== void 0 && amountInfo.isDeposit ? Number(amountInfo === null || amountInfo === void 0 ? void 0 : amountInfo.depositAmount) : totalAmount),
332
+ order_wait_pay_amount: order_wait_pay_amount !== null && order_wait_pay_amount !== void 0 ? order_wait_pay_amount : amountInfo !== null && amountInfo !== void 0 && amountInfo.isDeposit ? Number(amountInfo === null || amountInfo === void 0 ? void 0 : amountInfo.depositAmount) : totalAmount,
89
333
  // order_behavior_count_customer_id: 1,
90
334
  products: products,
91
335
  prepare_payments: [],
@@ -138,19 +382,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
138
382
  }, {
139
383
  key: "initializeWalletDataFromBusinessAsync",
140
384
  value: (function () {
141
- var _initializeWalletDataFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(businessData) {
385
+ var _initializeWalletDataFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(businessData) {
142
386
  var _businessData$amountI, _businessData$amountI2, _businessData$amountI3, _businessData$amountI4, _businessData$product;
143
387
  var startTime, walletParams, _result$walletRecomme, _result$userIdentific, result, endTime, duration, _businessData$amountI5, _endTime, _duration;
144
- return _regeneratorRuntime().wrap(function _callee$(_context) {
145
- while (1) switch (_context.prev = _context.next) {
388
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
389
+ while (1) switch (_context3.prev = _context3.next) {
146
390
  case 0:
147
391
  startTime = Date.now();
148
392
  walletParams = this.generateWalletParams(businessData);
149
393
  if (!(Number((businessData === null || businessData === void 0 || (_businessData$amountI = businessData.amountInfo) === null || _businessData$amountI === void 0 ? void 0 : _businessData$amountI.totalAmount) || 0) < 0 || Number((businessData === null || businessData === void 0 || (_businessData$amountI2 = businessData.amountInfo) === null || _businessData$amountI2 === void 0 ? void 0 : _businessData$amountI2.subTotal) || 0) < 0)) {
150
- _context.next = 4;
394
+ _context3.next = 4;
151
395
  break;
152
396
  }
153
- return _context.abrupt("return", {
397
+ return _context3.abrupt("return", {
154
398
  walletRecommendList: [],
155
399
  userIdentificationCodes: [],
156
400
  transformList: [],
@@ -159,10 +403,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
159
403
  });
160
404
  case 4:
161
405
  if (![1, 0].includes((walletParams === null || walletParams === void 0 ? void 0 : walletParams.customer_id) || 0)) {
162
- _context.next = 6;
406
+ _context3.next = 6;
163
407
  break;
164
408
  }
165
- return _context.abrupt("return", {
409
+ return _context3.abrupt("return", {
166
410
  walletRecommendList: [],
167
411
  userIdentificationCodes: []
168
412
  });
@@ -179,11 +423,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
179
423
  order_wait_pay_amount: businessData.order_wait_pay_amount,
180
424
  products_count: ((_businessData$product = businessData.products) === null || _businessData$product === void 0 ? void 0 : _businessData$product.length) || 0
181
425
  });
182
- _context.prev = 8;
183
- _context.next = 11;
426
+ _context3.prev = 8;
427
+ _context3.next = 11;
184
428
  return this.initializeWalletDataAsync(walletParams);
185
429
  case 11:
186
- result = _context.sent;
430
+ result = _context3.sent;
187
431
  endTime = Date.now();
188
432
  duration = endTime - startTime; // 发送初始化完成事件
189
433
  this.emitEvent(WalletPassHooks.OnWalletInitializationCompleted, {
@@ -198,32 +442,32 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
198
442
  walletRecommendList_count: ((_result$walletRecomme = result.walletRecommendList) === null || _result$walletRecomme === void 0 ? void 0 : _result$walletRecomme.length) || 0,
199
443
  userIdentificationCodes_count: ((_result$userIdentific = result.userIdentificationCodes) === null || _result$userIdentific === void 0 ? void 0 : _result$userIdentific.length) || 0
200
444
  });
201
- return _context.abrupt("return", result);
445
+ return _context3.abrupt("return", result);
202
446
  case 19:
203
- _context.prev = 19;
204
- _context.t0 = _context["catch"](8);
447
+ _context3.prev = 19;
448
+ _context3.t0 = _context3["catch"](8);
205
449
  _endTime = Date.now();
206
450
  _duration = _endTime - startTime; // 发送初始化失败事件
207
451
  this.emitEvent(WalletPassHooks.OnWalletInitializationFailed, {
208
452
  businessData: businessData,
209
- error: _context.t0,
453
+ error: _context3.t0,
210
454
  startTime: startTime,
211
455
  endTime: _endTime,
212
456
  duration: _duration
213
457
  });
214
- this.paymentModule.logError("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25", _context.t0, {
458
+ this.paymentModule.logError("[WalletPass] \u4ECE\u4E1A\u52A1\u6570\u636E\u521D\u59CB\u5316\u94B1\u5305\u6570\u636E\u5931\u8D25", _context3.t0, {
215
459
  duration: "".concat(_duration, "ms"),
216
460
  customer_id: businessData.customer_id,
217
461
  totalAmount: (_businessData$amountI5 = businessData.amountInfo) === null || _businessData$amountI5 === void 0 ? void 0 : _businessData$amountI5.totalAmount
218
462
  });
219
- throw _context.t0;
463
+ throw _context3.t0;
220
464
  case 26:
221
465
  case "end":
222
- return _context.stop();
466
+ return _context3.stop();
223
467
  }
224
- }, _callee, this, [[8, 19]]);
468
+ }, _callee3, this, [[8, 19]]);
225
469
  }));
226
- function initializeWalletDataFromBusinessAsync(_x) {
470
+ function initializeWalletDataFromBusinessAsync(_x3) {
227
471
  return _initializeWalletDataFromBusinessAsync.apply(this, arguments);
228
472
  }
229
473
  return initializeWalletDataFromBusinessAsync;
@@ -235,28 +479,28 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
235
479
  }, {
236
480
  key: "getOrderBasicDetailAsync",
237
481
  value: (function () {
238
- var _getOrderBasicDetailAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(orderId) {
482
+ var _getOrderBasicDetailAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(orderId) {
239
483
  var response;
240
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
241
- while (1) switch (_context2.prev = _context2.next) {
484
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
485
+ while (1) switch (_context4.prev = _context4.next) {
242
486
  case 0:
243
- _context2.prev = 0;
244
- _context2.next = 3;
487
+ _context4.prev = 0;
488
+ _context4.next = 3;
245
489
  return this.paymentModule.request.get("/order/order/".concat(orderId, "/basic-detail"));
246
490
  case 3:
247
- response = _context2.sent;
248
- return _context2.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || {});
491
+ response = _context4.sent;
492
+ return _context4.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || {});
249
493
  case 7:
250
- _context2.prev = 7;
251
- _context2.t0 = _context2["catch"](0);
252
- throw _context2.t0;
494
+ _context4.prev = 7;
495
+ _context4.t0 = _context4["catch"](0);
496
+ throw _context4.t0;
253
497
  case 10:
254
498
  case "end":
255
- return _context2.stop();
499
+ return _context4.stop();
256
500
  }
257
- }, _callee2, this, [[0, 7]]);
501
+ }, _callee4, this, [[0, 7]]);
258
502
  }));
259
- function getOrderBasicDetailAsync(_x2) {
503
+ function getOrderBasicDetailAsync(_x4) {
260
504
  return _getOrderBasicDetailAsync.apply(this, arguments);
261
505
  }
262
506
  return getOrderBasicDetailAsync;
@@ -269,12 +513,12 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
269
513
  }, {
270
514
  key: "initializeWalletDataAsync",
271
515
  value: (function () {
272
- var _initializeWalletDataAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(baseParams) {
273
- var _this$paymentModule$w, _this$paymentModule$w2, identificationParams, _yield$Promise$all, _yield$Promise$all2, allList, orderBasicDetail, walletPassEvaluator, products, res, recommended, transformList, noApplicableVoucher, recommendedAmount;
274
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
275
- while (1) switch (_context3.prev = _context3.next) {
516
+ var _initializeWalletDataAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(baseParams) {
517
+ var _this$paymentModule$w3, _this$paymentModule$w4, identificationParams, _yield$Promise$all, _yield$Promise$all2, allList, orderBasicDetail, walletPassEvaluator, products, res, recommended, transformList, noApplicableVoucher, recommendedAmount;
518
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
519
+ while (1) switch (_context5.prev = _context5.next) {
276
520
  case 0:
277
- _context3.prev = 0;
521
+ _context5.prev = 0;
278
522
  // 格式化用户识别码列表参数
279
523
  identificationParams = _objectSpread(_objectSpread({}, baseParams), {}, {
280
524
  available: 2,
@@ -282,19 +526,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
282
526
  other_exact_codes: [],
283
527
  filter_prepare_wallet_pass: 1
284
528
  }); // 并行获取用户识别码列表和订单详情
285
- _context3.next = 4;
529
+ _context5.next = 4;
286
530
  return Promise.all([this.getUserIdentificationCodeListAsync(identificationParams), baseParams.payment_order_id && typeof baseParams.payment_order_id === 'string' && !baseParams.payment_order_id.startsWith('LOCAL_') ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)]);
287
531
  case 4:
288
- _yield$Promise$all = _context3.sent;
532
+ _yield$Promise$all = _context5.sent;
289
533
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
290
534
  allList = _yield$Promise$all2[0];
291
535
  orderBasicDetail = _yield$Promise$all2[1];
292
- walletPassEvaluator = (_this$paymentModule$w = this.paymentModule.window) === null || _this$paymentModule$w === void 0 || (_this$paymentModule$w2 = _this$paymentModule$w.getWalletPassEvaluator) === null || _this$paymentModule$w2 === void 0 ? void 0 : _this$paymentModule$w2.call(_this$paymentModule$w);
536
+ walletPassEvaluator = (_this$paymentModule$w3 = this.paymentModule.window) === null || _this$paymentModule$w3 === void 0 || (_this$paymentModule$w4 = _this$paymentModule$w3.getWalletPassEvaluator) === null || _this$paymentModule$w4 === void 0 ? void 0 : _this$paymentModule$w4.call(_this$paymentModule$w3);
293
537
  if (walletPassEvaluator) {
294
- _context3.next = 11;
538
+ _context5.next = 11;
295
539
  break;
296
540
  }
297
- return _context3.abrupt("return", {
541
+ return _context5.abrupt("return", {
298
542
  walletRecommendList: [],
299
543
  userIdentificationCodes: [],
300
544
  transformList: [],
@@ -322,7 +566,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
322
566
  // // 再获取用户识别码列表
323
567
  // const userIdentificationCodes =
324
568
  // await this.getUserIdentificationCodeListAsync(identificationParams);
325
- return _context3.abrupt("return", {
569
+ return _context5.abrupt("return", {
326
570
  walletRecommendList: recommended,
327
571
  userIdentificationCodes: allList,
328
572
  transformList: transformList,
@@ -330,20 +574,20 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
330
574
  products: products || []
331
575
  });
332
576
  case 20:
333
- _context3.prev = 20;
334
- _context3.t0 = _context3["catch"](0);
335
- this.paymentModule.logError('[WalletPass] 初始化钱包数据失败', _context3.t0, {
577
+ _context5.prev = 20;
578
+ _context5.t0 = _context5["catch"](0);
579
+ this.paymentModule.logError('[WalletPass] 初始化钱包数据失败', _context5.t0, {
336
580
  customer_id: baseParams.customer_id,
337
581
  order_expect_amount: baseParams.order_expect_amount
338
582
  });
339
- throw _context3.t0;
583
+ throw _context5.t0;
340
584
  case 24:
341
585
  case "end":
342
- return _context3.stop();
586
+ return _context5.stop();
343
587
  }
344
- }, _callee3, this, [[0, 20]]);
588
+ }, _callee5, this, [[0, 20]]);
345
589
  }));
346
- function initializeWalletDataAsync(_x3) {
590
+ function initializeWalletDataAsync(_x5) {
347
591
  return _initializeWalletDataAsync.apply(this, arguments);
348
592
  }
349
593
  return initializeWalletDataAsync;
@@ -351,12 +595,12 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
351
595
  }, {
352
596
  key: "getWalletPassRecommendListAsync",
353
597
  value: function () {
354
- var _getWalletPassRecommendListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
598
+ var _getWalletPassRecommendListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
355
599
  var _this$walletParams, response;
356
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
357
- while (1) switch (_context4.prev = _context4.next) {
600
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
601
+ while (1) switch (_context6.prev = _context6.next) {
358
602
  case 0:
359
- _context4.prev = 0;
603
+ _context6.prev = 0;
360
604
  this.paymentModule.logInfo('[WalletPass] 开始获取钱包推荐列表', {
361
605
  customer_id: params.customer_id,
362
606
  order_expect_amount: params.order_expect_amount,
@@ -366,11 +610,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
366
610
  if (typeof params.payment_order_id === 'string' && params.payment_order_id.startsWith('LOCAL_')) {
367
611
  params.payment_order_id = undefined;
368
612
  }
369
- _context4.next = 5;
613
+ _context6.next = 5;
370
614
  return this.paymentModule.request.post('/machinecode/prepare/deduction/recommend', params // 将 params 作为请求体数据
371
615
  );
372
616
  case 5:
373
- response = _context4.sent;
617
+ response = _context6.sent;
374
618
  this.walletRecommendList = (response === null || response === void 0 ? void 0 : response.data) || [];
375
619
 
376
620
  // 发送钱包推荐列表更新事件(使用专用的WalletPassHooks)
@@ -388,24 +632,24 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
388
632
  };
389
633
  })
390
634
  });
391
- return _context4.abrupt("return", this.walletRecommendList);
635
+ return _context6.abrupt("return", this.walletRecommendList);
392
636
  case 12:
393
- _context4.prev = 12;
394
- _context4.t0 = _context4["catch"](0);
395
- this.paymentModule.logError('[WalletPass] 获取钱包推荐列表失败', _context4.t0, {
637
+ _context6.prev = 12;
638
+ _context6.t0 = _context6["catch"](0);
639
+ this.paymentModule.logError('[WalletPass] 获取钱包推荐列表失败', _context6.t0, {
396
640
  customer_id: params.customer_id,
397
641
  order_expect_amount: params.order_expect_amount,
398
642
  sale_channel: params.sale_channel
399
643
  });
400
644
  // throw error;
401
- return _context4.abrupt("return", []);
645
+ return _context6.abrupt("return", []);
402
646
  case 16:
403
647
  case "end":
404
- return _context4.stop();
648
+ return _context6.stop();
405
649
  }
406
- }, _callee4, this, [[0, 12]]);
650
+ }, _callee6, this, [[0, 12]]);
407
651
  }));
408
- function getWalletPassRecommendListAsync(_x4) {
652
+ function getWalletPassRecommendListAsync(_x6) {
409
653
  return _getWalletPassRecommendListAsync.apply(this, arguments);
410
654
  }
411
655
  return getWalletPassRecommendListAsync;
@@ -418,19 +662,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
418
662
  }, {
419
663
  key: "getUserIdentificationCodeListAsync",
420
664
  value: function () {
421
- var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
665
+ var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
422
666
  var _newParams$products, _newParams$prepare_pa, _this$walletParams2, newParams, response, sortedData;
423
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
424
- while (1) switch (_context5.prev = _context5.next) {
667
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
668
+ while (1) switch (_context7.prev = _context7.next) {
425
669
  case 0:
426
- _context5.prev = 0;
670
+ _context7.prev = 0;
427
671
  newParams = _objectSpread(_objectSpread({}, this.walletParams), params);
428
672
  if ((_newParams$products = newParams.products) !== null && _newParams$products !== void 0 && _newParams$products.length) {
429
- _context5.next = 5;
673
+ _context7.next = 5;
430
674
  break;
431
675
  }
432
676
  this.paymentModule.logInfo('[WalletPass] 商品列表为空,跳过获取用户识别码列表');
433
- return _context5.abrupt("return", []);
677
+ return _context7.abrupt("return", []);
434
678
  case 5:
435
679
  if (typeof newParams.payment_order_id === 'string' && newParams.payment_order_id.startsWith('LOCAL_')) {
436
680
  newParams.payment_order_id = undefined;
@@ -442,10 +686,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
442
686
  filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
443
687
  payment_order_id: (_this$walletParams2 = this.walletParams) === null || _this$walletParams2 === void 0 ? void 0 : _this$walletParams2.payment_order_id
444
688
  });
445
- _context5.next = 9;
689
+ _context7.next = 9;
446
690
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
447
691
  case 9:
448
- response = _context5.sent;
692
+ response = _context7.sent;
449
693
  // 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
450
694
  sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
451
695
  this.userIdentificationCodes = sortedData;
@@ -464,22 +708,22 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
464
708
  };
465
709
  })
466
710
  });
467
- return _context5.abrupt("return", this.userIdentificationCodes);
711
+ return _context7.abrupt("return", this.userIdentificationCodes);
468
712
  case 17:
469
- _context5.prev = 17;
470
- _context5.t0 = _context5["catch"](0);
471
- this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context5.t0, {
713
+ _context7.prev = 17;
714
+ _context7.t0 = _context7["catch"](0);
715
+ this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context7.t0, {
472
716
  customer_id: params.customer_id,
473
717
  available: params.available
474
718
  });
475
- return _context5.abrupt("return", []);
719
+ return _context7.abrupt("return", []);
476
720
  case 21:
477
721
  case "end":
478
- return _context5.stop();
722
+ return _context7.stop();
479
723
  }
480
- }, _callee5, this, [[0, 17]]);
724
+ }, _callee7, this, [[0, 17]]);
481
725
  }));
482
- function getUserIdentificationCodeListAsync(_x5) {
726
+ function getUserIdentificationCodeListAsync(_x7) {
483
727
  return _getUserIdentificationCodeListAsync.apply(this, arguments);
484
728
  }
485
729
  return getUserIdentificationCodeListAsync;
@@ -493,10 +737,21 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
493
737
  }, {
494
738
  key: "searchIdentificationCodeAsync",
495
739
  value: (function () {
496
- var _searchIdentificationCodeAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
740
+ var _searchIdentificationCodeAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
497
741
  var config,
498
- _ref,
499
- _response2,
742
+ _ref10,
743
+ _params$sale_channel,
744
+ _params$customer_id,
745
+ _params$order_expect_,
746
+ _params$order_product,
747
+ _params$order_wait_pa,
748
+ _ref11,
749
+ _ref12,
750
+ _params$order_behavio,
751
+ _ref13,
752
+ _params$products,
753
+ _ref14,
754
+ _params$prepare_payme,
500
755
  code,
501
756
  isWalletCode,
502
757
  walletDetailParams,
@@ -509,12 +764,12 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
509
764
  _this$searchResults,
510
765
  existingCodes,
511
766
  newResults,
512
- _args6 = arguments;
513
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
514
- while (1) switch (_context6.prev = _context6.next) {
767
+ _args8 = arguments;
768
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
769
+ while (1) switch (_context8.prev = _context8.next) {
515
770
  case 0:
516
- config = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
517
- _context6.prev = 1;
771
+ config = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
772
+ _context8.prev = 1;
518
773
  code = params.code;
519
774
  this.paymentModule.logInfo('[WalletPass] 开始搜索识别码', {
520
775
  code: code,
@@ -525,7 +780,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
525
780
  // 新钱包规则
526
781
  isWalletCode = code.startsWith('WL') || code.startsWith('200') && code.length === 10;
527
782
  if (!isWalletCode) {
528
- _context6.next = 14;
783
+ _context8.next = 14;
529
784
  break;
530
785
  }
531
786
  // 钱包识别码直接调用专门接口,不缓存,直接返回
@@ -539,17 +794,17 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
539
794
  with_customer: walletDetailParams.with_customer,
540
795
  with: walletDetailParams.with
541
796
  });
542
- _context6.next = 10;
797
+ _context8.next = 10;
543
798
  return this.paymentModule.request.post('/wallet/detail/search', walletDetailParams);
544
799
  case 10:
545
- _response = _context6.sent;
800
+ _response = _context8.sent;
546
801
  _searchResults = (_response === null || _response === void 0 ? void 0 : _response.data) || [];
547
802
  this.paymentModule.logInfo('[WalletPass] 钱包识别码搜索完成', {
548
803
  code: code,
549
804
  results_count: _searchResults.length,
550
805
  type: 'walletCode'
551
806
  });
552
- return _context6.abrupt("return", {
807
+ return _context8.abrupt("return", {
553
808
  type: 'walletCode',
554
809
  data: _searchResults
555
810
  });
@@ -558,14 +813,14 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
558
813
  baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
559
814
  searchParams = {
560
815
  // 基础钱包参数
561
- sale_channel: params.sale_channel || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel) || 'pos',
562
- customer_id: params.customer_id || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id),
563
- order_expect_amount: params.order_expect_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_expect_amount),
564
- order_product_amount: params.order_product_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_product_amount),
565
- order_wait_pay_amount: params.order_wait_pay_amount || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_wait_pay_amount),
566
- order_behavior_count_customer_id: params.order_behavior_count_customer_id || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_behavior_count_customer_id) || params.customer_id || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id),
567
- products: params.products || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.products),
568
- prepare_payments: params.prepare_payments || (baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.prepare_payments),
816
+ sale_channel: (_ref10 = (_params$sale_channel = params.sale_channel) !== null && _params$sale_channel !== void 0 ? _params$sale_channel : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.sale_channel) !== null && _ref10 !== void 0 ? _ref10 : 'pos',
817
+ customer_id: (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id,
818
+ order_expect_amount: (_params$order_expect_ = params.order_expect_amount) !== null && _params$order_expect_ !== void 0 ? _params$order_expect_ : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_expect_amount,
819
+ order_product_amount: (_params$order_product = params.order_product_amount) !== null && _params$order_product !== void 0 ? _params$order_product : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_product_amount,
820
+ order_wait_pay_amount: (_params$order_wait_pa = params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_wait_pay_amount,
821
+ order_behavior_count_customer_id: (_ref11 = (_ref12 = (_params$order_behavio = params.order_behavior_count_customer_id) !== null && _params$order_behavio !== void 0 ? _params$order_behavio : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.order_behavior_count_customer_id) !== null && _ref12 !== void 0 ? _ref12 : params.customer_id) !== null && _ref11 !== void 0 ? _ref11 : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id,
822
+ products: (_ref13 = (_params$products = params.products) !== null && _params$products !== void 0 ? _params$products : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.products) !== null && _ref13 !== void 0 ? _ref13 : [],
823
+ prepare_payments: (_ref14 = (_params$prepare_payme = params.prepare_payments) !== null && _params$prepare_payme !== void 0 ? _params$prepare_payme : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.prepare_payments) !== null && _ref14 !== void 0 ? _ref14 : [],
569
824
  multiple: 1,
570
825
  // 搜索特有参数
571
826
  code: params.code,
@@ -581,31 +836,20 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
581
836
  if (typeof searchParams.payment_order_id === 'string' && searchParams.payment_order_id.startsWith('LOCAL_')) {
582
837
  searchParams.payment_order_id = undefined;
583
838
  }
584
- if (!(!searchParams.products || ((_ref = searchParams.products || []) === null || _ref === void 0 ? void 0 : _ref.length) === 0)) {
585
- _context6.next = 22;
586
- break;
587
- }
588
- response = {
589
- data: []
590
- };
591
- _context6.next = 25;
592
- break;
593
- case 22:
594
- _context6.next = 24;
839
+ _context8.next = 20;
595
840
  return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
596
- case 24:
597
- response = _context6.sent;
598
- case 25:
599
- searchResults = ((_response2 = response) === null || _response2 === void 0 ? void 0 : _response2.data) || [];
841
+ case 20:
842
+ response = _context8.sent;
843
+ searchResults = (response === null || response === void 0 ? void 0 : response.data) || [];
600
844
  if (!config.noCache) {
601
- _context6.next = 28;
845
+ _context8.next = 24;
602
846
  break;
603
847
  }
604
- return _context6.abrupt("return", {
848
+ return _context8.abrupt("return", {
605
849
  type: 'normalCode',
606
850
  data: searchResults
607
851
  });
608
- case 28:
852
+ case 24:
609
853
  // 将搜索结果存储到缓存数组中
610
854
  if (searchResults.length > 0) {
611
855
  // 避免重复存储相同的识别码
@@ -631,49 +875,348 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
631
875
  cached_results_count: this.searchResults.length,
632
876
  type: 'normalCode'
633
877
  });
634
- return _context6.abrupt("return", {
878
+ return _context8.abrupt("return", {
635
879
  type: 'normalCode',
636
880
  data: searchResults
637
881
  });
638
- case 34:
639
- _context6.prev = 34;
640
- _context6.t0 = _context6["catch"](1);
641
- this.paymentModule.logError('[WalletPass] 搜索识别码信息失败', _context6.t0, {
882
+ case 30:
883
+ _context8.prev = 30;
884
+ _context8.t0 = _context8["catch"](1);
885
+ this.paymentModule.logError('[WalletPass] 搜索识别码信息失败', _context8.t0, {
642
886
  code: params.code,
643
887
  customer_id: params.customer_id,
644
888
  order_expect_amount: params.order_expect_amount
645
889
  });
646
- throw _context6.t0;
647
- case 38:
890
+ throw _context8.t0;
891
+ case 34:
648
892
  case "end":
649
- return _context6.stop();
893
+ return _context8.stop();
650
894
  }
651
- }, _callee6, this, [[1, 34]]);
895
+ }, _callee8, this, [[1, 30]]);
652
896
  }));
653
- function searchIdentificationCodeAsync(_x6) {
897
+ function searchIdentificationCodeAsync(_x8) {
654
898
  return _searchIdentificationCodeAsync.apply(this, arguments);
655
899
  }
656
900
  return searchIdentificationCodeAsync;
901
+ }()
902
+ /**
903
+ * 刷新购物车与结账共享的钱包资产。
904
+ *
905
+ * 与 legacy initializeWalletDataFromBusinessAsync 不同,这里维护选择状态;
906
+ * 推荐结果只作为可用性/金额计算输入,不会自动成为 selectedIds。
907
+ */
908
+ )
909
+ }, {
910
+ key: "refreshWalletAssetsFromBusinessAsync",
911
+ value: (function () {
912
+ var _refreshWalletAssetsFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(businessData) {
913
+ var options,
914
+ requestSequence,
915
+ nextCustomerId,
916
+ previousCustomerId,
917
+ customerChanged,
918
+ preserveSelection,
919
+ committedKeys,
920
+ committedItems,
921
+ selectedIds,
922
+ selectionSources,
923
+ result,
924
+ searchedWalletAssets,
925
+ recommendedKeys,
926
+ items,
927
+ latestSelectedIds,
928
+ latestSelectionSources,
929
+ _args9 = arguments;
930
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
931
+ while (1) switch (_context9.prev = _context9.next) {
932
+ case 0:
933
+ options = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : {};
934
+ requestSequence = ++this.walletAssetsRequestSequence;
935
+ nextCustomerId = businessData.customer_id;
936
+ previousCustomerId = this.walletAssetsState.customerId;
937
+ customerChanged = String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '');
938
+ preserveSelection = options.preserveSelection !== false && !customerChanged;
939
+ if (customerChanged) {
940
+ this.clearSearchResults();
941
+ }
942
+ committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
943
+ return String(id);
944
+ }));
945
+ committedItems = this.walletAssetsState.items.filter(function (item) {
946
+ return committedKeys.has(getWalletAssetKey(item));
947
+ });
948
+ selectedIds = preserveSelection ? _toConsumableArray(this.walletAssetsState.selectedIds) : [];
949
+ selectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {};
950
+ this.publishWalletAssetsState({
951
+ status: 'loading',
952
+ customerId: nextCustomerId,
953
+ items: preserveSelection ? this.walletAssetsState.items : committedItems,
954
+ selectedIds: selectedIds,
955
+ selectedItems: preserveSelection ? this.walletAssetsState.selectedItems : [],
956
+ selectionSources: selectionSources,
957
+ totalSelectedAmount: preserveSelection ? this.walletAssetsState.totalSelectedAmount : 0,
958
+ error: null
959
+ });
960
+ _context9.prev = 12;
961
+ _context9.next = 15;
962
+ return this.initializeWalletDataFromBusinessAsync(businessData);
963
+ case 15:
964
+ result = _context9.sent;
965
+ if (!(requestSequence !== this.walletAssetsRequestSequence)) {
966
+ _context9.next = 18;
967
+ break;
968
+ }
969
+ return _context9.abrupt("return", this.getWalletAssetsState());
970
+ case 18:
971
+ this.walletAssetsCalculationContext = {
972
+ orderTotalAmount: Number(businessData.order_wait_pay_amount || 0),
973
+ products: result.products || businessData.products || []
974
+ };
975
+ if (!preserveSelection) {
976
+ _context9.next = 25;
977
+ break;
978
+ }
979
+ _context9.next = 22;
980
+ return this.revalidateSearchedWalletAssets(requestSequence);
981
+ case 22:
982
+ _context9.t0 = _context9.sent;
983
+ _context9.next = 26;
984
+ break;
985
+ case 25:
986
+ _context9.t0 = [];
987
+ case 26:
988
+ searchedWalletAssets = _context9.t0;
989
+ if (!(requestSequence !== this.walletAssetsRequestSequence)) {
990
+ _context9.next = 29;
991
+ break;
992
+ }
993
+ return _context9.abrupt("return", this.getWalletAssetsState());
994
+ case 29:
995
+ recommendedKeys = new Set((result.walletRecommendList || []).map(function (asset) {
996
+ return getWalletAssetKey(asset);
997
+ }));
998
+ items = mergeWalletAssets(preserveSelection ? this.walletAssetsState.selectedItems : [], searchedWalletAssets, result.transformList || [], result.noApplicableVoucher || []).map(function (asset) {
999
+ return _objectSpread(_objectSpread({}, asset), {}, {
1000
+ _wallet_asset_recommended: recommendedKeys.has(getWalletAssetKey(asset))
1001
+ });
1002
+ });
1003
+ latestSelectedIds = preserveSelection ? _toConsumableArray(this.walletAssetsState.selectedIds) : [];
1004
+ latestSelectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {};
1005
+ return _context9.abrupt("return", this.recalculateWalletAssets(items, latestSelectedIds, latestSelectionSources));
1006
+ case 36:
1007
+ _context9.prev = 36;
1008
+ _context9.t1 = _context9["catch"](12);
1009
+ if (!(requestSequence !== this.walletAssetsRequestSequence)) {
1010
+ _context9.next = 40;
1011
+ break;
1012
+ }
1013
+ return _context9.abrupt("return", this.getWalletAssetsState());
1014
+ case 40:
1015
+ return _context9.abrupt("return", this.publishWalletAssetsState({
1016
+ status: 'error',
1017
+ items: preserveSelection ? this.walletAssetsState.items : committedItems,
1018
+ selectedIds: preserveSelection ? this.walletAssetsState.selectedIds : [],
1019
+ selectedItems: preserveSelection ? this.walletAssetsState.selectedItems : [],
1020
+ selectionSources: preserveSelection ? this.walletAssetsState.selectionSources : {},
1021
+ totalSelectedAmount: preserveSelection ? this.walletAssetsState.totalSelectedAmount : 0,
1022
+ customerId: nextCustomerId,
1023
+ error: _context9.t1 instanceof Error ? _context9.t1.message : String(_context9.t1)
1024
+ }));
1025
+ case 41:
1026
+ case "end":
1027
+ return _context9.stop();
1028
+ }
1029
+ }, _callee9, this, [[12, 36]]);
1030
+ }));
1031
+ function refreshWalletAssetsFromBusinessAsync(_x9) {
1032
+ return _refreshWalletAssetsFromBusinessAsync.apply(this, arguments);
1033
+ }
1034
+ return refreshWalletAssetsFromBusinessAsync;
657
1035
  }())
1036
+ }, {
1037
+ key: "getWalletAssetsState",
1038
+ value: function getWalletAssetsState() {
1039
+ return _objectSpread(_objectSpread({}, this.walletAssetsState), {}, {
1040
+ items: _toConsumableArray(this.walletAssetsState.items),
1041
+ selectedIds: _toConsumableArray(this.walletAssetsState.selectedIds),
1042
+ selectedItems: _toConsumableArray(this.walletAssetsState.selectedItems),
1043
+ committedIds: _toConsumableArray(this.walletAssetsState.committedIds),
1044
+ selectionSources: _objectSpread({}, this.walletAssetsState.selectionSources)
1045
+ });
1046
+ }
1047
+ }, {
1048
+ key: "exportWalletAssetsSnapshot",
1049
+ value: function exportWalletAssetsSnapshot() {
1050
+ return {
1051
+ state: this.getWalletAssetsState(),
1052
+ searchResults: _toConsumableArray(this.searchResults),
1053
+ walletParams: this.walletParams ? _objectSpread({}, this.walletParams) : null,
1054
+ calculationContext: {
1055
+ orderTotalAmount: this.walletAssetsCalculationContext.orderTotalAmount,
1056
+ products: _toConsumableArray(this.walletAssetsCalculationContext.products)
1057
+ }
1058
+ };
1059
+ }
1060
+ }, {
1061
+ key: "importWalletAssetsSnapshot",
1062
+ value: function importWalletAssetsSnapshot(snapshot) {
1063
+ var _snapshot$calculation, _snapshot$calculation2;
1064
+ if (!(snapshot !== null && snapshot !== void 0 && snapshot.state)) return this.getWalletAssetsState();
1065
+ this.walletAssetsRequestSequence += 1;
1066
+ this.searchResults = Array.isArray(snapshot.searchResults) ? _toConsumableArray(snapshot.searchResults) : [];
1067
+ this.walletParams = snapshot.walletParams ? _objectSpread({}, snapshot.walletParams) : null;
1068
+ this.walletAssetsCalculationContext = {
1069
+ orderTotalAmount: Number(((_snapshot$calculation = snapshot.calculationContext) === null || _snapshot$calculation === void 0 ? void 0 : _snapshot$calculation.orderTotalAmount) || 0),
1070
+ products: Array.isArray((_snapshot$calculation2 = snapshot.calculationContext) === null || _snapshot$calculation2 === void 0 ? void 0 : _snapshot$calculation2.products) ? _toConsumableArray(snapshot.calculationContext.products) : []
1071
+ };
1072
+ return this.publishWalletAssetsState(_objectSpread(_objectSpread({}, snapshot.state), {}, {
1073
+ items: Array.isArray(snapshot.state.items) ? snapshot.state.items : [],
1074
+ selectedIds: Array.isArray(snapshot.state.selectedIds) ? snapshot.state.selectedIds : [],
1075
+ selectedItems: Array.isArray(snapshot.state.selectedItems) ? snapshot.state.selectedItems : [],
1076
+ committedIds: Array.isArray(snapshot.state.committedIds) ? snapshot.state.committedIds : [],
1077
+ selectionSources: snapshot.state.selectionSources || {}
1078
+ }));
1079
+ }
1080
+ }, {
1081
+ key: "selectWalletAsset",
1082
+ value: function selectWalletAsset(assetId, options) {
1083
+ var assetKey = String(assetId);
1084
+ var committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
1085
+ return String(id);
1086
+ }));
1087
+ if (committedKeys.has(assetKey)) return this.getWalletAssetsState();
1088
+ var selectedIds = this.walletAssetsState.selectedIds.filter(function (id) {
1089
+ return String(id) !== assetKey;
1090
+ });
1091
+ var selectionSources = _objectSpread({}, this.walletAssetsState.selectionSources);
1092
+ delete selectionSources[assetKey];
1093
+ if (options.selected) {
1094
+ var asset = this.walletAssetsState.items.find(function (item) {
1095
+ return getWalletAssetKey(item) === assetKey;
1096
+ });
1097
+ if (!asset || !isWalletAssetAvailable(asset)) {
1098
+ return this.getWalletAssetsState();
1099
+ }
1100
+ selectedIds.push(assetId);
1101
+ selectionSources[assetKey] = options.source || 'manual';
1102
+ }
1103
+ return this.recalculateWalletAssets(this.walletAssetsState.items, selectedIds, selectionSources);
1104
+ }
1105
+ }, {
1106
+ key: "scanWalletAssetAsync",
1107
+ value: function () {
1108
+ var _scanWalletAssetAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(code) {
1109
+ var normalizedCode, result, paymentAssets, asset, items, assetId, selected;
1110
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1111
+ while (1) switch (_context10.prev = _context10.next) {
1112
+ case 0:
1113
+ normalizedCode = String(code || '').trim();
1114
+ if (normalizedCode) {
1115
+ _context10.next = 3;
1116
+ break;
1117
+ }
1118
+ return _context10.abrupt("return", {
1119
+ type: 'normalCode',
1120
+ selected: false,
1121
+ state: this.getWalletAssetsState()
1122
+ });
1123
+ case 3:
1124
+ this.walletAssetsRequestSequence += 1;
1125
+ _context10.next = 6;
1126
+ return this.searchIdentificationCodeAsync(_objectSpread(_objectSpread({}, this.walletParams || {}), {}, {
1127
+ code: normalizedCode,
1128
+ prepare_payments: this.formatWalletPassList2PreparePayments(this.walletAssetsState.selectedItems)
1129
+ }));
1130
+ case 6:
1131
+ result = _context10.sent;
1132
+ paymentAssets = result.data.filter(isWalletPaymentAsset);
1133
+ asset = paymentAssets.find(function (item) {
1134
+ return String((item === null || item === void 0 ? void 0 : item.code) || '') === normalizedCode;
1135
+ }) || paymentAssets[0];
1136
+ if (!(!asset || result.type === 'walletCode')) {
1137
+ _context10.next = 11;
1138
+ break;
1139
+ }
1140
+ return _context10.abrupt("return", {
1141
+ type: result.type,
1142
+ asset: asset,
1143
+ selected: false,
1144
+ state: this.getWalletAssetsState()
1145
+ });
1146
+ case 11:
1147
+ items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
1148
+ this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
1149
+ assetId = getWalletAssetId(asset);
1150
+ selected = assetId !== undefined && isWalletAssetAvailable(asset) ? this.selectWalletAsset(assetId, {
1151
+ selected: true,
1152
+ source: 'scan'
1153
+ }) : this.getWalletAssetsState();
1154
+ return _context10.abrupt("return", {
1155
+ type: result.type,
1156
+ asset: asset,
1157
+ selected: assetId !== undefined && selected.selectedIds.some(function (id) {
1158
+ return String(id) === String(assetId);
1159
+ }),
1160
+ state: selected
1161
+ });
1162
+ case 16:
1163
+ case "end":
1164
+ return _context10.stop();
1165
+ }
1166
+ }, _callee10, this);
1167
+ }));
1168
+ function scanWalletAssetAsync(_x10) {
1169
+ return _scanWalletAssetAsync.apply(this, arguments);
1170
+ }
1171
+ return scanWalletAssetAsync;
1172
+ }()
1173
+ }, {
1174
+ key: "clearWalletAssetSelection",
1175
+ value: function clearWalletAssetSelection() {
1176
+ return this.recalculateWalletAssets(this.walletAssetsState.items, [], {});
1177
+ }
1178
+ }, {
1179
+ key: "setCommittedWalletAssets",
1180
+ value: function setCommittedWalletAssets(committedIds) {
1181
+ var committedAssets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1182
+ var committedKeys = new Set(committedIds.map(function (id) {
1183
+ return String(id);
1184
+ }));
1185
+ var selectedIds = this.walletAssetsState.selectedIds.filter(function (id) {
1186
+ return !committedKeys.has(String(id));
1187
+ });
1188
+ var selectionSources = Object.entries(this.walletAssetsState.selectionSources).reduce(function (result, _ref15) {
1189
+ var _ref16 = _slicedToArray(_ref15, 2),
1190
+ key = _ref16[0],
1191
+ source = _ref16[1];
1192
+ if (!committedKeys.has(key)) result[key] = source;
1193
+ return result;
1194
+ }, {});
1195
+ this.publishWalletAssetsState({
1196
+ items: mergeWalletAssets(this.walletAssetsState.items, committedAssets),
1197
+ committedIds: committedIds
1198
+ });
1199
+ return this.recalculateWalletAssets(this.walletAssetsState.items, selectedIds, selectionSources);
1200
+ }
658
1201
  }, {
659
1202
  key: "processWalletPayment",
660
1203
  value: function () {
661
- var _processWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(amount, orderUuid, voucherId) {
1204
+ var _processWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(amount, orderUuid, voucherId) {
662
1205
  var walletMethod, paymentItem;
663
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
664
- while (1) switch (_context7.prev = _context7.next) {
1206
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1207
+ while (1) switch (_context11.prev = _context11.next) {
665
1208
  case 0:
666
1209
  this.paymentModule.logInfo('[WalletPass] 开始处理钱包支付', {
667
1210
  amount: amount,
668
1211
  orderUuid: orderUuid,
669
1212
  voucherId: voucherId || 'none'
670
1213
  });
671
- _context7.next = 3;
1214
+ _context11.next = 3;
672
1215
  return this.paymentModule.getWalletPaymentMethod();
673
1216
  case 3:
674
- walletMethod = _context7.sent;
1217
+ walletMethod = _context11.sent;
675
1218
  if (walletMethod) {
676
- _context7.next = 7;
1219
+ _context11.next = 7;
677
1220
  break;
678
1221
  }
679
1222
  this.paymentModule.logError('[WalletPass] 钱包支付方式未找到', null, {
@@ -691,7 +1234,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
691
1234
  type: walletMethod.type,
692
1235
  voucher_id: voucherId || ''
693
1236
  };
694
- _context7.next = 10;
1237
+ _context11.next = 10;
695
1238
  return this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
696
1239
  case 10:
697
1240
  this.paymentModule.logInfo('[WalletPass] 钱包支付处理完成', {
@@ -702,11 +1245,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
702
1245
  });
703
1246
  case 11:
704
1247
  case "end":
705
- return _context7.stop();
1248
+ return _context11.stop();
706
1249
  }
707
- }, _callee7, this);
1250
+ }, _callee11, this);
708
1251
  }));
709
- function processWalletPayment(_x7, _x8, _x9) {
1252
+ function processWalletPayment(_x11, _x12, _x13) {
710
1253
  return _processWalletPayment.apply(this, arguments);
711
1254
  }
712
1255
  return processWalletPayment;
@@ -714,18 +1257,18 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
714
1257
  }, {
715
1258
  key: "getWalletBalance",
716
1259
  value: function () {
717
- var _getWalletBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(voucherId) {
718
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
719
- while (1) switch (_context8.prev = _context8.next) {
1260
+ var _getWalletBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(voucherId) {
1261
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1262
+ while (1) switch (_context12.prev = _context12.next) {
720
1263
  case 0:
721
- return _context8.abrupt("return", 0);
1264
+ return _context12.abrupt("return", 0);
722
1265
  case 1:
723
1266
  case "end":
724
- return _context8.stop();
1267
+ return _context12.stop();
725
1268
  }
726
- }, _callee8);
1269
+ }, _callee12);
727
1270
  }));
728
- function getWalletBalance(_x10) {
1271
+ function getWalletBalance(_x14) {
729
1272
  return _getWalletBalance.apply(this, arguments);
730
1273
  }
731
1274
  return getWalletBalance;
@@ -838,6 +1381,13 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
838
1381
  this.searchResults = [];
839
1382
  this.walletParams = null;
840
1383
  this.walletInitData = null;
1384
+ this.walletAssetsRequestSequence += 1;
1385
+ this.walletAssetsCalculationContext = {
1386
+ orderTotalAmount: 0,
1387
+ products: []
1388
+ };
1389
+ this.walletAssetsState = createInitialWalletAssetsState();
1390
+ this.publishWalletAssetsState({});
841
1391
 
842
1392
  // 发送所有缓存清除事件
843
1393
  this.emitEvent(WalletPassHooks.OnWalletCacheCleared, {