@pisell/pisellos 2.2.276 → 2.2.800

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 (119) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +0 -7
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  4. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  8. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  11. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  12. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  13. package/dist/modules/OpenData/index.d.ts +0 -2
  14. package/dist/modules/OpenData/index.js +0 -8
  15. package/dist/modules/Order/index.d.ts +8 -28
  16. package/dist/modules/Order/index.js +496 -808
  17. package/dist/modules/Order/types.d.ts +1 -35
  18. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  19. package/dist/modules/Order/utils.js +6 -10
  20. package/dist/modules/Payment/index.d.ts +0 -2
  21. package/dist/modules/Payment/index.js +49 -78
  22. package/dist/modules/Payment/types.d.ts +25 -104
  23. package/dist/modules/Payment/types.js +0 -17
  24. package/dist/modules/Payment/walletpass.d.ts +1 -38
  25. package/dist/modules/Payment/walletpass.js +114 -917
  26. package/dist/modules/Rules/index.d.ts +0 -3
  27. package/dist/modules/Rules/index.js +70 -100
  28. package/dist/server/index.d.ts +0 -25
  29. package/dist/server/index.js +1069 -2001
  30. package/dist/server/modules/index.d.ts +1 -1
  31. package/dist/server/modules/order/index.d.ts +4 -70
  32. package/dist/server/modules/order/index.js +728 -1816
  33. package/dist/server/modules/order/types.d.ts +3 -25
  34. package/dist/server/modules/order/types.js +1 -7
  35. package/dist/server/utils/small-ticket.js +2 -1
  36. package/dist/solution/BaseSales/index.d.ts +5 -104
  37. package/dist/solution/BaseSales/index.js +436 -1767
  38. package/dist/solution/BaseSales/types.d.ts +1 -55
  39. package/dist/solution/BaseSales/types.js +1 -2
  40. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  41. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  42. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  43. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -7
  44. package/dist/solution/BookingByStep/index.d.ts +1 -1
  45. package/dist/solution/BookingTicket/index.d.ts +5 -21
  46. package/dist/solution/BookingTicket/index.js +56 -139
  47. package/dist/solution/BookingTicket/types.d.ts +0 -1
  48. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  49. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +83 -173
  50. package/dist/solution/Sales/index.d.ts +0 -2
  51. package/dist/solution/Sales/index.js +4 -26
  52. package/dist/solution/ScanOrder/index.js +20 -31
  53. package/dist/solution/VenueBooking/index.d.ts +0 -1
  54. package/dist/solution/VenueBooking/index.js +19 -30
  55. package/dist/types/index.d.ts +0 -1
  56. package/lib/core/index.d.ts +0 -2
  57. package/lib/core/index.js +0 -4
  58. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  59. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  60. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  61. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  62. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  63. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  64. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  65. package/lib/model/strategy/adapter/promotion/index.js +0 -2
  66. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  67. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  68. package/lib/modules/OpenData/index.d.ts +0 -2
  69. package/lib/modules/OpenData/index.js +0 -5
  70. package/lib/modules/Order/index.d.ts +8 -28
  71. package/lib/modules/Order/index.js +69 -231
  72. package/lib/modules/Order/types.d.ts +1 -35
  73. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  74. package/lib/modules/Order/utils.js +4 -11
  75. package/lib/modules/Payment/index.d.ts +0 -2
  76. package/lib/modules/Payment/index.js +12 -33
  77. package/lib/modules/Payment/types.d.ts +25 -104
  78. package/lib/modules/Payment/types.js +0 -1
  79. package/lib/modules/Payment/walletpass.d.ts +1 -38
  80. package/lib/modules/Payment/walletpass.js +21 -730
  81. package/lib/modules/Rules/index.d.ts +0 -3
  82. package/lib/modules/Rules/index.js +9 -38
  83. package/lib/server/index.d.ts +0 -25
  84. package/lib/server/index.js +31 -726
  85. package/lib/server/modules/index.d.ts +1 -1
  86. package/lib/server/modules/order/index.d.ts +4 -70
  87. package/lib/server/modules/order/index.js +69 -818
  88. package/lib/server/modules/order/types.d.ts +3 -25
  89. package/lib/server/modules/order/types.js +0 -1
  90. package/lib/server/utils/small-ticket.js +1 -1
  91. package/lib/solution/BaseSales/index.d.ts +5 -104
  92. package/lib/solution/BaseSales/index.js +27 -858
  93. package/lib/solution/BaseSales/types.d.ts +1 -55
  94. package/lib/solution/BaseSales/types.js +1 -2
  95. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  96. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  97. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  98. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -4
  99. package/lib/solution/BookingByStep/index.d.ts +1 -1
  100. package/lib/solution/BookingTicket/index.d.ts +5 -21
  101. package/lib/solution/BookingTicket/index.js +13 -64
  102. package/lib/solution/BookingTicket/types.d.ts +0 -1
  103. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  104. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +5 -37
  105. package/lib/solution/Sales/index.d.ts +0 -2
  106. package/lib/solution/Sales/index.js +6 -20
  107. package/lib/solution/ScanOrder/index.js +0 -8
  108. package/lib/solution/VenueBooking/index.d.ts +0 -1
  109. package/lib/solution/VenueBooking/index.js +0 -8
  110. package/lib/types/index.d.ts +0 -1
  111. package/package.json +1 -1
  112. package/dist/modules/Order/payment-utils.d.ts +0 -26
  113. package/dist/modules/Order/payment-utils.js +0 -225
  114. package/dist/utils/payment-number.d.ts +0 -9
  115. package/dist/utils/payment-number.js +0 -69
  116. package/lib/modules/Order/payment-utils.d.ts +0 -26
  117. package/lib/modules/Order/payment-utils.js +0 -224
  118. package/lib/utils/payment-number.d.ts +0 -9
  119. package/lib/utils/payment-number.js +0 -64
@@ -1,99 +1,27 @@
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; }
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); }
8
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
3
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
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); }
11
4
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
5
  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); }
13
9
  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); }); }; }
14
17
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
18
  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); } }
16
19
  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; }
19
20
  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; }
20
21
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
21
22
  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 matchesWalletAssetCode(asset, normalizedCode) {
38
- return [asset === null || asset === void 0 ? void 0 : asset.code, asset === null || asset === void 0 ? void 0 : asset.encoded].some(function (identifier) {
39
- return String(identifier !== null && identifier !== void 0 ? identifier : '').trim() === normalizedCode;
40
- });
41
- }
42
- function normalizeWalletAssetCode(code) {
43
- return String(code !== null && code !== void 0 ? code : '').trim().toUpperCase();
44
- }
45
- function getWalletAssetCodeKeys(asset) {
46
- return [asset === null || asset === void 0 ? void 0 : asset.code, asset === null || asset === void 0 ? void 0 : asset.encoded].map(normalizeWalletAssetCode).filter(Boolean);
47
- }
48
- function isWalletAssetAvailable(asset) {
49
- if (!asset) return false;
50
- if (asset.unified_available_status !== undefined && Number(asset.unified_available_status) !== 1) {
51
- return false;
52
- }
53
- if (asset._unified_available_status !== undefined && Number(asset._unified_available_status) !== 1) {
54
- return false;
55
- }
56
- if (asset.available === false || asset.isDisabled === true) return false;
57
- return true;
58
- }
59
- function getWalletAssetDeductionAmount(asset) {
60
- var _ref2, _ref3, _ref4, _ref5, _ref6, _asset$actualDeductio;
61
- 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;
62
- var amount = Number(value);
63
- return Number.isFinite(amount) && amount > 0 ? amount : 0;
64
- }
65
- function mergeWalletAssets() {
66
- var merged = [];
67
- var indexByKey = new Map();
68
- for (var _len = arguments.length, groups = new Array(_len), _key = 0; _key < _len; _key++) {
69
- groups[_key] = arguments[_key];
70
- }
71
- groups.flat().forEach(function (asset) {
72
- var key = getWalletAssetKey(asset);
73
- if (!key) return;
74
- var existedIndex = indexByKey.get(key);
75
- if (existedIndex === undefined) {
76
- indexByKey.set(key, merged.length);
77
- merged.push(asset);
78
- return;
79
- }
80
- merged[existedIndex] = _objectSpread(_objectSpread({}, merged[existedIndex]), asset);
81
- });
82
- return merged;
83
- }
84
- function createInitialWalletAssetsState() {
85
- return {
86
- status: 'idle',
87
- items: [],
88
- selectedIds: [],
89
- selectedItems: [],
90
- committedIds: [],
91
- selectionSources: {},
92
- totalSelectedAmount: 0,
93
- error: null,
94
- revision: 0
95
- };
96
- }
97
25
 
