@pisell/pisellos 3.0.57 → 3.0.59
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.js +1 -2
- package/dist/effects/index.d.ts +3 -4
- package/dist/effects/index.js +6 -15
- package/dist/modules/AccountList/index.d.ts +1 -7
- package/dist/modules/AccountList/index.js +14 -81
- package/dist/modules/AccountList/types.d.ts +0 -28
- package/dist/modules/AccountList/types.js +0 -8
- package/dist/modules/Cart/index.js +1 -1
- package/dist/modules/Payment/index.d.ts +9 -273
- package/dist/modules/Payment/index.js +109 -2525
- package/dist/modules/Payment/types.d.ts +30 -382
- package/dist/modules/Payment/types.js +14 -116
- package/dist/modules/ProductList/index.d.ts +1 -12
- package/dist/modules/ProductList/index.js +3 -27
- package/dist/modules/Rules/index.js +14 -27
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -1
- package/dist/plugins/window.d.ts +0 -1
- package/dist/solution/BookingByStep/index.js +1 -9
- package/dist/solution/ShopDiscount/index.js +2 -4
- package/dist/solution/index.d.ts +0 -2
- package/dist/solution/index.js +1 -3
- package/dist/types/index.d.ts +1 -3
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +3 -4
- package/lib/effects/index.js +1 -4
- package/lib/modules/AccountList/index.d.ts +1 -7
- package/lib/modules/AccountList/index.js +0 -27
- package/lib/modules/AccountList/types.d.ts +0 -28
- package/lib/modules/Cart/index.js +1 -1
- package/lib/modules/Payment/index.d.ts +9 -273
- package/lib/modules/Payment/index.js +50 -1285
- package/lib/modules/Payment/types.d.ts +30 -382
- package/lib/modules/Payment/types.js +6 -41
- package/lib/modules/ProductList/index.d.ts +1 -12
- package/lib/modules/ProductList/index.js +2 -29
- package/lib/modules/Rules/index.js +12 -20
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +0 -2
- package/lib/plugins/window.d.ts +0 -1
- package/lib/solution/BookingByStep/index.js +2 -1
- package/lib/solution/ShopDiscount/index.js +1 -2
- package/lib/solution/index.d.ts +0 -2
- package/lib/solution/index.js +1 -5
- package/lib/types/index.d.ts +1 -3
- package/package.json +2 -4
- package/dist/modules/Customer/constants.d.ts +0 -7
- package/dist/modules/Customer/constants.js +0 -12
- package/dist/modules/Customer/index.d.ts +0 -122
- package/dist/modules/Customer/index.js +0 -697
- package/dist/modules/Customer/types.d.ts +0 -146
- package/dist/modules/Customer/types.js +0 -41
- package/dist/modules/Payment/cash.d.ts +0 -11
- package/dist/modules/Payment/cash.js +0 -78
- package/dist/modules/Payment/eftpos.d.ts +0 -11
- package/dist/modules/Payment/eftpos.js +0 -80
- package/dist/modules/Payment/wallet.d.ts +0 -11
- package/dist/modules/Payment/wallet.js +0 -78
- package/dist/modules/Payment/walletpass.d.ts +0 -0
- package/dist/modules/Payment/walletpass.js +0 -0
- package/dist/plugins/app-types/app/app.d.ts +0 -83
- package/dist/plugins/app-types/app/const.d.ts +0 -4
- package/dist/plugins/app-types/app/index.d.ts +0 -14
- package/dist/plugins/app-types/applicationManager/application.d.ts +0 -50
- package/dist/plugins/app-types/applicationManager/index.d.ts +0 -13
- package/dist/plugins/app-types/config.d.ts +0 -3
- package/dist/plugins/app-types/cookie/index.d.ts +0 -13
- package/dist/plugins/app-types/data/index.d.ts +0 -8
- package/dist/plugins/app-types/history/config.d.ts +0 -24
- package/dist/plugins/app-types/history/index.d.ts +0 -20
- package/dist/plugins/app-types/history/type.d.ts +0 -2
- package/dist/plugins/app-types/hooks/index.d.ts +0 -12
- package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
- package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
- package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
- package/dist/plugins/app-types/hooks/useStore/index.d.ts +0 -6
- package/dist/plugins/app-types/index.d.ts +0 -6
- package/dist/plugins/app-types/indexDB/index.d.ts +0 -178
- package/dist/plugins/app-types/locales/en.d.ts +0 -3
- package/dist/plugins/app-types/locales/index.d.ts +0 -37
- package/dist/plugins/app-types/locales/original.d.ts +0 -3
- package/dist/plugins/app-types/locales/type.d.ts +0 -19
- package/dist/plugins/app-types/locales/zh-CN.d.ts +0 -3
- package/dist/plugins/app-types/locales/zh-HK.d.ts +0 -3
- package/dist/plugins/app-types/logger/feishu.d.ts +0 -11
- package/dist/plugins/app-types/logger/index.d.ts +0 -122
- package/dist/plugins/app-types/menuManager/hooks.d.ts +0 -17
- package/dist/plugins/app-types/menuManager/index.d.ts +0 -28
- package/dist/plugins/app-types/models/global.d.ts +0 -32
- package/dist/plugins/app-types/models/index.d.ts +0 -45
- package/dist/plugins/app-types/models/type.d.ts +0 -2
- package/dist/plugins/app-types/package.json +0 -15
- package/dist/plugins/app-types/plugin/index.d.ts +0 -0
- package/dist/plugins/app-types/pubsub/example.d.ts +0 -5
- package/dist/plugins/app-types/pubsub/index.d.ts +0 -63
- package/dist/plugins/app-types/request/cache.d.ts +0 -46
- package/dist/plugins/app-types/request/cancelToken.d.ts +0 -38
- package/dist/plugins/app-types/request/config.d.ts +0 -3
- package/dist/plugins/app-types/request/constants.d.ts +0 -2
- package/dist/plugins/app-types/request/index.d.ts +0 -24
- package/dist/plugins/app-types/request/pisell2Request.d.ts +0 -6
- package/dist/plugins/app-types/request/type.d.ts +0 -41
- package/dist/plugins/app-types/request/utils.d.ts +0 -46
- package/dist/plugins/app-types/routes/config.d.ts +0 -7
- package/dist/plugins/app-types/routes/index.d.ts +0 -28
- package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
- package/dist/plugins/app-types/socket/components/index.d.ts +0 -2
- package/dist/plugins/app-types/socket/constants.d.ts +0 -33
- package/dist/plugins/app-types/socket/events.d.ts +0 -31
- package/dist/plugins/app-types/socket/heartbeat.d.ts +0 -66
- package/dist/plugins/app-types/socket/index.d.ts +0 -61
- package/dist/plugins/app-types/socket/monitor.d.ts +0 -169
- package/dist/plugins/app-types/socket/reconnect.d.ts +0 -61
- package/dist/plugins/app-types/socket/socket.d.ts +0 -129
- package/dist/plugins/app-types/socket/types.d.ts +0 -85
- package/dist/plugins/app-types/storage/index.d.ts +0 -17
- package/dist/plugins/app-types/tasks/index.d.ts +0 -77
- package/dist/plugins/app-types/tasks/type.d.ts +0 -62
- package/dist/plugins/app-types/tasks/useTasks.d.ts +0 -5
- package/dist/plugins/app-types/type.d.ts +0 -2
- package/dist/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
- package/dist/plugins/app-types/variables/config.d.ts +0 -3
- package/dist/plugins/app-types/variables/index.d.ts +0 -6
- package/dist/plugins/app-types/variables/type.d.ts +0 -2
- package/dist/plugins/app-types/website/index.d.ts +0 -6
- package/dist/plugins/app.d.ts +0 -8
- package/dist/plugins/app.js +0 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -172
- package/dist/solution/BookingTicket/index.js +0 -665
- package/dist/solution/BookingTicket/types.d.ts +0 -68
- package/dist/solution/BookingTicket/types.js +0 -43
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -174
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -81
- package/dist/solution/BookingTicket/utils/scan/index.js +0 -285
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
- package/dist/solution/Checkout/appointmentDemo.json +0 -1
- package/dist/solution/Checkout/index.d.ts +0 -181
- package/dist/solution/Checkout/index.js +0 -1596
- package/dist/solution/Checkout/types.d.ts +0 -550
- package/dist/solution/Checkout/types.js +0 -132
- package/dist/solution/Checkout/utils/index.d.ts +0 -73
- package/dist/solution/Checkout/utils/index.js +0 -371
- package/dist/utils/task.d.ts +0 -40
- package/dist/utils/task.js +0 -171
- package/dist/utils/watch.d.ts +0 -102
- package/dist/utils/watch.js +0 -294
- package/lib/modules/Customer/constants.d.ts +0 -7
- package/lib/modules/Customer/constants.js +0 -39
- package/lib/modules/Customer/index.d.ts +0 -122
- package/lib/modules/Customer/index.js +0 -440
- package/lib/modules/Customer/types.d.ts +0 -146
- package/lib/modules/Customer/types.js +0 -37
- package/lib/modules/Payment/cash.d.ts +0 -11
- package/lib/modules/Payment/cash.js +0 -51
- package/lib/modules/Payment/eftpos.d.ts +0 -11
- package/lib/modules/Payment/eftpos.js +0 -51
- package/lib/modules/Payment/wallet.d.ts +0 -11
- package/lib/modules/Payment/wallet.js +0 -51
- package/lib/modules/Payment/walletpass.d.ts +0 -0
- package/lib/modules/Payment/walletpass.js +0 -0
- package/lib/plugins/app-types/app/app.d.ts +0 -83
- package/lib/plugins/app-types/app/const.d.ts +0 -4
- package/lib/plugins/app-types/app/index.d.ts +0 -14
- package/lib/plugins/app-types/applicationManager/application.d.ts +0 -50
- package/lib/plugins/app-types/applicationManager/index.d.ts +0 -13
- package/lib/plugins/app-types/config.d.ts +0 -3
- package/lib/plugins/app-types/cookie/index.d.ts +0 -13
- package/lib/plugins/app-types/data/index.d.ts +0 -8
- package/lib/plugins/app-types/history/config.d.ts +0 -24
- package/lib/plugins/app-types/history/index.d.ts +0 -20
- package/lib/plugins/app-types/history/type.d.ts +0 -2
- package/lib/plugins/app-types/hooks/index.d.ts +0 -12
- package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
- package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
- package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
- package/lib/plugins/app-types/hooks/useStore/index.d.ts +0 -6
- package/lib/plugins/app-types/index.d.ts +0 -6
- package/lib/plugins/app-types/indexDB/index.d.ts +0 -178
- package/lib/plugins/app-types/locales/en.d.ts +0 -3
- package/lib/plugins/app-types/locales/index.d.ts +0 -37
- package/lib/plugins/app-types/locales/original.d.ts +0 -3
- package/lib/plugins/app-types/locales/type.d.ts +0 -19
- package/lib/plugins/app-types/locales/zh-CN.d.ts +0 -3
- package/lib/plugins/app-types/locales/zh-HK.d.ts +0 -3
- package/lib/plugins/app-types/logger/feishu.d.ts +0 -11
- package/lib/plugins/app-types/logger/index.d.ts +0 -122
- package/lib/plugins/app-types/menuManager/hooks.d.ts +0 -17
- package/lib/plugins/app-types/menuManager/index.d.ts +0 -28
- package/lib/plugins/app-types/models/global.d.ts +0 -32
- package/lib/plugins/app-types/models/index.d.ts +0 -45
- package/lib/plugins/app-types/models/type.d.ts +0 -2
- package/lib/plugins/app-types/package.json +0 -15
- package/lib/plugins/app-types/plugin/index.d.ts +0 -0
- package/lib/plugins/app-types/pubsub/example.d.ts +0 -5
- package/lib/plugins/app-types/pubsub/index.d.ts +0 -63
- package/lib/plugins/app-types/request/cache.d.ts +0 -46
- package/lib/plugins/app-types/request/cancelToken.d.ts +0 -38
- package/lib/plugins/app-types/request/config.d.ts +0 -3
- package/lib/plugins/app-types/request/constants.d.ts +0 -2
- package/lib/plugins/app-types/request/index.d.ts +0 -24
- package/lib/plugins/app-types/request/pisell2Request.d.ts +0 -6
- package/lib/plugins/app-types/request/type.d.ts +0 -41
- package/lib/plugins/app-types/request/utils.d.ts +0 -46
- package/lib/plugins/app-types/routes/config.d.ts +0 -7
- package/lib/plugins/app-types/routes/index.d.ts +0 -28
- package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
- package/lib/plugins/app-types/socket/components/index.d.ts +0 -2
- package/lib/plugins/app-types/socket/constants.d.ts +0 -33
- package/lib/plugins/app-types/socket/events.d.ts +0 -31
- package/lib/plugins/app-types/socket/heartbeat.d.ts +0 -66
- package/lib/plugins/app-types/socket/index.d.ts +0 -61
- package/lib/plugins/app-types/socket/monitor.d.ts +0 -169
- package/lib/plugins/app-types/socket/reconnect.d.ts +0 -61
- package/lib/plugins/app-types/socket/socket.d.ts +0 -129
- package/lib/plugins/app-types/socket/types.d.ts +0 -85
- package/lib/plugins/app-types/storage/index.d.ts +0 -17
- package/lib/plugins/app-types/tasks/index.d.ts +0 -77
- package/lib/plugins/app-types/tasks/type.d.ts +0 -62
- package/lib/plugins/app-types/tasks/useTasks.d.ts +0 -5
- package/lib/plugins/app-types/type.d.ts +0 -2
- package/lib/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
- package/lib/plugins/app-types/variables/config.d.ts +0 -3
- package/lib/plugins/app-types/variables/index.d.ts +0 -6
- package/lib/plugins/app-types/variables/type.d.ts +0 -2
- package/lib/plugins/app-types/website/index.d.ts +0 -6
- package/lib/plugins/app.d.ts +0 -8
- package/lib/plugins/app.js +0 -17
- package/lib/solution/BookingTicket/index.d.ts +0 -172
- package/lib/solution/BookingTicket/index.js +0 -399
- package/lib/solution/BookingTicket/types.d.ts +0 -68
- package/lib/solution/BookingTicket/types.js +0 -72
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -125
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -81
- package/lib/solution/BookingTicket/utils/scan/index.js +0 -210
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
- package/lib/solution/Checkout/appointmentDemo.json +0 -1
- package/lib/solution/Checkout/index.d.ts +0 -181
- package/lib/solution/Checkout/index.js +0 -864
- package/lib/solution/Checkout/types.d.ts +0 -550
- package/lib/solution/Checkout/types.js +0 -75
- package/lib/solution/Checkout/utils/index.d.ts +0 -73
- package/lib/solution/Checkout/utils/index.js +0 -266
- package/lib/utils/task.d.ts +0 -40
- package/lib/utils/task.js +0 -109
- package/lib/utils/watch.d.ts +0 -102
- package/lib/utils/watch.js +0 -217
|
@@ -1,1596 +0,0 @@
|
|
|
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); }
|
|
2
|
-
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; }
|
|
3
|
-
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; }
|
|
4
|
-
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; }
|
|
5
|
-
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); } }
|
|
6
|
-
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); }); }; }
|
|
7
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
-
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); } }
|
|
9
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
14
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
15
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
17
|
-
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; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
|
-
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); }
|
|
20
|
-
import { BaseModule } from "../../modules/BaseModule";
|
|
21
|
-
import { OrderModule } from "../../modules/Order";
|
|
22
|
-
import { PaymentModule } from "../../modules/Payment";
|
|
23
|
-
import { CheckoutStatus, CheckoutStep, CheckoutHooks, CheckoutErrorType } from "./types";
|
|
24
|
-
import { PaymentStatus } from "../../modules/Payment/types";
|
|
25
|
-
import { validateCheckoutData, createCheckoutError, calculateProgress } from "./utils";
|
|
26
|
-
export * from "./types";
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 结账解决方案实现
|
|
30
|
-
*
|
|
31
|
-
* 整合订单处理和支付功能,提供完整的结账流程管理。
|
|
32
|
-
* 支持多种支付方式,提供实时状态跟踪和错误处理。
|
|
33
|
-
*/
|
|
34
|
-
export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
35
|
-
_inherits(CheckoutImpl, _BaseModule);
|
|
36
|
-
var _super = _createSuper(CheckoutImpl);
|
|
37
|
-
function CheckoutImpl(name, version) {
|
|
38
|
-
var _this;
|
|
39
|
-
_classCallCheck(this, CheckoutImpl);
|
|
40
|
-
_this = _super.call(this, name || 'checkout', version || '1.0.0');
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName", 'checkout');
|
|
42
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
43
|
-
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
44
|
-
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
46
|
-
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
47
|
-
return _this;
|
|
48
|
-
}
|
|
49
|
-
_createClass(CheckoutImpl, [{
|
|
50
|
-
key: "initialize",
|
|
51
|
-
value: function () {
|
|
52
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
53
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
54
|
-
while (1) switch (_context.prev = _context.next) {
|
|
55
|
-
case 0:
|
|
56
|
-
this.core = core;
|
|
57
|
-
this.otherParams = options.otherParams || {};
|
|
58
|
-
|
|
59
|
-
// 获取依赖的插件
|
|
60
|
-
this.request = core.getPlugin('request');
|
|
61
|
-
if (this.request) {
|
|
62
|
-
_context.next = 5;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
throw new Error('Checkout 解决方案需要 request 插件支持');
|
|
66
|
-
case 5:
|
|
67
|
-
// 初始化状态
|
|
68
|
-
this.store = {
|
|
69
|
-
order: new OrderModule(),
|
|
70
|
-
payment: new PaymentModule(),
|
|
71
|
-
status: CheckoutStatus.Initializing,
|
|
72
|
-
step: CheckoutStep.OrderConfirmation,
|
|
73
|
-
cartItems: [],
|
|
74
|
-
paymentMethods: []
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
// 注册并初始化子模块
|
|
78
|
-
_context.next = 8;
|
|
79
|
-
return this.initializeSubModules(core, options);
|
|
80
|
-
case 8:
|
|
81
|
-
_context.next = 10;
|
|
82
|
-
return this.preloadPaymentMethods();
|
|
83
|
-
case 10:
|
|
84
|
-
_context.next = 12;
|
|
85
|
-
return this.setStatus(CheckoutStatus.Ready);
|
|
86
|
-
case 12:
|
|
87
|
-
console.log('[Checkout] 初始化完成');
|
|
88
|
-
_context.next = 15;
|
|
89
|
-
return this.core.effects.emit(CheckoutHooks.OnCheckoutInitialized, {
|
|
90
|
-
timestamp: Date.now()
|
|
91
|
-
});
|
|
92
|
-
case 15:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context.stop();
|
|
95
|
-
}
|
|
96
|
-
}, _callee, this);
|
|
97
|
-
}));
|
|
98
|
-
function initialize(_x, _x2) {
|
|
99
|
-
return _initialize.apply(this, arguments);
|
|
100
|
-
}
|
|
101
|
-
return initialize;
|
|
102
|
-
}()
|
|
103
|
-
/**
|
|
104
|
-
* 初始化子模块
|
|
105
|
-
*/
|
|
106
|
-
}, {
|
|
107
|
-
key: "initializeSubModules",
|
|
108
|
-
value: (function () {
|
|
109
|
-
var _initializeSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(core, options) {
|
|
110
|
-
var _options$store, _options$store2;
|
|
111
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
112
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
113
|
-
case 0:
|
|
114
|
-
// 初始化订单模块
|
|
115
|
-
core.registerModule(this.store.order, {
|
|
116
|
-
store: ((_options$store = options.store) === null || _options$store === void 0 ? void 0 : _options$store.order) || {},
|
|
117
|
-
otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
118
|
-
parentModule: this.name
|
|
119
|
-
})
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// 初始化支付模块
|
|
123
|
-
core.registerModule(this.store.payment, {
|
|
124
|
-
store: ((_options$store2 = options.store) === null || _options$store2 === void 0 ? void 0 : _options$store2.payment) || {},
|
|
125
|
-
otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
126
|
-
parentModule: this.name
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// 监听支付模块事件
|
|
131
|
-
this.setupPaymentEventListeners();
|
|
132
|
-
case 3:
|
|
133
|
-
case "end":
|
|
134
|
-
return _context2.stop();
|
|
135
|
-
}
|
|
136
|
-
}, _callee2, this);
|
|
137
|
-
}));
|
|
138
|
-
function initializeSubModules(_x3, _x4) {
|
|
139
|
-
return _initializeSubModules.apply(this, arguments);
|
|
140
|
-
}
|
|
141
|
-
return initializeSubModules;
|
|
142
|
-
}()
|
|
143
|
-
/**
|
|
144
|
-
* 设置支付模块事件监听
|
|
145
|
-
*/
|
|
146
|
-
)
|
|
147
|
-
}, {
|
|
148
|
-
key: "setupPaymentEventListeners",
|
|
149
|
-
value: function setupPaymentEventListeners() {
|
|
150
|
-
var _this2 = this;
|
|
151
|
-
// 监听支付成功事件
|
|
152
|
-
this.core.effects.on('payment:onPaymentSyncSuccess', /*#__PURE__*/function () {
|
|
153
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
|
|
154
|
-
var _this2$store$currentO;
|
|
155
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
156
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
157
|
-
case 0:
|
|
158
|
-
if (!(((_this2$store$currentO = _this2.store.currentOrder) === null || _this2$store$currentO === void 0 ? void 0 : _this2$store$currentO.uuid) === data.orderUuid)) {
|
|
159
|
-
_context3.next = 3;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
_context3.next = 3;
|
|
163
|
-
return _this2.handlePaymentSuccess(data);
|
|
164
|
-
case 3:
|
|
165
|
-
case "end":
|
|
166
|
-
return _context3.stop();
|
|
167
|
-
}
|
|
168
|
-
}, _callee3);
|
|
169
|
-
}));
|
|
170
|
-
return function (_x5) {
|
|
171
|
-
return _ref.apply(this, arguments);
|
|
172
|
-
};
|
|
173
|
-
}());
|
|
174
|
-
|
|
175
|
-
// 监听支付失败事件
|
|
176
|
-
this.core.effects.on('payment:onPaymentSyncError', /*#__PURE__*/function () {
|
|
177
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
|
|
178
|
-
var _this2$store$currentO2;
|
|
179
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
180
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
181
|
-
case 0:
|
|
182
|
-
if (!(((_this2$store$currentO2 = _this2.store.currentOrder) === null || _this2$store$currentO2 === void 0 ? void 0 : _this2$store$currentO2.uuid) === data.orderUuid)) {
|
|
183
|
-
_context4.next = 3;
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
_context4.next = 3;
|
|
187
|
-
return _this2.handlePaymentError(data);
|
|
188
|
-
case 3:
|
|
189
|
-
case "end":
|
|
190
|
-
return _context4.stop();
|
|
191
|
-
}
|
|
192
|
-
}, _callee4);
|
|
193
|
-
}));
|
|
194
|
-
return function (_x6) {
|
|
195
|
-
return _ref2.apply(this, arguments);
|
|
196
|
-
};
|
|
197
|
-
}());
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* 初始化结账流程
|
|
202
|
-
*/
|
|
203
|
-
}, {
|
|
204
|
-
key: "initializeCheckoutAsync",
|
|
205
|
-
value: (function () {
|
|
206
|
-
var _initializeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
207
|
-
var validation;
|
|
208
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
209
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
210
|
-
case 0:
|
|
211
|
-
_context5.prev = 0;
|
|
212
|
-
_context5.next = 3;
|
|
213
|
-
return this.setStatus(CheckoutStatus.Initializing);
|
|
214
|
-
case 3:
|
|
215
|
-
_context5.next = 5;
|
|
216
|
-
return this.validateCheckoutParams(params);
|
|
217
|
-
case 5:
|
|
218
|
-
validation = _context5.sent;
|
|
219
|
-
if (validation.valid) {
|
|
220
|
-
_context5.next = 8;
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
224
|
-
case 8:
|
|
225
|
-
// 保存购物车数据
|
|
226
|
-
this.store.cartItems = params.cartItems;
|
|
227
|
-
|
|
228
|
-
// 设置为就绪状态
|
|
229
|
-
_context5.next = 11;
|
|
230
|
-
return this.setStatus(CheckoutStatus.Ready);
|
|
231
|
-
case 11:
|
|
232
|
-
_context5.next = 13;
|
|
233
|
-
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
234
|
-
case 13:
|
|
235
|
-
console.log('[Checkout] 结账流程初始化完成');
|
|
236
|
-
_context5.next = 21;
|
|
237
|
-
break;
|
|
238
|
-
case 16:
|
|
239
|
-
_context5.prev = 16;
|
|
240
|
-
_context5.t0 = _context5["catch"](0);
|
|
241
|
-
_context5.next = 20;
|
|
242
|
-
return this.handleError(_context5.t0, CheckoutErrorType.UnknownError);
|
|
243
|
-
case 20:
|
|
244
|
-
throw _context5.t0;
|
|
245
|
-
case 21:
|
|
246
|
-
case "end":
|
|
247
|
-
return _context5.stop();
|
|
248
|
-
}
|
|
249
|
-
}, _callee5, this, [[0, 16]]);
|
|
250
|
-
}));
|
|
251
|
-
function initializeCheckoutAsync(_x7) {
|
|
252
|
-
return _initializeCheckoutAsync.apply(this, arguments);
|
|
253
|
-
}
|
|
254
|
-
return initializeCheckoutAsync;
|
|
255
|
-
}()
|
|
256
|
-
/**
|
|
257
|
-
* 创建本地订单 (前端模拟下单流程)
|
|
258
|
-
*
|
|
259
|
-
* 此方法用于在前端模拟整个下单流程,创建一个本地的虚拟订单。
|
|
260
|
-
* 用户在购物车点击下单时,会把购物车参数传递给此方法,
|
|
261
|
-
* 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
|
|
262
|
-
*/
|
|
263
|
-
)
|
|
264
|
-
}, {
|
|
265
|
-
key: "createLocalOrderAsync",
|
|
266
|
-
value: (function () {
|
|
267
|
-
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
|
|
268
|
-
var validation, localOrderId, amountInfo, paymentOrder;
|
|
269
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
270
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
271
|
-
case 0:
|
|
272
|
-
_context6.prev = 0;
|
|
273
|
-
_context6.next = 3;
|
|
274
|
-
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
275
|
-
case 3:
|
|
276
|
-
_context6.next = 5;
|
|
277
|
-
return this.validateLocalOrderData(params.orderData);
|
|
278
|
-
case 5:
|
|
279
|
-
validation = _context6.sent;
|
|
280
|
-
if (validation.valid) {
|
|
281
|
-
_context6.next = 8;
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
285
|
-
case 8:
|
|
286
|
-
// 生成本地虚拟订单ID (后续可以被真实订单ID替换)
|
|
287
|
-
localOrderId = this.generateLocalOrderId(); // 从购物车小计数据中提取金额信息
|
|
288
|
-
amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // 保存原始订单数据到状态中
|
|
289
|
-
this.store.localOrderData = params.orderData;
|
|
290
|
-
|
|
291
|
-
// 创建支付订单对象
|
|
292
|
-
_context6.next = 13;
|
|
293
|
-
return this.store.payment.createPaymentOrderAsync({
|
|
294
|
-
order_id: localOrderId,
|
|
295
|
-
total_amount: amountInfo.totalAmount,
|
|
296
|
-
is_deposit: params.orderData.is_deposit || 0,
|
|
297
|
-
deposit_amount: amountInfo.depositAmount || '0.00',
|
|
298
|
-
order_info: {
|
|
299
|
-
original_order_data: params.orderData,
|
|
300
|
-
cart_summary: params.cartSummary,
|
|
301
|
-
created_at: new Date().toISOString(),
|
|
302
|
-
platform: params.orderData.platform.toLowerCase(),
|
|
303
|
-
type: params.orderData.type,
|
|
304
|
-
schedule_date: params.orderData.schedule_date,
|
|
305
|
-
shop_note: params.orderData.shop_note,
|
|
306
|
-
amount_breakdown: amountInfo
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
case 13:
|
|
310
|
-
paymentOrder = _context6.sent;
|
|
311
|
-
this.store.currentOrder = paymentOrder;
|
|
312
|
-
_context6.next = 17;
|
|
313
|
-
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
314
|
-
case 17:
|
|
315
|
-
_context6.next = 19;
|
|
316
|
-
return this.setStep(CheckoutStep.PaymentMethod);
|
|
317
|
-
case 19:
|
|
318
|
-
if (!params.autoPayment) {
|
|
319
|
-
_context6.next = 22;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
_context6.next = 22;
|
|
323
|
-
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
324
|
-
case 22:
|
|
325
|
-
_context6.next = 24;
|
|
326
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
327
|
-
order: paymentOrder,
|
|
328
|
-
timestamp: Date.now()
|
|
329
|
-
});
|
|
330
|
-
case 24:
|
|
331
|
-
console.log('[Checkout] 本地订单创建成功:', {
|
|
332
|
-
localOrderId: localOrderId,
|
|
333
|
-
uuid: paymentOrder.uuid,
|
|
334
|
-
totalAmount: amountInfo.totalAmount,
|
|
335
|
-
subTotal: amountInfo.subTotal,
|
|
336
|
-
taxAmount: amountInfo.taxAmount
|
|
337
|
-
});
|
|
338
|
-
return _context6.abrupt("return", paymentOrder);
|
|
339
|
-
case 28:
|
|
340
|
-
_context6.prev = 28;
|
|
341
|
-
_context6.t0 = _context6["catch"](0);
|
|
342
|
-
_context6.next = 32;
|
|
343
|
-
return this.handleError(_context6.t0, CheckoutErrorType.OrderCreationFailed);
|
|
344
|
-
case 32:
|
|
345
|
-
_context6.next = 34;
|
|
346
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
347
|
-
error: this.store.lastError,
|
|
348
|
-
timestamp: Date.now()
|
|
349
|
-
});
|
|
350
|
-
case 34:
|
|
351
|
-
throw _context6.t0;
|
|
352
|
-
case 35:
|
|
353
|
-
case "end":
|
|
354
|
-
return _context6.stop();
|
|
355
|
-
}
|
|
356
|
-
}, _callee6, this, [[0, 28]]);
|
|
357
|
-
}));
|
|
358
|
-
function createLocalOrderAsync(_x8) {
|
|
359
|
-
return _createLocalOrderAsync.apply(this, arguments);
|
|
360
|
-
}
|
|
361
|
-
return createLocalOrderAsync;
|
|
362
|
-
}()
|
|
363
|
-
/**
|
|
364
|
-
* 手动下单 (根据虚拟订单生成实际订单)
|
|
365
|
-
*
|
|
366
|
-
* 使用当前存储的本地订单数据调用 Order 模块创建真实订单
|
|
367
|
-
*/
|
|
368
|
-
)
|
|
369
|
-
}, {
|
|
370
|
-
key: "placeOrderAsync",
|
|
371
|
-
value: (function () {
|
|
372
|
-
var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
373
|
-
var params,
|
|
374
|
-
_this$store$localOrde,
|
|
375
|
-
_data,
|
|
376
|
-
orderData,
|
|
377
|
-
orderResponse,
|
|
378
|
-
realOrderId,
|
|
379
|
-
updatedOrder,
|
|
380
|
-
errorMessage,
|
|
381
|
-
_args7 = arguments;
|
|
382
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
383
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
384
|
-
case 0:
|
|
385
|
-
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
386
|
-
_context7.prev = 1;
|
|
387
|
-
if (this.store.localOrderData) {
|
|
388
|
-
_context7.next = 4;
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到本地订单数据,请先调用 createLocalOrderAsync 创建虚拟订单');
|
|
392
|
-
case 4:
|
|
393
|
-
if (this.store.currentOrder) {
|
|
394
|
-
_context7.next = 6;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到当前订单,请先创建虚拟订单');
|
|
398
|
-
case 6:
|
|
399
|
-
console.log('[Checkout] 开始手动下单流程...');
|
|
400
|
-
_context7.next = 9;
|
|
401
|
-
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
402
|
-
case 9:
|
|
403
|
-
// 准备订单数据,使用 Order 模块期望的格式
|
|
404
|
-
orderData = {
|
|
405
|
-
cartItems: this.store.cartItems,
|
|
406
|
-
type: this.store.localOrderData.type,
|
|
407
|
-
platform: (_this$store$localOrde = this.store.localOrderData.platform) === null || _this$store$localOrde === void 0 ? void 0 : _this$store$localOrde.toLowerCase()
|
|
408
|
-
}; // 调用 Order 模块提交订单
|
|
409
|
-
_context7.next = 12;
|
|
410
|
-
return this.store.order.submitOrder({
|
|
411
|
-
url: params.url,
|
|
412
|
-
// 可选的自定义 URL
|
|
413
|
-
query: orderData
|
|
414
|
-
});
|
|
415
|
-
case 12:
|
|
416
|
-
orderResponse = _context7.sent;
|
|
417
|
-
// 提取真实订单ID(假设返回格式包含 order_id)
|
|
418
|
-
realOrderId = (orderResponse === null || orderResponse === void 0 || (_data = orderResponse.data) === null || _data === void 0 ? void 0 : _data.order_id) || (orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.order_id);
|
|
419
|
-
if (realOrderId) {
|
|
420
|
-
_context7.next = 16;
|
|
421
|
-
break;
|
|
422
|
-
}
|
|
423
|
-
throw createCheckoutError(CheckoutErrorType.OrderCreationFailed, '订单创建成功但未返回订单ID');
|
|
424
|
-
case 16:
|
|
425
|
-
console.log('[Checkout] 真实订单创建成功:', realOrderId);
|
|
426
|
-
|
|
427
|
-
// 如果设置了自动替换订单ID,则替换虚拟订单ID
|
|
428
|
-
if (!(params.autoReplaceOrderId !== false)) {
|
|
429
|
-
_context7.next = 23;
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
// 默认为 true
|
|
433
|
-
console.log('[Checkout] 自动替换虚拟订单ID为真实订单ID...');
|
|
434
|
-
_context7.next = 21;
|
|
435
|
-
return this.replaceLocalOrderIdAsync(realOrderId);
|
|
436
|
-
case 21:
|
|
437
|
-
updatedOrder = _context7.sent;
|
|
438
|
-
if (updatedOrder) {
|
|
439
|
-
console.log('[Checkout] 订单ID替换成功:', {
|
|
440
|
-
oldId: this.store.currentOrder.order_id,
|
|
441
|
-
newId: realOrderId
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
case 23:
|
|
445
|
-
_context7.next = 25;
|
|
446
|
-
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
447
|
-
case 25:
|
|
448
|
-
_context7.next = 27;
|
|
449
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
450
|
-
order: this.store.currentOrder,
|
|
451
|
-
timestamp: Date.now()
|
|
452
|
-
});
|
|
453
|
-
case 27:
|
|
454
|
-
console.log('[Checkout] 手动下单流程完成');
|
|
455
|
-
return _context7.abrupt("return", {
|
|
456
|
-
success: true,
|
|
457
|
-
orderId: realOrderId
|
|
458
|
-
});
|
|
459
|
-
case 31:
|
|
460
|
-
_context7.prev = 31;
|
|
461
|
-
_context7.t0 = _context7["catch"](1);
|
|
462
|
-
// 处理 CheckoutError 对象
|
|
463
|
-
errorMessage = '下单失败';
|
|
464
|
-
if (_context7.t0 && _typeof(_context7.t0) === 'object' && 'message' in _context7.t0) {
|
|
465
|
-
errorMessage = _context7.t0.message;
|
|
466
|
-
} else if (_context7.t0 instanceof Error) {
|
|
467
|
-
errorMessage = _context7.t0.message;
|
|
468
|
-
}
|
|
469
|
-
console.error('[Checkout] 手动下单失败:', errorMessage);
|
|
470
|
-
_context7.next = 38;
|
|
471
|
-
return this.handleError(_context7.t0, CheckoutErrorType.OrderCreationFailed);
|
|
472
|
-
case 38:
|
|
473
|
-
return _context7.abrupt("return", {
|
|
474
|
-
success: false,
|
|
475
|
-
error: errorMessage
|
|
476
|
-
});
|
|
477
|
-
case 39:
|
|
478
|
-
case "end":
|
|
479
|
-
return _context7.stop();
|
|
480
|
-
}
|
|
481
|
-
}, _callee7, this, [[1, 31]]);
|
|
482
|
-
}));
|
|
483
|
-
function placeOrderAsync() {
|
|
484
|
-
return _placeOrderAsync.apply(this, arguments);
|
|
485
|
-
}
|
|
486
|
-
return placeOrderAsync;
|
|
487
|
-
}()
|
|
488
|
-
/**
|
|
489
|
-
* 创建订单
|
|
490
|
-
*/
|
|
491
|
-
)
|
|
492
|
-
}, {
|
|
493
|
-
key: "createOrderAsync",
|
|
494
|
-
value: (function () {
|
|
495
|
-
var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
496
|
-
var _data2, checkResult, orderResponse, paymentOrder;
|
|
497
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
498
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
499
|
-
case 0:
|
|
500
|
-
_context8.prev = 0;
|
|
501
|
-
_context8.next = 3;
|
|
502
|
-
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
503
|
-
case 3:
|
|
504
|
-
// 验证购物车数据
|
|
505
|
-
checkResult = this.store.order.checkBeforeSubmitOrder({
|
|
506
|
-
cartItems: params.cartItems,
|
|
507
|
-
type: 'account' // 默认使用 account 类型
|
|
508
|
-
});
|
|
509
|
-
if (checkResult) {
|
|
510
|
-
_context8.next = 6;
|
|
511
|
-
break;
|
|
512
|
-
}
|
|
513
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '购物车数据验证失败,请检查商品信息');
|
|
514
|
-
case 6:
|
|
515
|
-
_context8.next = 8;
|
|
516
|
-
return this.store.order.submitOrder({
|
|
517
|
-
query: {
|
|
518
|
-
cartItems: params.cartItems,
|
|
519
|
-
type: params.type || 'appointment_booking',
|
|
520
|
-
platform: params.platform || 'pc'
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
case 8:
|
|
524
|
-
orderResponse = _context8.sent;
|
|
525
|
-
_context8.next = 11;
|
|
526
|
-
return this.store.payment.createPaymentOrderAsync({
|
|
527
|
-
order_id: (orderResponse === null || orderResponse === void 0 || (_data2 = orderResponse.data) === null || _data2 === void 0 ? void 0 : _data2.order_id) || "order_".concat(Date.now()),
|
|
528
|
-
total_amount: this.calculateTotalAmount(params.cartItems),
|
|
529
|
-
order_info: orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.data
|
|
530
|
-
});
|
|
531
|
-
case 11:
|
|
532
|
-
paymentOrder = _context8.sent;
|
|
533
|
-
this.store.currentOrder = paymentOrder;
|
|
534
|
-
_context8.next = 15;
|
|
535
|
-
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
536
|
-
case 15:
|
|
537
|
-
_context8.next = 17;
|
|
538
|
-
return this.setStep(CheckoutStep.PaymentMethod);
|
|
539
|
-
case 17:
|
|
540
|
-
_context8.next = 19;
|
|
541
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
542
|
-
order: paymentOrder,
|
|
543
|
-
timestamp: Date.now()
|
|
544
|
-
});
|
|
545
|
-
case 19:
|
|
546
|
-
console.log('[Checkout] 订单创建成功:', paymentOrder.id);
|
|
547
|
-
return _context8.abrupt("return", paymentOrder);
|
|
548
|
-
case 23:
|
|
549
|
-
_context8.prev = 23;
|
|
550
|
-
_context8.t0 = _context8["catch"](0);
|
|
551
|
-
_context8.next = 27;
|
|
552
|
-
return this.handleError(_context8.t0, CheckoutErrorType.OrderCreationFailed);
|
|
553
|
-
case 27:
|
|
554
|
-
_context8.next = 29;
|
|
555
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
556
|
-
error: this.store.lastError,
|
|
557
|
-
timestamp: Date.now()
|
|
558
|
-
});
|
|
559
|
-
case 29:
|
|
560
|
-
throw _context8.t0;
|
|
561
|
-
case 30:
|
|
562
|
-
case "end":
|
|
563
|
-
return _context8.stop();
|
|
564
|
-
}
|
|
565
|
-
}, _callee8, this, [[0, 23]]);
|
|
566
|
-
}));
|
|
567
|
-
function createOrderAsync(_x9) {
|
|
568
|
-
return _createOrderAsync.apply(this, arguments);
|
|
569
|
-
}
|
|
570
|
-
return createOrderAsync;
|
|
571
|
-
}()
|
|
572
|
-
/**
|
|
573
|
-
* 处理支付
|
|
574
|
-
*/
|
|
575
|
-
)
|
|
576
|
-
}, {
|
|
577
|
-
key: "processPaymentAsync",
|
|
578
|
-
value: (function () {
|
|
579
|
-
var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
580
|
-
var paymentMethod, paymentItem, result;
|
|
581
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
582
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
583
|
-
case 0:
|
|
584
|
-
_context9.prev = 0;
|
|
585
|
-
if (this.store.currentOrder) {
|
|
586
|
-
_context9.next = 3;
|
|
587
|
-
break;
|
|
588
|
-
}
|
|
589
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,请先创建订单');
|
|
590
|
-
case 3:
|
|
591
|
-
_context9.next = 5;
|
|
592
|
-
return this.setStatus(CheckoutStatus.ProcessingPayment);
|
|
593
|
-
case 5:
|
|
594
|
-
_context9.next = 7;
|
|
595
|
-
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
596
|
-
case 7:
|
|
597
|
-
// 查找支付方式
|
|
598
|
-
paymentMethod = this.store.paymentMethods.find(function (method) {
|
|
599
|
-
return method.code === params.paymentMethodCode;
|
|
600
|
-
});
|
|
601
|
-
if (paymentMethod) {
|
|
602
|
-
_context9.next = 10;
|
|
603
|
-
break;
|
|
604
|
-
}
|
|
605
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u672A\u627E\u5230\u652F\u4ED8\u65B9\u5F0F: ".concat(params.paymentMethodCode));
|
|
606
|
-
case 10:
|
|
607
|
-
// 创建支付项
|
|
608
|
-
paymentItem = {
|
|
609
|
-
code: paymentMethod.code,
|
|
610
|
-
name: paymentMethod.name,
|
|
611
|
-
type: paymentMethod.type,
|
|
612
|
-
amount: String(params.amount),
|
|
613
|
-
id: paymentMethod.id
|
|
614
|
-
}; // 添加支付项到订单
|
|
615
|
-
_context9.next = 13;
|
|
616
|
-
return this.store.payment.pushPaymentAsync(this.store.currentOrder.uuid, paymentItem);
|
|
617
|
-
case 13:
|
|
618
|
-
_context9.next = 15;
|
|
619
|
-
return this.store.payment.submitPayAsync(this.store.currentOrder.uuid);
|
|
620
|
-
case 15:
|
|
621
|
-
result = _context9.sent;
|
|
622
|
-
_context9.next = 18;
|
|
623
|
-
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
624
|
-
orderUuid: this.store.currentOrder.uuid,
|
|
625
|
-
paymentMethodCode: params.paymentMethodCode,
|
|
626
|
-
amount: String(params.amount),
|
|
627
|
-
timestamp: Date.now()
|
|
628
|
-
});
|
|
629
|
-
case 18:
|
|
630
|
-
if (!(result.status === 'success')) {
|
|
631
|
-
_context9.next = 25;
|
|
632
|
-
break;
|
|
633
|
-
}
|
|
634
|
-
_context9.next = 21;
|
|
635
|
-
return this.setStatus(CheckoutStatus.PaymentCompleted);
|
|
636
|
-
case 21:
|
|
637
|
-
_context9.next = 23;
|
|
638
|
-
return this.handlePaymentSuccess({
|
|
639
|
-
orderUuid: this.store.currentOrder.uuid,
|
|
640
|
-
timestamp: Date.now()
|
|
641
|
-
});
|
|
642
|
-
case 23:
|
|
643
|
-
_context9.next = 26;
|
|
644
|
-
break;
|
|
645
|
-
case 25:
|
|
646
|
-
throw createCheckoutError(CheckoutErrorType.PaymentFailed, '支付处理失败,请重试');
|
|
647
|
-
case 26:
|
|
648
|
-
_context9.next = 33;
|
|
649
|
-
break;
|
|
650
|
-
case 28:
|
|
651
|
-
_context9.prev = 28;
|
|
652
|
-
_context9.t0 = _context9["catch"](0);
|
|
653
|
-
_context9.next = 32;
|
|
654
|
-
return this.handleError(_context9.t0, CheckoutErrorType.PaymentFailed);
|
|
655
|
-
case 32:
|
|
656
|
-
throw _context9.t0;
|
|
657
|
-
case 33:
|
|
658
|
-
case "end":
|
|
659
|
-
return _context9.stop();
|
|
660
|
-
}
|
|
661
|
-
}, _callee9, this, [[0, 28]]);
|
|
662
|
-
}));
|
|
663
|
-
function processPaymentAsync(_x10) {
|
|
664
|
-
return _processPaymentAsync.apply(this, arguments);
|
|
665
|
-
}
|
|
666
|
-
return processPaymentAsync;
|
|
667
|
-
}()
|
|
668
|
-
/**
|
|
669
|
-
* 完成结账
|
|
670
|
-
*/
|
|
671
|
-
)
|
|
672
|
-
}, {
|
|
673
|
-
key: "completeCheckoutAsync",
|
|
674
|
-
value: (function () {
|
|
675
|
-
var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
676
|
-
var order;
|
|
677
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
678
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
679
|
-
case 0:
|
|
680
|
-
_context10.prev = 0;
|
|
681
|
-
if (this.store.currentOrder) {
|
|
682
|
-
_context10.next = 3;
|
|
683
|
-
break;
|
|
684
|
-
}
|
|
685
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单');
|
|
686
|
-
case 3:
|
|
687
|
-
_context10.next = 5;
|
|
688
|
-
return this.store.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
689
|
-
case 5:
|
|
690
|
-
order = _context10.sent;
|
|
691
|
-
if (!(!order || order.payment_status !== PaymentStatus.Finished)) {
|
|
692
|
-
_context10.next = 8;
|
|
693
|
-
break;
|
|
694
|
-
}
|
|
695
|
-
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '订单支付未完成,无法完成结账');
|
|
696
|
-
case 8:
|
|
697
|
-
_context10.next = 10;
|
|
698
|
-
return this.setStatus(CheckoutStatus.Completed);
|
|
699
|
-
case 10:
|
|
700
|
-
_context10.next = 12;
|
|
701
|
-
return this.setStep(CheckoutStep.Complete);
|
|
702
|
-
case 12:
|
|
703
|
-
_context10.next = 14;
|
|
704
|
-
return this.core.effects.emit(CheckoutHooks.OnCheckoutCompleted, {
|
|
705
|
-
orderId: order.id,
|
|
706
|
-
timestamp: Date.now()
|
|
707
|
-
});
|
|
708
|
-
case 14:
|
|
709
|
-
console.log('[Checkout] 结账流程完成:', order.id);
|
|
710
|
-
return _context10.abrupt("return", {
|
|
711
|
-
success: true,
|
|
712
|
-
orderId: String(order.id)
|
|
713
|
-
});
|
|
714
|
-
case 18:
|
|
715
|
-
_context10.prev = 18;
|
|
716
|
-
_context10.t0 = _context10["catch"](0);
|
|
717
|
-
_context10.next = 22;
|
|
718
|
-
return this.handleError(_context10.t0, CheckoutErrorType.UnknownError);
|
|
719
|
-
case 22:
|
|
720
|
-
return _context10.abrupt("return", {
|
|
721
|
-
success: false
|
|
722
|
-
});
|
|
723
|
-
case 23:
|
|
724
|
-
case "end":
|
|
725
|
-
return _context10.stop();
|
|
726
|
-
}
|
|
727
|
-
}, _callee10, this, [[0, 18]]);
|
|
728
|
-
}));
|
|
729
|
-
function completeCheckoutAsync() {
|
|
730
|
-
return _completeCheckoutAsync.apply(this, arguments);
|
|
731
|
-
}
|
|
732
|
-
return completeCheckoutAsync;
|
|
733
|
-
}()
|
|
734
|
-
/**
|
|
735
|
-
* 取消结账
|
|
736
|
-
*/
|
|
737
|
-
)
|
|
738
|
-
}, {
|
|
739
|
-
key: "cancelCheckoutAsync",
|
|
740
|
-
value: (function () {
|
|
741
|
-
var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
742
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
743
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
744
|
-
case 0:
|
|
745
|
-
_context11.prev = 0;
|
|
746
|
-
if (!this.store.currentOrder) {
|
|
747
|
-
_context11.next = 5;
|
|
748
|
-
break;
|
|
749
|
-
}
|
|
750
|
-
_context11.next = 4;
|
|
751
|
-
return this.store.payment.deleteOrderAsync(this.store.currentOrder.uuid);
|
|
752
|
-
case 4:
|
|
753
|
-
this.store.currentOrder = undefined;
|
|
754
|
-
case 5:
|
|
755
|
-
_context11.next = 7;
|
|
756
|
-
return this.setStatus(CheckoutStatus.Cancelled);
|
|
757
|
-
case 7:
|
|
758
|
-
_context11.next = 9;
|
|
759
|
-
return this.core.effects.emit(CheckoutHooks.OnCheckoutCancelled, {
|
|
760
|
-
timestamp: Date.now()
|
|
761
|
-
});
|
|
762
|
-
case 9:
|
|
763
|
-
console.log('[Checkout] 结账流程已取消');
|
|
764
|
-
_context11.next = 17;
|
|
765
|
-
break;
|
|
766
|
-
case 12:
|
|
767
|
-
_context11.prev = 12;
|
|
768
|
-
_context11.t0 = _context11["catch"](0);
|
|
769
|
-
console.error('[Checkout] 取消结账失败:', _context11.t0);
|
|
770
|
-
_context11.next = 17;
|
|
771
|
-
return this.handleError(_context11.t0, CheckoutErrorType.UnknownError);
|
|
772
|
-
case 17:
|
|
773
|
-
case "end":
|
|
774
|
-
return _context11.stop();
|
|
775
|
-
}
|
|
776
|
-
}, _callee11, this, [[0, 12]]);
|
|
777
|
-
}));
|
|
778
|
-
function cancelCheckoutAsync() {
|
|
779
|
-
return _cancelCheckoutAsync.apply(this, arguments);
|
|
780
|
-
}
|
|
781
|
-
return cancelCheckoutAsync;
|
|
782
|
-
}()
|
|
783
|
-
/**
|
|
784
|
-
* 获取结账状态
|
|
785
|
-
*/
|
|
786
|
-
)
|
|
787
|
-
}, {
|
|
788
|
-
key: "getCheckoutStatus",
|
|
789
|
-
value: function getCheckoutStatus() {
|
|
790
|
-
return {
|
|
791
|
-
status: this.store.status,
|
|
792
|
-
step: this.store.step,
|
|
793
|
-
progress: calculateProgress(this.store.status, this.store.step),
|
|
794
|
-
message: this.getStatusMessage(),
|
|
795
|
-
error: this.store.lastError
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* 获取结账摘要
|
|
801
|
-
*/
|
|
802
|
-
}, {
|
|
803
|
-
key: "getCheckoutSummaryAsync",
|
|
804
|
-
value: (function () {
|
|
805
|
-
var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
806
|
-
var _this$store$currentOr, _this$store$currentOr2, _this$store$currentOr3;
|
|
807
|
-
var totalAmount, paidAmount, remainingAmount;
|
|
808
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
809
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
810
|
-
case 0:
|
|
811
|
-
totalAmount = ((_this$store$currentOr = this.store.currentOrder) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.total_amount) || '0.00';
|
|
812
|
-
paidAmount = this.calculatePaidAmount();
|
|
813
|
-
remainingAmount = ((_this$store$currentOr2 = this.store.currentOrder) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.expect_amount) || totalAmount;
|
|
814
|
-
return _context12.abrupt("return", {
|
|
815
|
-
order: this.store.currentOrder,
|
|
816
|
-
totalAmount: totalAmount,
|
|
817
|
-
paidAmount: paidAmount,
|
|
818
|
-
remainingAmount: remainingAmount,
|
|
819
|
-
paymentStatus: ((_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.payment_status) || PaymentStatus.Processing,
|
|
820
|
-
availablePaymentMethods: this.store.paymentMethods
|
|
821
|
-
});
|
|
822
|
-
case 4:
|
|
823
|
-
case "end":
|
|
824
|
-
return _context12.stop();
|
|
825
|
-
}
|
|
826
|
-
}, _callee12, this);
|
|
827
|
-
}));
|
|
828
|
-
function getCheckoutSummaryAsync() {
|
|
829
|
-
return _getCheckoutSummaryAsync.apply(this, arguments);
|
|
830
|
-
}
|
|
831
|
-
return getCheckoutSummaryAsync;
|
|
832
|
-
}()
|
|
833
|
-
/**
|
|
834
|
-
* 获取可用支付方式
|
|
835
|
-
*/
|
|
836
|
-
)
|
|
837
|
-
}, {
|
|
838
|
-
key: "getAvailablePaymentMethodsAsync",
|
|
839
|
-
value: (function () {
|
|
840
|
-
var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
841
|
-
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
842
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
843
|
-
case 0:
|
|
844
|
-
if (!(this.store.paymentMethods.length === 0)) {
|
|
845
|
-
_context13.next = 4;
|
|
846
|
-
break;
|
|
847
|
-
}
|
|
848
|
-
console.log('[Checkout] 支付方式缓存为空,重新加载...');
|
|
849
|
-
_context13.next = 4;
|
|
850
|
-
return this.preloadPaymentMethods();
|
|
851
|
-
case 4:
|
|
852
|
-
return _context13.abrupt("return", this.store.paymentMethods);
|
|
853
|
-
case 5:
|
|
854
|
-
case "end":
|
|
855
|
-
return _context13.stop();
|
|
856
|
-
}
|
|
857
|
-
}, _callee13, this);
|
|
858
|
-
}));
|
|
859
|
-
function getAvailablePaymentMethodsAsync() {
|
|
860
|
-
return _getAvailablePaymentMethodsAsync.apply(this, arguments);
|
|
861
|
-
}
|
|
862
|
-
return getAvailablePaymentMethodsAsync;
|
|
863
|
-
}()
|
|
864
|
-
/**
|
|
865
|
-
* 刷新支付方式缓存
|
|
866
|
-
*
|
|
867
|
-
* 强制重新从服务器获取支付方式列表,更新本地缓存
|
|
868
|
-
*/
|
|
869
|
-
)
|
|
870
|
-
}, {
|
|
871
|
-
key: "refreshPaymentMethodsAsync",
|
|
872
|
-
value: (function () {
|
|
873
|
-
var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
874
|
-
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
875
|
-
while (1) switch (_context14.prev = _context14.next) {
|
|
876
|
-
case 0:
|
|
877
|
-
console.log('[Checkout] 强制刷新支付方式缓存...');
|
|
878
|
-
_context14.next = 3;
|
|
879
|
-
return this.preloadPaymentMethods();
|
|
880
|
-
case 3:
|
|
881
|
-
return _context14.abrupt("return", this.store.paymentMethods);
|
|
882
|
-
case 4:
|
|
883
|
-
case "end":
|
|
884
|
-
return _context14.stop();
|
|
885
|
-
}
|
|
886
|
-
}, _callee14, this);
|
|
887
|
-
}));
|
|
888
|
-
function refreshPaymentMethodsAsync() {
|
|
889
|
-
return _refreshPaymentMethodsAsync.apply(this, arguments);
|
|
890
|
-
}
|
|
891
|
-
return refreshPaymentMethodsAsync;
|
|
892
|
-
}()
|
|
893
|
-
/**
|
|
894
|
-
* 获取当前订单基础信息
|
|
895
|
-
*
|
|
896
|
-
* 返回当前订单的基础信息,包括订单状态、金额、支付状态等
|
|
897
|
-
*/
|
|
898
|
-
)
|
|
899
|
-
}, {
|
|
900
|
-
key: "getCurrentOrderInfo",
|
|
901
|
-
value: function getCurrentOrderInfo() {
|
|
902
|
-
try {
|
|
903
|
-
var _localOrderData$platf;
|
|
904
|
-
var _this$store = this.store,
|
|
905
|
-
currentOrder = _this$store.currentOrder,
|
|
906
|
-
status = _this$store.status,
|
|
907
|
-
step = _this$store.step,
|
|
908
|
-
cartItems = _this$store.cartItems,
|
|
909
|
-
localOrderData = _this$store.localOrderData;
|
|
910
|
-
if (!currentOrder) {
|
|
911
|
-
console.log('[Checkout] 当前没有活跃订单');
|
|
912
|
-
return null;
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
// 从本地订单数据或订单信息中提取基础信息
|
|
916
|
-
var orderInfo = currentOrder.order_info || {};
|
|
917
|
-
var createdAt = orderInfo.created_at || new Date().toISOString();
|
|
918
|
-
var orderType = (localOrderData === null || localOrderData === void 0 ? void 0 : localOrderData.type) || orderInfo.type || 'virtual';
|
|
919
|
-
var platform = (localOrderData === null || localOrderData === void 0 || (_localOrderData$platf = localOrderData.platform) === null || _localOrderData$platf === void 0 ? void 0 : _localOrderData$platf.toLowerCase()) || orderInfo.platform || 'pc';
|
|
920
|
-
var result = {
|
|
921
|
-
uuid: currentOrder.uuid,
|
|
922
|
-
orderId: currentOrder.order_id,
|
|
923
|
-
status: status,
|
|
924
|
-
step: step,
|
|
925
|
-
totalAmount: currentOrder.total_amount,
|
|
926
|
-
remainingAmount: currentOrder.expect_amount,
|
|
927
|
-
paymentStatus: currentOrder.payment_status,
|
|
928
|
-
isDeposit: Boolean(currentOrder.is_deposit),
|
|
929
|
-
depositAmount: currentOrder.deposit_amount,
|
|
930
|
-
orderType: orderType,
|
|
931
|
-
platform: platform,
|
|
932
|
-
createdAt: createdAt,
|
|
933
|
-
itemCount: cartItems.length,
|
|
934
|
-
hasLocalOrderData: Boolean(localOrderData)
|
|
935
|
-
};
|
|
936
|
-
console.log('[Checkout] 获取当前订单基础信息:', {
|
|
937
|
-
uuid: result.uuid,
|
|
938
|
-
orderId: result.orderId,
|
|
939
|
-
status: result.status,
|
|
940
|
-
totalAmount: result.totalAmount,
|
|
941
|
-
remainingAmount: result.remainingAmount
|
|
942
|
-
});
|
|
943
|
-
return result;
|
|
944
|
-
} catch (error) {
|
|
945
|
-
console.error('[Checkout] 获取当前订单基础信息失败:', error);
|
|
946
|
-
return null;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/**
|
|
951
|
-
* 验证结账前置条件
|
|
952
|
-
*/
|
|
953
|
-
}, {
|
|
954
|
-
key: "validateCheckoutAsync",
|
|
955
|
-
value: (function () {
|
|
956
|
-
var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
957
|
-
var errors;
|
|
958
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
959
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
960
|
-
case 0:
|
|
961
|
-
errors = []; // 验证购物车
|
|
962
|
-
if (!this.store.cartItems || this.store.cartItems.length === 0) {
|
|
963
|
-
errors.push('购物车为空');
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
// 验证支付方式
|
|
967
|
-
if (this.store.paymentMethods.length === 0) {
|
|
968
|
-
errors.push('无可用支付方式');
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
// 验证订单状态
|
|
972
|
-
if (this.store.status === CheckoutStatus.Error) {
|
|
973
|
-
errors.push('结账流程存在错误');
|
|
974
|
-
}
|
|
975
|
-
return _context15.abrupt("return", {
|
|
976
|
-
valid: errors.length === 0,
|
|
977
|
-
errors: errors
|
|
978
|
-
});
|
|
979
|
-
case 5:
|
|
980
|
-
case "end":
|
|
981
|
-
return _context15.stop();
|
|
982
|
-
}
|
|
983
|
-
}, _callee15, this);
|
|
984
|
-
}));
|
|
985
|
-
function validateCheckoutAsync() {
|
|
986
|
-
return _validateCheckoutAsync.apply(this, arguments);
|
|
987
|
-
}
|
|
988
|
-
return validateCheckoutAsync;
|
|
989
|
-
}()
|
|
990
|
-
/**
|
|
991
|
-
* 重试失败的操作
|
|
992
|
-
*/
|
|
993
|
-
)
|
|
994
|
-
}, {
|
|
995
|
-
key: "retryFailedOperationAsync",
|
|
996
|
-
value: (function () {
|
|
997
|
-
var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
998
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
999
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
1000
|
-
case 0:
|
|
1001
|
-
_context16.prev = 0;
|
|
1002
|
-
if (!(this.store.status === CheckoutStatus.Error && this.store.lastError)) {
|
|
1003
|
-
_context16.next = 14;
|
|
1004
|
-
break;
|
|
1005
|
-
}
|
|
1006
|
-
_context16.t0 = this.store.lastError.type;
|
|
1007
|
-
_context16.next = _context16.t0 === CheckoutErrorType.OrderCreationFailed ? 5 : _context16.t0 === CheckoutErrorType.PaymentFailed ? 9 : 13;
|
|
1008
|
-
break;
|
|
1009
|
-
case 5:
|
|
1010
|
-
if (!(this.store.cartItems.length > 0)) {
|
|
1011
|
-
_context16.next = 8;
|
|
1012
|
-
break;
|
|
1013
|
-
}
|
|
1014
|
-
_context16.next = 8;
|
|
1015
|
-
return this.createOrderAsync({
|
|
1016
|
-
cartItems: this.store.cartItems
|
|
1017
|
-
});
|
|
1018
|
-
case 8:
|
|
1019
|
-
return _context16.abrupt("break", 14);
|
|
1020
|
-
case 9:
|
|
1021
|
-
if (!this.store.currentOrder) {
|
|
1022
|
-
_context16.next = 12;
|
|
1023
|
-
break;
|
|
1024
|
-
}
|
|
1025
|
-
_context16.next = 12;
|
|
1026
|
-
return this.store.payment.runPaymentSyncQueue();
|
|
1027
|
-
case 12:
|
|
1028
|
-
return _context16.abrupt("break", 14);
|
|
1029
|
-
case 13:
|
|
1030
|
-
console.warn('[Checkout] 无法重试此类型的错误:', this.store.lastError.type);
|
|
1031
|
-
case 14:
|
|
1032
|
-
_context16.next = 20;
|
|
1033
|
-
break;
|
|
1034
|
-
case 16:
|
|
1035
|
-
_context16.prev = 16;
|
|
1036
|
-
_context16.t1 = _context16["catch"](0);
|
|
1037
|
-
_context16.next = 20;
|
|
1038
|
-
return this.handleError(_context16.t1, CheckoutErrorType.UnknownError);
|
|
1039
|
-
case 20:
|
|
1040
|
-
case "end":
|
|
1041
|
-
return _context16.stop();
|
|
1042
|
-
}
|
|
1043
|
-
}, _callee16, this, [[0, 16]]);
|
|
1044
|
-
}));
|
|
1045
|
-
function retryFailedOperationAsync() {
|
|
1046
|
-
return _retryFailedOperationAsync.apply(this, arguments);
|
|
1047
|
-
}
|
|
1048
|
-
return retryFailedOperationAsync;
|
|
1049
|
-
}()
|
|
1050
|
-
/**
|
|
1051
|
-
* 设置当前步骤
|
|
1052
|
-
*/
|
|
1053
|
-
)
|
|
1054
|
-
}, {
|
|
1055
|
-
key: "setCurrentStep",
|
|
1056
|
-
value: function setCurrentStep(step) {
|
|
1057
|
-
var oldStep = this.store.step;
|
|
1058
|
-
this.store.step = step;
|
|
1059
|
-
this.core.effects.emit(CheckoutHooks.OnStepChanged, {
|
|
1060
|
-
oldStep: oldStep,
|
|
1061
|
-
newStep: step,
|
|
1062
|
-
timestamp: Date.now()
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
/**
|
|
1067
|
-
* 获取订单模块
|
|
1068
|
-
*/
|
|
1069
|
-
}, {
|
|
1070
|
-
key: "getOrderModule",
|
|
1071
|
-
value: function getOrderModule() {
|
|
1072
|
-
return this.store.order;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
/**
|
|
1076
|
-
* 获取支付模块
|
|
1077
|
-
*/
|
|
1078
|
-
}, {
|
|
1079
|
-
key: "getPaymentModule",
|
|
1080
|
-
value: function getPaymentModule() {
|
|
1081
|
-
return this.store.payment;
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
/**
|
|
1085
|
-
* 替换本地订单ID为真实订单ID
|
|
1086
|
-
*
|
|
1087
|
-
* 当后端订单创建完成后,调用此方法将本地虚拟订单ID替换为真实订单ID
|
|
1088
|
-
*
|
|
1089
|
-
* @param newOrderId 后端返回的真实订单ID
|
|
1090
|
-
* @returns 更新后的订单对象,如果当前没有订单则返回null
|
|
1091
|
-
*/
|
|
1092
|
-
}, {
|
|
1093
|
-
key: "replaceLocalOrderIdAsync",
|
|
1094
|
-
value: (function () {
|
|
1095
|
-
var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(newOrderId) {
|
|
1096
|
-
var updatedOrder;
|
|
1097
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1098
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
1099
|
-
case 0:
|
|
1100
|
-
_context17.prev = 0;
|
|
1101
|
-
if (this.store.currentOrder) {
|
|
1102
|
-
_context17.next = 4;
|
|
1103
|
-
break;
|
|
1104
|
-
}
|
|
1105
|
-
console.warn('[Checkout] 没有当前订单,无法替换订单ID');
|
|
1106
|
-
return _context17.abrupt("return", null);
|
|
1107
|
-
case 4:
|
|
1108
|
-
_context17.next = 6;
|
|
1109
|
-
return this.store.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, newOrderId);
|
|
1110
|
-
case 6:
|
|
1111
|
-
updatedOrder = _context17.sent;
|
|
1112
|
-
if (!updatedOrder) {
|
|
1113
|
-
_context17.next = 12;
|
|
1114
|
-
break;
|
|
1115
|
-
}
|
|
1116
|
-
// 更新当前订单引用
|
|
1117
|
-
this.store.currentOrder = updatedOrder;
|
|
1118
|
-
|
|
1119
|
-
// 触发订单更新事件
|
|
1120
|
-
_context17.next = 11;
|
|
1121
|
-
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1122
|
-
order: updatedOrder,
|
|
1123
|
-
timestamp: Date.now()
|
|
1124
|
-
});
|
|
1125
|
-
case 11:
|
|
1126
|
-
console.log('[Checkout] 本地订单ID替换成功:', {
|
|
1127
|
-
uuid: updatedOrder.uuid,
|
|
1128
|
-
newOrderId: updatedOrder.id
|
|
1129
|
-
});
|
|
1130
|
-
case 12:
|
|
1131
|
-
return _context17.abrupt("return", updatedOrder);
|
|
1132
|
-
case 15:
|
|
1133
|
-
_context17.prev = 15;
|
|
1134
|
-
_context17.t0 = _context17["catch"](0);
|
|
1135
|
-
console.error('[Checkout] 替换订单ID失败:', _context17.t0);
|
|
1136
|
-
_context17.next = 20;
|
|
1137
|
-
return this.handleError(_context17.t0, CheckoutErrorType.UnknownError);
|
|
1138
|
-
case 20:
|
|
1139
|
-
return _context17.abrupt("return", null);
|
|
1140
|
-
case 21:
|
|
1141
|
-
case "end":
|
|
1142
|
-
return _context17.stop();
|
|
1143
|
-
}
|
|
1144
|
-
}, _callee17, this, [[0, 15]]);
|
|
1145
|
-
}));
|
|
1146
|
-
function replaceLocalOrderIdAsync(_x11) {
|
|
1147
|
-
return _replaceLocalOrderIdAsync.apply(this, arguments);
|
|
1148
|
-
}
|
|
1149
|
-
return replaceLocalOrderIdAsync;
|
|
1150
|
-
}()
|
|
1151
|
-
/**
|
|
1152
|
-
* 设置状态
|
|
1153
|
-
*/
|
|
1154
|
-
)
|
|
1155
|
-
}, {
|
|
1156
|
-
key: "setStatus",
|
|
1157
|
-
value: (function () {
|
|
1158
|
-
var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(status) {
|
|
1159
|
-
var oldStatus;
|
|
1160
|
-
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1161
|
-
while (1) switch (_context18.prev = _context18.next) {
|
|
1162
|
-
case 0:
|
|
1163
|
-
oldStatus = this.store.status;
|
|
1164
|
-
this.store.status = status;
|
|
1165
|
-
_context18.next = 4;
|
|
1166
|
-
return this.core.effects.emit(CheckoutHooks.OnStatusChanged, {
|
|
1167
|
-
oldStatus: oldStatus,
|
|
1168
|
-
newStatus: status,
|
|
1169
|
-
timestamp: Date.now()
|
|
1170
|
-
});
|
|
1171
|
-
case 4:
|
|
1172
|
-
case "end":
|
|
1173
|
-
return _context18.stop();
|
|
1174
|
-
}
|
|
1175
|
-
}, _callee18, this);
|
|
1176
|
-
}));
|
|
1177
|
-
function setStatus(_x12) {
|
|
1178
|
-
return _setStatus.apply(this, arguments);
|
|
1179
|
-
}
|
|
1180
|
-
return setStatus;
|
|
1181
|
-
}()
|
|
1182
|
-
/**
|
|
1183
|
-
* 设置步骤
|
|
1184
|
-
*/
|
|
1185
|
-
)
|
|
1186
|
-
}, {
|
|
1187
|
-
key: "setStep",
|
|
1188
|
-
value: (function () {
|
|
1189
|
-
var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(step) {
|
|
1190
|
-
var oldStep;
|
|
1191
|
-
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1192
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
1193
|
-
case 0:
|
|
1194
|
-
oldStep = this.store.step;
|
|
1195
|
-
this.store.step = step;
|
|
1196
|
-
_context19.next = 4;
|
|
1197
|
-
return this.core.effects.emit(CheckoutHooks.OnStepChanged, {
|
|
1198
|
-
oldStep: oldStep,
|
|
1199
|
-
newStep: step,
|
|
1200
|
-
timestamp: Date.now()
|
|
1201
|
-
});
|
|
1202
|
-
case 4:
|
|
1203
|
-
case "end":
|
|
1204
|
-
return _context19.stop();
|
|
1205
|
-
}
|
|
1206
|
-
}, _callee19, this);
|
|
1207
|
-
}));
|
|
1208
|
-
function setStep(_x13) {
|
|
1209
|
-
return _setStep.apply(this, arguments);
|
|
1210
|
-
}
|
|
1211
|
-
return setStep;
|
|
1212
|
-
}()
|
|
1213
|
-
/**
|
|
1214
|
-
* 处理错误
|
|
1215
|
-
*/
|
|
1216
|
-
)
|
|
1217
|
-
}, {
|
|
1218
|
-
key: "handleError",
|
|
1219
|
-
value: (function () {
|
|
1220
|
-
var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(error, type) {
|
|
1221
|
-
var checkoutError;
|
|
1222
|
-
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1223
|
-
while (1) switch (_context20.prev = _context20.next) {
|
|
1224
|
-
case 0:
|
|
1225
|
-
checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
|
|
1226
|
-
this.store.lastError = checkoutError;
|
|
1227
|
-
_context20.next = 4;
|
|
1228
|
-
return this.setStatus(CheckoutStatus.Error);
|
|
1229
|
-
case 4:
|
|
1230
|
-
_context20.next = 6;
|
|
1231
|
-
return this.core.effects.emit(CheckoutHooks.OnError, {
|
|
1232
|
-
error: checkoutError,
|
|
1233
|
-
context: {
|
|
1234
|
-
status: this.store.status,
|
|
1235
|
-
step: this.store.step
|
|
1236
|
-
},
|
|
1237
|
-
timestamp: Date.now()
|
|
1238
|
-
});
|
|
1239
|
-
case 6:
|
|
1240
|
-
console.error('[Checkout] 错误:', checkoutError);
|
|
1241
|
-
case 7:
|
|
1242
|
-
case "end":
|
|
1243
|
-
return _context20.stop();
|
|
1244
|
-
}
|
|
1245
|
-
}, _callee20, this);
|
|
1246
|
-
}));
|
|
1247
|
-
function handleError(_x14, _x15) {
|
|
1248
|
-
return _handleError.apply(this, arguments);
|
|
1249
|
-
}
|
|
1250
|
-
return handleError;
|
|
1251
|
-
}()
|
|
1252
|
-
/**
|
|
1253
|
-
* 处理支付成功
|
|
1254
|
-
*/
|
|
1255
|
-
)
|
|
1256
|
-
}, {
|
|
1257
|
-
key: "handlePaymentSuccess",
|
|
1258
|
-
value: (function () {
|
|
1259
|
-
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(data) {
|
|
1260
|
-
var _this$store$currentOr4;
|
|
1261
|
-
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1262
|
-
while (1) switch (_context21.prev = _context21.next) {
|
|
1263
|
-
case 0:
|
|
1264
|
-
_context21.next = 2;
|
|
1265
|
-
return this.setStatus(CheckoutStatus.PaymentCompleted);
|
|
1266
|
-
case 2:
|
|
1267
|
-
_context21.next = 4;
|
|
1268
|
-
return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
|
|
1269
|
-
orderUuid: data.orderUuid,
|
|
1270
|
-
paymentMethodCode: '',
|
|
1271
|
-
amount: ((_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.total_amount) || '0',
|
|
1272
|
-
timestamp: data.timestamp
|
|
1273
|
-
});
|
|
1274
|
-
case 4:
|
|
1275
|
-
_context21.next = 6;
|
|
1276
|
-
return this.completeCheckoutAsync();
|
|
1277
|
-
case 6:
|
|
1278
|
-
case "end":
|
|
1279
|
-
return _context21.stop();
|
|
1280
|
-
}
|
|
1281
|
-
}, _callee21, this);
|
|
1282
|
-
}));
|
|
1283
|
-
function handlePaymentSuccess(_x16) {
|
|
1284
|
-
return _handlePaymentSuccess.apply(this, arguments);
|
|
1285
|
-
}
|
|
1286
|
-
return handlePaymentSuccess;
|
|
1287
|
-
}()
|
|
1288
|
-
/**
|
|
1289
|
-
* 处理支付错误
|
|
1290
|
-
*/
|
|
1291
|
-
)
|
|
1292
|
-
}, {
|
|
1293
|
-
key: "handlePaymentError",
|
|
1294
|
-
value: (function () {
|
|
1295
|
-
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(data) {
|
|
1296
|
-
var _this$store$currentOr5;
|
|
1297
|
-
var error;
|
|
1298
|
-
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1299
|
-
while (1) switch (_context22.prev = _context22.next) {
|
|
1300
|
-
case 0:
|
|
1301
|
-
error = createCheckoutError(CheckoutErrorType.PaymentFailed, data.error || '支付同步失败');
|
|
1302
|
-
_context22.next = 3;
|
|
1303
|
-
return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
|
|
1304
|
-
case 3:
|
|
1305
|
-
_context22.next = 5;
|
|
1306
|
-
return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
|
|
1307
|
-
orderUuid: data.orderUuid,
|
|
1308
|
-
paymentMethodCode: '',
|
|
1309
|
-
amount: ((_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.total_amount) || '0',
|
|
1310
|
-
timestamp: data.timestamp
|
|
1311
|
-
});
|
|
1312
|
-
case 5:
|
|
1313
|
-
case "end":
|
|
1314
|
-
return _context22.stop();
|
|
1315
|
-
}
|
|
1316
|
-
}, _callee22, this);
|
|
1317
|
-
}));
|
|
1318
|
-
function handlePaymentError(_x17) {
|
|
1319
|
-
return _handlePaymentError.apply(this, arguments);
|
|
1320
|
-
}
|
|
1321
|
-
return handlePaymentError;
|
|
1322
|
-
}()
|
|
1323
|
-
/**
|
|
1324
|
-
* 验证结账参数
|
|
1325
|
-
*/
|
|
1326
|
-
)
|
|
1327
|
-
}, {
|
|
1328
|
-
key: "validateCheckoutParams",
|
|
1329
|
-
value: (function () {
|
|
1330
|
-
var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
1331
|
-
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1332
|
-
while (1) switch (_context23.prev = _context23.next) {
|
|
1333
|
-
case 0:
|
|
1334
|
-
return _context23.abrupt("return", validateCheckoutData(params));
|
|
1335
|
-
case 1:
|
|
1336
|
-
case "end":
|
|
1337
|
-
return _context23.stop();
|
|
1338
|
-
}
|
|
1339
|
-
}, _callee23);
|
|
1340
|
-
}));
|
|
1341
|
-
function validateCheckoutParams(_x18) {
|
|
1342
|
-
return _validateCheckoutParams.apply(this, arguments);
|
|
1343
|
-
}
|
|
1344
|
-
return validateCheckoutParams;
|
|
1345
|
-
}()
|
|
1346
|
-
/**
|
|
1347
|
-
* 验证本地订单数据
|
|
1348
|
-
*/
|
|
1349
|
-
)
|
|
1350
|
-
}, {
|
|
1351
|
-
key: "validateLocalOrderData",
|
|
1352
|
-
value: (function () {
|
|
1353
|
-
var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(orderData) {
|
|
1354
|
-
var errors;
|
|
1355
|
-
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1356
|
-
while (1) switch (_context24.prev = _context24.next) {
|
|
1357
|
-
case 0:
|
|
1358
|
-
errors = []; // 验证基本字段
|
|
1359
|
-
if (!orderData.type) {
|
|
1360
|
-
errors.push('订单类型不能为空');
|
|
1361
|
-
}
|
|
1362
|
-
if (!orderData.platform) {
|
|
1363
|
-
errors.push('平台信息不能为空');
|
|
1364
|
-
}
|
|
1365
|
-
if (!orderData.bookings || orderData.bookings.length === 0) {
|
|
1366
|
-
errors.push('预订信息不能为空');
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
// 验证预订信息
|
|
1370
|
-
if (orderData.bookings) {
|
|
1371
|
-
orderData.bookings.forEach(function (booking, index) {
|
|
1372
|
-
if (!booking.product || !booking.product.product_id) {
|
|
1373
|
-
errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5546\u54C1\u4FE1\u606F"));
|
|
1374
|
-
}
|
|
1375
|
-
if (!booking.start_date) {
|
|
1376
|
-
errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65E5\u671F"));
|
|
1377
|
-
}
|
|
1378
|
-
if (!booking.start_time) {
|
|
1379
|
-
errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65F6\u95F4"));
|
|
1380
|
-
}
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
|
-
return _context24.abrupt("return", {
|
|
1384
|
-
valid: errors.length === 0,
|
|
1385
|
-
errors: errors
|
|
1386
|
-
});
|
|
1387
|
-
case 6:
|
|
1388
|
-
case "end":
|
|
1389
|
-
return _context24.stop();
|
|
1390
|
-
}
|
|
1391
|
-
}, _callee24);
|
|
1392
|
-
}));
|
|
1393
|
-
function validateLocalOrderData(_x19) {
|
|
1394
|
-
return _validateLocalOrderData.apply(this, arguments);
|
|
1395
|
-
}
|
|
1396
|
-
return validateLocalOrderData;
|
|
1397
|
-
}()
|
|
1398
|
-
/**
|
|
1399
|
-
* 生成本地订单ID
|
|
1400
|
-
*/
|
|
1401
|
-
)
|
|
1402
|
-
}, {
|
|
1403
|
-
key: "generateLocalOrderId",
|
|
1404
|
-
value: function generateLocalOrderId() {
|
|
1405
|
-
var timestamp = Date.now();
|
|
1406
|
-
var random = Math.floor(Math.random() * 10000).toString().padStart(4, '0');
|
|
1407
|
-
return "local_order_".concat(timestamp, "_").concat(random);
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
/**
|
|
1411
|
-
* 从购物车小计数据中提取金额信息
|
|
1412
|
-
*/
|
|
1413
|
-
}, {
|
|
1414
|
-
key: "extractAmountFromCartSummary",
|
|
1415
|
-
value: function extractAmountFromCartSummary(cartSummary) {
|
|
1416
|
-
var result = {
|
|
1417
|
-
totalAmount: '0.00',
|
|
1418
|
-
subTotal: '0.00',
|
|
1419
|
-
taxAmount: '0.00',
|
|
1420
|
-
discountAmount: '0.00',
|
|
1421
|
-
shopDiscountAmount: '0.00',
|
|
1422
|
-
roundingAmount: '0.00'
|
|
1423
|
-
};
|
|
1424
|
-
cartSummary.forEach(function (item) {
|
|
1425
|
-
var value = Number(item.value).toFixed(2);
|
|
1426
|
-
switch (item.key) {
|
|
1427
|
-
case 'expect_amount':
|
|
1428
|
-
result.totalAmount = value;
|
|
1429
|
-
break;
|
|
1430
|
-
case 'sub_total':
|
|
1431
|
-
result.subTotal = value;
|
|
1432
|
-
break;
|
|
1433
|
-
case 'tax':
|
|
1434
|
-
result.taxAmount = value;
|
|
1435
|
-
if (item.tax) {
|
|
1436
|
-
result.taxDetails = item.tax;
|
|
1437
|
-
}
|
|
1438
|
-
break;
|
|
1439
|
-
case 'discount':
|
|
1440
|
-
result.discountAmount = value;
|
|
1441
|
-
break;
|
|
1442
|
-
case 'shop_discount':
|
|
1443
|
-
result.shopDiscountAmount = value;
|
|
1444
|
-
break;
|
|
1445
|
-
case 'custom_roundingAmount':
|
|
1446
|
-
result.roundingAmount = value;
|
|
1447
|
-
break;
|
|
1448
|
-
default:
|
|
1449
|
-
// 处理其他可能的键,如定金等
|
|
1450
|
-
if (item.key.includes('deposit')) {
|
|
1451
|
-
result.depositAmount = value;
|
|
1452
|
-
}
|
|
1453
|
-
break;
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
console.log('[Checkout] 从购物车小计提取金额信息:', {
|
|
1457
|
-
totalAmount: result.totalAmount,
|
|
1458
|
-
subTotal: result.subTotal,
|
|
1459
|
-
taxAmount: result.taxAmount,
|
|
1460
|
-
discountAmount: result.discountAmount,
|
|
1461
|
-
shopDiscountAmount: result.shopDiscountAmount,
|
|
1462
|
-
roundingAmount: result.roundingAmount
|
|
1463
|
-
});
|
|
1464
|
-
return result;
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
/**
|
|
1468
|
-
* 预加载支付方式(在初始化时调用)
|
|
1469
|
-
*/
|
|
1470
|
-
}, {
|
|
1471
|
-
key: "preloadPaymentMethods",
|
|
1472
|
-
value: (function () {
|
|
1473
|
-
var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1474
|
-
var methods;
|
|
1475
|
-
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1476
|
-
while (1) switch (_context25.prev = _context25.next) {
|
|
1477
|
-
case 0:
|
|
1478
|
-
_context25.prev = 0;
|
|
1479
|
-
console.log('[Checkout] 预加载支付方式...');
|
|
1480
|
-
_context25.next = 4;
|
|
1481
|
-
return this.store.payment.getPayMethodListAsync();
|
|
1482
|
-
case 4:
|
|
1483
|
-
methods = _context25.sent;
|
|
1484
|
-
this.store.paymentMethods = methods;
|
|
1485
|
-
console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
|
|
1486
|
-
_context25.next = 13;
|
|
1487
|
-
break;
|
|
1488
|
-
case 9:
|
|
1489
|
-
_context25.prev = 9;
|
|
1490
|
-
_context25.t0 = _context25["catch"](0);
|
|
1491
|
-
console.error('[Checkout] 预加载支付方式失败:', _context25.t0);
|
|
1492
|
-
this.store.paymentMethods = [];
|
|
1493
|
-
case 13:
|
|
1494
|
-
case "end":
|
|
1495
|
-
return _context25.stop();
|
|
1496
|
-
}
|
|
1497
|
-
}, _callee25, this, [[0, 9]]);
|
|
1498
|
-
}));
|
|
1499
|
-
function preloadPaymentMethods() {
|
|
1500
|
-
return _preloadPaymentMethods.apply(this, arguments);
|
|
1501
|
-
}
|
|
1502
|
-
return preloadPaymentMethods;
|
|
1503
|
-
}()
|
|
1504
|
-
/**
|
|
1505
|
-
* 计算总金额
|
|
1506
|
-
*/
|
|
1507
|
-
)
|
|
1508
|
-
}, {
|
|
1509
|
-
key: "calculateTotalAmount",
|
|
1510
|
-
value: function calculateTotalAmount(cartItems) {
|
|
1511
|
-
var total = cartItems.reduce(function (sum, item) {
|
|
1512
|
-
var price = parseFloat(String(item.price) || '0');
|
|
1513
|
-
var quantity = item.quantity || 1;
|
|
1514
|
-
return sum + price * quantity;
|
|
1515
|
-
}, 0);
|
|
1516
|
-
return total.toFixed(2);
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
/**
|
|
1520
|
-
* 计算已支付金额
|
|
1521
|
-
*/
|
|
1522
|
-
}, {
|
|
1523
|
-
key: "calculatePaidAmount",
|
|
1524
|
-
value: function calculatePaidAmount() {
|
|
1525
|
-
if (!this.store.currentOrder) return '0.00';
|
|
1526
|
-
var paidAmount = this.store.currentOrder.payment.reduce(function (sum, payment) {
|
|
1527
|
-
return sum + parseFloat(payment.amount);
|
|
1528
|
-
}, 0);
|
|
1529
|
-
return paidAmount.toFixed(2);
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
/**
|
|
1533
|
-
* 获取状态消息
|
|
1534
|
-
*/
|
|
1535
|
-
}, {
|
|
1536
|
-
key: "getStatusMessage",
|
|
1537
|
-
value: function getStatusMessage() {
|
|
1538
|
-
var _this$store$lastError;
|
|
1539
|
-
switch (this.store.status) {
|
|
1540
|
-
case CheckoutStatus.Initializing:
|
|
1541
|
-
return '正在初始化结账流程...';
|
|
1542
|
-
case CheckoutStatus.Ready:
|
|
1543
|
-
return '准备就绪,可以开始结账';
|
|
1544
|
-
case CheckoutStatus.CreatingOrder:
|
|
1545
|
-
return '正在创建订单...';
|
|
1546
|
-
case CheckoutStatus.OrderCreated:
|
|
1547
|
-
return '订单创建成功,请选择支付方式';
|
|
1548
|
-
case CheckoutStatus.ProcessingPayment:
|
|
1549
|
-
return '正在处理支付...';
|
|
1550
|
-
case CheckoutStatus.PaymentCompleted:
|
|
1551
|
-
return '支付完成';
|
|
1552
|
-
case CheckoutStatus.Completed:
|
|
1553
|
-
return '结账完成';
|
|
1554
|
-
case CheckoutStatus.Cancelled:
|
|
1555
|
-
return '结账已取消';
|
|
1556
|
-
case CheckoutStatus.Error:
|
|
1557
|
-
return ((_this$store$lastError = this.store.lastError) === null || _this$store$lastError === void 0 ? void 0 : _this$store$lastError.message) || '发生未知错误';
|
|
1558
|
-
default:
|
|
1559
|
-
return '';
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
}, {
|
|
1563
|
-
key: "destroy",
|
|
1564
|
-
value: function () {
|
|
1565
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1566
|
-
var _this$store$order, _this$store$order$des, _this$store$payment, _this$store$payment$d;
|
|
1567
|
-
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1568
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
1569
|
-
case 0:
|
|
1570
|
-
// 清理事件监听
|
|
1571
|
-
this.core.effects.offByModuleDestroy(this.name);
|
|
1572
|
-
|
|
1573
|
-
// 销毁子模块
|
|
1574
|
-
_context26.next = 3;
|
|
1575
|
-
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$des = _this$store$order.destroy) === null || _this$store$order$des === void 0 ? void 0 : _this$store$order$des.call(_this$store$order);
|
|
1576
|
-
case 3:
|
|
1577
|
-
_context26.next = 5;
|
|
1578
|
-
return (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 || (_this$store$payment$d = _this$store$payment.destroy) === null || _this$store$payment$d === void 0 ? void 0 : _this$store$payment$d.call(_this$store$payment);
|
|
1579
|
-
case 5:
|
|
1580
|
-
// 取消注册模块
|
|
1581
|
-
this.core.unregisterModule(this);
|
|
1582
|
-
console.log('[Checkout] 已销毁');
|
|
1583
|
-
case 7:
|
|
1584
|
-
case "end":
|
|
1585
|
-
return _context26.stop();
|
|
1586
|
-
}
|
|
1587
|
-
}, _callee26, this);
|
|
1588
|
-
}));
|
|
1589
|
-
function destroy() {
|
|
1590
|
-
return _destroy.apply(this, arguments);
|
|
1591
|
-
}
|
|
1592
|
-
return destroy;
|
|
1593
|
-
}()
|
|
1594
|
-
}]);
|
|
1595
|
-
return CheckoutImpl;
|
|
1596
|
-
}(BaseModule);
|