@pisell/pisellos 0.0.237 → 0.0.239
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/Discount/index.d.ts +1 -0
- package/dist/modules/Order/index.js +12 -6
- package/dist/modules/Payment/index.js +1 -1
- package/dist/modules/Payment/types.d.ts +2 -0
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +165 -135
- package/dist/solution/Checkout/types.d.ts +35 -1
- package/dist/solution/Checkout/types.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +65 -30
- package/dist/solution/ShopDiscount/types.d.ts +2 -1
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Order/index.js +14 -0
- package/lib/modules/Payment/index.js +1 -1
- package/lib/modules/Payment/types.d.ts +2 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Checkout/index.js +78 -17
- package/lib/solution/Checkout/types.d.ts +35 -1
- package/lib/solution/Checkout/types.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +20 -1
- package/lib/solution/ShopDiscount/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -26,6 +26,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
26
26
|
import { BaseModule } from "../BaseModule";
|
|
27
27
|
import { generateDuration, mergeRelationForms } from "./utils";
|
|
28
28
|
import { isNormalProduct } from "../Product/utils";
|
|
29
|
+
import dayjs from 'dayjs';
|
|
29
30
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
30
31
|
_inherits(OrderModule, _BaseModule);
|
|
31
32
|
var _super = _createSuper(OrderModule);
|
|
@@ -205,6 +206,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
205
206
|
orderData.bookings = [];
|
|
206
207
|
orderData.relation_products = [];
|
|
207
208
|
}
|
|
209
|
+
|
|
210
|
+
// 兜底策略,如果是第一次下单,没有 order_id,且没有 schedule_date,则设置为当前时间
|
|
211
|
+
if (!params.order_id && !orderData.schedule_date) {
|
|
212
|
+
orderData.schedule_date = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
213
|
+
}
|
|
208
214
|
console.log('[Order] 调用后端接口创建订单:', {
|
|
209
215
|
url: '/order/checkout',
|
|
210
216
|
orderType: orderData.type,
|
|
@@ -220,25 +226,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
220
226
|
});
|
|
221
227
|
|
|
222
228
|
// 调用后端接口
|
|
223
|
-
_context3.next =
|
|
229
|
+
_context3.next = 9;
|
|
224
230
|
return this.request.post('/order/checkout', orderData);
|
|
225
|
-
case
|
|
231
|
+
case 9:
|
|
226
232
|
response = _context3.sent;
|
|
227
233
|
console.log('[Order] 订单创建成功,后端响应:', {
|
|
228
234
|
success: !!response,
|
|
229
235
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
230
236
|
});
|
|
231
237
|
return _context3.abrupt("return", response);
|
|
232
|
-
case
|
|
233
|
-
_context3.prev =
|
|
238
|
+
case 14:
|
|
239
|
+
_context3.prev = 14;
|
|
234
240
|
_context3.t0 = _context3["catch"](1);
|
|
235
241
|
console.error('[Order] createOrderByCheckout 创建订单失败:', _context3.t0);
|
|
236
242
|
throw _context3.t0;
|
|
237
|
-
case
|
|
243
|
+
case 18:
|
|
238
244
|
case "end":
|
|
239
245
|
return _context3.stop();
|
|
240
246
|
}
|
|
241
|
-
}, _callee3, this, [[1,
|
|
247
|
+
}, _callee3, this, [[1, 14]]);
|
|
242
248
|
}));
|
|
243
249
|
function createOrderByCheckout(_x4) {
|
|
244
250
|
return _createOrderByCheckout.apply(this, arguments);
|
|
@@ -1059,7 +1059,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1059
1059
|
type: paymentItem.type,
|
|
1060
1060
|
amount: formatAmount(paymentItem.amount),
|
|
1061
1061
|
voucher_id: paymentItem.voucher_id || '',
|
|
1062
|
-
rounding_amount: '0.00',
|
|
1062
|
+
rounding_amount: paymentItem.rounding_amount || '0.00',
|
|
1063
1063
|
service_charge: paymentItem.service_charge,
|
|
1064
1064
|
status: 'active',
|
|
1065
1065
|
// 新支付项默认为活跃状态
|
|
@@ -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 客户状态
|
|
@@ -1641,7 +1641,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1641
1641
|
key: "addPaymentItemAsync",
|
|
1642
1642
|
value: (function () {
|
|
1643
1643
|
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paymentItem) {
|
|
1644
|
-
var
|
|
1644
|
+
var _paymentItem$type, _paymentItem$code, isEftposPayment;
|
|
1645
1645
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1646
1646
|
while (1) switch (_context25.prev = _context25.next) {
|
|
1647
1647
|
case 0:
|
|
@@ -1659,7 +1659,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1659
1659
|
name: paymentItem.name,
|
|
1660
1660
|
type: paymentItem.type,
|
|
1661
1661
|
amount: paymentItem.amount,
|
|
1662
|
-
service_charge: paymentItem.service_charge
|
|
1662
|
+
service_charge: paymentItem.service_charge,
|
|
1663
|
+
rounding_amount: paymentItem.rounding_amount,
|
|
1664
|
+
voucher_id: paymentItem.voucher_id
|
|
1663
1665
|
}
|
|
1664
1666
|
});
|
|
1665
1667
|
|
|
@@ -1669,89 +1671,63 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1669
1671
|
case 6:
|
|
1670
1672
|
console.log('[Checkout] 支付项添加成功');
|
|
1671
1673
|
|
|
1672
|
-
//
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1674
|
+
// 检查是否是 EFTPOS 支付,如果是则立即同步订单
|
|
1675
|
+
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'));
|
|
1676
|
+
console.log('[Checkout] EFTPOS 支付检查:', {
|
|
1677
|
+
paymentCode: paymentItem.code,
|
|
1678
|
+
paymentType: paymentItem.type,
|
|
1679
|
+
isEftposPayment: isEftposPayment,
|
|
1680
|
+
currentOrderSynced: this.store.isOrderSynced
|
|
1678
1681
|
});
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
// 当前真实ID: currentOrderId,
|
|
1686
|
-
// 获取到的虚拟ID: updatedOrder.order_id
|
|
1687
|
-
// });
|
|
1688
|
-
// updatedOrder.order_id = currentOrderId; // 恢复真实的订单ID
|
|
1689
|
-
// }
|
|
1690
|
-
|
|
1691
|
-
// this.store.currentOrder = updatedOrder;
|
|
1692
|
-
// console.log('[Checkout] 订单数据已同步:', {
|
|
1693
|
-
// 支付项数量: updatedOrder.payment.length,
|
|
1694
|
-
// 最终订单ID: updatedOrder.order_id,
|
|
1695
|
-
// 是否为虚拟ID: this.isVirtualOrderId(updatedOrder.order_id)
|
|
1696
|
-
// });
|
|
1697
|
-
// }
|
|
1698
|
-
|
|
1699
|
-
// // 检查是否需要同步订单到后端
|
|
1700
|
-
// const needsOrderSync = this.shouldSyncOrderForPayment(paymentItem.code, paymentItem.type);
|
|
1701
|
-
|
|
1702
|
-
// console.log('[Checkout] 支付项同步检查:', {
|
|
1703
|
-
// paymentCode: paymentItem.code,
|
|
1704
|
-
// paymentType: paymentItem.type,
|
|
1705
|
-
// paymentAmount: paymentItem.amount,
|
|
1706
|
-
// expectedCashCode: PaymentMethodType.Cash,
|
|
1707
|
-
// needsOrderSync,
|
|
1708
|
-
// isOrderSynced: this.store.isOrderSynced
|
|
1709
|
-
// });
|
|
1710
|
-
|
|
1711
|
-
// if (needsOrderSync) {
|
|
1712
|
-
// console.log('[Checkout] 检测到非现金/自定义支付,开始同步订单到后端...', {
|
|
1713
|
-
// 同步前订单ID: this.store.currentOrder.order_id,
|
|
1714
|
-
// 是否为虚拟ID: this.isVirtualOrderId(this.store.currentOrder.order_id),
|
|
1715
|
-
// 订单同步状态: this.store.isOrderSynced,
|
|
1716
|
-
// 订单UUID: this.store.currentOrder.uuid
|
|
1717
|
-
// });
|
|
1718
|
-
|
|
1719
|
-
// await this.syncOrderToBackend();
|
|
1720
|
-
|
|
1721
|
-
// console.log('[Checkout] addPaymentItemAsync 中的同步完成:', {
|
|
1722
|
-
// 同步后订单ID: this.store.currentOrder.order_id,
|
|
1723
|
-
// 是否为虚拟ID: this.isVirtualOrderId(this.store.currentOrder.order_id),
|
|
1724
|
-
// 订单同步状态: this.store.isOrderSynced
|
|
1725
|
-
// });
|
|
1726
|
-
// }
|
|
1727
|
-
|
|
1728
|
-
// 支付项添加后,更新 stateAmount 为剩余未支付金额
|
|
1729
|
-
_context25.next = 12;
|
|
1730
|
-
return this.updateStateAmountToRemaining();
|
|
1731
|
-
case 12:
|
|
1682
|
+
if (!isEftposPayment) {
|
|
1683
|
+
_context25.next = 22;
|
|
1684
|
+
break;
|
|
1685
|
+
}
|
|
1686
|
+
console.log('[Checkout] 检测到 EFTPOS 支付,立即同步订单到后端...');
|
|
1687
|
+
_context25.prev = 11;
|
|
1732
1688
|
_context25.next = 14;
|
|
1689
|
+
return this.syncOrderToBackendWithReturn(true);
|
|
1690
|
+
case 14:
|
|
1691
|
+
console.log('[Checkout] EFTPOS 支付后订单同步完成 (已标记为手动同步):', {
|
|
1692
|
+
订单ID: this.store.currentOrder.order_id,
|
|
1693
|
+
是否已同步: this.store.isOrderSynced
|
|
1694
|
+
});
|
|
1695
|
+
_context25.next = 22;
|
|
1696
|
+
break;
|
|
1697
|
+
case 17:
|
|
1698
|
+
_context25.prev = 17;
|
|
1699
|
+
_context25.t0 = _context25["catch"](11);
|
|
1700
|
+
console.error('[Checkout] EFTPOS 支付后订单同步失败:', _context25.t0);
|
|
1701
|
+
// 不抛出错误,避免影响支付流程,但记录错误
|
|
1702
|
+
_context25.next = 22;
|
|
1703
|
+
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1704
|
+
case 22:
|
|
1705
|
+
_context25.next = 24;
|
|
1706
|
+
return this.updateStateAmountToRemaining();
|
|
1707
|
+
case 24:
|
|
1708
|
+
_context25.next = 26;
|
|
1733
1709
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1734
1710
|
orderUuid: this.store.currentOrder.uuid,
|
|
1735
1711
|
paymentMethodCode: paymentItem.code,
|
|
1736
1712
|
amount: String(paymentItem.amount),
|
|
1737
1713
|
timestamp: Date.now()
|
|
1738
1714
|
});
|
|
1739
|
-
case
|
|
1740
|
-
_context25.next =
|
|
1715
|
+
case 26:
|
|
1716
|
+
_context25.next = 34;
|
|
1741
1717
|
break;
|
|
1742
|
-
case
|
|
1743
|
-
_context25.prev =
|
|
1744
|
-
_context25.
|
|
1745
|
-
console.error('[Checkout] 添加支付项失败:', _context25.
|
|
1746
|
-
_context25.next =
|
|
1747
|
-
return this.handleError(_context25.
|
|
1748
|
-
case
|
|
1749
|
-
throw _context25.
|
|
1750
|
-
case
|
|
1718
|
+
case 28:
|
|
1719
|
+
_context25.prev = 28;
|
|
1720
|
+
_context25.t1 = _context25["catch"](0);
|
|
1721
|
+
console.error('[Checkout] 添加支付项失败:', _context25.t1);
|
|
1722
|
+
_context25.next = 33;
|
|
1723
|
+
return this.handleError(_context25.t1, CheckoutErrorType.PaymentFailed);
|
|
1724
|
+
case 33:
|
|
1725
|
+
throw _context25.t1;
|
|
1726
|
+
case 34:
|
|
1751
1727
|
case "end":
|
|
1752
1728
|
return _context25.stop();
|
|
1753
1729
|
}
|
|
1754
|
-
}, _callee25, this, [[0,
|
|
1730
|
+
}, _callee25, this, [[0, 28], [11, 17]]);
|
|
1755
1731
|
}));
|
|
1756
1732
|
function addPaymentItemAsync(_x16) {
|
|
1757
1733
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
@@ -2569,10 +2545,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2569
2545
|
allPaymentItems = _context33.sent;
|
|
2570
2546
|
// 过滤掉带有 voucher_id 的支付项(代金券类支付项)
|
|
2571
2547
|
filteredPaymentItems = allPaymentItems.filter(function (payment) {
|
|
2572
|
-
return !payment.voucher_id
|
|
2548
|
+
return !payment.voucher_id;
|
|
2573
2549
|
}); // 记录过滤结果
|
|
2574
2550
|
voucherItems = allPaymentItems.filter(function (payment) {
|
|
2575
|
-
return payment.voucher_id
|
|
2551
|
+
return payment.voucher_id;
|
|
2576
2552
|
});
|
|
2577
2553
|
console.log('[Checkout] 支付项过滤结果:', {
|
|
2578
2554
|
总支付项: allPaymentItems.length,
|
|
@@ -3436,7 +3412,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3436
3412
|
key: "checkOrderPaymentCompletion",
|
|
3437
3413
|
value: (function () {
|
|
3438
3414
|
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3439
|
-
var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, allPaymentsHaveVoucherId;
|
|
3415
|
+
var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, hasPaymentItems, allPaymentsHaveVoucherId, shouldAutoSync;
|
|
3440
3416
|
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3441
3417
|
while (1) switch (_context47.prev = _context47.next) {
|
|
3442
3418
|
case 0:
|
|
@@ -3453,7 +3429,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3453
3429
|
remainingAmount = _context47.sent;
|
|
3454
3430
|
remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
|
|
3455
3431
|
if (!(remainingValue <= 0)) {
|
|
3456
|
-
_context47.next =
|
|
3432
|
+
_context47.next = 29;
|
|
3457
3433
|
break;
|
|
3458
3434
|
}
|
|
3459
3435
|
totalAmount = this.store.currentOrder.total_amount;
|
|
@@ -3470,18 +3446,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3470
3446
|
isOrderSynced: this.store.isOrderSynced
|
|
3471
3447
|
});
|
|
3472
3448
|
|
|
3473
|
-
// 从 Payment
|
|
3449
|
+
// 从 Payment 模块获取最新支付项,检查自动同步条件
|
|
3474
3450
|
_context47.next = 15;
|
|
3475
3451
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3476
3452
|
);
|
|
3477
3453
|
case 15:
|
|
3478
3454
|
currentPayments = _context47.sent;
|
|
3479
|
-
|
|
3455
|
+
// 检查自动同步条件:
|
|
3456
|
+
// 1. 待付金额为 0 ✓ (已在上面检查)
|
|
3457
|
+
// 2. 需要有支付项
|
|
3458
|
+
// 3. 支付项不能全是带 voucher_id 的数据
|
|
3459
|
+
hasPaymentItems = currentPayments.length > 0;
|
|
3460
|
+
allPaymentsHaveVoucherId = hasPaymentItems && currentPayments.every(function (item) {
|
|
3480
3461
|
return item.status !== 'voided' && item.voucher_id;
|
|
3481
|
-
});
|
|
3482
|
-
|
|
3462
|
+
}); // 判断是否需要自动同步订单
|
|
3463
|
+
// 条件:
|
|
3464
|
+
// 1. 有支付项
|
|
3465
|
+
// 2. 不全是代金券支付
|
|
3466
|
+
// 3. 订单未同步 OR (订单已同步但支付刚完成,需要同步最终支付状态)
|
|
3467
|
+
shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
3468
|
+
console.log('[Checkout] 自动同步订单条件检查:', {
|
|
3483
3469
|
paymentCount: currentPayments.length,
|
|
3470
|
+
hasPaymentItems: hasPaymentItems,
|
|
3484
3471
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
3472
|
+
isOrderSynced: this.store.isOrderSynced,
|
|
3473
|
+
shouldAutoSync: shouldAutoSync,
|
|
3474
|
+
reason: shouldAutoSync ? '支付完成,需要同步最终支付状态' : '跳过同步',
|
|
3485
3475
|
paymentItems: currentPayments.map(function (p) {
|
|
3486
3476
|
return {
|
|
3487
3477
|
uuid: p.uuid,
|
|
@@ -3492,29 +3482,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3492
3482
|
};
|
|
3493
3483
|
})
|
|
3494
3484
|
});
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
// if (!this.store.isOrderSynced) {
|
|
3498
|
-
// if (allPaymentsHaveVoucherId) {
|
|
3499
|
-
// console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
|
|
3500
|
-
// } else {
|
|
3501
|
-
// console.log('[Checkout] 支付完成但订单未同步,开始同步订单到后端...');
|
|
3502
|
-
// await this.syncOrderToBackend();
|
|
3503
|
-
// }
|
|
3504
|
-
// }
|
|
3505
|
-
if (!allPaymentsHaveVoucherId) {
|
|
3506
|
-
_context47.next = 22;
|
|
3485
|
+
if (!shouldAutoSync) {
|
|
3486
|
+
_context47.next = 26;
|
|
3507
3487
|
break;
|
|
3508
3488
|
}
|
|
3509
|
-
console.log('[Checkout]
|
|
3510
|
-
_context47.next =
|
|
3511
|
-
break;
|
|
3512
|
-
case 22:
|
|
3513
|
-
console.log('[Checkout] 支付完成但订单未同步,开始同步订单到后端...');
|
|
3514
|
-
_context47.next = 25;
|
|
3489
|
+
console.log('[Checkout] 满足自动同步条件,开始同步订单到后端...');
|
|
3490
|
+
_context47.next = 24;
|
|
3515
3491
|
return this.syncOrderToBackend();
|
|
3516
|
-
case
|
|
3492
|
+
case 24:
|
|
3517
3493
|
_context47.next = 27;
|
|
3494
|
+
break;
|
|
3495
|
+
case 26:
|
|
3496
|
+
if (!hasPaymentItems) {
|
|
3497
|
+
console.log('[Checkout] 没有支付项,跳过订单同步');
|
|
3498
|
+
} else if (allPaymentsHaveVoucherId) {
|
|
3499
|
+
console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
|
|
3500
|
+
}
|
|
3501
|
+
case 27:
|
|
3502
|
+
_context47.next = 29;
|
|
3518
3503
|
return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
|
|
3519
3504
|
orderUuid: this.store.currentOrder.uuid,
|
|
3520
3505
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3523,18 +3508,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3523
3508
|
remainingAmount: remainingAmount,
|
|
3524
3509
|
timestamp: Date.now()
|
|
3525
3510
|
});
|
|
3526
|
-
case 27:
|
|
3527
|
-
_context47.next = 32;
|
|
3528
|
-
break;
|
|
3529
3511
|
case 29:
|
|
3530
|
-
_context47.
|
|
3512
|
+
_context47.next = 34;
|
|
3513
|
+
break;
|
|
3514
|
+
case 31:
|
|
3515
|
+
_context47.prev = 31;
|
|
3531
3516
|
_context47.t0 = _context47["catch"](0);
|
|
3532
3517
|
console.error('[Checkout] 检查订单支付完成状态失败:', _context47.t0);
|
|
3533
|
-
case
|
|
3518
|
+
case 34:
|
|
3534
3519
|
case "end":
|
|
3535
3520
|
return _context47.stop();
|
|
3536
3521
|
}
|
|
3537
|
-
}, _callee47, this, [[0,
|
|
3522
|
+
}, _callee47, this, [[0, 31]]);
|
|
3538
3523
|
}));
|
|
3539
3524
|
function checkOrderPaymentCompletion() {
|
|
3540
3525
|
return _checkOrderPaymentCompletion.apply(this, arguments);
|
|
@@ -3607,7 +3592,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3607
3592
|
key: "syncOrderToBackendWithReturn",
|
|
3608
3593
|
value: (function () {
|
|
3609
3594
|
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
3610
|
-
var _this$store$currentCu2, _this$store$currentOr18, _this$store$currentOr19;
|
|
3595
|
+
var _this$store$currentCu2, _this$store$currentOr18, _this$store$currentOr19, _checkoutResponse3, _checkoutResponse4, _checkoutResponse5, _checkoutResponse6;
|
|
3611
3596
|
var isManual,
|
|
3612
3597
|
customPaymentItems,
|
|
3613
3598
|
syncType,
|
|
@@ -3618,10 +3603,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3618
3603
|
operation,
|
|
3619
3604
|
paymentItems,
|
|
3620
3605
|
orderParams,
|
|
3606
|
+
startTime,
|
|
3621
3607
|
checkoutResponse,
|
|
3608
|
+
submitSuccess,
|
|
3609
|
+
submitError,
|
|
3610
|
+
_checkoutResponse,
|
|
3611
|
+
_checkoutResponse2,
|
|
3622
3612
|
realOrderId,
|
|
3623
|
-
|
|
3613
|
+
_checkoutResponse7,
|
|
3624
3614
|
extractedOrderId,
|
|
3615
|
+
_checkoutResponse8,
|
|
3625
3616
|
updatedOrder,
|
|
3626
3617
|
beforeManualUpdate,
|
|
3627
3618
|
finalOrderId,
|
|
@@ -3755,31 +3746,70 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3755
3746
|
console.log('[Checkout] 创建新订单操作');
|
|
3756
3747
|
}
|
|
3757
3748
|
|
|
3758
|
-
//
|
|
3759
|
-
|
|
3749
|
+
// 发送下单接口请求开始事件
|
|
3750
|
+
startTime = Date.now();
|
|
3751
|
+
_context48.next = 25;
|
|
3752
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
|
|
3753
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
3754
|
+
operation: isUpdateOperation ? 'update' : 'create',
|
|
3755
|
+
isManual: isManual,
|
|
3756
|
+
paymentItemCount: paymentItems.length,
|
|
3757
|
+
timestamp: startTime
|
|
3758
|
+
});
|
|
3759
|
+
case 25:
|
|
3760
|
+
submitSuccess = false;
|
|
3761
|
+
_context48.prev = 26;
|
|
3762
|
+
_context48.next = 29;
|
|
3760
3763
|
return this.order.createOrderByCheckout(orderParams);
|
|
3761
|
-
case
|
|
3764
|
+
case 29:
|
|
3762
3765
|
checkoutResponse = _context48.sent;
|
|
3766
|
+
submitSuccess = true;
|
|
3767
|
+
console.log('[Checkout] 下单接口调用成功');
|
|
3768
|
+
_context48.next = 40;
|
|
3769
|
+
break;
|
|
3770
|
+
case 34:
|
|
3771
|
+
_context48.prev = 34;
|
|
3772
|
+
_context48.t1 = _context48["catch"](26);
|
|
3773
|
+
submitSuccess = false;
|
|
3774
|
+
submitError = _context48.t1 instanceof Error ? _context48.t1.message : String(_context48.t1);
|
|
3775
|
+
console.error('[Checkout] 下单接口调用失败:', submitError);
|
|
3776
|
+
throw _context48.t1;
|
|
3777
|
+
case 40:
|
|
3778
|
+
_context48.prev = 40;
|
|
3779
|
+
_context48.next = 43;
|
|
3780
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
|
|
3781
|
+
success: submitSuccess,
|
|
3782
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
3783
|
+
operation: isUpdateOperation ? 'update' : 'create',
|
|
3784
|
+
isManual: isManual,
|
|
3785
|
+
orderId: submitSuccess ? ((_checkoutResponse = checkoutResponse) === null || _checkoutResponse === void 0 || (_checkoutResponse = _checkoutResponse.data) === null || _checkoutResponse === void 0 ? void 0 : _checkoutResponse.order_id) || ((_checkoutResponse2 = checkoutResponse) === null || _checkoutResponse2 === void 0 ? void 0 : _checkoutResponse2.order_id) : undefined,
|
|
3786
|
+
error: submitError,
|
|
3787
|
+
duration: Date.now() - startTime,
|
|
3788
|
+
timestamp: Date.now()
|
|
3789
|
+
});
|
|
3790
|
+
case 43:
|
|
3791
|
+
return _context48.finish(40);
|
|
3792
|
+
case 44:
|
|
3763
3793
|
console.log('[Checkout] 后端返回的响应数据:', {
|
|
3764
|
-
status: checkoutResponse === null ||
|
|
3765
|
-
code: checkoutResponse === null ||
|
|
3766
|
-
message: checkoutResponse === null ||
|
|
3767
|
-
data: checkoutResponse === null ||
|
|
3794
|
+
status: (_checkoutResponse3 = checkoutResponse) === null || _checkoutResponse3 === void 0 ? void 0 : _checkoutResponse3.status,
|
|
3795
|
+
code: (_checkoutResponse4 = checkoutResponse) === null || _checkoutResponse4 === void 0 ? void 0 : _checkoutResponse4.code,
|
|
3796
|
+
message: (_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message,
|
|
3797
|
+
data: (_checkoutResponse6 = checkoutResponse) === null || _checkoutResponse6 === void 0 ? void 0 : _checkoutResponse6.data
|
|
3768
3798
|
});
|
|
3769
3799
|
if (!isUpdateOperation) {
|
|
3770
|
-
_context48.next =
|
|
3800
|
+
_context48.next = 50;
|
|
3771
3801
|
break;
|
|
3772
3802
|
}
|
|
3773
3803
|
// 更新操作:使用现有的订单ID
|
|
3774
3804
|
realOrderId = currentOrderId;
|
|
3775
3805
|
console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
|
|
3776
|
-
_context48.next =
|
|
3806
|
+
_context48.next = 71;
|
|
3777
3807
|
break;
|
|
3778
|
-
case
|
|
3808
|
+
case 50:
|
|
3779
3809
|
// 创建操作:从响应中提取新的订单ID
|
|
3780
|
-
extractedOrderId = checkoutResponse === null ||
|
|
3810
|
+
extractedOrderId = (_checkoutResponse7 = checkoutResponse) === null || _checkoutResponse7 === void 0 || (_checkoutResponse7 = _checkoutResponse7.data) === null || _checkoutResponse7 === void 0 ? void 0 : _checkoutResponse7.order_id; // 如果data.order_id不存在,尝试直接从根级获取
|
|
3781
3811
|
if (!extractedOrderId) {
|
|
3782
|
-
extractedOrderId = checkoutResponse === null ||
|
|
3812
|
+
extractedOrderId = (_checkoutResponse8 = checkoutResponse) === null || _checkoutResponse8 === void 0 ? void 0 : _checkoutResponse8.order_id;
|
|
3783
3813
|
}
|
|
3784
3814
|
|
|
3785
3815
|
// 确保转换为字符串类型
|
|
@@ -3787,11 +3817,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3787
3817
|
extractedOrderId = String(extractedOrderId);
|
|
3788
3818
|
}
|
|
3789
3819
|
if (extractedOrderId) {
|
|
3790
|
-
_context48.next =
|
|
3820
|
+
_context48.next = 55;
|
|
3791
3821
|
break;
|
|
3792
3822
|
}
|
|
3793
3823
|
throw new Error('后端返回的订单信息中未包含订单ID');
|
|
3794
|
-
case
|
|
3824
|
+
case 55:
|
|
3795
3825
|
realOrderId = extractedOrderId;
|
|
3796
3826
|
console.log('[Checkout] 订单创建成功,真实订单ID:', realOrderId);
|
|
3797
3827
|
|
|
@@ -3801,10 +3831,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3801
3831
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3802
3832
|
newOrderId: realOrderId
|
|
3803
3833
|
});
|
|
3804
|
-
_context48.prev =
|
|
3805
|
-
_context48.next =
|
|
3834
|
+
_context48.prev = 58;
|
|
3835
|
+
_context48.next = 61;
|
|
3806
3836
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3807
|
-
case
|
|
3837
|
+
case 61:
|
|
3808
3838
|
updatedOrder = _context48.sent;
|
|
3809
3839
|
console.log('[Checkout] Payment模块替换订单ID结果:', {
|
|
3810
3840
|
wasSuccessful: !!updatedOrder,
|
|
@@ -3831,22 +3861,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3831
3861
|
目标ID: realOrderId
|
|
3832
3862
|
});
|
|
3833
3863
|
}
|
|
3834
|
-
_context48.next =
|
|
3864
|
+
_context48.next = 71;
|
|
3835
3865
|
break;
|
|
3836
|
-
case
|
|
3837
|
-
_context48.prev =
|
|
3838
|
-
_context48.
|
|
3839
|
-
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context48.
|
|
3866
|
+
case 66:
|
|
3867
|
+
_context48.prev = 66;
|
|
3868
|
+
_context48.t2 = _context48["catch"](58);
|
|
3869
|
+
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context48.t2);
|
|
3840
3870
|
|
|
3841
3871
|
// 发生错误时也进行手动替换
|
|
3842
3872
|
this.store.currentOrder.order_id = realOrderId;
|
|
3843
3873
|
console.log('[Checkout] 错误恢复:手动设置订单ID:', realOrderId);
|
|
3844
|
-
case
|
|
3874
|
+
case 71:
|
|
3845
3875
|
// 标记订单已同步
|
|
3846
3876
|
this.store.isOrderSynced = true;
|
|
3847
3877
|
|
|
3848
3878
|
// 触发订单同步完成事件
|
|
3849
|
-
_context48.next =
|
|
3879
|
+
_context48.next = 74;
|
|
3850
3880
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
3851
3881
|
orderUuid: this.store.currentOrder.uuid,
|
|
3852
3882
|
realOrderId: realOrderId,
|
|
@@ -3855,7 +3885,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3855
3885
|
isManual: isManual,
|
|
3856
3886
|
response: checkoutResponse
|
|
3857
3887
|
});
|
|
3858
|
-
case
|
|
3888
|
+
case 74:
|
|
3859
3889
|
// 验证最终状态
|
|
3860
3890
|
finalOrderId = this.store.currentOrder.order_id;
|
|
3861
3891
|
finalIsVirtual = this.isVirtualOrderId(finalOrderId || '');
|
|
@@ -3873,11 +3903,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3873
3903
|
|
|
3874
3904
|
// 返回真实订单ID
|
|
3875
3905
|
return _context48.abrupt("return", realOrderId);
|
|
3876
|
-
case
|
|
3906
|
+
case 79:
|
|
3877
3907
|
case "end":
|
|
3878
3908
|
return _context48.stop();
|
|
3879
3909
|
}
|
|
3880
|
-
}, _callee48, this, [[
|
|
3910
|
+
}, _callee48, this, [[26, 34, 40, 44], [58, 66]]);
|
|
3881
3911
|
}));
|
|
3882
3912
|
function syncOrderToBackendWithReturn() {
|
|
3883
3913
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -393,7 +393,11 @@ export declare enum CheckoutHooks {
|
|
|
393
393
|
/** 订单取消 */
|
|
394
394
|
OnOrderCancelled = "checkout:onOrderCancelled",
|
|
395
395
|
/** 订单状态已清理 */
|
|
396
|
-
OnOrderCleared = "checkout:onOrderCleared"
|
|
396
|
+
OnOrderCleared = "checkout:onOrderCleared",
|
|
397
|
+
/** 下单接口请求开始 */
|
|
398
|
+
OnOrderSubmitStart = "checkout:onOrderSubmitStart",
|
|
399
|
+
/** 下单接口请求完成 */
|
|
400
|
+
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd"
|
|
397
401
|
}
|
|
398
402
|
/**
|
|
399
403
|
* 结账状态数据
|
|
@@ -824,4 +828,34 @@ export interface CheckoutEventData {
|
|
|
824
828
|
} | null;
|
|
825
829
|
timestamp: number;
|
|
826
830
|
};
|
|
831
|
+
/** 下单接口请求开始事件 */
|
|
832
|
+
orderSubmitStart: {
|
|
833
|
+
/** 订单UUID */
|
|
834
|
+
orderUuid: string;
|
|
835
|
+
/** 操作类型 */
|
|
836
|
+
operation: 'create' | 'update';
|
|
837
|
+
/** 是否手动同步 */
|
|
838
|
+
isManual: boolean;
|
|
839
|
+
/** 支付项数量 */
|
|
840
|
+
paymentItemCount: number;
|
|
841
|
+
timestamp: number;
|
|
842
|
+
};
|
|
843
|
+
/** 下单接口请求完成事件 */
|
|
844
|
+
orderSubmitEnd: {
|
|
845
|
+
/** 是否成功 */
|
|
846
|
+
success: boolean;
|
|
847
|
+
/** 订单UUID */
|
|
848
|
+
orderUuid: string;
|
|
849
|
+
/** 操作类型 */
|
|
850
|
+
operation: 'create' | 'update';
|
|
851
|
+
/** 是否手动同步 */
|
|
852
|
+
isManual: boolean;
|
|
853
|
+
/** 返回的订单ID(成功时) */
|
|
854
|
+
orderId?: string;
|
|
855
|
+
/** 错误信息(失败时) */
|
|
856
|
+
error?: string;
|
|
857
|
+
/** 耗时(毫秒) */
|
|
858
|
+
duration?: number;
|
|
859
|
+
timestamp: number;
|
|
860
|
+
};
|
|
827
861
|
}
|
|
@@ -119,6 +119,8 @@ export var CheckoutHooks = /*#__PURE__*/function (CheckoutHooks) {
|
|
|
119
119
|
CheckoutHooks["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
|
|
120
120
|
CheckoutHooks["OnOrderCancelled"] = "checkout:onOrderCancelled";
|
|
121
121
|
CheckoutHooks["OnOrderCleared"] = "checkout:onOrderCleared";
|
|
122
|
+
CheckoutHooks["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
|
|
123
|
+
CheckoutHooks["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
|
|
122
124
|
return CheckoutHooks;
|
|
123
125
|
}({});
|
|
124
126
|
|
|
@@ -50,7 +50,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
50
50
|
customer: null,
|
|
51
51
|
productList: [],
|
|
52
52
|
discount: null,
|
|
53
|
-
rules: null
|
|
53
|
+
rules: null,
|
|
54
|
+
originalDiscountList: []
|
|
54
55
|
};
|
|
55
56
|
return _this;
|
|
56
57
|
}
|
|
@@ -360,26 +361,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
360
361
|
discountList: this.getDiscountList()
|
|
361
362
|
}, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable;
|
|
362
363
|
if (!isAvailable) {
|
|
363
|
-
_context5.next =
|
|
364
|
+
_context5.next = 21;
|
|
364
365
|
break;
|
|
365
366
|
}
|
|
366
367
|
this.setDiscountList(newDiscountList || []);
|
|
368
|
+
this.store.originalDiscountList = newDiscountList || [];
|
|
367
369
|
this.setProductList(newProductList || []);
|
|
368
370
|
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
369
|
-
_context5.next =
|
|
371
|
+
_context5.next = 21;
|
|
370
372
|
break;
|
|
371
373
|
}
|
|
372
|
-
_context5.next =
|
|
374
|
+
_context5.next = 21;
|
|
373
375
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
374
|
-
case
|
|
376
|
+
case 21:
|
|
375
377
|
return _context5.abrupt("return", {
|
|
376
378
|
type: "clientCalc",
|
|
377
379
|
isAvailable: isAvailable || false,
|
|
378
380
|
productList: newProductList || this.store.productList || [],
|
|
379
381
|
discountList: newDiscountList || this.getDiscountList()
|
|
380
382
|
});
|
|
381
|
-
case
|
|
382
|
-
_context5.prev =
|
|
383
|
+
case 24:
|
|
384
|
+
_context5.prev = 24;
|
|
383
385
|
_context5.t1 = _context5["catch"](0);
|
|
384
386
|
console.error('[ShopDiscount] 扫码出错:', _context5.t1);
|
|
385
387
|
return _context5.abrupt("return", {
|
|
@@ -388,11 +390,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
388
390
|
productList: this.store.productList || [],
|
|
389
391
|
discountList: this.getDiscountList()
|
|
390
392
|
});
|
|
391
|
-
case
|
|
393
|
+
case 28:
|
|
392
394
|
case "end":
|
|
393
395
|
return _context5.stop();
|
|
394
396
|
}
|
|
395
|
-
}, _callee5, this, [[0,
|
|
397
|
+
}, _callee5, this, [[0, 24]]);
|
|
396
398
|
}));
|
|
397
399
|
function scanCode(_x4, _x5) {
|
|
398
400
|
return _scanCode.apply(this, arguments);
|
|
@@ -580,20 +582,52 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
580
582
|
return _getCustomerWallet.apply(this, arguments);
|
|
581
583
|
}
|
|
582
584
|
return getCustomerWallet;
|
|
583
|
-
}()
|
|
585
|
+
}()
|
|
584
586
|
}, {
|
|
585
|
-
key: "
|
|
587
|
+
key: "bestDiscount",
|
|
586
588
|
value: function () {
|
|
587
|
-
var
|
|
588
|
-
var _this$
|
|
589
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
590
|
+
var _this$store$productLi;
|
|
591
|
+
var newDiscountList, result;
|
|
589
592
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
590
593
|
while (1) switch (_context8.prev = _context8.next) {
|
|
591
594
|
case 0:
|
|
592
|
-
|
|
595
|
+
newDiscountList = this.store.originalDiscountList;
|
|
596
|
+
this.setDiscountList(newDiscountList);
|
|
597
|
+
if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
|
|
598
|
+
_context8.next = 6;
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
result = this.calcDiscount(this.store.productList);
|
|
602
|
+
_context8.next = 6;
|
|
603
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
|
|
604
|
+
case 6:
|
|
605
|
+
_context8.next = 8;
|
|
606
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
|
|
607
|
+
case 8:
|
|
608
|
+
case "end":
|
|
609
|
+
return _context8.stop();
|
|
610
|
+
}
|
|
611
|
+
}, _callee8, this);
|
|
612
|
+
}));
|
|
613
|
+
function bestDiscount() {
|
|
614
|
+
return _bestDiscount.apply(this, arguments);
|
|
615
|
+
}
|
|
616
|
+
return bestDiscount;
|
|
617
|
+
}() // 加载准备配置
|
|
618
|
+
}, {
|
|
619
|
+
key: "loadPrepareConfig",
|
|
620
|
+
value: function () {
|
|
621
|
+
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
622
|
+
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, result;
|
|
623
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
624
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
625
|
+
case 0:
|
|
626
|
+
_context9.prev = 0;
|
|
593
627
|
customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
|
|
594
628
|
// return
|
|
595
629
|
// }
|
|
596
|
-
|
|
630
|
+
_context9.next = 4;
|
|
597
631
|
return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.loadPrepareConfig({
|
|
598
632
|
customer_id: customerId,
|
|
599
633
|
action: 'create',
|
|
@@ -601,7 +635,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
601
635
|
with_discount_card: 1
|
|
602
636
|
});
|
|
603
637
|
case 4:
|
|
604
|
-
goodPassList =
|
|
638
|
+
goodPassList = _context9.sent;
|
|
605
639
|
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
606
640
|
return item.isScan;
|
|
607
641
|
}); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
|
|
@@ -612,29 +646,30 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
612
646
|
return !scanDiscountIds.includes(n.id);
|
|
613
647
|
});
|
|
614
648
|
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || []));
|
|
649
|
+
this.store.originalDiscountList = newDiscountList;
|
|
615
650
|
this.setDiscountList(newDiscountList || []);
|
|
616
|
-
if (!((_this$store$
|
|
617
|
-
|
|
651
|
+
if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
|
|
652
|
+
_context9.next = 15;
|
|
618
653
|
break;
|
|
619
654
|
}
|
|
620
655
|
result = this.calcDiscount(this.store.productList);
|
|
621
|
-
|
|
656
|
+
_context9.next = 15;
|
|
622
657
|
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
|
|
623
|
-
case
|
|
624
|
-
|
|
658
|
+
case 15:
|
|
659
|
+
_context9.next = 17;
|
|
625
660
|
return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
|
|
626
|
-
case
|
|
627
|
-
|
|
661
|
+
case 17:
|
|
662
|
+
_context9.next = 22;
|
|
628
663
|
break;
|
|
629
|
-
case
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
console.error('[ShopDiscount] 加载准备配置出错:',
|
|
633
|
-
case
|
|
664
|
+
case 19:
|
|
665
|
+
_context9.prev = 19;
|
|
666
|
+
_context9.t0 = _context9["catch"](0);
|
|
667
|
+
console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
|
|
668
|
+
case 22:
|
|
634
669
|
case "end":
|
|
635
|
-
return
|
|
670
|
+
return _context9.stop();
|
|
636
671
|
}
|
|
637
|
-
},
|
|
672
|
+
}, _callee9, this, [[0, 19]]);
|
|
638
673
|
}));
|
|
639
674
|
function loadPrepareConfig(_x8) {
|
|
640
675
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiscountModule } from '../../modules/Discount';
|
|
1
|
+
import { DiscountModule, Discount } from '../../modules/Discount';
|
|
2
2
|
import { RulesModule } from '../../modules/Rules';
|
|
3
3
|
export declare enum ShopDiscountHooks {
|
|
4
4
|
onInited = "shopDiscount:onInited",
|
|
@@ -22,4 +22,5 @@ export interface ShopDiscountState {
|
|
|
22
22
|
discount: DiscountModule | null;
|
|
23
23
|
rules: RulesModule | null;
|
|
24
24
|
productList: Record<string, any>[];
|
|
25
|
+
originalDiscountList: Discount[];
|
|
25
26
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/modules/Order/index.ts
|
|
@@ -25,6 +35,7 @@ module.exports = __toCommonJS(Order_exports);
|
|
|
25
35
|
var import_BaseModule = require("../BaseModule");
|
|
26
36
|
var import_utils = require("./utils");
|
|
27
37
|
var import_utils2 = require("../Product/utils");
|
|
38
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
28
39
|
var OrderModule = class extends import_BaseModule.BaseModule {
|
|
29
40
|
constructor(name, version) {
|
|
30
41
|
super(name, version);
|
|
@@ -143,6 +154,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
143
154
|
orderData.bookings = [];
|
|
144
155
|
orderData.relation_products = [];
|
|
145
156
|
}
|
|
157
|
+
if (!params.order_id && !orderData.schedule_date) {
|
|
158
|
+
orderData.schedule_date = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
159
|
+
}
|
|
146
160
|
console.log("[Order] 调用后端接口创建订单:", {
|
|
147
161
|
url: "/order/checkout",
|
|
148
162
|
orderType: orderData.type,
|
|
@@ -524,7 +524,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
524
524
|
type: paymentItem.type,
|
|
525
525
|
amount: formatAmount(paymentItem.amount),
|
|
526
526
|
voucher_id: paymentItem.voucher_id || "",
|
|
527
|
-
rounding_amount: "0.00",
|
|
527
|
+
rounding_amount: paymentItem.rounding_amount || "0.00",
|
|
528
528
|
service_charge: paymentItem.service_charge,
|
|
529
529
|
status: "active",
|
|
530
530
|
// 新支付项默认为活跃状态
|
|
@@ -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 客户状态
|
|
@@ -908,6 +908,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
908
908
|
* @throws 当前没有活跃订单时抛出错误
|
|
909
909
|
*/
|
|
910
910
|
async addPaymentItemAsync(paymentItem) {
|
|
911
|
+
var _a, _b;
|
|
911
912
|
try {
|
|
912
913
|
if (!this.store.currentOrder) {
|
|
913
914
|
throw (0, import_utils.createCheckoutError)(
|
|
@@ -922,7 +923,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
922
923
|
name: paymentItem.name,
|
|
923
924
|
type: paymentItem.type,
|
|
924
925
|
amount: paymentItem.amount,
|
|
925
|
-
service_charge: paymentItem.service_charge
|
|
926
|
+
service_charge: paymentItem.service_charge,
|
|
927
|
+
rounding_amount: paymentItem.rounding_amount,
|
|
928
|
+
voucher_id: paymentItem.voucher_id
|
|
926
929
|
}
|
|
927
930
|
});
|
|
928
931
|
await this.payment.addPaymentItemAsync(
|
|
@@ -930,12 +933,29 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
930
933
|
paymentItem
|
|
931
934
|
);
|
|
932
935
|
console.log("[Checkout] 支付项添加成功");
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
936
|
+
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
937
|
+
console.log("[Checkout] EFTPOS 支付检查:", {
|
|
938
|
+
paymentCode: paymentItem.code,
|
|
939
|
+
paymentType: paymentItem.type,
|
|
940
|
+
isEftposPayment,
|
|
941
|
+
currentOrderSynced: this.store.isOrderSynced
|
|
938
942
|
});
|
|
943
|
+
if (isEftposPayment) {
|
|
944
|
+
console.log("[Checkout] 检测到 EFTPOS 支付,立即同步订单到后端...");
|
|
945
|
+
try {
|
|
946
|
+
await this.syncOrderToBackendWithReturn(true);
|
|
947
|
+
console.log("[Checkout] EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
|
|
948
|
+
订单ID: this.store.currentOrder.order_id,
|
|
949
|
+
是否已同步: this.store.isOrderSynced
|
|
950
|
+
});
|
|
951
|
+
} catch (error) {
|
|
952
|
+
console.error("[Checkout] EFTPOS 支付后订单同步失败:", error);
|
|
953
|
+
await this.handleError(
|
|
954
|
+
new Error(`EFTPOS 支付后订单同步失败: ${error instanceof Error ? error.message : String(error)}`),
|
|
955
|
+
import_types.CheckoutErrorType.OrderCreationFailed
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
939
959
|
await this.updateStateAmountToRemaining();
|
|
940
960
|
await this.core.effects.emit(import_types.CheckoutHooks.OnPaymentStarted, {
|
|
941
961
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -1492,10 +1512,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1492
1512
|
this.store.currentOrder.uuid
|
|
1493
1513
|
);
|
|
1494
1514
|
const filteredPaymentItems = allPaymentItems.filter(
|
|
1495
|
-
(payment) => !payment.voucher_id
|
|
1515
|
+
(payment) => !payment.voucher_id
|
|
1496
1516
|
);
|
|
1497
1517
|
const voucherItems = allPaymentItems.filter(
|
|
1498
|
-
(payment) => payment.voucher_id
|
|
1518
|
+
(payment) => payment.voucher_id
|
|
1499
1519
|
);
|
|
1500
1520
|
console.log("[Checkout] 支付项过滤结果:", {
|
|
1501
1521
|
总支付项: allPaymentItems.length,
|
|
@@ -2023,12 +2043,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2023
2043
|
false
|
|
2024
2044
|
// 不包括已撤销的支付项
|
|
2025
2045
|
);
|
|
2026
|
-
const
|
|
2046
|
+
const hasPaymentItems = currentPayments.length > 0;
|
|
2047
|
+
const allPaymentsHaveVoucherId = hasPaymentItems && currentPayments.every(
|
|
2027
2048
|
(item) => item.status !== "voided" && item.voucher_id
|
|
2028
2049
|
);
|
|
2029
|
-
|
|
2050
|
+
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
2051
|
+
console.log("[Checkout] 自动同步订单条件检查:", {
|
|
2030
2052
|
paymentCount: currentPayments.length,
|
|
2053
|
+
hasPaymentItems,
|
|
2031
2054
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2055
|
+
isOrderSynced: this.store.isOrderSynced,
|
|
2056
|
+
shouldAutoSync,
|
|
2057
|
+
reason: shouldAutoSync ? "支付完成,需要同步最终支付状态" : "跳过同步",
|
|
2032
2058
|
paymentItems: currentPayments.map((p) => ({
|
|
2033
2059
|
uuid: p.uuid,
|
|
2034
2060
|
code: p.code,
|
|
@@ -2037,11 +2063,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2037
2063
|
status: p.status
|
|
2038
2064
|
}))
|
|
2039
2065
|
});
|
|
2040
|
-
if (
|
|
2041
|
-
console.log("[Checkout]
|
|
2042
|
-
} else {
|
|
2043
|
-
console.log("[Checkout] 支付完成但订单未同步,开始同步订单到后端...");
|
|
2066
|
+
if (shouldAutoSync) {
|
|
2067
|
+
console.log("[Checkout] 满足自动同步条件,开始同步订单到后端...");
|
|
2044
2068
|
await this.syncOrderToBackend();
|
|
2069
|
+
} else {
|
|
2070
|
+
if (!hasPaymentItems) {
|
|
2071
|
+
console.log("[Checkout] 没有支付项,跳过订单同步");
|
|
2072
|
+
} else if (allPaymentsHaveVoucherId) {
|
|
2073
|
+
console.log("[Checkout] 所有支付项均为代金券类型,跳过订单同步");
|
|
2074
|
+
}
|
|
2045
2075
|
}
|
|
2046
2076
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderPaymentCompleted, {
|
|
2047
2077
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -2104,7 +2134,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2104
2134
|
* @returns 后端返回的真实订单ID
|
|
2105
2135
|
*/
|
|
2106
2136
|
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
|
|
2107
|
-
var _a, _b, _c, _d;
|
|
2137
|
+
var _a, _b, _c, _d, _e;
|
|
2108
2138
|
if (!this.store.localOrderData || !this.store.currentOrder) {
|
|
2109
2139
|
throw new Error("缺少必要的订单数据,无法同步到后端");
|
|
2110
2140
|
}
|
|
@@ -2204,7 +2234,38 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2204
2234
|
} else {
|
|
2205
2235
|
console.log("[Checkout] 创建新订单操作");
|
|
2206
2236
|
}
|
|
2207
|
-
const
|
|
2237
|
+
const startTime = Date.now();
|
|
2238
|
+
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderSubmitStart, {
|
|
2239
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
2240
|
+
operation: isUpdateOperation ? "update" : "create",
|
|
2241
|
+
isManual,
|
|
2242
|
+
paymentItemCount: paymentItems.length,
|
|
2243
|
+
timestamp: startTime
|
|
2244
|
+
});
|
|
2245
|
+
let checkoutResponse;
|
|
2246
|
+
let submitSuccess = false;
|
|
2247
|
+
let submitError;
|
|
2248
|
+
try {
|
|
2249
|
+
checkoutResponse = await this.order.createOrderByCheckout(orderParams);
|
|
2250
|
+
submitSuccess = true;
|
|
2251
|
+
console.log("[Checkout] 下单接口调用成功");
|
|
2252
|
+
} catch (error) {
|
|
2253
|
+
submitSuccess = false;
|
|
2254
|
+
submitError = error instanceof Error ? error.message : String(error);
|
|
2255
|
+
console.error("[Checkout] 下单接口调用失败:", submitError);
|
|
2256
|
+
throw error;
|
|
2257
|
+
} finally {
|
|
2258
|
+
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderSubmitEnd, {
|
|
2259
|
+
success: submitSuccess,
|
|
2260
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
2261
|
+
operation: isUpdateOperation ? "update" : "create",
|
|
2262
|
+
isManual,
|
|
2263
|
+
orderId: submitSuccess ? ((_d = checkoutResponse == null ? void 0 : checkoutResponse.data) == null ? void 0 : _d.order_id) || (checkoutResponse == null ? void 0 : checkoutResponse.order_id) : void 0,
|
|
2264
|
+
error: submitError,
|
|
2265
|
+
duration: Date.now() - startTime,
|
|
2266
|
+
timestamp: Date.now()
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2208
2269
|
console.log("[Checkout] 后端返回的响应数据:", {
|
|
2209
2270
|
status: checkoutResponse == null ? void 0 : checkoutResponse.status,
|
|
2210
2271
|
code: checkoutResponse == null ? void 0 : checkoutResponse.code,
|
|
@@ -2216,7 +2277,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2216
2277
|
realOrderId = currentOrderId;
|
|
2217
2278
|
console.log(`[Checkout] 订单更新成功,订单ID: ${realOrderId}`);
|
|
2218
2279
|
} else {
|
|
2219
|
-
let extractedOrderId = (
|
|
2280
|
+
let extractedOrderId = (_e = checkoutResponse == null ? void 0 : checkoutResponse.data) == null ? void 0 : _e.order_id;
|
|
2220
2281
|
if (!extractedOrderId) {
|
|
2221
2282
|
extractedOrderId = checkoutResponse == null ? void 0 : checkoutResponse.order_id;
|
|
2222
2283
|
}
|
|
@@ -393,7 +393,11 @@ export declare enum CheckoutHooks {
|
|
|
393
393
|
/** 订单取消 */
|
|
394
394
|
OnOrderCancelled = "checkout:onOrderCancelled",
|
|
395
395
|
/** 订单状态已清理 */
|
|
396
|
-
OnOrderCleared = "checkout:onOrderCleared"
|
|
396
|
+
OnOrderCleared = "checkout:onOrderCleared",
|
|
397
|
+
/** 下单接口请求开始 */
|
|
398
|
+
OnOrderSubmitStart = "checkout:onOrderSubmitStart",
|
|
399
|
+
/** 下单接口请求完成 */
|
|
400
|
+
OnOrderSubmitEnd = "checkout:onOrderSubmitEnd"
|
|
397
401
|
}
|
|
398
402
|
/**
|
|
399
403
|
* 结账状态数据
|
|
@@ -824,4 +828,34 @@ export interface CheckoutEventData {
|
|
|
824
828
|
} | null;
|
|
825
829
|
timestamp: number;
|
|
826
830
|
};
|
|
831
|
+
/** 下单接口请求开始事件 */
|
|
832
|
+
orderSubmitStart: {
|
|
833
|
+
/** 订单UUID */
|
|
834
|
+
orderUuid: string;
|
|
835
|
+
/** 操作类型 */
|
|
836
|
+
operation: 'create' | 'update';
|
|
837
|
+
/** 是否手动同步 */
|
|
838
|
+
isManual: boolean;
|
|
839
|
+
/** 支付项数量 */
|
|
840
|
+
paymentItemCount: number;
|
|
841
|
+
timestamp: number;
|
|
842
|
+
};
|
|
843
|
+
/** 下单接口请求完成事件 */
|
|
844
|
+
orderSubmitEnd: {
|
|
845
|
+
/** 是否成功 */
|
|
846
|
+
success: boolean;
|
|
847
|
+
/** 订单UUID */
|
|
848
|
+
orderUuid: string;
|
|
849
|
+
/** 操作类型 */
|
|
850
|
+
operation: 'create' | 'update';
|
|
851
|
+
/** 是否手动同步 */
|
|
852
|
+
isManual: boolean;
|
|
853
|
+
/** 返回的订单ID(成功时) */
|
|
854
|
+
orderId?: string;
|
|
855
|
+
/** 错误信息(失败时) */
|
|
856
|
+
error?: string;
|
|
857
|
+
/** 耗时(毫秒) */
|
|
858
|
+
duration?: number;
|
|
859
|
+
timestamp: number;
|
|
860
|
+
};
|
|
827
861
|
}
|
|
@@ -71,6 +71,8 @@ var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
|
|
|
71
71
|
CheckoutHooks2["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
|
|
72
72
|
CheckoutHooks2["OnOrderCancelled"] = "checkout:onOrderCancelled";
|
|
73
73
|
CheckoutHooks2["OnOrderCleared"] = "checkout:onOrderCleared";
|
|
74
|
+
CheckoutHooks2["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
|
|
75
|
+
CheckoutHooks2["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
|
|
74
76
|
return CheckoutHooks2;
|
|
75
77
|
})(CheckoutHooks || {});
|
|
76
78
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -50,7 +50,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
50
50
|
customer: null,
|
|
51
51
|
productList: [],
|
|
52
52
|
discount: null,
|
|
53
|
-
rules: null
|
|
53
|
+
rules: null,
|
|
54
|
+
originalDiscountList: []
|
|
54
55
|
};
|
|
55
56
|
}
|
|
56
57
|
// =========== 生命周期方法 ===========
|
|
@@ -241,6 +242,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
241
242
|
};
|
|
242
243
|
if (isAvailable) {
|
|
243
244
|
this.setDiscountList(newDiscountList || []);
|
|
245
|
+
this.store.originalDiscountList = newDiscountList || [];
|
|
244
246
|
this.setProductList(newProductList || []);
|
|
245
247
|
if (this.isWalkIn() && resultDiscountList.length && ((_b = this.options.otherParams) == null ? void 0 : _b.platform) === "shop") {
|
|
246
248
|
await this.getCustomerWallet(
|
|
@@ -388,6 +390,22 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
388
390
|
console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
|
|
389
391
|
}
|
|
390
392
|
}
|
|
393
|
+
async bestDiscount() {
|
|
394
|
+
var _a;
|
|
395
|
+
const newDiscountList = this.store.originalDiscountList;
|
|
396
|
+
this.setDiscountList(newDiscountList);
|
|
397
|
+
if ((_a = this.store.productList) == null ? void 0 : _a.length) {
|
|
398
|
+
const result = this.calcDiscount(this.store.productList);
|
|
399
|
+
await this.core.effects.emit(
|
|
400
|
+
import_types.ShopDiscountHooks.onLoadPrepareCalcResult,
|
|
401
|
+
result
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
await this.core.effects.emit(
|
|
405
|
+
import_types.ShopDiscountHooks.onLoadDiscountList,
|
|
406
|
+
newDiscountList
|
|
407
|
+
);
|
|
408
|
+
}
|
|
391
409
|
// 加载准备配置
|
|
392
410
|
async loadPrepareConfig(params) {
|
|
393
411
|
var _a, _b, _c, _d;
|
|
@@ -405,6 +423,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
405
423
|
const scanDiscountIds = scanDiscount.map((n) => n.id);
|
|
406
424
|
const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
|
|
407
425
|
const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
|
|
426
|
+
this.store.originalDiscountList = newDiscountList;
|
|
408
427
|
this.setDiscountList(newDiscountList || []);
|
|
409
428
|
if ((_d = this.store.productList) == null ? void 0 : _d.length) {
|
|
410
429
|
const result = this.calcDiscount(this.store.productList);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DiscountModule } from '../../modules/Discount';
|
|
1
|
+
import { DiscountModule, Discount } from '../../modules/Discount';
|
|
2
2
|
import { RulesModule } from '../../modules/Rules';
|
|
3
3
|
export declare enum ShopDiscountHooks {
|
|
4
4
|
onInited = "shopDiscount:onInited",
|
|
@@ -22,4 +22,5 @@ export interface ShopDiscountState {
|
|
|
22
22
|
discount: DiscountModule | null;
|
|
23
23
|
rules: RulesModule | null;
|
|
24
24
|
productList: Record<string, any>[];
|
|
25
|
+
originalDiscountList: Discount[];
|
|
25
26
|
}
|