@pisell/pisellos 2.2.50 → 2.2.51
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/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +0 -1
- package/dist/solution/Checkout/index.js +34 -32
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +0 -1
- package/lib/solution/Checkout/index.js +4 -2
- package/package.json +1 -1
|
@@ -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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -1161,7 +1161,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1161
1161
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1162
1162
|
product_variant_id: product_variant_id
|
|
1163
1163
|
});
|
|
1164
|
-
debugger;
|
|
1165
1164
|
// 保护,如果进来的是 session 商品,则必须要有 date 和时间片,否则不允许添加
|
|
1166
1165
|
if (isSessionProduct(productData)) {
|
|
1167
1166
|
if (!date || !date.startTime || !date.endTime) {
|
|
@@ -760,7 +760,6 @@ 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;
|
|
764
763
|
this.logInfo('updateLocalOrderAsync called', {
|
|
765
764
|
orderId: params.orderId,
|
|
766
765
|
orderDataType: (_params$orderData6 = params.orderData) === null || _params$orderData6 === void 0 ? void 0 : _params$orderData6.type,
|
|
@@ -772,11 +771,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
772
771
|
// 基础校验
|
|
773
772
|
validation = validateLocalOrderData(params.orderData);
|
|
774
773
|
if (validation.valid) {
|
|
775
|
-
_context10.next =
|
|
774
|
+
_context10.next = 4;
|
|
776
775
|
break;
|
|
777
776
|
}
|
|
778
777
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
779
|
-
case
|
|
778
|
+
case 4:
|
|
780
779
|
// 计算金额
|
|
781
780
|
amountInfo = extractAmountFromCartSummary(params.cartSummary); // 规范化补充字段
|
|
782
781
|
params.orderData.created_at = formatDateTime(new Date());
|
|
@@ -802,19 +801,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
802
801
|
}
|
|
803
802
|
|
|
804
803
|
// 保留原有支付项:通过 orderId 找到现有订单(按 id 或 order_id 匹配)
|
|
805
|
-
_context10.next =
|
|
804
|
+
_context10.next = 17;
|
|
806
805
|
return this.payment.getOrderListAsync();
|
|
807
|
-
case
|
|
806
|
+
case 17:
|
|
808
807
|
allOrders = _context10.sent;
|
|
809
808
|
existingOrder = allOrders.find(function (o) {
|
|
810
809
|
return String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId);
|
|
811
810
|
});
|
|
812
811
|
if (!existingOrder) {
|
|
813
|
-
_context10.next =
|
|
812
|
+
_context10.next = 71;
|
|
814
813
|
break;
|
|
815
814
|
}
|
|
816
815
|
if (!(params.existPayment && params.existPayment.length > 0)) {
|
|
817
|
-
_context10.next =
|
|
816
|
+
_context10.next = 47;
|
|
818
817
|
break;
|
|
819
818
|
}
|
|
820
819
|
this.logInfo('检测到云端支付项,将替换本地订单的支付项列表', {
|
|
@@ -838,7 +837,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
838
837
|
});
|
|
839
838
|
}); // 计算是否需要支付定金
|
|
840
839
|
_isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新订单,替换支付项列表
|
|
841
|
-
_context10.next =
|
|
840
|
+
_context10.next = 28;
|
|
842
841
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
843
842
|
total_amount: amountInfo.totalAmount,
|
|
844
843
|
is_deposit: _isNeedDeposit.hasDeposit ? 1 : 0,
|
|
@@ -856,21 +855,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
856
855
|
amount_breakdown: amountInfo
|
|
857
856
|
}
|
|
858
857
|
});
|
|
859
|
-
case
|
|
860
|
-
_context10.next =
|
|
858
|
+
case 28:
|
|
859
|
+
_context10.next = 30;
|
|
861
860
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
862
|
-
case
|
|
861
|
+
case 30:
|
|
863
862
|
_updated = _context10.sent;
|
|
864
863
|
if (_updated) {
|
|
865
|
-
_context10.next =
|
|
864
|
+
_context10.next = 33;
|
|
866
865
|
break;
|
|
867
866
|
}
|
|
868
867
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
869
|
-
case
|
|
868
|
+
case 33:
|
|
870
869
|
this.store.currentOrder = _updated;
|
|
871
|
-
_context10.next =
|
|
870
|
+
_context10.next = 36;
|
|
872
871
|
return this.updateStateAmountToRemaining(false);
|
|
873
|
-
case
|
|
872
|
+
case 36:
|
|
874
873
|
this.logInfo('本地订单更新成功(已替换云端支付项):', {
|
|
875
874
|
orderId: params.orderId,
|
|
876
875
|
uuid: _updated.uuid,
|
|
@@ -881,12 +880,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
881
880
|
});
|
|
882
881
|
|
|
883
882
|
// 事件通知
|
|
884
|
-
_context10.next =
|
|
883
|
+
_context10.next = 39;
|
|
885
884
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
886
885
|
order: _updated,
|
|
887
886
|
timestamp: Date.now()
|
|
888
887
|
});
|
|
889
|
-
case
|
|
888
|
+
case 39:
|
|
890
889
|
// 计算已同步的支付金额
|
|
891
890
|
syncedPayments = _updated.payment.filter(function (p) {
|
|
892
891
|
return p.isSynced && p.status !== 'voided';
|
|
@@ -894,6 +893,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
894
893
|
_syncedAmount = syncedPayments.reduce(function (sum, p) {
|
|
895
894
|
var amt = new Decimal(p.amount || '0');
|
|
896
895
|
var rounding = new Decimal(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || '0').abs();
|
|
896
|
+
if (p.service_fee) {
|
|
897
|
+
amt = amt.minus(new Decimal(p.service_fee));
|
|
898
|
+
}
|
|
897
899
|
return sum.plus(amt).plus(rounding);
|
|
898
900
|
}, new Decimal(0));
|
|
899
901
|
_totalAmount = new Decimal(amountInfo.totalAmount || '0');
|
|
@@ -906,7 +908,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
906
908
|
order_wait_pay_amount: Number(_depositDiffAmount) > 0 ? Number(_depositDiffAmount) : Number(_remainingExpectAmount)
|
|
907
909
|
});
|
|
908
910
|
return _context10.abrupt("return", _updated);
|
|
909
|
-
case
|
|
911
|
+
case 47:
|
|
910
912
|
// 原有逻辑:保留现有支付项
|
|
911
913
|
totalAmount = new Decimal(amountInfo.totalAmount || '0');
|
|
912
914
|
activePayments = (existingOrder.payment || []).filter(function (p) {
|
|
@@ -919,7 +921,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
919
921
|
}, new Decimal(0));
|
|
920
922
|
remaining = Decimal.max(0, totalAmount.minus(paidAmount)).toFixed(2); // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
921
923
|
_isNeedDeposit2 = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 更新到支付模块(使用 uuid,不修改 payment 列表)
|
|
922
|
-
_context10.next =
|
|
924
|
+
_context10.next = 54;
|
|
923
925
|
return this.payment.updateOrderAsync(existingOrder.uuid, {
|
|
924
926
|
total_amount: amountInfo.totalAmount,
|
|
925
927
|
is_deposit: _isNeedDeposit2.hasDeposit ? 1 : 0,
|
|
@@ -936,21 +938,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
936
938
|
amount_breakdown: amountInfo
|
|
937
939
|
}
|
|
938
940
|
});
|
|
939
|
-
case
|
|
940
|
-
_context10.next =
|
|
941
|
+
case 54:
|
|
942
|
+
_context10.next = 56;
|
|
941
943
|
return this.payment.getPaymentOrderByUuidAsync(existingOrder.uuid);
|
|
942
|
-
case
|
|
944
|
+
case 56:
|
|
943
945
|
updated = _context10.sent;
|
|
944
946
|
if (updated) {
|
|
945
|
-
_context10.next =
|
|
947
|
+
_context10.next = 59;
|
|
946
948
|
break;
|
|
947
949
|
}
|
|
948
950
|
throw createCheckoutError(CheckoutErrorType.UnknownError, '订单更新失败');
|
|
949
|
-
case
|
|
951
|
+
case 59:
|
|
950
952
|
this.store.currentOrder = updated;
|
|
951
|
-
_context10.next =
|
|
953
|
+
_context10.next = 62;
|
|
952
954
|
return this.updateStateAmountToRemaining(false);
|
|
953
|
-
case
|
|
955
|
+
case 62:
|
|
954
956
|
this.logInfo('本地订单更新成功(保留支付项):', {
|
|
955
957
|
orderId: params.orderId,
|
|
956
958
|
uuid: updated.uuid,
|
|
@@ -960,12 +962,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
960
962
|
});
|
|
961
963
|
|
|
962
964
|
// 事件通知(复用创建事件,便于上层监听刷新)
|
|
963
|
-
_context10.next =
|
|
965
|
+
_context10.next = 65;
|
|
964
966
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
965
967
|
order: updated,
|
|
966
968
|
timestamp: Date.now()
|
|
967
969
|
});
|
|
968
|
-
case
|
|
970
|
+
case 65:
|
|
969
971
|
// 需要减去已经同步给后端的支付过的钱
|
|
970
972
|
syncedAmount = activePayments.reduce(function (sum, p) {
|
|
971
973
|
var amt = new Decimal(p.amount || '0');
|
|
@@ -981,10 +983,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
981
983
|
order_wait_pay_amount: Number(depositDiffAmount) > 0 ? Number(depositDiffAmount) : Number(remainingExpectAmount)
|
|
982
984
|
});
|
|
983
985
|
return _context10.abrupt("return", updated);
|
|
984
|
-
case
|
|
986
|
+
case 71:
|
|
985
987
|
// 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
986
988
|
isNeedDeposit = this.checkIsNeedDepositAsync(params.orderData.bookings, params.orderData.relation_products); // 没找到现有订单时,回退为创建逻辑(用于异常兜底)
|
|
987
|
-
_context10.next =
|
|
989
|
+
_context10.next = 74;
|
|
988
990
|
return this.payment.createPaymentOrderAsync({
|
|
989
991
|
order_id: String(params.orderId),
|
|
990
992
|
total_amount: amountInfo.totalAmount,
|
|
@@ -1003,7 +1005,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1003
1005
|
amount_breakdown: amountInfo
|
|
1004
1006
|
}
|
|
1005
1007
|
});
|
|
1006
|
-
case
|
|
1008
|
+
case 74:
|
|
1007
1009
|
created = _context10.sent;
|
|
1008
1010
|
this.store.currentOrder = created;
|
|
1009
1011
|
|
|
@@ -1039,7 +1041,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1039
1041
|
this.initWalletData();
|
|
1040
1042
|
}
|
|
1041
1043
|
return _context10.abrupt("return", created);
|
|
1042
|
-
case
|
|
1044
|
+
case 78:
|
|
1043
1045
|
case "end":
|
|
1044
1046
|
return _context10.stop();
|
|
1045
1047
|
}
|
|
@@ -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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -606,7 +606,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
606
606
|
quantity = 1
|
|
607
607
|
} = product || {};
|
|
608
608
|
const productData = { ...origin, product_variant_id };
|
|
609
|
-
debugger;
|
|
610
609
|
if ((0, import_products.isSessionProduct)(productData)) {
|
|
611
610
|
if (!date || !date.startTime || !date.endTime) {
|
|
612
611
|
return { success: false, errorCode: "date_or_time_required" };
|
|
@@ -507,7 +507,6 @@ 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;
|
|
511
510
|
this.logInfo("updateLocalOrderAsync called", {
|
|
512
511
|
orderId: params.orderId,
|
|
513
512
|
orderDataType: (_a = params.orderData) == null ? void 0 : _a.type,
|
|
@@ -606,8 +605,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
606
605
|
});
|
|
607
606
|
const syncedPayments = updated2.payment.filter((p) => p.isSynced && p.status !== "voided");
|
|
608
607
|
const syncedAmount2 = syncedPayments.reduce((sum, p) => {
|
|
609
|
-
|
|
608
|
+
let amt = new import_decimal.default(p.amount || "0");
|
|
610
609
|
const rounding = new import_decimal.default(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || "0").abs();
|
|
610
|
+
if (p.service_fee) {
|
|
611
|
+
amt = amt.minus(new import_decimal.default(p.service_fee));
|
|
612
|
+
}
|
|
611
613
|
return sum.plus(amt).plus(rounding);
|
|
612
614
|
}, new import_decimal.default(0));
|
|
613
615
|
const totalAmount2 = new import_decimal.default(amountInfo.totalAmount || "0");
|