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