@pisell/pisellos 2.1.33 → 2.1.35
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/effects/index.d.ts +1 -0
- package/dist/effects/index.js +29 -6
- package/dist/modules/Account/index.js +2 -3
- package/dist/modules/BaseModule.d.ts +3 -0
- package/dist/modules/BaseModule.js +15 -0
- package/dist/modules/Customer/index.js +9 -10
- package/dist/modules/Customer/types.d.ts +2 -2
- package/dist/modules/Customer/types.js +2 -2
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Order/index.js +1 -1
- package/dist/modules/Payment/index.js +17 -17
- package/dist/modules/Payment/walletpass.js +4 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -4
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.js +2 -3
- package/dist/solution/BookingByStep/index.js +2 -2
- package/dist/solution/BookingTicket/index.d.ts +4 -0
- package/dist/solution/BookingTicket/index.js +17 -8
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
- package/dist/solution/BuyTickets/index.js +7 -8
- package/dist/solution/Checkout/index.js +35 -35
- package/dist/solution/ShopDiscount/index.js +9 -10
- package/dist/types/index.d.ts +1 -0
- package/lib/effects/index.d.ts +1 -0
- package/lib/effects/index.js +13 -0
- package/lib/modules/Account/index.js +2 -3
- package/lib/modules/BaseModule.d.ts +3 -0
- package/lib/modules/BaseModule.js +9 -0
- package/lib/modules/Customer/index.js +9 -10
- package/lib/modules/Customer/types.d.ts +2 -2
- package/lib/modules/Customer/types.js +2 -2
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Guests/index.js +9 -9
- package/lib/modules/Order/index.js +1 -1
- package/lib/modules/Payment/index.js +16 -16
- package/lib/modules/Payment/walletpass.js +3 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +3 -4
- package/lib/modules/Resource/index.js +1 -1
- package/lib/modules/Rules/index.js +2 -3
- package/lib/solution/BookingByStep/index.js +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -0
- package/lib/solution/BookingTicket/index.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
- package/lib/solution/BuyTickets/index.js +7 -8
- package/lib/solution/Checkout/index.js +34 -34
- package/lib/solution/ShopDiscount/index.js +10 -11
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -81,7 +81,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
81
81
|
await this.preloadPaymentMethods();
|
|
82
82
|
await this.cleanupExpiredOrdersAsync();
|
|
83
83
|
console.log("[Checkout] 初始化完成");
|
|
84
|
-
await this.core.effects.emit(
|
|
84
|
+
await this.core.effects.emit(`${this.name}:onCheckoutInitialized`, {
|
|
85
85
|
timestamp: Date.now()
|
|
86
86
|
});
|
|
87
87
|
this.logInfo("CheckoutModule initialized successfully");
|
|
@@ -265,7 +265,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
265
265
|
this.logInfo("initWalletData currentOrder found", {
|
|
266
266
|
currentOrder: this.store.currentOrder
|
|
267
267
|
});
|
|
268
|
-
await this.core.effects.emit(
|
|
268
|
+
await this.core.effects.emit(`${this.name}:onWalletDataInitialized`, {
|
|
269
269
|
orderUuid: (_g = this.store.currentOrder) == null ? void 0 : _g.uuid,
|
|
270
270
|
customerId: walletBusinessData.customer_id,
|
|
271
271
|
walletBusinessData: {
|
|
@@ -397,7 +397,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
397
397
|
}
|
|
398
398
|
});
|
|
399
399
|
this.store.currentOrder = paymentOrder;
|
|
400
|
-
this.core.effects.emit(
|
|
400
|
+
this.core.effects.emit(`${this.name}:onOrderCreated`, {
|
|
401
401
|
order: paymentOrder,
|
|
402
402
|
timestamp: Date.now()
|
|
403
403
|
});
|
|
@@ -427,7 +427,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
427
427
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
428
428
|
);
|
|
429
429
|
this.logError("本地订单创建失败:", error);
|
|
430
|
-
this.core.effects.emit(
|
|
430
|
+
this.core.effects.emit(`${this.name}:onOrderCreationFailed`, {
|
|
431
431
|
error: this.store.lastError,
|
|
432
432
|
timestamp: Date.now()
|
|
433
433
|
});
|
|
@@ -528,7 +528,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
528
528
|
totalAmount: updated.total_amount,
|
|
529
529
|
expectAmount: updated.expect_amount
|
|
530
530
|
});
|
|
531
|
-
await this.core.effects.emit(
|
|
531
|
+
await this.core.effects.emit(`${this.name}:onOrderCreated`, {
|
|
532
532
|
order: updated,
|
|
533
533
|
timestamp: Date.now()
|
|
534
534
|
});
|
|
@@ -594,7 +594,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
594
594
|
);
|
|
595
595
|
}
|
|
596
596
|
this.payment.wallet.clearAllCache();
|
|
597
|
-
await this.core.effects.emit(
|
|
597
|
+
await this.core.effects.emit(`${this.name}:onCheckoutCompleted`, {
|
|
598
598
|
orderId: order.id,
|
|
599
599
|
timestamp: Date.now()
|
|
600
600
|
});
|
|
@@ -705,7 +705,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
705
705
|
);
|
|
706
706
|
if (updatedOrder) {
|
|
707
707
|
this.store.currentOrder = updatedOrder;
|
|
708
|
-
await this.core.effects.emit(
|
|
708
|
+
await this.core.effects.emit(`${this.name}:onOrderCreated`, {
|
|
709
709
|
order: updatedOrder,
|
|
710
710
|
timestamp: Date.now()
|
|
711
711
|
});
|
|
@@ -746,7 +746,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
746
746
|
newAmount: formattedAmount
|
|
747
747
|
});
|
|
748
748
|
this.store.stateAmount = formattedAmount;
|
|
749
|
-
await this.core.effects.emit(
|
|
749
|
+
await this.core.effects.emit(`${this.name}:onStateAmountChanged`, {
|
|
750
750
|
oldAmount,
|
|
751
751
|
newAmount: formattedAmount,
|
|
752
752
|
timestamp: Date.now()
|
|
@@ -898,7 +898,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
898
898
|
}
|
|
899
899
|
}
|
|
900
900
|
}
|
|
901
|
-
this.core.effects.emit(
|
|
901
|
+
this.core.effects.emit(`${this.name}:onPaymentItemAdded`, {
|
|
902
902
|
orderUuid: this.store.currentOrder.uuid,
|
|
903
903
|
paymentMethodCode: paymentItem.code,
|
|
904
904
|
paymentMethodName: paymentItem.name,
|
|
@@ -975,7 +975,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
975
975
|
this.store.currentOrder = updatedOrder;
|
|
976
976
|
}
|
|
977
977
|
await this.updateStateAmountToRemaining(false);
|
|
978
|
-
await this.core.effects.emit(
|
|
978
|
+
await this.core.effects.emit(`${this.name}:onPaymentStarted`, {
|
|
979
979
|
orderUuid: this.store.currentOrder.uuid,
|
|
980
980
|
paymentMethodCode: paymentItem.code,
|
|
981
981
|
amount: `-${paymentItem.amount}`,
|
|
@@ -1070,7 +1070,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1070
1070
|
this.store.currentOrder = updatedOrder;
|
|
1071
1071
|
}
|
|
1072
1072
|
await this.updateStateAmountToRemaining(false);
|
|
1073
|
-
await this.core.effects.emit(
|
|
1073
|
+
await this.core.effects.emit(`${this.name}:onPaymentStarted`, {
|
|
1074
1074
|
orderUuid: this.store.currentOrder.uuid,
|
|
1075
1075
|
paymentMethodCode: "VOUCHER_BATCH",
|
|
1076
1076
|
amount: voucherPaymentItems.reduce((sum, item) => sum + parseFloat(String(item.amount)), 0).toFixed(2),
|
|
@@ -1132,7 +1132,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1132
1132
|
}
|
|
1133
1133
|
this.clearCalculationCache();
|
|
1134
1134
|
this.updateStateAmountToRemaining(false);
|
|
1135
|
-
await this.core.effects.emit(
|
|
1135
|
+
await this.core.effects.emit(`${this.name}:onOrderCreated`, {
|
|
1136
1136
|
order: this.store.currentOrder,
|
|
1137
1137
|
timestamp: Date.now()
|
|
1138
1138
|
});
|
|
@@ -1224,7 +1224,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1224
1224
|
}
|
|
1225
1225
|
this.clearCalculationCache();
|
|
1226
1226
|
this.updateStateAmountToRemaining(false);
|
|
1227
|
-
await this.core.effects.emit(
|
|
1227
|
+
await this.core.effects.emit(`${this.name}:onOrderCreated`, {
|
|
1228
1228
|
order: this.store.currentOrder,
|
|
1229
1229
|
timestamp: Date.now()
|
|
1230
1230
|
});
|
|
@@ -1411,7 +1411,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1411
1411
|
this.store.currentCustomer = void 0;
|
|
1412
1412
|
this.payment.wallet.clearAllCache();
|
|
1413
1413
|
this.logInfo("订单状态清理完成,currentOrder已释放");
|
|
1414
|
-
await this.core.effects.emit(
|
|
1414
|
+
await this.core.effects.emit(`${this.name}:onOrderCancelled`, {
|
|
1415
1415
|
orderUuid: currentOrderUuid,
|
|
1416
1416
|
orderId: currentOrderId,
|
|
1417
1417
|
cancelReason,
|
|
@@ -1528,7 +1528,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1528
1528
|
);
|
|
1529
1529
|
}
|
|
1530
1530
|
}
|
|
1531
|
-
await this.core.effects.emit(
|
|
1531
|
+
await this.core.effects.emit(`${this.name}:onOrderNoteChanged`, {
|
|
1532
1532
|
orderUuid: (_b = this.store.currentOrder) == null ? void 0 : _b.uuid,
|
|
1533
1533
|
oldNote,
|
|
1534
1534
|
newNote: note,
|
|
@@ -1553,7 +1553,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1553
1553
|
async handleError(error, type) {
|
|
1554
1554
|
const checkoutError = error instanceof Error && "type" in error ? error : (0, import_utils.createCheckoutError)(type, error.message, error);
|
|
1555
1555
|
this.store.lastError = checkoutError;
|
|
1556
|
-
await this.core.effects.emit(
|
|
1556
|
+
await this.core.effects.emit(`${this.name}:onError`, {
|
|
1557
1557
|
error: checkoutError,
|
|
1558
1558
|
context: {},
|
|
1559
1559
|
timestamp: Date.now()
|
|
@@ -1566,7 +1566,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1566
1566
|
async handlePaymentSuccess(data) {
|
|
1567
1567
|
var _a;
|
|
1568
1568
|
await this.updateStateAmountToRemaining();
|
|
1569
|
-
await this.core.effects.emit(
|
|
1569
|
+
await this.core.effects.emit(`${this.name}:onPaymentSuccess`, {
|
|
1570
1570
|
orderUuid: data.orderUuid,
|
|
1571
1571
|
paymentMethodCode: "",
|
|
1572
1572
|
amount: ((_a = this.store.currentOrder) == null ? void 0 : _a.total_amount) || "0",
|
|
@@ -1587,7 +1587,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1587
1587
|
error instanceof Error ? error : new Error(String(error)),
|
|
1588
1588
|
import_types.CheckoutErrorType.PaymentFailed
|
|
1589
1589
|
);
|
|
1590
|
-
await this.core.effects.emit(
|
|
1590
|
+
await this.core.effects.emit(`${this.name}:onPaymentFailed`, {
|
|
1591
1591
|
orderUuid: data.orderUuid,
|
|
1592
1592
|
paymentMethodCode: "",
|
|
1593
1593
|
amount: ((_a = this.store.currentOrder) == null ? void 0 : _a.total_amount) || "0",
|
|
@@ -1823,7 +1823,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1823
1823
|
}
|
|
1824
1824
|
/**
|
|
1825
1825
|
* 计算已支付金额(从 Payment 模块获取最新数据)
|
|
1826
|
-
*
|
|
1826
|
+
*
|
|
1827
1827
|
* 注意:此方法保持独立性,可以单独调用。
|
|
1828
1828
|
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
1829
1829
|
*/
|
|
@@ -1875,7 +1875,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
/**
|
|
1877
1877
|
* 计算剩余未支付金额(从 Payment 模块获取最新数据)
|
|
1878
|
-
*
|
|
1878
|
+
*
|
|
1879
1879
|
* 注意:此方法保持独立性,可以单独调用。
|
|
1880
1880
|
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
1881
1881
|
*/
|
|
@@ -1895,7 +1895,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1895
1895
|
}
|
|
1896
1896
|
/**
|
|
1897
1897
|
* 计算剩余未支付金额(排除定金计算,始终使用订单总金额)
|
|
1898
|
-
*
|
|
1898
|
+
*
|
|
1899
1899
|
* 注意:此方法保持独立性,可以单独调用。
|
|
1900
1900
|
* 在 updateStateAmountToRemaining 等批量操作中会使用缓存优化。
|
|
1901
1901
|
*/
|
|
@@ -1923,7 +1923,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1923
1923
|
const currentBalanceDueAmount = this.store.balanceDueAmount;
|
|
1924
1924
|
if (remainingAmount !== currentBalanceDueAmount) {
|
|
1925
1925
|
this.store.balanceDueAmount = remainingAmount;
|
|
1926
|
-
await this.core.effects.emit(
|
|
1926
|
+
await this.core.effects.emit(`${this.name}:onBalanceDueAmountChanged`, {
|
|
1927
1927
|
oldAmount: currentBalanceDueAmount,
|
|
1928
1928
|
newAmount: remainingAmount,
|
|
1929
1929
|
timestamp: Date.now(),
|
|
@@ -1945,7 +1945,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1945
1945
|
}
|
|
1946
1946
|
/**
|
|
1947
1947
|
* 更新 stateAmount 为当前剩余未支付金额
|
|
1948
|
-
*
|
|
1948
|
+
*
|
|
1949
1949
|
* 优化版本:批量获取数据,避免重复查询数据库
|
|
1950
1950
|
*/
|
|
1951
1951
|
async updateStateAmountToRemaining(checkOrder = true) {
|
|
@@ -2047,7 +2047,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2047
2047
|
}
|
|
2048
2048
|
/**
|
|
2049
2049
|
* 检查订单支付是否完成(优化版,复用已获取的数据)
|
|
2050
|
-
*
|
|
2050
|
+
*
|
|
2051
2051
|
* @param paymentItems 已获取的支付项数据
|
|
2052
2052
|
* @param remainingAmount 已计算的剩余金额
|
|
2053
2053
|
*/
|
|
@@ -2117,7 +2117,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2117
2117
|
* 检查订单支付是否完成
|
|
2118
2118
|
*
|
|
2119
2119
|
* 当剩余待付款金额 <= 0 时,触发订单支付完成事件
|
|
2120
|
-
*
|
|
2120
|
+
*
|
|
2121
2121
|
* 注意:此方法保持独立性,可以单独调用。
|
|
2122
2122
|
* 在 updateStateAmountToRemaining 中会使用优化版本。
|
|
2123
2123
|
*/
|
|
@@ -2176,7 +2176,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2176
2176
|
this.logInfo("所有支付项均为代金券类型,跳过订单同步");
|
|
2177
2177
|
}
|
|
2178
2178
|
}
|
|
2179
|
-
await this.core.effects.emit(
|
|
2179
|
+
await this.core.effects.emit(`${this.name}:onOrderPaymentCompleted`, {
|
|
2180
2180
|
orderUuid: this.store.currentOrder.uuid,
|
|
2181
2181
|
orderId: this.store.currentOrder.order_id,
|
|
2182
2182
|
totalAmount,
|
|
@@ -2325,7 +2325,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2325
2325
|
}
|
|
2326
2326
|
}
|
|
2327
2327
|
const startTime = Date.now();
|
|
2328
|
-
await this.core.effects.emit(
|
|
2328
|
+
await this.core.effects.emit(`${this.name}:onOrderSubmitStart`, {
|
|
2329
2329
|
orderUuid: this.store.currentOrder.uuid,
|
|
2330
2330
|
operation: isUpdateOperation ? "update" : "create",
|
|
2331
2331
|
isManual,
|
|
@@ -2348,7 +2348,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2348
2348
|
submitSuccess = false;
|
|
2349
2349
|
submitError = error instanceof Error ? error.message : String(error);
|
|
2350
2350
|
this.logError("下单接口调用失败:", submitError);
|
|
2351
|
-
await this.core.effects.emit(
|
|
2351
|
+
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2352
2352
|
orderUuid: this.store.currentOrder.uuid,
|
|
2353
2353
|
operation: isUpdateOperation ? "update" : "create",
|
|
2354
2354
|
isManual,
|
|
@@ -2359,7 +2359,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2359
2359
|
});
|
|
2360
2360
|
throw error;
|
|
2361
2361
|
} finally {
|
|
2362
|
-
await this.core.effects.emit(
|
|
2362
|
+
await this.core.effects.emit(`${this.name}:onOrderSubmitEnd`, {
|
|
2363
2363
|
success: submitSuccess,
|
|
2364
2364
|
orderUuid: this.store.currentOrder.uuid,
|
|
2365
2365
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2374,7 +2374,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2374
2374
|
const isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === "success" || responseStatus === 1 && (checkoutResponse == null ? void 0 : checkoutResponse.code) === 200;
|
|
2375
2375
|
if (!isSuccessResponse) {
|
|
2376
2376
|
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "订单同步失败,后端返回非成功状态";
|
|
2377
|
-
await this.core.effects.emit(
|
|
2377
|
+
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2378
2378
|
orderUuid: this.store.currentOrder.uuid,
|
|
2379
2379
|
operation: isUpdateOperation ? "update" : "create",
|
|
2380
2380
|
isManual,
|
|
@@ -2459,7 +2459,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2459
2459
|
}
|
|
2460
2460
|
this.store.isOrderSynced = true;
|
|
2461
2461
|
this.clearCalculationCache();
|
|
2462
|
-
await this.core.effects.emit(
|
|
2462
|
+
await this.core.effects.emit(`${this.name}:onOrderSynced`, {
|
|
2463
2463
|
orderUuid: this.store.currentOrder.uuid,
|
|
2464
2464
|
realOrderId,
|
|
2465
2465
|
virtualOrderId: this.store.currentOrder.order_id,
|
|
@@ -2526,7 +2526,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2526
2526
|
if (this.store.localOrderData) {
|
|
2527
2527
|
this.store.localOrderData.shop_note = note;
|
|
2528
2528
|
}
|
|
2529
|
-
await this.core.effects.emit(
|
|
2529
|
+
await this.core.effects.emit(`${this.name}:onOrderNoteChanged`, {
|
|
2530
2530
|
orderUuid: this.store.currentOrder.uuid,
|
|
2531
2531
|
oldNote: previousNote,
|
|
2532
2532
|
newNote: note,
|
|
@@ -2674,7 +2674,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2674
2674
|
* 重置 store 状态
|
|
2675
2675
|
*
|
|
2676
2676
|
* 在创建新订单前调用,确保状态完全干净
|
|
2677
|
-
*
|
|
2677
|
+
*
|
|
2678
2678
|
* 🚀 性能优化:改为同步方法,事件发射不阻塞主流程
|
|
2679
2679
|
*/
|
|
2680
2680
|
resetStoreState() {
|
|
@@ -2698,7 +2698,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2698
2698
|
console.log("[Checkout] Store 状态重置完成");
|
|
2699
2699
|
if (prevOrderInfo) {
|
|
2700
2700
|
setTimeout(() => {
|
|
2701
|
-
this.core.effects.emit(
|
|
2701
|
+
this.core.effects.emit(`${this.name}:onOrderCleared`, {
|
|
2702
2702
|
previousOrder: prevOrderInfo,
|
|
2703
2703
|
timestamp: Date.now()
|
|
2704
2704
|
});
|
|
@@ -34,7 +34,6 @@ __export(ShopDiscount_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(ShopDiscount_exports);
|
|
36
36
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
37
|
-
var import_types = require("./types");
|
|
38
37
|
var import_Discount = require("../../modules/Discount");
|
|
39
38
|
var import_Rules = require("../../modules/Rules");
|
|
40
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -73,7 +72,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
73
72
|
(_a = this.store.discount) == null ? void 0 : _a.destroy();
|
|
74
73
|
(_b = this.store.rules) == null ? void 0 : _b.destroy();
|
|
75
74
|
this.core.effects.offByModuleDestroy(this.name);
|
|
76
|
-
await this.core.effects.emit(
|
|
75
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
77
76
|
console.log("[ShopDiscount] 已销毁");
|
|
78
77
|
}
|
|
79
78
|
async clear() {
|
|
@@ -123,8 +122,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
123
122
|
this.store.rules = rules;
|
|
124
123
|
}
|
|
125
124
|
registerEventListeners() {
|
|
126
|
-
this.core.effects.
|
|
127
|
-
|
|
125
|
+
this.core.effects.only(
|
|
126
|
+
`${this.name}:onCustomerChange`,
|
|
128
127
|
(customer) => {
|
|
129
128
|
var _a;
|
|
130
129
|
if (((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) && this.getDiscountList().length) {
|
|
@@ -146,7 +145,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
146
145
|
if (((_a = this.store.customer) == null ? void 0 : _a.id) !== customer.id) {
|
|
147
146
|
this.store.customer = customer;
|
|
148
147
|
await this.core.effects.emit(
|
|
149
|
-
|
|
148
|
+
`${this.name}:onCustomerChange`,
|
|
150
149
|
customer
|
|
151
150
|
);
|
|
152
151
|
}
|
|
@@ -292,7 +291,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
292
291
|
// 触发优惠列表变更事件
|
|
293
292
|
async emitDiscountListChange(discountList) {
|
|
294
293
|
await this.core.effects.emit(
|
|
295
|
-
|
|
294
|
+
`${this.name}:onDiscountListChange`,
|
|
296
295
|
discountList
|
|
297
296
|
);
|
|
298
297
|
}
|
|
@@ -390,7 +389,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
390
389
|
const { ...customer } = result.data;
|
|
391
390
|
this.setCustomer(customer);
|
|
392
391
|
await this.core.effects.emit(
|
|
393
|
-
|
|
392
|
+
`${this.name}:onScanCustomerChange`,
|
|
394
393
|
customer
|
|
395
394
|
);
|
|
396
395
|
}
|
|
@@ -406,12 +405,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
406
405
|
const result = this.calcDiscount(this.store.productList);
|
|
407
406
|
cb == null ? void 0 : cb(result);
|
|
408
407
|
await this.core.effects.emit(
|
|
409
|
-
|
|
408
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
410
409
|
result
|
|
411
410
|
);
|
|
412
411
|
}
|
|
413
412
|
await this.core.effects.emit(
|
|
414
|
-
|
|
413
|
+
`${this.name}:onLoadDiscountList`,
|
|
415
414
|
newDiscountList
|
|
416
415
|
);
|
|
417
416
|
}
|
|
@@ -437,12 +436,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
437
436
|
if ((_d = this.store.productList) == null ? void 0 : _d.length) {
|
|
438
437
|
const result = this.calcDiscount(this.store.productList);
|
|
439
438
|
await this.core.effects.emit(
|
|
440
|
-
|
|
439
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
441
440
|
result
|
|
442
441
|
);
|
|
443
442
|
}
|
|
444
443
|
await this.core.effects.emit(
|
|
445
|
-
|
|
444
|
+
`${this.name}:onLoadDiscountList`,
|
|
446
445
|
newDiscountList
|
|
447
446
|
);
|
|
448
447
|
} catch (error) {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface PisellCore {
|
|
|
40
40
|
effects: {
|
|
41
41
|
on: (event: string, callback: (payload: any) => void) => () => void;
|
|
42
42
|
once: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
|
+
only: (event: string, callback: (payload: any) => void) => () => void;
|
|
43
44
|
off: (event: string, callback: (payload: any) => void) => void;
|
|
44
45
|
emit: (event: string, payload: any, value?: any) => Promise<{
|
|
45
46
|
status: boolean;
|