@pisell/pisellos 0.0.304 → 0.0.305
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/index.js +21 -14
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +20 -14
- package/lib/modules/Payment/index.js +8 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +7 -2
- package/package.json +1 -1
|
@@ -1044,7 +1044,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1044
1044
|
key: "addPaymentItemAsync",
|
|
1045
1045
|
value: (function () {
|
|
1046
1046
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
|
|
1047
|
-
var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, warningMessage, paymentUuid, newPaymentItem;
|
|
1047
|
+
var _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, newPaymentItem;
|
|
1048
1048
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1049
1049
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1050
1050
|
case 0:
|
|
@@ -1066,9 +1066,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1066
1066
|
throw new Error("Order not found: ".concat(orderUuid));
|
|
1067
1067
|
case 7:
|
|
1068
1068
|
// 🔒 支付锁检查:如果订单待付金额已经为0,不允许继续添加支付项
|
|
1069
|
-
expectAmount = new Decimal(order.expect_amount);
|
|
1070
|
-
|
|
1071
|
-
|
|
1069
|
+
expectAmount = new Decimal(order.expect_amount);
|
|
1070
|
+
paidDepositAmount = order.payment.reduce(function (sum, payment) {
|
|
1071
|
+
if (payment.order_payment_type === 'deposit') {
|
|
1072
|
+
return sum.plus(new Decimal(payment.amount));
|
|
1073
|
+
}
|
|
1074
|
+
return sum;
|
|
1075
|
+
}, new Decimal(0));
|
|
1076
|
+
expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
|
|
1077
|
+
if (!(expectAmount.lte(0) && expectedDepositAmount.lte(0))) {
|
|
1078
|
+
_context13.next = 15;
|
|
1072
1079
|
break;
|
|
1073
1080
|
}
|
|
1074
1081
|
warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
|
|
@@ -1085,7 +1092,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1085
1092
|
paymentItem: paymentItem
|
|
1086
1093
|
});
|
|
1087
1094
|
throw new Error(warningMessage);
|
|
1088
|
-
case
|
|
1095
|
+
case 15:
|
|
1089
1096
|
paymentUuid = getUniqueId('payment_');
|
|
1090
1097
|
newPaymentItem = {
|
|
1091
1098
|
uuid: paymentUuid,
|
|
@@ -1108,15 +1115,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1108
1115
|
};
|
|
1109
1116
|
order.payment.push(newPaymentItem);
|
|
1110
1117
|
this.recalculateOrderAmount(order);
|
|
1111
|
-
_context13.next = 19;
|
|
1112
|
-
return this.dbManager.update('order', order);
|
|
1113
|
-
case 19:
|
|
1114
1118
|
_context13.next = 21;
|
|
1119
|
+
return this.dbManager.update('order', order);
|
|
1120
|
+
case 21:
|
|
1121
|
+
_context13.next = 23;
|
|
1115
1122
|
return this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
|
|
1116
1123
|
orderUuid: orderUuid,
|
|
1117
1124
|
payment: newPaymentItem
|
|
1118
1125
|
});
|
|
1119
|
-
case
|
|
1126
|
+
case 23:
|
|
1120
1127
|
this.logInfo('addPaymentItemAsync completed successfully', {
|
|
1121
1128
|
orderUuid: orderUuid,
|
|
1122
1129
|
paymentUuid: newPaymentItem.uuid,
|
|
@@ -1130,10 +1137,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1130
1137
|
actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
|
|
1131
1138
|
changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
|
|
1132
1139
|
});
|
|
1133
|
-
_context13.next =
|
|
1140
|
+
_context13.next = 31;
|
|
1134
1141
|
break;
|
|
1135
|
-
case
|
|
1136
|
-
_context13.prev =
|
|
1142
|
+
case 26:
|
|
1143
|
+
_context13.prev = 26;
|
|
1137
1144
|
_context13.t0 = _context13["catch"](1);
|
|
1138
1145
|
console.error('[PaymentModule] 添加支付项失败', _context13.t0);
|
|
1139
1146
|
this.logError('addPaymentItemAsync failed', _context13.t0, {
|
|
@@ -1141,11 +1148,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1141
1148
|
paymentItem: paymentItem
|
|
1142
1149
|
});
|
|
1143
1150
|
throw _context13.t0;
|
|
1144
|
-
case
|
|
1151
|
+
case 31:
|
|
1145
1152
|
case "end":
|
|
1146
1153
|
return _context13.stop();
|
|
1147
1154
|
}
|
|
1148
|
-
}, _callee13, this, [[1,
|
|
1155
|
+
}, _callee13, this, [[1, 26]]);
|
|
1149
1156
|
}));
|
|
1150
1157
|
function addPaymentItemAsync(_x14, _x15) {
|
|
1151
1158
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -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
|
}
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
};
|
|
327
327
|
setOtherData(key: string, value: any): void;
|
|
328
328
|
getOtherData(key: string): any;
|
|
329
|
-
getProductTypeById(id: number): Promise<"
|
|
329
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
330
330
|
/**
|
|
331
331
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
332
332
|
*
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -1645,7 +1645,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1645
1645
|
key: "updateOrderDepositStatusAsync",
|
|
1646
1646
|
value: (function () {
|
|
1647
1647
|
var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(isDeposit) {
|
|
1648
|
-
var newDepositValue, oldDepositValue, updateParams;
|
|
1648
|
+
var newDepositValue, oldDepositValue, deposit_amount, updateParams;
|
|
1649
1649
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1650
1650
|
while (1) switch (_context19.prev = _context19.next) {
|
|
1651
1651
|
case 0:
|
|
@@ -1671,9 +1671,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1671
1671
|
console.log('[Checkout] 定金状态无变化,跳过更新');
|
|
1672
1672
|
return _context19.abrupt("return");
|
|
1673
1673
|
case 10:
|
|
1674
|
+
deposit_amount = newDepositValue === 1 ? this.store.currentOrder.deposit_amount : '0.00'; // 如果原来没有 deposit_amount,则默认把待付金额置为 deposit_amount
|
|
1675
|
+
if (!deposit_amount) {
|
|
1676
|
+
deposit_amount = this.store.currentOrder.expect_amount;
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1674
1679
|
// 准备更新参数
|
|
1675
1680
|
updateParams = {
|
|
1676
|
-
is_deposit: newDepositValue
|
|
1681
|
+
is_deposit: newDepositValue,
|
|
1682
|
+
deposit_amount: deposit_amount
|
|
1677
1683
|
}; // 如果从定金改为全款,可以清空定金金额
|
|
1678
1684
|
// if (
|
|
1679
1685
|
// isDeposit === 0 &&
|
|
@@ -1683,9 +1689,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1683
1689
|
// this.logInfo('订单从定金改为全款,清空定金金额');
|
|
1684
1690
|
// }
|
|
1685
1691
|
// 调用 Payment 模块更新订单
|
|
1686
|
-
_context19.next =
|
|
1692
|
+
_context19.next = 15;
|
|
1687
1693
|
return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
|
|
1688
|
-
case
|
|
1694
|
+
case 15:
|
|
1689
1695
|
// 更新本地缓存的订单对象
|
|
1690
1696
|
this.store.currentOrder = _objectSpread(_objectSpread({}, this.store.currentOrder), updateParams);
|
|
1691
1697
|
|
|
@@ -1693,34 +1699,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1693
1699
|
if (this.store.localOrderData) {
|
|
1694
1700
|
this.store.localOrderData.is_deposit = newDepositValue;
|
|
1695
1701
|
}
|
|
1696
|
-
this.updateStateAmountToRemaining();
|
|
1702
|
+
this.updateStateAmountToRemaining(false);
|
|
1697
1703
|
|
|
1698
1704
|
// 触发订单更新事件
|
|
1699
|
-
_context19.next =
|
|
1705
|
+
_context19.next = 20;
|
|
1700
1706
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1701
1707
|
order: this.store.currentOrder,
|
|
1702
1708
|
timestamp: Date.now()
|
|
1703
1709
|
});
|
|
1704
|
-
case
|
|
1710
|
+
case 20:
|
|
1705
1711
|
this.logInfo('订单定金状态更新成功:', {
|
|
1706
1712
|
isDeposit: newDepositValue,
|
|
1707
1713
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
1708
1714
|
});
|
|
1709
|
-
_context19.next =
|
|
1715
|
+
_context19.next = 29;
|
|
1710
1716
|
break;
|
|
1711
|
-
case
|
|
1712
|
-
_context19.prev =
|
|
1717
|
+
case 23:
|
|
1718
|
+
_context19.prev = 23;
|
|
1713
1719
|
_context19.t0 = _context19["catch"](0);
|
|
1714
1720
|
this.logError('更新订单定金状态失败:', _context19.t0);
|
|
1715
|
-
_context19.next =
|
|
1721
|
+
_context19.next = 28;
|
|
1716
1722
|
return this.handleError(_context19.t0, CheckoutErrorType.ValidationFailed);
|
|
1717
|
-
case
|
|
1723
|
+
case 28:
|
|
1718
1724
|
throw _context19.t0;
|
|
1719
|
-
case
|
|
1725
|
+
case 29:
|
|
1720
1726
|
case "end":
|
|
1721
1727
|
return _context19.stop();
|
|
1722
1728
|
}
|
|
1723
|
-
}, _callee19, this, [[0,
|
|
1729
|
+
}, _callee19, this, [[0, 23]]);
|
|
1724
1730
|
}));
|
|
1725
1731
|
function updateOrderDepositStatusAsync(_x18) {
|
|
1726
1732
|
return _updateOrderDepositStatusAsync.apply(this, arguments);
|
|
@@ -528,7 +528,14 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
528
528
|
throw new Error(`Order not found: ${orderUuid}`);
|
|
529
529
|
}
|
|
530
530
|
const expectAmount = new import_decimal.Decimal(order.expect_amount);
|
|
531
|
-
|
|
531
|
+
const paidDepositAmount = order.payment.reduce((sum, payment) => {
|
|
532
|
+
if (payment.order_payment_type === "deposit") {
|
|
533
|
+
return sum.plus(new import_decimal.Decimal(payment.amount));
|
|
534
|
+
}
|
|
535
|
+
return sum;
|
|
536
|
+
}, new import_decimal.Decimal(0));
|
|
537
|
+
const expectedDepositAmount = new import_decimal.Decimal(order.deposit_amount || "0").sub(paidDepositAmount);
|
|
538
|
+
if (expectAmount.lte(0) && expectedDepositAmount.lte(0)) {
|
|
532
539
|
const warningMessage = `订单 ${orderUuid} 待付金额已为0,不允许添加新的支付项`;
|
|
533
540
|
console.warn("[PaymentModule] Payment lock triggered:", {
|
|
534
541
|
orderUuid,
|
|
@@ -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
|
}
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
};
|
|
327
327
|
setOtherData(key: string, value: any): void;
|
|
328
328
|
getOtherData(key: string): any;
|
|
329
|
-
getProductTypeById(id: number): Promise<"
|
|
329
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
330
330
|
/**
|
|
331
331
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
332
332
|
*
|
|
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
111
|
* 获取当前的客户搜索条件
|
|
112
112
|
* @returns 当前搜索条件
|
|
113
113
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
114
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
115
115
|
/**
|
|
116
116
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
117
|
* @returns 客户状态
|
|
@@ -1087,8 +1087,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1087
1087
|
console.log("[Checkout] 定金状态无变化,跳过更新");
|
|
1088
1088
|
return;
|
|
1089
1089
|
}
|
|
1090
|
+
let deposit_amount = newDepositValue === 1 ? this.store.currentOrder.deposit_amount : "0.00";
|
|
1091
|
+
if (!deposit_amount) {
|
|
1092
|
+
deposit_amount = this.store.currentOrder.expect_amount;
|
|
1093
|
+
}
|
|
1090
1094
|
const updateParams = {
|
|
1091
|
-
is_deposit: newDepositValue
|
|
1095
|
+
is_deposit: newDepositValue,
|
|
1096
|
+
deposit_amount
|
|
1092
1097
|
};
|
|
1093
1098
|
await this.payment.updateOrderAsync(
|
|
1094
1099
|
this.store.currentOrder.uuid,
|
|
@@ -1101,7 +1106,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1101
1106
|
if (this.store.localOrderData) {
|
|
1102
1107
|
this.store.localOrderData.is_deposit = newDepositValue;
|
|
1103
1108
|
}
|
|
1104
|
-
this.updateStateAmountToRemaining();
|
|
1109
|
+
this.updateStateAmountToRemaining(false);
|
|
1105
1110
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreated, {
|
|
1106
1111
|
order: this.store.currentOrder,
|
|
1107
1112
|
timestamp: Date.now()
|