@pisell/pisellos 0.0.242 → 0.0.243
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.
|
@@ -389,7 +389,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
389
389
|
key: "createLocalOrderAsync",
|
|
390
390
|
value: (function () {
|
|
391
391
|
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
392
|
-
var _params$totalInfo, _params$totalInfo2, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
|
|
392
|
+
var _params$totalInfo, _params$totalInfo2, _params$totalInfo3, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
|
|
393
393
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
394
394
|
while (1) switch (_context9.prev = _context9.next) {
|
|
395
395
|
case 0:
|
|
@@ -416,10 +416,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
416
416
|
params.orderData.platform = 'pos';
|
|
417
417
|
// 补充 created_at 时间 (YYYY-MM-DD hh:mm:ss 格式)
|
|
418
418
|
params.orderData.created_at = this.formatDateTime(new Date());
|
|
419
|
-
//
|
|
420
|
-
params.orderData.surcharge_fee = (_params$totalInfo = params.totalInfo) === null || _params$totalInfo === void 0 || (_params$totalInfo = _params$totalInfo.total) === null || _params$totalInfo === void 0 ? void 0 : _params$totalInfo.
|
|
419
|
+
// 补充附加费信息
|
|
420
|
+
params.orderData.surcharge_fee = (_params$totalInfo = params.totalInfo) === null || _params$totalInfo === void 0 || (_params$totalInfo = _params$totalInfo.total) === null || _params$totalInfo === void 0 ? void 0 : _params$totalInfo.otherAmount;
|
|
421
|
+
params.orderData.surcharges = (_params$totalInfo2 = params.totalInfo) === null || _params$totalInfo2 === void 0 || (_params$totalInfo2 = _params$totalInfo2.total) === null || _params$totalInfo2 === void 0 ? void 0 : _params$totalInfo2.surcharge;
|
|
421
422
|
// 补充订单折扣信息
|
|
422
|
-
params.orderData.shop_discount = (_params$
|
|
423
|
+
params.orderData.shop_discount = (_params$totalInfo3 = params.totalInfo) === null || _params$totalInfo3 === void 0 || (_params$totalInfo3 = _params$totalInfo3.total) === null || _params$totalInfo3 === void 0 ? void 0 : _params$totalInfo3.shopDiscount;
|
|
423
424
|
|
|
424
425
|
// 保存原始订单数据和小计数据到状态中
|
|
425
426
|
this.store.localOrderData = params.orderData;
|
|
@@ -439,7 +440,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
440
|
}
|
|
440
441
|
|
|
441
442
|
// 创建支付订单对象
|
|
442
|
-
_context9.next =
|
|
443
|
+
_context9.next = 23;
|
|
443
444
|
return this.payment.createPaymentOrderAsync({
|
|
444
445
|
order_id: localOrderId,
|
|
445
446
|
total_amount: amountInfo.totalAmount,
|
|
@@ -456,34 +457,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
456
457
|
amount_breakdown: amountInfo
|
|
457
458
|
}
|
|
458
459
|
});
|
|
459
|
-
case
|
|
460
|
+
case 23:
|
|
460
461
|
paymentOrder = _context9.sent;
|
|
461
462
|
this.store.currentOrder = paymentOrder;
|
|
462
|
-
_context9.next =
|
|
463
|
+
_context9.next = 27;
|
|
463
464
|
return this.initWalletData();
|
|
464
|
-
case
|
|
465
|
-
_context9.next =
|
|
465
|
+
case 27:
|
|
466
|
+
_context9.next = 29;
|
|
466
467
|
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
467
|
-
case
|
|
468
|
-
_context9.next =
|
|
468
|
+
case 29:
|
|
469
|
+
_context9.next = 31;
|
|
469
470
|
return this.setStep(CheckoutStep.PaymentMethod);
|
|
470
|
-
case
|
|
471
|
+
case 31:
|
|
471
472
|
if (!params.autoPayment) {
|
|
472
|
-
_context9.next =
|
|
473
|
+
_context9.next = 34;
|
|
473
474
|
break;
|
|
474
475
|
}
|
|
475
|
-
_context9.next =
|
|
476
|
+
_context9.next = 34;
|
|
476
477
|
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
477
|
-
case
|
|
478
|
-
_context9.next =
|
|
478
|
+
case 34:
|
|
479
|
+
_context9.next = 36;
|
|
479
480
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
480
481
|
order: paymentOrder,
|
|
481
482
|
timestamp: Date.now()
|
|
482
483
|
});
|
|
483
|
-
case
|
|
484
|
-
_context9.next =
|
|
484
|
+
case 36:
|
|
485
|
+
_context9.next = 38;
|
|
485
486
|
return this.updateStateAmountToRemaining();
|
|
486
|
-
case
|
|
487
|
+
case 38:
|
|
487
488
|
console.log('[Checkout] 本地订单创建成功:', {
|
|
488
489
|
localOrderId: localOrderId,
|
|
489
490
|
uuid: paymentOrder.uuid,
|
|
@@ -493,24 +494,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
493
494
|
stateAmount: this.store.stateAmount
|
|
494
495
|
});
|
|
495
496
|
return _context9.abrupt("return", paymentOrder);
|
|
496
|
-
case
|
|
497
|
-
_context9.prev =
|
|
497
|
+
case 42:
|
|
498
|
+
_context9.prev = 42;
|
|
498
499
|
_context9.t0 = _context9["catch"](0);
|
|
499
|
-
_context9.next =
|
|
500
|
+
_context9.next = 46;
|
|
500
501
|
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
501
|
-
case
|
|
502
|
-
_context9.next =
|
|
502
|
+
case 46:
|
|
503
|
+
_context9.next = 48;
|
|
503
504
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
504
505
|
error: this.store.lastError,
|
|
505
506
|
timestamp: Date.now()
|
|
506
507
|
});
|
|
507
|
-
case 47:
|
|
508
|
-
throw _context9.t0;
|
|
509
508
|
case 48:
|
|
509
|
+
throw _context9.t0;
|
|
510
|
+
case 49:
|
|
510
511
|
case "end":
|
|
511
512
|
return _context9.stop();
|
|
512
513
|
}
|
|
513
|
-
}, _callee9, this, [[0,
|
|
514
|
+
}, _callee9, this, [[0, 42]]);
|
|
514
515
|
}));
|
|
515
516
|
function createLocalOrderAsync(_x11) {
|
|
516
517
|
return _createLocalOrderAsync.apply(this, arguments);
|
|
@@ -189,7 +189,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
189
189
|
* 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
|
|
190
190
|
*/
|
|
191
191
|
async createLocalOrderAsync(params) {
|
|
192
|
-
var _a, _b, _c, _d;
|
|
192
|
+
var _a, _b, _c, _d, _e, _f;
|
|
193
193
|
try {
|
|
194
194
|
await this.resetStoreStateAsync();
|
|
195
195
|
await this.setStatus(import_types.CheckoutStatus.CreatingOrder);
|
|
@@ -204,8 +204,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
204
204
|
const amountInfo = this.extractAmountFromCartSummary(params.cartSummary);
|
|
205
205
|
params.orderData.platform = "pos";
|
|
206
206
|
params.orderData.created_at = this.formatDateTime(/* @__PURE__ */ new Date());
|
|
207
|
-
params.orderData.surcharge_fee = (_b = (_a = params.totalInfo) == null ? void 0 : _a.total) == null ? void 0 : _b.
|
|
208
|
-
params.orderData.
|
|
207
|
+
params.orderData.surcharge_fee = (_b = (_a = params.totalInfo) == null ? void 0 : _a.total) == null ? void 0 : _b.otherAmount;
|
|
208
|
+
params.orderData.surcharges = (_d = (_c = params.totalInfo) == null ? void 0 : _c.total) == null ? void 0 : _d.surcharge;
|
|
209
|
+
params.orderData.shop_discount = (_f = (_e = params.totalInfo) == null ? void 0 : _e.total) == null ? void 0 : _f.shopDiscount;
|
|
209
210
|
this.store.localOrderData = params.orderData;
|
|
210
211
|
this.store.cartSummary = params.cartSummary;
|
|
211
212
|
const customerInfo = {
|