@pisell/pisellos 2.2.8 → 2.2.10
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/Cart/utils/cartProduct.js +41 -26
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/index.d.ts +3 -0
- package/dist/modules/Discount/index.js +70 -37
- package/dist/modules/Discount/types.d.ts +16 -0
- package/dist/modules/Order/index.js +4 -1
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +9 -0
- package/dist/modules/Payment/cash.js +1 -1
- package/dist/modules/Payment/eftpos.js +1 -1
- package/dist/modules/Payment/index.js +101 -31
- package/dist/modules/Payment/types.d.ts +22 -2
- package/dist/modules/Payment/walletpass.js +8 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +8 -9
- package/dist/modules/Rules/index.d.ts +16 -2
- package/dist/modules/Rules/index.js +1102 -200
- package/dist/modules/Rules/types.d.ts +8 -1
- package/dist/solution/BookingByStep/index.js +30 -8
- package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
- package/dist/solution/BookingByStep/utils/products.js +10 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.d.ts +2 -0
- package/dist/solution/Checkout/index.js +277 -88
- package/dist/solution/Checkout/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +5 -0
- package/dist/solution/ShopDiscount/index.js +96 -24
- package/dist/solution/ShopDiscount/types.d.ts +9 -1
- package/dist/solution/ShopDiscount/utils.d.ts +55 -0
- package/dist/solution/ShopDiscount/utils.js +432 -3
- package/lib/modules/Cart/utils/cartProduct.js +35 -22
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/index.d.ts +3 -0
- package/lib/modules/Discount/index.js +20 -5
- package/lib/modules/Discount/types.d.ts +16 -0
- package/lib/modules/Order/index.js +2 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +11 -0
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +71 -11
- package/lib/modules/Payment/types.d.ts +22 -2
- package/lib/modules/Payment/walletpass.js +15 -4
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/modules/Rules/index.d.ts +16 -2
- package/lib/modules/Rules/index.js +857 -184
- package/lib/modules/Rules/types.d.ts +8 -1
- package/lib/solution/BookingByStep/index.js +19 -2
- package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
- package/lib/solution/BookingByStep/utils/products.js +8 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.d.ts +2 -0
- package/lib/solution/Checkout/index.js +185 -25
- package/lib/solution/Checkout/types.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +5 -0
- package/lib/solution/ShopDiscount/index.js +67 -13
- package/lib/solution/ShopDiscount/types.d.ts +9 -1
- package/lib/solution/ShopDiscount/utils.d.ts +55 -0
- package/lib/solution/ShopDiscount/utils.js +266 -3
- package/package.json +2 -2
|
@@ -371,10 +371,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
371
371
|
}
|
|
372
372
|
return initializeCheckoutAsync;
|
|
373
373
|
}())
|
|
374
|
+
}, {
|
|
375
|
+
key: "getHolderIdFromBooking",
|
|
376
|
+
value: function getHolderIdFromBooking(obj) {
|
|
377
|
+
var _obj$holder;
|
|
378
|
+
if (!obj) return undefined;
|
|
379
|
+
var ret = obj.holder_id || ((_obj$holder = obj.holder) === null || _obj$holder === void 0 ? void 0 : _obj$holder.form_record);
|
|
380
|
+
if (Array.isArray(ret)) {
|
|
381
|
+
return ret.length > 0 ? Number(ret[0]) : undefined;
|
|
382
|
+
}
|
|
383
|
+
return Number(ret) || undefined;
|
|
384
|
+
}
|
|
374
385
|
}, {
|
|
375
386
|
key: "getProductListByOrder",
|
|
376
387
|
value: function getProductListByOrder() {
|
|
377
|
-
var _this$store$currentOr,
|
|
388
|
+
var _this$store$currentOr,
|
|
389
|
+
_this3 = this,
|
|
390
|
+
_this$store$currentOr2;
|
|
378
391
|
if (!this.store.currentOrder) {
|
|
379
392
|
return [];
|
|
380
393
|
}
|
|
@@ -383,30 +396,74 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
383
396
|
return pre + (item.amount || 0);
|
|
384
397
|
}, 0);
|
|
385
398
|
};
|
|
386
|
-
var
|
|
387
|
-
return {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
399
|
+
var formatProduct = function formatProduct(items) {
|
|
400
|
+
return items.map(function (item) {
|
|
401
|
+
var _item$is_charge_tax;
|
|
402
|
+
return {
|
|
403
|
+
product_id: item.product_id,
|
|
404
|
+
product_variant_id: item.product_variant_id,
|
|
405
|
+
quantity: item.num,
|
|
406
|
+
// 商品是否含税:1;0
|
|
407
|
+
is_charge_tax: (_item$is_charge_tax = item.is_charge_tax) !== null && _item$is_charge_tax !== void 0 ? _item$is_charge_tax : 0,
|
|
408
|
+
// 若商品不含税,计算得到的税费,单位(元)
|
|
409
|
+
tax_fee: item.tax_fee,
|
|
410
|
+
// 整个商品折扣后的总金额
|
|
411
|
+
selling_price: item.calculated_selling_price,
|
|
412
|
+
// 使用者id
|
|
413
|
+
holder_id: item.holder_id,
|
|
414
|
+
// 整个商品折扣前的总金额
|
|
415
|
+
original_price: item.calculated_original_price,
|
|
416
|
+
// 主商品折扣前金额,不包含套餐子商品
|
|
417
|
+
main_product_original_price: item.price,
|
|
418
|
+
// 主商品折扣后金额,不包含套餐子商品
|
|
419
|
+
main_product_selling_price: item.main_product_selling_price,
|
|
420
|
+
metadata: {
|
|
421
|
+
// 主商品+非原价(加减价)子商品税费
|
|
422
|
+
"main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
|
|
423
|
+
// 主商品+非原价(加减价)子商品附加费
|
|
424
|
+
"main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
|
|
425
|
+
// 可选,附加费均摊舍入金额
|
|
426
|
+
"surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
|
|
427
|
+
},
|
|
428
|
+
product_bundle: item.product_bundle.map(function (bundle) {
|
|
429
|
+
return {
|
|
430
|
+
bundle_id: bundle.bundle_id,
|
|
431
|
+
bundle_product_id: bundle.bundle_product_id,
|
|
432
|
+
bundle_variant_id: bundle.bundle_variant_id,
|
|
433
|
+
price_type: bundle.price_type,
|
|
434
|
+
price_type_ext: bundle.price_type_ext,
|
|
435
|
+
// 套餐子商品总价,不包含折扣金额
|
|
436
|
+
bundle_sum_price: bundle.bundle_sum_price,
|
|
437
|
+
// 套餐子商品折扣后金额
|
|
438
|
+
bundle_selling_price: bundle.bundle_selling_price,
|
|
439
|
+
num: bundle.num,
|
|
440
|
+
is_charge_tax: bundle.is_charge_tax,
|
|
441
|
+
tax_fee: bundle.tax_fee,
|
|
442
|
+
metadata: {
|
|
443
|
+
// 子商品单数量附加费
|
|
444
|
+
"surcharge_fee": bundle.metadata.surcharge_fee,
|
|
445
|
+
// 可选,附加费均摊舍入金额
|
|
446
|
+
"surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
})
|
|
450
|
+
};
|
|
451
|
+
}) || [];
|
|
452
|
+
};
|
|
453
|
+
var productList = formatProduct(((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
|
|
454
|
+
return _objectSpread(_objectSpread({}, item.product), {}, {
|
|
455
|
+
holder_id: _this3.getHolderIdFromBooking(item)
|
|
456
|
+
});
|
|
457
|
+
})) || []);
|
|
458
|
+
var relationProducts = formatProduct(((_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 ? void 0 : _this$store$currentOr2.relation_products) || []);
|
|
402
459
|
return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
|
|
403
460
|
}
|
|
404
461
|
}, {
|
|
405
462
|
key: "initWalletData",
|
|
406
463
|
value: function () {
|
|
407
464
|
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
408
|
-
var _this$store$currentOr3, _this$store$currentCu, _this$store$currentOr4, _this$store$currentOr5, _this$store$
|
|
409
|
-
var amountInfo, walletBusinessData, _this$store$
|
|
465
|
+
var _this$store$currentOr3, _this$store$currentCu, _this$store$currentOr4, _this$store$currentOr5, _this$store$currentOr6, _this$store$currentOr8;
|
|
466
|
+
var amountInfo, walletBusinessData, _this$store$currentOr7;
|
|
410
467
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
411
468
|
while (1) switch (_context8.prev = _context8.next) {
|
|
412
469
|
case 0:
|
|
@@ -426,16 +483,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
426
483
|
// 准备钱包初始化的业务数据
|
|
427
484
|
walletBusinessData = _objectSpread({
|
|
428
485
|
customer_id: (_this$store$currentCu = this.store.currentCustomer) !== null && _this$store$currentCu !== void 0 && _this$store$currentCu.customer_id ? Number(this.store.currentCustomer.customer_id) : undefined,
|
|
486
|
+
holder: (_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 || (_this$store$currentOr4 = _this$store$currentOr4.order_info) === null || _this$store$currentOr4 === void 0 || (_this$store$currentOr4 = _this$store$currentOr4.original_order_data) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.holder,
|
|
429
487
|
amountInfo: {
|
|
430
488
|
totalAmount: amountInfo.totalAmount,
|
|
431
489
|
subTotal: amountInfo.subTotal,
|
|
432
|
-
depositAmount: (_this$store$
|
|
433
|
-
isDeposit: (_this$store$
|
|
490
|
+
depositAmount: (_this$store$currentOr5 = this.store.currentOrder) === null || _this$store$currentOr5 === void 0 ? void 0 : _this$store$currentOr5.deposit_amount,
|
|
491
|
+
isDeposit: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.is_deposit
|
|
434
492
|
},
|
|
435
|
-
products: this.getProductListByOrder()
|
|
493
|
+
products: this.getProductListByOrder(),
|
|
494
|
+
is_price_include_tax: this.otherParams.is_price_include_tax
|
|
436
495
|
}, params); // 判断订单是否已经同步,如果是则追加payment_order_id参数
|
|
437
496
|
if (this.store.isOrderSynced) {
|
|
438
|
-
walletBusinessData.payment_order_id = (_this$store$
|
|
497
|
+
walletBusinessData.payment_order_id = (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.order_id;
|
|
439
498
|
}
|
|
440
499
|
this.logInfo('开始拉取:initializeWalletDataFromBusinessAsync', {
|
|
441
500
|
walletBusinessData: walletBusinessData
|
|
@@ -460,7 +519,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
460
519
|
// 触发钱包数据初始化完成事件
|
|
461
520
|
_context8.next = 16;
|
|
462
521
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
463
|
-
orderUuid: (_this$store$
|
|
522
|
+
orderUuid: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.uuid,
|
|
464
523
|
customerId: walletBusinessData.customer_id,
|
|
465
524
|
walletBusinessData: {
|
|
466
525
|
customer_id: walletBusinessData.customer_id,
|
|
@@ -693,7 +752,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
693
752
|
value: (function () {
|
|
694
753
|
var _updateLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
695
754
|
var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8;
|
|
696
|
-
var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining,
|
|
755
|
+
var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment2, _existingOrder$paymen, _updated$payment, currentTime, formattedExistPayments, _isNeedDeposit, _updated, syncedPayments, _syncedAmount, _totalAmount, _remainingExpectAmount, _depositDiffAmount, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit2, updated, syncedAmount, remainingExpectAmount, depositDiffAmount, isNeedDeposit, created, _syncedPayments, _syncedAmount2;
|
|
697
756
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
698
757
|
while (1) switch (_context10.prev = _context10.next) {
|
|
699
758
|
case 0:
|
|
@@ -746,10 +805,104 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
746
805
|
return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
|
|
747
806
|
});
|
|
748
807
|
if (!existingOrder) {
|
|
749
|
-
_context10.next =
|
|
808
|
+
_context10.next = 71;
|
|
809
|
+
break;
|
|
810
|
+
}
|
|
811
|
+
if (!(params.existPayment && params.existPayment.length > 0)) {
|
|
812
|
+
_context10.next = 47;
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
this.logInfo('检测到云端支付项,将替换本地订单的支付项列表', {
|
|
816
|
+
orderId: params.orderId,
|
|
817
|
+
existingPaymentCount: ((_existingOrder$paymen = existingOrder.payment) === null || _existingOrder$paymen === void 0 ? void 0 : _existingOrder$paymen.length) || 0,
|
|
818
|
+
newPaymentCount: params.existPayment.length
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
// 标记订单已同步(因为支付项来自云端)
|
|
822
|
+
this.store.isOrderSynced = true;
|
|
823
|
+
|
|
824
|
+
// 格式化云端支付项(添加时间戳、标记已同步)
|
|
825
|
+
currentTime = formatDateTime(new Date());
|
|
826
|
+
formattedExistPayments = params.existPayment.map(function (payment) {
|
|
827
|
+
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
828
|
+
isSynced: true,
|
|
829
|
+
// 标记为已同步
|
|
830
|
+
status: payment.status || 'active',
|
|
831
|
+
created_at: payment.created_at || currentTime,
|
|
832
|
+
updated_at: payment.updated_at || currentTime
|
|
833
|
+
});
|
|
834
|
+
}); // 计算是否需要支付定金
|
|
835
|
+
_isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新订单,替换支付项列表
|
|
836
|
+
_context10.next = 28;
|
|
837
|
+
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
838
|
+
total_amount: amountInfo.totalAmount,
|
|
839
|
+
is_deposit: _isNeedDeposit.hasDeposit ? 1 : 0,
|
|
840
|
+
deposit_amount: _isNeedDeposit.total ? _isNeedDeposit.total.toString() : '0.00',
|
|
841
|
+
payment: formattedExistPayments,
|
|
842
|
+
// 🔧 替换支付项列表
|
|
843
|
+
order_info: {
|
|
844
|
+
original_order_data: params.orderData,
|
|
845
|
+
cart_summary: params.cartSummary,
|
|
846
|
+
created_at: new Date().toISOString(),
|
|
847
|
+
platform: params.orderData.platform,
|
|
848
|
+
type: params.orderData.type,
|
|
849
|
+
schedule_date: params.orderData.schedule_date,
|
|
850
|
+
shop_note: params.orderData.shop_note,
|
|
851
|
+
amount_breakdown: amountInfo
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
case 28:
|
|
855
|
+
_context10.next = 30;
|
|
856
|
+
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
857
|
+
case 30:
|
|
858
|
+
_updated = _context10.sent;
|
|
859
|
+
if (_updated) {
|
|
860
|
+
_context10.next = 33;
|
|
750
861
|
break;
|
|
751
862
|
}
|
|
752
|
-
|
|
863
|
+
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
864
|
+
case 33:
|
|
865
|
+
this.store.currentOrder = _updated;
|
|
866
|
+
_context10.next = 36;
|
|
867
|
+
return this.updateStateAmountToRemaining(false);
|
|
868
|
+
case 36:
|
|
869
|
+
this.logInfo('本地订单更新成功(已替换云端支付项):', {
|
|
870
|
+
orderId: params.orderId,
|
|
871
|
+
uuid: _updated.uuid,
|
|
872
|
+
payments: ((_updated$payment = _updated.payment) === null || _updated$payment === void 0 ? void 0 : _updated$payment.length) || 0,
|
|
873
|
+
totalAmount: _updated.total_amount,
|
|
874
|
+
expectAmount: _updated.expect_amount,
|
|
875
|
+
isOrderSynced: true
|
|
876
|
+
});
|
|
877
|
+
|
|
878
|
+
// 事件通知
|
|
879
|
+
_context10.next = 39;
|
|
880
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
881
|
+
order: _updated,
|
|
882
|
+
timestamp: Date.now()
|
|
883
|
+
});
|
|
884
|
+
case 39:
|
|
885
|
+
// 计算已同步的支付金额
|
|
886
|
+
syncedPayments = _updated.payment.filter(function (p) {
|
|
887
|
+
return p.isSynced && p.status !== 'voided';
|
|
888
|
+
});
|
|
889
|
+
_syncedAmount = syncedPayments.reduce(function (sum, p) {
|
|
890
|
+
var amt = new Decimal(p.amount || '0');
|
|
891
|
+
var rounding = new Decimal(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || '0').abs();
|
|
892
|
+
return sum.plus(amt).plus(rounding);
|
|
893
|
+
}, new Decimal(0));
|
|
894
|
+
_totalAmount = new Decimal(amountInfo.totalAmount || '0');
|
|
895
|
+
_remainingExpectAmount = Decimal.max(0, _totalAmount.minus(_syncedAmount)).toFixed(2); // 计算定金差值
|
|
896
|
+
_depositDiffAmount = new Decimal(0).toFixed(2);
|
|
897
|
+
if (_updated.is_deposit === 1) {
|
|
898
|
+
_depositDiffAmount = new Decimal(_updated.deposit_amount).minus(_syncedAmount).toFixed(2);
|
|
899
|
+
}
|
|
900
|
+
this.initWalletData({
|
|
901
|
+
order_wait_pay_amount: Number(_depositDiffAmount) > 0 ? Number(_depositDiffAmount) : Number(_remainingExpectAmount)
|
|
902
|
+
});
|
|
903
|
+
return _context10.abrupt("return", _updated);
|
|
904
|
+
case 47:
|
|
905
|
+
// 原有逻辑:保留现有支付项
|
|
753
906
|
totalAmount = new Decimal(amountInfo.totalAmount || '0');
|
|
754
907
|
activePayments = (existingOrder.payment || []).filter(function (p) {
|
|
755
908
|
return p.status !== 'voided';
|
|
@@ -760,12 +913,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
760
913
|
return sum.plus(amt).plus(rounding);
|
|
761
914
|
}, new Decimal(0));
|
|
762
915
|
remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
763
|
-
|
|
764
|
-
_context10.next =
|
|
916
|
+
_isNeedDeposit2 = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新到支付模块(使用 uuid,不修改 payment 列表)
|
|
917
|
+
_context10.next = 54;
|
|
765
918
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
766
919
|
total_amount: amountInfo.totalAmount,
|
|
767
|
-
is_deposit:
|
|
768
|
-
deposit_amount:
|
|
920
|
+
is_deposit: _isNeedDeposit2.hasDeposit ? 1 : 0,
|
|
921
|
+
deposit_amount: _isNeedDeposit2.total ? _isNeedDeposit2.total.toString() : '0.00',
|
|
769
922
|
expect_amount: remaining,
|
|
770
923
|
order_info: {
|
|
771
924
|
original_order_data: params.orderData,
|
|
@@ -778,36 +931,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
778
931
|
amount_breakdown: amountInfo
|
|
779
932
|
}
|
|
780
933
|
});
|
|
781
|
-
case
|
|
782
|
-
_context10.next =
|
|
934
|
+
case 54:
|
|
935
|
+
_context10.next = 56;
|
|
783
936
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
784
|
-
case
|
|
937
|
+
case 56:
|
|
785
938
|
updated = _context10.sent;
|
|
786
939
|
if (updated) {
|
|
787
|
-
_context10.next =
|
|
940
|
+
_context10.next = 59;
|
|
788
941
|
break;
|
|
789
942
|
}
|
|
790
943
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
791
|
-
case
|
|
944
|
+
case 59:
|
|
792
945
|
this.store.currentOrder = updated;
|
|
793
|
-
_context10.next =
|
|
946
|
+
_context10.next = 62;
|
|
794
947
|
return this.updateStateAmountToRemaining(false);
|
|
795
|
-
case
|
|
948
|
+
case 62:
|
|
796
949
|
this.logInfo('本地订单更新成功(保留支付项):', {
|
|
797
950
|
orderId: params.orderId,
|
|
798
951
|
uuid: updated.uuid,
|
|
799
|
-
payments: ((_updated$
|
|
952
|
+
payments: ((_updated$payment2 = updated.payment) === null || _updated$payment2 === void 0 ? void 0 : _updated$payment2.length) || 0,
|
|
800
953
|
totalAmount: updated.total_amount,
|
|
801
954
|
expectAmount: updated.expect_amount
|
|
802
955
|
});
|
|
803
956
|
|
|
804
957
|
// 事件通知(复用创建事件,便于上层监听刷新)
|
|
805
|
-
_context10.next =
|
|
958
|
+
_context10.next = 65;
|
|
806
959
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
807
960
|
order: updated,
|
|
808
961
|
timestamp: Date.now()
|
|
809
962
|
});
|
|
810
|
-
case
|
|
963
|
+
case 65:
|
|
811
964
|
// 需要减去已经同步给后端的支付过的钱
|
|
812
965
|
syncedAmount = activePayments.reduce(function (sum, p) {
|
|
813
966
|
var amt = new Decimal(p.amount || '0');
|
|
@@ -823,15 +976,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
823
976
|
order_wait_pay_amount: Number(depositDiffAmount) > 0 ? Number(depositDiffAmount) : Number(remainingExpectAmount)
|
|
824
977
|
});
|
|
825
978
|
return _context10.abrupt("return", updated);
|
|
826
|
-
case
|
|
979
|
+
case 71:
|
|
827
980
|
// 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
828
981
|
isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
|
|
829
|
-
_context10.next =
|
|
982
|
+
_context10.next = 74;
|
|
830
983
|
return this.payment.createPaymentOrderAsync({
|
|
831
984
|
order_id: String(params.orderId),
|
|
832
985
|
total_amount: amountInfo.totalAmount,
|
|
833
986
|
is_deposit: isNeedDeposit.hasDeposit ? 1 : 0,
|
|
834
987
|
deposit_amount: isNeedDeposit.total ? isNeedDeposit.total.toString() : '0.00',
|
|
988
|
+
existPayment: params.existPayment,
|
|
989
|
+
// 🔧 新增: 传递云端支付项
|
|
835
990
|
order_info: {
|
|
836
991
|
original_order_data: params.orderData,
|
|
837
992
|
cart_summary: params.cartSummary,
|
|
@@ -843,12 +998,43 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
843
998
|
amount_breakdown: amountInfo
|
|
844
999
|
}
|
|
845
1000
|
});
|
|
846
|
-
case
|
|
1001
|
+
case 74:
|
|
847
1002
|
created = _context10.sent;
|
|
848
1003
|
this.store.currentOrder = created;
|
|
849
|
-
|
|
1004
|
+
|
|
1005
|
+
// 🔧 新增: 如果有云端支付项,需要计算正确的待付金额
|
|
1006
|
+
if (params.existPayment && params.existPayment.length > 0) {
|
|
1007
|
+
// 标记订单已同步(因为订单和支付项都来自云端)
|
|
1008
|
+
this.store.isOrderSynced = true;
|
|
1009
|
+
|
|
1010
|
+
// 计算已同步的支付金额
|
|
1011
|
+
_syncedPayments = created.payment.filter(function (p) {
|
|
1012
|
+
return p.isSynced && p.status !== 'voided';
|
|
1013
|
+
});
|
|
1014
|
+
_syncedAmount2 = _syncedPayments.reduce(function (sum, p) {
|
|
1015
|
+
var amt = new Decimal(p.amount || '0');
|
|
1016
|
+
var rounding = new Decimal(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || '0').abs();
|
|
1017
|
+
return sum.plus(amt).plus(rounding);
|
|
1018
|
+
}, new Decimal(0));
|
|
1019
|
+
this.logInfo('云端订单初始化钱包数据', {
|
|
1020
|
+
orderId: params.orderId,
|
|
1021
|
+
totalAmount: created.total_amount,
|
|
1022
|
+
expectAmount: created.expect_amount,
|
|
1023
|
+
syncedAmount: _syncedAmount2.toFixed(2),
|
|
1024
|
+
syncedPaymentCount: _syncedPayments.length,
|
|
1025
|
+
isOrderSynced: true
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
// 初始化钱包数据,使用系统计算的待付金额
|
|
1029
|
+
this.initWalletData({
|
|
1030
|
+
order_wait_pay_amount: Number(created.expect_amount)
|
|
1031
|
+
});
|
|
1032
|
+
} else {
|
|
1033
|
+
// 没有云端支付项,正常初始化
|
|
1034
|
+
this.initWalletData();
|
|
1035
|
+
}
|
|
850
1036
|
return _context10.abrupt("return", created);
|
|
851
|
-
case
|
|
1037
|
+
case 78:
|
|
852
1038
|
case "end":
|
|
853
1039
|
return _context10.stop();
|
|
854
1040
|
}
|
|
@@ -931,8 +1117,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
931
1117
|
}, {
|
|
932
1118
|
key: "getOrderOriginalData",
|
|
933
1119
|
value: function getOrderOriginalData() {
|
|
934
|
-
var _this$store$
|
|
935
|
-
return (_this$store$
|
|
1120
|
+
var _this$store$currentOr9;
|
|
1121
|
+
return (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.order_info;
|
|
936
1122
|
}
|
|
937
1123
|
|
|
938
1124
|
/**
|
|
@@ -1542,7 +1728,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1542
1728
|
key: "updateVoucherPaymentItemsAsync",
|
|
1543
1729
|
value: (function () {
|
|
1544
1730
|
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(voucherPaymentItems) {
|
|
1545
|
-
var
|
|
1731
|
+
var _this4 = this;
|
|
1546
1732
|
var paymentItems, allPaymentItemsSynced, remainingAmount, remainingValue, isOrderSynced, orderPaymentType, voucherPaymentItemsWithType, currentOrderId, isCurrentOrderReal, updatedOrder;
|
|
1547
1733
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1548
1734
|
while (1) switch (_context18.prev = _context18.next) {
|
|
@@ -1594,8 +1780,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1594
1780
|
|
|
1595
1781
|
// 从 otherParams 获取 metadata 字段
|
|
1596
1782
|
var metadata = _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
1597
|
-
rounding_rule:
|
|
1598
|
-
shop_wallet_pass_id:
|
|
1783
|
+
rounding_rule: _this4.otherParams.order_rounding_setting,
|
|
1784
|
+
shop_wallet_pass_id: _this4.otherParams.shop_wallet_pass_id
|
|
1599
1785
|
});
|
|
1600
1786
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
1601
1787
|
order_payment_type: orderPaymentType,
|
|
@@ -1781,7 +1967,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1781
1967
|
key: "setDepositAmountAsync",
|
|
1782
1968
|
value: (function () {
|
|
1783
1969
|
var _setDepositAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(depositAmount) {
|
|
1784
|
-
var _this$store$
|
|
1970
|
+
var _this$store$currentOr10, _this$store$currentOr11;
|
|
1785
1971
|
var depositValue, formattedDepositAmount, oldDepositAmount, updateParams;
|
|
1786
1972
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1787
1973
|
while (1) switch (_context20.prev = _context20.next) {
|
|
@@ -1789,8 +1975,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1789
1975
|
this.logInfo('setDepositAmountAsync called', {
|
|
1790
1976
|
depositAmount: depositAmount,
|
|
1791
1977
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1792
|
-
currentOrderId: (_this$store$
|
|
1793
|
-
currentTotalAmount: (_this$store$
|
|
1978
|
+
currentOrderId: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.order_id,
|
|
1979
|
+
currentTotalAmount: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.total_amount
|
|
1794
1980
|
});
|
|
1795
1981
|
_context20.prev = 1;
|
|
1796
1982
|
// 验证定金金额格式
|
|
@@ -1910,17 +2096,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1910
2096
|
key: "manualSyncOrderAsync",
|
|
1911
2097
|
value: (function () {
|
|
1912
2098
|
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1913
|
-
var _this$store$
|
|
1914
|
-
var _this$store$
|
|
2099
|
+
var _this$store$currentOr12, _this$store$currentOr13, _this$store$currentOr14;
|
|
2100
|
+
var _this$store$currentOr15, orderUuid, oldOrderId, syncResult, finalOrderId, finalIsVirtual, newRes, _this$store$currentOr16, errorMessage;
|
|
1915
2101
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1916
2102
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1917
2103
|
case 0:
|
|
1918
2104
|
console.log('manualSyncOrderAsync called');
|
|
1919
2105
|
this.logInfo('manualSyncOrderAsync called', {
|
|
1920
2106
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1921
|
-
currentOrderId: (_this$store$
|
|
1922
|
-
orderUuid: (_this$store$
|
|
1923
|
-
totalAmount: (_this$store$
|
|
2107
|
+
currentOrderId: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.order_id,
|
|
2108
|
+
orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
|
|
2109
|
+
totalAmount: (_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.total_amount,
|
|
1924
2110
|
isOrderSynced: this.store.isOrderSynced,
|
|
1925
2111
|
isVirtualOrderId: this.store.currentOrder ? isVirtualOrderId(this.store.currentOrder.order_id) : false
|
|
1926
2112
|
});
|
|
@@ -1980,7 +2166,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1980
2166
|
this.logError('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
|
|
1981
2167
|
}
|
|
1982
2168
|
newRes = _objectSpread(_objectSpread({}, syncResult), {}, {
|
|
1983
|
-
is_deposit: ((_this$store$
|
|
2169
|
+
is_deposit: ((_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.is_deposit) || 0
|
|
1984
2170
|
});
|
|
1985
2171
|
_context21.next = 30;
|
|
1986
2172
|
return this.updateStateAmountToRemaining(false);
|
|
@@ -1994,7 +2180,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1994
2180
|
return _context21.abrupt("return", {
|
|
1995
2181
|
success: false,
|
|
1996
2182
|
message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
|
|
1997
|
-
orderUuid: (_this$store$
|
|
2183
|
+
orderUuid: (_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.uuid
|
|
1998
2184
|
});
|
|
1999
2185
|
case 38:
|
|
2000
2186
|
case "end":
|
|
@@ -2071,15 +2257,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2071
2257
|
key: "cancelCurrentOrderAsync",
|
|
2072
2258
|
value: (function () {
|
|
2073
2259
|
var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(cancelReason) {
|
|
2074
|
-
var _this$store$
|
|
2260
|
+
var _this$store$currentOr17, _this$store$currentOr18, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
|
|
2075
2261
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2076
2262
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2077
2263
|
case 0:
|
|
2078
2264
|
_context22.prev = 0;
|
|
2079
2265
|
this.logInfo('开始取消当前本地订单:', {
|
|
2080
2266
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2081
|
-
orderUuid: (_this$store$
|
|
2082
|
-
orderId: (_this$store$
|
|
2267
|
+
orderUuid: (_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.uuid,
|
|
2268
|
+
orderId: (_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.order_id,
|
|
2083
2269
|
isOrderSynced: this.store.isOrderSynced,
|
|
2084
2270
|
cancelReason: cancelReason
|
|
2085
2271
|
});
|
|
@@ -2190,7 +2376,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2190
2376
|
key: "saveForLaterPaymentAsync",
|
|
2191
2377
|
value: (function () {
|
|
2192
2378
|
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2193
|
-
var orderUuid, currentOrderId, allPaymentItems, syncResult, _this$store$
|
|
2379
|
+
var orderUuid, currentOrderId, allPaymentItems, syncResult, _this$store$currentOr19, errorMessage;
|
|
2194
2380
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2195
2381
|
while (1) switch (_context23.prev = _context23.next) {
|
|
2196
2382
|
case 0:
|
|
@@ -2244,7 +2430,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2244
2430
|
return _context23.abrupt("return", {
|
|
2245
2431
|
success: false,
|
|
2246
2432
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2247
|
-
orderUuid: (_this$store$
|
|
2433
|
+
orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid
|
|
2248
2434
|
});
|
|
2249
2435
|
case 21:
|
|
2250
2436
|
case "end":
|
|
@@ -2267,7 +2453,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2267
2453
|
key: "updateOrderNoteAsync",
|
|
2268
2454
|
value: (function () {
|
|
2269
2455
|
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(note) {
|
|
2270
|
-
var _this$store$
|
|
2456
|
+
var _this$store$currentOr20, _this$store$currentOr21, oldNote, orderInPayment;
|
|
2271
2457
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2272
2458
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2273
2459
|
case 0:
|
|
@@ -2279,7 +2465,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2279
2465
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
|
|
2280
2466
|
case 3:
|
|
2281
2467
|
console.log('[Checkout] 更新订单备注:', {
|
|
2282
|
-
orderUuid: (_this$store$
|
|
2468
|
+
orderUuid: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.uuid,
|
|
2283
2469
|
oldNote: this.store.localOrderData.shop_note,
|
|
2284
2470
|
newNote: note
|
|
2285
2471
|
});
|
|
@@ -2312,7 +2498,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2312
2498
|
case 17:
|
|
2313
2499
|
_context24.next = 19;
|
|
2314
2500
|
return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
|
|
2315
|
-
orderUuid: (_this$store$
|
|
2501
|
+
orderUuid: (_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.uuid,
|
|
2316
2502
|
oldNote: oldNote,
|
|
2317
2503
|
newNote: note,
|
|
2318
2504
|
timestamp: Date.now()
|
|
@@ -2384,7 +2570,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2384
2570
|
key: "handlePaymentSuccess",
|
|
2385
2571
|
value: (function () {
|
|
2386
2572
|
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data) {
|
|
2387
|
-
var _this$store$
|
|
2573
|
+
var _this$store$currentOr22;
|
|
2388
2574
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2389
2575
|
while (1) switch (_context26.prev = _context26.next) {
|
|
2390
2576
|
case 0:
|
|
@@ -2395,7 +2581,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2395
2581
|
return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
|
|
2396
2582
|
orderUuid: data.orderUuid,
|
|
2397
2583
|
paymentMethodCode: '',
|
|
2398
|
-
amount: ((_this$store$
|
|
2584
|
+
amount: ((_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.total_amount) || '0',
|
|
2399
2585
|
timestamp: data.timestamp
|
|
2400
2586
|
});
|
|
2401
2587
|
case 4:
|
|
@@ -2420,7 +2606,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2420
2606
|
key: "handlePaymentError",
|
|
2421
2607
|
value: (function () {
|
|
2422
2608
|
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(data) {
|
|
2423
|
-
var _this$store$
|
|
2609
|
+
var _this$store$currentOr23;
|
|
2424
2610
|
var error;
|
|
2425
2611
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2426
2612
|
while (1) switch (_context27.prev = _context27.next) {
|
|
@@ -2433,7 +2619,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2433
2619
|
return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
|
|
2434
2620
|
orderUuid: data.orderUuid,
|
|
2435
2621
|
paymentMethodCode: '',
|
|
2436
|
-
amount: ((_this$store$
|
|
2622
|
+
amount: ((_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.total_amount) || '0',
|
|
2437
2623
|
timestamp: data.timestamp
|
|
2438
2624
|
});
|
|
2439
2625
|
case 5:
|
|
@@ -3140,7 +3326,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3140
3326
|
key: "updateStateAmountToRemaining",
|
|
3141
3327
|
value: (function () {
|
|
3142
3328
|
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
3143
|
-
var
|
|
3329
|
+
var _this5 = this;
|
|
3144
3330
|
var checkOrder,
|
|
3145
3331
|
_yield$this$fetchOrde3,
|
|
3146
3332
|
paymentItems,
|
|
@@ -3191,8 +3377,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3191
3377
|
depositPaidAmount = paymentItems.filter(function (item) {
|
|
3192
3378
|
return item.order_payment_type === 'deposit' && item.status !== 'voided';
|
|
3193
3379
|
}).reduce(function (sum, item) {
|
|
3194
|
-
// 如果是 wallet
|
|
3195
|
-
|
|
3380
|
+
// 如果是 wallet,并且还没同步到后端,且此时还没有其他类型的支付项(现金,eftpos,标记支付),不计入已付金额
|
|
3381
|
+
// 如果有其他支付项了,代表此时处于马上要同步的状态,所以计入
|
|
3382
|
+
if (item.voucher_id && !item.isSynced && paymentItems.filter(function (item) {
|
|
3383
|
+
return !item.voucher_id;
|
|
3384
|
+
}).length === 0) {
|
|
3196
3385
|
return sum;
|
|
3197
3386
|
}
|
|
3198
3387
|
var amount = new Decimal(item.amount || '0');
|
|
@@ -3233,7 +3422,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3233
3422
|
hasStateChanged = true;
|
|
3234
3423
|
setTimeout(function () {
|
|
3235
3424
|
// 发出 stateAmount 变更事件
|
|
3236
|
-
|
|
3425
|
+
_this5.core.effects.emit("".concat(_this5.name, ":onStateAmountChanged"), {
|
|
3237
3426
|
oldAmount: currentStateAmount,
|
|
3238
3427
|
newAmount: remainingAmount,
|
|
3239
3428
|
timestamp: Date.now(),
|
|
@@ -3254,7 +3443,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3254
3443
|
|
|
3255
3444
|
// 发出 balanceDueAmount 变更事件
|
|
3256
3445
|
setTimeout(function () {
|
|
3257
|
-
|
|
3446
|
+
_this5.core.effects.emit("".concat(_this5.name, ":onBalanceDueAmountChanged"), {
|
|
3258
3447
|
oldAmount: currentBalanceDueAmount,
|
|
3259
3448
|
newAmount: remainingAmount,
|
|
3260
3449
|
timestamp: Date.now(),
|
|
@@ -3552,11 +3741,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3552
3741
|
key: "syncOrderToBackendWithReturn",
|
|
3553
3742
|
value: (function () {
|
|
3554
3743
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3555
|
-
var
|
|
3556
|
-
_this$store$currentOr23,
|
|
3744
|
+
var _this6 = this,
|
|
3557
3745
|
_this$store$currentOr24,
|
|
3558
|
-
_this$store$currentCu2,
|
|
3559
3746
|
_this$store$currentOr25,
|
|
3747
|
+
_this$store$currentCu2,
|
|
3748
|
+
_this$store$currentOr26,
|
|
3560
3749
|
_this$store$localOrde,
|
|
3561
3750
|
_this$store$localOrde2,
|
|
3562
3751
|
_checkoutResponse3,
|
|
@@ -3633,12 +3822,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3633
3822
|
var _item$metadata, _item$metadata2;
|
|
3634
3823
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
3635
3824
|
metadata: _objectSpread(_objectSpread({}, item.metadata), {}, {
|
|
3636
|
-
rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) ||
|
|
3637
|
-
shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) ||
|
|
3825
|
+
rounding_rule: ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.rounding_rule) || _this6.otherParams.order_rounding_setting,
|
|
3826
|
+
shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this6.otherParams.shop_wallet_pass_id
|
|
3638
3827
|
})
|
|
3639
3828
|
});
|
|
3640
3829
|
}); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
|
|
3641
|
-
manualDepositAmount = ((_this$store$
|
|
3830
|
+
manualDepositAmount = ((_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
|
|
3642
3831
|
manualDepositValue = new Decimal(manualDepositAmount);
|
|
3643
3832
|
if (manualDepositValue.gt(0)) {
|
|
3644
3833
|
// 如果手动设置了定金金额且大于0,使用手动设置的值
|
|
@@ -3698,7 +3887,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3698
3887
|
}),
|
|
3699
3888
|
manualDepositAmount: manualDepositAmount,
|
|
3700
3889
|
finalDepositAmount: finalDepositAmount,
|
|
3701
|
-
isDeposit: ((_this$store$
|
|
3890
|
+
isDeposit: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.is_deposit) || 0
|
|
3702
3891
|
});
|
|
3703
3892
|
|
|
3704
3893
|
// 构造订单参数,直接使用 localOrderData 中已处理好的数据
|
|
@@ -3720,7 +3909,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3720
3909
|
currency_code: this.otherParams.currency_code,
|
|
3721
3910
|
currency_symbol: this.otherParams.currency_symbol,
|
|
3722
3911
|
currency_format: this.otherParams.currency_format,
|
|
3723
|
-
is_deposit: ((_this$store$
|
|
3912
|
+
is_deposit: ((_this$store$currentOr26 = this.store.currentOrder) !== null && _this$store$currentOr26 !== void 0 && _this$store$currentOr26.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
|
|
3724
3913
|
deposit_amount: finalDepositAmount,
|
|
3725
3914
|
// 使用最终确定的定金金额(手动设置优先)
|
|
3726
3915
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
@@ -4341,7 +4530,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4341
4530
|
}, {
|
|
4342
4531
|
key: "resetStoreState",
|
|
4343
4532
|
value: function resetStoreState() {
|
|
4344
|
-
var
|
|
4533
|
+
var _this7 = this;
|
|
4345
4534
|
try {
|
|
4346
4535
|
var prevOrderInfo = this.store.currentOrder ? {
|
|
4347
4536
|
uuid: this.store.currentOrder.uuid,
|
|
@@ -4376,7 +4565,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4376
4565
|
// 使用 setTimeout 确保事件处理不会阻塞状态重置
|
|
4377
4566
|
if (prevOrderInfo) {
|
|
4378
4567
|
setTimeout(function () {
|
|
4379
|
-
|
|
4568
|
+
_this7.core.effects.emit("".concat(_this7.name, ":onOrderCleared"), {
|
|
4380
4569
|
previousOrder: prevOrderInfo,
|
|
4381
4570
|
timestamp: Date.now()
|
|
4382
4571
|
});
|