98
26
  /**
99
27
  * 钱包支付实现
@@ -106,33 +34,14 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
106
34
  _defineProperty(this, "searchResults", []);
107
35
  _defineProperty(this, "walletParams", null);
108
36
  _defineProperty(this, "walletInitData", null);
109
- _defineProperty(this, "walletAssetsState", createInitialWalletAssetsState());
110
- _defineProperty(this, "walletAssetsRequestSequence", 0);
111
- _defineProperty(this, "walletAssetsBehavior", {
112
- autoSelectAfterSearch: true
113
- });
114
- _defineProperty(this, "pendingAutoSelectSearchCodes", new Set());
115
- _defineProperty(this, "walletAssetsCalculationContext", {
116
- orderTotalAmount: 0,
117
- products: []
118
- });
119
37
  this.paymentModule = paymentModule;
120
38
  }
121
- _createClass(WalletPassPaymentImpl, [{
122
- key: "configureWalletAssetsBehavior",
123
- value: function configureWalletAssetsBehavior(options) {
124
- if (options.autoSelectAfterSearch === undefined) return;
125
- this.walletAssetsBehavior.autoSelectAfterSearch = options.autoSelectAfterSearch;
126
- if (!options.autoSelectAfterSearch) {
127
- this.pendingAutoSelectSearchCodes.clear();
128
- }
129
- }
130
39
 
131
- /**
132
- * 发送事件的辅助方法
133
- * 支持使用WalletPassHooks或PaymentHooks
134
- */
135
- }, {
40
+ /**
41
+ * 发送事件的辅助方法
42
+ * 支持使用WalletPassHooks或PaymentHooks
43
+ */
44
+ _createClass(WalletPassPaymentImpl, [{
136
45
  key: "emitEvent",
137
46
  value: function emitEvent(hook, data) {
138
47
  try {
@@ -146,156 +55,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
146
55
  });
147
56
  }
148
57
  }
149
- }, {
150
- key: "publishWalletAssetsState",
151
- value: function publishWalletAssetsState(patch) {
152
- var _patch$items, _patch$selectedIds, _patch$selectedItems, _patch$committedIds, _patch$selectionSourc;
153
- this.walletAssetsState = _objectSpread(_objectSpread(_objectSpread({}, this.walletAssetsState), patch), {}, {
154
- items: _toConsumableArray((_patch$items = patch.items) !== null && _patch$items !== void 0 ? _patch$items : this.walletAssetsState.items),
155
- selectedIds: _toConsumableArray((_patch$selectedIds = patch.selectedIds) !== null && _patch$selectedIds !== void 0 ? _patch$selectedIds : this.walletAssetsState.selectedIds),
156
- selectedItems: _toConsumableArray((_patch$selectedItems = patch.selectedItems) !== null && _patch$selectedItems !== void 0 ? _patch$selectedItems : this.walletAssetsState.selectedItems),
157
- committedIds: _toConsumableArray((_patch$committedIds = patch.committedIds) !== null && _patch$committedIds !== void 0 ? _patch$committedIds : this.walletAssetsState.committedIds),
158
- selectionSources: _objectSpread({}, (_patch$selectionSourc = patch.selectionSources) !== null && _patch$selectionSourc !== void 0 ? _patch$selectionSourc : this.walletAssetsState.selectionSources),
159
- revision: this.walletAssetsState.revision + 1
160
- });
161
- var state = this.getWalletAssetsState();
162
- this.emitEvent(WalletPassHooks.OnWalletAssetsStateChanged, {
163
- state: state
164
- });
165
- return state;
166
- }
167
- }, {
168
- key: "recalculateWalletAssets",
169
- value: function recalculateWalletAssets(items, requestedIds, selectionSources) {
170
- var _this$paymentModule$w, _this$paymentModule$w2;
171
- var committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
172
- return String(id);
173
- }));
174
- var itemsByKey = new Map(items.map(function (item) {
175
- return [getWalletAssetKey(item), item];
176
- }));
177
- var requested = requestedIds.map(function (id) {
178
- return String(id);
179
- }).filter(function (id) {
180
- return !committedKeys.has(id);
181
- }).map(function (id) {
182
- return itemsByKey.get(id);
183
- }).filter(function (item) {
184
- return item && isWalletAssetAvailable(item);
185
- });
186
- var nextItems = items;
187
- var selectedItems = requested;
188
- 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);
189
- if (evaluator !== null && evaluator !== void 0 && evaluator.recalculateVouchers) {
190
- try {
191
- var result = evaluator.recalculateVouchers(items, requested, this.walletAssetsCalculationContext.orderTotalAmount, this.walletAssetsCalculationContext.products);
192
- nextItems = mergeWalletAssets(items, (result === null || result === void 0 ? void 0 : result.allWithUpdatedStatus) || []);
193
- selectedItems = ((result === null || result === void 0 ? void 0 : result.selectedWithDetails) || []).filter(function (item) {
194
- return isWalletAssetAvailable(item) && getWalletAssetDeductionAmount(item) > 0;
195
- });
196
- } catch (error) {
197
- this.paymentModule.logWarning('[WalletPass] 共享钱包资产重新计算失败,回退接口可用状态', {
198
- error: error instanceof Error ? error.message : String(error)
199
- });
200
- }
201
- }
202
- var selectedIds = selectedItems.map(function (item) {
203
- return getWalletAssetId(item);
204
- }).filter(function (id) {
205
- return id !== undefined && id !== null;
206
- });
207
- var selectedKeys = new Set(selectedIds.map(function (id) {
208
- return String(id);
209
- }));
210
- var nextSources = Object.entries(selectionSources).reduce(function (result, _ref7) {
211
- var _ref8 = _slicedToArray(_ref7, 2),
212
- key = _ref8[0],
213
- source = _ref8[1];
214
- if (selectedKeys.has(key)) result[key] = source;
215
- return result;
216
- }, {});
217
- var totalSelectedAmount = selectedItems.reduce(function (total, item) {
218
- return total + getWalletAssetDeductionAmount(item);
219
- }, 0);
220
- return this.publishWalletAssetsState({
221
- status: 'ready',
222
- items: nextItems,
223
- selectedIds: selectedIds,
224
- selectedItems: selectedItems,
225
- selectionSources: nextSources,
226
- totalSelectedAmount: totalSelectedAmount,
227
- error: null
228
- });
229
- }
230
-
231
- /** 获取当前缓存中所有支付类 Wallet 资产的扫码 code。 */
232
- }, {
233
- key: "getSearchedWalletAssetCodes",
234
- value: function getSearchedWalletAssetCodes() {
235
- var cachedAssets = this.searchResults.filter(isWalletPaymentAsset);
236
- var seenCodes = new Set();
237
- return cachedAssets.map(function (item) {
238
- return String((item === null || item === void 0 ? void 0 : item.code) || '').trim();
239
- }).filter(function (code) {
240
- var normalizedCode = code.toUpperCase();
241
- if (!normalizedCode || seenCodes.has(normalizedCode)) return false;
242
- seenCodes.add(normalizedCode);
243
- return true;
244
- });
245
- }
246
-
247
- /**
248
- * 用订单重算接口返回的数据更新扫码 Wallet 缓存。
249
- * 接口暂时缺失某个扫码 code 时继续保留旧值,避免列表闪空。
250
- */
251
- }, {
252
- key: "syncSearchedWalletAssets",
253
- value: function syncSearchedWalletAssets(refreshedCandidates) {
254
- var cachedAssets = this.searchResults.filter(isWalletPaymentAsset);
255
- var searchedCodeKeys = new Set(this.getSearchedWalletAssetCodes().map(function (code) {
256
- return code.toUpperCase();
257
- }));
258
- if (searchedCodeKeys.size === 0) return cachedAssets;
259
- var refreshedAssets = refreshedCandidates.filter(function (item) {
260
- return isWalletPaymentAsset(item) && searchedCodeKeys.has(String((item === null || item === void 0 ? void 0 : item.code) || '').trim().toUpperCase());
261
- });
262
- if (refreshedAssets.length > 0) {
263
- var replacedCodes = new Set(refreshedAssets.map(function (item) {
264
- return String((item === null || item === void 0 ? void 0 : item.code) || '').trim().toUpperCase();
265
- }));
266
- this.searchResults = [].concat(_toConsumableArray(this.searchResults.filter(function (item) {
267
- return !replacedCodes.has(String((item === null || item === void 0 ? void 0 : item.code) || '').trim().toUpperCase());
268
- })), _toConsumableArray(refreshedAssets));
269
- }
270
- return mergeWalletAssets(cachedAssets, refreshedAssets);
271
- }
272
- }, {
273
- key: "isPendingAutoSelectAsset",
274
- value: function isPendingAutoSelectAsset(asset) {
275
- var _this = this;
276
- return getWalletAssetCodeKeys(asset).some(function (code) {
277
- return _this.pendingAutoSelectSearchCodes.has(code);
278
- });
279
- }
280
- }, {
281
- key: "clearPendingAutoSelectForAsset",
282
- value: function clearPendingAutoSelectForAsset(asset) {
283
- var _this2 = this;
284
- getWalletAssetCodeKeys(asset).forEach(function (code) {
285
- _this2.pendingAutoSelectSearchCodes.delete(code);
286
- });
287
- }
288
- }, {
289
- key: "queuePendingAutoSelectForAssets",
290
- value: function queuePendingAutoSelectForAssets(assets) {
291
- var _this3 = this;
292
- if (!this.walletAssetsBehavior.autoSelectAfterSearch) return;
293
- assets.forEach(function (asset) {
294
- getWalletAssetCodeKeys(asset).forEach(function (code) {
295
- _this3.pendingAutoSelectSearchCodes.add(code);
296
- });
297
- });
298
- }
299
58
 
300
59
  /**
301
60
  * 生成钱包API默认参数
@@ -326,7 +85,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
326
85
  // 订单小计金额
327
86
  order_product_amount: subTotal,
328
87
  // 订单待支付金额
329
- 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,
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),
330
89
  // order_behavior_count_customer_id: 1,
331
90
  products: products,
332
91
  prepare_payments: [],
@@ -511,7 +270,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
511
270
  key: "initializeWalletDataAsync",
512
271
  value: (function () {
513
272
  var _initializeWalletDataAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(baseParams) {
514
- var _this$paymentModule$w3, _this$paymentModule$w4, identificationParams, _yield$Promise$all, _yield$Promise$all2, allList, orderBasicDetail, walletPassEvaluator, products, res, recommended, transformList, noApplicableVoucher, recommendedAmount;
273
+ var _this$paymentModule$w, _this$paymentModule$w2, identificationParams, _yield$Promise$all, _yield$Promise$all2, allList, orderBasicDetail, walletPassEvaluator, products, res, recommended, transformList, noApplicableVoucher, recommendedAmount;
515
274
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
516
275
  while (1) switch (_context3.prev = _context3.next) {
517
276
  case 0:
@@ -530,7 +289,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
530
289
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
531
290
  allList = _yield$Promise$all2[0];
532
291
  orderBasicDetail = _yield$Promise$all2[1];
533
- 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);
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);
534
293
  if (walletPassEvaluator) {
535
294
  _context3.next = 11;
536
295
  break;
@@ -588,115 +347,16 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
588
347
  return _initializeWalletDataAsync.apply(this, arguments);
589
348
  }
590
349
  return initializeWalletDataAsync;
591
- }()
592
- /**
593
- * 商品或订单金额变化后,使用聚合接口一次重算已选与剩余 WalletPass。
594
- * Walk-In 不发送 customer_id;会员才携带真实 customer_id。
595
- */
596
- )
597
- }, {
598
- key: "aggregateRecalculateWalletAssetsAsync",
599
- value: (function () {
600
- var _aggregateRecalculateWalletAssetsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(businessData, selectedIds) {
601
- var _this$paymentModule$w5, _this$paymentModule$w6;
602
- var walletParams, customerId, requestParams, response, responseData, hasAggregateLists, recalculateList, customerWalletPassList, allList, walletPassEvaluator, evaluated, returnedSelectedKeys, authoritativeSelectedIds;
603
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
604
- while (1) switch (_context4.prev = _context4.next) {
605
- case 0:
606
- walletParams = this.generateWalletParams(businessData);
607
- customerId = Number(walletParams.customer_id || 0);
608
- requestParams = {
609
- ids: selectedIds.map(function (id) {
610
- return String(id);
611
- }),
612
- exact_codes: this.getSearchedWalletAssetCodes(),
613
- order_product_amount: walletParams.order_product_amount,
614
- order_expect_amount: walletParams.order_expect_amount,
615
- order_wait_pay_amount: walletParams.order_wait_pay_amount,
616
- products: walletParams.products,
617
- available: 2,
618
- filter_prepare_wallet_pass: 1,
619
- sale_channel: walletParams.sale_channel || 'pos'
620
- };
621
- if (customerId > 1) {
622
- requestParams.customer_id = customerId;
623
- }
624
- _context4.next = 6;
625
- return this.paymentModule.request.post('/machinecode/prepare/deduction/aggregate-recalculate', requestParams);
626
- case 6:
627
- response = _context4.sent;
628
- responseData = response === null || response === void 0 ? void 0 : response.data;
629
- hasAggregateLists = responseData && (Object.prototype.hasOwnProperty.call(responseData, 'recalculate_list') || Object.prototype.hasOwnProperty.call(responseData, 'customer_wallet_pass_list'));
630
- if (hasAggregateLists) {
631
- _context4.next = 11;
632
- break;
633
- }
634
- throw new Error('WalletPass aggregate response is missing list data');
635
- case 11:
636
- recalculateList = Array.isArray(responseData === null || responseData === void 0 ? void 0 : responseData.recalculate_list) ? responseData.recalculate_list : [];
637
- customerWalletPassList = Array.isArray(responseData === null || responseData === void 0 ? void 0 : responseData.customer_wallet_pass_list) ? responseData.customer_wallet_pass_list : [];
638
- allList = mergeWalletAssets(recalculateList, customerWalletPassList);
639
- walletPassEvaluator = (_this$paymentModule$w5 = this.paymentModule.window) === null || _this$paymentModule$w5 === void 0 || (_this$paymentModule$w6 = _this$paymentModule$w5.getWalletPassEvaluator) === null || _this$paymentModule$w6 === void 0 ? void 0 : _this$paymentModule$w6.call(_this$paymentModule$w5);
640
- evaluated = walletPassEvaluator !== null && walletPassEvaluator !== void 0 && walletPassEvaluator.getRecommendedVouchers ? walletPassEvaluator.getRecommendedVouchers({
641
- orderTotalAmount: walletParams.order_wait_pay_amount,
642
- products: walletParams.products,
643
- vouchers: allList
644
- }) : {
645
- recommended: [],
646
- transformList: allList.filter(isWalletAssetAvailable),
647
- noApplicableVoucher: allList.filter(function (item) {
648
- return !isWalletAssetAvailable(item);
649
- })
650
- };
651
- returnedSelectedKeys = new Set(recalculateList.filter(isWalletAssetAvailable).map(function (item) {
652
- return getWalletAssetKey(item);
653
- }));
654
- authoritativeSelectedIds = selectedIds.filter(function (id) {
655
- return returnedSelectedKeys.has(String(id));
656
- });
657
- this.walletRecommendList = evaluated.recommended || [];
658
- this.userIdentificationCodes = allList;
659
- this.emitEvent(WalletPassHooks.OnUserIdentificationCodesUpdated, {
660
- userIdentificationCodes: this.userIdentificationCodes
661
- });
662
- this.walletInitData = {
663
- transformList: evaluated.transformList || [],
664
- noApplicableVoucher: evaluated.noApplicableVoucher || [],
665
- products: walletParams.products || []
666
- };
667
- this.paymentModule.logInfo('[WalletPass] 聚合重算 WalletPass 完成', {
668
- selected_count: recalculateList.length,
669
- remaining_count: customerWalletPassList.length,
670
- searched_codes_count: requestParams.exact_codes.length
671
- });
672
- return _context4.abrupt("return", {
673
- walletRecommendList: this.walletRecommendList,
674
- userIdentificationCodes: this.userIdentificationCodes,
675
- transformList: evaluated.transformList || [],
676
- noApplicableVoucher: evaluated.noApplicableVoucher || [],
677
- products: walletParams.products || [],
678
- authoritativeSelectedIds: authoritativeSelectedIds
679
- });
680
- case 24:
681
- case "end":
682
- return _context4.stop();
683
- }
684
- }, _callee4, this);
685
- }));
686
- function aggregateRecalculateWalletAssetsAsync(_x4, _x5) {
687
- return _aggregateRecalculateWalletAssetsAsync.apply(this, arguments);
688
- }
689
- return aggregateRecalculateWalletAssetsAsync;
690
350
  }())
