@pisell/pisellos 0.0.321 → 0.0.325
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/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/Discount/index.js +1 -1
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Payment/index.js +18 -18
- package/dist/modules/Payment/walletpass.js +4 -1
- package/dist/modules/ProductList/index.js +4 -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.js +7 -7
- package/dist/solution/BuyTickets/index.js +7 -8
- package/dist/solution/Checkout/index.js +29 -29
- package/dist/solution/ShopDiscount/index.js +1 -1
- 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/Discount/index.js +1 -1
- package/lib/modules/Guests/index.js +9 -9
- package/lib/modules/Payment/index.js +17 -17
- package/lib/modules/Payment/walletpass.js +3 -1
- package/lib/modules/ProductList/index.js +4 -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.js +6 -6
- package/lib/solution/BuyTickets/index.js +7 -8
- package/lib/solution/Checkout/index.js +28 -28
- package/lib/solution/ShopDiscount/index.js +1 -1
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import Decimal from 'decimal.js';
|
|
29
29
|
import { OrderModule } from "../../modules/Order";
|
|
30
30
|
import { PaymentModule } from "../../modules/Payment";
|
|
31
|
-
import {
|
|
31
|
+
import { CheckoutErrorType } from "./types";
|
|
32
32
|
import { PaymentStatus, PaymentHooks } from "../../modules/Payment/types";
|
|
33
33
|
import { validateCheckoutData, createCheckoutError, validateLocalOrderData, generateLocalOrderId, formatDateTime, extractAmountFromCartSummary, isVirtualOrderId, isCashPayment } from "./utils";
|
|
34
34
|
import { getProductDeposit } from "../../modules/Cart/utils";
|
|
@@ -117,7 +117,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
117
117
|
case 19:
|
|
118
118
|
console.log('[Checkout] 初始化完成');
|
|
119
119
|
_context.next = 22;
|
|
120
|
-
return this.core.effects.emit(
|
|
120
|
+
return this.core.effects.emit("".concat(this.name, ":onCheckoutInitialized"), {
|
|
121
121
|
timestamp: Date.now()
|
|
122
122
|
});
|
|
123
123
|
case 22:
|
|
@@ -453,7 +453,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
453
453
|
});
|
|
454
454
|
// 触发钱包数据初始化完成事件
|
|
455
455
|
_context8.next = 16;
|
|
456
|
-
return this.core.effects.emit(
|
|
456
|
+
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
457
457
|
orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid,
|
|
458
458
|
customerId: walletBusinessData.customer_id,
|
|
459
459
|
walletBusinessData: {
|
|
@@ -623,7 +623,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
623
623
|
if (params.autoPayment) {
|
|
624
624
|
// 自动支付模式标记
|
|
625
625
|
}
|
|
626
|
-
this.core.effects.emit(
|
|
626
|
+
this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
627
627
|
order: paymentOrder,
|
|
628
628
|
timestamp: Date.now()
|
|
629
629
|
});
|
|
@@ -649,7 +649,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
649
649
|
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
650
650
|
case 37:
|
|
651
651
|
this.logError('本地订单创建失败:', _context9.t0);
|
|
652
|
-
this.core.effects.emit(
|
|
652
|
+
this.core.effects.emit("".concat(this.name, ":onOrderCreationFailed"), {
|
|
653
653
|
error: this.store.lastError,
|
|
654
654
|
timestamp: Date.now()
|
|
655
655
|
});
|
|
@@ -787,7 +787,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
787
787
|
|
|
788
788
|
// 事件通知(复用创建事件,便于上层监听刷新)
|
|
789
789
|
_context10.next = 38;
|
|
790
|
-
return this.core.effects.emit(
|
|
790
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
791
791
|
order: updated,
|
|
792
792
|
timestamp: Date.now()
|
|
793
793
|
});
|
|
@@ -875,7 +875,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
875
875
|
// 清理钱包模块的所有缓存数据
|
|
876
876
|
this.payment.wallet.clearAllCache();
|
|
877
877
|
_context11.next = 11;
|
|
878
|
-
return this.core.effects.emit(
|
|
878
|
+
return this.core.effects.emit("".concat(this.name, ":onCheckoutCompleted"), {
|
|
879
879
|
orderId: order.id,
|
|
880
880
|
timestamp: Date.now()
|
|
881
881
|
});
|
|
@@ -1064,7 +1064,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1064
1064
|
|
|
1065
1065
|
// 触发订单更新事件
|
|
1066
1066
|
_context13.next = 11;
|
|
1067
|
-
return this.core.effects.emit(
|
|
1067
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
1068
1068
|
order: updatedOrder,
|
|
1069
1069
|
timestamp: Date.now()
|
|
1070
1070
|
});
|
|
@@ -1144,7 +1144,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1144
1144
|
|
|
1145
1145
|
// 触发金额变更事件
|
|
1146
1146
|
_context14.next = 12;
|
|
1147
|
-
return this.core.effects.emit(
|
|
1147
|
+
return this.core.effects.emit("".concat(this.name, ":onStateAmountChanged"), {
|
|
1148
1148
|
oldAmount: oldAmount,
|
|
1149
1149
|
newAmount: formattedAmount,
|
|
1150
1150
|
timestamp: Date.now()
|
|
@@ -1368,7 +1368,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1368
1368
|
return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
1369
1369
|
case 38:
|
|
1370
1370
|
// 触发支付项添加事件(可以复用支付开始事件)
|
|
1371
|
-
this.core.effects.emit(
|
|
1371
|
+
this.core.effects.emit("".concat(this.name, ":onPaymentItemAdded"), {
|
|
1372
1372
|
orderUuid: this.store.currentOrder.uuid,
|
|
1373
1373
|
paymentMethodCode: paymentItem.code,
|
|
1374
1374
|
paymentMethodName: paymentItem.name,
|
|
@@ -1478,7 +1478,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1478
1478
|
return this.updateStateAmountToRemaining(false);
|
|
1479
1479
|
case 22:
|
|
1480
1480
|
_context17.next = 24;
|
|
1481
|
-
return this.core.effects.emit(
|
|
1481
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentStarted"), {
|
|
1482
1482
|
orderUuid: this.store.currentOrder.uuid,
|
|
1483
1483
|
paymentMethodCode: paymentItem.code,
|
|
1484
1484
|
amount: "-".concat(paymentItem.amount),
|
|
@@ -1609,7 +1609,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1609
1609
|
return this.updateStateAmountToRemaining(false);
|
|
1610
1610
|
case 28:
|
|
1611
1611
|
_context18.next = 30;
|
|
1612
|
-
return this.core.effects.emit(
|
|
1612
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentStarted"), {
|
|
1613
1613
|
orderUuid: this.store.currentOrder.uuid,
|
|
1614
1614
|
paymentMethodCode: 'VOUCHER_BATCH',
|
|
1615
1615
|
amount: voucherPaymentItems.reduce(function (sum, item) {
|
|
@@ -1711,7 +1711,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1711
1711
|
|
|
1712
1712
|
// 触发订单更新事件
|
|
1713
1713
|
_context19.next = 20;
|
|
1714
|
-
return this.core.effects.emit(
|
|
1714
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
1715
1715
|
order: this.store.currentOrder,
|
|
1716
1716
|
timestamp: Date.now()
|
|
1717
1717
|
});
|
|
@@ -1837,7 +1837,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1837
1837
|
|
|
1838
1838
|
// 触发订单更新事件
|
|
1839
1839
|
_context20.next = 22;
|
|
1840
|
-
return this.core.effects.emit(
|
|
1840
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
|
|
1841
1841
|
order: this.store.currentOrder,
|
|
1842
1842
|
timestamp: Date.now()
|
|
1843
1843
|
});
|
|
@@ -2106,7 +2106,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2106
2106
|
|
|
2107
2107
|
// 触发订单取消事件
|
|
2108
2108
|
_context22.next = 32;
|
|
2109
|
-
return this.core.effects.emit(
|
|
2109
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderCancelled"), {
|
|
2110
2110
|
orderUuid: currentOrderUuid,
|
|
2111
2111
|
orderId: currentOrderId,
|
|
2112
2112
|
cancelReason: cancelReason,
|
|
@@ -2277,7 +2277,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2277
2277
|
console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context24.t0);
|
|
2278
2278
|
case 17:
|
|
2279
2279
|
_context24.next = 19;
|
|
2280
|
-
return this.core.effects.emit(
|
|
2280
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
|
|
2281
2281
|
orderUuid: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.uuid,
|
|
2282
2282
|
oldNote: oldNote,
|
|
2283
2283
|
newNote: note,
|
|
@@ -2324,7 +2324,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2324
2324
|
checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
|
|
2325
2325
|
this.store.lastError = checkoutError;
|
|
2326
2326
|
_context25.next = 4;
|
|
2327
|
-
return this.core.effects.emit(
|
|
2327
|
+
return this.core.effects.emit("".concat(this.name, ":onError"), {
|
|
2328
2328
|
error: checkoutError,
|
|
2329
2329
|
context: {},
|
|
2330
2330
|
timestamp: Date.now()
|
|
@@ -2358,7 +2358,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2358
2358
|
return this.updateStateAmountToRemaining();
|
|
2359
2359
|
case 2:
|
|
2360
2360
|
_context26.next = 4;
|
|
2361
|
-
return this.core.effects.emit(
|
|
2361
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
|
|
2362
2362
|
orderUuid: data.orderUuid,
|
|
2363
2363
|
paymentMethodCode: '',
|
|
2364
2364
|
amount: ((_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.total_amount) || '0',
|
|
@@ -2396,7 +2396,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2396
2396
|
return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
|
|
2397
2397
|
case 3:
|
|
2398
2398
|
_context27.next = 5;
|
|
2399
|
-
return this.core.effects.emit(
|
|
2399
|
+
return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
|
|
2400
2400
|
orderUuid: data.orderUuid,
|
|
2401
2401
|
paymentMethodCode: '',
|
|
2402
2402
|
amount: ((_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.total_amount) || '0',
|
|
@@ -2931,7 +2931,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2931
2931
|
|
|
2932
2932
|
// 发出 balanceDueAmount 变更事件
|
|
2933
2933
|
_context34.next = 12;
|
|
2934
|
-
return this.core.effects.emit(
|
|
2934
|
+
return this.core.effects.emit("".concat(this.name, ":onBalanceDueAmountChanged"), {
|
|
2935
2935
|
oldAmount: currentBalanceDueAmount,
|
|
2936
2936
|
newAmount: remainingAmount,
|
|
2937
2937
|
timestamp: Date.now(),
|
|
@@ -3035,7 +3035,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3035
3035
|
this.store.stateAmount = remainingAmount;
|
|
3036
3036
|
|
|
3037
3037
|
// 发出 stateAmount 变更事件
|
|
3038
|
-
this.core.effects.emit(
|
|
3038
|
+
this.core.effects.emit("".concat(this.name, ":onStateAmountChanged"), {
|
|
3039
3039
|
oldAmount: currentStateAmount,
|
|
3040
3040
|
newAmount: remainingAmount,
|
|
3041
3041
|
timestamp: Date.now(),
|
|
@@ -3184,7 +3184,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3184
3184
|
}
|
|
3185
3185
|
case 27:
|
|
3186
3186
|
_context36.next = 29;
|
|
3187
|
-
return this.core.effects.emit(
|
|
3187
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderPaymentCompleted"), {
|
|
3188
3188
|
orderUuid: this.store.currentOrder.uuid,
|
|
3189
3189
|
orderId: this.store.currentOrder.order_id,
|
|
3190
3190
|
totalAmount: totalAmount,
|
|
@@ -3422,7 +3422,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3422
3422
|
// 发送下单接口请求开始事件
|
|
3423
3423
|
startTime = Date.now();
|
|
3424
3424
|
_context37.next = 27;
|
|
3425
|
-
return this.core.effects.emit(
|
|
3425
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderSubmitStart"), {
|
|
3426
3426
|
orderUuid: this.store.currentOrder.uuid,
|
|
3427
3427
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
3428
3428
|
isManual: isManual,
|
|
@@ -3456,7 +3456,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3456
3456
|
|
|
3457
3457
|
// 发送订单同步失败事件(网络错误或请求失败)
|
|
3458
3458
|
_context37.next = 44;
|
|
3459
|
-
return this.core.effects.emit(
|
|
3459
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
|
|
3460
3460
|
orderUuid: this.store.currentOrder.uuid,
|
|
3461
3461
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
3462
3462
|
isManual: isManual,
|
|
@@ -3470,7 +3470,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3470
3470
|
case 45:
|
|
3471
3471
|
_context37.prev = 45;
|
|
3472
3472
|
_context37.next = 48;
|
|
3473
|
-
return this.core.effects.emit(
|
|
3473
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderSubmitEnd"), {
|
|
3474
3474
|
success: submitSuccess,
|
|
3475
3475
|
orderUuid: this.store.currentOrder.uuid,
|
|
3476
3476
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
@@ -3492,7 +3492,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3492
3492
|
}
|
|
3493
3493
|
errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
|
|
3494
3494
|
_context37.next = 55;
|
|
3495
|
-
return this.core.effects.emit(
|
|
3495
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
|
|
3496
3496
|
orderUuid: this.store.currentOrder.uuid,
|
|
3497
3497
|
operation: isUpdateOperation ? 'update' : 'create',
|
|
3498
3498
|
isManual: isManual,
|
|
@@ -3625,7 +3625,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3625
3625
|
|
|
3626
3626
|
// 触发订单同步完成事件
|
|
3627
3627
|
_context37.next = 106;
|
|
3628
|
-
return this.core.effects.emit(
|
|
3628
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderSynced"), {
|
|
3629
3629
|
orderUuid: this.store.currentOrder.uuid,
|
|
3630
3630
|
realOrderId: realOrderId,
|
|
3631
3631
|
virtualOrderId: this.store.currentOrder.order_id,
|
|
@@ -3752,7 +3752,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3752
3752
|
|
|
3753
3753
|
// 触发订单备注变更事件
|
|
3754
3754
|
_context39.next = 15;
|
|
3755
|
-
return this.core.effects.emit(
|
|
3755
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
|
|
3756
3756
|
orderUuid: this.store.currentOrder.uuid,
|
|
3757
3757
|
oldNote: previousNote,
|
|
3758
3758
|
newNote: note,
|
|
@@ -4044,7 +4044,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4044
4044
|
break;
|
|
4045
4045
|
}
|
|
4046
4046
|
_context43.next = 17;
|
|
4047
|
-
return this.core.effects.emit(
|
|
4047
|
+
return this.core.effects.emit("".concat(this.name, ":onOrderCleared"), {
|
|
4048
4048
|
previousOrder: prevOrderInfo,
|
|
4049
4049
|
timestamp: Date.now()
|
|
4050
4050
|
});
|
|
@@ -107,7 +107,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
107
107
|
(_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.destroy();
|
|
108
108
|
this.core.effects.offByModuleDestroy(this.name);
|
|
109
109
|
_context2.next = 7;
|
|
110
|
-
return this.core.effects.emit(
|
|
110
|
+
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
111
111
|
case 7:
|
|
112
112
|
console.log('[ShopDiscount] 已销毁');
|
|
113
113
|
case 8:
|
|
@@ -24,7 +24,6 @@ __export(Account_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(Account_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
|
-
var import_types = require("./types");
|
|
28
27
|
__reExport(Account_exports, require("./types"), module.exports);
|
|
29
28
|
var AccountModule = class extends import_BaseModule.BaseModule {
|
|
30
29
|
constructor(name, version) {
|
|
@@ -59,7 +58,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
59
58
|
};
|
|
60
59
|
this.store.accountInfo = account;
|
|
61
60
|
this.store.isLoggedIn = true;
|
|
62
|
-
await this.core.effects.emit(
|
|
61
|
+
await this.core.effects.emit(`${this.name}:onLogin`, account);
|
|
63
62
|
}
|
|
64
63
|
getCurrentAccount() {
|
|
65
64
|
return this.store.accountInfo;
|
|
@@ -72,7 +71,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
|
|
|
72
71
|
...updates
|
|
73
72
|
};
|
|
74
73
|
await this.core.effects.emit(
|
|
75
|
-
|
|
74
|
+
`${this.name}:onProfileUpdate`,
|
|
76
75
|
this.store.accountInfo
|
|
77
76
|
);
|
|
78
77
|
}
|
|
@@ -14,4 +14,7 @@ export declare class BaseModule {
|
|
|
14
14
|
store: any;
|
|
15
15
|
cacheKey: string[];
|
|
16
16
|
}): void;
|
|
17
|
+
effectsOn(eventType: string, callback: (payload: any) => void): void;
|
|
18
|
+
effectsOff(eventType: string, callback: (payload: any) => void): void;
|
|
19
|
+
effectsOnce(eventType: string, callback: (payload: any) => void): void;
|
|
17
20
|
}
|
|
@@ -84,6 +84,15 @@ var BaseModule = class {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
effectsOn(eventType, callback) {
|
|
88
|
+
this.core.effects.on(`${this.name}:${eventType}`, callback);
|
|
89
|
+
}
|
|
90
|
+
effectsOff(eventType, callback) {
|
|
91
|
+
this.core.effects.off(`${this.name}:${eventType}`, callback);
|
|
92
|
+
}
|
|
93
|
+
effectsOnce(eventType, callback) {
|
|
94
|
+
this.core.effects.once(`${this.name}:${eventType}`, callback);
|
|
95
|
+
}
|
|
87
96
|
};
|
|
88
97
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
98
|
0 && (module.exports = {
|
|
@@ -25,7 +25,6 @@ __export(Customer_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(Customer_exports);
|
|
26
26
|
var import_lodash_es = require("lodash-es");
|
|
27
27
|
var import_BaseModule = require("../BaseModule");
|
|
28
|
-
var import_types = require("./types");
|
|
29
28
|
var import_constants = require("./constants");
|
|
30
29
|
__reExport(Customer_exports, require("./types"), module.exports);
|
|
31
30
|
var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
@@ -128,7 +127,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
128
127
|
console.error(`Failed to ${operation}:`, error);
|
|
129
128
|
this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
|
|
130
129
|
await this.core.effects.emit(
|
|
131
|
-
|
|
130
|
+
`${this.name}:onCustomerListError`,
|
|
132
131
|
this.store.error
|
|
133
132
|
);
|
|
134
133
|
}
|
|
@@ -150,7 +149,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
150
149
|
this.store.hasMore = page * pageSize < total;
|
|
151
150
|
this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
|
|
152
151
|
await this.core.effects.emit(
|
|
153
|
-
|
|
152
|
+
`${this.name}:onCustomerListUpdate`,
|
|
154
153
|
this.store
|
|
155
154
|
);
|
|
156
155
|
this.triggerPaginationChange({
|
|
@@ -193,7 +192,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
193
192
|
setSelectedCustomer(customer) {
|
|
194
193
|
this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
|
|
195
194
|
this.core.effects.emit(
|
|
196
|
-
|
|
195
|
+
`${this.name}:onCustomerSelected`,
|
|
197
196
|
this.store.selectedCustomer
|
|
198
197
|
);
|
|
199
198
|
this.storeChange();
|
|
@@ -233,7 +232,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
233
232
|
this.store.loadingMore = false;
|
|
234
233
|
this.store.searchParams = {};
|
|
235
234
|
this.core.effects.emit(
|
|
236
|
-
|
|
235
|
+
`${this.name}:onCustomerListUpdate`,
|
|
237
236
|
this.store
|
|
238
237
|
);
|
|
239
238
|
this.storeChange();
|
|
@@ -247,7 +246,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
247
246
|
this.store.customerList = [newCustomer, ...this.store.customerList];
|
|
248
247
|
this.store.total += 1;
|
|
249
248
|
this.core.effects.emit(
|
|
250
|
-
|
|
249
|
+
`${this.name}:onCustomerListUpdate`,
|
|
251
250
|
this.store
|
|
252
251
|
);
|
|
253
252
|
this.storeChange();
|
|
@@ -277,7 +276,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
277
276
|
*/
|
|
278
277
|
triggerPaginationChange(pagination) {
|
|
279
278
|
this.core.effects.emit(
|
|
280
|
-
|
|
279
|
+
`${this.name}:onPaginationChange`,
|
|
281
280
|
pagination
|
|
282
281
|
);
|
|
283
282
|
}
|
|
@@ -344,7 +343,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
344
343
|
this.store.total = total;
|
|
345
344
|
this.store.hasMore = page * pageSize < total;
|
|
346
345
|
await this.core.effects.emit(
|
|
347
|
-
|
|
346
|
+
`${this.name}:onScrollLoadMore`,
|
|
348
347
|
{
|
|
349
348
|
newCustomers,
|
|
350
349
|
allCustomers: this.store.customerList,
|
|
@@ -353,7 +352,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
353
352
|
}
|
|
354
353
|
);
|
|
355
354
|
await this.core.effects.emit(
|
|
356
|
-
|
|
355
|
+
`${this.name}:onCustomerListUpdate`,
|
|
357
356
|
this.store
|
|
358
357
|
);
|
|
359
358
|
this.triggerPaginationChange({
|
|
@@ -395,7 +394,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
395
394
|
};
|
|
396
395
|
const response = await this.getCustomerList(resetParams);
|
|
397
396
|
await this.core.effects.emit(
|
|
398
|
-
|
|
397
|
+
`${this.name}:onScrollLoadComplete`,
|
|
399
398
|
{
|
|
400
399
|
customers: this.store.customerList,
|
|
401
400
|
total: this.store.total,
|
|
@@ -184,7 +184,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
184
184
|
async destroy() {
|
|
185
185
|
this.store.discountList = [];
|
|
186
186
|
this.core.effects.offByModuleDestroy(this.name);
|
|
187
|
-
await this.core.effects.emit(
|
|
187
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
188
188
|
console.log("[Discount] 已销毁");
|
|
189
189
|
}
|
|
190
190
|
async clear() {
|
|
@@ -41,8 +41,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
41
41
|
}
|
|
42
42
|
async addGuest(guest) {
|
|
43
43
|
this.state.list.push(guest);
|
|
44
|
-
await this.core.effects.emit(
|
|
45
|
-
await this.core.effects.emit(
|
|
44
|
+
await this.core.effects.emit(`${this.name}:onGuestAdd`, guest);
|
|
45
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
46
46
|
}
|
|
47
47
|
async updateGuest(id, updates) {
|
|
48
48
|
const index = this.state.list.findIndex((g) => g.id === id);
|
|
@@ -56,15 +56,15 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
56
56
|
import_types.GuestHooks.OnGuestUpdate,
|
|
57
57
|
this.state.list[index]
|
|
58
58
|
);
|
|
59
|
-
await this.core.effects.emit(
|
|
59
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
60
60
|
}
|
|
61
61
|
async removeGuest(id) {
|
|
62
62
|
const index = this.state.list.findIndex((g) => g.id === id);
|
|
63
63
|
if (index === -1)
|
|
64
64
|
return;
|
|
65
65
|
const [removed] = this.state.list.splice(index, 1);
|
|
66
|
-
await this.core.effects.emit(
|
|
67
|
-
await this.core.effects.emit(
|
|
66
|
+
await this.core.effects.emit(`${this.name}:onGuestRemove`, removed);
|
|
67
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
68
68
|
}
|
|
69
69
|
async getGuests() {
|
|
70
70
|
return this.state.list;
|
|
@@ -77,8 +77,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
77
77
|
if (!guest)
|
|
78
78
|
return;
|
|
79
79
|
guest.items.push(item);
|
|
80
|
-
await this.core.effects.emit(
|
|
81
|
-
await this.core.effects.emit(
|
|
80
|
+
await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
|
|
81
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
82
82
|
}
|
|
83
83
|
async removeItemFromGuest(guestId, itemId) {
|
|
84
84
|
const guest = this.state.list.find((g) => g.id === guestId);
|
|
@@ -88,8 +88,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
|
|
|
88
88
|
if (index === -1)
|
|
89
89
|
return;
|
|
90
90
|
guest.items.splice(index, 1);
|
|
91
|
-
await this.core.effects.emit(
|
|
92
|
-
await this.core.effects.emit(
|
|
91
|
+
await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
|
|
92
|
+
await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -193,7 +193,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
193
193
|
console.warn("[PaymentModule] 无法缓存支付方式,pay_method 表不存在");
|
|
194
194
|
}
|
|
195
195
|
await this.core.effects.emit(
|
|
196
|
-
|
|
196
|
+
`${this.name}:onPaymentMethodsLoaded`,
|
|
197
197
|
payMethods
|
|
198
198
|
);
|
|
199
199
|
this.logInfo("getPayMethodListAsync completed successfully", {
|
|
@@ -243,7 +243,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
243
243
|
newMethods: newPayMethods
|
|
244
244
|
};
|
|
245
245
|
await this.core.effects.emit(
|
|
246
|
-
|
|
246
|
+
`${this.name}:onPaymentMethodsChanged`,
|
|
247
247
|
eventData
|
|
248
248
|
);
|
|
249
249
|
} else {
|
|
@@ -338,7 +338,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
338
338
|
this.recalculateOrderAmount(existingOrder);
|
|
339
339
|
await this.dbManager.update("order", existingOrder);
|
|
340
340
|
await this.core.effects.emit(
|
|
341
|
-
|
|
341
|
+
`${this.name}:onOrderUpdated`,
|
|
342
342
|
existingOrder
|
|
343
343
|
);
|
|
344
344
|
return existingOrder;
|
|
@@ -358,7 +358,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
358
358
|
deposit_amount: params.deposit_amount || "0.00"
|
|
359
359
|
};
|
|
360
360
|
await this.dbManager.add("order", newOrder);
|
|
361
|
-
this.core.effects.emit(
|
|
361
|
+
this.core.effects.emit(`${this.name}:onOrderAdded`, newOrder);
|
|
362
362
|
this.logInfo("createPaymentOrderAsync completed - new payment order created", {
|
|
363
363
|
orderUuid: newOrder.uuid,
|
|
364
364
|
orderId: newOrder.id
|
|
@@ -381,7 +381,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
381
381
|
const order = await this.dbManager.get("order", orderUuid);
|
|
382
382
|
if (order) {
|
|
383
383
|
await this.dbManager.delete("order", orderUuid);
|
|
384
|
-
await this.core.effects.emit(
|
|
384
|
+
await this.core.effects.emit(`${this.name}:onOrderDeleted`, order);
|
|
385
385
|
console.log("[PaymentModule] 支付订单删除成功:", orderUuid);
|
|
386
386
|
}
|
|
387
387
|
} catch (error) {
|
|
@@ -399,8 +399,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
399
399
|
const updatedOrder = { ...order, ...params };
|
|
400
400
|
this.recalculateOrderAmount(updatedOrder);
|
|
401
401
|
await this.dbManager.update("order", updatedOrder);
|
|
402
|
-
await this.core.effects.emit(
|
|
403
|
-
await this.core.effects.emit(
|
|
402
|
+
await this.core.effects.emit(`${this.name}:onOrderUpdated`, updatedOrder);
|
|
403
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
404
404
|
action: "update",
|
|
405
405
|
order: updatedOrder,
|
|
406
406
|
originalOrder: order
|
|
@@ -458,8 +458,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
458
458
|
}
|
|
459
459
|
};
|
|
460
460
|
await this.dbManager.update("order", updatedOrder);
|
|
461
|
-
await this.core.effects.emit(
|
|
462
|
-
await this.core.effects.emit(
|
|
461
|
+
await this.core.effects.emit(`${this.name}:onOrderUpdated`, updatedOrder);
|
|
462
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
463
463
|
action: "order_id_replaced",
|
|
464
464
|
order: updatedOrder,
|
|
465
465
|
originalOrder: existingOrder,
|
|
@@ -576,7 +576,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
576
576
|
order.payment.push(newPaymentItem);
|
|
577
577
|
this.recalculateOrderAmount(order);
|
|
578
578
|
await this.dbManager.update("order", order);
|
|
579
|
-
await this.core.effects.emit(
|
|
579
|
+
await this.core.effects.emit(`${this.name}:onPaymentAdded`, {
|
|
580
580
|
orderUuid,
|
|
581
581
|
payment: newPaymentItem
|
|
582
582
|
});
|
|
@@ -632,11 +632,11 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
632
632
|
});
|
|
633
633
|
this.recalculateOrderAmount(order);
|
|
634
634
|
await this.dbManager.update("order", order);
|
|
635
|
-
await this.core.effects.emit(
|
|
635
|
+
await this.core.effects.emit(`${this.name}:onPaymentDeleted`, {
|
|
636
636
|
order,
|
|
637
637
|
paymentItem
|
|
638
638
|
});
|
|
639
|
-
await this.core.effects.emit(
|
|
639
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
640
640
|
action: "payment_delete",
|
|
641
641
|
order,
|
|
642
642
|
paymentItem
|
|
@@ -713,7 +713,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
713
713
|
await this.addPaymentItemAsync(orderUuid, voucherItem);
|
|
714
714
|
}
|
|
715
715
|
const updatedOrder = await this.getPaymentOrderByUuidAsync(orderUuid);
|
|
716
|
-
await this.core.effects.emit(
|
|
716
|
+
await this.core.effects.emit(`${this.name}:onPaymentAdded`, {
|
|
717
717
|
orderUuid,
|
|
718
718
|
order: updatedOrder,
|
|
719
719
|
payment: null
|
|
@@ -754,11 +754,11 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
754
754
|
Object.assign(paymentItem, formattedParams);
|
|
755
755
|
this.recalculateOrderAmount(order);
|
|
756
756
|
await this.dbManager.update("order", order);
|
|
757
|
-
await this.core.effects.emit(
|
|
757
|
+
await this.core.effects.emit(`${this.name}:onPaymentUpdated`, {
|
|
758
758
|
order,
|
|
759
759
|
paymentItem
|
|
760
760
|
});
|
|
761
|
-
await this.core.effects.emit(
|
|
761
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
762
762
|
action: "payment_update",
|
|
763
763
|
order,
|
|
764
764
|
paymentItem
|
|
@@ -846,8 +846,8 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
846
846
|
});
|
|
847
847
|
return;
|
|
848
848
|
}
|
|
849
|
-
await this.core.effects.emit(
|
|
850
|
-
await this.core.effects.emit(
|
|
849
|
+
await this.core.effects.emit(`${this.name}:onPaymentSubmitted`, order);
|
|
850
|
+
await this.core.effects.emit(`${this.name}:onOrderChanged`, {
|
|
851
851
|
action: "submit",
|
|
852
852
|
order
|
|
853
853
|
});
|
|
@@ -38,7 +38,9 @@ var WalletPassPaymentImpl = class {
|
|
|
38
38
|
*/
|
|
39
39
|
emitEvent(hook, data) {
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
const eventName = hook.split(":")[1] || hook.replace(/^[A-Z][a-z]+/, "").replace(/^On/, "").toLowerCase();
|
|
42
|
+
const fullEventName = `${this.paymentModule.name}:${eventName}`;
|
|
43
|
+
this.paymentModule.core.effects.emit(fullEventName, data);
|
|
42
44
|
} catch (error) {
|
|
43
45
|
this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
|
|
44
46
|
}
|
|
@@ -24,7 +24,6 @@ __export(ProductList_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(ProductList_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
|
-
var import_types = require("./types");
|
|
28
27
|
var import_lodash_es = require("lodash-es");
|
|
29
28
|
__reExport(ProductList_exports, require("./types"), module.exports);
|
|
30
29
|
var ProductList = class extends import_BaseModule.BaseModule {
|
|
@@ -98,7 +97,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
98
97
|
schedule_date,
|
|
99
98
|
with_schedule,
|
|
100
99
|
schedule_datetime,
|
|
101
|
-
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel
|
|
100
|
+
application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
|
|
101
|
+
is_eject: 1
|
|
102
102
|
},
|
|
103
103
|
{ useCache: true }
|
|
104
104
|
);
|
|
@@ -126,14 +126,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
126
126
|
}
|
|
127
127
|
async getProducts() {
|
|
128
128
|
await this.core.effects.emit(
|
|
129
|
-
|
|
129
|
+
`${this.name}:onGetProducts`,
|
|
130
130
|
this.store.list
|
|
131
131
|
);
|
|
132
132
|
return (0, import_lodash_es.cloneDeep)(this.store.list);
|
|
133
133
|
}
|
|
134
134
|
async getProduct(id) {
|
|
135
135
|
await this.core.effects.emit(
|
|
136
|
-
|
|
136
|
+
`${this.name}:onGetProduct`,
|
|
137
137
|
this.store.list
|
|
138
138
|
);
|
|
139
139
|
const product = this.store.list.find((product2) => product2.id === id);
|
|
@@ -42,7 +42,7 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
42
42
|
if (!resource)
|
|
43
43
|
return;
|
|
44
44
|
this.store.selectedResource = resource;
|
|
45
|
-
await this.core.effects.emit(
|
|
45
|
+
await this.core.effects.emit(`${this.name}:onResourceSelect`, resource);
|
|
46
46
|
}
|
|
47
47
|
getSelectedResource() {
|
|
48
48
|
return this.store.selectedResource;
|