@pisell/pisellos 0.0.279 → 0.0.281
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/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +15 -9
- package/dist/solution/Checkout/index.js +24 -22
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +12 -8
- package/lib/solution/Checkout/index.js +3 -1
- package/package.json +1 -1
|
@@ -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<"normal" | "duration" | "session">;
|
|
330
330
|
/**
|
|
331
331
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
332
332
|
*
|
|
@@ -2783,6 +2783,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2783
2783
|
var hasCapacityIssue = false;
|
|
2784
2784
|
var resourceCapacityInfo = [];
|
|
2785
2785
|
|
|
2786
|
+
// 用于跟踪已处理的商品,避免重复添加
|
|
2787
|
+
var processedCartItemIds = new Set();
|
|
2788
|
+
|
|
2786
2789
|
// 先检查所有资源类型,收集可用数量信息
|
|
2787
2790
|
var _loop3 = function _loop3() {
|
|
2788
2791
|
var _resourceTypeConfig;
|
|
@@ -2912,17 +2915,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2912
2915
|
};
|
|
2913
2916
|
}
|
|
2914
2917
|
|
|
2915
|
-
//
|
|
2918
|
+
// 使用第一个公共可用时间段,但只处理未处理过的商品
|
|
2916
2919
|
var firstCommonSlot = commonTimeSlots[0];
|
|
2917
2920
|
console.log("\u4F7F\u7528\u516C\u5171\u65F6\u95F4\u6BB5: ".concat(firstCommonSlot.startTime, " - ").concat(firstCommonSlot.endTime));
|
|
2918
2921
|
items.forEach(function (cartItem) {
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2922
|
+
// 只处理未处理过的商品,避免重复添加
|
|
2923
|
+
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2924
|
+
processedCartItemIds.add(cartItem._id);
|
|
2925
|
+
var processedItem = _objectSpread(_objectSpread({}, cartItem), {}, {
|
|
2926
|
+
start_date: dateRange[0].date,
|
|
2927
|
+
start_time: firstCommonSlot.startTime,
|
|
2928
|
+
end_time: firstCommonSlot.endTime,
|
|
2929
|
+
end_date: dateRange[0].date
|
|
2930
|
+
});
|
|
2931
|
+
processedItemsWithoutTime.push(processedItem);
|
|
2932
|
+
}
|
|
2926
2933
|
});
|
|
2927
2934
|
},
|
|
2928
2935
|
_ret3;
|
|
@@ -2970,7 +2977,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2970
2977
|
}
|
|
2971
2978
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
2972
2979
|
});
|
|
2973
|
-
|
|
2974
2980
|
// 检查每个时间段是否有足够的资源容量
|
|
2975
2981
|
var _loop4 = function _loop4() {
|
|
2976
2982
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
@@ -1049,7 +1049,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1049
1049
|
key: "addPaymentItemAsync",
|
|
1050
1050
|
value: (function () {
|
|
1051
1051
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(paymentItem) {
|
|
1052
|
-
var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, syncResult;
|
|
1052
|
+
var orderPaymentType, processedPaymentItem, metadata, paymentItemWithType, remainingAmount, _paymentItem$type, _paymentItem$code, isEftposPayment, _isCashPayment, isCustomePayment, syncResult;
|
|
1053
1053
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1054
1054
|
while (1) switch (_context15.prev = _context15.next) {
|
|
1055
1055
|
case 0:
|
|
@@ -1090,44 +1090,46 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1090
1090
|
case 17:
|
|
1091
1091
|
remainingAmount = _context15.sent;
|
|
1092
1092
|
if (!(Number(remainingAmount) > 0)) {
|
|
1093
|
-
_context15.next =
|
|
1093
|
+
_context15.next = 38;
|
|
1094
1094
|
break;
|
|
1095
1095
|
}
|
|
1096
1096
|
this.logInfo('订单金额还有待付的,同步 EFTPOS 支付');
|
|
1097
1097
|
// 检查是否是 EFTPOS 支付,如果是则立即同步订单
|
|
1098
1098
|
isEftposPayment = ((_paymentItem$type = paymentItem.type) === null || _paymentItem$type === void 0 ? void 0 : _paymentItem$type.toLowerCase()) === 'eftpos' || ((_paymentItem$code = paymentItem.code) === null || _paymentItem$code === void 0 ? void 0 : _paymentItem$code.toUpperCase().includes('EFTPOS'));
|
|
1099
|
+
_isCashPayment = paymentItem.code === 'CASHMANUAL';
|
|
1100
|
+
isCustomePayment = paymentItem.type === 'custom';
|
|
1099
1101
|
this.logInfo('EFTPOS 支付检查:', {
|
|
1100
1102
|
paymentCode: paymentItem.code,
|
|
1101
1103
|
paymentType: paymentItem.type,
|
|
1102
1104
|
isEftposPayment: isEftposPayment,
|
|
1103
1105
|
currentOrderSynced: this.store.isOrderSynced
|
|
1104
1106
|
});
|
|
1105
|
-
if (!isEftposPayment) {
|
|
1106
|
-
_context15.next =
|
|
1107
|
+
if (!(isEftposPayment || _isCashPayment || isCustomePayment)) {
|
|
1108
|
+
_context15.next = 38;
|
|
1107
1109
|
break;
|
|
1108
1110
|
}
|
|
1109
1111
|
this.logInfo('检测到 EFTPOS 支付,立即同步订单到后端...');
|
|
1110
|
-
_context15.prev =
|
|
1111
|
-
_context15.next =
|
|
1112
|
+
_context15.prev = 26;
|
|
1113
|
+
_context15.next = 29;
|
|
1112
1114
|
return this.syncOrderToBackendWithReturn(true);
|
|
1113
|
-
case
|
|
1115
|
+
case 29:
|
|
1114
1116
|
syncResult = _context15.sent;
|
|
1115
1117
|
this.logInfo('EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
|
|
1116
1118
|
orderId: syncResult.orderId,
|
|
1117
1119
|
isOrderSynced: this.store.isOrderSynced,
|
|
1118
1120
|
backendResponse: syncResult.response
|
|
1119
1121
|
});
|
|
1120
|
-
_context15.next =
|
|
1122
|
+
_context15.next = 38;
|
|
1121
1123
|
break;
|
|
1122
|
-
case
|
|
1123
|
-
_context15.prev =
|
|
1124
|
-
_context15.t0 = _context15["catch"](
|
|
1124
|
+
case 33:
|
|
1125
|
+
_context15.prev = 33;
|
|
1126
|
+
_context15.t0 = _context15["catch"](26);
|
|
1125
1127
|
this.logError('EFTPOS 支付后订单同步失败:', _context15.t0);
|
|
1126
1128
|
// 不抛出错误,避免影响支付流程,但记录错误
|
|
1127
|
-
_context15.next = 36;
|
|
1128
|
-
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1129
|
-
case 36:
|
|
1130
1129
|
_context15.next = 38;
|
|
1130
|
+
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1131
|
+
case 38:
|
|
1132
|
+
_context15.next = 40;
|
|
1131
1133
|
return this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
|
|
1132
1134
|
orderUuid: this.store.currentOrder.uuid,
|
|
1133
1135
|
paymentMethodCode: paymentItem.code,
|
|
@@ -1135,22 +1137,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1135
1137
|
amount: String(paymentItem.amount),
|
|
1136
1138
|
timestamp: Date.now()
|
|
1137
1139
|
});
|
|
1138
|
-
case 38:
|
|
1139
|
-
_context15.next = 46;
|
|
1140
|
-
break;
|
|
1141
1140
|
case 40:
|
|
1142
|
-
_context15.
|
|
1141
|
+
_context15.next = 48;
|
|
1142
|
+
break;
|
|
1143
|
+
case 42:
|
|
1144
|
+
_context15.prev = 42;
|
|
1143
1145
|
_context15.t1 = _context15["catch"](1);
|
|
1144
1146
|
this.logError('添加支付项失败:', _context15.t1);
|
|
1145
|
-
_context15.next =
|
|
1147
|
+
_context15.next = 47;
|
|
1146
1148
|
return this.handleError(_context15.t1, CheckoutErrorType.PaymentFailed);
|
|
1147
|
-
case
|
|
1149
|
+
case 47:
|
|
1148
1150
|
throw _context15.t1;
|
|
1149
|
-
case
|
|
1151
|
+
case 48:
|
|
1150
1152
|
case "end":
|
|
1151
1153
|
return _context15.stop();
|
|
1152
1154
|
}
|
|
1153
|
-
}, _callee15, this, [[1,
|
|
1155
|
+
}, _callee15, this, [[1, 42], [26, 33]]);
|
|
1154
1156
|
}));
|
|
1155
1157
|
function addPaymentItemAsync(_x14) {
|
|
1156
1158
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -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<"normal" | "duration" | "session">;
|
|
330
330
|
/**
|
|
331
331
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
332
332
|
*
|
|
@@ -1950,6 +1950,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1950
1950
|
});
|
|
1951
1951
|
let hasCapacityIssue = false;
|
|
1952
1952
|
const resourceCapacityInfo = [];
|
|
1953
|
+
const processedCartItemIds = /* @__PURE__ */ new Set();
|
|
1953
1954
|
for (const [resourceCode, items] of Object.entries(itemsByResourceType)) {
|
|
1954
1955
|
const targetFormId = resourceCodeToFormIdMap[resourceCode];
|
|
1955
1956
|
if (!targetFormId) {
|
|
@@ -2028,14 +2029,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2028
2029
|
const firstCommonSlot = commonTimeSlots[0];
|
|
2029
2030
|
console.log(`使用公共时间段: ${firstCommonSlot.startTime} - ${firstCommonSlot.endTime}`);
|
|
2030
2031
|
items.forEach((cartItem) => {
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2032
|
+
if (!processedCartItemIds.has(cartItem._id)) {
|
|
2033
|
+
processedCartItemIds.add(cartItem._id);
|
|
2034
|
+
const processedItem = {
|
|
2035
|
+
...cartItem,
|
|
2036
|
+
start_date: dateRange[0].date,
|
|
2037
|
+
start_time: firstCommonSlot.startTime,
|
|
2038
|
+
end_time: firstCommonSlot.endTime,
|
|
2039
|
+
end_date: dateRange[0].date
|
|
2040
|
+
};
|
|
2041
|
+
processedItemsWithoutTime.push(processedItem);
|
|
2042
|
+
}
|
|
2039
2043
|
});
|
|
2040
2044
|
}
|
|
2041
2045
|
if (hasCapacityIssue) {
|
|
@@ -659,13 +659,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
659
659
|
if (Number(remainingAmount) > 0) {
|
|
660
660
|
this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
|
|
661
661
|
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
662
|
+
const isCashPayment2 = paymentItem.code === "CASHMANUAL";
|
|
663
|
+
const isCustomePayment = paymentItem.type === "custom";
|
|
662
664
|
this.logInfo("EFTPOS 支付检查:", {
|
|
663
665
|
paymentCode: paymentItem.code,
|
|
664
666
|
paymentType: paymentItem.type,
|
|
665
667
|
isEftposPayment,
|
|
666
668
|
currentOrderSynced: this.store.isOrderSynced
|
|
667
669
|
});
|
|
668
|
-
if (isEftposPayment) {
|
|
670
|
+
if (isEftposPayment || isCashPayment2 || isCustomePayment) {
|
|
669
671
|
this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
|
|
670
672
|
try {
|
|
671
673
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|