691
351
  }, {
692
352
  key: "getWalletPassRecommendListAsync",
693
353
  value: function () {
694
- var _getWalletPassRecommendListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
354
+ var _getWalletPassRecommendListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
695
355
  var _this$walletParams, response;
696
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
697
- while (1) switch (_context5.prev = _context5.next) {
356
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
357
+ while (1) switch (_context4.prev = _context4.next) {
698
358
  case 0:
699
- _context5.prev = 0;
359
+ _context4.prev = 0;
700
360
  this.paymentModule.logInfo('[WalletPass] 开始获取钱包推荐列表', {
701
361
  customer_id: params.customer_id,
702
362
  order_expect_amount: params.order_expect_amount,
@@ -706,11 +366,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
706
366
  if (typeof params.payment_order_id === 'string' && params.payment_order_id.startsWith('LOCAL_')) {
707
367
  params.payment_order_id = undefined;
708
368
  }
709
- _context5.next = 5;
369
+ _context4.next = 5;
710
370
  return this.paymentModule.request.post('/machinecode/prepare/deduction/recommend', params // 将 params 作为请求体数据
711
371
  );
712
372
  case 5:
713
- response = _context5.sent;
373
+ response = _context4.sent;
714
374
  this.walletRecommendList = (response === null || response === void 0 ? void 0 : response.data) || [];
715
375
 
716
376
  // 发送钱包推荐列表更新事件(使用专用的WalletPassHooks)
@@ -728,24 +388,24 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
728
388
  };
729
389
  })
730
390
  });
731
- return _context5.abrupt("return", this.walletRecommendList);
391
+ return _context4.abrupt("return", this.walletRecommendList);
732
392
  case 12:
733
- _context5.prev = 12;
734
- _context5.t0 = _context5["catch"](0);
735
- this.paymentModule.logError('[WalletPass] 获取钱包推荐列表失败', _context5.t0, {
393
+ _context4.prev = 12;
394
+ _context4.t0 = _context4["catch"](0);
395
+ this.paymentModule.logError('[WalletPass] 获取钱包推荐列表失败', _context4.t0, {
736
396
  customer_id: params.customer_id,
737
397
  order_expect_amount: params.order_expect_amount,
738
398
  sale_channel: params.sale_channel
739
399
  });
740
400
  // throw error;
741
- return _context5.abrupt("return", []);
401
+ return _context4.abrupt("return", []);
742
402
  case 16:
743
403
  case "end":
744
- return _context5.stop();
404
+ return _context4.stop();
745
405
  }
746
- }, _callee5, this, [[0, 12]]);
406
+ }, _callee4, this, [[0, 12]]);
747
407
  }));
