@pisell/pisellos 2.2.49 → 2.2.50
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.
|
@@ -760,6 +760,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
760
760
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
761
761
|
while (1) switch (_context10.prev = _context10.next) {
|
|
762
762
|
case 0:
|
|
763
|
+
debugger;
|
|
763
764
|
this.logInfo('updateLocalOrderAsync called', {
|
|
764
765
|
orderId: params.orderId,
|
|
765
766
|
orderDataType: (_params$orderData6 = params.orderData) === null || _params$orderData6 === void 0 ? void 0 : _params$orderData6.type,
|
|
@@ -771,11 +772,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
771
772
|
// 基础校验
|
|
772
773
|
validation = validateLocalOrderData(params.orderData);
|
|
773
774
|
if (validation.valid) {
|
|
774
|
-
_context10.next =
|
|
775
|
+
_context10.next = 5;
|
|
775
776
|
break;
|
|
776
777
|
}
|
|
777
778
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
778
|
-
case
|
|
779
|
+
case 5:
|
|
779
780
|
// 计算金额
|
|
780
781
|
amountInfo = extractAmountFromCartSummary(params.cartSummary); // 规范化补充字段
|
|
781
782
|
params.orderData.created_at = formatDateTime(new Date());
|
|
@@ -801,19 +802,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
801
802
|
}
|
|
802
803
|
|
|
803
804
|
// 保留原有支付项:通过 orderId 找到现有订单(按 id 或 order_id 匹配)
|
|
804
|
-
_context10.next =
|
|
805
|
+
_context10.next = 18;
|
|
805
806
|
return this.payment.getOrderListAsync();
|
|
806
|
-
case
|
|
807
|
+
case 18:
|
|
807
808
|
allOrders = _context10.sent;
|
|
808
809
|
existingOrder = allOrders.find(function (o) {
|
|
809
810
|
return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
|
|
810
811
|
});
|
|
811
812
|
if (!existingOrder) {
|
|
812
|
-
_context10.next =
|
|
813
|
+
_context10.next = 72;
|
|
813
814
|
break;
|
|
814
815
|
}
|
|
815
816
|
if (!(params.existPayment && params.existPayment.length > 0)) {
|
|
816
|
-
_context10.next =
|
|
817
|
+
_context10.next = 48;
|
|
817
818
|
break;
|
|
818
819
|
}
|
|
819
820
|
this.logInfo('检测到云端支付项,将替换本地订单的支付项列表', {
|
|
@@ -837,7 +838,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
837
838
|
});
|
|
838
839
|
}); // 计算是否需要支付定金
|
|
839
840
|
_isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新订单,替换支付项列表
|
|
840
|
-
_context10.next =
|
|
841
|
+
_context10.next = 29;
|
|
841
842
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
842
843
|
total_amount: amountInfo.totalAmount,
|
|
843
844
|
is_deposit: _isNeedDeposit.hasDeposit ? 1 : 0,
|
|
@@ -855,21 +856,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
855
856
|
amount_breakdown: amountInfo
|
|
856
857
|
}
|
|
857
858
|
});
|
|
858
|
-
case
|
|
859
|
-
_context10.next =
|
|
859
|
+
case 29:
|
|
860
|
+
_context10.next = 31;
|
|
860
861
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
861
|
-
case
|
|
862
|
+
case 31:
|
|
862
863
|
_updated = _context10.sent;
|
|
863
864
|
if (_updated) {
|
|
864
|
-
_context10.next =
|
|
865
|
+
_context10.next = 34;
|
|
865
866
|
break;
|
|
866
867
|
}
|
|
867
868
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
868
|
-
case
|
|
869
|
+
case 34:
|
|
869
870
|
this.store.currentOrder = _updated;
|
|
870
|
-
_context10.next =
|
|
871
|
+
_context10.next = 37;
|
|
871
872
|
return this.updateStateAmountToRemaining(false);
|
|
872
|
-
case
|
|
873
|
+
case 37:
|
|
873
874
|
this.logInfo('本地订单更新成功(已替换云端支付项):', {
|
|
874
875
|
orderId: params.orderId,
|
|
875
876
|
uuid: _updated.uuid,
|
|
@@ -880,12 +881,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
880
881
|
});
|
|
881
882
|
|
|
882
883
|
// 事件通知
|
|
883
|
-
_context10.next =
|
|
884
|
+
_context10.next = 40;
|
|
884
885
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
885
886
|
order: _updated,
|
|
886
887
|
timestamp: Date.now()
|
|
887
888
|
});
|
|
888
|
-
case
|
|
889
|
+
case 40:
|
|
889
890
|
// 计算已同步的支付金额
|
|
890
891
|
syncedPayments = _updated.payment.filter(function (p) {
|
|
891
892
|
return p.isSynced && p.status !== 'voided';
|
|
@@ -905,7 +906,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
905
906
|
order_wait_pay_amount: Number(_depositDiffAmount) > 0 ? Number(_depositDiffAmount) : Number(_remainingExpectAmount)
|
|
906
907
|
});
|
|
907
908
|
return _context10.abrupt("return", _updated);
|
|
908
|
-
case
|
|
909
|
+
case 48:
|
|
909
910
|
// 原有逻辑:保留现有支付项
|
|
910
911
|
totalAmount = new Decimal(amountInfo.totalAmount || '0');
|
|
911
912
|
activePayments = (existingOrder.payment || []).filter(function (p) {
|
|
@@ -918,7 +919,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
918
919
|
}, new Decimal(0));
|
|
919
920
|
remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
920
921
|
_isNeedDeposit2 = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新到支付模块(使用 uuid,不修改 payment 列表)
|
|
921
|
-
_context10.next =
|
|
922
|
+
_context10.next = 55;
|
|
922
923
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
923
924
|
total_amount: amountInfo.totalAmount,
|
|
924
925
|
is_deposit: _isNeedDeposit2.hasDeposit ? 1 : 0,
|
|
@@ -935,21 +936,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
935
936
|
amount_breakdown: amountInfo
|
|
936
937
|
}
|
|
937
938
|
});
|
|
938
|
-
case
|
|
939
|
-
_context10.next =
|
|
939
|
+
case 55:
|
|
940
|
+
_context10.next = 57;
|
|
940
941
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
941
|
-
case
|
|
942
|
+
case 57:
|
|
942
943
|
updated = _context10.sent;
|
|
943
944
|
if (updated) {
|
|
944
|
-
_context10.next =
|
|
945
|
+
_context10.next = 60;
|
|
945
946
|
break;
|
|
946
947
|
}
|
|
947
948
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
948
|
-
case
|
|
949
|
+
case 60:
|
|
949
950
|
this.store.currentOrder = updated;
|
|
950
|
-
_context10.next =
|
|
951
|
+
_context10.next = 63;
|
|
951
952
|
return this.updateStateAmountToRemaining(false);
|
|
952
|
-
case
|
|
953
|
+
case 63:
|
|
953
954
|
this.logInfo('本地订单更新成功(保留支付项):', {
|
|
954
955
|
orderId: params.orderId,
|
|
955
956
|
uuid: updated.uuid,
|
|
@@ -959,12 +960,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
959
960
|
});
|
|
960
961
|
|
|
961
962
|
// 事件通知(复用创建事件,便于上层监听刷新)
|
|
962
|
-
_context10.next =
|
|
963
|
+
_context10.next = 66;
|
|
963
964
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
964
965
|
order: updated,
|
|
965
966
|
timestamp: Date.now()
|
|
966
967
|
});
|
|
967
|
-
case
|
|
968
|
+
case 66:
|
|
968
969
|
// 需要减去已经同步给后端的支付过的钱
|
|
969
970
|
syncedAmount = activePayments.reduce(function (sum, p) {
|
|
970
971
|
var amt = new Decimal(p.amount || '0');
|
|
@@ -980,10 +981,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
980
981
|
order_wait_pay_amount: Number(depositDiffAmount) > 0 ? Number(depositDiffAmount) : Number(remainingExpectAmount)
|
|
981
982
|
});
|
|
982
983
|
return _context10.abrupt("return", updated);
|
|
983
|
-
case
|
|
984
|
+
case 72:
|
|
984
985
|
// 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
985
986
|
isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
|
|
986
|
-
_context10.next =
|
|
987
|
+
_context10.next = 75;
|
|
987
988
|
return this.payment.createPaymentOrderAsync({
|
|
988
989
|
order_id: String(params.orderId),
|
|
989
990
|
total_amount: amountInfo.totalAmount,
|
|
@@ -1002,7 +1003,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1002
1003
|
amount_breakdown: amountInfo
|
|
1003
1004
|
}
|
|
1004
1005
|
});
|
|
1005
|
-
case
|
|
1006
|
+
case 75:
|
|
1006
1007
|
created = _context10.sent;
|
|
1007
1008
|
this.store.currentOrder = created;
|
|
1008
1009
|
|
|
@@ -1038,7 +1039,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1038
1039
|
this.initWalletData();
|
|
1039
1040
|
}
|
|
1040
1041
|
return _context10.abrupt("return", created);
|
|
1041
|
-
case
|
|
1042
|
+
case 79:
|
|
1042
1043
|
case "end":
|
|
1043
1044
|
return _context10.stop();
|
|
1044
1045
|
}
|
|
@@ -3134,6 +3135,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3134
3135
|
// 当 rounding_amount 为负数时,表示抹掉的金额,应该按绝对值加到实际支付中
|
|
3135
3136
|
// 例如:amount=15, rounding_amount=-0.2,实际相当于支付了15.2(抹掉了0.2元的零头)
|
|
3136
3137
|
var effectiveAmount = amount.add(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
|
|
3138
|
+
if (payment.service_fee) {
|
|
3139
|
+
effectiveAmount = effectiveAmount.minus(new Decimal(payment.service_fee));
|
|
3140
|
+
}
|
|
3137
3141
|
return sum.add(effectiveAmount);
|
|
3138
3142
|
}, new Decimal(0));
|
|
3139
3143
|
return paidAmount.toFixed(2);
|
|
@@ -507,6 +507,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
507
507
|
*/
|
|
508
508
|
async updateLocalOrderAsync(params) {
|
|
509
509
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
510
|
+
debugger;
|
|
510
511
|
this.logInfo("updateLocalOrderAsync called", {
|
|
511
512
|
orderId: params.orderId,
|
|
512
513
|
orderDataType: (_a = params.orderData) == null ? void 0 : _a.type,
|
|
@@ -2030,7 +2031,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2030
2031
|
const paidAmount = payments.filter((payment) => payment.status !== "voided").reduce((sum, payment) => {
|
|
2031
2032
|
const amount = new import_decimal.default(payment.amount || "0");
|
|
2032
2033
|
const roundingAmount = new import_decimal.default(payment.rounding_amount || "0");
|
|
2033
|
-
|
|
2034
|
+
let effectiveAmount = amount.add(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
|
|
2035
|
+
if (payment.service_fee) {
|
|
2036
|
+
effectiveAmount = effectiveAmount.minus(new import_decimal.default(payment.service_fee));
|
|
2037
|
+
}
|
|
2034
2038
|
return sum.add(effectiveAmount);
|
|
2035
2039
|
}, new import_decimal.default(0));
|
|
2036
2040
|
return paidAmount.toFixed(2);
|