@pisell/pisellos 0.0.258 → 0.0.260
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/walletpass.js +2 -3
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +73 -42
- package/dist/solution/Checkout/types.d.ts +3 -1
- package/dist/solution/Checkout/types.js +1 -0
- package/lib/modules/Payment/walletpass.js +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +29 -5
- package/lib/solution/Checkout/types.d.ts +3 -1
- package/lib/solution/Checkout/types.js +1 -0
- package/package.json +1 -1
|
@@ -406,9 +406,8 @@ export var WalletPassPaymentImpl = /*#__PURE__*/function () {
|
|
|
406
406
|
});
|
|
407
407
|
|
|
408
408
|
// 检查识别码是否为9位且前3位为"000"
|
|
409
|
-
|
|
410
|
-
//
|
|
411
|
-
isWalletCode = code.startsWith('WL');
|
|
409
|
+
isWalletCode = code.length === 9 && code.startsWith('000'); // 测试环境先使用 WL
|
|
410
|
+
// const isWalletCode = code.startsWith('WL');
|
|
412
411
|
if (!isWalletCode) {
|
|
413
412
|
_context5.next = 14;
|
|
414
413
|
break;
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
314
314
|
}[];
|
|
315
315
|
setOtherData(key: string, value: any): void;
|
|
316
316
|
getOtherData(key: string): any;
|
|
317
|
-
getProductTypeById(id: number): Promise<"
|
|
317
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
318
318
|
/**
|
|
319
319
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
320
320
|
*
|
|
@@ -1099,9 +1099,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1099
1099
|
return this.updateStateAmountToRemaining();
|
|
1100
1100
|
case 31:
|
|
1101
1101
|
_context15.next = 33;
|
|
1102
|
-
return this.core.effects.emit(CheckoutHooks.
|
|
1102
|
+
return this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
|
|
1103
1103
|
orderUuid: this.store.currentOrder.uuid,
|
|
1104
1104
|
paymentMethodCode: paymentItem.code,
|
|
1105
|
+
paymentMethodName: paymentItem.name,
|
|
1105
1106
|
amount: String(paymentItem.amount),
|
|
1106
1107
|
timestamp: Date.now()
|
|
1107
1108
|
});
|
|
@@ -1743,7 +1744,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1743
1744
|
case 8:
|
|
1744
1745
|
allPaymentItems = _context21.sent;
|
|
1745
1746
|
_context21.next = 11;
|
|
1746
|
-
return this.syncOrderToBackendWithReturn(
|
|
1747
|
+
return this.syncOrderToBackendWithReturn(true, allPaymentItems);
|
|
1747
1748
|
case 11:
|
|
1748
1749
|
syncResult = _context21.sent;
|
|
1749
1750
|
this.logInfo('保存订单完成:', {
|
|
@@ -2673,8 +2674,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2673
2674
|
value: (function () {
|
|
2674
2675
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2675
2676
|
var _this4 = this,
|
|
2676
|
-
_this$store$currentCu2,
|
|
2677
2677
|
_this$store$currentOr17,
|
|
2678
|
+
_this$store$currentCu2,
|
|
2678
2679
|
_this$store$currentOr18,
|
|
2679
2680
|
_checkoutResponse3,
|
|
2680
2681
|
_checkoutResponse4;
|
|
@@ -2684,6 +2685,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2684
2685
|
isUpdateOperation,
|
|
2685
2686
|
paymentItems,
|
|
2686
2687
|
processedPaymentItems,
|
|
2688
|
+
depositPaymentItems,
|
|
2689
|
+
calculatedDepositAmount,
|
|
2687
2690
|
orderParams,
|
|
2688
2691
|
startTime,
|
|
2689
2692
|
checkoutResponse,
|
|
@@ -2747,7 +2750,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2747
2750
|
shop_wallet_pass_id: ((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.shop_wallet_pass_id) || _this4.otherParams.shop_wallet_pass_id
|
|
2748
2751
|
})
|
|
2749
2752
|
});
|
|
2750
|
-
}); //
|
|
2753
|
+
}); // 计算定金支付项的总金额(order_payment_type="deposit")
|
|
2754
|
+
depositPaymentItems = processedPaymentItems.filter(function (item) {
|
|
2755
|
+
return item.order_payment_type === 'deposit' && item.status !== 'voided';
|
|
2756
|
+
});
|
|
2757
|
+
calculatedDepositAmount = depositPaymentItems.reduce(function (sum, item) {
|
|
2758
|
+
var amount = new Decimal(item.amount || '0');
|
|
2759
|
+
var roundingAmount = new Decimal(item.rounding_amount || '0');
|
|
2760
|
+
// 包含抹零计算的有效支付金额
|
|
2761
|
+
var effectiveAmount = amount.add(roundingAmount.abs());
|
|
2762
|
+
return sum.add(effectiveAmount);
|
|
2763
|
+
}, new Decimal(0)).toFixed(2);
|
|
2764
|
+
this.logInfo('计算定金支付项总金额', {
|
|
2765
|
+
depositPaymentItemsCount: depositPaymentItems.length,
|
|
2766
|
+
depositPaymentItems: depositPaymentItems.map(function (item) {
|
|
2767
|
+
return {
|
|
2768
|
+
uuid: item.uuid,
|
|
2769
|
+
code: item.code,
|
|
2770
|
+
amount: item.amount,
|
|
2771
|
+
rounding_amount: item.rounding_amount,
|
|
2772
|
+
order_payment_type: item.order_payment_type,
|
|
2773
|
+
status: item.status
|
|
2774
|
+
};
|
|
2775
|
+
}),
|
|
2776
|
+
calculatedDepositAmount: calculatedDepositAmount,
|
|
2777
|
+
originalDepositAmount: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.deposit_amount) || '0.00'
|
|
2778
|
+
});
|
|
2779
|
+
|
|
2780
|
+
// 构造订单参数,直接使用 localOrderData 中已处理好的数据
|
|
2751
2781
|
orderParams = _objectSpread(_objectSpread({}, this.store.localOrderData), {}, {
|
|
2752
2782
|
type: this.store.localOrderData.type,
|
|
2753
2783
|
platform: this.store.localOrderData.platform,
|
|
@@ -2766,8 +2796,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2766
2796
|
currency_code: this.otherParams.currency_code,
|
|
2767
2797
|
currency_symbol: this.otherParams.currency_symbol,
|
|
2768
2798
|
currency_format: this.otherParams.currency_format,
|
|
2769
|
-
is_deposit: ((_this$store$
|
|
2770
|
-
deposit_amount:
|
|
2799
|
+
is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0,
|
|
2800
|
+
deposit_amount: calculatedDepositAmount,
|
|
2801
|
+
// 使用从支付项中计算出的定金金额
|
|
2771
2802
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
2772
2803
|
note: this.store.localOrderData.shop_note
|
|
2773
2804
|
}); // 如果是更新操作,需要在参数中包含真实的订单ID
|
|
@@ -2782,7 +2813,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2782
2813
|
|
|
2783
2814
|
// 发送下单接口请求开始事件
|
|
2784
2815
|
startTime = Date.now();
|
|
2785
|
-
_context34.next =
|
|
2816
|
+
_context34.next = 23;
|
|
2786
2817
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
2787
2818
|
orderUuid: this.store.currentOrder.uuid,
|
|
2788
2819
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -2790,9 +2821,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2790
2821
|
paymentItemCount: paymentItems.length,
|
|
2791
2822
|
timestamp: startTime
|
|
2792
2823
|
});
|
|
2793
|
-
case
|
|
2824
|
+
case 23:
|
|
2794
2825
|
submitSuccess = false;
|
|
2795
|
-
_context34.prev =
|
|
2826
|
+
_context34.prev = 24;
|
|
2796
2827
|
// 记录接口调用参数
|
|
2797
2828
|
this.logInfo('Calling backend checkout API', _objectSpread({
|
|
2798
2829
|
url: '/order/checkout',
|
|
@@ -2800,23 +2831,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2800
2831
|
}, orderParams));
|
|
2801
2832
|
|
|
2802
2833
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
2803
|
-
_context34.next =
|
|
2834
|
+
_context34.next = 28;
|
|
2804
2835
|
return this.order.createOrderByCheckout(orderParams);
|
|
2805
|
-
case
|
|
2836
|
+
case 28:
|
|
2806
2837
|
checkoutResponse = _context34.sent;
|
|
2807
2838
|
submitSuccess = true;
|
|
2808
2839
|
this.logInfo('下单接口调用成功', checkoutResponse);
|
|
2809
|
-
_context34.next =
|
|
2840
|
+
_context34.next = 41;
|
|
2810
2841
|
break;
|
|
2811
|
-
case
|
|
2812
|
-
_context34.prev =
|
|
2813
|
-
_context34.t1 = _context34["catch"](
|
|
2842
|
+
case 33:
|
|
2843
|
+
_context34.prev = 33;
|
|
2844
|
+
_context34.t1 = _context34["catch"](24);
|
|
2814
2845
|
submitSuccess = false;
|
|
2815
2846
|
submitError = _context34.t1 instanceof Error ? _context34.t1.message : String(_context34.t1);
|
|
2816
2847
|
this.logError('下单接口调用失败:', submitError);
|
|
2817
2848
|
|
|
2818
2849
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
2819
|
-
_context34.next =
|
|
2850
|
+
_context34.next = 40;
|
|
2820
2851
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
2821
2852
|
orderUuid: this.store.currentOrder.uuid,
|
|
2822
2853
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -2826,11 +2857,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2826
2857
|
duration: Date.now() - startTime,
|
|
2827
2858
|
timestamp: Date.now()
|
|
2828
2859
|
});
|
|
2829
|
-
case
|
|
2860
|
+
case 40:
|
|
2830
2861
|
throw _context34.t1;
|
|
2831
|
-
case
|
|
2832
|
-
_context34.prev =
|
|
2833
|
-
_context34.next =
|
|
2862
|
+
case 41:
|
|
2863
|
+
_context34.prev = 41;
|
|
2864
|
+
_context34.next = 44;
|
|
2834
2865
|
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
2835
2866
|
success: submitSuccess,
|
|
2836
2867
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -2841,18 +2872,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2841
2872
|
duration: Date.now() - startTime,
|
|
2842
2873
|
timestamp: Date.now()
|
|
2843
2874
|
});
|
|
2844
|
-
case
|
|
2845
|
-
return _context34.finish(
|
|
2846
|
-
case
|
|
2875
|
+
case 44:
|
|
2876
|
+
return _context34.finish(41);
|
|
2877
|
+
case 45:
|
|
2847
2878
|
// 检查响应状态是否为成功状态
|
|
2848
2879
|
responseStatus = (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status;
|
|
2849
2880
|
isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === 'success' || responseStatus === 1 && ((_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code) === 200;
|
|
2850
2881
|
if (isSuccessResponse) {
|
|
2851
|
-
_context34.next =
|
|
2882
|
+
_context34.next = 52;
|
|
2852
2883
|
break;
|
|
2853
2884
|
}
|
|
2854
2885
|
errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
2855
|
-
_context34.next =
|
|
2886
|
+
_context34.next = 51;
|
|
2856
2887
|
return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
|
|
2857
2888
|
orderUuid: this.store.currentOrder.uuid,
|
|
2858
2889
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -2863,18 +2894,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2863
2894
|
duration: Date.now() - startTime,
|
|
2864
2895
|
timestamp: Date.now()
|
|
2865
2896
|
});
|
|
2866
|
-
case
|
|
2897
|
+
case 51:
|
|
2867
2898
|
throw new Error(errorMessage);
|
|
2868
|
-
case
|
|
2899
|
+
case 52:
|
|
2869
2900
|
if (!isUpdateOperation) {
|
|
2870
|
-
_context34.next =
|
|
2901
|
+
_context34.next = 56;
|
|
2871
2902
|
break;
|
|
2872
2903
|
}
|
|
2873
2904
|
// 更新操作:使用现有的订单ID
|
|
2874
2905
|
realOrderId = currentOrderId;
|
|
2875
|
-
_context34.next =
|
|
2906
|
+
_context34.next = 75;
|
|
2876
2907
|
break;
|
|
2877
|
-
case
|
|
2908
|
+
case 56:
|
|
2878
2909
|
// 创建操作:从响应中提取新的订单ID
|
|
2879
2910
|
extractedOrderId = (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 || (_checkoutResponse6 = _checkoutResponse6.data) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
2880
2911
|
if (!extractedOrderId) {
|
|
@@ -2896,10 +2927,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2896
2927
|
oldOrderId: this.store.currentOrder.order_id,
|
|
2897
2928
|
newOrderId: realOrderId
|
|
2898
2929
|
});
|
|
2899
|
-
_context34.prev =
|
|
2900
|
-
_context34.next =
|
|
2930
|
+
_context34.prev = 62;
|
|
2931
|
+
_context34.next = 65;
|
|
2901
2932
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
2902
|
-
case
|
|
2933
|
+
case 65:
|
|
2903
2934
|
updatedOrder = _context34.sent;
|
|
2904
2935
|
this.logInfo('Payment模块替换订单ID结果:', {
|
|
2905
2936
|
wasSuccessful: !!updatedOrder,
|
|
@@ -2926,22 +2957,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2926
2957
|
目标ID: realOrderId
|
|
2927
2958
|
});
|
|
2928
2959
|
}
|
|
2929
|
-
_context34.next =
|
|
2960
|
+
_context34.next = 75;
|
|
2930
2961
|
break;
|
|
2931
|
-
case
|
|
2932
|
-
_context34.prev =
|
|
2933
|
-
_context34.t2 = _context34["catch"](
|
|
2962
|
+
case 70:
|
|
2963
|
+
_context34.prev = 70;
|
|
2964
|
+
_context34.t2 = _context34["catch"](62);
|
|
2934
2965
|
this.logError('调用Payment模块替换订单ID时发生错误:', _context34.t2);
|
|
2935
2966
|
|
|
2936
2967
|
// 发生错误时也进行手动替换
|
|
2937
2968
|
this.store.currentOrder.order_id = realOrderId;
|
|
2938
2969
|
this.logInfo('错误恢复:手动设置订单ID:', realOrderId);
|
|
2939
|
-
case
|
|
2970
|
+
case 75:
|
|
2940
2971
|
// 标记订单已同步
|
|
2941
2972
|
this.store.isOrderSynced = true;
|
|
2942
2973
|
|
|
2943
2974
|
// 触发订单同步完成事件
|
|
2944
|
-
_context34.next =
|
|
2975
|
+
_context34.next = 78;
|
|
2945
2976
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
2946
2977
|
orderUuid: this.store.currentOrder.uuid,
|
|
2947
2978
|
realOrderId: realOrderId,
|
|
@@ -2950,18 +2981,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2950
2981
|
isManual: isManual,
|
|
2951
2982
|
response: checkoutResponse
|
|
2952
2983
|
});
|
|
2953
|
-
case
|
|
2984
|
+
case 78:
|
|
2954
2985
|
return _context34.abrupt("return", {
|
|
2955
2986
|
success: true,
|
|
2956
2987
|
orderId: realOrderId,
|
|
2957
2988
|
orderUuid: this.store.currentOrder.uuid,
|
|
2958
2989
|
response: checkoutResponse
|
|
2959
2990
|
});
|
|
2960
|
-
case
|
|
2991
|
+
case 79:
|
|
2961
2992
|
case "end":
|
|
2962
2993
|
return _context34.stop();
|
|
2963
2994
|
}
|
|
2964
|
-
}, _callee34, this, [[
|
|
2995
|
+
}, _callee34, this, [[24, 33, 41, 45], [62, 70]]);
|
|
2965
2996
|
}));
|
|
2966
2997
|
function syncOrderToBackendWithReturn() {
|
|
2967
2998
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -300,7 +300,9 @@ export declare enum CheckoutHooks {
|
|
|
300
300
|
/** 下单接口请求完成 */
|
|
301
301
|
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd",
|
|
302
302
|
/** 钱包数据初始化完成 */
|
|
303
|
-
OnWalletDataInitialized = "checkout:onWalletDataInitialized"
|
|
303
|
+
OnWalletDataInitialized = "checkout:onWalletDataInitialized",
|
|
304
|
+
/** 支付项添加成功 */
|
|
305
|
+
OnPaymentItemAdded = "checkout:onPaymentItemAdded"
|
|
304
306
|
}
|
|
305
307
|
/**
|
|
306
308
|
* 结账状态数据
|
|
@@ -75,6 +75,7 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
|
|
|
75
75
|
CheckoutHooks["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
|
|
76
76
|
CheckoutHooks["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
|
|
77
77
|
CheckoutHooks["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
|
|
78
|
+
CheckoutHooks["OnPaymentItemAdded"] = "checkout:onPaymentItemAdded";
|
|
78
79
|
return CheckoutHooks;
|
|
79
80
|
}({});
|
|
80
81
|
|
|
@@ -268,7 +268,7 @@ var WalletPassPaymentImpl = class {
|
|
|
268
268
|
code_length: code.length,
|
|
269
269
|
noCache: config.noCache || false
|
|
270
270
|
});
|
|
271
|
-
const isWalletCode = code.startsWith("
|
|
271
|
+
const isWalletCode = code.length === 9 && code.startsWith("000");
|
|
272
272
|
if (isWalletCode) {
|
|
273
273
|
const walletDetailParams = {
|
|
274
274
|
code,
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "session" | "normal";
|
|
53
53
|
}
|
|
@@ -314,7 +314,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
314
314
|
}[];
|
|
315
315
|
setOtherData(key: string, value: any): void;
|
|
316
316
|
getOtherData(key: string): any;
|
|
317
|
-
getProductTypeById(id: number): Promise<"
|
|
317
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
318
318
|
/**
|
|
319
319
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
320
320
|
*
|
|
@@ -665,9 +665,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
667
|
await this.updateStateAmountToRemaining();
|
|
668
|
-
await this.core.effects.emit(import_types.CheckoutHooks.
|
|
668
|
+
await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentItemAdded, {
|
|
669
669
|
orderUuid: this.store.currentOrder.uuid,
|
|
670
670
|
paymentMethodCode: paymentItem.code,
|
|
671
|
+
paymentMethodName: paymentItem.name,
|
|
671
672
|
amount: String(paymentItem.amount),
|
|
672
673
|
timestamp: Date.now()
|
|
673
674
|
});
|
|
@@ -1103,7 +1104,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1103
1104
|
this.store.currentOrder.uuid
|
|
1104
1105
|
);
|
|
1105
1106
|
const syncResult = await this.syncOrderToBackendWithReturn(
|
|
1106
|
-
|
|
1107
|
+
true,
|
|
1107
1108
|
allPaymentItems
|
|
1108
1109
|
);
|
|
1109
1110
|
this.logInfo("保存订单完成:", {
|
|
@@ -1636,13 +1637,35 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1636
1637
|
}
|
|
1637
1638
|
};
|
|
1638
1639
|
});
|
|
1640
|
+
const depositPaymentItems = processedPaymentItems.filter(
|
|
1641
|
+
(item) => item.order_payment_type === "deposit" && item.status !== "voided"
|
|
1642
|
+
);
|
|
1643
|
+
const calculatedDepositAmount = depositPaymentItems.reduce((sum, item) => {
|
|
1644
|
+
const amount = new import_decimal.default(item.amount || "0");
|
|
1645
|
+
const roundingAmount = new import_decimal.default(item.rounding_amount || "0");
|
|
1646
|
+
const effectiveAmount = amount.add(roundingAmount.abs());
|
|
1647
|
+
return sum.add(effectiveAmount);
|
|
1648
|
+
}, new import_decimal.default(0)).toFixed(2);
|
|
1649
|
+
this.logInfo("计算定金支付项总金额", {
|
|
1650
|
+
depositPaymentItemsCount: depositPaymentItems.length,
|
|
1651
|
+
depositPaymentItems: depositPaymentItems.map((item) => ({
|
|
1652
|
+
uuid: item.uuid,
|
|
1653
|
+
code: item.code,
|
|
1654
|
+
amount: item.amount,
|
|
1655
|
+
rounding_amount: item.rounding_amount,
|
|
1656
|
+
order_payment_type: item.order_payment_type,
|
|
1657
|
+
status: item.status
|
|
1658
|
+
})),
|
|
1659
|
+
calculatedDepositAmount,
|
|
1660
|
+
originalDepositAmount: ((_a = this.store.currentOrder) == null ? void 0 : _a.deposit_amount) || "0.00"
|
|
1661
|
+
});
|
|
1639
1662
|
const orderParams = {
|
|
1640
1663
|
...this.store.localOrderData,
|
|
1641
1664
|
type: this.store.localOrderData.type,
|
|
1642
1665
|
platform: this.store.localOrderData.platform,
|
|
1643
1666
|
payments: processedPaymentItems,
|
|
1644
1667
|
// 使用处理过的支付项数据
|
|
1645
|
-
customer_id: (
|
|
1668
|
+
customer_id: (_b = this.store.currentCustomer) == null ? void 0 : _b.customer_id,
|
|
1646
1669
|
// 添加客户ID
|
|
1647
1670
|
is_price_include_tax: this.otherParams.is_price_include_tax,
|
|
1648
1671
|
// core 有
|
|
@@ -1655,8 +1678,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1655
1678
|
currency_code: this.otherParams.currency_code,
|
|
1656
1679
|
currency_symbol: this.otherParams.currency_symbol,
|
|
1657
1680
|
currency_format: this.otherParams.currency_format,
|
|
1658
|
-
is_deposit: ((
|
|
1659
|
-
deposit_amount:
|
|
1681
|
+
is_deposit: ((_c = this.store.currentOrder) == null ? void 0 : _c.is_deposit) || 0,
|
|
1682
|
+
deposit_amount: calculatedDepositAmount,
|
|
1683
|
+
// 使用从支付项中计算出的定金金额
|
|
1660
1684
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
1661
1685
|
note: this.store.localOrderData.shop_note
|
|
1662
1686
|
};
|
|
@@ -300,7 +300,9 @@ export declare enum CheckoutHooks {
|
|
|
300
300
|
/** 下单接口请求完成 */
|
|
301
301
|
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd",
|
|
302
302
|
/** 钱包数据初始化完成 */
|
|
303
|
-
OnWalletDataInitialized = "checkout:onWalletDataInitialized"
|
|
303
|
+
OnWalletDataInitialized = "checkout:onWalletDataInitialized",
|
|
304
|
+
/** 支付项添加成功 */
|
|
305
|
+
OnPaymentItemAdded = "checkout:onPaymentItemAdded"
|
|
304
306
|
}
|
|
305
307
|
/**
|
|
306
308
|
* 结账状态数据
|
|
@@ -53,6 +53,7 @@ var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
|
|
|
53
53
|
CheckoutHooks2["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
|
|
54
54
|
CheckoutHooks2["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
|
|
55
55
|
CheckoutHooks2["OnWalletDataInitialized"] = "checkout:onWalletDataInitialized";
|
|
56
|
+
CheckoutHooks2["OnPaymentItemAdded"] = "checkout:onPaymentItemAdded";
|
|
56
57
|
return CheckoutHooks2;
|
|
57
58
|
})(CheckoutHooks || {});
|
|
58
59
|
// Annotate the CommonJS export names for ESM import in node:
|