748
- function getWalletPassRecommendListAsync(_x6) {
408
+ function getWalletPassRecommendListAsync(_x4) {
749
409
  return _getWalletPassRecommendListAsync.apply(this, arguments);
750
410
  }
751
411
  return getWalletPassRecommendListAsync;
@@ -758,19 +418,19 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
758
418
  }, {
759
419
  key: "getUserIdentificationCodeListAsync",
760
420
  value: function () {
761
- var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
421
+ var _getUserIdentificationCodeListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
762
422
  var _newParams$products, _newParams$prepare_pa, _this$walletParams2, newParams, response, sortedData;
763
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
764
- while (1) switch (_context6.prev = _context6.next) {
423
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
424
+ while (1) switch (_context5.prev = _context5.next) {
765
425
  case 0:
766
- _context6.prev = 0;
426
+ _context5.prev = 0;
767
427
  newParams = _objectSpread(_objectSpread({}, this.walletParams), params);
768
428
  if ((_newParams$products = newParams.products) !== null && _newParams$products !== void 0 && _newParams$products.length) {
769
- _context6.next = 5;
429
+ _context5.next = 5;
770
430
  break;
771
431
  }
772
432
  this.paymentModule.logInfo('[WalletPass] 商品列表为空,跳过获取用户识别码列表');
773
- return _context6.abrupt("return", []);
433
+ return _context5.abrupt("return", []);
774
434
  case 5:
775
435
  if (typeof newParams.payment_order_id === 'string' && newParams.payment_order_id.startsWith('LOCAL_')) {
776
436
  newParams.payment_order_id = undefined;
@@ -782,10 +442,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
782
442
  filter_prepare_wallet_pass: newParams.filter_prepare_wallet_pass,
783
443
  payment_order_id: (_this$walletParams2 = this.walletParams) === null || _this$walletParams2 === void 0 ? void 0 : _this$walletParams2.payment_order_id
784
444
  });
785
- _context6.next = 9;
445
+ _context5.next = 9;
786
446
  return this.paymentModule.request.post('/machinecode/prepare/deduction', newParams);
787
447
  case 9:
788
- response = _context6.sent;
448
+ response = _context5.sent;
789
449
  // 对获取到的数据进行排序,将错误码为 500100、500200、500300 的项目排到最后
790
450
  sortedData = sortUserIdentificationCodeList((response === null || response === void 0 ? void 0 : response.data) || []);
791
451
  this.userIdentificationCodes = sortedData;
@@ -804,22 +464,22 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
804
464
  };
805
465
  })
806
466
  });
807
- return _context6.abrupt("return", this.userIdentificationCodes);
467
+ return _context5.abrupt("return", this.userIdentificationCodes);
808
468
  case 17:
809
- _context6.prev = 17;
810
- _context6.t0 = _context6["catch"](0);
811
- this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context6.t0, {
469
+ _context5.prev = 17;
470
+ _context5.t0 = _context5["catch"](0);
471
+ this.paymentModule.logError('[WalletPass] 获取用户识别码列表失败', _context5.t0, {
812
472
  customer_id: params.customer_id,
813
473
  available: params.available
814
474
  });
815
- return _context6.abrupt("return", []);
475
+ return _context5.abrupt("return", []);
816
476
  case 21:
817
477
  case "end":
818
- return _context6.stop();
478
+ return _context5.stop();
819
479
  }
820
- }, _callee6, this, [[0, 17]]);
480
+ }, _callee5, this, [[0, 17]]);
821
481
  }));
