@pisell/pisellos 0.0.567 → 0.0.568
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/core/index.js +6 -9
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
- package/dist/model/strategy/adapter/walletPass/example.js +3 -26
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -3
- package/dist/model/strategy/strategy-example.js +5 -19
- package/dist/modules/Cart/index.js +0 -3
- package/dist/modules/Cart/utils/cartProduct.js +0 -1
- package/dist/modules/Date/index.js +1 -5
- package/dist/modules/Discount/index.js +1 -4
- package/dist/modules/OpenData/index.js +0 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +14 -41
- package/dist/modules/Payment/index.js +142 -270
- package/dist/modules/Payment/walletpass.js +4 -5
- package/dist/modules/Rules/index.js +0 -7
- package/dist/modules/Schedule/utils.js +0 -1
- package/dist/modules/Step/index.js +0 -1
- package/dist/plugins/request.js +1 -4
- package/dist/plugins/window.js +2 -6
- package/dist/server/index.js +88 -121
- package/dist/server/modules/menu/index.js +32 -41
- package/dist/server/modules/products/index.js +29 -49
- package/dist/server/modules/quotation/index.js +29 -38
- package/dist/server/modules/resource/index.js +3 -4
- package/dist/server/modules/schedule/index.js +32 -40
- package/dist/server/utils/product.js +0 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +7 -59
- package/dist/solution/BookingByStep/utils/capacity.js +1 -11
- package/dist/solution/BookingByStep/utils/resources.js +1 -3
- package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +5 -7
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
- package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
- package/dist/solution/BuyTickets/index.js +9 -12
- package/dist/solution/Checkout/index.js +177 -246
- package/dist/solution/Checkout/utils/index.js +4 -16
- package/dist/solution/RegisterAndLogin/index.js +30 -76
- package/dist/solution/ScanOrder/index.js +50 -60
- package/dist/solution/ShopDiscount/index.js +2 -7
- package/dist/solution/VenueBooking/index.d.ts +5 -0
- package/dist/solution/VenueBooking/index.js +364 -327
- package/dist/utils/task.js +15 -18
- package/dist/utils/watch.js +0 -1
- package/lib/apis/picoding.js +2 -0
- package/lib/core/index.js +130 -131
- package/lib/effects/index.js +46 -57
- package/lib/index.js +92 -53
- package/lib/model/index.js +14 -21
- package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
- package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
- package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
- package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
- package/lib/model/strategy/adapter/index.js +100 -64
- package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
- package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
- package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
- package/lib/model/strategy/adapter/itemRule/index.js +83 -57
- package/lib/model/strategy/adapter/itemRule/type.js +97 -36
- package/lib/model/strategy/adapter/promotion/adapter.js +84 -63
- package/lib/model/strategy/adapter/promotion/evaluator.js +381 -231
- package/lib/model/strategy/adapter/promotion/examples.js +139 -159
- package/lib/model/strategy/adapter/promotion/index.js +1 -49
- package/lib/model/strategy/adapter/promotion/type.js +199 -35
- package/lib/model/strategy/adapter/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -152
- package/lib/model/strategy/adapter/walletPass/example.js +217 -190
- package/lib/model/strategy/adapter/walletPass/index.js +75 -51
- package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
- package/lib/model/strategy/adapter/walletPass/type.js +4 -16
- package/lib/model/strategy/adapter/walletPass/utils.js +652 -402
- package/lib/model/strategy/engine.js +270 -168
- package/lib/model/strategy/index.js +49 -34
- package/lib/model/strategy/strategy-example.js +243 -239
- package/lib/model/strategy/type.js +100 -40
- package/lib/modules/Account/index.js +39 -53
- package/lib/modules/Account/types.js +20 -33
- package/lib/modules/AccountList/index.js +116 -154
- package/lib/modules/AccountList/types.js +30 -31
- package/lib/modules/AccountList/utils.js +18 -30
- package/lib/modules/BaseModule.js +22 -45
- package/lib/modules/Cart/index.js +170 -124
- package/lib/modules/Cart/types.js +46 -51
- package/lib/modules/Cart/utils/cartAccount.js +40 -39
- package/lib/modules/Cart/utils/cartDate.js +56 -61
- package/lib/modules/Cart/utils/cartDiscount.js +28 -33
- package/lib/modules/Cart/utils/cartNote.js +27 -32
- package/lib/modules/Cart/utils/cartProduct.js +306 -241
- package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
- package/lib/modules/Cart/utils/cartResource.js +72 -78
- package/lib/modules/Cart/utils/changePrice.js +26 -62
- package/lib/modules/Cart/utils/index.js +106 -48
- package/lib/modules/Customer/constants.js +13 -34
- package/lib/modules/Customer/index.js +216 -153
- package/lib/modules/Customer/types.js +38 -35
- package/lib/modules/Date/index.js +116 -115
- package/lib/modules/Date/types.js +16 -28
- package/lib/modules/Date/utils.js +174 -123
- package/lib/modules/Discount/index.js +117 -113
- package/lib/modules/Discount/types.js +9 -31
- package/lib/modules/Guests/index.js +30 -56
- package/lib/modules/Guests/types.js +23 -33
- package/lib/modules/Holder/index.js +209 -189
- package/lib/modules/Holder/types.js +4 -16
- package/lib/modules/Holder/utils.js +20 -49
- package/lib/modules/OpenData/index.js +63 -74
- package/lib/modules/OpenData/types.js +4 -16
- package/lib/modules/OpenData/utils.js +44 -78
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +332 -320
- package/lib/modules/Order/types.js +24 -33
- package/lib/modules/Order/utils.js +350 -284
- package/lib/modules/Payment/cash.js +20 -33
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
- package/lib/modules/Payment/eftpos.js +16 -30
- package/lib/modules/Payment/index.js +566 -432
- package/lib/modules/Payment/mx51.js +1 -0
- package/lib/modules/Payment/types.js +216 -107
- package/lib/modules/Payment/utils.js +50 -47
- package/lib/modules/Payment/walletpass.js +221 -203
- package/lib/modules/Product/index.js +51 -46
- package/lib/modules/Product/types.js +4 -16
- package/lib/modules/Product/utils.js +32 -33
- package/lib/modules/ProductList/index.js +111 -110
- package/lib/modules/ProductList/types.js +9 -31
- package/lib/modules/Quotation/index.js +60 -82
- package/lib/modules/Quotation/types.js +4 -16
- package/lib/modules/Resource/index.js +27 -59
- package/lib/modules/Resource/types.js +22 -32
- package/lib/modules/Resource/utils.js +30 -38
- package/lib/modules/Rules/index.js +1172 -872
- package/lib/modules/Rules/types.js +17 -40
- package/lib/modules/SalesSummary/index.js +59 -68
- package/lib/modules/SalesSummary/types.js +4 -16
- package/lib/modules/SalesSummary/utils.js +176 -193
- package/lib/modules/ScanOrderLogger/index.js +59 -79
- package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
- package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
- package/lib/modules/ScanOrderLogger/types.js +4 -16
- package/lib/modules/Schedule/getDateIsInSchedule.js +334 -167
- package/lib/modules/Schedule/index.js +97 -107
- package/lib/modules/Schedule/type.js +4 -16
- package/lib/modules/Schedule/types.js +4 -16
- package/lib/modules/Schedule/utils.js +433 -291
- package/lib/modules/Step/index.js +40 -52
- package/lib/modules/Step/tyeps.js +4 -16
- package/lib/modules/Summary/index.js +66 -70
- package/lib/modules/Summary/types.js +4 -16
- package/lib/modules/Summary/utils.js +782 -429
- package/lib/modules/index.js +212 -57
- package/lib/plugins/app.js +4 -16
- package/lib/plugins/index.js +36 -25
- package/lib/plugins/request.js +137 -126
- package/lib/plugins/shopStore.js +4 -16
- package/lib/plugins/user.js +4 -16
- package/lib/plugins/window.js +171 -179
- package/lib/server/index.js +882 -623
- package/lib/server/modules/index.js +85 -59
- package/lib/server/modules/menu/index.js +146 -122
- package/lib/server/modules/menu/types.js +18 -31
- package/lib/server/modules/order/index.js +195 -231
- package/lib/server/modules/order/types.js +107 -32
- package/lib/server/modules/order/utils/filterBookings.js +174 -140
- package/lib/server/modules/order/utils/filterOrders.js +89 -60
- package/lib/server/modules/products/index.js +430 -335
- package/lib/server/modules/products/types.js +41 -34
- package/lib/server/modules/quotation/index.js +76 -77
- package/lib/server/modules/quotation/types.js +21 -31
- package/lib/server/modules/resource/index.js +216 -187
- package/lib/server/modules/resource/types.js +42 -33
- package/lib/server/modules/schedule/index.js +134 -119
- package/lib/server/modules/schedule/types.js +14 -21
- package/lib/server/modules/schedule/utils.js +334 -163
- package/lib/server/types.js +4 -16
- package/lib/server/utils/index.js +25 -23
- package/lib/server/utils/product.js +196 -139
- package/lib/server/utils/schedule.js +34 -41
- package/lib/server/utils/time.js +40 -49
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +1530 -1343
- package/lib/solution/BookingByStep/types.js +40 -99
- package/lib/solution/BookingByStep/utils/capacity.js +192 -160
- package/lib/solution/BookingByStep/utils/products.js +42 -52
- package/lib/solution/BookingByStep/utils/resources.js +527 -330
- package/lib/solution/BookingByStep/utils/stock.js +65 -44
- package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +147 -122
- package/lib/solution/BookingTicket/types.js +38 -64
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +64 -80
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +82 -80
- package/lib/solution/BookingTicket/utils/scan/index.js +90 -94
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
- package/lib/solution/BuyTickets/index.js +67 -70
- package/lib/solution/BuyTickets/types.js +22 -38
- package/lib/solution/Checkout/index.js +1451 -1158
- package/lib/solution/Checkout/types.js +91 -61
- package/lib/solution/Checkout/utils/index.js +227 -158
- package/lib/solution/PlaceOrder/index.js +55 -0
- package/lib/solution/RegisterAndLogin/config.js +493 -460
- package/lib/solution/RegisterAndLogin/index.js +633 -630
- package/lib/solution/RegisterAndLogin/types.js +189 -76
- package/lib/solution/RegisterAndLogin/utils.js +183 -125
- package/lib/solution/Sales/index.js +218 -200
- package/lib/solution/Sales/types.js +27 -33
- package/lib/solution/ScanOrder/index.js +803 -840
- package/lib/solution/ScanOrder/types.js +34 -34
- package/lib/solution/ScanOrder/utils.js +372 -331
- package/lib/solution/ShopDiscount/index.js +230 -236
- package/lib/solution/ShopDiscount/types.js +15 -37
- package/lib/solution/ShopDiscount/utils.js +309 -172
- package/lib/solution/VenueBooking/index.d.ts +5 -0
- package/lib/solution/VenueBooking/index.js +886 -929
- package/lib/solution/VenueBooking/types.js +20 -40
- package/lib/solution/VenueBooking/utils/dateSummary.js +22 -54
- package/lib/solution/VenueBooking/utils/resource.js +31 -54
- package/lib/solution/VenueBooking/utils/slotMerge.js +88 -106
- package/lib/solution/VenueBooking/utils/smartPricing.js +112 -100
- package/lib/solution/VenueBooking/utils/timeSlot.js +133 -132
- package/lib/solution/VenueBooking/utils.js +130 -67
- package/lib/solution/index.js +102 -37
- package/lib/store/createStore.js +32 -29
- package/lib/types/index.js +4 -16
- package/lib/utils/task.js +36 -36
- package/lib/utils/watch.js +81 -47
- package/package.json +2 -1
|
@@ -123,14 +123,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
123
123
|
_context.next = 19;
|
|
124
124
|
return this.cleanupExpiredOrdersAsync();
|
|
125
125
|
case 19:
|
|
126
|
-
|
|
127
|
-
_context.next = 22;
|
|
126
|
+
_context.next = 21;
|
|
128
127
|
return this.core.effects.emit("".concat(this.name, ":onCheckoutInitialized"), {
|
|
129
128
|
timestamp: Date.now()
|
|
130
129
|
});
|
|
131
|
-
case
|
|
130
|
+
case 21:
|
|
132
131
|
this.logInfo('CheckoutModule initialized successfully');
|
|
133
|
-
case
|
|
132
|
+
case 22:
|
|
134
133
|
case "end":
|
|
135
134
|
return _context.stop();
|
|
136
135
|
}
|
|
@@ -288,9 +287,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
288
287
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
289
288
|
while (1) switch (_context5.prev = _context5.next) {
|
|
290
289
|
case 0:
|
|
291
|
-
console.log('[Checkout] 收到支付方式加载完成事件:', methods.length);
|
|
292
290
|
_this2.store.paymentMethods = methods;
|
|
293
|
-
case
|
|
291
|
+
case 1:
|
|
294
292
|
case "end":
|
|
295
293
|
return _context5.stop();
|
|
296
294
|
}
|
|
@@ -307,12 +305,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
307
305
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
308
306
|
while (1) switch (_context6.prev = _context6.next) {
|
|
309
307
|
case 0:
|
|
310
|
-
console.log('[Checkout] 收到支付方式变更事件:', {
|
|
311
|
-
oldCount: data.oldMethods.length,
|
|
312
|
-
newCount: data.newMethods.length
|
|
313
|
-
});
|
|
314
308
|
_this2.store.paymentMethods = data.newMethods;
|
|
315
|
-
case
|
|
309
|
+
case 1:
|
|
316
310
|
case "end":
|
|
317
311
|
return _context6.stop();
|
|
318
312
|
}
|
|
@@ -352,21 +346,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
352
346
|
case 5:
|
|
353
347
|
// 保存购物车数据
|
|
354
348
|
this.store.cartItems = params.cartItems;
|
|
355
|
-
|
|
356
|
-
_context7.next = 14;
|
|
349
|
+
_context7.next = 13;
|
|
357
350
|
break;
|
|
358
|
-
case
|
|
359
|
-
_context7.prev =
|
|
351
|
+
case 8:
|
|
352
|
+
_context7.prev = 8;
|
|
360
353
|
_context7.t0 = _context7["catch"](1);
|
|
361
|
-
_context7.next =
|
|
354
|
+
_context7.next = 12;
|
|
362
355
|
return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
|
|
363
|
-
case
|
|
356
|
+
case 12:
|
|
364
357
|
throw _context7.t0;
|
|
365
|
-
case
|
|
358
|
+
case 13:
|
|
366
359
|
case "end":
|
|
367
360
|
return _context7.stop();
|
|
368
361
|
}
|
|
369
|
-
}, _callee7, this, [[1,
|
|
362
|
+
}, _callee7, this, [[1, 8]]);
|
|
370
363
|
}));
|
|
371
364
|
function initializeCheckoutAsync(_x9) {
|
|
372
365
|
return _initializeCheckoutAsync.apply(this, arguments);
|
|
@@ -668,10 +661,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
668
661
|
}; // 只有在有客户信息时才存储
|
|
669
662
|
if (customerInfo.customer_id || customerInfo.customer_name) {
|
|
670
663
|
this.store.currentCustomer = customerInfo;
|
|
671
|
-
console.log('[Checkout] 保存客户信息:', customerInfo);
|
|
672
664
|
} else {
|
|
673
665
|
this.store.currentCustomer = undefined;
|
|
674
|
-
console.log('[Checkout] 未提供客户信息');
|
|
675
666
|
}
|
|
676
667
|
|
|
677
668
|
// 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
|
|
@@ -1097,28 +1088,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1097
1088
|
timestamp: Date.now()
|
|
1098
1089
|
});
|
|
1099
1090
|
case 11:
|
|
1100
|
-
console.log('[Checkout] 结账流程完成:', order.id);
|
|
1101
|
-
|
|
1102
1091
|
// 🔧 新增:自动重置 store 状态(同步执行)
|
|
1103
1092
|
this.resetStoreState();
|
|
1104
1093
|
return _context11.abrupt("return", {
|
|
1105
1094
|
success: true,
|
|
1106
1095
|
orderId: String(order.id)
|
|
1107
1096
|
});
|
|
1108
|
-
case
|
|
1109
|
-
_context11.prev =
|
|
1097
|
+
case 15:
|
|
1098
|
+
_context11.prev = 15;
|
|
1110
1099
|
_context11.t0 = _context11["catch"](0);
|
|
1111
|
-
_context11.next =
|
|
1100
|
+
_context11.next = 19;
|
|
1112
1101
|
return this.handleError(_context11.t0, CheckoutErrorType.UnknownError);
|
|
1113
|
-
case
|
|
1102
|
+
case 19:
|
|
1114
1103
|
return _context11.abrupt("return", {
|
|
1115
1104
|
success: false
|
|
1116
1105
|
});
|
|
1117
|
-
case
|
|
1106
|
+
case 20:
|
|
1118
1107
|
case "end":
|
|
1119
1108
|
return _context11.stop();
|
|
1120
1109
|
}
|
|
1121
|
-
}, _callee11, this, [[0,
|
|
1110
|
+
}, _callee11, this, [[0, 15]]);
|
|
1122
1111
|
}));
|
|
1123
1112
|
function completeCheckoutAsync() {
|
|
1124
1113
|
return _completeCheckoutAsync.apply(this, arguments);
|
|
@@ -1150,7 +1139,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1150
1139
|
cartItems = _this$store.cartItems,
|
|
1151
1140
|
localOrderData = _this$store.localOrderData;
|
|
1152
1141
|
if (!_currentOrder) {
|
|
1153
|
-
console.log('[Checkout] 当前没有活跃订单');
|
|
1154
1142
|
return null;
|
|
1155
1143
|
}
|
|
1156
1144
|
|
|
@@ -1196,27 +1184,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1196
1184
|
_context12.prev = 0;
|
|
1197
1185
|
_currentOrder2 = this.store.currentOrder;
|
|
1198
1186
|
if (_currentOrder2) {
|
|
1199
|
-
_context12.next =
|
|
1187
|
+
_context12.next = 4;
|
|
1200
1188
|
break;
|
|
1201
1189
|
}
|
|
1202
|
-
console.log('[Checkout] 当前没有活跃订单,无法获取支付项');
|
|
1203
1190
|
return _context12.abrupt("return", []);
|
|
1204
|
-
case
|
|
1205
|
-
_context12.next =
|
|
1191
|
+
case 4:
|
|
1192
|
+
_context12.next = 6;
|
|
1206
1193
|
return this.payment.getPaymentItemsAsync(_currentOrder2.uuid);
|
|
1207
|
-
case
|
|
1194
|
+
case 6:
|
|
1208
1195
|
paymentItems = _context12.sent;
|
|
1209
1196
|
return _context12.abrupt("return", paymentItems);
|
|
1210
|
-
case
|
|
1211
|
-
_context12.prev =
|
|
1197
|
+
case 10:
|
|
1198
|
+
_context12.prev = 10;
|
|
1212
1199
|
_context12.t0 = _context12["catch"](0);
|
|
1213
1200
|
console.error('[Checkout] 获取当前订单支付项失败:', _context12.t0);
|
|
1214
1201
|
return _context12.abrupt("return", []);
|
|
1215
|
-
case
|
|
1202
|
+
case 14:
|
|
1216
1203
|
case "end":
|
|
1217
1204
|
return _context12.stop();
|
|
1218
1205
|
}
|
|
1219
|
-
}, _callee12, this, [[0,
|
|
1206
|
+
}, _callee12, this, [[0, 10]]);
|
|
1220
1207
|
}));
|
|
1221
1208
|
function getCurrentOrderPaymentItemsAsync() {
|
|
1222
1209
|
return _getCurrentOrderPaymentItemsAsync.apply(this, arguments);
|
|
@@ -1273,7 +1260,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1273
1260
|
case 8:
|
|
1274
1261
|
updatedOrder = _context13.sent;
|
|
1275
1262
|
if (!updatedOrder) {
|
|
1276
|
-
_context13.next =
|
|
1263
|
+
_context13.next = 19;
|
|
1277
1264
|
break;
|
|
1278
1265
|
}
|
|
1279
1266
|
// 🔧 重要:Payment.replaceOrderIdByUuidAsync 返回的是 DB 快照(只保证 order_id 变化)
|
|
@@ -1298,32 +1285,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1298
1285
|
timestamp: Date.now()
|
|
1299
1286
|
});
|
|
1300
1287
|
case 16:
|
|
1301
|
-
console.log('[Checkout] 本地订单ID替换成功:', {
|
|
1302
|
-
uuid: updatedOrder.uuid,
|
|
1303
|
-
newOrderId: updatedOrder.id
|
|
1304
|
-
});
|
|
1305
|
-
|
|
1306
1288
|
// 标记订单已同步(替换ID意味着订单已在后端创建)
|
|
1307
1289
|
this.store.isOrderSynced = true;
|
|
1308
1290
|
|
|
1309
1291
|
// 订单ID替换后更新 stateAmount
|
|
1310
|
-
_context13.next =
|
|
1292
|
+
_context13.next = 19;
|
|
1311
1293
|
return this.updateStateAmountToRemaining(false);
|
|
1312
|
-
case
|
|
1294
|
+
case 19:
|
|
1313
1295
|
return _context13.abrupt("return", updatedOrder);
|
|
1314
|
-
case
|
|
1315
|
-
_context13.prev =
|
|
1296
|
+
case 22:
|
|
1297
|
+
_context13.prev = 22;
|
|
1316
1298
|
_context13.t0 = _context13["catch"](0);
|
|
1317
1299
|
console.error('[Checkout] 替换订单ID失败:', _context13.t0);
|
|
1318
|
-
_context13.next =
|
|
1300
|
+
_context13.next = 27;
|
|
1319
1301
|
return this.handleError(_context13.t0, CheckoutErrorType.UnknownError);
|
|
1320
|
-
case
|
|
1302
|
+
case 27:
|
|
1321
1303
|
return _context13.abrupt("return", null);
|
|
1322
|
-
case
|
|
1304
|
+
case 28:
|
|
1323
1305
|
case "end":
|
|
1324
1306
|
return _context13.stop();
|
|
1325
1307
|
}
|
|
1326
|
-
}, _callee13, this, [[0,
|
|
1308
|
+
}, _callee13, this, [[0, 22]]);
|
|
1327
1309
|
}));
|
|
1328
1310
|
function replaceLocalOrderIdAsync(_x13) {
|
|
1329
1311
|
return _replaceLocalOrderIdAsync.apply(this, arguments);
|
|
@@ -1970,12 +1952,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1970
1952
|
newDepositValue = isDeposit;
|
|
1971
1953
|
oldDepositValue = this.store.currentOrder.is_deposit; // 如果状态没有变化,直接返回
|
|
1972
1954
|
if (!(oldDepositValue === newDepositValue)) {
|
|
1973
|
-
_context19.next =
|
|
1955
|
+
_context19.next = 9;
|
|
1974
1956
|
break;
|
|
1975
1957
|
}
|
|
1976
|
-
console.log('[Checkout] 定金状态无变化,跳过更新');
|
|
1977
1958
|
return _context19.abrupt("return");
|
|
1978
|
-
case
|
|
1959
|
+
case 9:
|
|
1979
1960
|
deposit_amount = this.store.currentOrder.deposit_amount || '0.00'; // 如果原来没有 deposit_amount,则默认把待付金额置为 deposit_amount
|
|
1980
1961
|
if (!deposit_amount || Number(deposit_amount) === 0) {
|
|
1981
1962
|
deposit_amount = this.store.currentOrder.expect_amount;
|
|
@@ -1994,9 +1975,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1994
1975
|
// this.logInfo('订单从定金改为全款,清空定金金额');
|
|
1995
1976
|
// }
|
|
1996
1977
|
// 调用 Payment 模块更新订单
|
|
1997
|
-
_context19.next =
|
|
1978
|
+
_context19.next = 14;
|
|
1998
1979
|
return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
|
|
1999
|
-
case
|
|
1980
|
+
case 14:
|
|
2000
1981
|
// 更新本地缓存的订单对象
|
|
2001
1982
|
this.store.currentOrder = _objectSpread(_objectSpread({}, this.store.currentOrder), updateParams);
|
|
2002
1983
|
|
|
@@ -2010,31 +1991,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2010
1991
|
this.updateStateAmountToRemaining(false);
|
|
2011
1992
|
|
|
2012
1993
|
// 触发订单更新事件
|
|
2013
|
-
_context19.next =
|
|
1994
|
+
_context19.next = 20;
|
|
2014
1995
|
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
2015
1996
|
order: this.store.currentOrder,
|
|
2016
1997
|
timestamp: Date.now()
|
|
2017
1998
|
});
|
|
2018
|
-
case
|
|
1999
|
+
case 20:
|
|
2019
2000
|
this.logInfo('订单定金状态更新成功:', {
|
|
2020
2001
|
isDeposit: newDepositValue,
|
|
2021
2002
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
2022
2003
|
});
|
|
2023
|
-
_context19.next =
|
|
2004
|
+
_context19.next = 29;
|
|
2024
2005
|
break;
|
|
2025
|
-
case
|
|
2026
|
-
_context19.prev =
|
|
2006
|
+
case 23:
|
|
2007
|
+
_context19.prev = 23;
|
|
2027
2008
|
_context19.t0 = _context19["catch"](0);
|
|
2028
2009
|
this.logError('更新订单定金状态失败:', _context19.t0);
|
|
2029
|
-
_context19.next =
|
|
2010
|
+
_context19.next = 28;
|
|
2030
2011
|
return this.handleError(_context19.t0, CheckoutErrorType.ValidationFailed);
|
|
2031
|
-
case
|
|
2012
|
+
case 28:
|
|
2032
2013
|
throw _context19.t0;
|
|
2033
|
-
case
|
|
2014
|
+
case 29:
|
|
2034
2015
|
case "end":
|
|
2035
2016
|
return _context19.stop();
|
|
2036
2017
|
}
|
|
2037
|
-
}, _callee19, this, [[0,
|
|
2018
|
+
}, _callee19, this, [[0, 23]]);
|
|
2038
2019
|
}));
|
|
2039
2020
|
function updateOrderDepositStatusAsync(_x19) {
|
|
2040
2021
|
return _updateOrderDepositStatusAsync.apply(this, arguments);
|
|
@@ -2189,7 +2170,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2189
2170
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2190
2171
|
while (1) switch (_context21.prev = _context21.next) {
|
|
2191
2172
|
case 0:
|
|
2192
|
-
console.log('manualSyncOrderAsync called');
|
|
2193
2173
|
this.logInfo('manualSyncOrderAsync called', {
|
|
2194
2174
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
2195
2175
|
currentOrderId: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.order_id,
|
|
@@ -2198,16 +2178,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2198
2178
|
isOrderSynced: this.store.isOrderSynced,
|
|
2199
2179
|
isVirtualOrderId: this.store.currentOrder ? isVirtualOrderId(this.store.currentOrder.order_id) : false
|
|
2200
2180
|
});
|
|
2201
|
-
_context21.prev =
|
|
2181
|
+
_context21.prev = 1;
|
|
2202
2182
|
if (this.store.currentOrder) {
|
|
2203
|
-
_context21.next =
|
|
2183
|
+
_context21.next = 4;
|
|
2204
2184
|
break;
|
|
2205
2185
|
}
|
|
2206
2186
|
return _context21.abrupt("return", {
|
|
2207
2187
|
success: false,
|
|
2208
2188
|
message: '当前没有活跃订单,无法同步'
|
|
2209
2189
|
});
|
|
2210
|
-
case
|
|
2190
|
+
case 4:
|
|
2211
2191
|
orderUuid = this.store.currentOrder.uuid;
|
|
2212
2192
|
oldOrderId = this.store.currentOrder.order_id; // 检查订单是否已经同步
|
|
2213
2193
|
if (this.store.isOrderSynced) {
|
|
@@ -2217,9 +2197,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2217
2197
|
_context21.t1 = orderUuid;
|
|
2218
2198
|
_context21.t2 = oldOrderId;
|
|
2219
2199
|
_context21.t3 = this.store.currentOrder.total_amount;
|
|
2220
|
-
_context21.next =
|
|
2200
|
+
_context21.next = 13;
|
|
2221
2201
|
return this.calculateRemainingAmountAsync();
|
|
2222
|
-
case
|
|
2202
|
+
case 13:
|
|
2223
2203
|
_context21.t4 = _context21.sent;
|
|
2224
2204
|
_context21.t5 = {
|
|
2225
2205
|
orderUuid: _context21.t1,
|
|
@@ -2228,14 +2208,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2228
2208
|
remainingAmount: _context21.t4
|
|
2229
2209
|
};
|
|
2230
2210
|
_context21.t0.logInfo.call(_context21.t0, '开始手动同步订单到后端:', _context21.t5);
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
// 强制同步订单到后端,并获取完整响应数据
|
|
2234
|
-
_context21.next = 20;
|
|
2211
|
+
_context21.next = 18;
|
|
2235
2212
|
return this.syncOrderToBackendWithReturn(true);
|
|
2236
|
-
case
|
|
2213
|
+
case 18:
|
|
2237
2214
|
syncResult = _context21.sent;
|
|
2238
|
-
console.timeEnd('manualSyncOrderAsync');
|
|
2239
2215
|
this.logInfo('手动同步订单完成:', {
|
|
2240
2216
|
orderUuid: orderUuid,
|
|
2241
2217
|
syncResult: syncResult,
|
|
@@ -2256,13 +2232,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2256
2232
|
newRes = _objectSpread(_objectSpread({}, syncResult), {}, {
|
|
2257
2233
|
is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0
|
|
2258
2234
|
});
|
|
2259
|
-
_context21.next =
|
|
2235
|
+
_context21.next = 27;
|
|
2260
2236
|
return this.updateStateAmountToRemaining(false);
|
|
2261
|
-
case
|
|
2237
|
+
case 27:
|
|
2262
2238
|
return _context21.abrupt("return", newRes);
|
|
2263
|
-
case
|
|
2264
|
-
_context21.prev =
|
|
2265
|
-
_context21.t6 = _context21["catch"](
|
|
2239
|
+
case 30:
|
|
2240
|
+
_context21.prev = 30;
|
|
2241
|
+
_context21.t6 = _context21["catch"](1);
|
|
2266
2242
|
this.logError('手动同步订单失败:', _context21.t6);
|
|
2267
2243
|
errorMessage = _context21.t6 instanceof Error ? _context21.t6.message : '同步失败';
|
|
2268
2244
|
return _context21.abrupt("return", {
|
|
@@ -2270,11 +2246,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2270
2246
|
message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
|
|
2271
2247
|
orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid
|
|
2272
2248
|
});
|
|
2273
|
-
case
|
|
2249
|
+
case 35:
|
|
2274
2250
|
case "end":
|
|
2275
2251
|
return _context21.stop();
|
|
2276
2252
|
}
|
|
2277
|
-
}, _callee21, this, [[
|
|
2253
|
+
}, _callee21, this, [[1, 30]]);
|
|
2278
2254
|
}));
|
|
2279
2255
|
function manualSyncOrderAsync() {
|
|
2280
2256
|
return _manualSyncOrderAsync.apply(this, arguments);
|
|
@@ -2291,7 +2267,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2291
2267
|
key: "getOrderNote",
|
|
2292
2268
|
value: function getOrderNote() {
|
|
2293
2269
|
if (!this.store.localOrderData) {
|
|
2294
|
-
console.log('[Checkout] 没有本地订单数据,无法获取备注');
|
|
2295
2270
|
return '';
|
|
2296
2271
|
}
|
|
2297
2272
|
return this.store.localOrderData.shop_note || '';
|
|
@@ -2321,15 +2296,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2321
2296
|
value: function isCurrentOrderSynced() {
|
|
2322
2297
|
// 如果没有当前订单,返回false
|
|
2323
2298
|
if (!this.store.currentOrder) {
|
|
2324
|
-
console.log('[Checkout] 没有当前订单,同步状态为false');
|
|
2325
2299
|
return false;
|
|
2326
2300
|
}
|
|
2327
2301
|
var syncStatus = this.store.isOrderSynced;
|
|
2328
|
-
console.log('[Checkout] 当前订单同步状态:', {
|
|
2329
|
-
orderUuid: this.store.currentOrder.uuid,
|
|
2330
|
-
orderId: this.store.currentOrder.order_id,
|
|
2331
|
-
isOrderSynced: syncStatus
|
|
2332
|
-
});
|
|
2333
2302
|
return syncStatus;
|
|
2334
2303
|
}
|
|
2335
2304
|
|
|
@@ -2548,7 +2517,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2548
2517
|
key: "updateOrderNoteAsync",
|
|
2549
2518
|
value: (function () {
|
|
2550
2519
|
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(note) {
|
|
2551
|
-
var _this$store$currentOr23,
|
|
2520
|
+
var _this$store$currentOr23, oldNote, orderInPayment;
|
|
2552
2521
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2553
2522
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2554
2523
|
case 0:
|
|
@@ -2559,65 +2528,51 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2559
2528
|
}
|
|
2560
2529
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
|
|
2561
2530
|
case 3:
|
|
2562
|
-
console.log('[Checkout] 更新订单备注:', {
|
|
2563
|
-
orderUuid: (_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.uuid,
|
|
2564
|
-
oldNote: this.store.localOrderData.shop_note,
|
|
2565
|
-
newNote: note
|
|
2566
|
-
});
|
|
2567
|
-
|
|
2568
2531
|
// 更新备注
|
|
2569
2532
|
oldNote = this.store.localOrderData.shop_note;
|
|
2570
2533
|
this.store.localOrderData.shop_note = note;
|
|
2571
2534
|
|
|
2572
2535
|
// 如果有当前订单,也同步到Payment模块中的订单数据
|
|
2573
2536
|
if (!this.store.currentOrder) {
|
|
2574
|
-
_context24.next =
|
|
2537
|
+
_context24.next = 16;
|
|
2575
2538
|
break;
|
|
2576
2539
|
}
|
|
2577
|
-
_context24.prev =
|
|
2578
|
-
_context24.next =
|
|
2540
|
+
_context24.prev = 6;
|
|
2541
|
+
_context24.next = 9;
|
|
2579
2542
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
2580
|
-
case
|
|
2543
|
+
case 9:
|
|
2581
2544
|
orderInPayment = _context24.sent;
|
|
2582
|
-
if (orderInPayment && orderInPayment.note !== undefined) {
|
|
2583
|
-
|
|
2584
|
-
// 这里可能需要根据Payment模块的实际API来调整
|
|
2585
|
-
console.log('[Checkout] 同步备注到Payment模块的订单数据中');
|
|
2586
|
-
}
|
|
2587
|
-
_context24.next = 17;
|
|
2545
|
+
if (orderInPayment && orderInPayment.note !== undefined) {}
|
|
2546
|
+
_context24.next = 16;
|
|
2588
2547
|
break;
|
|
2589
|
-
case
|
|
2590
|
-
_context24.prev =
|
|
2591
|
-
_context24.t0 = _context24["catch"](
|
|
2548
|
+
case 13:
|
|
2549
|
+
_context24.prev = 13;
|
|
2550
|
+
_context24.t0 = _context24["catch"](6);
|
|
2592
2551
|
console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context24.t0);
|
|
2593
|
-
case
|
|
2594
|
-
_context24.next =
|
|
2552
|
+
case 16:
|
|
2553
|
+
_context24.next = 18;
|
|
2595
2554
|
return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
|
|
2596
|
-
orderUuid: (_this$store$
|
|
2555
|
+
orderUuid: (_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.uuid,
|
|
2597
2556
|
oldNote: oldNote,
|
|
2598
2557
|
newNote: note,
|
|
2599
2558
|
timestamp: Date.now()
|
|
2600
2559
|
});
|
|
2601
|
-
case
|
|
2602
|
-
|
|
2603
|
-
oldNote: oldNote,
|
|
2604
|
-
newNote: note
|
|
2605
|
-
});
|
|
2606
|
-
_context24.next = 28;
|
|
2560
|
+
case 18:
|
|
2561
|
+
_context24.next = 26;
|
|
2607
2562
|
break;
|
|
2608
|
-
case
|
|
2609
|
-
_context24.prev =
|
|
2563
|
+
case 20:
|
|
2564
|
+
_context24.prev = 20;
|
|
2610
2565
|
_context24.t1 = _context24["catch"](0);
|
|
2611
2566
|
console.error('[Checkout] 更新订单备注失败:', _context24.t1);
|
|
2612
|
-
_context24.next =
|
|
2567
|
+
_context24.next = 25;
|
|
2613
2568
|
return this.handleError(_context24.t1, CheckoutErrorType.ValidationFailed);
|
|
2614
|
-
case
|
|
2569
|
+
case 25:
|
|
2615
2570
|
throw _context24.t1;
|
|
2616
|
-
case
|
|
2571
|
+
case 26:
|
|
2617
2572
|
case "end":
|
|
2618
2573
|
return _context24.stop();
|
|
2619
2574
|
}
|
|
2620
|
-
}, _callee24, this, [[0,
|
|
2575
|
+
}, _callee24, this, [[0, 20], [6, 13]]);
|
|
2621
2576
|
}));
|
|
2622
2577
|
function updateOrderNoteAsync(_x22) {
|
|
2623
2578
|
return _updateOrderNoteAsync.apply(this, arguments);
|
|
@@ -2665,7 +2620,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2665
2620
|
key: "handlePaymentSuccess",
|
|
2666
2621
|
value: (function () {
|
|
2667
2622
|
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data) {
|
|
2668
|
-
var _this$store$
|
|
2623
|
+
var _this$store$currentOr24;
|
|
2669
2624
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2670
2625
|
while (1) switch (_context26.prev = _context26.next) {
|
|
2671
2626
|
case 0:
|
|
@@ -2676,7 +2631,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2676
2631
|
return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
|
|
2677
2632
|
orderUuid: data.orderUuid,
|
|
2678
2633
|
paymentMethodCode: '',
|
|
2679
|
-
amount: ((_this$store$
|
|
2634
|
+
amount: ((_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.total_amount) || '0',
|
|
2680
2635
|
timestamp: data.timestamp
|
|
2681
2636
|
});
|
|
2682
2637
|
case 4:
|
|
@@ -2701,7 +2656,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2701
2656
|
key: "handlePaymentError",
|
|
2702
2657
|
value: (function () {
|
|
2703
2658
|
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(data) {
|
|
2704
|
-
var _this$store$
|
|
2659
|
+
var _this$store$currentOr25;
|
|
2705
2660
|
var error;
|
|
2706
2661
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2707
2662
|
while (1) switch (_context27.prev = _context27.next) {
|
|
@@ -2714,7 +2669,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2714
2669
|
return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
|
|
2715
2670
|
orderUuid: data.orderUuid,
|
|
2716
2671
|
paymentMethodCode: '',
|
|
2717
|
-
amount: ((_this$store$
|
|
2672
|
+
amount: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.total_amount) || '0',
|
|
2718
2673
|
timestamp: data.timestamp
|
|
2719
2674
|
});
|
|
2720
2675
|
case 5:
|
|
@@ -2842,25 +2797,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2842
2797
|
while (1) switch (_context29.prev = _context29.next) {
|
|
2843
2798
|
case 0:
|
|
2844
2799
|
_context29.prev = 0;
|
|
2845
|
-
|
|
2846
|
-
_context29.next = 4;
|
|
2800
|
+
_context29.next = 3;
|
|
2847
2801
|
return this.payment.getPayMethodListAsync();
|
|
2848
|
-
case
|
|
2802
|
+
case 3:
|
|
2849
2803
|
methods = _context29.sent;
|
|
2850
2804
|
this.store.paymentMethods = methods;
|
|
2851
|
-
|
|
2852
|
-
_context29.next = 13;
|
|
2805
|
+
_context29.next = 11;
|
|
2853
2806
|
break;
|
|
2854
|
-
case
|
|
2855
|
-
_context29.prev =
|
|
2807
|
+
case 7:
|
|
2808
|
+
_context29.prev = 7;
|
|
2856
2809
|
_context29.t0 = _context29["catch"](0);
|
|
2857
2810
|
console.error('[Checkout] 预加载支付方式失败:', _context29.t0);
|
|
2858
2811
|
this.store.paymentMethods = [];
|
|
2859
|
-
case
|
|
2812
|
+
case 11:
|
|
2860
2813
|
case "end":
|
|
2861
2814
|
return _context29.stop();
|
|
2862
2815
|
}
|
|
2863
|
-
}, _callee29, this, [[0,
|
|
2816
|
+
}, _callee29, this, [[0, 7]]);
|
|
2864
2817
|
}));
|
|
2865
2818
|
function preloadPaymentMethods() {
|
|
2866
2819
|
return _preloadPaymentMethods.apply(this, arguments);
|
|
@@ -2888,48 +2841,43 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2888
2841
|
retentionDays = cleanupConfig.retentionDays || 7; // 默认保留7天
|
|
2889
2842
|
maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100; // 默认最多删除100个订单
|
|
2890
2843
|
if (isCleanupEnabled) {
|
|
2891
|
-
_context30.next =
|
|
2844
|
+
_context30.next = 7;
|
|
2892
2845
|
break;
|
|
2893
2846
|
}
|
|
2894
|
-
console.log('[Checkout] 订单数据清理功能已禁用');
|
|
2895
2847
|
return _context30.abrupt("return");
|
|
2896
|
-
case
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
// 获取所有订单
|
|
2900
|
-
_context30.next = 11;
|
|
2848
|
+
case 7:
|
|
2849
|
+
_context30.next = 9;
|
|
2901
2850
|
return this.payment.getOrderListAsync();
|
|
2902
|
-
case
|
|
2851
|
+
case 9:
|
|
2903
2852
|
allOrders = _context30.sent;
|
|
2904
2853
|
if (!(!allOrders || allOrders.length === 0)) {
|
|
2905
|
-
_context30.next =
|
|
2854
|
+
_context30.next = 12;
|
|
2906
2855
|
break;
|
|
2907
2856
|
}
|
|
2908
|
-
console.log('[Checkout] 没有找到需要清理的订单数据');
|
|
2909
2857
|
return _context30.abrupt("return");
|
|
2910
|
-
case
|
|
2858
|
+
case 12:
|
|
2911
2859
|
thresholdDate = new Date();
|
|
2912
2860
|
thresholdDate.setDate(thresholdDate.getDate() - retentionDays);
|
|
2913
2861
|
deletedCount = 0;
|
|
2914
2862
|
ordersToDelete = [];
|
|
2915
2863
|
_iterator = _createForOfIteratorHelper(allOrders);
|
|
2916
|
-
_context30.prev =
|
|
2864
|
+
_context30.prev = 17;
|
|
2917
2865
|
_iterator.s();
|
|
2918
|
-
case
|
|
2866
|
+
case 19:
|
|
2919
2867
|
if ((_step = _iterator.n()).done) {
|
|
2920
|
-
_context30.next =
|
|
2868
|
+
_context30.next = 38;
|
|
2921
2869
|
break;
|
|
2922
2870
|
}
|
|
2923
2871
|
order = _step.value;
|
|
2924
|
-
_context30.prev =
|
|
2872
|
+
_context30.prev = 21;
|
|
2925
2873
|
// 检查订单是否已同步(订单ID不是虚拟ID)
|
|
2926
2874
|
isSynced = order.order_id && !isVirtualOrderId(order.order_id);
|
|
2927
2875
|
if (isSynced) {
|
|
2928
|
-
_context30.next =
|
|
2876
|
+
_context30.next = 25;
|
|
2929
2877
|
break;
|
|
2930
2878
|
}
|
|
2931
|
-
return _context30.abrupt("continue",
|
|
2932
|
-
case
|
|
2879
|
+
return _context30.abrupt("continue", 36);
|
|
2880
|
+
case 25:
|
|
2933
2881
|
// 检查创建时间
|
|
2934
2882
|
orderCreatedAt = null; // 尝试从 order_info.created_at 获取创建时间
|
|
2935
2883
|
if ((_order$order_info = order.order_info) !== null && _order$order_info !== void 0 && _order$order_info.created_at) {
|
|
@@ -2942,11 +2890,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2942
2890
|
|
|
2943
2891
|
// 如果无法获取创建时间,跳过此订单
|
|
2944
2892
|
if (!(!orderCreatedAt || isNaN(orderCreatedAt.getTime()))) {
|
|
2945
|
-
_context30.next =
|
|
2893
|
+
_context30.next = 29;
|
|
2946
2894
|
break;
|
|
2947
2895
|
}
|
|
2948
|
-
return _context30.abrupt("continue",
|
|
2949
|
-
case
|
|
2896
|
+
return _context30.abrupt("continue", 36);
|
|
2897
|
+
case 29:
|
|
2950
2898
|
// 检查是否超过指定天数
|
|
2951
2899
|
if (orderCreatedAt < thresholdDate) {
|
|
2952
2900
|
ordersToDelete.push({
|
|
@@ -2956,69 +2904,68 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2956
2904
|
daysSinceCreated: Math.floor((Date.now() - orderCreatedAt.getTime()) / (1000 * 60 * 60 * 24))
|
|
2957
2905
|
});
|
|
2958
2906
|
}
|
|
2959
|
-
_context30.next =
|
|
2907
|
+
_context30.next = 36;
|
|
2960
2908
|
break;
|
|
2961
|
-
case
|
|
2962
|
-
_context30.prev =
|
|
2963
|
-
_context30.t0 = _context30["catch"](
|
|
2909
|
+
case 32:
|
|
2910
|
+
_context30.prev = 32;
|
|
2911
|
+
_context30.t0 = _context30["catch"](21);
|
|
2964
2912
|
console.warn("[Checkout] \u5904\u7406\u8BA2\u5355 ".concat(order.uuid, " \u65F6\u51FA\u9519:"), _context30.t0);
|
|
2965
|
-
return _context30.abrupt("continue",
|
|
2966
|
-
case
|
|
2967
|
-
_context30.next =
|
|
2913
|
+
return _context30.abrupt("continue", 36);
|
|
2914
|
+
case 36:
|
|
2915
|
+
_context30.next = 19;
|
|
2968
2916
|
break;
|
|
2969
|
-
case
|
|
2970
|
-
_context30.next =
|
|
2917
|
+
case 38:
|
|
2918
|
+
_context30.next = 43;
|
|
2971
2919
|
break;
|
|
2920
|
+
case 40:
|
|
2921
|
+
_context30.prev = 40;
|
|
2922
|
+
_context30.t1 = _context30["catch"](17);
|
|
2923
|
+
_iterator.e(_context30.t1);
|
|
2972
2924
|
case 43:
|
|
2973
2925
|
_context30.prev = 43;
|
|
2974
|
-
_context30.t1 = _context30["catch"](20);
|
|
2975
|
-
_iterator.e(_context30.t1);
|
|
2976
|
-
case 46:
|
|
2977
|
-
_context30.prev = 46;
|
|
2978
2926
|
_iterator.f();
|
|
2979
|
-
return _context30.finish(
|
|
2980
|
-
case
|
|
2927
|
+
return _context30.finish(43);
|
|
2928
|
+
case 46:
|
|
2981
2929
|
// 按创建时间排序(最老的先删除)并限制删除数量
|
|
2982
2930
|
ordersToDelete.sort(function (a, b) {
|
|
2983
2931
|
return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
|
|
2984
2932
|
});
|
|
2985
2933
|
actualOrdersToDelete = ordersToDelete.slice(0, maxOrdersToDelete); // 删除符合条件的订单
|
|
2986
2934
|
_iterator2 = _createForOfIteratorHelper(actualOrdersToDelete);
|
|
2987
|
-
_context30.prev =
|
|
2935
|
+
_context30.prev = 49;
|
|
2988
2936
|
_iterator2.s();
|
|
2989
|
-
case
|
|
2937
|
+
case 51:
|
|
2990
2938
|
if ((_step2 = _iterator2.n()).done) {
|
|
2991
|
-
_context30.next =
|
|
2939
|
+
_context30.next = 64;
|
|
2992
2940
|
break;
|
|
2993
2941
|
}
|
|
2994
2942
|
orderInfo = _step2.value;
|
|
2995
|
-
_context30.prev =
|
|
2996
|
-
_context30.next =
|
|
2943
|
+
_context30.prev = 53;
|
|
2944
|
+
_context30.next = 56;
|
|
2997
2945
|
return this.payment.deletePaymentOrderAsync(orderInfo.uuid);
|
|
2998
|
-
case
|
|
2946
|
+
case 56:
|
|
2999
2947
|
deletedCount++;
|
|
3000
|
-
|
|
3001
|
-
_context30.next = 66;
|
|
2948
|
+
_context30.next = 62;
|
|
3002
2949
|
break;
|
|
3003
|
-
case
|
|
3004
|
-
_context30.prev =
|
|
3005
|
-
_context30.t2 = _context30["catch"](
|
|
2950
|
+
case 59:
|
|
2951
|
+
_context30.prev = 59;
|
|
2952
|
+
_context30.t2 = _context30["catch"](53);
|
|
3006
2953
|
console.error("[Checkout] \u5220\u9664\u8BA2\u5355 ".concat(orderInfo.uuid, " \u5931\u8D25:"), _context30.t2);
|
|
3007
|
-
case
|
|
3008
|
-
_context30.next =
|
|
2954
|
+
case 62:
|
|
2955
|
+
_context30.next = 51;
|
|
3009
2956
|
break;
|
|
3010
|
-
case
|
|
3011
|
-
_context30.next =
|
|
2957
|
+
case 64:
|
|
2958
|
+
_context30.next = 69;
|
|
3012
2959
|
break;
|
|
3013
|
-
case
|
|
3014
|
-
_context30.prev =
|
|
3015
|
-
_context30.t3 = _context30["catch"](
|
|
2960
|
+
case 66:
|
|
2961
|
+
_context30.prev = 66;
|
|
2962
|
+
_context30.t3 = _context30["catch"](49);
|
|
3016
2963
|
_iterator2.e(_context30.t3);
|
|
3017
|
-
case
|
|
3018
|
-
_context30.prev =
|
|
2964
|
+
case 69:
|
|
2965
|
+
_context30.prev = 69;
|
|
3019
2966
|
_iterator2.f();
|
|
3020
|
-
return _context30.finish(
|
|
3021
|
-
case
|
|
2967
|
+
return _context30.finish(69);
|
|
2968
|
+
case 72:
|
|
3022
2969
|
summary = {
|
|
3023
2970
|
totalOrders: allOrders.length,
|
|
3024
2971
|
expiredSyncedOrders: ordersToDelete.length,
|
|
@@ -3030,26 +2977,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3030
2977
|
skippedOrders: Math.max(0, ordersToDelete.length - maxOrdersToDelete)
|
|
3031
2978
|
}; // 记录清理结果
|
|
3032
2979
|
this.logInfo('Expired orders cleanup completed', summary);
|
|
3033
|
-
if (ordersToDelete.length > maxOrdersToDelete) {
|
|
3034
|
-
|
|
3035
|
-
} else {
|
|
3036
|
-
console.log("[Checkout] \u8FC7\u671F\u8BA2\u5355\u6E05\u7406\u5B8C\u6210: \u603B\u8BA1 ".concat(allOrders.length, " \u4E2A\u8BA2\u5355\uFF0C\u5220\u9664\u4E86 ").concat(deletedCount, " \u4E2A\u8FC7\u671F\u5DF2\u540C\u6B65\u8BA2\u5355"));
|
|
3037
|
-
}
|
|
3038
|
-
_context30.next = 86;
|
|
2980
|
+
if (ordersToDelete.length > maxOrdersToDelete) {} else {}
|
|
2981
|
+
_context30.next = 82;
|
|
3039
2982
|
break;
|
|
3040
|
-
case
|
|
3041
|
-
_context30.prev =
|
|
2983
|
+
case 77:
|
|
2984
|
+
_context30.prev = 77;
|
|
3042
2985
|
_context30.t4 = _context30["catch"](0);
|
|
3043
2986
|
errorMessage = _context30.t4 instanceof Error ? _context30.t4.message : String(_context30.t4);
|
|
3044
2987
|
console.error('[Checkout] 清理过期订单数据失败:', _context30.t4);
|
|
3045
2988
|
this.logError('Expired orders cleanup failed', {
|
|
3046
2989
|
error: errorMessage
|
|
3047
2990
|
});
|
|
3048
|
-
case
|
|
2991
|
+
case 82:
|
|
3049
2992
|
case "end":
|
|
3050
2993
|
return _context30.stop();
|
|
3051
2994
|
}
|
|
3052
|
-
}, _callee30, this, [[0,
|
|
2995
|
+
}, _callee30, this, [[0, 77], [17, 40, 43, 46], [21, 32], [49, 66, 69, 72], [53, 59]]);
|
|
3053
2996
|
}));
|
|
3054
2997
|
function cleanupExpiredOrdersAsync() {
|
|
3055
2998
|
return _cleanupExpiredOrdersAsync.apply(this, arguments);
|
|
@@ -3447,22 +3390,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3447
3390
|
}
|
|
3448
3391
|
return _context36.abrupt("return");
|
|
3449
3392
|
case 4:
|
|
3450
|
-
|
|
3451
|
-
// 🚀 性能优化:一次性批量获取所有需要的数据
|
|
3452
|
-
_context36.next = 7;
|
|
3393
|
+
_context36.next = 6;
|
|
3453
3394
|
return this.fetchOrderDataBatch();
|
|
3454
|
-
case
|
|
3395
|
+
case 6:
|
|
3455
3396
|
_yield$this$fetchOrde3 = _context36.sent;
|
|
3456
3397
|
paymentItems = _yield$this$fetchOrde3.paymentItems;
|
|
3457
3398
|
_currentOrder3 = _yield$this$fetchOrde3.currentOrder;
|
|
3458
|
-
console.timeEnd('updateStateAmountToRemaining');
|
|
3459
3399
|
if (_currentOrder3) {
|
|
3460
|
-
_context36.next =
|
|
3400
|
+
_context36.next = 12;
|
|
3461
3401
|
break;
|
|
3462
3402
|
}
|
|
3463
3403
|
this.logWarning('updateStateAmountToRemaining: 未找到当前订单');
|
|
3464
3404
|
return _context36.abrupt("return");
|
|
3465
|
-
case
|
|
3405
|
+
case 12:
|
|
3466
3406
|
// 🚀 性能优化:一次性计算所有金额(纯计算,不查询数据库)
|
|
3467
3407
|
paidAmount = this.calculatePaidAmountFromItems(paymentItems); // 缓存已支付金额,供其他方法使用
|
|
3468
3408
|
this.calculationCache.paidAmount = paidAmount;
|
|
@@ -3498,20 +3438,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3498
3438
|
currentBalanceDueAmount = this.store.balanceDueAmount; // 批量更新状态,减少操作次数
|
|
3499
3439
|
hasStateChanged = false; // 如果需要更新定金状态
|
|
3500
3440
|
if (!needUpdateDepositStatus) {
|
|
3501
|
-
_context36.next =
|
|
3441
|
+
_context36.next = 26;
|
|
3502
3442
|
break;
|
|
3503
3443
|
}
|
|
3504
3444
|
this.store.currentOrder = _objectSpread(_objectSpread({}, this.store.currentOrder), {}, {
|
|
3505
3445
|
is_deposit: 0
|
|
3506
3446
|
});
|
|
3507
|
-
_context36.next =
|
|
3447
|
+
_context36.next = 25;
|
|
3508
3448
|
return this.payment.updateOrderAsync(this.store.currentOrder.uuid, {
|
|
3509
3449
|
is_deposit: 0
|
|
3510
3450
|
});
|
|
3511
|
-
case
|
|
3451
|
+
case 25:
|
|
3512
3452
|
hasStateChanged = true;
|
|
3513
|
-
case
|
|
3514
|
-
console.time('updateStateAmountToRemaining: remainingAmount');
|
|
3453
|
+
case 26:
|
|
3515
3454
|
// 更新 stateAmount
|
|
3516
3455
|
if (remainingAmount !== currentStateAmount) {
|
|
3517
3456
|
this.store.stateAmount = remainingAmount;
|
|
@@ -3530,8 +3469,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3530
3469
|
newAmount: remainingAmount
|
|
3531
3470
|
});
|
|
3532
3471
|
}
|
|
3533
|
-
console.timeEnd('updateStateAmountToRemaining: remainingAmount');
|
|
3534
|
-
console.time('updateStateAmountToRemaining: updateStateAmountToRemaining');
|
|
3535
3472
|
// 更新 balanceDueAmount
|
|
3536
3473
|
if (remainingAmount !== currentBalanceDueAmount) {
|
|
3537
3474
|
this.store.balanceDueAmount = remainingAmount;
|
|
@@ -3551,7 +3488,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3551
3488
|
newAmount: remainingAmount
|
|
3552
3489
|
});
|
|
3553
3490
|
}
|
|
3554
|
-
console.timeEnd('updateStateAmountToRemaining: updateStateAmountToRemaining');
|
|
3555
3491
|
if (!hasStateChanged) {
|
|
3556
3492
|
this.logInfo('状态无需更新,当前值已是最新:', {
|
|
3557
3493
|
stateAmount: currentStateAmount,
|
|
@@ -3561,28 +3497,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3561
3497
|
|
|
3562
3498
|
// 检查订单支付完成(复用已获取的数据)
|
|
3563
3499
|
if (!checkOrder) {
|
|
3564
|
-
_context36.next =
|
|
3500
|
+
_context36.next = 34;
|
|
3565
3501
|
break;
|
|
3566
3502
|
}
|
|
3567
|
-
_context36.next =
|
|
3503
|
+
_context36.next = 32;
|
|
3568
3504
|
return this.checkOrderPaymentCompletionOptimized(paymentItems, remainingAmount);
|
|
3569
|
-
case
|
|
3570
|
-
_context36.next =
|
|
3505
|
+
case 32:
|
|
3506
|
+
_context36.next = 35;
|
|
3571
3507
|
break;
|
|
3572
|
-
case
|
|
3508
|
+
case 34:
|
|
3573
3509
|
this.logInfo('外部传入无需 checkOrder,不执行订单支付完成检测和同步');
|
|
3574
|
-
case
|
|
3575
|
-
_context36.next =
|
|
3510
|
+
case 35:
|
|
3511
|
+
_context36.next = 40;
|
|
3576
3512
|
break;
|
|
3577
|
-
case
|
|
3578
|
-
_context36.prev =
|
|
3513
|
+
case 37:
|
|
3514
|
+
_context36.prev = 37;
|
|
3579
3515
|
_context36.t0 = _context36["catch"](1);
|
|
3580
3516
|
this.logError('更新 stateAmount 为剩余金额失败:', _context36.t0);
|
|
3581
|
-
case
|
|
3517
|
+
case 40:
|
|
3582
3518
|
case "end":
|
|
3583
3519
|
return _context36.stop();
|
|
3584
3520
|
}
|
|
3585
|
-
}, _callee36, this, [[1,
|
|
3521
|
+
}, _callee36, this, [[1, 37]]);
|
|
3586
3522
|
}));
|
|
3587
3523
|
function updateStateAmountToRemaining() {
|
|
3588
3524
|
return _updateStateAmountToRemaining.apply(this, arguments);
|
|
@@ -4213,11 +4149,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4213
4149
|
resolveInFlight,
|
|
4214
4150
|
rejectInFlight,
|
|
4215
4151
|
inFlightPromise,
|
|
4152
|
+
_this$store$currentOr26,
|
|
4216
4153
|
_this$store$currentOr27,
|
|
4217
|
-
_this$store$currentOr28,
|
|
4218
4154
|
_this$store$currentCu2,
|
|
4219
4155
|
_this$otherParams2,
|
|
4220
|
-
_this$store$
|
|
4156
|
+
_this$store$currentOr28,
|
|
4221
4157
|
_this$store$localOrde,
|
|
4222
4158
|
_this$store$localOrde2,
|
|
4223
4159
|
_checkoutResponse12,
|
|
@@ -4334,7 +4270,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4334
4270
|
})
|
|
4335
4271
|
});
|
|
4336
4272
|
}); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
|
|
4337
|
-
manualDepositAmount = ((_this$store$
|
|
4273
|
+
manualDepositAmount = ((_this$store$currentOr26 = this.store.currentOrder) === null || _this$store$currentOr26 === void 0 ? void 0 : _this$store$currentOr26.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
|
|
4338
4274
|
manualDepositValue = new Decimal(manualDepositAmount);
|
|
4339
4275
|
if (manualDepositValue.gt(0)) {
|
|
4340
4276
|
// 如果手动设置了定金金额且大于0,使用手动设置的值
|
|
@@ -4394,7 +4330,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4394
4330
|
}),
|
|
4395
4331
|
manualDepositAmount: manualDepositAmount,
|
|
4396
4332
|
finalDepositAmount: finalDepositAmount,
|
|
4397
|
-
isDeposit: ((_this$store$
|
|
4333
|
+
isDeposit: ((_this$store$currentOr27 = this.store.currentOrder) === null || _this$store$currentOr27 === void 0 ? void 0 : _this$store$currentOr27.is_deposit) || 0
|
|
4398
4334
|
});
|
|
4399
4335
|
|
|
4400
4336
|
// 计算订单状态,优先读取外面传递的,如果没有则根据订单支付数据来
|
|
@@ -4442,7 +4378,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4442
4378
|
currency_symbol: this.otherParams.currency_symbol,
|
|
4443
4379
|
currency_format: this.otherParams.currency_format,
|
|
4444
4380
|
business_code: ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.business_code) || undefined,
|
|
4445
|
-
is_deposit: ((_this$store$
|
|
4381
|
+
is_deposit: ((_this$store$currentOr28 = this.store.currentOrder) !== null && _this$store$currentOr28 !== void 0 && _this$store$currentOr28.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
|
|
4446
4382
|
deposit_amount: finalDepositAmount,
|
|
4447
4383
|
// 使用最终确定的定金金额(手动设置优先)
|
|
4448
4384
|
product_tax_fee: this.store.localOrderData.tax_fee,
|
|
@@ -5085,8 +5021,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5085
5021
|
case 6:
|
|
5086
5022
|
// 取消注册模块
|
|
5087
5023
|
this.core.unregisterModule(this);
|
|
5088
|
-
|
|
5089
|
-
case 8:
|
|
5024
|
+
case 7:
|
|
5090
5025
|
case "end":
|
|
5091
5026
|
return _context46.stop();
|
|
5092
5027
|
}
|
|
@@ -5113,8 +5048,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5113
5048
|
uuid: this.store.currentOrder.uuid,
|
|
5114
5049
|
orderId: this.store.currentOrder.order_id
|
|
5115
5050
|
} : null;
|
|
5116
|
-
console.log('[Checkout] 重置 store 状态,准备创建新订单', prevOrderInfo);
|
|
5117
|
-
|
|
5118
5051
|
// 重置订单相关的 store 状态(保留 paymentMethods,因为支付方式数据变更不频繁)
|
|
5119
5052
|
this.store.currentOrder = undefined;
|
|
5120
5053
|
this.store.localOrderData = undefined;
|
|
@@ -5136,8 +5069,6 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
5136
5069
|
|
|
5137
5070
|
// 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
|
|
5138
5071
|
|
|
5139
|
-
console.log('[Checkout] Store 状态重置完成');
|
|
5140
|
-
|
|
5141
5072
|
// 🚀 性能优化:异步触发订单清理事件(不阻塞主流程)
|
|
5142
5073
|
// 使用 setTimeout 确保事件处理不会阻塞状态重置
|
|
5143
5074
|
if (prevOrderInfo) {
|