@pisell/pisellos 2.1.39 → 2.1.41
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 +2 -3
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.js +2 -3
- package/dist/solution/BookingByStep/index.js +8 -4
- package/dist/solution/BookingTicket/index.d.ts +5 -1
- 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/RegisterAndLogin/config.js +2 -2
- package/dist/solution/RegisterAndLogin/index.js +2 -1
- package/dist/solution/ShopDiscount/index.js +36 -19
- 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 +2 -3
- package/lib/modules/Resource/index.js +1 -1
- package/lib/modules/Rules/index.js +2 -3
- package/lib/solution/BookingByStep/index.js +3 -3
- package/lib/solution/BookingTicket/index.d.ts +5 -1
- package/lib/solution/BookingTicket/index.js +12 -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/RegisterAndLogin/config.js +2 -2
- package/lib/solution/RegisterAndLogin/index.js +2 -1
- package/lib/solution/ShopDiscount/index.js +19 -11
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -116,7 +116,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
this.store.schedule.loadAllSchedule();
|
|
119
|
-
this.core.effects.emit(
|
|
119
|
+
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
120
120
|
}
|
|
121
121
|
// 初始化step
|
|
122
122
|
initStep(stepList) {
|
|
@@ -1921,7 +1921,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1921
1921
|
}
|
|
1922
1922
|
checkMaxDurationCapacity() {
|
|
1923
1923
|
var _a, _b;
|
|
1924
|
-
const cartItems =
|
|
1924
|
+
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
1925
1925
|
if (cartItems.length === 0)
|
|
1926
1926
|
return { success: true, minAvailableCount: 0 };
|
|
1927
1927
|
const itemsWithTime = [];
|
|
@@ -2183,7 +2183,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2183
2183
|
account
|
|
2184
2184
|
}) {
|
|
2185
2185
|
var _a, _b;
|
|
2186
|
-
const cartItems =
|
|
2186
|
+
const cartItems = this.store.cart.getItems().filter((item) => !(0, import_utils5.isNormalProduct)(item._productOrigin));
|
|
2187
2187
|
const currentCartItem = this.convertProductToCartItem({ product, date, account });
|
|
2188
2188
|
cartItems.push(currentCartItem);
|
|
2189
2189
|
if (cartItems.length === 0)
|
|
@@ -22,6 +22,10 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
22
22
|
* @returns 商品列表
|
|
23
23
|
*/
|
|
24
24
|
loadProducts(params?: ILoadProductsParams): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* 初始化外设扫码结果监听
|
|
27
|
+
*/
|
|
28
|
+
initPeripheralsListener(): void;
|
|
25
29
|
/**
|
|
26
30
|
* 获取商品列表(不加载到模块中)
|
|
27
31
|
* @returns 商品列表
|
|
@@ -111,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
111
115
|
* 获取当前的客户搜索条件
|
|
112
116
|
* @returns 当前搜索条件
|
|
113
117
|
*/
|
|
114
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
118
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
115
119
|
/**
|
|
116
120
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
117
121
|
* @returns 客户状态
|
|
@@ -99,7 +99,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
99
99
|
throw new Error(`模块 ${step} 不存在`);
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
-
this.core.effects.emit(
|
|
102
|
+
this.core.effects.emit(`${this.name}:onInited`, {});
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* 获取商品列表
|
|
@@ -115,13 +115,19 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
115
115
|
...params,
|
|
116
116
|
cacheId: this.cacheId
|
|
117
117
|
});
|
|
118
|
-
this.core.effects.emit(
|
|
118
|
+
this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
|
|
119
119
|
return result;
|
|
120
120
|
} catch (error) {
|
|
121
121
|
console.error("Failed to load products:", error);
|
|
122
122
|
throw error;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* 初始化外设扫码结果监听
|
|
127
|
+
*/
|
|
128
|
+
initPeripheralsListener() {
|
|
129
|
+
this.scan.initPeripheralsListener();
|
|
130
|
+
}
|
|
125
131
|
/**
|
|
126
132
|
* 获取商品列表(不加载到模块中)
|
|
127
133
|
* @returns 商品列表
|
|
@@ -149,7 +155,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
149
155
|
*/
|
|
150
156
|
setActiveCustomer(customer) {
|
|
151
157
|
this.store.customer.setSelectedCustomer(customer);
|
|
152
|
-
this.core.effects.emit(
|
|
158
|
+
this.core.effects.emit(`${this.name}:onCustomerSelected`, {
|
|
153
159
|
customer
|
|
154
160
|
});
|
|
155
161
|
}
|
|
@@ -168,7 +174,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
168
174
|
const customer = this.store.customer.getCustomerById(customerId);
|
|
169
175
|
if (customer) {
|
|
170
176
|
this.store.customer.setSelectedCustomer(customer);
|
|
171
|
-
this.core.effects.emit(
|
|
177
|
+
this.core.effects.emit(`${this.name}:onCustomerSelected`, {
|
|
172
178
|
customer
|
|
173
179
|
});
|
|
174
180
|
}
|
|
@@ -248,7 +254,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
248
254
|
async loadMoreCustomers() {
|
|
249
255
|
try {
|
|
250
256
|
const result = await this.store.customer.loadMoreCustomers();
|
|
251
|
-
this.core.effects.emit(
|
|
257
|
+
this.core.effects.emit(`${this.name}:onCustomerListUpdate`, result);
|
|
252
258
|
return result;
|
|
253
259
|
} catch (error) {
|
|
254
260
|
console.error("Failed to load more customers:", error);
|
|
@@ -263,7 +269,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
263
269
|
async resetAndLoadCustomers(params = {}) {
|
|
264
270
|
try {
|
|
265
271
|
const result = await this.store.customer.resetAndLoadCustomers(params);
|
|
266
|
-
this.core.effects.emit(
|
|
272
|
+
this.core.effects.emit(`${this.name}:onCustomerListReset`, result);
|
|
267
273
|
return result;
|
|
268
274
|
} catch (error) {
|
|
269
275
|
console.error("Failed to reset and load customers:", error);
|
|
@@ -37,9 +37,15 @@ var import_task = __toESM(require("../../../../utils/task"));
|
|
|
37
37
|
var Scan = class {
|
|
38
38
|
constructor(solution, watchKey) {
|
|
39
39
|
this.listenerConfig = /* @__PURE__ */ new Map();
|
|
40
|
-
var _a, _b, _c, _d, _e;
|
|
41
40
|
this.solution = solution;
|
|
42
41
|
this.watchKey = watchKey;
|
|
42
|
+
this.initPeripheralsListener();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 初始化外设扫码结果监听
|
|
46
|
+
*/
|
|
47
|
+
initPeripheralsListener() {
|
|
48
|
+
var _a, _b, _c, _d, _e;
|
|
43
49
|
(_e = (_d = (_c = (_b = (_a = this.solution) == null ? void 0 : _a.window) == null ? void 0 : _b.interaction) == null ? void 0 : _c.utils) == null ? void 0 : _d.mountFunction) == null ? void 0 : _e.call(
|
|
44
50
|
_d,
|
|
45
51
|
"global",
|
|
@@ -24,7 +24,6 @@ __export(BuyTickets_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(BuyTickets_exports);
|
|
26
26
|
var import_modules = require("../../modules/");
|
|
27
|
-
var import_types = require("./types");
|
|
28
27
|
var import_BaseModule = require("../../modules/BaseModule");
|
|
29
28
|
__reExport(BuyTickets_exports, require("./types"), module.exports);
|
|
30
29
|
var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
|
|
@@ -49,7 +48,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
|
|
|
49
48
|
if (this.otherParams.prodctIds) {
|
|
50
49
|
await this.loadProductsByIds(this.otherParams.prodctIds);
|
|
51
50
|
}
|
|
52
|
-
await this.core.effects.emit(
|
|
51
|
+
await this.core.effects.emit(`${this.name}:onInited`, {});
|
|
53
52
|
}
|
|
54
53
|
// 通过 ids 获取产品,在当前解决方案下,获取到的就是主商品
|
|
55
54
|
async loadProductsByIds(ids) {
|
|
@@ -69,13 +68,13 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
|
|
|
69
68
|
}
|
|
70
69
|
});
|
|
71
70
|
this.store.mainProducts = mainProducts;
|
|
72
|
-
await this.core.effects.emit(
|
|
71
|
+
await this.core.effects.emit(`${this.name}:onMainProductsLoaded`, {});
|
|
73
72
|
}
|
|
74
73
|
// 通过 ids 获取产品,在当前解决方案下,获取到的就是其他商品
|
|
75
74
|
async loadProductsByCategory(categoryId) {
|
|
76
75
|
}
|
|
77
76
|
async destroy() {
|
|
78
|
-
await this.core.effects.emit(
|
|
77
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
79
78
|
console.log("[BuyTickets] 已销毁");
|
|
80
79
|
}
|
|
81
80
|
// 获取当前绑定的所有商品
|
|
@@ -83,7 +82,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
|
|
|
83
82
|
var _a;
|
|
84
83
|
const mainData = await this.store.mainProducts.getProducts() || [];
|
|
85
84
|
const otherData = await ((_a = this.store.otherProducts) == null ? void 0 : _a.getProducts()) || [];
|
|
86
|
-
await this.core.effects.emit(
|
|
85
|
+
await this.core.effects.emit(`${this.name}:onGetProducts`, [
|
|
87
86
|
...mainData,
|
|
88
87
|
...otherData
|
|
89
88
|
]);
|
|
@@ -102,7 +101,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
|
|
|
102
101
|
}
|
|
103
102
|
// 商品列表页提交
|
|
104
103
|
async listSubmit(data) {
|
|
105
|
-
const res = await this.core.effects.emit(
|
|
104
|
+
const res = await this.core.effects.emit(`${this.name}:onListSubmit`, {
|
|
106
105
|
...data,
|
|
107
106
|
products: this.getProducts()
|
|
108
107
|
});
|
|
@@ -116,14 +115,14 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
|
|
|
116
115
|
}
|
|
117
116
|
// 购物车提交
|
|
118
117
|
async cartSubmit(data) {
|
|
119
|
-
await this.core.effects.emit(
|
|
118
|
+
await this.core.effects.emit(`${this.name}:onCartSubmit`, {
|
|
120
119
|
...data,
|
|
121
120
|
products: this.getProducts()
|
|
122
121
|
});
|
|
123
122
|
}
|
|
124
123
|
// 结算提交
|
|
125
124
|
async checkoutSubmit(data) {
|
|
126
|
-
await this.core.effects.emit(
|
|
125
|
+
await this.core.effects.emit(`${this.name}:onCheckoutSubmit`, {
|
|
127
126
|
...data,
|
|
128
127
|
products: this.getProducts()
|
|
129
128
|
});
|
|
@@ -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
|
});
|
|
@@ -276,7 +276,7 @@ var onlineStoreConfig = {
|
|
|
276
276
|
url: "/auth/apple/login",
|
|
277
277
|
method: "POST",
|
|
278
278
|
transformParams: (params) => ({
|
|
279
|
-
|
|
279
|
+
code: params.code
|
|
280
280
|
})
|
|
281
281
|
}
|
|
282
282
|
};
|
|
@@ -526,7 +526,7 @@ var defaultConfig = {
|
|
|
526
526
|
url: "/auth/apple/login",
|
|
527
527
|
method: "POST",
|
|
528
528
|
transformParams: (params) => ({
|
|
529
|
-
|
|
529
|
+
code: params.code
|
|
530
530
|
})
|
|
531
531
|
}
|
|
532
532
|
};
|
|
@@ -1459,7 +1459,8 @@ var RegisterAndLoginImpl = class extends import_BaseModule.BaseModule {
|
|
|
1459
1459
|
});
|
|
1460
1460
|
console.log("[RegisterAndLogin] 调用后端 appleLogin 接口");
|
|
1461
1461
|
const result = await this.apiCaller.call("appleLogin", {
|
|
1462
|
-
|
|
1462
|
+
code: identityToken || authorizationCode,
|
|
1463
|
+
login_channel: this.channel
|
|
1463
1464
|
});
|
|
1464
1465
|
console.log("[RegisterAndLogin] appleLogin 接口返回成功", {
|
|
1465
1466
|
hasResult: Boolean(result)
|
|
@@ -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
|
}
|
|
@@ -234,6 +233,15 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
234
233
|
isScan: true
|
|
235
234
|
};
|
|
236
235
|
});
|
|
236
|
+
const currentSelectedDiscountList = this.getDiscountList().filter((n) => n.isSelected);
|
|
237
|
+
if (currentSelectedDiscountList.length && currentSelectedDiscountList.some((n) => withScanList.some((m) => m.id === n.id))) {
|
|
238
|
+
return {
|
|
239
|
+
type: "clientCalc",
|
|
240
|
+
isAvailable: true,
|
|
241
|
+
productList: this.store.productList || [],
|
|
242
|
+
discountList: this.getDiscountList()
|
|
243
|
+
};
|
|
244
|
+
}
|
|
237
245
|
const {
|
|
238
246
|
productList: newProductList,
|
|
239
247
|
discountList: newDiscountList,
|
|
@@ -292,7 +300,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
292
300
|
// 触发优惠列表变更事件
|
|
293
301
|
async emitDiscountListChange(discountList) {
|
|
294
302
|
await this.core.effects.emit(
|
|
295
|
-
|
|
303
|
+
`${this.name}:onDiscountListChange`,
|
|
296
304
|
discountList
|
|
297
305
|
);
|
|
298
306
|
}
|
|
@@ -390,7 +398,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
390
398
|
const { ...customer } = result.data;
|
|
391
399
|
this.setCustomer(customer);
|
|
392
400
|
await this.core.effects.emit(
|
|
393
|
-
|
|
401
|
+
`${this.name}:onScanCustomerChange`,
|
|
394
402
|
customer
|
|
395
403
|
);
|
|
396
404
|
}
|
|
@@ -406,12 +414,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
406
414
|
const result = this.calcDiscount(this.store.productList);
|
|
407
415
|
cb == null ? void 0 : cb(result);
|
|
408
416
|
await this.core.effects.emit(
|
|
409
|
-
|
|
417
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
410
418
|
result
|
|
411
419
|
);
|
|
412
420
|
}
|
|
413
421
|
await this.core.effects.emit(
|
|
414
|
-
|
|
422
|
+
`${this.name}:onLoadDiscountList`,
|
|
415
423
|
newDiscountList
|
|
416
424
|
);
|
|
417
425
|
}
|
|
@@ -437,12 +445,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
437
445
|
if ((_d = this.store.productList) == null ? void 0 : _d.length) {
|
|
438
446
|
const result = this.calcDiscount(this.store.productList);
|
|
439
447
|
await this.core.effects.emit(
|
|
440
|
-
|
|
448
|
+
`${this.name}:onLoadPrepareCalcResult`,
|
|
441
449
|
result
|
|
442
450
|
);
|
|
443
451
|
}
|
|
444
452
|
await this.core.effects.emit(
|
|
445
|
-
|
|
453
|
+
`${this.name}:onLoadDiscountList`,
|
|
446
454
|
newDiscountList
|
|
447
455
|
);
|
|
448
456
|
} 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;
|