822
- function getUserIdentificationCodeListAsync(_x7) {
482
+ function getUserIdentificationCodeListAsync(_x5) {
823
483
  return _getUserIdentificationCodeListAsync.apply(this, arguments);
824
484
  }
825
485
  return getUserIdentificationCodeListAsync;
@@ -833,21 +493,10 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
833
493
  }, {
834
494
  key: "searchIdentificationCodeAsync",
835
495
  value: (function () {
836
- var _searchIdentificationCodeAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
496
+ var _searchIdentificationCodeAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
837
497
  var config,
838
- _ref9,
839
- _params$sale_channel,
840
- _params$customer_id,
841
- _params$order_expect_,
842
- _params$order_product,
843
- _params$order_wait_pa,
844
- _ref10,
845
- _ref11,
846
- _params$order_behavio,
847
- _ref12,
848
- _params$products,
849
- _ref13,
850
- _params$prepare_payme,
498
+ _ref,
499
+ _response2,
851
500
  code,
852
501
  isWalletCode,
853
502
  walletDetailParams,
@@ -860,12 +509,12 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
860
509
  _this$searchResults,
861
510
  existingCodes,
862
511
  newResults,
863
- _args7 = arguments;
864
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
865
- while (1) switch (_context7.prev = _context7.next) {
512
+ _args6 = arguments;
513
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
514
+ while (1) switch (_context6.prev = _context6.next) {
866
515
  case 0:
867
- config = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
868
- _context7.prev = 1;
516
+ config = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
517
+ _context6.prev = 1;
869
518
  code = params.code;
870
519
  this.paymentModule.logInfo('[WalletPass] 开始搜索识别码', {
871
520
  code: code,
@@ -876,7 +525,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
876
525
  // 新钱包规则
877
526
  isWalletCode = code.startsWith('WL') || code.startsWith('200') && code.length === 10;
878
527
  if (!isWalletCode) {
879
- _context7.next = 14;
528
+ _context6.next = 14;
880
529
  break;
881
530
  }
882
531
  // 钱包识别码直接调用专门接口,不缓存,直接返回
@@ -890,17 +539,17 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
890
539
  with_customer: walletDetailParams.with_customer,
891
540
  with: walletDetailParams.with
892
541
  });
893
- _context7.next = 10;
542
+ _context6.next = 10;
894
543
  return this.paymentModule.request.post('/wallet/detail/search', walletDetailParams);
895
544
  case 10:
896
- _response = _context7.sent;
545
+ _response = _context6.sent;
897
546
  _searchResults = (_response === null || _response === void 0 ? void 0 : _response.data) || [];
898
547
  this.paymentModule.logInfo('[WalletPass] 钱包识别码搜索完成', {
899
548
  code: code,
900
549
  results_count: _searchResults.length,
901
550
  type: 'walletCode'
902
551
  });
903
- return _context7.abrupt("return", {
552
+ return _context6.abrupt("return", {
904
553
  type: 'walletCode',
905
554
  data: _searchResults
906
555
  });
@@ -909,14 +558,14 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
909
558
  baseWalletParams = this.walletParams; // 构建完整的搜索参数,包含钱包扣款推荐的所有参数
910
559
  searchParams = {
911
560
  // 基础钱包参数
912
- sale_channel: (_ref9 = (_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 && _ref9 !== void 0 ? _ref9 : 'pos',
913
- 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,
914
- 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,
915
- 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,
916
- 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,
917
- order_behavior_count_customer_id: (_ref10 = (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : params.customer_id) !== null && _ref10 !== void 0 ? _ref10 : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.customer_id,
918
- products: (_ref12 = (_params$products = params.products) !== null && _params$products !== void 0 ? _params$products : baseWalletParams === null || baseWalletParams === void 0 ? void 0 : baseWalletParams.products) !== null && _ref12 !== void 0 ? _ref12 : [],
919
- prepare_payments: (_ref13 = (_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 && _ref13 !== void 0 ? _ref13 : [],
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),
920
569
  multiple: 1,
921
570
  // 搜索特有参数
922
571
  code: params.code,
@@ -932,20 +581,31 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
932
581
  if (typeof searchParams.payment_order_id === 'string' && searchParams.payment_order_id.startsWith('LOCAL_')) {
933
582
  searchParams.payment_order_id = undefined;
934
583
  }
935
- _context7.next = 20;
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;
936
595
  return this.paymentModule.request.post('/machinecode/prepare/deduction/search', searchParams);
937
- case 20:
938
- response = _context7.sent;
939
- searchResults = (response === null || response === void 0 ? void 0 : response.data) || [];
596
+ case 24:
597
+ response = _context6.sent;
598
+ case 25:
599
+ searchResults = ((_response2 = response) === null || _response2 === void 0 ? void 0 : _response2.data) || [];
940
600
  if (!config.noCache) {
941
- _context7.next = 24;
601
+ _context6.next = 28;
942
602
  break;
943
603
  }
944
- return _context7.abrupt("return", {
604
+ return _context6.abrupt("return", {
945
605
  type: 'normalCode',
946
606
  data: searchResults
947
607
  });
948
- case 24:
608
+ case 28:
949
609
  // 将搜索结果存储到缓存数组中
950
610
  if (searchResults.length > 0) {
951
611
  // 避免重复存储相同的识别码
@@ -971,503 +631,49 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
971
631
  cached_results_count: this.searchResults.length,
972
632
  type: 'normalCode'
973
633
  });
974
- return _context7.abrupt("return", {
634
+ return _context6.abrupt("return", {
975
635
  type: 'normalCode',
976
636
  data: searchResults
977
637
  });
978
- case 30:
979
- _context7.prev = 30;
980
- _context7.t0 = _context7["catch"](1);
981
- this.paymentModule.logError('[WalletPass] 搜索识别码信息失败', _context7.t0, {
638
+ case 34:
639
+ _context6.prev = 34;
640
+ _context6.t0 = _context6["catch"](1);
641
+ this.paymentModule.logError('[WalletPass] 搜索识别码信息失败', _context6.t0, {
982
642
  code: params.code,
983
643
  customer_id: params.customer_id,
984
644
  order_expect_amount: params.order_expect_amount
985
645
  });
986
- throw _context7.t0;
987
- case 34:
646
+ throw _context6.t0;
647
+ case 38:
988
648
  case "end":
989
- return _context7.stop();
649
+ return _context6.stop();
990
650
  }
991
- }, _callee7, this, [[1, 30]]);
651
+ }, _callee6, this, [[1, 34]]);
992
652
  }));
993
- function searchIdentificationCodeAsync(_x8) {
653
+ function searchIdentificationCodeAsync(_x6) {
994
654
  return _searchIdentificationCodeAsync.apply(this, arguments);
995
655
  }
996
656
  return searchIdentificationCodeAsync;
997
- }()
998
- /**
999
- * 刷新购物车与结账共享的钱包资产。
1000
- *
1001
- * 与 legacy initializeWalletDataFromBusinessAsync 不同,这里维护选择状态;
1002
- * 推荐结果只作为可用性/金额计算输入,不会自动成为 selectedIds。
1003
- */
1004
- )
1005
- }, {
1006
- key: "refreshWalletAssetsFromBusinessAsync",
1007
- value: (function () {
1008
- var _refreshWalletAssetsFromBusinessAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(businessData) {
1009
- var _businessData$product2,
1010
- _this4 = this;
1011
- var options,
1012
- requestSequence,
1013
- nextCustomerId,
1014
- previousCustomerId,
1015
- customerChanged,
1016
- preserveSelection,
1017
- committedKeys,
1018
- committedItems,
1019
- selectedIds,
1020
- selectionSources,
1021
- scanSelectedAssets,
1022
- restoredSearchedAssets,
1023
- searchedWalletAssetCodes,
1024
- useAggregateRecalculate,
1025
- aggregateResult,
1026
- result,
1027
- authoritativeSelectedIds,
1028
- returnedAggregateKeys,
1029
- missingSelectedKeys,
1030
- searchedWalletAssets,
1031
- recommendedKeys,
1032
- items,
1033
- latestSelectedIds,
1034
- latestSelectionSources,
1035
- pendingAutoSelectAssets,
1036
- requestedKeySet,
1037
- nextState,
1038
- selectedKeySet,
1039
- droppedScanSelectedAssets,
1040
- _args8 = arguments;
1041
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1042
- while (1) switch (_context8.prev = _context8.next) {
1043
- case 0:
1044
- options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
1045
- requestSequence = ++this.walletAssetsRequestSequence;
1046
- nextCustomerId = businessData.customer_id;
1047
- previousCustomerId = this.walletAssetsState.customerId;
1048
- customerChanged = String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '');
1049
- preserveSelection = options.preserveSelection !== false && !customerChanged;
1050
- if (customerChanged) {
1051
- this.clearSearchResults();
1052
- }
1053
- committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
1054
- return String(id);
1055
- }));
1056
- committedItems = this.walletAssetsState.items.filter(function (item) {
1057
- return committedKeys.has(getWalletAssetKey(item));
1058
- });
1059
- selectedIds = preserveSelection ? _toConsumableArray(this.walletAssetsState.selectedIds) : [];
1060
- selectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {};
1061
- scanSelectedAssets = preserveSelection ? this.walletAssetsState.selectedItems.filter(function (asset) {
1062
- var assetId = getWalletAssetId(asset);
1063
- return assetId !== undefined && assetId !== null && selectionSources[String(assetId)] === 'scan';
1064
- }) : []; // aggregate-recalculate 不接受空商品列表。
1065
- // 清空购物车时保留扫码资产供后续加购恢复;只有手动 Remove/Clear
1066
- // 会取消自动应用资格,商品变化导致的自动失效需要重新进入待选队列。
1067
- if ((_businessData$product2 = businessData.products) !== null && _businessData$product2 !== void 0 && _businessData$product2.length) {
1068
- _context8.next = 22;
1069
- break;
1070
- }
1071
- this.queuePendingAutoSelectForAssets(scanSelectedAssets);
1072
- this.generateWalletParams(businessData);
1073
- restoredSearchedAssets = this.searchResults.filter(isWalletPaymentAsset).map(function (item) {
1074
- return _objectSpread(_objectSpread({}, item), {}, {
1075
- actualDeduction: 0,
1076
- deductionDetails: [],
1077
- _available_max_amount: 0,
1078
- _unified_available_status: 0,
1079
- _wallet_asset_recommended: false
1080
- });
1081
- });
1082
- this.walletRecommendList = [];
1083
- this.userIdentificationCodes = [];
1084
- this.walletInitData = {
1085
- transformList: [],
1086
- noApplicableVoucher: restoredSearchedAssets,
1087
- products: []
1088
- };
1089
- this.walletAssetsCalculationContext = {
1090
- orderTotalAmount: 0,
1091
- products: []
1092
- };
1093
- this.emitEvent(WalletPassHooks.OnUserIdentificationCodesUpdated, {
1094
- userIdentificationCodes: []
1095
- });
1096
- return _context8.abrupt("return", this.publishWalletAssetsState({
1097
- status: 'ready',
1098
- customerId: nextCustomerId,
1099
- items: mergeWalletAssets(restoredSearchedAssets, committedItems),
1100
- selectedIds: [],
1101
- selectedItems: [],
1102
- selectionSources: {},
1103
- totalSelectedAmount: 0,
1104
- error: null
1105
- }));
1106
- case 22:
1107
- this.publishWalletAssetsState({
1108
- status: 'loading',
1109
- customerId: nextCustomerId,
1110
- items: preserveSelection ? this.walletAssetsState.items : committedItems,
1111
- selectedIds: selectedIds,
1112
- selectedItems: preserveSelection ? this.walletAssetsState.selectedItems : [],
1113
- selectionSources: selectionSources,
1114
- totalSelectedAmount: preserveSelection ? this.walletAssetsState.totalSelectedAmount : 0,
1115
- error: null
1116
- });
1117
- _context8.prev = 23;
1118
- searchedWalletAssetCodes = preserveSelection ? this.getSearchedWalletAssetCodes() : [];
1119
- useAggregateRecalculate = preserveSelection && (selectedIds.length > 0 || searchedWalletAssetCodes.length > 0);
1120
- if (!useAggregateRecalculate) {
1121
- _context8.next = 32;
1122
- break;
1123
- }
1124
- _context8.next = 29;
1125
- return this.aggregateRecalculateWalletAssetsAsync(businessData, selectedIds);
1126
- case 29:
1127
- _context8.t0 = _context8.sent;
1128
- _context8.next = 33;
1129
- break;
1130
- case 32:
1131
- _context8.t0 = null;
1132
- case 33:
1133
- aggregateResult = _context8.t0;
1134
- _context8.t1 = aggregateResult;
1135
- if (_context8.t1) {
1136
- _context8.next = 39;
1137
- break;
1138
- }
1139
- _context8.next = 38;
1140
- return this.initializeWalletDataFromBusinessAsync(businessData);
1141
- case 38:
1142
- _context8.t1 = _context8.sent;
1143
- case 39:
1144
- result = _context8.t1;
1145
- if (!(requestSequence !== this.walletAssetsRequestSequence)) {
1146
- _context8.next = 42;
1147
- break;
1148
- }
1149
- return _context8.abrupt("return", this.getWalletAssetsState());
1150
- case 42:
1151
- this.walletAssetsCalculationContext = {
1152
- orderTotalAmount: Number(businessData.order_wait_pay_amount || 0),
1153
- products: result.products || businessData.products || []
1154
- };
1155
- authoritativeSelectedIds = (aggregateResult === null || aggregateResult === void 0 ? void 0 : aggregateResult.authoritativeSelectedIds) || selectedIds;
1156
- if (aggregateResult) {
1157
- returnedAggregateKeys = new Set([].concat(_toConsumableArray(result.transformList || []), _toConsumableArray(result.noApplicableVoucher || [])).map(function (item) {
1158
- return getWalletAssetKey(item);
1159
- }));
1160
- missingSelectedKeys = new Set(selectedIds.map(function (id) {
1161
- return String(id);
1162
- }).filter(function (id) {
1163
- return !returnedAggregateKeys.has(id);
1164
- }));
1165
- if (missingSelectedKeys.size > 0) {
1166
- this.searchResults = this.searchResults.filter(function (item) {
1167
- return !missingSelectedKeys.has(getWalletAssetKey(item));
1168
- });
1169
- }
1170
- }
1171
- searchedWalletAssets = preserveSelection ? this.syncSearchedWalletAssets([].concat(_toConsumableArray(result.transformList || []), _toConsumableArray(result.noApplicableVoucher || []))) : [];
1172
- if (!(requestSequence !== this.walletAssetsRequestSequence)) {
1173
- _context8.next = 48;
1174
- break;
1175
- }
1176
- return _context8.abrupt("return", this.getWalletAssetsState());
1177
- case 48:
1178
- recommendedKeys = new Set((result.walletRecommendList || []).map(function (asset) {
1179
- return getWalletAssetKey(asset);
1180
- }));
1181
- items = mergeWalletAssets(preserveSelection && !aggregateResult ? this.walletAssetsState.selectedItems : [], searchedWalletAssets, result.transformList || [], result.noApplicableVoucher || []).map(function (asset) {
1182
- return _objectSpread(_objectSpread({}, asset), {}, {
1183
- _wallet_asset_recommended: recommendedKeys.has(getWalletAssetKey(asset))
1184
- });
1185
- });
1186
- latestSelectedIds = preserveSelection ? authoritativeSelectedIds : [];
1187
- latestSelectionSources = preserveSelection ? _objectSpread({}, this.walletAssetsState.selectionSources) : {};
1188
- pendingAutoSelectAssets = this.walletAssetsBehavior.autoSelectAfterSearch ? items.filter(function (asset) {
1189
- return _this4.isPendingAutoSelectAsset(asset) && isWalletAssetAvailable(asset);
1190
- }) : [];
1191
- requestedKeySet = new Set(latestSelectedIds.map(function (id) {
1192
- return String(id);
1193
- }));
1194
- pendingAutoSelectAssets.forEach(function (asset) {
1195
- var assetId = getWalletAssetId(asset);
1196
- if (assetId === undefined || assetId === null) return;
1197
- var assetKey = String(assetId);
1198
- if (!requestedKeySet.has(assetKey)) {
1199
- requestedKeySet.add(assetKey);
1200
- latestSelectedIds.push(assetId);
1201
- }
1202
- latestSelectionSources[assetKey] = 'scan';
1203
- });
1204
- nextState = this.recalculateWalletAssets(items, latestSelectedIds, latestSelectionSources);
1205
- selectedKeySet = new Set(nextState.selectedIds.map(function (id) {
1206
- return String(id);
1207
- }));
1208
- pendingAutoSelectAssets.forEach(function (asset) {
1209
- var assetId = getWalletAssetId(asset);
1210
- if (assetId !== undefined && assetId !== null && selectedKeySet.has(String(assetId))) {
1211
- _this4.clearPendingAutoSelectForAsset(asset);
1212
- }
1213
- });
1214
- droppedScanSelectedAssets = scanSelectedAssets.filter(function (asset) {
1215
- var assetId = getWalletAssetId(asset);
1216
- return assetId !== undefined && assetId !== null && !selectedKeySet.has(String(assetId));
1217
- });
1218
- this.queuePendingAutoSelectForAssets(droppedScanSelectedAssets);
1219
- return _context8.abrupt("return", nextState);
1220
- case 63:
1221
- _context8.prev = 63;
1222
- _context8.t2 = _context8["catch"](23);
1223
- if (!(requestSequence !== this.walletAssetsRequestSequence)) {
1224
- _context8.next = 67;
1225
- break;
1226
- }
1227
- return _context8.abrupt("return", this.getWalletAssetsState());
1228
- case 67:
1229
- this.paymentModule.logError('[WalletPass] 刷新共享钱包资产失败,保留刷新前状态', _context8.t2, {
1230
- customer_id: businessData.customer_id,
1231
- selected_ids: selectedIds,
1232
- searched_codes: this.getSearchedWalletAssetCodes()
1233
- });
1234
- return _context8.abrupt("return", this.publishWalletAssetsState({
1235
- status: 'error',
1236
- items: preserveSelection ? this.walletAssetsState.items : committedItems,
1237
- selectedIds: preserveSelection ? this.walletAssetsState.selectedIds : [],
1238
- selectedItems: preserveSelection ? this.walletAssetsState.selectedItems : [],
1239
- selectionSources: preserveSelection ? this.walletAssetsState.selectionSources : {},
1240
- totalSelectedAmount: preserveSelection ? this.walletAssetsState.totalSelectedAmount : 0,
1241
- customerId: nextCustomerId,
1242
- error: _context8.t2 instanceof Error ? _context8.t2.message : String(_context8.t2)
1243
- }));
1244
- case 69:
1245
- case "end":
1246
- return _context8.stop();
1247
- }
1248
- }, _callee8, this, [[23, 63]]);
1249
- }));
1250
- function refreshWalletAssetsFromBusinessAsync(_x9) {
1251
- return _refreshWalletAssetsFromBusinessAsync.apply(this, arguments);
1252
- }
1253
- return refreshWalletAssetsFromBusinessAsync;
1254
657
  }())
