@pisell/pisellos 0.0.299 → 0.0.301
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.
|
@@ -674,7 +674,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
674
674
|
value: (function () {
|
|
675
675
|
var _updateLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
676
676
|
var _params$orderData6, _params$orderData7, _params$cartSummary2, _params$totalInfo5, _params$totalInfo6, _params$totalInfo7, _params$totalInfo8;
|
|
677
|
-
var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, updated, created;
|
|
677
|
+
var validation, amountInfo, customerInfo, allOrders, existingOrder, _updated$payment, totalAmount, activePayments, paidAmount, remaining, _isNeedDeposit, updated, isNeedDeposit, created;
|
|
678
678
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
679
679
|
while (1) switch (_context10.prev = _context10.next) {
|
|
680
680
|
case 0:
|
|
@@ -727,7 +727,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
727
727
|
return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
|
|
728
728
|
});
|
|
729
729
|
if (!existingOrder) {
|
|
730
|
-
_context10.next =
|
|
730
|
+
_context10.next = 40;
|
|
731
731
|
break;
|
|
732
732
|
}
|
|
733
733
|
// 基于现有支付项计算新的 expect_amount
|
|
@@ -740,12 +740,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
740
740
|
var rounding = new Decimal(p.rounding_amount || '0').abs();
|
|
741
741
|
return sum.plus(amt).plus(rounding);
|
|
742
742
|
}, new Decimal(0));
|
|
743
|
-
remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); //
|
|
744
|
-
|
|
743
|
+
remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
744
|
+
_isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新到支付模块(使用 uuid,不修改 payment 列表)
|
|
745
|
+
_context10.next = 27;
|
|
745
746
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
746
747
|
total_amount: amountInfo.totalAmount,
|
|
747
|
-
is_deposit:
|
|
748
|
-
deposit_amount:
|
|
748
|
+
is_deposit: _isNeedDeposit.hasDeposit ? 1 : 0,
|
|
749
|
+
deposit_amount: _isNeedDeposit.total ? _isNeedDeposit.total.toString() : '0.00',
|
|
749
750
|
expect_amount: remaining,
|
|
750
751
|
order_info: {
|
|
751
752
|
original_order_data: params.orderData,
|
|
@@ -758,21 +759,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
759
|
amount_breakdown: amountInfo
|
|
759
760
|
}
|
|
760
761
|
});
|
|
761
|
-
case
|
|
762
|
-
_context10.next =
|
|
762
|
+
case 27:
|
|
763
|
+
_context10.next = 29;
|
|
763
764
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
764
|
-
case
|
|
765
|
+
case 29:
|
|
765
766
|
updated = _context10.sent;
|
|
766
767
|
if (updated) {
|
|
767
|
-
_context10.next =
|
|
768
|
+
_context10.next = 32;
|
|
768
769
|
break;
|
|
769
770
|
}
|
|
770
771
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
771
|
-
case
|
|
772
|
+
case 32:
|
|
772
773
|
this.store.currentOrder = updated;
|
|
773
|
-
_context10.next =
|
|
774
|
+
_context10.next = 35;
|
|
774
775
|
return this.updateStateAmountToRemaining(false);
|
|
775
|
-
case
|
|
776
|
+
case 35:
|
|
776
777
|
this.logInfo('本地订单更新成功(保留支付项):', {
|
|
777
778
|
orderId: params.orderId,
|
|
778
779
|
uuid: updated.uuid,
|
|
@@ -782,23 +783,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
782
783
|
});
|
|
783
784
|
|
|
784
785
|
// 事件通知(复用创建事件,便于上层监听刷新)
|
|
785
|
-
_context10.next =
|
|
786
|
+
_context10.next = 38;
|
|
786
787
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
787
788
|
order: updated,
|
|
788
789
|
timestamp: Date.now()
|
|
789
790
|
});
|
|
790
|
-
case
|
|
791
|
+
case 38:
|
|
791
792
|
this.initWalletData({
|
|
792
793
|
order_wait_pay_amount: Number(updated.expect_amount)
|
|
793
794
|
});
|
|
794
795
|
return _context10.abrupt("return", updated);
|
|
795
|
-
case
|
|
796
|
-
|
|
796
|
+
case 40:
|
|
797
|
+
// 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
798
|
+
isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
|
|
799
|
+
_context10.next = 43;
|
|
797
800
|
return this.payment.createPaymentOrderAsync({
|
|
798
801
|
order_id: String(params.orderId),
|
|
799
802
|
total_amount: amountInfo.totalAmount,
|
|
800
|
-
is_deposit:
|
|
801
|
-
deposit_amount:
|
|
803
|
+
is_deposit: isNeedDeposit.hasDeposit ? 1 : 0,
|
|
804
|
+
deposit_amount: isNeedDeposit.total ? isNeedDeposit.total.toString() : '0.00',
|
|
802
805
|
order_info: {
|
|
803
806
|
original_order_data: params.orderData,
|
|
804
807
|
cart_summary: params.cartSummary,
|
|
@@ -810,15 +813,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
810
813
|
amount_breakdown: amountInfo
|
|
811
814
|
}
|
|
812
815
|
});
|
|
813
|
-
case
|
|
816
|
+
case 43:
|
|
814
817
|
created = _context10.sent;
|
|
815
818
|
this.store.currentOrder = created;
|
|
816
|
-
_context10.next =
|
|
819
|
+
_context10.next = 47;
|
|
817
820
|
return this.updateStateAmountToRemaining();
|
|
818
|
-
case
|
|
821
|
+
case 47:
|
|
819
822
|
this.initWalletData();
|
|
820
823
|
return _context10.abrupt("return", created);
|
|
821
|
-
case
|
|
824
|
+
case 49:
|
|
822
825
|
case "end":
|
|
823
826
|
return _context10.stop();
|
|
824
827
|
}
|
|
@@ -1669,15 +1672,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1669
1672
|
updateParams = {
|
|
1670
1673
|
is_deposit: newDepositValue
|
|
1671
1674
|
}; // 如果从定金改为全款,可以清空定金金额
|
|
1672
|
-
if (
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1675
|
+
// if (
|
|
1676
|
+
// isDeposit === 0 &&
|
|
1677
|
+
// this.store.currentOrder.deposit_amount !== '0.00'
|
|
1678
|
+
// ) {
|
|
1679
|
+
// updateParams.deposit_amount = '0.00';
|
|
1680
|
+
// this.logInfo('订单从定金改为全款,清空定金金额');
|
|
1681
|
+
// }
|
|
1677
1682
|
// 调用 Payment 模块更新订单
|
|
1678
|
-
_context19.next =
|
|
1683
|
+
_context19.next = 13;
|
|
1679
1684
|
return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
|
|
1680
|
-
case
|
|
1685
|
+
case 13:
|
|
1681
1686
|
// 更新本地缓存的订单对象
|
|
1682
1687
|
this.store.currentOrder = _objectSpread(_objectSpread({}, this.store.currentOrder), updateParams);
|
|
1683
1688
|
|
|
@@ -1688,31 +1693,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1688
1693
|
this.updateStateAmountToRemaining();
|
|
1689
1694
|
|
|
1690
1695
|
// 触发订单更新事件
|
|
1691
|
-
_context19.next =
|
|
1696
|
+
_context19.next = 18;
|
|
1692
1697
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1693
1698
|
order: this.store.currentOrder,
|
|
1694
1699
|
timestamp: Date.now()
|
|
1695
1700
|
});
|
|
1696
|
-
case
|
|
1701
|
+
case 18:
|
|
1697
1702
|
this.logInfo('订单定金状态更新成功:', {
|
|
1698
1703
|
isDeposit: newDepositValue,
|
|
1699
1704
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
1700
1705
|
});
|
|
1701
|
-
_context19.next =
|
|
1706
|
+
_context19.next = 27;
|
|
1702
1707
|
break;
|
|
1703
|
-
case
|
|
1704
|
-
_context19.prev =
|
|
1708
|
+
case 21:
|
|
1709
|
+
_context19.prev = 21;
|
|
1705
1710
|
_context19.t0 = _context19["catch"](0);
|
|
1706
1711
|
this.logError('更新订单定金状态失败:', _context19.t0);
|
|
1707
|
-
_context19.next =
|
|
1712
|
+
_context19.next = 26;
|
|
1708
1713
|
return this.handleError(_context19.t0, CheckoutErrorType.ValidationFailed);
|
|
1709
|
-
case
|
|
1714
|
+
case 26:
|
|
1710
1715
|
throw _context19.t0;
|
|
1711
|
-
case
|
|
1716
|
+
case 27:
|
|
1712
1717
|
case "end":
|
|
1713
1718
|
return _context19.stop();
|
|
1714
1719
|
}
|
|
1715
|
-
}, _callee19, this, [[0,
|
|
1720
|
+
}, _callee19, this, [[0, 21]]);
|
|
1716
1721
|
}));
|
|
1717
1722
|
function updateOrderDepositStatusAsync(_x18) {
|
|
1718
1723
|
return _updateOrderDepositStatusAsync.apply(this, arguments);
|
|
@@ -488,6 +488,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
488
488
|
discount.tag = discount.type;
|
|
489
489
|
}
|
|
490
490
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
491
|
+
name: discount.name || discount.discount.title.auto,
|
|
491
492
|
isEditMode: true,
|
|
492
493
|
limited_relation_product_data: {},
|
|
493
494
|
savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.num) || 1),
|
|
@@ -480,10 +480,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
480
480
|
const remaining = import_decimal.default.max(0, totalAmount.minus(paidAmount)).toFixed(
|
|
481
481
|
2
|
|
482
482
|
);
|
|
483
|
+
const isNeedDeposit2 = this.checkIsNeedDepositAsync(
|
|
484
|
+
params.orderData.bookings,
|
|
485
|
+
params.orderData.relation_products
|
|
486
|
+
);
|
|
483
487
|
await this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
484
488
|
total_amount: amountInfo.totalAmount,
|
|
485
|
-
is_deposit:
|
|
486
|
-
deposit_amount:
|
|
489
|
+
is_deposit: isNeedDeposit2.hasDeposit ? 1 : 0,
|
|
490
|
+
deposit_amount: isNeedDeposit2.total ? isNeedDeposit2.total.toString() : "0.00",
|
|
487
491
|
expect_amount: remaining,
|
|
488
492
|
order_info: {
|
|
489
493
|
original_order_data: params.orderData,
|
|
@@ -522,11 +526,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
522
526
|
});
|
|
523
527
|
return updated;
|
|
524
528
|
}
|
|
529
|
+
const isNeedDeposit = this.checkIsNeedDepositAsync(
|
|
530
|
+
params.orderData.bookings,
|
|
531
|
+
params.orderData.relation_products
|
|
532
|
+
);
|
|
525
533
|
const created = await this.payment.createPaymentOrderAsync({
|
|
526
534
|
order_id: String(params.orderId),
|
|
527
535
|
total_amount: amountInfo.totalAmount,
|
|
528
|
-
is_deposit:
|
|
529
|
-
deposit_amount:
|
|
536
|
+
is_deposit: isNeedDeposit.hasDeposit ? 1 : 0,
|
|
537
|
+
deposit_amount: isNeedDeposit.total ? isNeedDeposit.total.toString() : "0.00",
|
|
530
538
|
order_info: {
|
|
531
539
|
original_order_data: params.orderData,
|
|
532
540
|
cart_summary: params.cartSummary,
|
|
@@ -1081,10 +1089,6 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1081
1089
|
const updateParams = {
|
|
1082
1090
|
is_deposit: newDepositValue
|
|
1083
1091
|
};
|
|
1084
|
-
if (isDeposit === 0 && this.store.currentOrder.deposit_amount !== "0.00") {
|
|
1085
|
-
updateParams.deposit_amount = "0.00";
|
|
1086
|
-
this.logInfo("订单从定金改为全款,清空定金金额");
|
|
1087
|
-
}
|
|
1088
1092
|
await this.payment.updateOrderAsync(
|
|
1089
1093
|
this.store.currentOrder.uuid,
|
|
1090
1094
|
updateParams
|
|
@@ -324,6 +324,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
324
324
|
}
|
|
325
325
|
editModeDiscountList.push({
|
|
326
326
|
...discount,
|
|
327
|
+
name: discount.name || discount.discount.title.auto,
|
|
327
328
|
isEditMode: true,
|
|
328
329
|
limited_relation_product_data: {},
|
|
329
330
|
savedAmount: discount.amount * ((product == null ? void 0 : product.num) || 1),
|