@pisell/pisellos 0.0.324 → 0.0.326
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 +2 -2
- 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 +1 -1
- 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/types.d.ts +7 -7
- 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/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +2 -2
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- 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/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +28 -27
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +7 -3
- package/lib/modules/Account/index.js +12 -12
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.d.ts +3 -0
- package/lib/modules/BaseModule.js +12 -6
- package/lib/modules/Cart/index.js +9 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +24 -28
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +6 -10
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +7 -12
- package/lib/modules/Guests/index.js +24 -19
- package/lib/modules/Order/index.js +9 -11
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +86 -97
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +6 -3
- package/lib/modules/Payment/walletpass.js +34 -32
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +5 -8
- package/lib/modules/Resource/index.js +13 -9
- package/lib/modules/Rules/index.js +19 -15
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +105 -71
- package/lib/solution/BookingByStep/utils/capacity.js +15 -10
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/stock.js +6 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
- package/lib/solution/BookingTicket/index.js +20 -25
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
- package/lib/solution/BuyTickets/index.js +22 -23
- package/lib/solution/Checkout/index.js +227 -234
- package/lib/solution/Checkout/utils/index.js +22 -18
- package/lib/solution/ShopDiscount/index.js +12 -16
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +7 -5
- package/package.json +1 -1
|
@@ -46,9 +46,12 @@ var sortUserIdentificationCodeList = (list) => {
|
|
|
46
46
|
var _a;
|
|
47
47
|
const errorCode = (_a = item.unified_error_code) == null ? void 0 : _a.toString();
|
|
48
48
|
const availableStatus = item.unified_available_status;
|
|
49
|
-
if (errorCode && middlePriorityErrorCodes.includes(errorCode))
|
|
50
|
-
|
|
51
|
-
if (availableStatus ===
|
|
49
|
+
if (errorCode && middlePriorityErrorCodes.includes(errorCode))
|
|
50
|
+
return 2;
|
|
51
|
+
if (availableStatus === 0)
|
|
52
|
+
return 3;
|
|
53
|
+
if (availableStatus === 1)
|
|
54
|
+
return 1;
|
|
52
55
|
return 0;
|
|
53
56
|
};
|
|
54
57
|
const aPriority = getPriority(a);
|
|
@@ -27,20 +27,22 @@ var import_utils = require("./utils");
|
|
|
27
27
|
var WalletPassPaymentImpl = class {
|
|
28
28
|
constructor(paymentModule) {
|
|
29
29
|
this.paymentModule = paymentModule;
|
|
30
|
+
this.walletRecommendList = [];
|
|
31
|
+
this.userIdentificationCodes = [];
|
|
32
|
+
this.searchResults = [];
|
|
33
|
+
this.walletParams = null;
|
|
30
34
|
}
|
|
31
|
-
walletRecommendList = [];
|
|
32
|
-
userIdentificationCodes = [];
|
|
33
|
-
searchResults = [];
|
|
34
|
-
walletParams = null;
|
|
35
35
|
/**
|
|
36
36
|
* 发送事件的辅助方法
|
|
37
37
|
* 支持使用WalletPassHooks或PaymentHooks
|
|
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
|
-
this.paymentModule.logError("[WalletPass]
|
|
45
|
+
this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
@@ -67,7 +69,7 @@ var WalletPassPaymentImpl = class {
|
|
|
67
69
|
payment_order_id
|
|
68
70
|
};
|
|
69
71
|
this.walletParams = walletParams;
|
|
70
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
72
|
+
this.paymentModule.logInfo("[WalletPass] 钱包默认参数已生成并存储", {
|
|
71
73
|
customer_id: walletParams.customer_id,
|
|
72
74
|
order_expect_amount: walletParams.order_expect_amount,
|
|
73
75
|
order_product_amount: walletParams.order_product_amount,
|
|
@@ -89,7 +91,7 @@ var WalletPassPaymentImpl = class {
|
|
|
89
91
|
*/
|
|
90
92
|
clearStoredWalletParams() {
|
|
91
93
|
this.walletParams = null;
|
|
92
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
94
|
+
this.paymentModule.logInfo("[WalletPass] 已存储的钱包参数已清理");
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
95
97
|
* 从业务数据初始化钱包数据
|
|
@@ -109,7 +111,7 @@ var WalletPassPaymentImpl = class {
|
|
|
109
111
|
businessData,
|
|
110
112
|
startTime
|
|
111
113
|
});
|
|
112
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
114
|
+
this.paymentModule.logInfo("[WalletPass] 开始从业务数据初始化钱包数据", {
|
|
113
115
|
customer_id: businessData.customer_id,
|
|
114
116
|
totalAmount: (_c = businessData.amountInfo) == null ? void 0 : _c.totalAmount,
|
|
115
117
|
subTotal: (_d = businessData.amountInfo) == null ? void 0 : _d.subTotal,
|
|
@@ -127,7 +129,7 @@ var WalletPassPaymentImpl = class {
|
|
|
127
129
|
endTime,
|
|
128
130
|
duration
|
|
129
131
|
});
|
|
130
|
-
this.paymentModule.logInfo(`[WalletPass]
|
|
132
|
+
this.paymentModule.logInfo(`[WalletPass] 从业务数据初始化钱包数据成功`, {
|
|
131
133
|
duration: `${duration}ms`,
|
|
132
134
|
walletRecommendList_count: ((_f = result.walletRecommendList) == null ? void 0 : _f.length) || 0,
|
|
133
135
|
userIdentificationCodes_count: ((_g = result.userIdentificationCodes) == null ? void 0 : _g.length) || 0
|
|
@@ -143,7 +145,7 @@ var WalletPassPaymentImpl = class {
|
|
|
143
145
|
endTime,
|
|
144
146
|
duration
|
|
145
147
|
});
|
|
146
|
-
this.paymentModule.logError(`[WalletPass]
|
|
148
|
+
this.paymentModule.logError(`[WalletPass] 从业务数据初始化钱包数据失败`, error, {
|
|
147
149
|
duration: `${duration}ms`,
|
|
148
150
|
customer_id: businessData.customer_id,
|
|
149
151
|
totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
|
|
@@ -171,7 +173,7 @@ var WalletPassPaymentImpl = class {
|
|
|
171
173
|
userIdentificationCodes
|
|
172
174
|
};
|
|
173
175
|
} catch (error) {
|
|
174
|
-
this.paymentModule.logError("[WalletPass]
|
|
176
|
+
this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
|
|
175
177
|
customer_id: baseParams.customer_id,
|
|
176
178
|
order_expect_amount: baseParams.order_expect_amount
|
|
177
179
|
});
|
|
@@ -181,7 +183,7 @@ var WalletPassPaymentImpl = class {
|
|
|
181
183
|
async getWalletPassRecommendListAsync(params) {
|
|
182
184
|
var _a;
|
|
183
185
|
try {
|
|
184
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
186
|
+
this.paymentModule.logInfo("[WalletPass] 开始获取钱包推荐列表", {
|
|
185
187
|
customer_id: params.customer_id,
|
|
186
188
|
order_expect_amount: params.order_expect_amount,
|
|
187
189
|
sale_channel: params.sale_channel,
|
|
@@ -196,7 +198,7 @@ var WalletPassPaymentImpl = class {
|
|
|
196
198
|
this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListUpdated, {
|
|
197
199
|
walletRecommendList: this.walletRecommendList
|
|
198
200
|
});
|
|
199
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
201
|
+
this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已更新", {
|
|
200
202
|
count: this.walletRecommendList.length,
|
|
201
203
|
items: this.walletRecommendList.map((item) => ({
|
|
202
204
|
voucher_id: item.voucher_id,
|
|
@@ -207,7 +209,7 @@ var WalletPassPaymentImpl = class {
|
|
|
207
209
|
});
|
|
208
210
|
return this.walletRecommendList;
|
|
209
211
|
} catch (error) {
|
|
210
|
-
this.paymentModule.logError("[WalletPass]
|
|
212
|
+
this.paymentModule.logError("[WalletPass] 获取钱包推荐列表失败", error, {
|
|
211
213
|
customer_id: params.customer_id,
|
|
212
214
|
order_expect_amount: params.order_expect_amount,
|
|
213
215
|
sale_channel: params.sale_channel
|
|
@@ -225,7 +227,7 @@ var WalletPassPaymentImpl = class {
|
|
|
225
227
|
...this.walletParams,
|
|
226
228
|
...params
|
|
227
229
|
};
|
|
228
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
230
|
+
this.paymentModule.logInfo("[WalletPass] 开始获取用户识别码列表", {
|
|
229
231
|
customer_id: newParams.customer_id,
|
|
230
232
|
available: newParams.available,
|
|
231
233
|
prepare_payments_count: ((_a = newParams.prepare_payments) == null ? void 0 : _a.length) || 0,
|
|
@@ -241,7 +243,7 @@ var WalletPassPaymentImpl = class {
|
|
|
241
243
|
this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesUpdated, {
|
|
242
244
|
userIdentificationCodes: this.userIdentificationCodes
|
|
243
245
|
});
|
|
244
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
246
|
+
this.paymentModule.logInfo("[WalletPass] 用户识别码列表已更新", {
|
|
245
247
|
count: this.userIdentificationCodes.length,
|
|
246
248
|
sorted_items: this.userIdentificationCodes.slice(0, 5).map((item) => ({
|
|
247
249
|
code: item.code,
|
|
@@ -251,7 +253,7 @@ var WalletPassPaymentImpl = class {
|
|
|
251
253
|
});
|
|
252
254
|
return this.userIdentificationCodes;
|
|
253
255
|
} catch (error) {
|
|
254
|
-
this.paymentModule.logError("[WalletPass]
|
|
256
|
+
this.paymentModule.logError("[WalletPass] 获取用户识别码列表失败", error, {
|
|
255
257
|
customer_id: params.customer_id,
|
|
256
258
|
available: params.available
|
|
257
259
|
});
|
|
@@ -267,7 +269,7 @@ var WalletPassPaymentImpl = class {
|
|
|
267
269
|
async searchIdentificationCodeAsync(params, config = {}) {
|
|
268
270
|
try {
|
|
269
271
|
const { code } = params;
|
|
270
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
272
|
+
this.paymentModule.logInfo("[WalletPass] 开始搜索识别码", {
|
|
271
273
|
code,
|
|
272
274
|
code_length: code.length,
|
|
273
275
|
noCache: config.noCache || false
|
|
@@ -279,7 +281,7 @@ var WalletPassPaymentImpl = class {
|
|
|
279
281
|
with_customer: 1,
|
|
280
282
|
with: ["wallet"]
|
|
281
283
|
};
|
|
282
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
284
|
+
this.paymentModule.logInfo("[WalletPass] 搜索钱包识别码", {
|
|
283
285
|
code,
|
|
284
286
|
with_customer: walletDetailParams.with_customer,
|
|
285
287
|
with: walletDetailParams.with
|
|
@@ -289,7 +291,7 @@ var WalletPassPaymentImpl = class {
|
|
|
289
291
|
walletDetailParams
|
|
290
292
|
);
|
|
291
293
|
const searchResults2 = (response2 == null ? void 0 : response2.data) || [];
|
|
292
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
294
|
+
this.paymentModule.logInfo("[WalletPass] 钱包识别码搜索完成", {
|
|
293
295
|
code,
|
|
294
296
|
results_count: searchResults2.length,
|
|
295
297
|
type: "walletCode"
|
|
@@ -315,7 +317,7 @@ var WalletPassPaymentImpl = class {
|
|
|
315
317
|
code: params.code,
|
|
316
318
|
payment_order_id: baseWalletParams == null ? void 0 : baseWalletParams.payment_order_id
|
|
317
319
|
};
|
|
318
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
320
|
+
this.paymentModule.logInfo("[WalletPass] 搜索普通识别码", {
|
|
319
321
|
code: searchParams.code,
|
|
320
322
|
customer_id: searchParams.customer_id,
|
|
321
323
|
order_expect_amount: searchParams.order_expect_amount,
|
|
@@ -348,7 +350,7 @@ var WalletPassPaymentImpl = class {
|
|
|
348
350
|
cachedSearchResults: [...this.searchResults],
|
|
349
351
|
searchParams: params
|
|
350
352
|
});
|
|
351
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
353
|
+
this.paymentModule.logInfo("[WalletPass] 普通识别码搜索完成", {
|
|
352
354
|
code: params.code,
|
|
353
355
|
results_count: searchResults.length,
|
|
354
356
|
cached_results_count: this.searchResults.length,
|
|
@@ -359,7 +361,7 @@ var WalletPassPaymentImpl = class {
|
|
|
359
361
|
data: searchResults
|
|
360
362
|
};
|
|
361
363
|
} catch (error) {
|
|
362
|
-
this.paymentModule.logError("[WalletPass]
|
|
364
|
+
this.paymentModule.logError("[WalletPass] 搜索识别码信息失败", error, {
|
|
363
365
|
code: params.code,
|
|
364
366
|
customer_id: params.customer_id,
|
|
365
367
|
order_expect_amount: params.order_expect_amount
|
|
@@ -368,19 +370,19 @@ var WalletPassPaymentImpl = class {
|
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
372
|
async processWalletPayment(amount, orderUuid, voucherId) {
|
|
371
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
373
|
+
this.paymentModule.logInfo("[WalletPass] 开始处理钱包支付", {
|
|
372
374
|
amount,
|
|
373
375
|
orderUuid,
|
|
374
376
|
voucherId: voucherId || "none"
|
|
375
377
|
});
|
|
376
378
|
const walletMethod = await this.paymentModule.getWalletPaymentMethod();
|
|
377
379
|
if (!walletMethod) {
|
|
378
|
-
this.paymentModule.logError("[WalletPass]
|
|
380
|
+
this.paymentModule.logError("[WalletPass] 钱包支付方式未找到", null, {
|
|
379
381
|
amount,
|
|
380
382
|
orderUuid,
|
|
381
383
|
voucherId
|
|
382
384
|
});
|
|
383
|
-
throw new Error("
|
|
385
|
+
throw new Error("钱包支付方式未找到");
|
|
384
386
|
}
|
|
385
387
|
const paymentItem = {
|
|
386
388
|
amount: amount.toString(),
|
|
@@ -391,7 +393,7 @@ var WalletPassPaymentImpl = class {
|
|
|
391
393
|
voucher_id: voucherId || ""
|
|
392
394
|
};
|
|
393
395
|
await this.paymentModule.addPaymentItemAsync(orderUuid, paymentItem);
|
|
394
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
396
|
+
this.paymentModule.logInfo("[WalletPass] 钱包支付处理完成", {
|
|
395
397
|
amount,
|
|
396
398
|
orderUuid,
|
|
397
399
|
voucherId: voucherId || "none",
|
|
@@ -421,7 +423,7 @@ var WalletPassPaymentImpl = class {
|
|
|
421
423
|
this.emitEvent(import_types.WalletPassHooks.OnWalletRecommendListCleared, {
|
|
422
424
|
clearedTypes: ["walletRecommendList"]
|
|
423
425
|
});
|
|
424
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
426
|
+
this.paymentModule.logInfo("[WalletPass] 钱包推荐列表已清除");
|
|
425
427
|
}
|
|
426
428
|
/**
|
|
427
429
|
* 清除用户识别码列表
|
|
@@ -431,7 +433,7 @@ var WalletPassPaymentImpl = class {
|
|
|
431
433
|
this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesCleared, {
|
|
432
434
|
clearedTypes: ["userIdentificationCodes"]
|
|
433
435
|
});
|
|
434
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
436
|
+
this.paymentModule.logInfo("[WalletPass] 用户识别码列表已清除");
|
|
435
437
|
}
|
|
436
438
|
/**
|
|
437
439
|
* 获取缓存的搜索结果列表
|
|
@@ -450,7 +452,7 @@ var WalletPassPaymentImpl = class {
|
|
|
450
452
|
*/
|
|
451
453
|
clearSearchResults() {
|
|
452
454
|
this.searchResults = [];
|
|
453
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
455
|
+
this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
|
|
454
456
|
}
|
|
455
457
|
/**
|
|
456
458
|
* 清除所有缓存数据
|
|
@@ -463,7 +465,7 @@ var WalletPassPaymentImpl = class {
|
|
|
463
465
|
this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
|
|
464
466
|
clearedTypes: ["all"]
|
|
465
467
|
});
|
|
466
|
-
this.paymentModule.logInfo("[WalletPass]
|
|
468
|
+
this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
|
|
467
469
|
cleared_types: ["walletRecommendList", "userIdentificationCodes", "searchResults", "walletParams"]
|
|
468
470
|
});
|
|
469
471
|
}
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -26,14 +26,13 @@ module.exports = __toCommonJS(Product_exports);
|
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
27
|
__reExport(Product_exports, require("./types"), module.exports);
|
|
28
28
|
var Product = class extends import_BaseModule.BaseModule {
|
|
29
|
-
defaultName = "product";
|
|
30
|
-
defaultVersion = "1.0.0";
|
|
31
|
-
store;
|
|
32
|
-
otherParams = {
|
|
33
|
-
scheduler: []
|
|
34
|
-
};
|
|
35
29
|
constructor(name, version) {
|
|
36
30
|
super(name, version);
|
|
31
|
+
this.defaultName = "product";
|
|
32
|
+
this.defaultVersion = "1.0.0";
|
|
33
|
+
this.otherParams = {
|
|
34
|
+
scheduler: []
|
|
35
|
+
};
|
|
37
36
|
}
|
|
38
37
|
async initialize(core, options) {
|
|
39
38
|
this.core = core;
|
|
@@ -24,17 +24,14 @@ __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 {
|
|
31
|
-
defaultName = "productList";
|
|
32
|
-
defaultVersion = "1.0.0";
|
|
33
|
-
store;
|
|
34
|
-
request;
|
|
35
|
-
otherParams = {};
|
|
36
30
|
constructor(name, version) {
|
|
37
31
|
super(name, version);
|
|
32
|
+
this.defaultName = "productList";
|
|
33
|
+
this.defaultVersion = "1.0.0";
|
|
34
|
+
this.otherParams = {};
|
|
38
35
|
}
|
|
39
36
|
async initialize(core, options) {
|
|
40
37
|
var _a;
|
|
@@ -129,14 +126,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
129
126
|
}
|
|
130
127
|
async getProducts() {
|
|
131
128
|
await this.core.effects.emit(
|
|
132
|
-
|
|
129
|
+
`${this.name}:onGetProducts`,
|
|
133
130
|
this.store.list
|
|
134
131
|
);
|
|
135
132
|
return (0, import_lodash_es.cloneDeep)(this.store.list);
|
|
136
133
|
}
|
|
137
134
|
async getProduct(id) {
|
|
138
135
|
await this.core.effects.emit(
|
|
139
|
-
|
|
136
|
+
`${this.name}:onGetProduct`,
|
|
140
137
|
this.store.list
|
|
141
138
|
);
|
|
142
139
|
const product = this.store.list.find((product2) => product2.id === id);
|
|
@@ -25,11 +25,10 @@ module.exports = __toCommonJS(Resource_exports);
|
|
|
25
25
|
var import_BaseModule = require("../BaseModule");
|
|
26
26
|
var import_types = require("./types");
|
|
27
27
|
var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
28
|
-
defaultName = "resourceList";
|
|
29
|
-
defaultVersion = "1.0.0";
|
|
30
|
-
store;
|
|
31
28
|
constructor(name, version) {
|
|
32
29
|
super(name, version);
|
|
30
|
+
this.defaultName = "resourceList";
|
|
31
|
+
this.defaultVersion = "1.0.0";
|
|
33
32
|
}
|
|
34
33
|
async initialize(core, options) {
|
|
35
34
|
this.core = core;
|
|
@@ -40,28 +39,32 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
40
39
|
}
|
|
41
40
|
async selectResource(resourceId) {
|
|
42
41
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
43
|
-
if (!resource)
|
|
42
|
+
if (!resource)
|
|
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;
|
|
49
49
|
}
|
|
50
50
|
async checkAvailability(resourceId, start, end) {
|
|
51
51
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
52
|
-
if (!resource)
|
|
52
|
+
if (!resource)
|
|
53
|
+
return false;
|
|
53
54
|
return resource.timeSlots.some(
|
|
54
55
|
(slot) => slot.start.getTime() <= start.getTime() && slot.end.getTime() >= end.getTime() && slot.availableCapacity > 0
|
|
55
56
|
);
|
|
56
57
|
}
|
|
57
58
|
async getAvailableTimeSlots(resourceId) {
|
|
58
59
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
59
|
-
if (!resource)
|
|
60
|
+
if (!resource)
|
|
61
|
+
return [];
|
|
60
62
|
return resource.timeSlots.filter((slot) => slot.availableCapacity > 0);
|
|
61
63
|
}
|
|
62
64
|
getAvailableCapacity(resourceId, timeSlot) {
|
|
63
65
|
const resource = this.store.list.find((r) => r.id === resourceId);
|
|
64
|
-
if (!resource)
|
|
66
|
+
if (!resource)
|
|
67
|
+
return 0;
|
|
65
68
|
const slot = resource.timeSlots.find(
|
|
66
69
|
(s) => s.start.getTime() === timeSlot.start.getTime() && s.end.getTime() === timeSlot.end.getTime()
|
|
67
70
|
);
|
|
@@ -69,7 +72,8 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
|
|
|
69
72
|
}
|
|
70
73
|
async updateResource(resourceId, updates) {
|
|
71
74
|
const index = this.store.list.findIndex((r) => r.id === resourceId);
|
|
72
|
-
if (index === -1)
|
|
75
|
+
if (index === -1)
|
|
76
|
+
return;
|
|
73
77
|
this.store.list[index] = {
|
|
74
78
|
...this.store.list[index],
|
|
75
79
|
...updates
|
|
@@ -33,18 +33,15 @@ __export(Rules_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Rules_exports);
|
|
35
35
|
var import_BaseModule = require("../BaseModule");
|
|
36
|
-
var import_types = require("./types");
|
|
37
36
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
38
37
|
var import_utils2 = require("../Cart/utils");
|
|
39
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
39
|
var import_lodash_es = require("lodash-es");
|
|
41
40
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
42
|
-
defaultName = "rules";
|
|
43
|
-
defaultVersion = "1.0.0";
|
|
44
|
-
store;
|
|
45
|
-
hooks;
|
|
46
41
|
constructor(name, version) {
|
|
47
42
|
super(name, version);
|
|
43
|
+
this.defaultName = "rules";
|
|
44
|
+
this.defaultVersion = "1.0.0";
|
|
48
45
|
this.hooks = {};
|
|
49
46
|
}
|
|
50
47
|
async initialize(core, options) {
|
|
@@ -54,7 +51,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
54
51
|
}
|
|
55
52
|
async setRulesList(rulesList) {
|
|
56
53
|
this.store.rulesList = rulesList;
|
|
57
|
-
await this.core.effects.emit(
|
|
54
|
+
await this.core.effects.emit(`${this.name}:onRulesListChange`, rulesList);
|
|
58
55
|
}
|
|
59
56
|
getRulesList() {
|
|
60
57
|
return this.store.rulesList;
|
|
@@ -135,15 +132,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
135
132
|
});
|
|
136
133
|
const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
|
|
137
134
|
var _a, _b;
|
|
138
|
-
if (a.tag === "good_pass" && b.tag !== "good_pass")
|
|
139
|
-
|
|
135
|
+
if (a.tag === "good_pass" && b.tag !== "good_pass")
|
|
136
|
+
return -1;
|
|
137
|
+
if (b.tag === "good_pass" && a.tag !== "good_pass")
|
|
138
|
+
return 1;
|
|
140
139
|
if (a.tag === "good_pass" && b.tag === "good_pass") {
|
|
141
140
|
return compareByExpireTime(a, b);
|
|
142
141
|
} else if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
|
|
143
142
|
const typeA = ((_a = a.metadata) == null ? void 0 : _a.discount_card_type) || "percent";
|
|
144
143
|
const typeB = ((_b = b.metadata) == null ? void 0 : _b.discount_card_type) || "percent";
|
|
145
|
-
if (typeA === "fixed_amount" && typeB === "percent")
|
|
146
|
-
|
|
144
|
+
if (typeA === "fixed_amount" && typeB === "percent")
|
|
145
|
+
return -1;
|
|
146
|
+
if (typeA === "percent" && typeB === "fixed_amount")
|
|
147
|
+
return 1;
|
|
147
148
|
if (typeA === "fixed_amount" && typeB === "fixed_amount") {
|
|
148
149
|
if (a.par_value !== b.par_value) {
|
|
149
150
|
const valueA = new import_decimal.default(a.par_value || 0);
|
|
@@ -236,13 +237,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
236
237
|
}
|
|
237
238
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
238
239
|
var _a2;
|
|
239
|
-
if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
|
|
240
|
+
if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
|
|
241
|
+
return false;
|
|
240
242
|
if ((Number(product.total) <= 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
|
|
241
243
|
var _a3;
|
|
242
244
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
243
|
-
})) && (discount.tag || discount.type) !== "good_pass")
|
|
245
|
+
})) && (discount.tag || discount.type) !== "good_pass")
|
|
246
|
+
return false;
|
|
244
247
|
const targetUsedDiscounts = usedDiscounts.get(discount.id);
|
|
245
|
-
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|
|
248
|
+
if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
|
|
249
|
+
return false;
|
|
246
250
|
const limitedData = discount.limited_relation_product_data;
|
|
247
251
|
if (limitedData.type === "product_all") {
|
|
248
252
|
return true;
|
|
@@ -484,8 +488,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
484
488
|
}
|
|
485
489
|
async destroy() {
|
|
486
490
|
this.core.effects.offByModuleDestroy(this.name);
|
|
487
|
-
await this.core.effects.emit(
|
|
488
|
-
console.log("[Rules]
|
|
491
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
492
|
+
console.log("[Rules] 已销毁");
|
|
489
493
|
}
|
|
490
494
|
async clear() {
|
|
491
495
|
console.log("[Rules] clear");
|
|
@@ -42,22 +42,19 @@ var import_utils2 = require("./utils");
|
|
|
42
42
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
43
43
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
44
44
|
var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
45
|
-
defaultName = "schedule";
|
|
46
|
-
defaultVersion = "1.0.0";
|
|
47
|
-
request;
|
|
48
|
-
store = {};
|
|
49
|
-
cacheId;
|
|
50
|
-
openCache = false;
|
|
51
|
-
fatherModule;
|
|
52
45
|
constructor(name, version) {
|
|
53
46
|
super(name, version);
|
|
47
|
+
this.defaultName = "schedule";
|
|
48
|
+
this.defaultVersion = "1.0.0";
|
|
49
|
+
this.store = {};
|
|
50
|
+
this.openCache = false;
|
|
54
51
|
}
|
|
55
52
|
async initialize(core, options) {
|
|
56
53
|
var _a, _b;
|
|
57
54
|
this.core = core;
|
|
58
55
|
this.request = core.getPlugin("request");
|
|
59
56
|
if (!this.request) {
|
|
60
|
-
throw new Error("ScheduleModule
|
|
57
|
+
throw new Error("ScheduleModule 需要 request 插件支持");
|
|
61
58
|
}
|
|
62
59
|
this.store = options == null ? void 0 : options.store;
|
|
63
60
|
if (options.initialState) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ScheduleItem = {
|
|
2
2
|
/** 颜色 */
|
|
3
3
|
color: string;
|
|
4
4
|
/** 创建时间 */
|
|
@@ -65,7 +65,7 @@ export declare type ScheduleItem = {
|
|
|
65
65
|
schedule_id: number;
|
|
66
66
|
}[];
|
|
67
67
|
};
|
|
68
|
-
export
|
|
68
|
+
export type ScheduleFormOtherValue = {
|
|
69
69
|
/** 截止模式
|
|
70
70
|
* 1: 永不截止
|
|
71
71
|
* 2: 按日期截止
|
|
@@ -79,11 +79,11 @@ export declare type ScheduleFormOtherValue = {
|
|
|
79
79
|
includeStatus: boolean;
|
|
80
80
|
type: 'standard' | 'time-slots' | 'designation';
|
|
81
81
|
};
|
|
82
|
-
export
|
|
82
|
+
export type ExcIncDate = {
|
|
83
83
|
start: string;
|
|
84
84
|
end: string;
|
|
85
85
|
};
|
|
86
|
-
export
|
|
86
|
+
export type ScheduleFormData = {
|
|
87
87
|
/** 颜色 */
|
|
88
88
|
color: string;
|
|
89
89
|
/** 日程名称 */
|
|
@@ -131,20 +131,20 @@ export declare type ScheduleFormData = {
|
|
|
131
131
|
start_time: any;
|
|
132
132
|
end_time: any;
|
|
133
133
|
};
|
|
134
|
-
export
|
|
134
|
+
export type CalendarDataItem = {
|
|
135
135
|
date: string;
|
|
136
136
|
color: string[];
|
|
137
137
|
isExcluded: boolean;
|
|
138
138
|
schedule_ids?: number[];
|
|
139
139
|
[key: string]: any;
|
|
140
140
|
};
|
|
141
|
-
export
|
|
141
|
+
export type RequestData<Data> = {
|
|
142
142
|
data: Data;
|
|
143
143
|
status: boolean;
|
|
144
144
|
message: string;
|
|
145
145
|
code: number;
|
|
146
146
|
};
|
|
147
|
-
export
|
|
147
|
+
export type ResponseListData<Data> = {
|
|
148
148
|
status: boolean;
|
|
149
149
|
message: string;
|
|
150
150
|
code: number;
|
|
@@ -4,7 +4,7 @@ export interface ScheduleState {
|
|
|
4
4
|
availabilityDateList: ScheduleAvailabilityDateItem[];
|
|
5
5
|
otherProductsIds: number[];
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export type ScheduleAvailabilityDateItem = {
|
|
8
8
|
date: string;
|
|
9
9
|
schedule_id: number[];
|
|
10
10
|
product_ids: number[];
|
|
@@ -24,7 +24,7 @@ export interface LoadScheduleAvailableDateParams {
|
|
|
24
24
|
}
|
|
25
25
|
export interface ScheduleModuleAPI {
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type ScheduleItem = {
|
|
28
28
|
/** 颜色 */
|
|
29
29
|
color: string;
|
|
30
30
|
/** 创建时间 */
|
|
@@ -91,7 +91,7 @@ export declare type ScheduleItem = {
|
|
|
91
91
|
schedule_id: number;
|
|
92
92
|
}[];
|
|
93
93
|
};
|
|
94
|
-
export
|
|
94
|
+
export type ScheduleFormOtherValue = {
|
|
95
95
|
/** 截止模式
|
|
96
96
|
* 1: 永不截止
|
|
97
97
|
* 2: 按日期截止
|
|
@@ -105,11 +105,11 @@ export declare type ScheduleFormOtherValue = {
|
|
|
105
105
|
includeStatus: boolean;
|
|
106
106
|
type: 'standard' | 'time-slots' | 'designation';
|
|
107
107
|
};
|
|
108
|
-
export
|
|
108
|
+
export type ExcIncDate = {
|
|
109
109
|
start: string;
|
|
110
110
|
end: string;
|
|
111
111
|
};
|
|
112
|
-
export
|
|
112
|
+
export type ScheduleFormData = {
|
|
113
113
|
/** 颜色 */
|
|
114
114
|
color: string;
|
|
115
115
|
/** 日程名称 */
|
|
@@ -157,20 +157,20 @@ export declare type ScheduleFormData = {
|
|
|
157
157
|
start_time: any;
|
|
158
158
|
end_time: any;
|
|
159
159
|
};
|
|
160
|
-
export
|
|
160
|
+
export type CalendarDataItem = {
|
|
161
161
|
date: string;
|
|
162
162
|
color: string[];
|
|
163
163
|
isExcluded: boolean;
|
|
164
164
|
schedule_ids?: number[];
|
|
165
165
|
[key: string]: any;
|
|
166
166
|
};
|
|
167
|
-
export
|
|
167
|
+
export type RequestData<Data> = {
|
|
168
168
|
data: Data;
|
|
169
169
|
status: boolean;
|
|
170
170
|
message: string;
|
|
171
171
|
code: number;
|
|
172
172
|
};
|
|
173
|
-
export
|
|
173
|
+
export type ResponseListData<Data> = {
|
|
174
174
|
status: boolean;
|
|
175
175
|
message: string;
|
|
176
176
|
code: number;
|
|
@@ -181,7 +181,7 @@ export declare type ResponseListData<Data> = {
|
|
|
181
181
|
skip: number;
|
|
182
182
|
};
|
|
183
183
|
};
|
|
184
|
-
export
|
|
184
|
+
export type ScheduleAllMap = Record<string, {
|
|
185
185
|
minTime: dayjs.Dayjs | null;
|
|
186
186
|
maxTime: dayjs.Dayjs | null;
|
|
187
187
|
minTimeStr: string | null;
|
|
@@ -346,7 +346,8 @@ var calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
|
|
|
346
346
|
time_slot
|
|
347
347
|
} = values;
|
|
348
348
|
const { endRadio, excludedStatus, includeStatus } = others;
|
|
349
|
-
if (!start_time)
|
|
349
|
+
if (!start_time)
|
|
350
|
+
return [];
|
|
350
351
|
const start = (0, import_dayjs.default)(start_time);
|
|
351
352
|
const end = (0, import_dayjs.default)(start_time);
|
|
352
353
|
return processDateRange(
|
|
@@ -580,7 +581,8 @@ function getAllSortedDateRanges(schedules) {
|
|
|
580
581
|
}
|
|
581
582
|
let sortedDateRanges = allDateRanges.sort((a, b) => {
|
|
582
583
|
const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
583
|
-
if (startTimeCompare !== 0)
|
|
584
|
+
if (startTimeCompare !== 0)
|
|
585
|
+
return startTimeCompare;
|
|
584
586
|
const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
|
|
585
587
|
const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
|
|
586
588
|
return durationA - durationB;
|