1255
- }, {
1256
- key: "getWalletAssetsState",
1257
- value: function getWalletAssetsState() {
1258
- return _objectSpread(_objectSpread({}, this.walletAssetsState), {}, {
1259
- items: _toConsumableArray(this.walletAssetsState.items),
1260
- selectedIds: _toConsumableArray(this.walletAssetsState.selectedIds),
1261
- selectedItems: _toConsumableArray(this.walletAssetsState.selectedItems),
1262
- committedIds: _toConsumableArray(this.walletAssetsState.committedIds),
1263
- selectionSources: _objectSpread({}, this.walletAssetsState.selectionSources)
1264
- });
1265
- }
1266
- }, {
1267
- key: "exportWalletAssetsSnapshot",
1268
- value: function exportWalletAssetsSnapshot() {
1269
- return {
1270
- state: this.getWalletAssetsState(),
1271
- searchResults: _toConsumableArray(this.searchResults),
1272
- pendingAutoSelectSearchCodes: _toConsumableArray(this.pendingAutoSelectSearchCodes),
1273
- walletParams: this.walletParams ? _objectSpread({}, this.walletParams) : null,
1274
- calculationContext: {
1275
- orderTotalAmount: this.walletAssetsCalculationContext.orderTotalAmount,
1276
- products: _toConsumableArray(this.walletAssetsCalculationContext.products)
1277
- }
1278
- };
1279
- }
1280
- }, {
1281
- key: "importWalletAssetsSnapshot",
1282
- value: function importWalletAssetsSnapshot(snapshot) {
1283
- var _snapshot$calculation, _snapshot$calculation2;
1284
- if (!(snapshot !== null && snapshot !== void 0 && snapshot.state)) return this.getWalletAssetsState();
1285
- this.walletAssetsRequestSequence += 1;
1286
- this.searchResults = Array.isArray(snapshot.searchResults) ? _toConsumableArray(snapshot.searchResults) : [];
1287
- this.pendingAutoSelectSearchCodes = this.walletAssetsBehavior.autoSelectAfterSearch && Array.isArray(snapshot.pendingAutoSelectSearchCodes) ? new Set(snapshot.pendingAutoSelectSearchCodes.map(normalizeWalletAssetCode).filter(Boolean)) : new Set();
1288
- this.walletParams = snapshot.walletParams ? _objectSpread({}, snapshot.walletParams) : null;
1289
- this.walletAssetsCalculationContext = {
1290
- orderTotalAmount: Number(((_snapshot$calculation = snapshot.calculationContext) === null || _snapshot$calculation === void 0 ? void 0 : _snapshot$calculation.orderTotalAmount) || 0),
1291
- products: Array.isArray((_snapshot$calculation2 = snapshot.calculationContext) === null || _snapshot$calculation2 === void 0 ? void 0 : _snapshot$calculation2.products) ? _toConsumableArray(snapshot.calculationContext.products) : []
1292
- };
1293
- return this.publishWalletAssetsState(_objectSpread(_objectSpread({}, snapshot.state), {}, {
1294
- items: Array.isArray(snapshot.state.items) ? snapshot.state.items : [],
1295
- selectedIds: Array.isArray(snapshot.state.selectedIds) ? snapshot.state.selectedIds : [],
1296
- selectedItems: Array.isArray(snapshot.state.selectedItems) ? snapshot.state.selectedItems : [],
1297
- committedIds: Array.isArray(snapshot.state.committedIds) ? snapshot.state.committedIds : [],
1298
- selectionSources: snapshot.state.selectionSources || {}
1299
- }));
1300
- }
1301
- }, {
1302
- key: "selectWalletAsset",
1303
- value: function selectWalletAsset(assetId, options) {
1304
- var assetKey = String(assetId);
1305
- var asset = this.walletAssetsState.items.find(function (item) {
1306
- return getWalletAssetKey(item) === assetKey;
1307
- });
1308
- var committedKeys = new Set(this.walletAssetsState.committedIds.map(function (id) {
1309
- return String(id);
1310
- }));
1311
- if (committedKeys.has(assetKey)) return this.getWalletAssetsState();
1312
- var selectedIds = this.walletAssetsState.selectedIds.filter(function (id) {
1313
- return String(id) !== assetKey;
1314
- });
1315
- var selectionSources = _objectSpread({}, this.walletAssetsState.selectionSources);
1316
- delete selectionSources[assetKey];
1317
- if (options.selected) {
1318
- if (!asset || !isWalletAssetAvailable(asset)) {
1319
- return this.getWalletAssetsState();
1320
- }
1321
- selectedIds.push(assetId);
1322
- selectionSources[assetKey] = options.source || 'manual';
1323
- } else if (asset) {
1324
- this.clearPendingAutoSelectForAsset(asset);
1325
- }
1326
- var nextState = this.recalculateWalletAssets(this.walletAssetsState.items, selectedIds, selectionSources);
1327
- if (options.selected && asset && nextState.selectedIds.some(function (id) {
1328
- return String(id) === assetKey;
1329
- })) {
1330
- this.clearPendingAutoSelectForAsset(asset);
1331
- }
1332
- return nextState;
1333
- }
1334
- }, {
1335
- key: "scanWalletAssetAsync",
1336
- value: function () {
1337
- var _scanWalletAssetAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(code) {
1338
- var normalizedCode, selectedAsset, result, paymentAssets, asset, items, recalculatedState, assetId, selected, isSelected;
1339
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1340
- while (1) switch (_context9.prev = _context9.next) {
1341
- case 0:
1342
- normalizedCode = String(code || '').trim();
1343
- if (normalizedCode) {
1344
- _context9.next = 3;
1345
- break;
1346
- }
1347
- return _context9.abrupt("return", {
1348
- type: 'normalCode',
1349
- selected: false,
1350
- state: this.getWalletAssetsState()
1351
- });
1352
- case 3:
1353
- selectedAsset = this.walletAssetsState.selectedItems.find(function (asset) {
1354
- return matchesWalletAssetCode(asset, normalizedCode);
1355
- });
1356
- if (!selectedAsset) {
1357
- _context9.next = 6;
1358
- break;
1359
- }
1360
- return _context9.abrupt("return", {
1361
- type: 'normalCode',
1362
- asset: selectedAsset,
1363
- selected: true,
1364
- state: this.getWalletAssetsState()
1365
- });
1366
- case 6:
1367
- this.walletAssetsRequestSequence += 1;
1368
- _context9.next = 9;
1369
- return this.searchIdentificationCodeAsync(_objectSpread(_objectSpread({}, this.walletParams || {}), {}, {
1370
- code: normalizedCode,
1371
- prepare_payments: this.formatWalletPassList2PreparePayments(this.walletAssetsState.selectedItems)
1372
- }));
1373
- case 9:
1374
- result = _context9.sent;
1375
- paymentAssets = result.data.filter(isWalletPaymentAsset);
1376
- asset = paymentAssets.find(function (item) {
1377
- return String((item === null || item === void 0 ? void 0 : item.code) || '') === normalizedCode;
1378
- }) || paymentAssets[0];
1379
- if (!(!asset || result.type === 'walletCode')) {
1380
- _context9.next = 14;
1381
- break;
1382
- }
1383
- return _context9.abrupt("return", {
1384
- type: result.type,
1385
- asset: asset,
1386
- selected: false,
1387
- state: this.getWalletAssetsState()
1388
- });
1389
- case 14:
1390
- items = mergeWalletAssets(this.walletAssetsState.items, [asset]);
1391
- recalculatedState = this.recalculateWalletAssets(items, this.walletAssetsState.selectedIds, this.walletAssetsState.selectionSources);
1392
- assetId = getWalletAssetId(asset);
1393
- selected = this.walletAssetsBehavior.autoSelectAfterSearch && assetId !== undefined && isWalletAssetAvailable(asset) ? this.selectWalletAsset(assetId, {
1394
- selected: true,
1395
- source: 'scan'
1396
- }) : recalculatedState;
1397
- isSelected = assetId !== undefined && selected.selectedIds.some(function (id) {
1398
- return String(id) === String(assetId);
1399
- });
1400
- if (isSelected) {
1401
- this.clearPendingAutoSelectForAsset(asset);
1402
- } else if (this.walletAssetsBehavior.autoSelectAfterSearch) {
1403
- this.pendingAutoSelectSearchCodes.add(normalizeWalletAssetCode(normalizedCode));
1404
- this.queuePendingAutoSelectForAssets([asset]);
1405
- }
1406
- return _context9.abrupt("return", {
1407
- type: result.type,
1408
- asset: asset,
1409
- selected: isSelected,
1410
- state: selected
1411
- });
1412
- case 21:
1413
- case "end":
1414
- return _context9.stop();
1415
- }
1416
- }, _callee9, this);
1417
- }));
1418
- function scanWalletAssetAsync(_x10) {
1419
- return _scanWalletAssetAsync.apply(this, arguments);
1420
- }
1421
- return scanWalletAssetAsync;
1422
- }()
1423
- }, {
1424
- key: "clearWalletAssetSelection",
1425
- value: function clearWalletAssetSelection() {
1426
- this.pendingAutoSelectSearchCodes.clear();
1427
- return this.recalculateWalletAssets(this.walletAssetsState.items, [], {});
1428
- }
1429
- }, {
1430
- key: "setCommittedWalletAssets",
1431
- value: function setCommittedWalletAssets(committedIds) {
1432
- var committedAssets = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1433
- var committedKeys = new Set(committedIds.map(function (id) {
1434
- return String(id);
1435
- }));
1436
- var selectedIds = this.walletAssetsState.selectedIds.filter(function (id) {
1437
- return !committedKeys.has(String(id));
1438
- });
1439
- var selectionSources = Object.entries(this.walletAssetsState.selectionSources).reduce(function (result, _ref14) {
1440
- var _ref15 = _slicedToArray(_ref14, 2),
1441
- key = _ref15[0],
1442
- source = _ref15[1];
1443
- if (!committedKeys.has(key)) result[key] = source;
1444
- return result;
1445
- }, {});
1446
- this.publishWalletAssetsState({
1447
- items: mergeWalletAssets(this.walletAssetsState.items, committedAssets),
1448
- committedIds: committedIds
1449
- });
1450
- return this.recalculateWalletAssets(this.walletAssetsState.items, selectedIds, selectionSources);
1451
- }
1452
658
  }, {
1453
659
  key: "processWalletPayment",
1454
660
  value: function () {
1455
- var _processWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(amount, orderUuid, voucherId) {
661
+ var _processWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(amount, orderUuid, voucherId) {
1456
662
  var walletMethod, paymentItem;
1457
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1458
- while (1) switch (_context10.prev = _context10.next) {
663
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
664
+ while (1) switch (_context7.prev = _context7.next) {
1459
665
  case 0:
1460
666
  this.paymentModule.logInfo('[WalletPass] 开始处理钱包支付', {
1461
667
  amount: amount,
1462
668
  orderUuid: orderUuid,
1463
669
  voucherId: voucherId || 'none'
1464
670
  });
1465
- _context10.next = 3;
671
+ _context7.next = 3;
1466
672
  return this.paymentModule.getWalletPaymentMethod();
1467
673
  case 3:
1468
- walletMethod = _context10.sent;
674
+ walletMethod = _context7.sent;
1469
675
  if (walletMethod) {
1470
- _context10.next = 7;
676
+ _context7.next = 7;
1471
677
  break;
1472
678
  }
1473
679
  this.paymentModule.logError('[WalletPass] 钱包支付方式未找到', null, {
@@ -1485,7 +691,7 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1485
691
  type: walletMethod.type,
1486
692
  voucher_id: voucherId || ''
1487
693
  };
1488
- _context10.next = 10;
694
+ _context7.next = 10;
1489
695
  return this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
1490
696
  case 10:
1491
697
  this.paymentModule.logInfo('[WalletPass] 钱包支付处理完成', {
@@ -1496,11 +702,11 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1496
702
  });
1497
703
  case 11:
1498
704
  case "end":
1499
- return _context10.stop();
705
+ return _context7.stop();
1500
706
  }
1501
- }, _callee10, this);
707
+ }, _callee7, this);
1502
708
  }));
