@pisell/pisellos 0.0.235 → 0.0.237
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/modules/Payment/types.d.ts +46 -1
- package/dist/modules/Payment/types.js +15 -0
- package/dist/modules/Payment/walletpass.js +37 -12
- package/dist/solution/Checkout/index.d.ts +23 -1
- package/dist/solution/Checkout/index.js +1092 -885
- package/dist/solution/Checkout/types.d.ts +11 -1
- package/dist/solution/Checkout/types.js +1 -0
- package/lib/modules/Payment/types.d.ts +46 -1
- package/lib/modules/Payment/types.js +3 -0
- package/lib/modules/Payment/walletpass.js +28 -3
- package/lib/solution/Checkout/index.d.ts +23 -1
- package/lib/solution/Checkout/index.js +334 -121
- package/lib/solution/Checkout/types.d.ts +11 -1
- package/lib/solution/Checkout/types.js +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
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
3
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
4
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
5
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
6
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
7
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
8
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
@@ -28,13 +28,13 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import { OrderModule } from "../../modules/Order";
|
|
29
29
|
import { PaymentModule } from "../../modules/Payment";
|
|
30
30
|
import { CheckoutStatus, CheckoutStep, CheckoutHooks, CheckoutErrorType } from "./types";
|
|
31
|
-
import { PaymentStatus, PaymentMethodType } from "../../modules/Payment/types";
|
|
31
|
+
import { PaymentStatus, PaymentHooks, PaymentMethodType } from "../../modules/Payment/types";
|
|
32
32
|
import { validateCheckoutData, createCheckoutError, calculateProgress } from "./utils";
|
|
33
33
|
export * from "./types";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* 结账解决方案实现
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* 整合订单处理和支付功能,提供完整的结账流程管理。
|
|
39
39
|
* 支持多种支付方式,提供实时状态跟踪和错误处理。
|
|
40
40
|
*/
|
|
@@ -211,6 +211,47 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
211
211
|
return _ref2.apply(this, arguments);
|
|
212
212
|
};
|
|
213
213
|
}());
|
|
214
|
+
|
|
215
|
+
// 监听支付方式加载完成事件
|
|
216
|
+
this.core.effects.on(PaymentHooks.OnPaymentMethodsLoaded, /*#__PURE__*/function () {
|
|
217
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(methods) {
|
|
218
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
219
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
220
|
+
case 0:
|
|
221
|
+
console.log('[Checkout] 收到支付方式加载完成事件:', methods.length);
|
|
222
|
+
_this2.store.paymentMethods = methods;
|
|
223
|
+
case 2:
|
|
224
|
+
case "end":
|
|
225
|
+
return _context5.stop();
|
|
226
|
+
}
|
|
227
|
+
}, _callee5);
|
|
228
|
+
}));
|
|
229
|
+
return function (_x7) {
|
|
230
|
+
return _ref3.apply(this, arguments);
|
|
231
|
+
};
|
|
232
|
+
}());
|
|
233
|
+
|
|
234
|
+
// 监听支付方式变更事件
|
|
235
|
+
this.core.effects.on(PaymentHooks.OnPaymentMethodsChanged, /*#__PURE__*/function () {
|
|
236
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) {
|
|
237
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
238
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
239
|
+
case 0:
|
|
240
|
+
console.log('[Checkout] 收到支付方式变更事件:', {
|
|
241
|
+
oldCount: data.oldMethods.length,
|
|
242
|
+
newCount: data.newMethods.length
|
|
243
|
+
});
|
|
244
|
+
_this2.store.paymentMethods = data.newMethods;
|
|
245
|
+
case 2:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context6.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee6);
|
|
250
|
+
}));
|
|
251
|
+
return function (_x8) {
|
|
252
|
+
return _ref4.apply(this, arguments);
|
|
253
|
+
};
|
|
254
|
+
}());
|
|
214
255
|
}
|
|
215
256
|
|
|
216
257
|
/**
|
|
@@ -219,21 +260,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
219
260
|
}, {
|
|
220
261
|
key: "initializeCheckoutAsync",
|
|
221
262
|
value: (function () {
|
|
222
|
-
var _initializeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
263
|
+
var _initializeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
223
264
|
var validation;
|
|
224
|
-
return _regeneratorRuntime().wrap(function
|
|
225
|
-
while (1) switch (
|
|
265
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
266
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
226
267
|
case 0:
|
|
227
|
-
|
|
228
|
-
|
|
268
|
+
_context7.prev = 0;
|
|
269
|
+
_context7.next = 3;
|
|
229
270
|
return this.setStatus(CheckoutStatus.Initializing);
|
|
230
271
|
case 3:
|
|
231
|
-
|
|
272
|
+
_context7.next = 5;
|
|
232
273
|
return this.validateCheckoutParams(params);
|
|
233
274
|
case 5:
|
|
234
|
-
validation =
|
|
275
|
+
validation = _context7.sent;
|
|
235
276
|
if (validation.valid) {
|
|
236
|
-
|
|
277
|
+
_context7.next = 8;
|
|
237
278
|
break;
|
|
238
279
|
}
|
|
239
280
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
@@ -242,29 +283,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
242
283
|
this.store.cartItems = params.cartItems;
|
|
243
284
|
|
|
244
285
|
// 设置为就绪状态
|
|
245
|
-
|
|
286
|
+
_context7.next = 11;
|
|
246
287
|
return this.setStatus(CheckoutStatus.Ready);
|
|
247
288
|
case 11:
|
|
248
|
-
|
|
289
|
+
_context7.next = 13;
|
|
249
290
|
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
250
291
|
case 13:
|
|
251
292
|
console.log('[Checkout] 结账流程初始化完成');
|
|
252
|
-
|
|
293
|
+
_context7.next = 21;
|
|
253
294
|
break;
|
|
254
295
|
case 16:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return this.handleError(
|
|
296
|
+
_context7.prev = 16;
|
|
297
|
+
_context7.t0 = _context7["catch"](0);
|
|
298
|
+
_context7.next = 20;
|
|
299
|
+
return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
|
|
259
300
|
case 20:
|
|
260
|
-
throw
|
|
301
|
+
throw _context7.t0;
|
|
261
302
|
case 21:
|
|
262
303
|
case "end":
|
|
263
|
-
return
|
|
304
|
+
return _context7.stop();
|
|
264
305
|
}
|
|
265
|
-
},
|
|
306
|
+
}, _callee7, this, [[0, 16]]);
|
|
266
307
|
}));
|
|
267
|
-
function initializeCheckoutAsync(
|
|
308
|
+
function initializeCheckoutAsync(_x9) {
|
|
268
309
|
return _initializeCheckoutAsync.apply(this, arguments);
|
|
269
310
|
}
|
|
270
311
|
return initializeCheckoutAsync;
|
|
@@ -272,7 +313,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
272
313
|
}, {
|
|
273
314
|
key: "getProductListByOrder",
|
|
274
315
|
value: function getProductListByOrder() {
|
|
275
|
-
var _this$store$currentOr;
|
|
316
|
+
var _this$store$currentOr, _this$store$currentOr2;
|
|
276
317
|
if (!this.store.currentOrder) {
|
|
277
318
|
return [];
|
|
278
319
|
}
|
|
@@ -281,31 +322,39 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
281
322
|
return pre + (item.amount || 0);
|
|
282
323
|
}, 0);
|
|
283
324
|
};
|
|
284
|
-
var productList = (_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.
|
|
325
|
+
var productList = ((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
|
|
285
326
|
return {
|
|
286
327
|
product_id: item.product.product_id,
|
|
287
328
|
product_variant_id: item.product.product_variant_id,
|
|
288
329
|
quantity: item.product.num,
|
|
289
330
|
selling_price: item.product.price - (item.product.discount_amount || 0) - getDiscountListAmount(item.product.discount_list)
|
|
290
331
|
};
|
|
291
|
-
});
|
|
292
|
-
|
|
332
|
+
})) || [];
|
|
333
|
+
var relationProducts = ((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.relation_products) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.map(function (item) {
|
|
334
|
+
return {
|
|
335
|
+
product_id: item.product_id,
|
|
336
|
+
product_variant_id: item.product_variant_id,
|
|
337
|
+
quantity: item.num,
|
|
338
|
+
selling_price: item.source_product_price
|
|
339
|
+
};
|
|
340
|
+
})) || [];
|
|
341
|
+
return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
|
|
293
342
|
}
|
|
294
343
|
}, {
|
|
295
344
|
key: "initWalletData",
|
|
296
345
|
value: function () {
|
|
297
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
298
|
-
var _this$store$
|
|
346
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
347
|
+
var _this$store$currentOr3, _this$store$currentCu;
|
|
299
348
|
var amountInfo, walletBusinessData;
|
|
300
|
-
return _regeneratorRuntime().wrap(function
|
|
301
|
-
while (1) switch (
|
|
349
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
350
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
302
351
|
case 0:
|
|
303
|
-
amountInfo = (_this$store$
|
|
352
|
+
amountInfo = (_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 || (_this$store$currentOr3 = _this$store$currentOr3.order_info) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.amount_breakdown;
|
|
304
353
|
if (amountInfo) {
|
|
305
|
-
|
|
354
|
+
_context8.next = 3;
|
|
306
355
|
break;
|
|
307
356
|
}
|
|
308
|
-
return
|
|
357
|
+
return _context8.abrupt("return");
|
|
309
358
|
case 3:
|
|
310
359
|
// 准备钱包初始化的业务数据
|
|
311
360
|
walletBusinessData = _objectSpread({
|
|
@@ -316,22 +365,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
316
365
|
},
|
|
317
366
|
products: this.getProductListByOrder()
|
|
318
367
|
}, params);
|
|
319
|
-
|
|
368
|
+
_context8.next = 6;
|
|
320
369
|
return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
321
370
|
case 6:
|
|
322
371
|
case "end":
|
|
323
|
-
return
|
|
372
|
+
return _context8.stop();
|
|
324
373
|
}
|
|
325
|
-
},
|
|
374
|
+
}, _callee8, this);
|
|
326
375
|
}));
|
|
327
|
-
function initWalletData(
|
|
376
|
+
function initWalletData(_x10) {
|
|
328
377
|
return _initWalletData.apply(this, arguments);
|
|
329
378
|
}
|
|
330
379
|
return initWalletData;
|
|
331
380
|
}()
|
|
332
381
|
/**
|
|
333
382
|
* 创建本地订单 (前端模拟下单流程)
|
|
334
|
-
*
|
|
383
|
+
*
|
|
335
384
|
* 此方法用于在前端模拟整个下单流程,创建一个本地的虚拟订单。
|
|
336
385
|
* 用户在购物车点击下单时,会把购物车参数传递给此方法,
|
|
337
386
|
* 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
|
|
@@ -339,28 +388,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
339
388
|
}, {
|
|
340
389
|
key: "createLocalOrderAsync",
|
|
341
390
|
value: (function () {
|
|
342
|
-
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
391
|
+
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
343
392
|
var _params$totalInfo, _params$totalInfo2, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
|
|
344
|
-
return _regeneratorRuntime().wrap(function
|
|
345
|
-
while (1) switch (
|
|
393
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
394
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
346
395
|
case 0:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return this.
|
|
396
|
+
_context9.prev = 0;
|
|
397
|
+
_context9.next = 3;
|
|
398
|
+
return this.resetStoreStateAsync();
|
|
350
399
|
case 3:
|
|
351
|
-
|
|
352
|
-
return this.
|
|
400
|
+
_context9.next = 5;
|
|
401
|
+
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
353
402
|
case 5:
|
|
354
|
-
|
|
403
|
+
_context9.next = 7;
|
|
404
|
+
return this.validateLocalOrderData(params.orderData);
|
|
405
|
+
case 7:
|
|
406
|
+
validation = _context9.sent;
|
|
355
407
|
if (validation.valid) {
|
|
356
|
-
|
|
408
|
+
_context9.next = 10;
|
|
357
409
|
break;
|
|
358
410
|
}
|
|
359
411
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
360
|
-
case
|
|
412
|
+
case 10:
|
|
361
413
|
// 生成本地虚拟订单ID (后续可以被真实订单ID替换)
|
|
362
414
|
localOrderId = this.generateLocalOrderId(); // 从购物车小计数据中提取金额信息
|
|
363
|
-
amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
|
|
415
|
+
amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
|
|
364
416
|
params.orderData.platform = 'pos';
|
|
365
417
|
// 补充 created_at 时间 (YYYY-MM-DD hh:mm:ss 格式)
|
|
366
418
|
params.orderData.created_at = this.formatDateTime(new Date());
|
|
@@ -387,7 +439,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
387
439
|
}
|
|
388
440
|
|
|
389
441
|
// 创建支付订单对象
|
|
390
|
-
|
|
442
|
+
_context9.next = 22;
|
|
391
443
|
return this.payment.createPaymentOrderAsync({
|
|
392
444
|
order_id: localOrderId,
|
|
393
445
|
total_amount: amountInfo.totalAmount,
|
|
@@ -404,34 +456,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
404
456
|
amount_breakdown: amountInfo
|
|
405
457
|
}
|
|
406
458
|
});
|
|
407
|
-
case
|
|
408
|
-
paymentOrder =
|
|
459
|
+
case 22:
|
|
460
|
+
paymentOrder = _context9.sent;
|
|
409
461
|
this.store.currentOrder = paymentOrder;
|
|
410
|
-
|
|
462
|
+
_context9.next = 26;
|
|
411
463
|
return this.initWalletData();
|
|
412
|
-
case 24:
|
|
413
|
-
_context7.next = 26;
|
|
414
|
-
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
415
464
|
case 26:
|
|
416
|
-
|
|
417
|
-
return this.
|
|
465
|
+
_context9.next = 28;
|
|
466
|
+
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
418
467
|
case 28:
|
|
468
|
+
_context9.next = 30;
|
|
469
|
+
return this.setStep(CheckoutStep.PaymentMethod);
|
|
470
|
+
case 30:
|
|
419
471
|
if (!params.autoPayment) {
|
|
420
|
-
|
|
472
|
+
_context9.next = 33;
|
|
421
473
|
break;
|
|
422
474
|
}
|
|
423
|
-
|
|
475
|
+
_context9.next = 33;
|
|
424
476
|
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
425
|
-
case
|
|
426
|
-
|
|
477
|
+
case 33:
|
|
478
|
+
_context9.next = 35;
|
|
427
479
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
428
480
|
order: paymentOrder,
|
|
429
481
|
timestamp: Date.now()
|
|
430
482
|
});
|
|
431
|
-
case 33:
|
|
432
|
-
_context7.next = 35;
|
|
433
|
-
return this.updateStateAmountToRemaining();
|
|
434
483
|
case 35:
|
|
484
|
+
_context9.next = 37;
|
|
485
|
+
return this.updateStateAmountToRemaining();
|
|
486
|
+
case 37:
|
|
435
487
|
console.log('[Checkout] 本地订单创建成功:', {
|
|
436
488
|
localOrderId: localOrderId,
|
|
437
489
|
uuid: paymentOrder.uuid,
|
|
@@ -440,41 +492,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
440
492
|
taxAmount: amountInfo.taxAmount,
|
|
441
493
|
stateAmount: this.store.stateAmount
|
|
442
494
|
});
|
|
443
|
-
return
|
|
444
|
-
case
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return this.handleError(
|
|
449
|
-
case
|
|
450
|
-
|
|
495
|
+
return _context9.abrupt("return", paymentOrder);
|
|
496
|
+
case 41:
|
|
497
|
+
_context9.prev = 41;
|
|
498
|
+
_context9.t0 = _context9["catch"](0);
|
|
499
|
+
_context9.next = 45;
|
|
500
|
+
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
501
|
+
case 45:
|
|
502
|
+
_context9.next = 47;
|
|
451
503
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
452
504
|
error: this.store.lastError,
|
|
453
505
|
timestamp: Date.now()
|
|
454
506
|
});
|
|
455
|
-
case
|
|
456
|
-
throw
|
|
457
|
-
case
|
|
507
|
+
case 47:
|
|
508
|
+
throw _context9.t0;
|
|
509
|
+
case 48:
|
|
458
510
|
case "end":
|
|
459
|
-
return
|
|
511
|
+
return _context9.stop();
|
|
460
512
|
}
|
|
461
|
-
},
|
|
513
|
+
}, _callee9, this, [[0, 41]]);
|
|
462
514
|
}));
|
|
463
|
-
function createLocalOrderAsync(
|
|
515
|
+
function createLocalOrderAsync(_x11) {
|
|
464
516
|
return _createLocalOrderAsync.apply(this, arguments);
|
|
465
517
|
}
|
|
466
518
|
return createLocalOrderAsync;
|
|
467
519
|
}()
|
|
468
520
|
/**
|
|
469
521
|
* 手动下单 (根据虚拟订单生成实际订单)
|
|
470
|
-
*
|
|
522
|
+
*
|
|
471
523
|
* 使用当前存储的本地订单数据调用 Order 模块创建真实订单
|
|
472
524
|
*/
|
|
473
525
|
)
|
|
474
526
|
}, {
|
|
475
527
|
key: "placeOrderAsync",
|
|
476
528
|
value: (function () {
|
|
477
|
-
var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
529
|
+
var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
478
530
|
var params,
|
|
479
531
|
_data,
|
|
480
532
|
orderData,
|
|
@@ -482,26 +534,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
482
534
|
realOrderId,
|
|
483
535
|
updatedOrder,
|
|
484
536
|
errorMessage,
|
|
485
|
-
|
|
486
|
-
return _regeneratorRuntime().wrap(function
|
|
487
|
-
while (1) switch (
|
|
537
|
+
_args10 = arguments;
|
|
538
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
539
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
488
540
|
case 0:
|
|
489
|
-
params =
|
|
490
|
-
|
|
541
|
+
params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
|
|
542
|
+
_context10.prev = 1;
|
|
491
543
|
if (this.store.localOrderData) {
|
|
492
|
-
|
|
544
|
+
_context10.next = 4;
|
|
493
545
|
break;
|
|
494
546
|
}
|
|
495
547
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到本地订单数据,请先调用 createLocalOrderAsync 创建虚拟订单');
|
|
496
548
|
case 4:
|
|
497
549
|
if (this.store.currentOrder) {
|
|
498
|
-
|
|
550
|
+
_context10.next = 6;
|
|
499
551
|
break;
|
|
500
552
|
}
|
|
501
553
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到当前订单,请先创建虚拟订单');
|
|
502
554
|
case 6:
|
|
503
555
|
console.log('[Checkout] 开始手动下单流程...');
|
|
504
|
-
|
|
556
|
+
_context10.next = 9;
|
|
505
557
|
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
506
558
|
case 9:
|
|
507
559
|
// 准备订单数据,使用 Order 模块期望的格式
|
|
@@ -510,18 +562,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
510
562
|
type: this.store.localOrderData.type,
|
|
511
563
|
platform: this.store.localOrderData.platform
|
|
512
564
|
}; // 调用 Order 模块提交订单
|
|
513
|
-
|
|
565
|
+
_context10.next = 12;
|
|
514
566
|
return this.order.submitOrder({
|
|
515
567
|
url: params.url,
|
|
516
568
|
// 可选的自定义 URL
|
|
517
569
|
query: orderData
|
|
518
570
|
});
|
|
519
571
|
case 12:
|
|
520
|
-
orderResponse =
|
|
572
|
+
orderResponse = _context10.sent;
|
|
521
573
|
// 提取真实订单ID(假设返回格式包含 order_id)
|
|
522
574
|
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);
|
|
523
575
|
if (realOrderId) {
|
|
524
|
-
|
|
576
|
+
_context10.next = 16;
|
|
525
577
|
break;
|
|
526
578
|
}
|
|
527
579
|
throw createCheckoutError(CheckoutErrorType.OrderCreationFailed, '订单创建成功但未返回订单ID');
|
|
@@ -530,15 +582,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
530
582
|
|
|
531
583
|
// 如果设置了自动替换订单ID,则替换虚拟订单ID
|
|
532
584
|
if (!(params.autoReplaceOrderId !== false)) {
|
|
533
|
-
|
|
585
|
+
_context10.next = 23;
|
|
534
586
|
break;
|
|
535
587
|
}
|
|
536
588
|
// 默认为 true
|
|
537
589
|
console.log('[Checkout] 自动替换虚拟订单ID为真实订单ID...');
|
|
538
|
-
|
|
590
|
+
_context10.next = 21;
|
|
539
591
|
return this.replaceLocalOrderIdAsync(realOrderId);
|
|
540
592
|
case 21:
|
|
541
|
-
updatedOrder =
|
|
593
|
+
updatedOrder = _context10.sent;
|
|
542
594
|
if (updatedOrder) {
|
|
543
595
|
console.log('[Checkout] 订单ID替换成功:', {
|
|
544
596
|
oldId: this.store.currentOrder.order_id,
|
|
@@ -546,10 +598,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
546
598
|
});
|
|
547
599
|
}
|
|
548
600
|
case 23:
|
|
549
|
-
|
|
601
|
+
_context10.next = 25;
|
|
550
602
|
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
551
603
|
case 25:
|
|
552
|
-
|
|
604
|
+
_context10.next = 27;
|
|
553
605
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
554
606
|
order: this.store.currentOrder,
|
|
555
607
|
timestamp: Date.now()
|
|
@@ -558,33 +610,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
558
610
|
// 标记订单已同步
|
|
559
611
|
this.store.isOrderSynced = true;
|
|
560
612
|
console.log('[Checkout] 手动下单流程完成');
|
|
561
|
-
return
|
|
613
|
+
return _context10.abrupt("return", {
|
|
562
614
|
success: true,
|
|
563
615
|
orderId: realOrderId
|
|
564
616
|
});
|
|
565
617
|
case 32:
|
|
566
|
-
|
|
567
|
-
|
|
618
|
+
_context10.prev = 32;
|
|
619
|
+
_context10.t0 = _context10["catch"](1);
|
|
568
620
|
// 处理 CheckoutError 对象
|
|
569
621
|
errorMessage = '下单失败';
|
|
570
|
-
if (
|
|
571
|
-
errorMessage =
|
|
572
|
-
} else if (
|
|
573
|
-
errorMessage =
|
|
622
|
+
if (_context10.t0 && _typeof(_context10.t0) === 'object' && 'message' in _context10.t0) {
|
|
623
|
+
errorMessage = _context10.t0.message;
|
|
624
|
+
} else if (_context10.t0 instanceof Error) {
|
|
625
|
+
errorMessage = _context10.t0.message;
|
|
574
626
|
}
|
|
575
627
|
console.error('[Checkout] 手动下单失败:', errorMessage);
|
|
576
|
-
|
|
577
|
-
return this.handleError(
|
|
628
|
+
_context10.next = 39;
|
|
629
|
+
return this.handleError(_context10.t0, CheckoutErrorType.OrderCreationFailed);
|
|
578
630
|
case 39:
|
|
579
|
-
return
|
|
631
|
+
return _context10.abrupt("return", {
|
|
580
632
|
success: false,
|
|
581
633
|
error: errorMessage
|
|
582
634
|
});
|
|
583
635
|
case 40:
|
|
584
636
|
case "end":
|
|
585
|
-
return
|
|
637
|
+
return _context10.stop();
|
|
586
638
|
}
|
|
587
|
-
},
|
|
639
|
+
}, _callee10, this, [[1, 32]]);
|
|
588
640
|
}));
|
|
589
641
|
function placeOrderAsync() {
|
|
590
642
|
return _placeOrderAsync.apply(this, arguments);
|
|
@@ -598,13 +650,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
650
|
}, {
|
|
599
651
|
key: "createOrderAsync",
|
|
600
652
|
value: (function () {
|
|
601
|
-
var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
653
|
+
var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
602
654
|
var _data2, checkResult, orderResponse, paymentOrder;
|
|
603
|
-
return _regeneratorRuntime().wrap(function
|
|
604
|
-
while (1) switch (
|
|
655
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
656
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
605
657
|
case 0:
|
|
606
|
-
|
|
607
|
-
|
|
658
|
+
_context11.prev = 0;
|
|
659
|
+
_context11.next = 3;
|
|
608
660
|
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
609
661
|
case 3:
|
|
610
662
|
// 验证购物车数据
|
|
@@ -613,12 +665,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
613
665
|
type: 'account' // 默认使用 account 类型
|
|
614
666
|
});
|
|
615
667
|
if (checkResult) {
|
|
616
|
-
|
|
668
|
+
_context11.next = 6;
|
|
617
669
|
break;
|
|
618
670
|
}
|
|
619
671
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '购物车数据验证失败,请检查商品信息');
|
|
620
672
|
case 6:
|
|
621
|
-
|
|
673
|
+
_context11.next = 8;
|
|
622
674
|
return this.order.submitOrder({
|
|
623
675
|
query: {
|
|
624
676
|
cartItems: params.cartItems,
|
|
@@ -627,23 +679,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
627
679
|
}
|
|
628
680
|
});
|
|
629
681
|
case 8:
|
|
630
|
-
orderResponse =
|
|
631
|
-
|
|
682
|
+
orderResponse = _context11.sent;
|
|
683
|
+
_context11.next = 11;
|
|
632
684
|
return this.payment.createPaymentOrderAsync({
|
|
633
685
|
order_id: (orderResponse === null || orderResponse === void 0 || (_data2 = orderResponse.data) === null || _data2 === void 0 ? void 0 : _data2.order_id) || "order_".concat(Date.now()),
|
|
634
686
|
total_amount: this.calculateTotalAmount(params.cartItems),
|
|
635
687
|
order_info: orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.data
|
|
636
688
|
});
|
|
637
689
|
case 11:
|
|
638
|
-
paymentOrder =
|
|
690
|
+
paymentOrder = _context11.sent;
|
|
639
691
|
this.store.currentOrder = paymentOrder;
|
|
640
|
-
|
|
692
|
+
_context11.next = 15;
|
|
641
693
|
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
642
694
|
case 15:
|
|
643
|
-
|
|
695
|
+
_context11.next = 17;
|
|
644
696
|
return this.setStep(CheckoutStep.PaymentMethod);
|
|
645
697
|
case 17:
|
|
646
|
-
|
|
698
|
+
_context11.next = 19;
|
|
647
699
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
648
700
|
order: paymentOrder,
|
|
649
701
|
timestamp: Date.now()
|
|
@@ -653,31 +705,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
653
705
|
this.store.isOrderSynced = true;
|
|
654
706
|
|
|
655
707
|
// 自动设置 stateAmount 为剩余未支付金额
|
|
656
|
-
|
|
708
|
+
_context11.next = 22;
|
|
657
709
|
return this.updateStateAmountToRemaining();
|
|
658
710
|
case 22:
|
|
659
711
|
console.log('[Checkout] 订单创建成功:', paymentOrder.id);
|
|
660
|
-
return
|
|
712
|
+
return _context11.abrupt("return", paymentOrder);
|
|
661
713
|
case 26:
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return this.handleError(
|
|
714
|
+
_context11.prev = 26;
|
|
715
|
+
_context11.t0 = _context11["catch"](0);
|
|
716
|
+
_context11.next = 30;
|
|
717
|
+
return this.handleError(_context11.t0, CheckoutErrorType.OrderCreationFailed);
|
|
666
718
|
case 30:
|
|
667
|
-
|
|
719
|
+
_context11.next = 32;
|
|
668
720
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
669
721
|
error: this.store.lastError,
|
|
670
722
|
timestamp: Date.now()
|
|
671
723
|
});
|
|
672
724
|
case 32:
|
|
673
|
-
throw
|
|
725
|
+
throw _context11.t0;
|
|
674
726
|
case 33:
|
|
675
727
|
case "end":
|
|
676
|
-
return
|
|
728
|
+
return _context11.stop();
|
|
677
729
|
}
|
|
678
|
-
},
|
|
730
|
+
}, _callee11, this, [[0, 26]]);
|
|
679
731
|
}));
|
|
680
|
-
function createOrderAsync(
|
|
732
|
+
function createOrderAsync(_x12) {
|
|
681
733
|
return _createOrderAsync.apply(this, arguments);
|
|
682
734
|
}
|
|
683
735
|
return createOrderAsync;
|
|
@@ -689,22 +741,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
689
741
|
}, {
|
|
690
742
|
key: "processPaymentAsync",
|
|
691
743
|
value: (function () {
|
|
692
|
-
var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
744
|
+
var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
693
745
|
var paymentMethod, paymentItem, result;
|
|
694
|
-
return _regeneratorRuntime().wrap(function
|
|
695
|
-
while (1) switch (
|
|
746
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
747
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
696
748
|
case 0:
|
|
697
|
-
|
|
749
|
+
_context12.prev = 0;
|
|
698
750
|
if (this.store.currentOrder) {
|
|
699
|
-
|
|
751
|
+
_context12.next = 3;
|
|
700
752
|
break;
|
|
701
753
|
}
|
|
702
754
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,请先创建订单');
|
|
703
755
|
case 3:
|
|
704
|
-
|
|
756
|
+
_context12.next = 5;
|
|
705
757
|
return this.setStatus(CheckoutStatus.ProcessingPayment);
|
|
706
758
|
case 5:
|
|
707
|
-
|
|
759
|
+
_context12.next = 7;
|
|
708
760
|
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
709
761
|
case 7:
|
|
710
762
|
// 查找支付方式
|
|
@@ -712,7 +764,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
712
764
|
return method.code === params.paymentMethodCode;
|
|
713
765
|
});
|
|
714
766
|
if (paymentMethod) {
|
|
715
|
-
|
|
767
|
+
_context12.next = 10;
|
|
716
768
|
break;
|
|
717
769
|
}
|
|
718
770
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u672A\u627E\u5230\u652F\u4ED8\u65B9\u5F0F: ".concat(params.paymentMethodCode));
|
|
@@ -725,14 +777,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
725
777
|
amount: String(params.amount),
|
|
726
778
|
id: paymentMethod.id
|
|
727
779
|
}; // 添加支付项到订单
|
|
728
|
-
|
|
780
|
+
_context12.next = 13;
|
|
729
781
|
return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
|
|
730
782
|
case 13:
|
|
731
|
-
|
|
783
|
+
_context12.next = 15;
|
|
732
784
|
return this.payment.submitPayAsync(this.store.currentOrder.uuid);
|
|
733
785
|
case 15:
|
|
734
|
-
result =
|
|
735
|
-
|
|
786
|
+
result = _context12.sent;
|
|
787
|
+
_context12.next = 18;
|
|
736
788
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
737
789
|
orderUuid: this.store.currentOrder.uuid,
|
|
738
790
|
paymentMethodCode: params.paymentMethodCode,
|
|
@@ -741,42 +793,42 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
741
793
|
});
|
|
742
794
|
case 18:
|
|
743
795
|
if (!(result.status === 'success')) {
|
|
744
|
-
|
|
796
|
+
_context12.next = 27;
|
|
745
797
|
break;
|
|
746
798
|
}
|
|
747
|
-
|
|
799
|
+
_context12.next = 21;
|
|
748
800
|
return this.setStatus(CheckoutStatus.PaymentCompleted);
|
|
749
801
|
case 21:
|
|
750
|
-
|
|
802
|
+
_context12.next = 23;
|
|
751
803
|
return this.updateStateAmountToRemaining();
|
|
752
804
|
case 23:
|
|
753
|
-
|
|
805
|
+
_context12.next = 25;
|
|
754
806
|
return this.handlePaymentSuccess({
|
|
755
807
|
orderUuid: this.store.currentOrder.uuid,
|
|
756
808
|
timestamp: Date.now()
|
|
757
809
|
});
|
|
758
810
|
case 25:
|
|
759
|
-
|
|
811
|
+
_context12.next = 28;
|
|
760
812
|
break;
|
|
761
813
|
case 27:
|
|
762
814
|
throw createCheckoutError(CheckoutErrorType.PaymentFailed, '支付处理失败,请重试');
|
|
763
815
|
case 28:
|
|
764
|
-
|
|
816
|
+
_context12.next = 35;
|
|
765
817
|
break;
|
|
766
818
|
case 30:
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
return this.handleError(
|
|
819
|
+
_context12.prev = 30;
|
|
820
|
+
_context12.t0 = _context12["catch"](0);
|
|
821
|
+
_context12.next = 34;
|
|
822
|
+
return this.handleError(_context12.t0, CheckoutErrorType.PaymentFailed);
|
|
771
823
|
case 34:
|
|
772
|
-
throw
|
|
824
|
+
throw _context12.t0;
|
|
773
825
|
case 35:
|
|
774
826
|
case "end":
|
|
775
|
-
return
|
|
827
|
+
return _context12.stop();
|
|
776
828
|
}
|
|
777
|
-
},
|
|
829
|
+
}, _callee12, this, [[0, 30]]);
|
|
778
830
|
}));
|
|
779
|
-
function processPaymentAsync(
|
|
831
|
+
function processPaymentAsync(_x13) {
|
|
780
832
|
return _processPaymentAsync.apply(this, arguments);
|
|
781
833
|
}
|
|
782
834
|
return processPaymentAsync;
|
|
@@ -788,61 +840,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
788
840
|
}, {
|
|
789
841
|
key: "completeCheckoutAsync",
|
|
790
842
|
value: (function () {
|
|
791
|
-
var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
843
|
+
var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
792
844
|
var order;
|
|
793
|
-
return _regeneratorRuntime().wrap(function
|
|
794
|
-
while (1) switch (
|
|
845
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
846
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
795
847
|
case 0:
|
|
796
|
-
|
|
848
|
+
_context13.prev = 0;
|
|
797
849
|
if (this.store.currentOrder) {
|
|
798
|
-
|
|
850
|
+
_context13.next = 3;
|
|
799
851
|
break;
|
|
800
852
|
}
|
|
801
853
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单');
|
|
802
854
|
case 3:
|
|
803
|
-
|
|
855
|
+
_context13.next = 5;
|
|
804
856
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
805
857
|
case 5:
|
|
806
|
-
order =
|
|
858
|
+
order = _context13.sent;
|
|
807
859
|
if (!(!order || order.payment_status !== PaymentStatus.Finished)) {
|
|
808
|
-
|
|
860
|
+
_context13.next = 8;
|
|
809
861
|
break;
|
|
810
862
|
}
|
|
811
863
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '订单支付未完成,无法完成结账');
|
|
812
864
|
case 8:
|
|
813
865
|
// 清理钱包模块的所有缓存数据
|
|
814
866
|
this.payment.wallet.clearAllCache();
|
|
815
|
-
|
|
867
|
+
_context13.next = 11;
|
|
816
868
|
return this.setStatus(CheckoutStatus.Completed);
|
|
817
869
|
case 11:
|
|
818
|
-
|
|
870
|
+
_context13.next = 13;
|
|
819
871
|
return this.setStep(CheckoutStep.Complete);
|
|
820
872
|
case 13:
|
|
821
|
-
|
|
873
|
+
_context13.next = 15;
|
|
822
874
|
return this.core.effects.emit(CheckoutHooks.OnCheckoutCompleted, {
|
|
823
875
|
orderId: order.id,
|
|
824
876
|
timestamp: Date.now()
|
|
825
877
|
});
|
|
826
878
|
case 15:
|
|
827
879
|
console.log('[Checkout] 结账流程完成:', order.id);
|
|
828
|
-
|
|
880
|
+
|
|
881
|
+
// 🔧 新增:自动重置 store 状态
|
|
882
|
+
_context13.next = 18;
|
|
883
|
+
return this.resetStoreStateAsync();
|
|
884
|
+
case 18:
|
|
885
|
+
return _context13.abrupt("return", {
|
|
829
886
|
success: true,
|
|
830
887
|
orderId: String(order.id)
|
|
831
888
|
});
|
|
832
|
-
case
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
return this.handleError(
|
|
837
|
-
case
|
|
838
|
-
return
|
|
889
|
+
case 21:
|
|
890
|
+
_context13.prev = 21;
|
|
891
|
+
_context13.t0 = _context13["catch"](0);
|
|
892
|
+
_context13.next = 25;
|
|
893
|
+
return this.handleError(_context13.t0, CheckoutErrorType.UnknownError);
|
|
894
|
+
case 25:
|
|
895
|
+
return _context13.abrupt("return", {
|
|
839
896
|
success: false
|
|
840
897
|
});
|
|
841
|
-
case
|
|
898
|
+
case 26:
|
|
842
899
|
case "end":
|
|
843
|
-
return
|
|
900
|
+
return _context13.stop();
|
|
844
901
|
}
|
|
845
|
-
},
|
|
902
|
+
}, _callee13, this, [[0, 21]]);
|
|
846
903
|
}));
|
|
847
904
|
function completeCheckoutAsync() {
|
|
848
905
|
return _completeCheckoutAsync.apply(this, arguments);
|
|
@@ -856,16 +913,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
856
913
|
}, {
|
|
857
914
|
key: "cancelCheckoutAsync",
|
|
858
915
|
value: (function () {
|
|
859
|
-
var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
860
|
-
return _regeneratorRuntime().wrap(function
|
|
861
|
-
while (1) switch (
|
|
916
|
+
var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
917
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
918
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
862
919
|
case 0:
|
|
863
|
-
|
|
920
|
+
_context14.prev = 0;
|
|
864
921
|
if (!this.store.currentOrder) {
|
|
865
|
-
|
|
922
|
+
_context14.next = 5;
|
|
866
923
|
break;
|
|
867
924
|
}
|
|
868
|
-
|
|
925
|
+
_context14.next = 4;
|
|
869
926
|
return this.payment.deletePaymentOrderAsync(this.store.currentOrder.uuid);
|
|
870
927
|
case 4:
|
|
871
928
|
this.store.currentOrder = undefined;
|
|
@@ -878,28 +935,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
878
935
|
this.store.stateAmount = '0.00';
|
|
879
936
|
this.store.isOrderSynced = false;
|
|
880
937
|
this.store.currentCustomer = undefined;
|
|
881
|
-
|
|
938
|
+
_context14.next = 14;
|
|
882
939
|
return this.setStatus(CheckoutStatus.Cancelled);
|
|
883
940
|
case 14:
|
|
884
|
-
|
|
941
|
+
_context14.next = 16;
|
|
885
942
|
return this.core.effects.emit(CheckoutHooks.OnCheckoutCancelled, {
|
|
886
943
|
timestamp: Date.now()
|
|
887
944
|
});
|
|
888
945
|
case 16:
|
|
889
946
|
console.log('[Checkout] 结账流程已取消');
|
|
890
|
-
|
|
947
|
+
_context14.next = 24;
|
|
891
948
|
break;
|
|
892
949
|
case 19:
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
console.error('[Checkout] 取消结账失败:',
|
|
896
|
-
|
|
897
|
-
return this.handleError(
|
|
950
|
+
_context14.prev = 19;
|
|
951
|
+
_context14.t0 = _context14["catch"](0);
|
|
952
|
+
console.error('[Checkout] 取消结账失败:', _context14.t0);
|
|
953
|
+
_context14.next = 24;
|
|
954
|
+
return this.handleError(_context14.t0, CheckoutErrorType.UnknownError);
|
|
898
955
|
case 24:
|
|
899
956
|
case "end":
|
|
900
|
-
return
|
|
957
|
+
return _context14.stop();
|
|
901
958
|
}
|
|
902
|
-
},
|
|
959
|
+
}, _callee14, this, [[0, 19]]);
|
|
903
960
|
}));
|
|
904
961
|
function cancelCheckoutAsync() {
|
|
905
962
|
return _cancelCheckoutAsync.apply(this, arguments);
|
|
@@ -928,34 +985,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
928
985
|
}, {
|
|
929
986
|
key: "getCheckoutSummaryAsync",
|
|
930
987
|
value: (function () {
|
|
931
|
-
var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
932
|
-
var _this$store$
|
|
988
|
+
var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
989
|
+
var _this$store$currentOr4, _this$store$currentOr5;
|
|
933
990
|
var totalAmount, paidAmount, remainingAmount;
|
|
934
|
-
return _regeneratorRuntime().wrap(function
|
|
935
|
-
while (1) switch (
|
|
991
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
992
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
936
993
|
case 0:
|
|
937
|
-
totalAmount = ((_this$store$
|
|
938
|
-
|
|
994
|
+
totalAmount = ((_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.total_amount) || '0.00';
|
|
995
|
+
_context15.next = 3;
|
|
939
996
|
return this.calculatePaidAmountAsync();
|
|
940
997
|
case 3:
|
|
941
|
-
paidAmount =
|
|
942
|
-
|
|
998
|
+
paidAmount = _context15.sent;
|
|
999
|
+
_context15.next = 6;
|
|
943
1000
|
return this.calculateRemainingAmountAsync();
|
|
944
1001
|
case 6:
|
|
945
|
-
remainingAmount =
|
|
946
|
-
return
|
|
1002
|
+
remainingAmount = _context15.sent;
|
|
1003
|
+
return _context15.abrupt("return", {
|
|
947
1004
|
order: this.store.currentOrder,
|
|
948
1005
|
totalAmount: totalAmount,
|
|
949
1006
|
paidAmount: paidAmount,
|
|
950
1007
|
remainingAmount: remainingAmount,
|
|
951
|
-
paymentStatus: ((_this$store$
|
|
1008
|
+
paymentStatus: ((_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.payment_status) || PaymentStatus.Processing,
|
|
952
1009
|
availablePaymentMethods: this.store.paymentMethods
|
|
953
1010
|
});
|
|
954
1011
|
case 8:
|
|
955
1012
|
case "end":
|
|
956
|
-
return
|
|
1013
|
+
return _context15.stop();
|
|
957
1014
|
}
|
|
958
|
-
},
|
|
1015
|
+
}, _callee15, this);
|
|
959
1016
|
}));
|
|
960
1017
|
function getCheckoutSummaryAsync() {
|
|
961
1018
|
return _getCheckoutSummaryAsync.apply(this, arguments);
|
|
@@ -969,24 +1026,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
969
1026
|
}, {
|
|
970
1027
|
key: "getAvailablePaymentMethodsAsync",
|
|
971
1028
|
value: (function () {
|
|
972
|
-
var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
973
|
-
return _regeneratorRuntime().wrap(function
|
|
974
|
-
while (1) switch (
|
|
1029
|
+
var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1030
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1031
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
975
1032
|
case 0:
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
_context14.next = 4;
|
|
982
|
-
return this.preloadPaymentMethods();
|
|
983
|
-
case 4:
|
|
984
|
-
return _context14.abrupt("return", this.store.paymentMethods);
|
|
985
|
-
case 5:
|
|
1033
|
+
_context16.next = 2;
|
|
1034
|
+
return this.getPaymentMethodsAsync();
|
|
1035
|
+
case 2:
|
|
1036
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1037
|
+
case 3:
|
|
986
1038
|
case "end":
|
|
987
|
-
return
|
|
1039
|
+
return _context16.stop();
|
|
988
1040
|
}
|
|
989
|
-
},
|
|
1041
|
+
}, _callee16, this);
|
|
990
1042
|
}));
|
|
991
1043
|
function getAvailablePaymentMethodsAsync() {
|
|
992
1044
|
return _getAvailablePaymentMethodsAsync.apply(this, arguments);
|
|
@@ -995,27 +1047,38 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
995
1047
|
}()
|
|
996
1048
|
/**
|
|
997
1049
|
* 刷新支付方式缓存
|
|
998
|
-
*
|
|
1050
|
+
*
|
|
999
1051
|
* 强制重新从服务器获取支付方式列表,更新本地缓存
|
|
1000
1052
|
*/
|
|
1001
1053
|
)
|
|
1002
1054
|
}, {
|
|
1003
1055
|
key: "refreshPaymentMethodsAsync",
|
|
1004
1056
|
value: (function () {
|
|
1005
|
-
var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1006
|
-
|
|
1007
|
-
|
|
1057
|
+
var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1058
|
+
var methods;
|
|
1059
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1060
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1008
1061
|
case 0:
|
|
1009
1062
|
console.log('[Checkout] 强制刷新支付方式缓存...');
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
return _context15.abrupt("return", this.store.paymentMethods);
|
|
1063
|
+
_context17.prev = 1;
|
|
1064
|
+
_context17.next = 4;
|
|
1065
|
+
return this.payment.getPayMethodListAsync();
|
|
1014
1066
|
case 4:
|
|
1067
|
+
methods = _context17.sent;
|
|
1068
|
+
// 更新本地缓存
|
|
1069
|
+
this.store.paymentMethods = methods;
|
|
1070
|
+
console.log("[Checkout] \u5F3A\u5236\u5237\u65B0\u5B8C\u6210\uFF0C\u83B7\u53D6\u5230 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
|
|
1071
|
+
return _context17.abrupt("return", methods);
|
|
1072
|
+
case 10:
|
|
1073
|
+
_context17.prev = 10;
|
|
1074
|
+
_context17.t0 = _context17["catch"](1);
|
|
1075
|
+
console.error('[Checkout] 强制刷新支付方式失败:', _context17.t0);
|
|
1076
|
+
return _context17.abrupt("return", this.store.paymentMethods);
|
|
1077
|
+
case 14:
|
|
1015
1078
|
case "end":
|
|
1016
|
-
return
|
|
1079
|
+
return _context17.stop();
|
|
1017
1080
|
}
|
|
1018
|
-
},
|
|
1081
|
+
}, _callee17, this, [[1, 10]]);
|
|
1019
1082
|
}));
|
|
1020
1083
|
function refreshPaymentMethodsAsync() {
|
|
1021
1084
|
return _refreshPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -1029,13 +1092,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1029
1092
|
}, {
|
|
1030
1093
|
key: "getOrderOriginalData",
|
|
1031
1094
|
value: function getOrderOriginalData() {
|
|
1032
|
-
var _this$store$
|
|
1033
|
-
return (_this$store$
|
|
1095
|
+
var _this$store$currentOr6;
|
|
1096
|
+
return (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.order_info;
|
|
1034
1097
|
}
|
|
1035
1098
|
|
|
1036
1099
|
/**
|
|
1037
1100
|
* 获取当前订单基础信息
|
|
1038
|
-
*
|
|
1101
|
+
*
|
|
1039
1102
|
* 返回当前订单的基础信息,包括订单状态、金额、支付状态等
|
|
1040
1103
|
*/
|
|
1041
1104
|
}, {
|
|
@@ -1090,25 +1153,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1090
1153
|
|
|
1091
1154
|
/**
|
|
1092
1155
|
* 获取当前订单的支付项
|
|
1093
|
-
*
|
|
1156
|
+
*
|
|
1094
1157
|
* 返回当前订单的所有支付项,包括活跃和已撤销的支付项
|
|
1095
1158
|
*/
|
|
1096
1159
|
}, {
|
|
1097
1160
|
key: "getCurrentOrderPaymentItemsAsync",
|
|
1098
1161
|
value: (function () {
|
|
1099
|
-
var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1162
|
+
var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1100
1163
|
var _currentOrder2, paymentItems;
|
|
1101
|
-
return _regeneratorRuntime().wrap(function
|
|
1102
|
-
while (1) switch (
|
|
1164
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1165
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1103
1166
|
case 0:
|
|
1104
|
-
|
|
1167
|
+
_context18.prev = 0;
|
|
1105
1168
|
_currentOrder2 = this.store.currentOrder;
|
|
1106
1169
|
if (_currentOrder2) {
|
|
1107
|
-
|
|
1170
|
+
_context18.next = 5;
|
|
1108
1171
|
break;
|
|
1109
1172
|
}
|
|
1110
1173
|
console.log('[Checkout] 当前没有活跃订单,无法获取支付项');
|
|
1111
|
-
return
|
|
1174
|
+
return _context18.abrupt("return", []);
|
|
1112
1175
|
case 5:
|
|
1113
1176
|
console.log('[Checkout] 获取当前订单支付项:', {
|
|
1114
1177
|
orderUuid: _currentOrder2.uuid,
|
|
@@ -1116,10 +1179,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1116
1179
|
});
|
|
1117
1180
|
|
|
1118
1181
|
// 调用Payment模块获取支付项
|
|
1119
|
-
|
|
1182
|
+
_context18.next = 8;
|
|
1120
1183
|
return this.payment.getPaymentItemsAsync(_currentOrder2.uuid);
|
|
1121
1184
|
case 8:
|
|
1122
|
-
paymentItems =
|
|
1185
|
+
paymentItems = _context18.sent;
|
|
1123
1186
|
console.log('[Checkout] 成功获取支付项:', {
|
|
1124
1187
|
orderUuid: _currentOrder2.uuid,
|
|
1125
1188
|
paymentItemCount: paymentItems.length,
|
|
@@ -1144,17 +1207,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1144
1207
|
};
|
|
1145
1208
|
})
|
|
1146
1209
|
});
|
|
1147
|
-
return
|
|
1210
|
+
return _context18.abrupt("return", paymentItems);
|
|
1148
1211
|
case 13:
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
console.error('[Checkout] 获取当前订单支付项失败:',
|
|
1152
|
-
return
|
|
1212
|
+
_context18.prev = 13;
|
|
1213
|
+
_context18.t0 = _context18["catch"](0);
|
|
1214
|
+
console.error('[Checkout] 获取当前订单支付项失败:', _context18.t0);
|
|
1215
|
+
return _context18.abrupt("return", []);
|
|
1153
1216
|
case 17:
|
|
1154
1217
|
case "end":
|
|
1155
|
-
return
|
|
1218
|
+
return _context18.stop();
|
|
1156
1219
|
}
|
|
1157
|
-
},
|
|
1220
|
+
}, _callee18, this, [[0, 13]]);
|
|
1158
1221
|
}));
|
|
1159
1222
|
function getCurrentOrderPaymentItemsAsync() {
|
|
1160
1223
|
return _getCurrentOrderPaymentItemsAsync.apply(this, arguments);
|
|
@@ -1168,10 +1231,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1168
1231
|
}, {
|
|
1169
1232
|
key: "validateCheckoutAsync",
|
|
1170
1233
|
value: (function () {
|
|
1171
|
-
var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1234
|
+
var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1172
1235
|
var errors;
|
|
1173
|
-
return _regeneratorRuntime().wrap(function
|
|
1174
|
-
while (1) switch (
|
|
1236
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1237
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1175
1238
|
case 0:
|
|
1176
1239
|
errors = []; // 验证购物车
|
|
1177
1240
|
if (!this.store.cartItems || this.store.cartItems.length === 0) {
|
|
@@ -1187,15 +1250,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1187
1250
|
if (this.store.status === CheckoutStatus.Error) {
|
|
1188
1251
|
errors.push('结账流程存在错误');
|
|
1189
1252
|
}
|
|
1190
|
-
return
|
|
1253
|
+
return _context19.abrupt("return", {
|
|
1191
1254
|
valid: errors.length === 0,
|
|
1192
1255
|
errors: errors
|
|
1193
1256
|
});
|
|
1194
1257
|
case 5:
|
|
1195
1258
|
case "end":
|
|
1196
|
-
return
|
|
1259
|
+
return _context19.stop();
|
|
1197
1260
|
}
|
|
1198
|
-
},
|
|
1261
|
+
}, _callee19, this);
|
|
1199
1262
|
}));
|
|
1200
1263
|
function validateCheckoutAsync() {
|
|
1201
1264
|
return _validateCheckoutAsync.apply(this, arguments);
|
|
@@ -1209,44 +1272,44 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1209
1272
|
}, {
|
|
1210
1273
|
key: "retryFailedOperationAsync",
|
|
1211
1274
|
value: (function () {
|
|
1212
|
-
var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1213
|
-
return _regeneratorRuntime().wrap(function
|
|
1214
|
-
while (1) switch (
|
|
1275
|
+
var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1276
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1277
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1215
1278
|
case 0:
|
|
1216
|
-
|
|
1279
|
+
_context20.prev = 0;
|
|
1217
1280
|
if (!(this.store.status === CheckoutStatus.Error && this.store.lastError)) {
|
|
1218
|
-
|
|
1281
|
+
_context20.next = 10;
|
|
1219
1282
|
break;
|
|
1220
1283
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1284
|
+
_context20.t0 = this.store.lastError.type;
|
|
1285
|
+
_context20.next = _context20.t0 === CheckoutErrorType.OrderCreationFailed ? 5 : 9;
|
|
1223
1286
|
break;
|
|
1224
1287
|
case 5:
|
|
1225
1288
|
if (!(this.store.cartItems.length > 0)) {
|
|
1226
|
-
|
|
1289
|
+
_context20.next = 8;
|
|
1227
1290
|
break;
|
|
1228
1291
|
}
|
|
1229
|
-
|
|
1292
|
+
_context20.next = 8;
|
|
1230
1293
|
return this.createOrderAsync({
|
|
1231
1294
|
cartItems: this.store.cartItems
|
|
1232
1295
|
});
|
|
1233
1296
|
case 8:
|
|
1234
|
-
return
|
|
1297
|
+
return _context20.abrupt("break", 10);
|
|
1235
1298
|
case 9:
|
|
1236
1299
|
console.warn('[Checkout] 无法重试此类型的错误:', this.store.lastError.type);
|
|
1237
1300
|
case 10:
|
|
1238
|
-
|
|
1301
|
+
_context20.next = 16;
|
|
1239
1302
|
break;
|
|
1240
1303
|
case 12:
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
return this.handleError(
|
|
1304
|
+
_context20.prev = 12;
|
|
1305
|
+
_context20.t1 = _context20["catch"](0);
|
|
1306
|
+
_context20.next = 16;
|
|
1307
|
+
return this.handleError(_context20.t1, CheckoutErrorType.UnknownError);
|
|
1245
1308
|
case 16:
|
|
1246
1309
|
case "end":
|
|
1247
|
-
return
|
|
1310
|
+
return _context20.stop();
|
|
1248
1311
|
}
|
|
1249
|
-
},
|
|
1312
|
+
}, _callee20, this, [[0, 12]]);
|
|
1250
1313
|
}));
|
|
1251
1314
|
function retryFailedOperationAsync() {
|
|
1252
1315
|
return _retryFailedOperationAsync.apply(this, arguments);
|
|
@@ -1289,41 +1352,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1289
1352
|
|
|
1290
1353
|
/**
|
|
1291
1354
|
* 替换本地订单ID为真实订单ID
|
|
1292
|
-
*
|
|
1355
|
+
*
|
|
1293
1356
|
* 当后端订单创建完成后,调用此方法将本地虚拟订单ID替换为真实订单ID
|
|
1294
|
-
*
|
|
1357
|
+
*
|
|
1295
1358
|
* @param newOrderId 后端返回的真实订单ID
|
|
1296
1359
|
* @returns 更新后的订单对象,如果当前没有订单则返回null
|
|
1297
1360
|
*/
|
|
1298
1361
|
}, {
|
|
1299
1362
|
key: "replaceLocalOrderIdAsync",
|
|
1300
1363
|
value: (function () {
|
|
1301
|
-
var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1364
|
+
var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(newOrderId) {
|
|
1302
1365
|
var updatedOrder;
|
|
1303
|
-
return _regeneratorRuntime().wrap(function
|
|
1304
|
-
while (1) switch (
|
|
1366
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1367
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1305
1368
|
case 0:
|
|
1306
|
-
|
|
1369
|
+
_context21.prev = 0;
|
|
1307
1370
|
if (this.store.currentOrder) {
|
|
1308
|
-
|
|
1371
|
+
_context21.next = 4;
|
|
1309
1372
|
break;
|
|
1310
1373
|
}
|
|
1311
1374
|
console.warn('[Checkout] 没有当前订单,无法替换订单ID');
|
|
1312
|
-
return
|
|
1375
|
+
return _context21.abrupt("return", null);
|
|
1313
1376
|
case 4:
|
|
1314
|
-
|
|
1377
|
+
_context21.next = 6;
|
|
1315
1378
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, newOrderId);
|
|
1316
1379
|
case 6:
|
|
1317
|
-
updatedOrder =
|
|
1380
|
+
updatedOrder = _context21.sent;
|
|
1318
1381
|
if (!updatedOrder) {
|
|
1319
|
-
|
|
1382
|
+
_context21.next = 15;
|
|
1320
1383
|
break;
|
|
1321
1384
|
}
|
|
1322
1385
|
// 更新当前订单引用
|
|
1323
1386
|
this.store.currentOrder = updatedOrder;
|
|
1324
1387
|
|
|
1325
1388
|
// 触发订单更新事件
|
|
1326
|
-
|
|
1389
|
+
_context21.next = 11;
|
|
1327
1390
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1328
1391
|
order: updatedOrder,
|
|
1329
1392
|
timestamp: Date.now()
|
|
@@ -1338,50 +1401,50 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1338
1401
|
this.store.isOrderSynced = true;
|
|
1339
1402
|
|
|
1340
1403
|
// 订单ID替换后更新 stateAmount
|
|
1341
|
-
|
|
1404
|
+
_context21.next = 15;
|
|
1342
1405
|
return this.updateStateAmountToRemaining();
|
|
1343
1406
|
case 15:
|
|
1344
|
-
return
|
|
1407
|
+
return _context21.abrupt("return", updatedOrder);
|
|
1345
1408
|
case 18:
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
console.error('[Checkout] 替换订单ID失败:',
|
|
1349
|
-
|
|
1350
|
-
return this.handleError(
|
|
1409
|
+
_context21.prev = 18;
|
|
1410
|
+
_context21.t0 = _context21["catch"](0);
|
|
1411
|
+
console.error('[Checkout] 替换订单ID失败:', _context21.t0);
|
|
1412
|
+
_context21.next = 23;
|
|
1413
|
+
return this.handleError(_context21.t0, CheckoutErrorType.UnknownError);
|
|
1351
1414
|
case 23:
|
|
1352
|
-
return
|
|
1415
|
+
return _context21.abrupt("return", null);
|
|
1353
1416
|
case 24:
|
|
1354
1417
|
case "end":
|
|
1355
|
-
return
|
|
1418
|
+
return _context21.stop();
|
|
1356
1419
|
}
|
|
1357
|
-
},
|
|
1420
|
+
}, _callee21, this, [[0, 18]]);
|
|
1358
1421
|
}));
|
|
1359
|
-
function replaceLocalOrderIdAsync(
|
|
1422
|
+
function replaceLocalOrderIdAsync(_x14) {
|
|
1360
1423
|
return _replaceLocalOrderIdAsync.apply(this, arguments);
|
|
1361
1424
|
}
|
|
1362
1425
|
return replaceLocalOrderIdAsync;
|
|
1363
1426
|
}()
|
|
1364
1427
|
/**
|
|
1365
1428
|
* 设置自定义支付金额
|
|
1366
|
-
*
|
|
1429
|
+
*
|
|
1367
1430
|
* 允许UI自定义本次支付的金额,通常用于部分支付或调整支付金额场景
|
|
1368
|
-
*
|
|
1431
|
+
*
|
|
1369
1432
|
* @param amount 自定义支付金额,必须是有效的数字字符串
|
|
1370
1433
|
*/
|
|
1371
1434
|
)
|
|
1372
1435
|
}, {
|
|
1373
1436
|
key: "setStateAmountAsync",
|
|
1374
1437
|
value: (function () {
|
|
1375
|
-
var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1438
|
+
var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(amount) {
|
|
1376
1439
|
var numAmount, oldAmount, formattedAmount, errorMessage;
|
|
1377
|
-
return _regeneratorRuntime().wrap(function
|
|
1378
|
-
while (1) switch (
|
|
1440
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1441
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1379
1442
|
case 0:
|
|
1380
|
-
|
|
1443
|
+
_context22.prev = 0;
|
|
1381
1444
|
// 验证金额格式
|
|
1382
1445
|
numAmount = parseFloat(amount);
|
|
1383
1446
|
if (!(isNaN(numAmount) || numAmount < 0)) {
|
|
1384
|
-
|
|
1447
|
+
_context22.next = 4;
|
|
1385
1448
|
break;
|
|
1386
1449
|
}
|
|
1387
1450
|
throw new Error("\u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: ".concat(amount));
|
|
@@ -1389,16 +1452,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1389
1452
|
oldAmount = this.store.stateAmount;
|
|
1390
1453
|
formattedAmount = numAmount.toFixed(2); // 如果金额没有变化,直接返回
|
|
1391
1454
|
if (!(oldAmount === formattedAmount)) {
|
|
1392
|
-
|
|
1455
|
+
_context22.next = 8;
|
|
1393
1456
|
break;
|
|
1394
1457
|
}
|
|
1395
|
-
return
|
|
1458
|
+
return _context22.abrupt("return");
|
|
1396
1459
|
case 8:
|
|
1397
1460
|
// 更新状态
|
|
1398
1461
|
this.store.stateAmount = formattedAmount;
|
|
1399
1462
|
|
|
1400
1463
|
// 触发金额变更事件
|
|
1401
|
-
|
|
1464
|
+
_context22.next = 11;
|
|
1402
1465
|
return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
|
|
1403
1466
|
oldAmount: oldAmount,
|
|
1404
1467
|
newAmount: formattedAmount,
|
|
@@ -1409,31 +1472,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1409
1472
|
oldAmount: oldAmount,
|
|
1410
1473
|
newAmount: formattedAmount
|
|
1411
1474
|
});
|
|
1412
|
-
|
|
1475
|
+
_context22.next = 21;
|
|
1413
1476
|
break;
|
|
1414
1477
|
case 14:
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
errorMessage =
|
|
1478
|
+
_context22.prev = 14;
|
|
1479
|
+
_context22.t0 = _context22["catch"](0);
|
|
1480
|
+
errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : '设置支付金额失败';
|
|
1418
1481
|
console.error('[Checkout] 设置自定义支付金额失败:', errorMessage);
|
|
1419
|
-
|
|
1482
|
+
_context22.next = 20;
|
|
1420
1483
|
return this.handleError(new Error(errorMessage), CheckoutErrorType.ValidationFailed);
|
|
1421
1484
|
case 20:
|
|
1422
|
-
throw
|
|
1485
|
+
throw _context22.t0;
|
|
1423
1486
|
case 21:
|
|
1424
1487
|
case "end":
|
|
1425
|
-
return
|
|
1488
|
+
return _context22.stop();
|
|
1426
1489
|
}
|
|
1427
|
-
},
|
|
1490
|
+
}, _callee22, this, [[0, 14]]);
|
|
1428
1491
|
}));
|
|
1429
|
-
function setStateAmountAsync(
|
|
1492
|
+
function setStateAmountAsync(_x15) {
|
|
1430
1493
|
return _setStateAmountAsync.apply(this, arguments);
|
|
1431
1494
|
}
|
|
1432
1495
|
return setStateAmountAsync;
|
|
1433
1496
|
}()
|
|
1434
1497
|
/**
|
|
1435
1498
|
* 获取当前自定义支付金额
|
|
1436
|
-
*
|
|
1499
|
+
*
|
|
1437
1500
|
* @returns 当前设置的自定义支付金额
|
|
1438
1501
|
*/
|
|
1439
1502
|
)
|
|
@@ -1445,23 +1508,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1445
1508
|
|
|
1446
1509
|
/**
|
|
1447
1510
|
* 刷新 stateAmount 为当前剩余未支付金额
|
|
1448
|
-
*
|
|
1511
|
+
*
|
|
1449
1512
|
* UI 可以调用此方法来主动刷新支付金额状态
|
|
1450
1513
|
*/
|
|
1451
1514
|
}, {
|
|
1452
1515
|
key: "refreshStateAmountAsync",
|
|
1453
1516
|
value: (function () {
|
|
1454
|
-
var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1455
|
-
return _regeneratorRuntime().wrap(function
|
|
1456
|
-
while (1) switch (
|
|
1517
|
+
var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1518
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1519
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1457
1520
|
case 0:
|
|
1458
|
-
|
|
1521
|
+
_context23.next = 2;
|
|
1459
1522
|
return this.updateStateAmountToRemaining();
|
|
1460
1523
|
case 2:
|
|
1461
1524
|
case "end":
|
|
1462
|
-
return
|
|
1525
|
+
return _context23.stop();
|
|
1463
1526
|
}
|
|
1464
|
-
},
|
|
1527
|
+
}, _callee23, this);
|
|
1465
1528
|
}));
|
|
1466
1529
|
function refreshStateAmountAsync() {
|
|
1467
1530
|
return _refreshStateAmountAsync.apply(this, arguments);
|
|
@@ -1470,9 +1533,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1470
1533
|
}()
|
|
1471
1534
|
/**
|
|
1472
1535
|
* 获取购物车小计数据
|
|
1473
|
-
*
|
|
1536
|
+
*
|
|
1474
1537
|
* 返回当前结账流程中的购物车小计项数据,包含各种费用明细
|
|
1475
|
-
*
|
|
1538
|
+
*
|
|
1476
1539
|
* @returns 购物车小计数据数组,如果没有则返回 null
|
|
1477
1540
|
*/
|
|
1478
1541
|
)
|
|
@@ -1498,9 +1561,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1498
1561
|
|
|
1499
1562
|
/**
|
|
1500
1563
|
* 获取提取的金额详细信息
|
|
1501
|
-
*
|
|
1564
|
+
*
|
|
1502
1565
|
* 从当前的购物车小计数据中提取结构化的金额信息
|
|
1503
|
-
*
|
|
1566
|
+
*
|
|
1504
1567
|
* @returns 提取的金额信息对象,如果没有小计数据则返回 null
|
|
1505
1568
|
*/
|
|
1506
1569
|
}, {
|
|
@@ -1517,27 +1580,48 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1517
1580
|
|
|
1518
1581
|
/**
|
|
1519
1582
|
* 获取支付方式列表
|
|
1520
|
-
*
|
|
1521
|
-
*
|
|
1522
|
-
*
|
|
1583
|
+
*
|
|
1584
|
+
* 优先使用 store 中的缓存数据,避免重复接口调用。
|
|
1585
|
+
* 如果 store 中没有数据,则调用 Payment 模块的方法获取。
|
|
1586
|
+
*
|
|
1523
1587
|
* @returns 支付方式列表
|
|
1524
1588
|
*/
|
|
1525
1589
|
}, {
|
|
1526
1590
|
key: "getPaymentMethodsAsync",
|
|
1527
1591
|
value: (function () {
|
|
1528
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1529
|
-
|
|
1530
|
-
|
|
1592
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1593
|
+
var methods;
|
|
1594
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1595
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1531
1596
|
case 0:
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1597
|
+
if (!(this.store.paymentMethods && this.store.paymentMethods.length > 0)) {
|
|
1598
|
+
_context24.next = 3;
|
|
1599
|
+
break;
|
|
1600
|
+
}
|
|
1601
|
+
console.log("[Checkout] \u4F7F\u7528\u7F13\u5B58\u7684\u652F\u4ED8\u65B9\u5F0F\u6570\u636E\uFF0C\u5171 ".concat(this.store.paymentMethods.length, " \u79CD"));
|
|
1602
|
+
return _context24.abrupt("return", this.store.paymentMethods);
|
|
1536
1603
|
case 3:
|
|
1604
|
+
// 如果缓存为空,调用 Payment 模块获取
|
|
1605
|
+
console.log('[Checkout] store 中无缓存,从 Payment 模块获取支付方式...');
|
|
1606
|
+
_context24.prev = 4;
|
|
1607
|
+
_context24.next = 7;
|
|
1608
|
+
return this.payment.getPayMethodListAsync();
|
|
1609
|
+
case 7:
|
|
1610
|
+
methods = _context24.sent;
|
|
1611
|
+
// 更新缓存
|
|
1612
|
+
this.store.paymentMethods = methods;
|
|
1613
|
+
console.log("[Checkout] \u4ECE Payment \u6A21\u5757\u83B7\u53D6\u5230 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F\uFF0C\u5DF2\u66F4\u65B0\u7F13\u5B58"));
|
|
1614
|
+
return _context24.abrupt("return", methods);
|
|
1615
|
+
case 13:
|
|
1616
|
+
_context24.prev = 13;
|
|
1617
|
+
_context24.t0 = _context24["catch"](4);
|
|
1618
|
+
console.error('[Checkout] 获取支付方式失败:', _context24.t0);
|
|
1619
|
+
return _context24.abrupt("return", []);
|
|
1620
|
+
case 17:
|
|
1537
1621
|
case "end":
|
|
1538
|
-
return
|
|
1622
|
+
return _context24.stop();
|
|
1539
1623
|
}
|
|
1540
|
-
},
|
|
1624
|
+
}, _callee24, this, [[4, 13]]);
|
|
1541
1625
|
}));
|
|
1542
1626
|
function getPaymentMethodsAsync() {
|
|
1543
1627
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -1546,9 +1630,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1546
1630
|
}()
|
|
1547
1631
|
/**
|
|
1548
1632
|
* 为当前订单添加支付项
|
|
1549
|
-
*
|
|
1633
|
+
*
|
|
1550
1634
|
* 向当前活跃订单添加一个支付项,支付项包含支付方式信息和金额
|
|
1551
|
-
*
|
|
1635
|
+
*
|
|
1552
1636
|
* @param paymentItem 支付项数据
|
|
1553
1637
|
* @throws 当前没有活跃订单时抛出错误
|
|
1554
1638
|
*/
|
|
@@ -1556,14 +1640,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1556
1640
|
}, {
|
|
1557
1641
|
key: "addPaymentItemAsync",
|
|
1558
1642
|
value: (function () {
|
|
1559
|
-
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1643
|
+
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paymentItem) {
|
|
1560
1644
|
var currentOrderId, isCurrentOrderReal;
|
|
1561
|
-
return _regeneratorRuntime().wrap(function
|
|
1562
|
-
while (1) switch (
|
|
1645
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1646
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1563
1647
|
case 0:
|
|
1564
|
-
|
|
1648
|
+
_context25.prev = 0;
|
|
1565
1649
|
if (this.store.currentOrder) {
|
|
1566
|
-
|
|
1650
|
+
_context25.next = 3;
|
|
1567
1651
|
break;
|
|
1568
1652
|
}
|
|
1569
1653
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
|
|
@@ -1580,7 +1664,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1580
1664
|
});
|
|
1581
1665
|
|
|
1582
1666
|
// 添加支付项到订单
|
|
1583
|
-
|
|
1667
|
+
_context25.next = 6;
|
|
1584
1668
|
return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
|
|
1585
1669
|
case 6:
|
|
1586
1670
|
console.log('[Checkout] 支付项添加成功');
|
|
@@ -1642,10 +1726,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1642
1726
|
// }
|
|
1643
1727
|
|
|
1644
1728
|
// 支付项添加后,更新 stateAmount 为剩余未支付金额
|
|
1645
|
-
|
|
1729
|
+
_context25.next = 12;
|
|
1646
1730
|
return this.updateStateAmountToRemaining();
|
|
1647
1731
|
case 12:
|
|
1648
|
-
|
|
1732
|
+
_context25.next = 14;
|
|
1649
1733
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1650
1734
|
orderUuid: this.store.currentOrder.uuid,
|
|
1651
1735
|
paymentMethodCode: paymentItem.code,
|
|
@@ -1653,32 +1737,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1653
1737
|
timestamp: Date.now()
|
|
1654
1738
|
});
|
|
1655
1739
|
case 14:
|
|
1656
|
-
|
|
1740
|
+
_context25.next = 22;
|
|
1657
1741
|
break;
|
|
1658
1742
|
case 16:
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
console.error('[Checkout] 添加支付项失败:',
|
|
1662
|
-
|
|
1663
|
-
return this.handleError(
|
|
1743
|
+
_context25.prev = 16;
|
|
1744
|
+
_context25.t0 = _context25["catch"](0);
|
|
1745
|
+
console.error('[Checkout] 添加支付项失败:', _context25.t0);
|
|
1746
|
+
_context25.next = 21;
|
|
1747
|
+
return this.handleError(_context25.t0, CheckoutErrorType.PaymentFailed);
|
|
1664
1748
|
case 21:
|
|
1665
|
-
throw
|
|
1749
|
+
throw _context25.t0;
|
|
1666
1750
|
case 22:
|
|
1667
1751
|
case "end":
|
|
1668
|
-
return
|
|
1752
|
+
return _context25.stop();
|
|
1669
1753
|
}
|
|
1670
|
-
},
|
|
1754
|
+
}, _callee25, this, [[0, 16]]);
|
|
1671
1755
|
}));
|
|
1672
|
-
function addPaymentItemAsync(
|
|
1756
|
+
function addPaymentItemAsync(_x16) {
|
|
1673
1757
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
1674
1758
|
}
|
|
1675
1759
|
return addPaymentItemAsync;
|
|
1676
1760
|
}()
|
|
1677
1761
|
/**
|
|
1678
1762
|
* 删除当前订单的支付项
|
|
1679
|
-
*
|
|
1763
|
+
*
|
|
1680
1764
|
* 从当前活跃订单中删除指定的支付项,支付项将被标记为已撤销状态
|
|
1681
|
-
*
|
|
1765
|
+
*
|
|
1682
1766
|
* @param paymentUuid 要删除的支付项UUID
|
|
1683
1767
|
* @throws 当前没有活跃订单时抛出错误
|
|
1684
1768
|
* @throws 支付项不存在时抛出错误
|
|
@@ -1687,14 +1771,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1687
1771
|
}, {
|
|
1688
1772
|
key: "deletePaymentItemAsync",
|
|
1689
1773
|
value: (function () {
|
|
1690
|
-
var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1774
|
+
var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paymentUuid) {
|
|
1691
1775
|
var currentPayments, paymentItem, currentOrderId, isCurrentOrderReal, updatedOrder;
|
|
1692
|
-
return _regeneratorRuntime().wrap(function
|
|
1693
|
-
while (1) switch (
|
|
1776
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1777
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1694
1778
|
case 0:
|
|
1695
|
-
|
|
1779
|
+
_context26.prev = 0;
|
|
1696
1780
|
if (this.store.currentOrder) {
|
|
1697
|
-
|
|
1781
|
+
_context26.next = 3;
|
|
1698
1782
|
break;
|
|
1699
1783
|
}
|
|
1700
1784
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法删除支付项');
|
|
@@ -1705,16 +1789,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1705
1789
|
});
|
|
1706
1790
|
|
|
1707
1791
|
// 从 Payment 模块验证支付项是否存在
|
|
1708
|
-
|
|
1792
|
+
_context26.next = 6;
|
|
1709
1793
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, true // 包括已撤销的支付项,因为我们需要验证是否存在
|
|
1710
1794
|
);
|
|
1711
1795
|
case 6:
|
|
1712
|
-
currentPayments =
|
|
1796
|
+
currentPayments = _context26.sent;
|
|
1713
1797
|
paymentItem = currentPayments.find(function (p) {
|
|
1714
1798
|
return p.uuid === paymentUuid;
|
|
1715
1799
|
});
|
|
1716
1800
|
if (paymentItem) {
|
|
1717
|
-
|
|
1801
|
+
_context26.next = 10;
|
|
1718
1802
|
break;
|
|
1719
1803
|
}
|
|
1720
1804
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
|
|
@@ -1727,7 +1811,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1727
1811
|
});
|
|
1728
1812
|
|
|
1729
1813
|
// 调用 Payment 模块删除支付项
|
|
1730
|
-
|
|
1814
|
+
_context26.next = 13;
|
|
1731
1815
|
return this.payment.deletePaymentAsync(this.store.currentOrder.uuid, paymentUuid);
|
|
1732
1816
|
case 13:
|
|
1733
1817
|
console.log('[Checkout] Payment模块删除完成');
|
|
@@ -1735,10 +1819,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1735
1819
|
// 重新从Payment模块获取最新的订单数据,确保支付项同步
|
|
1736
1820
|
currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
|
|
1737
1821
|
isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
|
|
1738
|
-
|
|
1822
|
+
_context26.next = 18;
|
|
1739
1823
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
1740
1824
|
case 18:
|
|
1741
|
-
updatedOrder =
|
|
1825
|
+
updatedOrder = _context26.sent;
|
|
1742
1826
|
if (updatedOrder) {
|
|
1743
1827
|
// 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
|
|
1744
1828
|
if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
|
|
@@ -1753,10 +1837,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1753
1837
|
}
|
|
1754
1838
|
|
|
1755
1839
|
// 更新 stateAmount 为剩余未支付金额
|
|
1756
|
-
|
|
1840
|
+
_context26.next = 22;
|
|
1757
1841
|
return this.updateStateAmountToRemaining();
|
|
1758
1842
|
case 22:
|
|
1759
|
-
|
|
1843
|
+
_context26.next = 24;
|
|
1760
1844
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1761
1845
|
orderUuid: this.store.currentOrder.uuid,
|
|
1762
1846
|
paymentMethodCode: paymentItem.code,
|
|
@@ -1766,33 +1850,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1766
1850
|
});
|
|
1767
1851
|
case 24:
|
|
1768
1852
|
console.log('[Checkout] 支付项删除成功');
|
|
1769
|
-
|
|
1853
|
+
_context26.next = 33;
|
|
1770
1854
|
break;
|
|
1771
1855
|
case 27:
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
console.error('[Checkout] 删除支付项失败:',
|
|
1775
|
-
|
|
1776
|
-
return this.handleError(
|
|
1856
|
+
_context26.prev = 27;
|
|
1857
|
+
_context26.t0 = _context26["catch"](0);
|
|
1858
|
+
console.error('[Checkout] 删除支付项失败:', _context26.t0);
|
|
1859
|
+
_context26.next = 32;
|
|
1860
|
+
return this.handleError(_context26.t0, CheckoutErrorType.PaymentFailed);
|
|
1777
1861
|
case 32:
|
|
1778
|
-
throw
|
|
1862
|
+
throw _context26.t0;
|
|
1779
1863
|
case 33:
|
|
1780
1864
|
case "end":
|
|
1781
|
-
return
|
|
1865
|
+
return _context26.stop();
|
|
1782
1866
|
}
|
|
1783
|
-
},
|
|
1867
|
+
}, _callee26, this, [[0, 27]]);
|
|
1784
1868
|
}));
|
|
1785
|
-
function deletePaymentItemAsync(
|
|
1869
|
+
function deletePaymentItemAsync(_x17) {
|
|
1786
1870
|
return _deletePaymentItemAsync.apply(this, arguments);
|
|
1787
1871
|
}
|
|
1788
1872
|
return deletePaymentItemAsync;
|
|
1789
1873
|
}()
|
|
1790
1874
|
/**
|
|
1791
1875
|
* 批量更新当前订单的代金券支付项(覆盖更新)
|
|
1792
|
-
*
|
|
1876
|
+
*
|
|
1793
1877
|
* 删除所有现有的代金券支付项,然后添加新的代金券支付项。
|
|
1794
1878
|
* 这是一个覆盖式更新操作,确保代金券支付项的一致性。
|
|
1795
|
-
*
|
|
1879
|
+
*
|
|
1796
1880
|
* @param voucherPaymentItems 新的代金券支付项列表,每个都必须包含 voucher_id
|
|
1797
1881
|
* @throws 当前没有活跃订单时抛出错误
|
|
1798
1882
|
* @throws 支付项缺少 voucher_id 时抛出错误
|
|
@@ -1801,14 +1885,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1801
1885
|
}, {
|
|
1802
1886
|
key: "updateVoucherPaymentItemsAsync",
|
|
1803
1887
|
value: (function () {
|
|
1804
|
-
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1888
|
+
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(voucherPaymentItems) {
|
|
1805
1889
|
var _iterator, _step, item, currentOrderId, isCurrentOrderReal, updatedOrder, voucherItems;
|
|
1806
|
-
return _regeneratorRuntime().wrap(function
|
|
1807
|
-
while (1) switch (
|
|
1890
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1891
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1808
1892
|
case 0:
|
|
1809
|
-
|
|
1893
|
+
_context27.prev = 0;
|
|
1810
1894
|
if (this.store.currentOrder) {
|
|
1811
|
-
|
|
1895
|
+
_context27.next = 3;
|
|
1812
1896
|
break;
|
|
1813
1897
|
}
|
|
1814
1898
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法更新代金券支付项');
|
|
@@ -1821,35 +1905,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1821
1905
|
|
|
1822
1906
|
// 验证所有支付项都包含 voucher_id
|
|
1823
1907
|
_iterator = _createForOfIteratorHelper(voucherPaymentItems);
|
|
1824
|
-
|
|
1908
|
+
_context27.prev = 5;
|
|
1825
1909
|
_iterator.s();
|
|
1826
1910
|
case 7:
|
|
1827
1911
|
if ((_step = _iterator.n()).done) {
|
|
1828
|
-
|
|
1912
|
+
_context27.next = 13;
|
|
1829
1913
|
break;
|
|
1830
1914
|
}
|
|
1831
1915
|
item = _step.value;
|
|
1832
1916
|
if (item.voucher_id) {
|
|
1833
|
-
|
|
1917
|
+
_context27.next = 11;
|
|
1834
1918
|
break;
|
|
1835
1919
|
}
|
|
1836
1920
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(item)));
|
|
1837
1921
|
case 11:
|
|
1838
|
-
|
|
1922
|
+
_context27.next = 7;
|
|
1839
1923
|
break;
|
|
1840
1924
|
case 13:
|
|
1841
|
-
|
|
1925
|
+
_context27.next = 18;
|
|
1842
1926
|
break;
|
|
1843
1927
|
case 15:
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
_iterator.e(
|
|
1928
|
+
_context27.prev = 15;
|
|
1929
|
+
_context27.t0 = _context27["catch"](5);
|
|
1930
|
+
_iterator.e(_context27.t0);
|
|
1847
1931
|
case 18:
|
|
1848
|
-
|
|
1932
|
+
_context27.prev = 18;
|
|
1849
1933
|
_iterator.f();
|
|
1850
|
-
return
|
|
1934
|
+
return _context27.finish(18);
|
|
1851
1935
|
case 21:
|
|
1852
|
-
|
|
1936
|
+
_context27.next = 23;
|
|
1853
1937
|
return this.payment.updateVoucherPaymentItemsAsync(this.store.currentOrder.uuid, voucherPaymentItems);
|
|
1854
1938
|
case 23:
|
|
1855
1939
|
console.log('[Checkout] Payment模块批量更新完成');
|
|
@@ -1857,10 +1941,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1857
1941
|
// 重新从Payment模块获取最新的订单数据,确保支付项同步
|
|
1858
1942
|
currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
|
|
1859
1943
|
isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
|
|
1860
|
-
|
|
1944
|
+
_context27.next = 28;
|
|
1861
1945
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
1862
1946
|
case 28:
|
|
1863
|
-
updatedOrder =
|
|
1947
|
+
updatedOrder = _context27.sent;
|
|
1864
1948
|
if (updatedOrder) {
|
|
1865
1949
|
// 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
|
|
1866
1950
|
if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
|
|
@@ -1891,10 +1975,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1891
1975
|
}
|
|
1892
1976
|
|
|
1893
1977
|
// 更新 stateAmount 为剩余未支付金额
|
|
1894
|
-
|
|
1978
|
+
_context27.next = 32;
|
|
1895
1979
|
return this.updateStateAmountToRemaining();
|
|
1896
1980
|
case 32:
|
|
1897
|
-
|
|
1981
|
+
_context27.next = 34;
|
|
1898
1982
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1899
1983
|
orderUuid: this.store.currentOrder.uuid,
|
|
1900
1984
|
paymentMethodCode: 'VOUCHER_BATCH',
|
|
@@ -1905,32 +1989,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1905
1989
|
});
|
|
1906
1990
|
case 34:
|
|
1907
1991
|
console.log('[Checkout] 代金券支付项批量更新成功');
|
|
1908
|
-
|
|
1992
|
+
_context27.next = 43;
|
|
1909
1993
|
break;
|
|
1910
1994
|
case 37:
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
console.error('[Checkout] 批量更新代金券支付项失败:',
|
|
1914
|
-
|
|
1915
|
-
return this.handleError(
|
|
1995
|
+
_context27.prev = 37;
|
|
1996
|
+
_context27.t1 = _context27["catch"](0);
|
|
1997
|
+
console.error('[Checkout] 批量更新代金券支付项失败:', _context27.t1);
|
|
1998
|
+
_context27.next = 42;
|
|
1999
|
+
return this.handleError(_context27.t1, CheckoutErrorType.PaymentFailed);
|
|
1916
2000
|
case 42:
|
|
1917
|
-
throw
|
|
2001
|
+
throw _context27.t1;
|
|
1918
2002
|
case 43:
|
|
1919
2003
|
case "end":
|
|
1920
|
-
return
|
|
2004
|
+
return _context27.stop();
|
|
1921
2005
|
}
|
|
1922
|
-
},
|
|
2006
|
+
}, _callee27, this, [[0, 37], [5, 15, 18, 21]]);
|
|
1923
2007
|
}));
|
|
1924
|
-
function updateVoucherPaymentItemsAsync(
|
|
2008
|
+
function updateVoucherPaymentItemsAsync(_x18) {
|
|
1925
2009
|
return _updateVoucherPaymentItemsAsync.apply(this, arguments);
|
|
1926
2010
|
}
|
|
1927
2011
|
return updateVoucherPaymentItemsAsync;
|
|
1928
2012
|
}()
|
|
1929
2013
|
/**
|
|
1930
2014
|
* 修改当前订单的定金状态
|
|
1931
|
-
*
|
|
2015
|
+
*
|
|
1932
2016
|
* 更新当前订单的 is_deposit 字段,用于标识订单是否为定金订单
|
|
1933
|
-
*
|
|
2017
|
+
*
|
|
1934
2018
|
* @param isDeposit 定金状态 (1: 定金订单, 0: 全款订单)
|
|
1935
2019
|
* @throws 当前没有活跃订单时抛出错误
|
|
1936
2020
|
*/
|
|
@@ -1938,20 +2022,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1938
2022
|
}, {
|
|
1939
2023
|
key: "updateOrderDepositStatusAsync",
|
|
1940
2024
|
value: (function () {
|
|
1941
|
-
var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2025
|
+
var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(isDeposit) {
|
|
1942
2026
|
var newDepositValue, oldDepositValue, updateParams;
|
|
1943
|
-
return _regeneratorRuntime().wrap(function
|
|
1944
|
-
while (1) switch (
|
|
2027
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2028
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1945
2029
|
case 0:
|
|
1946
|
-
|
|
2030
|
+
_context28.prev = 0;
|
|
1947
2031
|
if (!(isDeposit !== 0 && isDeposit !== 1)) {
|
|
1948
|
-
|
|
2032
|
+
_context28.next = 3;
|
|
1949
2033
|
break;
|
|
1950
2034
|
}
|
|
1951
2035
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, 'isDeposit 参数只能是 0(全款订单)或 1(定金订单)');
|
|
1952
2036
|
case 3:
|
|
1953
2037
|
if (this.store.currentOrder) {
|
|
1954
|
-
|
|
2038
|
+
_context28.next = 5;
|
|
1955
2039
|
break;
|
|
1956
2040
|
}
|
|
1957
2041
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法修改定金状态');
|
|
@@ -1959,11 +2043,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1959
2043
|
newDepositValue = isDeposit;
|
|
1960
2044
|
oldDepositValue = this.store.currentOrder.is_deposit; // 如果状态没有变化,直接返回
|
|
1961
2045
|
if (!(oldDepositValue === newDepositValue)) {
|
|
1962
|
-
|
|
2046
|
+
_context28.next = 10;
|
|
1963
2047
|
break;
|
|
1964
2048
|
}
|
|
1965
2049
|
console.log('[Checkout] 定金状态无变化,跳过更新');
|
|
1966
|
-
return
|
|
2050
|
+
return _context28.abrupt("return");
|
|
1967
2051
|
case 10:
|
|
1968
2052
|
console.log('[Checkout] 更新订单定金状态:', {
|
|
1969
2053
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -1982,7 +2066,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1982
2066
|
}
|
|
1983
2067
|
|
|
1984
2068
|
// 调用 Payment 模块更新订单
|
|
1985
|
-
|
|
2069
|
+
_context28.next = 15;
|
|
1986
2070
|
return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
|
|
1987
2071
|
case 15:
|
|
1988
2072
|
// 更新本地缓存的订单对象
|
|
@@ -1994,7 +2078,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1994
2078
|
}
|
|
1995
2079
|
|
|
1996
2080
|
// 触发订单更新事件
|
|
1997
|
-
|
|
2081
|
+
_context28.next = 19;
|
|
1998
2082
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1999
2083
|
order: this.store.currentOrder,
|
|
2000
2084
|
timestamp: Date.now()
|
|
@@ -2004,32 +2088,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2004
2088
|
isDeposit: newDepositValue,
|
|
2005
2089
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
2006
2090
|
});
|
|
2007
|
-
|
|
2091
|
+
_context28.next = 28;
|
|
2008
2092
|
break;
|
|
2009
2093
|
case 22:
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
console.error('[Checkout] 更新订单定金状态失败:',
|
|
2013
|
-
|
|
2014
|
-
return this.handleError(
|
|
2094
|
+
_context28.prev = 22;
|
|
2095
|
+
_context28.t0 = _context28["catch"](0);
|
|
2096
|
+
console.error('[Checkout] 更新订单定金状态失败:', _context28.t0);
|
|
2097
|
+
_context28.next = 27;
|
|
2098
|
+
return this.handleError(_context28.t0, CheckoutErrorType.ValidationFailed);
|
|
2015
2099
|
case 27:
|
|
2016
|
-
throw
|
|
2100
|
+
throw _context28.t0;
|
|
2017
2101
|
case 28:
|
|
2018
2102
|
case "end":
|
|
2019
|
-
return
|
|
2103
|
+
return _context28.stop();
|
|
2020
2104
|
}
|
|
2021
|
-
},
|
|
2105
|
+
}, _callee28, this, [[0, 22]]);
|
|
2022
2106
|
}));
|
|
2023
|
-
function updateOrderDepositStatusAsync(
|
|
2107
|
+
function updateOrderDepositStatusAsync(_x19) {
|
|
2024
2108
|
return _updateOrderDepositStatusAsync.apply(this, arguments);
|
|
2025
2109
|
}
|
|
2026
2110
|
return updateOrderDepositStatusAsync;
|
|
2027
2111
|
}()
|
|
2028
2112
|
/**
|
|
2029
2113
|
* 更新当前订单的客户信息
|
|
2030
|
-
*
|
|
2114
|
+
*
|
|
2031
2115
|
* 更新当前订单关联的客户信息,用于标识订单的所属客户
|
|
2032
|
-
*
|
|
2116
|
+
*
|
|
2033
2117
|
* @param customer 客户信息 (customer_id 和/或 customer_name)
|
|
2034
2118
|
* @throws 当前没有活跃订单时抛出错误
|
|
2035
2119
|
*/
|
|
@@ -2037,13 +2121,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2037
2121
|
}, {
|
|
2038
2122
|
key: "updateOrderCustomerAsync",
|
|
2039
2123
|
value: (function () {
|
|
2040
|
-
var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2041
|
-
return _regeneratorRuntime().wrap(function
|
|
2042
|
-
while (1) switch (
|
|
2124
|
+
var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(customer) {
|
|
2125
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2126
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2043
2127
|
case 0:
|
|
2044
|
-
|
|
2128
|
+
_context29.prev = 0;
|
|
2045
2129
|
if (this.store.currentOrder) {
|
|
2046
|
-
|
|
2130
|
+
_context29.next = 3;
|
|
2047
2131
|
break;
|
|
2048
2132
|
}
|
|
2049
2133
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法更新客户信息');
|
|
@@ -2066,30 +2150,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2066
2150
|
this.store.localOrderData.customer_name = customer.customer_name;
|
|
2067
2151
|
}
|
|
2068
2152
|
console.log('[Checkout] 订单客户信息更新成功:', this.store.currentCustomer);
|
|
2069
|
-
|
|
2153
|
+
_context29.next = 15;
|
|
2070
2154
|
break;
|
|
2071
2155
|
case 9:
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
console.error('[Checkout] 更新订单客户信息失败:',
|
|
2075
|
-
|
|
2076
|
-
return this.handleError(
|
|
2156
|
+
_context29.prev = 9;
|
|
2157
|
+
_context29.t0 = _context29["catch"](0);
|
|
2158
|
+
console.error('[Checkout] 更新订单客户信息失败:', _context29.t0);
|
|
2159
|
+
_context29.next = 14;
|
|
2160
|
+
return this.handleError(_context29.t0, CheckoutErrorType.ValidationFailed);
|
|
2077
2161
|
case 14:
|
|
2078
|
-
throw
|
|
2162
|
+
throw _context29.t0;
|
|
2079
2163
|
case 15:
|
|
2080
2164
|
case "end":
|
|
2081
|
-
return
|
|
2165
|
+
return _context29.stop();
|
|
2082
2166
|
}
|
|
2083
|
-
},
|
|
2167
|
+
}, _callee29, this, [[0, 9]]);
|
|
2084
2168
|
}));
|
|
2085
|
-
function updateOrderCustomerAsync(
|
|
2169
|
+
function updateOrderCustomerAsync(_x20) {
|
|
2086
2170
|
return _updateOrderCustomerAsync.apply(this, arguments);
|
|
2087
2171
|
}
|
|
2088
2172
|
return updateOrderCustomerAsync;
|
|
2089
2173
|
}()
|
|
2090
2174
|
/**
|
|
2091
2175
|
* 获取当前订单的客户信息
|
|
2092
|
-
*
|
|
2176
|
+
*
|
|
2093
2177
|
* @returns 当前客户信息,如果没有则返回 null
|
|
2094
2178
|
*/
|
|
2095
2179
|
)
|
|
@@ -2101,41 +2185,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2101
2185
|
|
|
2102
2186
|
/**
|
|
2103
2187
|
* 检查订单是否需要手动同步(异步版本)
|
|
2104
|
-
*
|
|
2188
|
+
*
|
|
2105
2189
|
* 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
|
|
2106
2190
|
* 从 Payment 模块获取最新的支付项数据
|
|
2107
2191
|
*/
|
|
2108
2192
|
}, {
|
|
2109
2193
|
key: "needsManualSyncAsync",
|
|
2110
2194
|
value: (function () {
|
|
2111
|
-
var _needsManualSyncAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2195
|
+
var _needsManualSyncAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2112
2196
|
var remainingAmount, remainingValue, currentPayments, allPaymentsHaveVoucherId;
|
|
2113
|
-
return _regeneratorRuntime().wrap(function
|
|
2114
|
-
while (1) switch (
|
|
2197
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2198
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2115
2199
|
case 0:
|
|
2116
|
-
|
|
2200
|
+
_context30.prev = 0;
|
|
2117
2201
|
if (!(!this.store.currentOrder || this.store.isOrderSynced)) {
|
|
2118
|
-
|
|
2202
|
+
_context30.next = 3;
|
|
2119
2203
|
break;
|
|
2120
2204
|
}
|
|
2121
|
-
return
|
|
2205
|
+
return _context30.abrupt("return", false);
|
|
2122
2206
|
case 3:
|
|
2123
|
-
|
|
2207
|
+
_context30.next = 5;
|
|
2124
2208
|
return this.calculateRemainingAmountAsync();
|
|
2125
2209
|
case 5:
|
|
2126
|
-
remainingAmount =
|
|
2210
|
+
remainingAmount = _context30.sent;
|
|
2127
2211
|
remainingValue = parseFloat(remainingAmount);
|
|
2128
2212
|
if (!(remainingValue > 0)) {
|
|
2129
|
-
|
|
2213
|
+
_context30.next = 9;
|
|
2130
2214
|
break;
|
|
2131
2215
|
}
|
|
2132
|
-
return
|
|
2216
|
+
return _context30.abrupt("return", false);
|
|
2133
2217
|
case 9:
|
|
2134
|
-
|
|
2218
|
+
_context30.next = 11;
|
|
2135
2219
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
2136
2220
|
);
|
|
2137
2221
|
case 11:
|
|
2138
|
-
currentPayments =
|
|
2222
|
+
currentPayments = _context30.sent;
|
|
2139
2223
|
allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(function (item) {
|
|
2140
2224
|
return item.status !== 'voided' && item.voucher_id;
|
|
2141
2225
|
});
|
|
@@ -2155,17 +2239,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2155
2239
|
};
|
|
2156
2240
|
})
|
|
2157
2241
|
});
|
|
2158
|
-
return
|
|
2242
|
+
return _context30.abrupt("return", allPaymentsHaveVoucherId);
|
|
2159
2243
|
case 17:
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
console.error('[Checkout] needsManualSyncAsync 检查失败:',
|
|
2163
|
-
return
|
|
2244
|
+
_context30.prev = 17;
|
|
2245
|
+
_context30.t0 = _context30["catch"](0);
|
|
2246
|
+
console.error('[Checkout] needsManualSyncAsync 检查失败:', _context30.t0);
|
|
2247
|
+
return _context30.abrupt("return", false);
|
|
2164
2248
|
case 21:
|
|
2165
2249
|
case "end":
|
|
2166
|
-
return
|
|
2250
|
+
return _context30.stop();
|
|
2167
2251
|
}
|
|
2168
|
-
},
|
|
2252
|
+
}, _callee30, this, [[0, 17]]);
|
|
2169
2253
|
}));
|
|
2170
2254
|
function needsManualSyncAsync() {
|
|
2171
2255
|
return _needsManualSyncAsync.apply(this, arguments);
|
|
@@ -2174,24 +2258,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2174
2258
|
}()
|
|
2175
2259
|
/**
|
|
2176
2260
|
* 手动同步订单到后端
|
|
2177
|
-
*
|
|
2261
|
+
*
|
|
2178
2262
|
* 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
|
|
2179
2263
|
*/
|
|
2180
2264
|
)
|
|
2181
2265
|
}, {
|
|
2182
2266
|
key: "manualSyncOrderAsync",
|
|
2183
2267
|
value: (function () {
|
|
2184
|
-
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2185
|
-
var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$
|
|
2186
|
-
return _regeneratorRuntime().wrap(function
|
|
2187
|
-
while (1) switch (
|
|
2268
|
+
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2269
|
+
var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr7, errorMessage;
|
|
2270
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2271
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2188
2272
|
case 0:
|
|
2189
|
-
|
|
2273
|
+
_context31.prev = 0;
|
|
2190
2274
|
if (this.store.currentOrder) {
|
|
2191
|
-
|
|
2275
|
+
_context31.next = 3;
|
|
2192
2276
|
break;
|
|
2193
2277
|
}
|
|
2194
|
-
return
|
|
2278
|
+
return _context31.abrupt("return", {
|
|
2195
2279
|
success: false,
|
|
2196
2280
|
message: '当前没有活跃订单,无法同步'
|
|
2197
2281
|
});
|
|
@@ -2201,25 +2285,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2201
2285
|
if (this.store.isOrderSynced) {
|
|
2202
2286
|
console.log('[Checkout] 订单已同步过,将执行更新操作');
|
|
2203
2287
|
}
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2288
|
+
_context31.t0 = console;
|
|
2289
|
+
_context31.t1 = orderUuid;
|
|
2290
|
+
_context31.t2 = oldOrderId;
|
|
2291
|
+
_context31.t3 = this.store.currentOrder.total_amount;
|
|
2292
|
+
_context31.next = 12;
|
|
2209
2293
|
return this.calculateRemainingAmountAsync();
|
|
2210
2294
|
case 12:
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
orderUuid:
|
|
2214
|
-
orderId:
|
|
2215
|
-
totalAmount:
|
|
2216
|
-
remainingAmount:
|
|
2295
|
+
_context31.t4 = _context31.sent;
|
|
2296
|
+
_context31.t5 = {
|
|
2297
|
+
orderUuid: _context31.t1,
|
|
2298
|
+
orderId: _context31.t2,
|
|
2299
|
+
totalAmount: _context31.t3,
|
|
2300
|
+
remainingAmount: _context31.t4
|
|
2217
2301
|
};
|
|
2218
|
-
|
|
2219
|
-
|
|
2302
|
+
_context31.t0.log.call(_context31.t0, '[Checkout] 开始手动同步订单到后端:', _context31.t5);
|
|
2303
|
+
_context31.next = 17;
|
|
2220
2304
|
return this.syncOrderToBackendWithReturn(true);
|
|
2221
2305
|
case 17:
|
|
2222
|
-
realOrderId =
|
|
2306
|
+
realOrderId = _context31.sent;
|
|
2223
2307
|
console.log('[Checkout] 手动同步订单完成:', {
|
|
2224
2308
|
orderUuid: orderUuid,
|
|
2225
2309
|
oldOrderId: oldOrderId,
|
|
@@ -2243,7 +2327,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2243
2327
|
if (realOrderId !== finalOrderId) {
|
|
2244
2328
|
console.error('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
|
|
2245
2329
|
}
|
|
2246
|
-
return
|
|
2330
|
+
return _context31.abrupt("return", {
|
|
2247
2331
|
success: true,
|
|
2248
2332
|
message: '订单同步成功',
|
|
2249
2333
|
orderId: realOrderId,
|
|
@@ -2251,20 +2335,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2251
2335
|
orderUuid: orderUuid
|
|
2252
2336
|
});
|
|
2253
2337
|
case 27:
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
console.error('[Checkout] 手动同步订单失败:',
|
|
2257
|
-
errorMessage =
|
|
2258
|
-
return
|
|
2338
|
+
_context31.prev = 27;
|
|
2339
|
+
_context31.t6 = _context31["catch"](0);
|
|
2340
|
+
console.error('[Checkout] 手动同步订单失败:', _context31.t6);
|
|
2341
|
+
errorMessage = _context31.t6 instanceof Error ? _context31.t6.message : '同步失败';
|
|
2342
|
+
return _context31.abrupt("return", {
|
|
2259
2343
|
success: false,
|
|
2260
2344
|
message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
|
|
2261
|
-
orderUuid: (_this$store$
|
|
2345
|
+
orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid
|
|
2262
2346
|
});
|
|
2263
2347
|
case 32:
|
|
2264
2348
|
case "end":
|
|
2265
|
-
return
|
|
2349
|
+
return _context31.stop();
|
|
2266
2350
|
}
|
|
2267
|
-
},
|
|
2351
|
+
}, _callee31, this, [[0, 27]]);
|
|
2268
2352
|
}));
|
|
2269
2353
|
function manualSyncOrderAsync() {
|
|
2270
2354
|
return _manualSyncOrderAsync.apply(this, arguments);
|
|
@@ -2273,7 +2357,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2273
2357
|
}()
|
|
2274
2358
|
/**
|
|
2275
2359
|
* 获取当前订单备注
|
|
2276
|
-
*
|
|
2360
|
+
*
|
|
2277
2361
|
* @returns 当前订单的备注内容,如果没有则返回空字符串
|
|
2278
2362
|
*/
|
|
2279
2363
|
)
|
|
@@ -2289,7 +2373,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2289
2373
|
|
|
2290
2374
|
/**
|
|
2291
2375
|
* 获取当前订单ID
|
|
2292
|
-
*
|
|
2376
|
+
*
|
|
2293
2377
|
* @returns 当前订单的ID,如果没有订单则返回null
|
|
2294
2378
|
*/
|
|
2295
2379
|
}, {
|
|
@@ -2303,7 +2387,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2303
2387
|
|
|
2304
2388
|
/**
|
|
2305
2389
|
* 获取当前订单是否已同步到后端
|
|
2306
|
-
*
|
|
2390
|
+
*
|
|
2307
2391
|
* @returns 当前订单是否已同步状态,如果没有订单则返回false
|
|
2308
2392
|
*/
|
|
2309
2393
|
}, {
|
|
@@ -2325,36 +2409,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2325
2409
|
|
|
2326
2410
|
/**
|
|
2327
2411
|
* 取消当前本地订单
|
|
2328
|
-
*
|
|
2412
|
+
*
|
|
2329
2413
|
* 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
|
|
2330
|
-
*
|
|
2414
|
+
*
|
|
2331
2415
|
* @param cancelReason 取消原因(可选)
|
|
2332
2416
|
* @returns 取消结果
|
|
2333
2417
|
*/
|
|
2334
2418
|
}, {
|
|
2335
2419
|
key: "cancelCurrentOrderAsync",
|
|
2336
2420
|
value: (function () {
|
|
2337
|
-
var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2338
|
-
var _this$store$
|
|
2339
|
-
return _regeneratorRuntime().wrap(function
|
|
2340
|
-
while (1) switch (
|
|
2421
|
+
var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(cancelReason) {
|
|
2422
|
+
var _this$store$currentOr8, _this$store$currentOr9, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
|
|
2423
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2424
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2341
2425
|
case 0:
|
|
2342
|
-
|
|
2426
|
+
_context32.prev = 0;
|
|
2343
2427
|
console.log('[Checkout] 开始取消当前本地订单:', {
|
|
2344
2428
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2345
|
-
orderUuid: (_this$store$
|
|
2346
|
-
orderId: (_this$store$
|
|
2429
|
+
orderUuid: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.uuid,
|
|
2430
|
+
orderId: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.order_id,
|
|
2347
2431
|
isOrderSynced: this.store.isOrderSynced,
|
|
2348
2432
|
cancelReason: cancelReason
|
|
2349
2433
|
});
|
|
2350
2434
|
|
|
2351
2435
|
// 检查是否有当前订单
|
|
2352
2436
|
if (this.store.currentOrder) {
|
|
2353
|
-
|
|
2437
|
+
_context32.next = 5;
|
|
2354
2438
|
break;
|
|
2355
2439
|
}
|
|
2356
2440
|
console.log('[Checkout] 没有当前订单,无需取消');
|
|
2357
|
-
return
|
|
2441
|
+
return _context32.abrupt("return", {
|
|
2358
2442
|
success: false,
|
|
2359
2443
|
message: '没有当前订单可取消'
|
|
2360
2444
|
});
|
|
@@ -2363,14 +2447,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2363
2447
|
currentOrderId = this.store.currentOrder.order_id;
|
|
2364
2448
|
isOrderSynced = this.store.isOrderSynced; // 检查订单是否已同步,已同步的订单不能取消
|
|
2365
2449
|
if (!isOrderSynced) {
|
|
2366
|
-
|
|
2450
|
+
_context32.next = 11;
|
|
2367
2451
|
break;
|
|
2368
2452
|
}
|
|
2369
2453
|
console.log('[Checkout] 订单已同步到后端,不能取消:', {
|
|
2370
2454
|
orderId: currentOrderId,
|
|
2371
2455
|
orderUuid: currentOrderUuid
|
|
2372
2456
|
});
|
|
2373
|
-
return
|
|
2457
|
+
return _context32.abrupt("return", {
|
|
2374
2458
|
success: false,
|
|
2375
2459
|
message: '订单已同步到后端,无法取消',
|
|
2376
2460
|
orderId: currentOrderId
|
|
@@ -2379,18 +2463,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2379
2463
|
console.log('[Checkout] 订单尚未同步,可以取消');
|
|
2380
2464
|
|
|
2381
2465
|
// 删除本地订单数据
|
|
2382
|
-
|
|
2466
|
+
_context32.prev = 12;
|
|
2383
2467
|
console.log('[Checkout] 删除本地订单数据');
|
|
2384
|
-
|
|
2468
|
+
_context32.next = 16;
|
|
2385
2469
|
return this.payment.deletePaymentOrderAsync(currentOrderUuid);
|
|
2386
2470
|
case 16:
|
|
2387
2471
|
console.log('[Checkout] 本地订单数据删除成功');
|
|
2388
|
-
|
|
2472
|
+
_context32.next = 22;
|
|
2389
2473
|
break;
|
|
2390
2474
|
case 19:
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
console.warn('[Checkout] 删除本地订单数据失败,但继续执行:',
|
|
2475
|
+
_context32.prev = 19;
|
|
2476
|
+
_context32.t0 = _context32["catch"](12);
|
|
2477
|
+
console.warn('[Checkout] 删除本地订单数据失败,但继续执行:', _context32.t0);
|
|
2394
2478
|
case 22:
|
|
2395
2479
|
// 清理订单相关状态,确保正确释放 currentOrder
|
|
2396
2480
|
console.log('[Checkout] 清理订单相关状态');
|
|
@@ -2405,7 +2489,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2405
2489
|
console.log('[Checkout] 订单状态清理完成,currentOrder已释放');
|
|
2406
2490
|
|
|
2407
2491
|
// 触发订单取消事件
|
|
2408
|
-
|
|
2492
|
+
_context32.next = 32;
|
|
2409
2493
|
return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
|
|
2410
2494
|
orderUuid: currentOrderUuid,
|
|
2411
2495
|
orderId: currentOrderId,
|
|
@@ -2420,34 +2504,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2420
2504
|
orderId: currentOrderId,
|
|
2421
2505
|
cancelReason: cancelReason
|
|
2422
2506
|
});
|
|
2423
|
-
return
|
|
2507
|
+
return _context32.abrupt("return", {
|
|
2424
2508
|
success: true,
|
|
2425
2509
|
message: '本地订单已成功取消',
|
|
2426
2510
|
orderId: currentOrderId
|
|
2427
2511
|
});
|
|
2428
2512
|
case 36:
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
console.error('[Checkout] 取消本地订单失败:',
|
|
2432
|
-
errorMessage =
|
|
2433
|
-
return
|
|
2513
|
+
_context32.prev = 36;
|
|
2514
|
+
_context32.t1 = _context32["catch"](0);
|
|
2515
|
+
console.error('[Checkout] 取消本地订单失败:', _context32.t1);
|
|
2516
|
+
errorMessage = _context32.t1 instanceof Error ? _context32.t1.message : '未知错误';
|
|
2517
|
+
return _context32.abrupt("return", {
|
|
2434
2518
|
success: false,
|
|
2435
2519
|
message: "\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ".concat(errorMessage)
|
|
2436
2520
|
});
|
|
2437
2521
|
case 41:
|
|
2438
2522
|
case "end":
|
|
2439
|
-
return
|
|
2523
|
+
return _context32.stop();
|
|
2440
2524
|
}
|
|
2441
|
-
},
|
|
2525
|
+
}, _callee32, this, [[0, 36], [12, 19]]);
|
|
2442
2526
|
}));
|
|
2443
|
-
function cancelCurrentOrderAsync(
|
|
2527
|
+
function cancelCurrentOrderAsync(_x21) {
|
|
2444
2528
|
return _cancelCurrentOrderAsync.apply(this, arguments);
|
|
2445
2529
|
}
|
|
2446
2530
|
return cancelCurrentOrderAsync;
|
|
2447
2531
|
}()
|
|
2448
2532
|
/**
|
|
2449
2533
|
* 保存订单并稍后支付
|
|
2450
|
-
*
|
|
2534
|
+
*
|
|
2451
2535
|
* 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
|
|
2452
2536
|
* 适用于用户想要保存订单但稍后完成支付的场景
|
|
2453
2537
|
*/
|
|
@@ -2455,17 +2539,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2455
2539
|
}, {
|
|
2456
2540
|
key: "saveForLaterPaymentAsync",
|
|
2457
2541
|
value: (function () {
|
|
2458
|
-
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2459
|
-
var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$
|
|
2460
|
-
return _regeneratorRuntime().wrap(function
|
|
2461
|
-
while (1) switch (
|
|
2542
|
+
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2543
|
+
var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr10, errorMessage;
|
|
2544
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2545
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2462
2546
|
case 0:
|
|
2463
|
-
|
|
2547
|
+
_context33.prev = 0;
|
|
2464
2548
|
if (this.store.currentOrder) {
|
|
2465
|
-
|
|
2549
|
+
_context33.next = 3;
|
|
2466
2550
|
break;
|
|
2467
2551
|
}
|
|
2468
|
-
return
|
|
2552
|
+
return _context33.abrupt("return", {
|
|
2469
2553
|
success: false,
|
|
2470
2554
|
message: '当前没有活跃订单,无法保存'
|
|
2471
2555
|
});
|
|
@@ -2479,10 +2563,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2479
2563
|
});
|
|
2480
2564
|
|
|
2481
2565
|
// 获取当前订单的所有支付项
|
|
2482
|
-
|
|
2566
|
+
_context33.next = 8;
|
|
2483
2567
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
2484
2568
|
case 8:
|
|
2485
|
-
allPaymentItems =
|
|
2569
|
+
allPaymentItems = _context33.sent;
|
|
2486
2570
|
// 过滤掉带有 voucher_id 的支付项(代金券类支付项)
|
|
2487
2571
|
filteredPaymentItems = allPaymentItems.filter(function (payment) {
|
|
2488
2572
|
return !payment.voucher_id || payment.voucher_id.trim() === '';
|
|
@@ -2512,10 +2596,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2512
2596
|
});
|
|
2513
2597
|
|
|
2514
2598
|
// 调用同步方法,传入过滤后的支付项
|
|
2515
|
-
|
|
2599
|
+
_context33.next = 14;
|
|
2516
2600
|
return this.syncOrderToBackendWithReturn(false, filteredPaymentItems);
|
|
2517
2601
|
case 14:
|
|
2518
|
-
realOrderId =
|
|
2602
|
+
realOrderId = _context33.sent;
|
|
2519
2603
|
console.log('[Checkout] 保存订单完成:', {
|
|
2520
2604
|
orderUuid: orderUuid,
|
|
2521
2605
|
oldOrderId: currentOrderId,
|
|
@@ -2532,27 +2616,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2532
2616
|
是否一致: realOrderId === finalOrderId,
|
|
2533
2617
|
同步状态: this.store.isOrderSynced
|
|
2534
2618
|
});
|
|
2535
|
-
return
|
|
2619
|
+
return _context33.abrupt("return", {
|
|
2536
2620
|
success: true,
|
|
2537
2621
|
message: '订单保存成功,可稍后继续支付',
|
|
2538
2622
|
orderId: realOrderId,
|
|
2539
2623
|
orderUuid: orderUuid
|
|
2540
2624
|
});
|
|
2541
2625
|
case 21:
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
console.error('[Checkout] 保存订单失败:',
|
|
2545
|
-
errorMessage =
|
|
2546
|
-
return
|
|
2626
|
+
_context33.prev = 21;
|
|
2627
|
+
_context33.t0 = _context33["catch"](0);
|
|
2628
|
+
console.error('[Checkout] 保存订单失败:', _context33.t0);
|
|
2629
|
+
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : '保存失败';
|
|
2630
|
+
return _context33.abrupt("return", {
|
|
2547
2631
|
success: false,
|
|
2548
2632
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2549
|
-
orderUuid: (_this$store$
|
|
2633
|
+
orderUuid: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.uuid
|
|
2550
2634
|
});
|
|
2551
2635
|
case 26:
|
|
2552
2636
|
case "end":
|
|
2553
|
-
return
|
|
2637
|
+
return _context33.stop();
|
|
2554
2638
|
}
|
|
2555
|
-
},
|
|
2639
|
+
}, _callee33, this, [[0, 21]]);
|
|
2556
2640
|
}));
|
|
2557
2641
|
function saveForLaterPaymentAsync() {
|
|
2558
2642
|
return _saveForLaterPaymentAsync.apply(this, arguments);
|
|
@@ -2561,7 +2645,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2561
2645
|
}()
|
|
2562
2646
|
/**
|
|
2563
2647
|
* 获取当前商店折扣金额
|
|
2564
|
-
*
|
|
2648
|
+
*
|
|
2565
2649
|
* @returns 当前的商店折扣金额,如果没有则返回0
|
|
2566
2650
|
*/
|
|
2567
2651
|
)
|
|
@@ -2588,23 +2672,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2588
2672
|
|
|
2589
2673
|
/**
|
|
2590
2674
|
* 更新订单商店折扣
|
|
2591
|
-
*
|
|
2675
|
+
*
|
|
2592
2676
|
* 同时更新cartSummary和localOrderData中的shop_discount值
|
|
2593
|
-
*
|
|
2677
|
+
*
|
|
2594
2678
|
* @param discountAmount 商店折扣金额
|
|
2595
2679
|
*/
|
|
2596
2680
|
}, {
|
|
2597
2681
|
key: "updateShopDiscountAsync",
|
|
2598
2682
|
value: (function () {
|
|
2599
|
-
var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2600
|
-
var _this$store$
|
|
2601
|
-
return _regeneratorRuntime().wrap(function
|
|
2602
|
-
while (1) switch (
|
|
2683
|
+
var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(discountAmount) {
|
|
2684
|
+
var _this$store$currentOr11, _this$store$currentOr12, oldDiscount, shopDiscountItem, updatedAmountInfo;
|
|
2685
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2686
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2603
2687
|
case 0:
|
|
2604
|
-
|
|
2688
|
+
_context34.prev = 0;
|
|
2605
2689
|
oldDiscount = this.getShopDiscount();
|
|
2606
2690
|
console.log('[Checkout] 更新商店折扣:', {
|
|
2607
|
-
orderUuid: (_this$store$
|
|
2691
|
+
orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid,
|
|
2608
2692
|
oldDiscount: oldDiscount,
|
|
2609
2693
|
newDiscount: discountAmount
|
|
2610
2694
|
});
|
|
@@ -2649,12 +2733,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2649
2733
|
}
|
|
2650
2734
|
|
|
2651
2735
|
// 4. 更新 stateAmount 为剩余未支付金额
|
|
2652
|
-
|
|
2736
|
+
_context34.next = 8;
|
|
2653
2737
|
return this.updateStateAmountToRemaining();
|
|
2654
2738
|
case 8:
|
|
2655
|
-
|
|
2739
|
+
_context34.next = 10;
|
|
2656
2740
|
return this.core.effects.emit(CheckoutHooks.OnShopDiscountChanged, {
|
|
2657
|
-
orderUuid: (_this$store$
|
|
2741
|
+
orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
|
|
2658
2742
|
oldDiscount: oldDiscount,
|
|
2659
2743
|
newDiscount: discountAmount,
|
|
2660
2744
|
timestamp: Date.now()
|
|
@@ -2664,50 +2748,50 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2664
2748
|
oldDiscount: oldDiscount,
|
|
2665
2749
|
newDiscount: discountAmount
|
|
2666
2750
|
});
|
|
2667
|
-
|
|
2751
|
+
_context34.next = 19;
|
|
2668
2752
|
break;
|
|
2669
2753
|
case 13:
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
console.error('[Checkout] 更新商店折扣失败:',
|
|
2673
|
-
|
|
2674
|
-
return this.handleError(
|
|
2754
|
+
_context34.prev = 13;
|
|
2755
|
+
_context34.t0 = _context34["catch"](0);
|
|
2756
|
+
console.error('[Checkout] 更新商店折扣失败:', _context34.t0);
|
|
2757
|
+
_context34.next = 18;
|
|
2758
|
+
return this.handleError(_context34.t0, CheckoutErrorType.ValidationFailed);
|
|
2675
2759
|
case 18:
|
|
2676
|
-
throw
|
|
2760
|
+
throw _context34.t0;
|
|
2677
2761
|
case 19:
|
|
2678
2762
|
case "end":
|
|
2679
|
-
return
|
|
2763
|
+
return _context34.stop();
|
|
2680
2764
|
}
|
|
2681
|
-
},
|
|
2765
|
+
}, _callee34, this, [[0, 13]]);
|
|
2682
2766
|
}));
|
|
2683
|
-
function updateShopDiscountAsync(
|
|
2767
|
+
function updateShopDiscountAsync(_x22) {
|
|
2684
2768
|
return _updateShopDiscountAsync.apply(this, arguments);
|
|
2685
2769
|
}
|
|
2686
2770
|
return updateShopDiscountAsync;
|
|
2687
2771
|
}()
|
|
2688
2772
|
/**
|
|
2689
2773
|
* 更新订单备注
|
|
2690
|
-
*
|
|
2774
|
+
*
|
|
2691
2775
|
* @param note 订单备注内容
|
|
2692
2776
|
*/
|
|
2693
2777
|
)
|
|
2694
2778
|
}, {
|
|
2695
2779
|
key: "updateOrderNoteAsync",
|
|
2696
2780
|
value: (function () {
|
|
2697
|
-
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2698
|
-
var _this$store$
|
|
2699
|
-
return _regeneratorRuntime().wrap(function
|
|
2700
|
-
while (1) switch (
|
|
2781
|
+
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(note) {
|
|
2782
|
+
var _this$store$currentOr13, _this$store$currentOr14, oldNote, orderInPayment;
|
|
2783
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2784
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2701
2785
|
case 0:
|
|
2702
|
-
|
|
2786
|
+
_context35.prev = 0;
|
|
2703
2787
|
if (this.store.localOrderData) {
|
|
2704
|
-
|
|
2788
|
+
_context35.next = 3;
|
|
2705
2789
|
break;
|
|
2706
2790
|
}
|
|
2707
2791
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
|
|
2708
2792
|
case 3:
|
|
2709
2793
|
console.log('[Checkout] 更新订单备注:', {
|
|
2710
|
-
orderUuid: (_this$store$
|
|
2794
|
+
orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
|
|
2711
2795
|
oldNote: this.store.localOrderData.shop_note,
|
|
2712
2796
|
newNote: note
|
|
2713
2797
|
});
|
|
@@ -2718,29 +2802,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2718
2802
|
|
|
2719
2803
|
// 如果有当前订单,也同步到Payment模块中的订单数据
|
|
2720
2804
|
if (!this.store.currentOrder) {
|
|
2721
|
-
|
|
2805
|
+
_context35.next = 17;
|
|
2722
2806
|
break;
|
|
2723
2807
|
}
|
|
2724
|
-
|
|
2725
|
-
|
|
2808
|
+
_context35.prev = 7;
|
|
2809
|
+
_context35.next = 10;
|
|
2726
2810
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
2727
2811
|
case 10:
|
|
2728
|
-
orderInPayment =
|
|
2812
|
+
orderInPayment = _context35.sent;
|
|
2729
2813
|
if (orderInPayment && orderInPayment.note !== undefined) {
|
|
2730
2814
|
// 使用Payment模块的更新方法(如果有的话)
|
|
2731
2815
|
// 这里可能需要根据Payment模块的实际API来调整
|
|
2732
2816
|
console.log('[Checkout] 同步备注到Payment模块的订单数据中');
|
|
2733
2817
|
}
|
|
2734
|
-
|
|
2818
|
+
_context35.next = 17;
|
|
2735
2819
|
break;
|
|
2736
2820
|
case 14:
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:',
|
|
2821
|
+
_context35.prev = 14;
|
|
2822
|
+
_context35.t0 = _context35["catch"](7);
|
|
2823
|
+
console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context35.t0);
|
|
2740
2824
|
case 17:
|
|
2741
|
-
|
|
2825
|
+
_context35.next = 19;
|
|
2742
2826
|
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
2743
|
-
orderUuid: (_this$store$
|
|
2827
|
+
orderUuid: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.uuid,
|
|
2744
2828
|
oldNote: oldNote,
|
|
2745
2829
|
newNote: note,
|
|
2746
2830
|
timestamp: Date.now()
|
|
@@ -2750,23 +2834,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2750
2834
|
oldNote: oldNote,
|
|
2751
2835
|
newNote: note
|
|
2752
2836
|
});
|
|
2753
|
-
|
|
2837
|
+
_context35.next = 28;
|
|
2754
2838
|
break;
|
|
2755
2839
|
case 22:
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
console.error('[Checkout] 更新订单备注失败:',
|
|
2759
|
-
|
|
2760
|
-
return this.handleError(
|
|
2840
|
+
_context35.prev = 22;
|
|
2841
|
+
_context35.t1 = _context35["catch"](0);
|
|
2842
|
+
console.error('[Checkout] 更新订单备注失败:', _context35.t1);
|
|
2843
|
+
_context35.next = 27;
|
|
2844
|
+
return this.handleError(_context35.t1, CheckoutErrorType.ValidationFailed);
|
|
2761
2845
|
case 27:
|
|
2762
|
-
throw
|
|
2846
|
+
throw _context35.t1;
|
|
2763
2847
|
case 28:
|
|
2764
2848
|
case "end":
|
|
2765
|
-
return
|
|
2849
|
+
return _context35.stop();
|
|
2766
2850
|
}
|
|
2767
|
-
},
|
|
2851
|
+
}, _callee35, this, [[0, 22], [7, 14]]);
|
|
2768
2852
|
}));
|
|
2769
|
-
function updateOrderNoteAsync(
|
|
2853
|
+
function updateOrderNoteAsync(_x23) {
|
|
2770
2854
|
return _updateOrderNoteAsync.apply(this, arguments);
|
|
2771
2855
|
}
|
|
2772
2856
|
return updateOrderNoteAsync;
|
|
@@ -2778,14 +2862,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2778
2862
|
}, {
|
|
2779
2863
|
key: "setStatus",
|
|
2780
2864
|
value: (function () {
|
|
2781
|
-
var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2865
|
+
var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(status) {
|
|
2782
2866
|
var oldStatus;
|
|
2783
|
-
return _regeneratorRuntime().wrap(function
|
|
2784
|
-
while (1) switch (
|
|
2867
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2868
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2785
2869
|
case 0:
|
|
2786
2870
|
oldStatus = this.store.status;
|
|
2787
2871
|
this.store.status = status;
|
|
2788
|
-
|
|
2872
|
+
_context36.next = 4;
|
|
2789
2873
|
return this.core.effects.emit(CheckoutHooks.OnStatusChanged, {
|
|
2790
2874
|
oldStatus: oldStatus,
|
|
2791
2875
|
newStatus: status,
|
|
@@ -2793,11 +2877,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2793
2877
|
});
|
|
2794
2878
|
case 4:
|
|
2795
2879
|
case "end":
|
|
2796
|
-
return
|
|
2880
|
+
return _context36.stop();
|
|
2797
2881
|
}
|
|
2798
|
-
},
|
|
2882
|
+
}, _callee36, this);
|
|
2799
2883
|
}));
|
|
2800
|
-
function setStatus(
|
|
2884
|
+
function setStatus(_x24) {
|
|
2801
2885
|
return _setStatus.apply(this, arguments);
|
|
2802
2886
|
}
|
|
2803
2887
|
return setStatus;
|
|
@@ -2809,14 +2893,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2809
2893
|
}, {
|
|
2810
2894
|
key: "setStep",
|
|
2811
2895
|
value: (function () {
|
|
2812
|
-
var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2896
|
+
var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(step) {
|
|
2813
2897
|
var oldStep;
|
|
2814
|
-
return _regeneratorRuntime().wrap(function
|
|
2815
|
-
while (1) switch (
|
|
2898
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2899
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2816
2900
|
case 0:
|
|
2817
2901
|
oldStep = this.store.step;
|
|
2818
2902
|
this.store.step = step;
|
|
2819
|
-
|
|
2903
|
+
_context37.next = 4;
|
|
2820
2904
|
return this.core.effects.emit(CheckoutHooks.OnStepChanged, {
|
|
2821
2905
|
oldStep: oldStep,
|
|
2822
2906
|
newStep: step,
|
|
@@ -2824,11 +2908,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2824
2908
|
});
|
|
2825
2909
|
case 4:
|
|
2826
2910
|
case "end":
|
|
2827
|
-
return
|
|
2911
|
+
return _context37.stop();
|
|
2828
2912
|
}
|
|
2829
|
-
},
|
|
2913
|
+
}, _callee37, this);
|
|
2830
2914
|
}));
|
|
2831
|
-
function setStep(
|
|
2915
|
+
function setStep(_x25) {
|
|
2832
2916
|
return _setStep.apply(this, arguments);
|
|
2833
2917
|
}
|
|
2834
2918
|
return setStep;
|
|
@@ -2840,17 +2924,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2840
2924
|
}, {
|
|
2841
2925
|
key: "handleError",
|
|
2842
2926
|
value: (function () {
|
|
2843
|
-
var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2927
|
+
var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(error, type) {
|
|
2844
2928
|
var checkoutError;
|
|
2845
|
-
return _regeneratorRuntime().wrap(function
|
|
2846
|
-
while (1) switch (
|
|
2929
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2930
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2847
2931
|
case 0:
|
|
2848
2932
|
checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
|
|
2849
2933
|
this.store.lastError = checkoutError;
|
|
2850
|
-
|
|
2934
|
+
_context38.next = 4;
|
|
2851
2935
|
return this.setStatus(CheckoutStatus.Error);
|
|
2852
2936
|
case 4:
|
|
2853
|
-
|
|
2937
|
+
_context38.next = 6;
|
|
2854
2938
|
return this.core.effects.emit(CheckoutHooks.OnError, {
|
|
2855
2939
|
error: checkoutError,
|
|
2856
2940
|
context: {
|
|
@@ -2863,11 +2947,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2863
2947
|
console.error('[Checkout] 错误:', checkoutError);
|
|
2864
2948
|
case 7:
|
|
2865
2949
|
case "end":
|
|
2866
|
-
return
|
|
2950
|
+
return _context38.stop();
|
|
2867
2951
|
}
|
|
2868
|
-
},
|
|
2952
|
+
}, _callee38, this);
|
|
2869
2953
|
}));
|
|
2870
|
-
function handleError(
|
|
2954
|
+
function handleError(_x26, _x27) {
|
|
2871
2955
|
return _handleError.apply(this, arguments);
|
|
2872
2956
|
}
|
|
2873
2957
|
return handleError;
|
|
@@ -2879,34 +2963,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2879
2963
|
}, {
|
|
2880
2964
|
key: "handlePaymentSuccess",
|
|
2881
2965
|
value: (function () {
|
|
2882
|
-
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2883
|
-
var _this$store$
|
|
2884
|
-
return _regeneratorRuntime().wrap(function
|
|
2885
|
-
while (1) switch (
|
|
2966
|
+
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(data) {
|
|
2967
|
+
var _this$store$currentOr15;
|
|
2968
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2969
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2886
2970
|
case 0:
|
|
2887
|
-
|
|
2971
|
+
_context39.next = 2;
|
|
2888
2972
|
return this.setStatus(CheckoutStatus.PaymentCompleted);
|
|
2889
2973
|
case 2:
|
|
2890
|
-
|
|
2974
|
+
_context39.next = 4;
|
|
2891
2975
|
return this.updateStateAmountToRemaining();
|
|
2892
2976
|
case 4:
|
|
2893
|
-
|
|
2977
|
+
_context39.next = 6;
|
|
2894
2978
|
return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
|
|
2895
2979
|
orderUuid: data.orderUuid,
|
|
2896
2980
|
paymentMethodCode: '',
|
|
2897
|
-
amount: ((_this$store$
|
|
2981
|
+
amount: ((_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.total_amount) || '0',
|
|
2898
2982
|
timestamp: data.timestamp
|
|
2899
2983
|
});
|
|
2900
2984
|
case 6:
|
|
2901
|
-
|
|
2985
|
+
_context39.next = 8;
|
|
2902
2986
|
return this.completeCheckoutAsync();
|
|
2903
2987
|
case 8:
|
|
2904
2988
|
case "end":
|
|
2905
|
-
return
|
|
2989
|
+
return _context39.stop();
|
|
2906
2990
|
}
|
|
2907
|
-
},
|
|
2991
|
+
}, _callee39, this);
|
|
2908
2992
|
}));
|
|
2909
|
-
function handlePaymentSuccess(
|
|
2993
|
+
function handlePaymentSuccess(_x28) {
|
|
2910
2994
|
return _handlePaymentSuccess.apply(this, arguments);
|
|
2911
2995
|
}
|
|
2912
2996
|
return handlePaymentSuccess;
|
|
@@ -2918,30 +3002,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2918
3002
|
}, {
|
|
2919
3003
|
key: "handlePaymentError",
|
|
2920
3004
|
value: (function () {
|
|
2921
|
-
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2922
|
-
var _this$store$
|
|
3005
|
+
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
|
|
3006
|
+
var _this$store$currentOr16;
|
|
2923
3007
|
var error;
|
|
2924
|
-
return _regeneratorRuntime().wrap(function
|
|
2925
|
-
while (1) switch (
|
|
3008
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3009
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2926
3010
|
case 0:
|
|
2927
3011
|
error = createCheckoutError(CheckoutErrorType.PaymentFailed, data.error || '支付同步失败');
|
|
2928
|
-
|
|
3012
|
+
_context40.next = 3;
|
|
2929
3013
|
return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
|
|
2930
3014
|
case 3:
|
|
2931
|
-
|
|
3015
|
+
_context40.next = 5;
|
|
2932
3016
|
return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
|
|
2933
3017
|
orderUuid: data.orderUuid,
|
|
2934
3018
|
paymentMethodCode: '',
|
|
2935
|
-
amount: ((_this$store$
|
|
3019
|
+
amount: ((_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.total_amount) || '0',
|
|
2936
3020
|
timestamp: data.timestamp
|
|
2937
3021
|
});
|
|
2938
3022
|
case 5:
|
|
2939
3023
|
case "end":
|
|
2940
|
-
return
|
|
3024
|
+
return _context40.stop();
|
|
2941
3025
|
}
|
|
2942
|
-
},
|
|
3026
|
+
}, _callee40, this);
|
|
2943
3027
|
}));
|
|
2944
|
-
function handlePaymentError(
|
|
3028
|
+
function handlePaymentError(_x29) {
|
|
2945
3029
|
return _handlePaymentError.apply(this, arguments);
|
|
2946
3030
|
}
|
|
2947
3031
|
return handlePaymentError;
|
|
@@ -2953,18 +3037,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2953
3037
|
}, {
|
|
2954
3038
|
key: "validateCheckoutParams",
|
|
2955
3039
|
value: (function () {
|
|
2956
|
-
var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2957
|
-
return _regeneratorRuntime().wrap(function
|
|
2958
|
-
while (1) switch (
|
|
3040
|
+
var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
3041
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3042
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
2959
3043
|
case 0:
|
|
2960
|
-
return
|
|
3044
|
+
return _context41.abrupt("return", validateCheckoutData(params));
|
|
2961
3045
|
case 1:
|
|
2962
3046
|
case "end":
|
|
2963
|
-
return
|
|
3047
|
+
return _context41.stop();
|
|
2964
3048
|
}
|
|
2965
|
-
},
|
|
3049
|
+
}, _callee41);
|
|
2966
3050
|
}));
|
|
2967
|
-
function validateCheckoutParams(
|
|
3051
|
+
function validateCheckoutParams(_x30) {
|
|
2968
3052
|
return _validateCheckoutParams.apply(this, arguments);
|
|
2969
3053
|
}
|
|
2970
3054
|
return validateCheckoutParams;
|
|
@@ -2976,10 +3060,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2976
3060
|
}, {
|
|
2977
3061
|
key: "validateLocalOrderData",
|
|
2978
3062
|
value: (function () {
|
|
2979
|
-
var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3063
|
+
var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(orderData) {
|
|
3064
|
+
var _orderData$relation_p;
|
|
2980
3065
|
var errors;
|
|
2981
|
-
return _regeneratorRuntime().wrap(function
|
|
2982
|
-
while (1) switch (
|
|
3066
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3067
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
2983
3068
|
case 0:
|
|
2984
3069
|
errors = []; // 验证基本字段
|
|
2985
3070
|
if (!orderData.type) {
|
|
@@ -2988,7 +3073,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2988
3073
|
if (!orderData.platform) {
|
|
2989
3074
|
errors.push('平台信息不能为空');
|
|
2990
3075
|
}
|
|
2991
|
-
if (!orderData.bookings || orderData.bookings.length === 0) {
|
|
3076
|
+
if ((!orderData.bookings || orderData.bookings.length === 0) && !(orderData !== null && orderData !== void 0 && (_orderData$relation_p = orderData.relation_products) !== null && _orderData$relation_p !== void 0 && _orderData$relation_p.length)) {
|
|
2992
3077
|
errors.push('预订信息不能为空');
|
|
2993
3078
|
}
|
|
2994
3079
|
|
|
@@ -3006,17 +3091,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3006
3091
|
}
|
|
3007
3092
|
});
|
|
3008
3093
|
}
|
|
3009
|
-
return
|
|
3094
|
+
return _context42.abrupt("return", {
|
|
3010
3095
|
valid: errors.length === 0,
|
|
3011
3096
|
errors: errors
|
|
3012
3097
|
});
|
|
3013
3098
|
case 6:
|
|
3014
3099
|
case "end":
|
|
3015
|
-
return
|
|
3100
|
+
return _context42.stop();
|
|
3016
3101
|
}
|
|
3017
|
-
},
|
|
3102
|
+
}, _callee42);
|
|
3018
3103
|
}));
|
|
3019
|
-
function validateLocalOrderData(
|
|
3104
|
+
function validateLocalOrderData(_x31) {
|
|
3020
3105
|
return _validateLocalOrderData.apply(this, arguments);
|
|
3021
3106
|
}
|
|
3022
3107
|
return validateLocalOrderData;
|
|
@@ -3035,7 +3120,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3035
3120
|
|
|
3036
3121
|
/**
|
|
3037
3122
|
* 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
|
|
3038
|
-
*
|
|
3123
|
+
*
|
|
3039
3124
|
* @param date 要格式化的日期对象
|
|
3040
3125
|
* @returns 格式化后的日期时间字符串
|
|
3041
3126
|
*/
|
|
@@ -3114,31 +3199,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3114
3199
|
}, {
|
|
3115
3200
|
key: "preloadPaymentMethods",
|
|
3116
3201
|
value: (function () {
|
|
3117
|
-
var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3202
|
+
var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
3118
3203
|
var methods;
|
|
3119
|
-
return _regeneratorRuntime().wrap(function
|
|
3120
|
-
while (1) switch (
|
|
3204
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3205
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3121
3206
|
case 0:
|
|
3122
|
-
|
|
3207
|
+
_context43.prev = 0;
|
|
3123
3208
|
console.log('[Checkout] 预加载支付方式...');
|
|
3124
|
-
|
|
3209
|
+
_context43.next = 4;
|
|
3125
3210
|
return this.payment.getPayMethodListAsync();
|
|
3126
3211
|
case 4:
|
|
3127
|
-
methods =
|
|
3212
|
+
methods = _context43.sent;
|
|
3128
3213
|
this.store.paymentMethods = methods;
|
|
3129
3214
|
console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
|
|
3130
|
-
|
|
3215
|
+
_context43.next = 13;
|
|
3131
3216
|
break;
|
|
3132
3217
|
case 9:
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
console.error('[Checkout] 预加载支付方式失败:',
|
|
3218
|
+
_context43.prev = 9;
|
|
3219
|
+
_context43.t0 = _context43["catch"](0);
|
|
3220
|
+
console.error('[Checkout] 预加载支付方式失败:', _context43.t0);
|
|
3136
3221
|
this.store.paymentMethods = [];
|
|
3137
3222
|
case 13:
|
|
3138
3223
|
case "end":
|
|
3139
|
-
return
|
|
3224
|
+
return _context43.stop();
|
|
3140
3225
|
}
|
|
3141
|
-
},
|
|
3226
|
+
}, _callee43, this, [[0, 9]]);
|
|
3142
3227
|
}));
|
|
3143
3228
|
function preloadPaymentMethods() {
|
|
3144
3229
|
return _preloadPaymentMethods.apply(this, arguments);
|
|
@@ -3166,24 +3251,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3166
3251
|
}, {
|
|
3167
3252
|
key: "calculatePaidAmountAsync",
|
|
3168
3253
|
value: (function () {
|
|
3169
|
-
var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3254
|
+
var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3170
3255
|
var payments, paidAmount, result;
|
|
3171
|
-
return _regeneratorRuntime().wrap(function
|
|
3172
|
-
while (1) switch (
|
|
3256
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3257
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3173
3258
|
case 0:
|
|
3174
3259
|
if (this.store.currentOrder) {
|
|
3175
|
-
|
|
3260
|
+
_context44.next = 3;
|
|
3176
3261
|
break;
|
|
3177
3262
|
}
|
|
3178
3263
|
console.log('[Checkout] calculatePaidAmountAsync: 没有当前订单');
|
|
3179
|
-
return
|
|
3264
|
+
return _context44.abrupt("return", '0.00');
|
|
3180
3265
|
case 3:
|
|
3181
|
-
|
|
3182
|
-
|
|
3266
|
+
_context44.prev = 3;
|
|
3267
|
+
_context44.next = 6;
|
|
3183
3268
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3184
3269
|
);
|
|
3185
3270
|
case 6:
|
|
3186
|
-
payments =
|
|
3271
|
+
payments = _context44.sent;
|
|
3187
3272
|
console.log('[Checkout] calculatePaidAmountAsync: 支付项详情:', {
|
|
3188
3273
|
paymentCount: payments.length,
|
|
3189
3274
|
payments: payments.map(function (p) {
|
|
@@ -3205,17 +3290,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3205
3290
|
}, 0);
|
|
3206
3291
|
result = paidAmount.toFixed(2);
|
|
3207
3292
|
console.log('[Checkout] calculatePaidAmountAsync: 计算结果 =', result);
|
|
3208
|
-
return
|
|
3293
|
+
return _context44.abrupt("return", result);
|
|
3209
3294
|
case 14:
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
console.error('[Checkout] calculatePaidAmountAsync 失败:',
|
|
3213
|
-
return
|
|
3295
|
+
_context44.prev = 14;
|
|
3296
|
+
_context44.t0 = _context44["catch"](3);
|
|
3297
|
+
console.error('[Checkout] calculatePaidAmountAsync 失败:', _context44.t0);
|
|
3298
|
+
return _context44.abrupt("return", '0.00');
|
|
3214
3299
|
case 18:
|
|
3215
3300
|
case "end":
|
|
3216
|
-
return
|
|
3301
|
+
return _context44.stop();
|
|
3217
3302
|
}
|
|
3218
|
-
},
|
|
3303
|
+
}, _callee44, this, [[3, 14]]);
|
|
3219
3304
|
}));
|
|
3220
3305
|
function calculatePaidAmountAsync() {
|
|
3221
3306
|
return _calculatePaidAmountAsync.apply(this, arguments);
|
|
@@ -3229,25 +3314,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3229
3314
|
}, {
|
|
3230
3315
|
key: "calculateRemainingAmountAsync",
|
|
3231
3316
|
value: (function () {
|
|
3232
|
-
var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3317
|
+
var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
3233
3318
|
var totalAmount, paidAmount, remainingAmount, result;
|
|
3234
|
-
return _regeneratorRuntime().wrap(function
|
|
3235
|
-
while (1) switch (
|
|
3319
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3320
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
3236
3321
|
case 0:
|
|
3237
3322
|
if (this.store.currentOrder) {
|
|
3238
|
-
|
|
3323
|
+
_context45.next = 3;
|
|
3239
3324
|
break;
|
|
3240
3325
|
}
|
|
3241
3326
|
console.log('[Checkout] calculateRemainingAmountAsync: 没有当前订单');
|
|
3242
|
-
return
|
|
3327
|
+
return _context45.abrupt("return", '0.00');
|
|
3243
3328
|
case 3:
|
|
3244
3329
|
totalAmount = parseFloat(this.store.currentOrder.total_amount || '0');
|
|
3245
|
-
|
|
3246
|
-
|
|
3330
|
+
_context45.t0 = parseFloat;
|
|
3331
|
+
_context45.next = 7;
|
|
3247
3332
|
return this.calculatePaidAmountAsync();
|
|
3248
3333
|
case 7:
|
|
3249
|
-
|
|
3250
|
-
paidAmount = (0,
|
|
3334
|
+
_context45.t1 = _context45.sent;
|
|
3335
|
+
paidAmount = (0, _context45.t0)(_context45.t1);
|
|
3251
3336
|
remainingAmount = totalAmount - paidAmount;
|
|
3252
3337
|
result = Math.max(0, remainingAmount).toFixed(2);
|
|
3253
3338
|
console.log('[Checkout] calculateRemainingAmountAsync: 计算详情:', {
|
|
@@ -3257,12 +3342,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3257
3342
|
calculatedRemaining: remainingAmount.toFixed(2),
|
|
3258
3343
|
finalResult: result
|
|
3259
3344
|
});
|
|
3260
|
-
return
|
|
3345
|
+
return _context45.abrupt("return", result);
|
|
3261
3346
|
case 13:
|
|
3262
3347
|
case "end":
|
|
3263
|
-
return
|
|
3348
|
+
return _context45.stop();
|
|
3264
3349
|
}
|
|
3265
|
-
},
|
|
3350
|
+
}, _callee45, this);
|
|
3266
3351
|
}));
|
|
3267
3352
|
function calculateRemainingAmountAsync() {
|
|
3268
3353
|
return _calculateRemainingAmountAsync.apply(this, arguments);
|
|
@@ -3276,33 +3361,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3276
3361
|
}, {
|
|
3277
3362
|
key: "updateStateAmountToRemaining",
|
|
3278
3363
|
value: (function () {
|
|
3279
|
-
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3280
|
-
var _this$store$
|
|
3281
|
-
return _regeneratorRuntime().wrap(function
|
|
3282
|
-
while (1) switch (
|
|
3364
|
+
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3365
|
+
var _this$store$currentOr17, remainingAmount, currentStateAmount;
|
|
3366
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3367
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
3283
3368
|
case 0:
|
|
3284
|
-
|
|
3285
|
-
|
|
3369
|
+
_context46.prev = 0;
|
|
3370
|
+
_context46.next = 3;
|
|
3286
3371
|
return this.calculateRemainingAmountAsync();
|
|
3287
3372
|
case 3:
|
|
3288
|
-
remainingAmount =
|
|
3373
|
+
remainingAmount = _context46.sent;
|
|
3289
3374
|
currentStateAmount = this.store.stateAmount;
|
|
3290
3375
|
console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
|
|
3291
3376
|
calculatedRemainingAmount: remainingAmount,
|
|
3292
3377
|
currentStateAmount: currentStateAmount,
|
|
3293
3378
|
needsUpdate: remainingAmount !== currentStateAmount,
|
|
3294
|
-
orderUuid: (_this$store$
|
|
3379
|
+
orderUuid: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.uuid
|
|
3295
3380
|
});
|
|
3296
3381
|
|
|
3297
3382
|
// 只有当剩余金额与当前 stateAmount 不同时才更新
|
|
3298
3383
|
if (!(remainingAmount !== currentStateAmount)) {
|
|
3299
|
-
|
|
3384
|
+
_context46.next = 13;
|
|
3300
3385
|
break;
|
|
3301
3386
|
}
|
|
3302
3387
|
this.store.stateAmount = remainingAmount;
|
|
3303
3388
|
|
|
3304
3389
|
// 发出 stateAmount 变更事件
|
|
3305
|
-
|
|
3390
|
+
_context46.next = 10;
|
|
3306
3391
|
return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
|
|
3307
3392
|
oldAmount: currentStateAmount,
|
|
3308
3393
|
newAmount: remainingAmount,
|
|
@@ -3313,7 +3398,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3313
3398
|
oldAmount: currentStateAmount,
|
|
3314
3399
|
newAmount: remainingAmount
|
|
3315
3400
|
});
|
|
3316
|
-
|
|
3401
|
+
_context46.next = 14;
|
|
3317
3402
|
break;
|
|
3318
3403
|
case 13:
|
|
3319
3404
|
console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
|
|
@@ -3321,20 +3406,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3321
3406
|
remainingAmount: remainingAmount
|
|
3322
3407
|
});
|
|
3323
3408
|
case 14:
|
|
3324
|
-
|
|
3409
|
+
_context46.next = 16;
|
|
3325
3410
|
return this.checkOrderPaymentCompletion();
|
|
3326
3411
|
case 16:
|
|
3327
|
-
|
|
3412
|
+
_context46.next = 21;
|
|
3328
3413
|
break;
|
|
3329
3414
|
case 18:
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
console.error('[Checkout] 更新 stateAmount 为剩余金额失败:',
|
|
3415
|
+
_context46.prev = 18;
|
|
3416
|
+
_context46.t0 = _context46["catch"](0);
|
|
3417
|
+
console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context46.t0);
|
|
3333
3418
|
case 21:
|
|
3334
3419
|
case "end":
|
|
3335
|
-
return
|
|
3420
|
+
return _context46.stop();
|
|
3336
3421
|
}
|
|
3337
|
-
},
|
|
3422
|
+
}, _callee46, this, [[0, 18]]);
|
|
3338
3423
|
}));
|
|
3339
3424
|
function updateStateAmountToRemaining() {
|
|
3340
3425
|
return _updateStateAmountToRemaining.apply(this, arguments);
|
|
@@ -3343,39 +3428,39 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3343
3428
|
}()
|
|
3344
3429
|
/**
|
|
3345
3430
|
* 检查订单支付是否完成
|
|
3346
|
-
*
|
|
3431
|
+
*
|
|
3347
3432
|
* 当剩余待付款金额 <= 0 时,触发订单支付完成事件
|
|
3348
3433
|
*/
|
|
3349
3434
|
)
|
|
3350
3435
|
}, {
|
|
3351
3436
|
key: "checkOrderPaymentCompletion",
|
|
3352
3437
|
value: (function () {
|
|
3353
|
-
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3438
|
+
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3354
3439
|
var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, allPaymentsHaveVoucherId;
|
|
3355
|
-
return _regeneratorRuntime().wrap(function
|
|
3356
|
-
while (1) switch (
|
|
3440
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3441
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
3357
3442
|
case 0:
|
|
3358
|
-
|
|
3443
|
+
_context47.prev = 0;
|
|
3359
3444
|
if (this.store.currentOrder) {
|
|
3360
|
-
|
|
3445
|
+
_context47.next = 3;
|
|
3361
3446
|
break;
|
|
3362
3447
|
}
|
|
3363
|
-
return
|
|
3448
|
+
return _context47.abrupt("return");
|
|
3364
3449
|
case 3:
|
|
3365
|
-
|
|
3450
|
+
_context47.next = 5;
|
|
3366
3451
|
return this.calculateRemainingAmountAsync();
|
|
3367
3452
|
case 5:
|
|
3368
|
-
remainingAmount =
|
|
3453
|
+
remainingAmount = _context47.sent;
|
|
3369
3454
|
remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
|
|
3370
3455
|
if (!(remainingValue <= 0)) {
|
|
3371
|
-
|
|
3456
|
+
_context47.next = 27;
|
|
3372
3457
|
break;
|
|
3373
3458
|
}
|
|
3374
3459
|
totalAmount = this.store.currentOrder.total_amount;
|
|
3375
|
-
|
|
3460
|
+
_context47.next = 11;
|
|
3376
3461
|
return this.calculatePaidAmountAsync();
|
|
3377
3462
|
case 11:
|
|
3378
|
-
paidAmount =
|
|
3463
|
+
paidAmount = _context47.sent;
|
|
3379
3464
|
console.log('[Checkout] 检测到订单支付完成:', {
|
|
3380
3465
|
orderUuid: this.store.currentOrder.uuid,
|
|
3381
3466
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3386,11 +3471,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3386
3471
|
});
|
|
3387
3472
|
|
|
3388
3473
|
// 从 Payment 模块获取最新支付项,检查是否所有支付项都带有 voucher_id
|
|
3389
|
-
|
|
3474
|
+
_context47.next = 15;
|
|
3390
3475
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3391
3476
|
);
|
|
3392
3477
|
case 15:
|
|
3393
|
-
currentPayments =
|
|
3478
|
+
currentPayments = _context47.sent;
|
|
3394
3479
|
allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(function (item) {
|
|
3395
3480
|
return item.status !== 'voided' && item.voucher_id;
|
|
3396
3481
|
});
|
|
@@ -3418,18 +3503,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3418
3503
|
// }
|
|
3419
3504
|
// }
|
|
3420
3505
|
if (!allPaymentsHaveVoucherId) {
|
|
3421
|
-
|
|
3506
|
+
_context47.next = 22;
|
|
3422
3507
|
break;
|
|
3423
3508
|
}
|
|
3424
3509
|
console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
|
|
3425
|
-
|
|
3510
|
+
_context47.next = 25;
|
|
3426
3511
|
break;
|
|
3427
3512
|
case 22:
|
|
3428
3513
|
console.log('[Checkout] 支付完成但订单未同步,开始同步订单到后端...');
|
|
3429
|
-
|
|
3514
|
+
_context47.next = 25;
|
|
3430
3515
|
return this.syncOrderToBackend();
|
|
3431
3516
|
case 25:
|
|
3432
|
-
|
|
3517
|
+
_context47.next = 27;
|
|
3433
3518
|
return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
|
|
3434
3519
|
orderUuid: this.store.currentOrder.uuid,
|
|
3435
3520
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3439,17 +3524,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3439
3524
|
timestamp: Date.now()
|
|
3440
3525
|
});
|
|
3441
3526
|
case 27:
|
|
3442
|
-
|
|
3527
|
+
_context47.next = 32;
|
|
3443
3528
|
break;
|
|
3444
3529
|
case 29:
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
console.error('[Checkout] 检查订单支付完成状态失败:',
|
|
3530
|
+
_context47.prev = 29;
|
|
3531
|
+
_context47.t0 = _context47["catch"](0);
|
|
3532
|
+
console.error('[Checkout] 检查订单支付完成状态失败:', _context47.t0);
|
|
3448
3533
|
case 32:
|
|
3449
3534
|
case "end":
|
|
3450
|
-
return
|
|
3535
|
+
return _context47.stop();
|
|
3451
3536
|
}
|
|
3452
|
-
},
|
|
3537
|
+
}, _callee47, this, [[0, 29]]);
|
|
3453
3538
|
}));
|
|
3454
3539
|
function checkOrderPaymentCompletion() {
|
|
3455
3540
|
return _checkOrderPaymentCompletion.apply(this, arguments);
|
|
@@ -3458,11 +3543,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3458
3543
|
}()
|
|
3459
3544
|
/**
|
|
3460
3545
|
* 判断支付方式是否需要同步订单到后端
|
|
3461
|
-
*
|
|
3546
|
+
*
|
|
3462
3547
|
* 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
|
|
3463
|
-
*
|
|
3548
|
+
*
|
|
3464
3549
|
* @param paymentCode 支付方式代码
|
|
3465
|
-
* @param paymentType 支付方式类型
|
|
3550
|
+
* @param paymentType 支付方式类型
|
|
3466
3551
|
* @returns 是否需要同步订单
|
|
3467
3552
|
*/
|
|
3468
3553
|
)
|
|
@@ -3496,12 +3581,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3496
3581
|
|
|
3497
3582
|
/**
|
|
3498
3583
|
* 同步订单到后端
|
|
3499
|
-
*
|
|
3584
|
+
*
|
|
3500
3585
|
* 调用后端 /order/checkout 接口创建真实订单
|
|
3501
3586
|
*/
|
|
3502
3587
|
/**
|
|
3503
3588
|
* 判断订单ID是否为本地生成的虚拟ID
|
|
3504
|
-
*
|
|
3589
|
+
*
|
|
3505
3590
|
* @param orderId 订单ID
|
|
3506
3591
|
* @returns true 表示是虚拟ID,false 表示是真实的后端ID
|
|
3507
3592
|
*/
|
|
@@ -3513,7 +3598,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3513
3598
|
|
|
3514
3599
|
/**
|
|
3515
3600
|
* 同步订单到后端并返回真实订单ID
|
|
3516
|
-
*
|
|
3601
|
+
*
|
|
3517
3602
|
* @param isManual 是否为手动同步,默认为 false
|
|
3518
3603
|
* @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
|
|
3519
3604
|
* @returns 后端返回的真实订单ID
|
|
@@ -3521,8 +3606,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3521
3606
|
}, {
|
|
3522
3607
|
key: "syncOrderToBackendWithReturn",
|
|
3523
3608
|
value: (function () {
|
|
3524
|
-
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3525
|
-
var _this$store$currentCu2, _this$store$
|
|
3609
|
+
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
3610
|
+
var _this$store$currentCu2, _this$store$currentOr18, _this$store$currentOr19;
|
|
3526
3611
|
var isManual,
|
|
3527
3612
|
customPaymentItems,
|
|
3528
3613
|
syncType,
|
|
@@ -3541,14 +3626,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3541
3626
|
beforeManualUpdate,
|
|
3542
3627
|
finalOrderId,
|
|
3543
3628
|
finalIsVirtual,
|
|
3544
|
-
|
|
3545
|
-
return _regeneratorRuntime().wrap(function
|
|
3546
|
-
while (1) switch (
|
|
3629
|
+
_args48 = arguments;
|
|
3630
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
3631
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
3547
3632
|
case 0:
|
|
3548
|
-
isManual =
|
|
3549
|
-
customPaymentItems =
|
|
3633
|
+
isManual = _args48.length > 0 && _args48[0] !== undefined ? _args48[0] : false;
|
|
3634
|
+
customPaymentItems = _args48.length > 1 ? _args48[1] : undefined;
|
|
3550
3635
|
if (!(!this.store.localOrderData || !this.store.currentOrder)) {
|
|
3551
|
-
|
|
3636
|
+
_context48.next = 4;
|
|
3552
3637
|
break;
|
|
3553
3638
|
}
|
|
3554
3639
|
throw new Error('缺少必要的订单数据,无法同步到后端');
|
|
@@ -3589,17 +3674,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3589
3674
|
});
|
|
3590
3675
|
|
|
3591
3676
|
// 获取当前订单的支付项
|
|
3592
|
-
|
|
3593
|
-
if (
|
|
3594
|
-
|
|
3677
|
+
_context48.t0 = customPaymentItems;
|
|
3678
|
+
if (_context48.t0) {
|
|
3679
|
+
_context48.next = 18;
|
|
3595
3680
|
break;
|
|
3596
3681
|
}
|
|
3597
|
-
|
|
3682
|
+
_context48.next = 17;
|
|
3598
3683
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
3599
3684
|
case 17:
|
|
3600
|
-
|
|
3685
|
+
_context48.t0 = _context48.sent;
|
|
3601
3686
|
case 18:
|
|
3602
|
-
paymentItems =
|
|
3687
|
+
paymentItems = _context48.t0;
|
|
3603
3688
|
console.log('[Checkout] 获取到支付项:', {
|
|
3604
3689
|
count: paymentItems.length,
|
|
3605
3690
|
isCustomFiltered: !!customPaymentItems,
|
|
@@ -3640,12 +3725,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3640
3725
|
currency_code: this.otherParams.currency_code,
|
|
3641
3726
|
currency_symbol: this.otherParams.currency_symbol,
|
|
3642
3727
|
currency_format: this.otherParams.currency_format,
|
|
3643
|
-
is_deposit: ((_this$store$
|
|
3644
|
-
deposit_amount: ((_this$store$
|
|
3728
|
+
is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0,
|
|
3729
|
+
deposit_amount: ((_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.deposit_amount) || '0.00',
|
|
3645
3730
|
// surcharge_fee: this.otherParams.surcharge_fee,
|
|
3646
3731
|
// surcharges: ,
|
|
3647
3732
|
note: this.store.localOrderData.shop_note
|
|
3648
|
-
// deposit_amount:
|
|
3733
|
+
// deposit_amount:
|
|
3649
3734
|
}); // 如果是更新操作,需要在参数中包含真实的订单ID
|
|
3650
3735
|
|
|
3651
3736
|
if (isUpdateOperation) {
|
|
@@ -3671,10 +3756,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3671
3756
|
}
|
|
3672
3757
|
|
|
3673
3758
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
3674
|
-
|
|
3759
|
+
_context48.next = 24;
|
|
3675
3760
|
return this.order.createOrderByCheckout(orderParams);
|
|
3676
3761
|
case 24:
|
|
3677
|
-
checkoutResponse =
|
|
3762
|
+
checkoutResponse = _context48.sent;
|
|
3678
3763
|
console.log('[Checkout] 后端返回的响应数据:', {
|
|
3679
3764
|
status: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.status,
|
|
3680
3765
|
code: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.code,
|
|
@@ -3682,13 +3767,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3682
3767
|
data: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.data
|
|
3683
3768
|
});
|
|
3684
3769
|
if (!isUpdateOperation) {
|
|
3685
|
-
|
|
3770
|
+
_context48.next = 31;
|
|
3686
3771
|
break;
|
|
3687
3772
|
}
|
|
3688
3773
|
// 更新操作:使用现有的订单ID
|
|
3689
3774
|
realOrderId = currentOrderId;
|
|
3690
3775
|
console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
|
|
3691
|
-
|
|
3776
|
+
_context48.next = 52;
|
|
3692
3777
|
break;
|
|
3693
3778
|
case 31:
|
|
3694
3779
|
// 创建操作:从响应中提取新的订单ID
|
|
@@ -3702,7 +3787,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3702
3787
|
extractedOrderId = String(extractedOrderId);
|
|
3703
3788
|
}
|
|
3704
3789
|
if (extractedOrderId) {
|
|
3705
|
-
|
|
3790
|
+
_context48.next = 36;
|
|
3706
3791
|
break;
|
|
3707
3792
|
}
|
|
3708
3793
|
throw new Error('后端返回的订单信息中未包含订单ID');
|
|
@@ -3716,11 +3801,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3716
3801
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3717
3802
|
newOrderId: realOrderId
|
|
3718
3803
|
});
|
|
3719
|
-
|
|
3720
|
-
|
|
3804
|
+
_context48.prev = 39;
|
|
3805
|
+
_context48.next = 42;
|
|
3721
3806
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3722
3807
|
case 42:
|
|
3723
|
-
updatedOrder =
|
|
3808
|
+
updatedOrder = _context48.sent;
|
|
3724
3809
|
console.log('[Checkout] Payment模块替换订单ID结果:', {
|
|
3725
3810
|
wasSuccessful: !!updatedOrder,
|
|
3726
3811
|
returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
|
|
@@ -3746,12 +3831,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3746
3831
|
目标ID: realOrderId
|
|
3747
3832
|
});
|
|
3748
3833
|
}
|
|
3749
|
-
|
|
3834
|
+
_context48.next = 52;
|
|
3750
3835
|
break;
|
|
3751
3836
|
case 47:
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:',
|
|
3837
|
+
_context48.prev = 47;
|
|
3838
|
+
_context48.t1 = _context48["catch"](39);
|
|
3839
|
+
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context48.t1);
|
|
3755
3840
|
|
|
3756
3841
|
// 发生错误时也进行手动替换
|
|
3757
3842
|
this.store.currentOrder.order_id = realOrderId;
|
|
@@ -3761,7 +3846,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3761
3846
|
this.store.isOrderSynced = true;
|
|
3762
3847
|
|
|
3763
3848
|
// 触发订单同步完成事件
|
|
3764
|
-
|
|
3849
|
+
_context48.next = 55;
|
|
3765
3850
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
3766
3851
|
orderUuid: this.store.currentOrder.uuid,
|
|
3767
3852
|
realOrderId: realOrderId,
|
|
@@ -3787,12 +3872,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3787
3872
|
}
|
|
3788
3873
|
|
|
3789
3874
|
// 返回真实订单ID
|
|
3790
|
-
return
|
|
3875
|
+
return _context48.abrupt("return", realOrderId);
|
|
3791
3876
|
case 60:
|
|
3792
3877
|
case "end":
|
|
3793
|
-
return
|
|
3878
|
+
return _context48.stop();
|
|
3794
3879
|
}
|
|
3795
|
-
},
|
|
3880
|
+
}, _callee48, this, [[39, 47]]);
|
|
3796
3881
|
}));
|
|
3797
3882
|
function syncOrderToBackendWithReturn() {
|
|
3798
3883
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -3802,27 +3887,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3802
3887
|
}, {
|
|
3803
3888
|
key: "syncOrderToBackend",
|
|
3804
3889
|
value: function () {
|
|
3805
|
-
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3806
|
-
return _regeneratorRuntime().wrap(function
|
|
3807
|
-
while (1) switch (
|
|
3890
|
+
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
3891
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
3892
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
3808
3893
|
case 0:
|
|
3809
|
-
|
|
3810
|
-
|
|
3894
|
+
_context49.prev = 0;
|
|
3895
|
+
_context49.next = 3;
|
|
3811
3896
|
return this.syncOrderToBackendWithReturn(false);
|
|
3812
3897
|
case 3:
|
|
3813
|
-
|
|
3898
|
+
_context49.next = 10;
|
|
3814
3899
|
break;
|
|
3815
3900
|
case 5:
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
console.error('[Checkout] 同步订单到后端失败:',
|
|
3819
|
-
|
|
3820
|
-
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(
|
|
3901
|
+
_context49.prev = 5;
|
|
3902
|
+
_context49.t0 = _context49["catch"](0);
|
|
3903
|
+
console.error('[Checkout] 同步订单到后端失败:', _context49.t0);
|
|
3904
|
+
_context49.next = 10;
|
|
3905
|
+
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
3821
3906
|
case 10:
|
|
3822
3907
|
case "end":
|
|
3823
|
-
return
|
|
3908
|
+
return _context49.stop();
|
|
3824
3909
|
}
|
|
3825
|
-
},
|
|
3910
|
+
}, _callee49, this, [[0, 5]]);
|
|
3826
3911
|
}));
|
|
3827
3912
|
function syncOrderToBackend() {
|
|
3828
3913
|
return _syncOrderToBackend.apply(this, arguments);
|
|
@@ -3862,15 +3947,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3862
3947
|
}, {
|
|
3863
3948
|
key: "setOtherParams",
|
|
3864
3949
|
value: function () {
|
|
3865
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3866
|
-
var
|
|
3867
|
-
|
|
3950
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
3951
|
+
var _ref5,
|
|
3952
|
+
_ref5$cover,
|
|
3868
3953
|
cover,
|
|
3869
|
-
|
|
3870
|
-
return _regeneratorRuntime().wrap(function
|
|
3871
|
-
while (1) switch (
|
|
3954
|
+
_args50 = arguments;
|
|
3955
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
3956
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
3872
3957
|
case 0:
|
|
3873
|
-
|
|
3958
|
+
_ref5 = _args50.length > 1 && _args50[1] !== undefined ? _args50[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
3874
3959
|
if (cover) {
|
|
3875
3960
|
this.otherParams = params;
|
|
3876
3961
|
} else {
|
|
@@ -3878,20 +3963,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3878
3963
|
}
|
|
3879
3964
|
case 2:
|
|
3880
3965
|
case "end":
|
|
3881
|
-
return
|
|
3966
|
+
return _context50.stop();
|
|
3882
3967
|
}
|
|
3883
|
-
},
|
|
3968
|
+
}, _callee50, this);
|
|
3884
3969
|
}));
|
|
3885
|
-
function setOtherParams(
|
|
3970
|
+
function setOtherParams(_x32) {
|
|
3886
3971
|
return _setOtherParams.apply(this, arguments);
|
|
3887
3972
|
}
|
|
3888
3973
|
return setOtherParams;
|
|
3889
3974
|
}()
|
|
3890
3975
|
/**
|
|
3891
3976
|
* 通过订单ID编辑订单备注
|
|
3892
|
-
*
|
|
3977
|
+
*
|
|
3893
3978
|
* 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
|
|
3894
|
-
*
|
|
3979
|
+
*
|
|
3895
3980
|
* @param orderId 后端订单ID
|
|
3896
3981
|
* @param note 新的订单备注
|
|
3897
3982
|
* @returns 修改结果
|
|
@@ -3899,12 +3984,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3899
3984
|
}, {
|
|
3900
3985
|
key: "editOrderNoteByOrderIdAsync",
|
|
3901
3986
|
value: (function () {
|
|
3902
|
-
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3987
|
+
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(orderId, note) {
|
|
3903
3988
|
var response, previousNote, errorMessage, _errorMessage;
|
|
3904
|
-
return _regeneratorRuntime().wrap(function
|
|
3905
|
-
while (1) switch (
|
|
3989
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
3990
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
3906
3991
|
case 0:
|
|
3907
|
-
|
|
3992
|
+
_context51.prev = 0;
|
|
3908
3993
|
console.log('[Checkout] 开始编辑订单备注:', {
|
|
3909
3994
|
orderId: orderId,
|
|
3910
3995
|
note: note,
|
|
@@ -3913,21 +3998,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3913
3998
|
|
|
3914
3999
|
// 参数验证
|
|
3915
4000
|
if (orderId) {
|
|
3916
|
-
|
|
4001
|
+
_context51.next = 4;
|
|
3917
4002
|
break;
|
|
3918
4003
|
}
|
|
3919
|
-
return
|
|
4004
|
+
return _context51.abrupt("return", {
|
|
3920
4005
|
success: false,
|
|
3921
4006
|
message: '订单ID不能为空',
|
|
3922
4007
|
orderId: orderId
|
|
3923
4008
|
});
|
|
3924
4009
|
case 4:
|
|
3925
|
-
|
|
4010
|
+
_context51.next = 6;
|
|
3926
4011
|
return this.request.put("/shop/order/order/".concat(orderId, "/note"), {
|
|
3927
4012
|
note: note
|
|
3928
4013
|
});
|
|
3929
4014
|
case 6:
|
|
3930
|
-
response =
|
|
4015
|
+
response = _context51.sent;
|
|
3931
4016
|
console.log('[Checkout] 订单备注编辑响应:', {
|
|
3932
4017
|
orderId: orderId,
|
|
3933
4018
|
status: response.status,
|
|
@@ -3937,14 +4022,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3937
4022
|
|
|
3938
4023
|
// 检查响应状态
|
|
3939
4024
|
if (!(response.status === true || response.status === 200)) {
|
|
3940
|
-
|
|
4025
|
+
_context51.next = 19;
|
|
3941
4026
|
break;
|
|
3942
4027
|
}
|
|
3943
4028
|
console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
|
|
3944
4029
|
|
|
3945
4030
|
// 如果当前订单就是被修改的订单,同时更新本地状态
|
|
3946
4031
|
if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
|
|
3947
|
-
|
|
4032
|
+
_context51.next = 16;
|
|
3948
4033
|
break;
|
|
3949
4034
|
}
|
|
3950
4035
|
console.log('[Checkout] 更新本地订单备注状态');
|
|
@@ -3956,7 +4041,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3956
4041
|
}
|
|
3957
4042
|
|
|
3958
4043
|
// 触发订单备注变更事件
|
|
3959
|
-
|
|
4044
|
+
_context51.next = 16;
|
|
3960
4045
|
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
3961
4046
|
orderUuid: this.store.currentOrder.uuid,
|
|
3962
4047
|
oldNote: previousNote,
|
|
@@ -3964,7 +4049,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3964
4049
|
timestamp: Date.now()
|
|
3965
4050
|
});
|
|
3966
4051
|
case 16:
|
|
3967
|
-
return
|
|
4052
|
+
return _context51.abrupt("return", {
|
|
3968
4053
|
success: true,
|
|
3969
4054
|
message: response.message || '订单备注修改成功',
|
|
3970
4055
|
orderId: orderId
|
|
@@ -3973,40 +4058,40 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3973
4058
|
// API返回失败状态
|
|
3974
4059
|
errorMessage = response.message || '订单备注修改失败';
|
|
3975
4060
|
console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
|
|
3976
|
-
return
|
|
4061
|
+
return _context51.abrupt("return", {
|
|
3977
4062
|
success: false,
|
|
3978
4063
|
message: errorMessage,
|
|
3979
4064
|
orderId: orderId
|
|
3980
4065
|
});
|
|
3981
4066
|
case 22:
|
|
3982
|
-
|
|
4067
|
+
_context51.next = 29;
|
|
3983
4068
|
break;
|
|
3984
4069
|
case 24:
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
console.error('[Checkout] 编辑订单备注失败:',
|
|
3988
|
-
_errorMessage =
|
|
3989
|
-
return
|
|
4070
|
+
_context51.prev = 24;
|
|
4071
|
+
_context51.t0 = _context51["catch"](0);
|
|
4072
|
+
console.error('[Checkout] 编辑订单备注失败:', _context51.t0);
|
|
4073
|
+
_errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : '网络错误或服务器异常';
|
|
4074
|
+
return _context51.abrupt("return", {
|
|
3990
4075
|
success: false,
|
|
3991
4076
|
message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
|
|
3992
4077
|
orderId: orderId
|
|
3993
4078
|
});
|
|
3994
4079
|
case 29:
|
|
3995
4080
|
case "end":
|
|
3996
|
-
return
|
|
4081
|
+
return _context51.stop();
|
|
3997
4082
|
}
|
|
3998
|
-
},
|
|
4083
|
+
}, _callee51, this, [[0, 24]]);
|
|
3999
4084
|
}));
|
|
4000
|
-
function editOrderNoteByOrderIdAsync(
|
|
4085
|
+
function editOrderNoteByOrderIdAsync(_x33, _x34) {
|
|
4001
4086
|
return _editOrderNoteByOrderIdAsync.apply(this, arguments);
|
|
4002
4087
|
}
|
|
4003
4088
|
return editOrderNoteByOrderIdAsync;
|
|
4004
4089
|
}()
|
|
4005
4090
|
/**
|
|
4006
4091
|
* 发送客户支付链接邮件
|
|
4007
|
-
*
|
|
4092
|
+
*
|
|
4008
4093
|
* 向指定邮箱发送订单支付提醒邮件
|
|
4009
|
-
*
|
|
4094
|
+
*
|
|
4010
4095
|
* @param params 发送参数
|
|
4011
4096
|
* @returns 发送结果
|
|
4012
4097
|
*/
|
|
@@ -4014,12 +4099,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4014
4099
|
}, {
|
|
4015
4100
|
key: "sendCustomerPayLinkAsync",
|
|
4016
4101
|
value: (function () {
|
|
4017
|
-
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4102
|
+
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4018
4103
|
var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
|
|
4019
|
-
return _regeneratorRuntime().wrap(function
|
|
4020
|
-
while (1) switch (
|
|
4104
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4105
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4021
4106
|
case 0:
|
|
4022
|
-
|
|
4107
|
+
_context52.prev = 0;
|
|
4023
4108
|
console.log('[Checkout] 开始发送客户支付链接邮件:', {
|
|
4024
4109
|
orderIds: params.order_ids,
|
|
4025
4110
|
emails: params.emails,
|
|
@@ -4028,19 +4113,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4028
4113
|
|
|
4029
4114
|
// 参数验证
|
|
4030
4115
|
if (!(!params.order_ids || params.order_ids.length === 0)) {
|
|
4031
|
-
|
|
4116
|
+
_context52.next = 4;
|
|
4032
4117
|
break;
|
|
4033
4118
|
}
|
|
4034
|
-
return
|
|
4119
|
+
return _context52.abrupt("return", {
|
|
4035
4120
|
success: false,
|
|
4036
4121
|
message: '订单ID列表不能为空'
|
|
4037
4122
|
});
|
|
4038
4123
|
case 4:
|
|
4039
4124
|
if (!(!params.emails || params.emails.length === 0)) {
|
|
4040
|
-
|
|
4125
|
+
_context52.next = 6;
|
|
4041
4126
|
break;
|
|
4042
4127
|
}
|
|
4043
|
-
return
|
|
4128
|
+
return _context52.abrupt("return", {
|
|
4044
4129
|
success: false,
|
|
4045
4130
|
message: '邮箱地址列表不能为空'
|
|
4046
4131
|
});
|
|
@@ -4051,10 +4136,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4051
4136
|
return !emailRegex.test(email);
|
|
4052
4137
|
});
|
|
4053
4138
|
if (!(invalidEmails.length > 0)) {
|
|
4054
|
-
|
|
4139
|
+
_context52.next = 10;
|
|
4055
4140
|
break;
|
|
4056
4141
|
}
|
|
4057
|
-
return
|
|
4142
|
+
return _context52.abrupt("return", {
|
|
4058
4143
|
success: false,
|
|
4059
4144
|
message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
|
|
4060
4145
|
});
|
|
@@ -4068,10 +4153,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4068
4153
|
console.log('[Checkout] 发送支付链接邮件请求参数:', requestBody);
|
|
4069
4154
|
|
|
4070
4155
|
// 调用后端API发送邮件
|
|
4071
|
-
|
|
4156
|
+
_context52.next = 14;
|
|
4072
4157
|
return this.request.post('/order/batch-email', requestBody);
|
|
4073
4158
|
case 14:
|
|
4074
|
-
response =
|
|
4159
|
+
response = _context52.sent;
|
|
4075
4160
|
console.log('[Checkout] 支付链接邮件发送响应:', {
|
|
4076
4161
|
status: response.status,
|
|
4077
4162
|
message: response.message,
|
|
@@ -4081,11 +4166,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4081
4166
|
|
|
4082
4167
|
// 检查响应状态
|
|
4083
4168
|
if (!(response.status === true || response.status === 200)) {
|
|
4084
|
-
|
|
4169
|
+
_context52.next = 21;
|
|
4085
4170
|
break;
|
|
4086
4171
|
}
|
|
4087
4172
|
console.log('[Checkout] 支付链接邮件发送成功');
|
|
4088
|
-
return
|
|
4173
|
+
return _context52.abrupt("return", {
|
|
4089
4174
|
success: true,
|
|
4090
4175
|
message: response.message || '支付链接邮件发送成功'
|
|
4091
4176
|
});
|
|
@@ -4093,36 +4178,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4093
4178
|
// API返回失败状态
|
|
4094
4179
|
errorMessage = response.message || '支付链接邮件发送失败';
|
|
4095
4180
|
console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
|
|
4096
|
-
return
|
|
4181
|
+
return _context52.abrupt("return", {
|
|
4097
4182
|
success: false,
|
|
4098
4183
|
message: errorMessage
|
|
4099
4184
|
});
|
|
4100
4185
|
case 24:
|
|
4101
|
-
|
|
4186
|
+
_context52.next = 31;
|
|
4102
4187
|
break;
|
|
4103
4188
|
case 26:
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
console.error('[Checkout] 发送客户支付链接邮件失败:',
|
|
4107
|
-
_errorMessage2 =
|
|
4108
|
-
return
|
|
4189
|
+
_context52.prev = 26;
|
|
4190
|
+
_context52.t0 = _context52["catch"](0);
|
|
4191
|
+
console.error('[Checkout] 发送客户支付链接邮件失败:', _context52.t0);
|
|
4192
|
+
_errorMessage2 = _context52.t0 instanceof Error ? _context52.t0.message : '网络错误或服务器异常';
|
|
4193
|
+
return _context52.abrupt("return", {
|
|
4109
4194
|
success: false,
|
|
4110
4195
|
message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
|
|
4111
4196
|
});
|
|
4112
4197
|
case 31:
|
|
4113
4198
|
case "end":
|
|
4114
|
-
return
|
|
4199
|
+
return _context52.stop();
|
|
4115
4200
|
}
|
|
4116
|
-
},
|
|
4201
|
+
}, _callee52, this, [[0, 26]]);
|
|
4117
4202
|
}));
|
|
4118
|
-
function sendCustomerPayLinkAsync(
|
|
4203
|
+
function sendCustomerPayLinkAsync(_x35) {
|
|
4119
4204
|
return _sendCustomerPayLinkAsync.apply(this, arguments);
|
|
4120
4205
|
}
|
|
4121
4206
|
return sendCustomerPayLinkAsync;
|
|
4122
4207
|
}()
|
|
4123
4208
|
/**
|
|
4124
4209
|
* 金额舍入
|
|
4125
|
-
*
|
|
4210
|
+
*
|
|
4126
4211
|
* @param amount 原始金额
|
|
4127
4212
|
* @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
|
|
4128
4213
|
*/
|
|
@@ -4130,25 +4215,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4130
4215
|
}, {
|
|
4131
4216
|
key: "roundAmountAsync",
|
|
4132
4217
|
value: (function () {
|
|
4133
|
-
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4218
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(amount) {
|
|
4134
4219
|
var _this$otherParams$ord, _this$otherParams$ord2;
|
|
4135
4220
|
var result;
|
|
4136
|
-
return _regeneratorRuntime().wrap(function
|
|
4137
|
-
while (1) switch (
|
|
4221
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
4222
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4138
4223
|
case 0:
|
|
4139
|
-
|
|
4224
|
+
_context53.next = 2;
|
|
4140
4225
|
return this.payment.roundAmountAsync(amount, (_this$otherParams$ord = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord === void 0 ? void 0 : _this$otherParams$ord.interval, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.type);
|
|
4141
4226
|
case 2:
|
|
4142
|
-
result =
|
|
4227
|
+
result = _context53.sent;
|
|
4143
4228
|
console.log("[Checkout] \u91D1\u989D\u820D\u5165\u5B8C\u6210 - \u539F\u59CB: ".concat(result.originalAmount, ", \u820D\u5165\u540E: ").concat(result.roundedAmount, ", \u5DEE\u989D: ").concat(result.roundingDifference));
|
|
4144
|
-
return
|
|
4229
|
+
return _context53.abrupt("return", result);
|
|
4145
4230
|
case 5:
|
|
4146
4231
|
case "end":
|
|
4147
|
-
return
|
|
4232
|
+
return _context53.stop();
|
|
4148
4233
|
}
|
|
4149
|
-
},
|
|
4234
|
+
}, _callee53, this);
|
|
4150
4235
|
}));
|
|
4151
|
-
function roundAmountAsync(
|
|
4236
|
+
function roundAmountAsync(_x36) {
|
|
4152
4237
|
return _roundAmountAsync.apply(this, arguments);
|
|
4153
4238
|
}
|
|
4154
4239
|
return roundAmountAsync;
|
|
@@ -4156,10 +4241,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4156
4241
|
}, {
|
|
4157
4242
|
key: "destroy",
|
|
4158
4243
|
value: function () {
|
|
4159
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4244
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
|
|
4160
4245
|
var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
|
|
4161
|
-
return _regeneratorRuntime().wrap(function
|
|
4162
|
-
while (1) switch (
|
|
4246
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
4247
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
4163
4248
|
case 0:
|
|
4164
4249
|
// 清理钱包模块的所有缓存数据
|
|
4165
4250
|
this.payment.wallet.clearAllCache();
|
|
@@ -4168,10 +4253,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4168
4253
|
this.core.effects.offByModuleDestroy(this.name);
|
|
4169
4254
|
|
|
4170
4255
|
// 销毁子模块
|
|
4171
|
-
|
|
4256
|
+
_context54.next = 4;
|
|
4172
4257
|
return (_this$order = this.order) === null || _this$order === void 0 || (_this$order$destroy = _this$order.destroy) === null || _this$order$destroy === void 0 ? void 0 : _this$order$destroy.call(_this$order);
|
|
4173
4258
|
case 4:
|
|
4174
|
-
|
|
4259
|
+
_context54.next = 6;
|
|
4175
4260
|
return (_this$payment = this.payment) === null || _this$payment === void 0 || (_this$payment$destroy = _this$payment.destroy) === null || _this$payment$destroy === void 0 ? void 0 : _this$payment$destroy.call(_this$payment);
|
|
4176
4261
|
case 6:
|
|
4177
4262
|
// 取消注册模块
|
|
@@ -4179,15 +4264,137 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4179
4264
|
console.log('[Checkout] 已销毁');
|
|
4180
4265
|
case 8:
|
|
4181
4266
|
case "end":
|
|
4182
|
-
return
|
|
4267
|
+
return _context54.stop();
|
|
4183
4268
|
}
|
|
4184
|
-
},
|
|
4269
|
+
}, _callee54, this);
|
|
4185
4270
|
}));
|
|
4186
4271
|
function destroy() {
|
|
4187
4272
|
return _destroy.apply(this, arguments);
|
|
4188
4273
|
}
|
|
4189
4274
|
return destroy;
|
|
4190
4275
|
}()
|
|
4276
|
+
/**
|
|
4277
|
+
* 重置 store 状态
|
|
4278
|
+
*
|
|
4279
|
+
* 在创建新订单前调用,确保状态完全干净
|
|
4280
|
+
*/
|
|
4281
|
+
}, {
|
|
4282
|
+
key: "resetStoreStateAsync",
|
|
4283
|
+
value: (function () {
|
|
4284
|
+
var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
|
|
4285
|
+
var prevOrderInfo;
|
|
4286
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
4287
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
4288
|
+
case 0:
|
|
4289
|
+
_context55.prev = 0;
|
|
4290
|
+
prevOrderInfo = this.store.currentOrder ? {
|
|
4291
|
+
uuid: this.store.currentOrder.uuid,
|
|
4292
|
+
orderId: this.store.currentOrder.order_id
|
|
4293
|
+
} : null;
|
|
4294
|
+
console.log('[Checkout] 重置 store 状态,准备创建新订单', prevOrderInfo);
|
|
4295
|
+
|
|
4296
|
+
// 重置订单相关的 store 状态(保留 paymentMethods,因为支付方式数据变更不频繁)
|
|
4297
|
+
this.store.currentOrder = undefined;
|
|
4298
|
+
this.store.localOrderData = undefined;
|
|
4299
|
+
this.store.cartSummary = undefined;
|
|
4300
|
+
this.store.stateAmount = '0.00';
|
|
4301
|
+
this.store.isOrderSynced = false;
|
|
4302
|
+
this.store.currentCustomer = undefined;
|
|
4303
|
+
this.store.lastError = undefined;
|
|
4304
|
+
|
|
4305
|
+
// 清空购物车项目
|
|
4306
|
+
this.store.cartItems = [];
|
|
4307
|
+
|
|
4308
|
+
// 清理钱包缓存
|
|
4309
|
+
this.payment.wallet.clearAllCache();
|
|
4310
|
+
|
|
4311
|
+
// 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
|
|
4312
|
+
|
|
4313
|
+
// 重置状态和步骤为初始状态
|
|
4314
|
+
_context55.next = 14;
|
|
4315
|
+
return this.setStatus(CheckoutStatus.Ready);
|
|
4316
|
+
case 14:
|
|
4317
|
+
_context55.next = 16;
|
|
4318
|
+
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
4319
|
+
case 16:
|
|
4320
|
+
console.log('[Checkout] Store 状态重置完成');
|
|
4321
|
+
|
|
4322
|
+
// 触发订单清理事件(如果之前有订单)
|
|
4323
|
+
if (!prevOrderInfo) {
|
|
4324
|
+
_context55.next = 20;
|
|
4325
|
+
break;
|
|
4326
|
+
}
|
|
4327
|
+
_context55.next = 20;
|
|
4328
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
|
|
4329
|
+
previousOrder: prevOrderInfo,
|
|
4330
|
+
timestamp: Date.now()
|
|
4331
|
+
});
|
|
4332
|
+
case 20:
|
|
4333
|
+
_context55.next = 25;
|
|
4334
|
+
break;
|
|
4335
|
+
case 22:
|
|
4336
|
+
_context55.prev = 22;
|
|
4337
|
+
_context55.t0 = _context55["catch"](0);
|
|
4338
|
+
console.error('[Checkout] 重置 store 状态失败:', _context55.t0);
|
|
4339
|
+
case 25:
|
|
4340
|
+
case "end":
|
|
4341
|
+
return _context55.stop();
|
|
4342
|
+
}
|
|
4343
|
+
}, _callee55, this, [[0, 22]]);
|
|
4344
|
+
}));
|
|
4345
|
+
function resetStoreStateAsync() {
|
|
4346
|
+
return _resetStoreStateAsync.apply(this, arguments);
|
|
4347
|
+
}
|
|
4348
|
+
return resetStoreStateAsync;
|
|
4349
|
+
}()
|
|
4350
|
+
/**
|
|
4351
|
+
* 手动清理已完成的订单状态(公开方法)
|
|
4352
|
+
*
|
|
4353
|
+
* 供UI层调用的公开方法,用于手动清理订单状态
|
|
4354
|
+
*
|
|
4355
|
+
* @returns 清理结果
|
|
4356
|
+
*/
|
|
4357
|
+
)
|
|
4358
|
+
}, {
|
|
4359
|
+
key: "clearCompletedOrderAsync",
|
|
4360
|
+
value: (function () {
|
|
4361
|
+
var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
|
|
4362
|
+
var prevOrderInfo;
|
|
4363
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
4364
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
4365
|
+
case 0:
|
|
4366
|
+
_context56.prev = 0;
|
|
4367
|
+
prevOrderInfo = this.store.currentOrder ? {
|
|
4368
|
+
uuid: this.store.currentOrder.uuid,
|
|
4369
|
+
orderId: this.store.currentOrder.order_id
|
|
4370
|
+
} : null;
|
|
4371
|
+
_context56.next = 4;
|
|
4372
|
+
return this.resetStoreStateAsync();
|
|
4373
|
+
case 4:
|
|
4374
|
+
return _context56.abrupt("return", {
|
|
4375
|
+
success: true,
|
|
4376
|
+
message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
|
|
4377
|
+
clearedOrder: prevOrderInfo
|
|
4378
|
+
});
|
|
4379
|
+
case 7:
|
|
4380
|
+
_context56.prev = 7;
|
|
4381
|
+
_context56.t0 = _context56["catch"](0);
|
|
4382
|
+
console.error('[Checkout] 手动清理订单状态失败:', _context56.t0);
|
|
4383
|
+
return _context56.abrupt("return", {
|
|
4384
|
+
success: false,
|
|
4385
|
+
message: _context56.t0 instanceof Error ? _context56.t0.message : '清理失败'
|
|
4386
|
+
});
|
|
4387
|
+
case 11:
|
|
4388
|
+
case "end":
|
|
4389
|
+
return _context56.stop();
|
|
4390
|
+
}
|
|
4391
|
+
}, _callee56, this, [[0, 7]]);
|
|
4392
|
+
}));
|
|
4393
|
+
function clearCompletedOrderAsync() {
|
|
4394
|
+
return _clearCompletedOrderAsync.apply(this, arguments);
|
|
4395
|
+
}
|
|
4396
|
+
return clearCompletedOrderAsync;
|
|
4397
|
+
}())
|
|
4191
4398
|
}]);
|
|
4192
4399
|
return CheckoutImpl;
|
|
4193
4400
|
}(BaseModule);
|