1503
- function processWalletPayment(_x11, _x12, _x13) {
709
+ function processWalletPayment(_x7, _x8, _x9) {
1504
710
  return _processWalletPayment.apply(this, arguments);
1505
711
  }
1506
712
  return processWalletPayment;
@@ -1508,18 +714,18 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1508
714
  }, {
1509
715
  key: "getWalletBalance",
1510
716
  value: function () {
1511
- var _getWalletBalance = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(voucherId) {
1512
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1513
- while (1) switch (_context11.prev = _context11.next) {
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) {
1514
720
  case 0:
1515
- return _context11.abrupt("return", 0);
721
+ return _context8.abrupt("return", 0);
1516
722
  case 1:
1517
723
  case "end":
1518
- return _context11.stop();
724
+ return _context8.stop();
1519
725
  }
1520
- }, _callee11);
726
+ }, _callee8);
1521
727
  }));
1522
- function getWalletBalance(_x14) {
728
+ function getWalletBalance(_x10) {
1523
729
  return _getWalletBalance.apply(this, arguments);
1524
730
  }
1525
731
  return getWalletBalance;
@@ -1599,7 +805,6 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1599
805
  key: "clearSearchResults",
1600
806
  value: function clearSearchResults() {
1601
807
  this.searchResults = [];
1602
- this.pendingAutoSelectSearchCodes.clear();
1603
808
  this.paymentModule.logInfo('[WalletPass] 搜索结果缓存已清除');
1604
809
  }
1605
810
 
@@ -1631,16 +836,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
1631
836
  this.walletRecommendList = [];
1632
837
  this.userIdentificationCodes = [];
1633
838
  this.searchResults = [];
1634
- this.pendingAutoSelectSearchCodes.clear();
1635
839
  this.walletParams = null;
1636
840
  this.walletInitData = null;
1637
- this.walletAssetsRequestSequence += 1;
1638
- this.walletAssetsCalculationContext = {
1639
- orderTotalAmount: 0,
1640
- products: []
1641
- };
1642
- this.walletAssetsState = createInitialWalletAssetsState();
1643
- this.publishWalletAssetsState({});
1644
841
 
1645
842
  // 发送所有缓存清除事件
1646
843
  this.emitEvent(WalletPassHooks.OnWalletCacheCleared, {