@pisell/pisellos 2.1.151 → 2.1.152
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/model/strategy/adapter/promotion/evaluator.js +26 -99
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +8 -61
- package/dist/model/strategy/adapter/walletPass/locales.js +3 -12
- package/dist/model/strategy/engine.d.ts +5 -18
- package/dist/model/strategy/engine.js +45 -145
- package/dist/model/strategy/type.d.ts +0 -17
- package/dist/model/strategy/type.js +0 -4
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +25 -56
- package/dist/modules/Discount/index.d.ts +9 -3
- package/dist/modules/Discount/index.js +103 -11
- package/dist/modules/Discount/types.d.ts +8 -19
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +66 -1
- package/dist/modules/Order/index.js +906 -30
- package/dist/modules/Order/types.d.ts +174 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +118 -0
- package/dist/modules/Order/utils.js +586 -2
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -3
- package/dist/modules/Quotation/index.d.ts +48 -0
- package/dist/modules/Quotation/index.js +248 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/Rules/index.d.ts +5 -9
- package/dist/modules/Rules/index.js +168 -677
- package/dist/modules/Rules/types.d.ts +0 -2
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +60 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +480 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +23 -0
- package/dist/modules/ScanOrderLogger/index.js +174 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +221 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +3 -9
- package/dist/modules/Summary/utils.js +41 -52
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -2
- package/dist/solution/BookingByStep/index.js +46 -43
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ScanOrder/index.d.ts +152 -0
- package/dist/solution/ScanOrder/index.js +3132 -0
- package/dist/solution/ScanOrder/types.d.ts +287 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +764 -0
- package/dist/solution/ShopDiscount/index.d.ts +3 -2
- package/dist/solution/ShopDiscount/index.js +60 -59
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.js +12 -26
- package/dist/solution/VenueBooking/index.d.ts +200 -0
- package/dist/solution/VenueBooking/index.js +3459 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +154 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +131 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +239 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/model/strategy/adapter/promotion/evaluator.js +8 -57
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +3 -34
- package/lib/model/strategy/adapter/walletPass/locales.js +3 -12
- package/lib/model/strategy/engine.d.ts +5 -18
- package/lib/model/strategy/engine.js +21 -85
- package/lib/model/strategy/type.d.ts +0 -17
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +12 -39
- package/lib/modules/Discount/index.d.ts +9 -3
- package/lib/modules/Discount/index.js +65 -4
- package/lib/modules/Discount/types.d.ts +8 -19
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +66 -1
- package/lib/modules/Order/index.js +515 -1
- package/lib/modules/Order/types.d.ts +174 -12
- package/lib/modules/Order/utils.d.ts +118 -0
- package/lib/modules/Order/utils.js +483 -2
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -3
- package/lib/modules/Quotation/index.d.ts +48 -0
- package/lib/modules/Quotation/index.js +152 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/Rules/index.d.ts +5 -9
- package/lib/modules/Rules/index.js +288 -780
- package/lib/modules/Rules/types.d.ts +0 -2
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +60 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +420 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +23 -0
- package/lib/modules/ScanOrderLogger/index.js +147 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +157 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +3 -9
- package/lib/modules/Summary/utils.js +22 -31
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -2
- package/lib/solution/BookingByStep/index.js +6 -4
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ScanOrder/index.d.ts +152 -0
- package/lib/solution/ScanOrder/index.js +1901 -0
- package/lib/solution/ScanOrder/types.d.ts +287 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +635 -0
- package/lib/solution/ShopDiscount/index.d.ts +3 -2
- package/lib/solution/ShopDiscount/index.js +19 -25
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/lib/solution/VenueBooking/index.d.ts +200 -0
- package/lib/solution/VenueBooking/index.js +1926 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +154 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +92 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +38 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +237 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -31,7 +31,6 @@ var WalletPassPaymentImpl = class {
|
|
|
31
31
|
this.userIdentificationCodes = [];
|
|
32
32
|
this.searchResults = [];
|
|
33
33
|
this.walletParams = null;
|
|
34
|
-
this.walletInitData = null;
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
36
|
* 发送事件的辅助方法
|
|
@@ -43,9 +42,7 @@ var WalletPassPaymentImpl = class {
|
|
|
43
42
|
const fullEventName = `${this.paymentModule.name}:${eventName}`;
|
|
44
43
|
this.paymentModule.core.effects.emit(fullEventName, data);
|
|
45
44
|
} catch (error) {
|
|
46
|
-
this.paymentModule.logError("[WalletPass] 发送事件失败", error, {
|
|
47
|
-
hook
|
|
48
|
-
});
|
|
45
|
+
this.paymentModule.logError("[WalletPass] 发送事件失败", error, { hook });
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
/**
|
|
@@ -115,10 +112,7 @@ var WalletPassPaymentImpl = class {
|
|
|
115
112
|
if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) < 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) < 0) {
|
|
116
113
|
return {
|
|
117
114
|
walletRecommendList: [],
|
|
118
|
-
userIdentificationCodes: []
|
|
119
|
-
transformList: [],
|
|
120
|
-
noApplicableVoucher: [],
|
|
121
|
-
products: []
|
|
115
|
+
userIdentificationCodes: []
|
|
122
116
|
};
|
|
123
117
|
}
|
|
124
118
|
this.emitEvent(import_types.WalletPassHooks.OnWalletInitializationStarted, {
|
|
@@ -159,28 +153,11 @@ var WalletPassPaymentImpl = class {
|
|
|
159
153
|
endTime,
|
|
160
154
|
duration
|
|
161
155
|
});
|
|
162
|
-
this.paymentModule.logError(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
customer_id: businessData.customer_id,
|
|
168
|
-
totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
throw error;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* 获取订单基础详情
|
|
176
|
-
*/
|
|
177
|
-
async getOrderBasicDetailAsync(orderId) {
|
|
178
|
-
try {
|
|
179
|
-
const response = await this.paymentModule.request.get(
|
|
180
|
-
`/order/order/${orderId}/basic-detail`
|
|
181
|
-
);
|
|
182
|
-
return (response == null ? void 0 : response.data) || {};
|
|
183
|
-
} catch (error) {
|
|
156
|
+
this.paymentModule.logError(`[WalletPass] 从业务数据初始化钱包数据失败`, error, {
|
|
157
|
+
duration: `${duration}ms`,
|
|
158
|
+
customer_id: businessData.customer_id,
|
|
159
|
+
totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
|
|
160
|
+
});
|
|
184
161
|
throw error;
|
|
185
162
|
}
|
|
186
163
|
}
|
|
@@ -189,49 +166,19 @@ var WalletPassPaymentImpl = class {
|
|
|
189
166
|
* 先获取推荐列表,再获取用户识别码列表(顺序执行)
|
|
190
167
|
*/
|
|
191
168
|
async initializeWalletDataAsync(baseParams) {
|
|
192
|
-
var _a, _b;
|
|
193
169
|
try {
|
|
170
|
+
const walletRecommendList = await this.getWalletPassRecommendListAsync(baseParams);
|
|
194
171
|
const identificationParams = {
|
|
195
172
|
...baseParams,
|
|
196
173
|
available: 2,
|
|
197
|
-
prepare_payments:
|
|
174
|
+
prepare_payments: this.formatWalletPassList2PreparePayments(walletRecommendList),
|
|
198
175
|
other_exact_codes: [],
|
|
199
176
|
filter_prepare_wallet_pass: 1
|
|
200
177
|
};
|
|
201
|
-
const
|
|
202
|
-
this.getUserIdentificationCodeListAsync(identificationParams),
|
|
203
|
-
baseParams.payment_order_id ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
|
|
204
|
-
]);
|
|
205
|
-
const walletPassEvaluator = (_b = (_a = this.paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
|
|
206
|
-
if (!walletPassEvaluator) {
|
|
207
|
-
return {
|
|
208
|
-
walletRecommendList: [],
|
|
209
|
-
userIdentificationCodes: [],
|
|
210
|
-
transformList: [],
|
|
211
|
-
noApplicableVoucher: [],
|
|
212
|
-
products: []
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
const products = (orderBasicDetail == null ? void 0 : orderBasicDetail.detail) || baseParams.products;
|
|
216
|
-
const res = walletPassEvaluator == null ? void 0 : walletPassEvaluator.getRecommendedVouchers({
|
|
217
|
-
orderTotalAmount: baseParams.order_wait_pay_amount,
|
|
218
|
-
products,
|
|
219
|
-
vouchers: allList
|
|
220
|
-
});
|
|
221
|
-
const { recommended, transformList, noApplicableVoucher, recommendedAmount } = res;
|
|
222
|
-
console.log(res, "resres12");
|
|
223
|
-
this.walletRecommendList = recommended;
|
|
224
|
-
this.walletInitData = {
|
|
225
|
-
transformList,
|
|
226
|
-
noApplicableVoucher,
|
|
227
|
-
products: products || []
|
|
228
|
-
};
|
|
178
|
+
const userIdentificationCodes = await this.getUserIdentificationCodeListAsync(identificationParams);
|
|
229
179
|
return {
|
|
230
|
-
walletRecommendList
|
|
231
|
-
userIdentificationCodes
|
|
232
|
-
transformList,
|
|
233
|
-
noApplicableVoucher,
|
|
234
|
-
products: products || []
|
|
180
|
+
walletRecommendList,
|
|
181
|
+
userIdentificationCodes
|
|
235
182
|
};
|
|
236
183
|
} catch (error) {
|
|
237
184
|
this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
|
|
@@ -314,14 +261,10 @@ var WalletPassPaymentImpl = class {
|
|
|
314
261
|
});
|
|
315
262
|
return this.userIdentificationCodes;
|
|
316
263
|
} catch (error) {
|
|
317
|
-
this.paymentModule.logError(
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
customer_id: params.customer_id,
|
|
322
|
-
available: params.available
|
|
323
|
-
}
|
|
324
|
-
);
|
|
264
|
+
this.paymentModule.logError("[WalletPass] 获取用户识别码列表失败", error, {
|
|
265
|
+
customer_id: params.customer_id,
|
|
266
|
+
available: params.available
|
|
267
|
+
});
|
|
325
268
|
return [];
|
|
326
269
|
}
|
|
327
270
|
}
|
|
@@ -519,19 +462,6 @@ var WalletPassPaymentImpl = class {
|
|
|
519
462
|
this.searchResults = [];
|
|
520
463
|
this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
|
|
521
464
|
}
|
|
522
|
-
/**
|
|
523
|
-
* 获取存储的钱包初始化数据
|
|
524
|
-
*/
|
|
525
|
-
getStoredWalletInitData() {
|
|
526
|
-
return this.walletInitData;
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* 清除存储的钱包初始化数据
|
|
530
|
-
*/
|
|
531
|
-
clearStoredWalletInitData() {
|
|
532
|
-
this.walletInitData = null;
|
|
533
|
-
this.paymentModule.logInfo("[WalletPass] 钱包初始化数据已清除");
|
|
534
|
-
}
|
|
535
465
|
/**
|
|
536
466
|
* 清除所有缓存数据
|
|
537
467
|
*/
|
|
@@ -540,18 +470,11 @@ var WalletPassPaymentImpl = class {
|
|
|
540
470
|
this.userIdentificationCodes = [];
|
|
541
471
|
this.searchResults = [];
|
|
542
472
|
this.walletParams = null;
|
|
543
|
-
this.walletInitData = null;
|
|
544
473
|
this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
|
|
545
474
|
clearedTypes: ["all"]
|
|
546
475
|
});
|
|
547
476
|
this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
|
|
548
|
-
cleared_types: [
|
|
549
|
-
"walletRecommendList",
|
|
550
|
-
"userIdentificationCodes",
|
|
551
|
-
"searchResults",
|
|
552
|
-
"walletParams",
|
|
553
|
-
"walletInitData"
|
|
554
|
-
]
|
|
477
|
+
cleared_types: ["walletRecommendList", "userIdentificationCodes", "searchResults", "walletParams"]
|
|
555
478
|
});
|
|
556
479
|
}
|
|
557
480
|
};
|
|
@@ -25,10 +25,10 @@ __export(utils_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(utils_exports);
|
|
26
26
|
function isNormalProduct(product) {
|
|
27
27
|
var _a;
|
|
28
|
-
if (product.duration) {
|
|
28
|
+
if (product == null ? void 0 : product.duration) {
|
|
29
29
|
return false;
|
|
30
30
|
}
|
|
31
|
-
if ((_a = product["schedule.ids"]) == null ? void 0 : _a.length) {
|
|
31
|
+
if ((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
return true;
|
|
@@ -16,10 +16,10 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
16
16
|
product_ids?: number[];
|
|
17
17
|
collection?: number | string[];
|
|
18
18
|
schedule_date?: string;
|
|
19
|
+
schedule_datetime?: string;
|
|
19
20
|
cacheId?: string;
|
|
20
21
|
customer_id?: number;
|
|
21
22
|
menu_list_ids?: number[];
|
|
22
|
-
schedule_datetime?: string;
|
|
23
23
|
with_count?: string[];
|
|
24
24
|
with_schedule?: number;
|
|
25
25
|
}): Promise<any>;
|
|
@@ -61,7 +61,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
61
61
|
cacheId,
|
|
62
62
|
with_schedule
|
|
63
63
|
}) {
|
|
64
|
-
var _a
|
|
64
|
+
var _a;
|
|
65
65
|
let userPlugin = this.core.getPlugin("user");
|
|
66
66
|
let customer_id = void 0;
|
|
67
67
|
try {
|
|
@@ -95,12 +95,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
95
95
|
with_count,
|
|
96
96
|
// client_schedule_ids: schedule_ids,
|
|
97
97
|
schedule_date,
|
|
98
|
-
application_code:
|
|
98
|
+
// application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
|
|
99
|
+
application_code: "online-store",
|
|
99
100
|
with_schedule,
|
|
100
101
|
schedule_datetime,
|
|
101
102
|
is_eject: 1
|
|
102
103
|
},
|
|
103
|
-
{ useCache: true
|
|
104
|
+
{ useCache: true, customToast: () => {
|
|
105
|
+
} }
|
|
104
106
|
);
|
|
105
107
|
const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
|
|
106
108
|
this.addProduct(sortedList);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import type { ScheduleItem } from '../Schedule/types';
|
|
4
|
+
import type { QuotationItem } from './types';
|
|
5
|
+
export type { QuotationItem, QuotationProductData, QuotationSchedule, QuotationState } from './types';
|
|
6
|
+
export declare class QuotationModule extends BaseModule implements Module {
|
|
7
|
+
protected defaultName: string;
|
|
8
|
+
protected defaultVersion: string;
|
|
9
|
+
private request;
|
|
10
|
+
private store;
|
|
11
|
+
private scheduleResolver?;
|
|
12
|
+
constructor(name?: string, version?: string);
|
|
13
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
|
+
loadQuotations(params?: {
|
|
15
|
+
channel?: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
getQuotationList(): QuotationItem[];
|
|
18
|
+
/**
|
|
19
|
+
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
20
|
+
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
21
|
+
*
|
|
22
|
+
* Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
|
|
23
|
+
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
24
|
+
* the requested productId wins.
|
|
25
|
+
*/
|
|
26
|
+
getPriceForProduct(params: {
|
|
27
|
+
productId: number;
|
|
28
|
+
variantId?: number;
|
|
29
|
+
datetime: string;
|
|
30
|
+
}): string | null;
|
|
31
|
+
getQuotationShelfId(params: {
|
|
32
|
+
productId: number;
|
|
33
|
+
variantId?: number;
|
|
34
|
+
datetime: string;
|
|
35
|
+
}): number;
|
|
36
|
+
/**
|
|
37
|
+
* Batch pre-compute quotation prices for a set of products across multiple time points.
|
|
38
|
+
* Key format: `${productId}:${timePoint}`
|
|
39
|
+
* This avoids repeated schedule matching when the same product appears in multiple resource rows.
|
|
40
|
+
*/
|
|
41
|
+
buildProductPriceMap(params: {
|
|
42
|
+
productIds: number[];
|
|
43
|
+
timePoints: string[];
|
|
44
|
+
}): Map<string, string | null>;
|
|
45
|
+
setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
|
|
46
|
+
private isQuotationActiveAt;
|
|
47
|
+
private findProductData;
|
|
48
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Quotation/index.ts
|
|
20
|
+
var Quotation_exports = {};
|
|
21
|
+
__export(Quotation_exports, {
|
|
22
|
+
QuotationModule: () => QuotationModule
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Quotation_exports);
|
|
25
|
+
var import_BaseModule = require("../BaseModule");
|
|
26
|
+
var import_getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
|
|
27
|
+
var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
28
|
+
constructor(name, version) {
|
|
29
|
+
super(name, version);
|
|
30
|
+
this.defaultName = "quotation";
|
|
31
|
+
this.defaultVersion = "1.0.0";
|
|
32
|
+
this.store = { list: [] };
|
|
33
|
+
}
|
|
34
|
+
async initialize(core, options) {
|
|
35
|
+
this.core = core;
|
|
36
|
+
this.request = core.getPlugin("request");
|
|
37
|
+
if (!this.request)
|
|
38
|
+
throw new Error("QuotationModule 需要 request 插件支持");
|
|
39
|
+
this.store = { list: [] };
|
|
40
|
+
}
|
|
41
|
+
async loadQuotations(params) {
|
|
42
|
+
var _a;
|
|
43
|
+
const query = {};
|
|
44
|
+
if (params == null ? void 0 : params.channel)
|
|
45
|
+
query.channel = params.channel;
|
|
46
|
+
if ((params == null ? void 0 : params.channel) === "online_store") {
|
|
47
|
+
query.channel = "online-store";
|
|
48
|
+
}
|
|
49
|
+
const res = await this.request.get(
|
|
50
|
+
"/quotation/available",
|
|
51
|
+
query,
|
|
52
|
+
{ useCache: false }
|
|
53
|
+
);
|
|
54
|
+
const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
|
|
55
|
+
list.sort((a, b) => b.sort - a.sort);
|
|
56
|
+
this.store.list = list;
|
|
57
|
+
}
|
|
58
|
+
getQuotationList() {
|
|
59
|
+
return this.store.list;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Look up the quotation price for a specific product (+ optional variant) at a given datetime.
|
|
63
|
+
* Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
|
|
64
|
+
*
|
|
65
|
+
* Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
|
|
66
|
+
* First matching quotation whose schedule covers `datetime` and whose product_data contains
|
|
67
|
+
* the requested productId wins.
|
|
68
|
+
*/
|
|
69
|
+
getPriceForProduct(params) {
|
|
70
|
+
const { productId, variantId, datetime } = params;
|
|
71
|
+
for (const quotation of this.store.list) {
|
|
72
|
+
if (!this.isQuotationActiveAt(quotation, datetime))
|
|
73
|
+
continue;
|
|
74
|
+
const match = this.findProductData(quotation.product_data, productId, variantId);
|
|
75
|
+
if (!match)
|
|
76
|
+
continue;
|
|
77
|
+
if (match.value === 0)
|
|
78
|
+
continue;
|
|
79
|
+
return String(match.value);
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
getQuotationShelfId(params) {
|
|
84
|
+
const { productId, variantId, datetime } = params;
|
|
85
|
+
for (const quotation of this.store.list) {
|
|
86
|
+
if (!this.isQuotationActiveAt(quotation, datetime))
|
|
87
|
+
continue;
|
|
88
|
+
const match = this.findProductData(quotation.product_data, productId, variantId);
|
|
89
|
+
if (!match || match.value === 0)
|
|
90
|
+
continue;
|
|
91
|
+
return quotation.id;
|
|
92
|
+
}
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Batch pre-compute quotation prices for a set of products across multiple time points.
|
|
97
|
+
* Key format: `${productId}:${timePoint}`
|
|
98
|
+
* This avoids repeated schedule matching when the same product appears in multiple resource rows.
|
|
99
|
+
*/
|
|
100
|
+
buildProductPriceMap(params) {
|
|
101
|
+
const map = /* @__PURE__ */ new Map();
|
|
102
|
+
if (!this.store.list.length)
|
|
103
|
+
return map;
|
|
104
|
+
for (const productId of params.productIds) {
|
|
105
|
+
for (const timePoint of params.timePoints) {
|
|
106
|
+
const key = `${productId}:${timePoint}`;
|
|
107
|
+
const price = this.getPriceForProduct({ productId, datetime: timePoint });
|
|
108
|
+
if (price !== null) {
|
|
109
|
+
map.set(key, price);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return map;
|
|
114
|
+
}
|
|
115
|
+
setScheduleResolver(resolver) {
|
|
116
|
+
this.scheduleResolver = resolver;
|
|
117
|
+
}
|
|
118
|
+
isQuotationActiveAt(quotation, datetime) {
|
|
119
|
+
var _a;
|
|
120
|
+
if (!((_a = quotation.schedule) == null ? void 0 : _a.length))
|
|
121
|
+
return false;
|
|
122
|
+
const scheduleItems = quotation.schedule.map((s) => {
|
|
123
|
+
var _a2;
|
|
124
|
+
const full = (_a2 = this.scheduleResolver) == null ? void 0 : _a2.call(this, s.id);
|
|
125
|
+
if (full)
|
|
126
|
+
return full;
|
|
127
|
+
return {
|
|
128
|
+
...s,
|
|
129
|
+
repeat_type: s.repeat_type || "none",
|
|
130
|
+
repeat_rule: s.repeat_rule || null,
|
|
131
|
+
time_slot: s.time_slot || []
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
return (0, import_getDateIsInSchedule.getDateIsInSchedule)(datetime, scheduleItems);
|
|
135
|
+
}
|
|
136
|
+
findProductData(productData, productId, variantId) {
|
|
137
|
+
if (variantId && variantId !== 0) {
|
|
138
|
+
const variantMatch = productData.find(
|
|
139
|
+
(p) => p.product_id === productId && p.variant_id === variantId
|
|
140
|
+
);
|
|
141
|
+
if (variantMatch)
|
|
142
|
+
return variantMatch;
|
|
143
|
+
}
|
|
144
|
+
return productData.find(
|
|
145
|
+
(p) => p.product_id === productId && p.variant_id === 0
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
+
0 && (module.exports = {
|
|
151
|
+
QuotationModule
|
|
152
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface QuotationProductData {
|
|
2
|
+
id: number;
|
|
3
|
+
shelf_id: number;
|
|
4
|
+
product_id: number;
|
|
5
|
+
variant_id: number;
|
|
6
|
+
type: string;
|
|
7
|
+
value: number;
|
|
8
|
+
}
|
|
9
|
+
export interface QuotationSchedule {
|
|
10
|
+
id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
13
|
+
start_time: string;
|
|
14
|
+
end_time: string;
|
|
15
|
+
is_all: number;
|
|
16
|
+
repeat_type?: string;
|
|
17
|
+
repeat_rule?: any;
|
|
18
|
+
designation?: any;
|
|
19
|
+
time_slot?: Array<{
|
|
20
|
+
start_time: string;
|
|
21
|
+
end_time: string;
|
|
22
|
+
}>;
|
|
23
|
+
pivot?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
export interface QuotationItem {
|
|
26
|
+
id: number;
|
|
27
|
+
shop_id: number;
|
|
28
|
+
shelf_type_id?: number;
|
|
29
|
+
name: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
status: string;
|
|
32
|
+
sort: number;
|
|
33
|
+
channel: string[];
|
|
34
|
+
created_at?: string;
|
|
35
|
+
updated_at?: string;
|
|
36
|
+
deleted_at?: string | null;
|
|
37
|
+
schedule: QuotationSchedule[];
|
|
38
|
+
product_data: QuotationProductData[];
|
|
39
|
+
}
|
|
40
|
+
export interface QuotationState {
|
|
41
|
+
list: QuotationItem[];
|
|
42
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/modules/Quotation/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
4
|
-
import { Discount } from
|
|
5
|
-
import {
|
|
4
|
+
import { Discount } from "../Discount/types";
|
|
5
|
+
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
6
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
7
7
|
protected defaultName: string;
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
|
-
window: WindowPlugin;
|
|
11
10
|
private hooks;
|
|
12
11
|
constructor(name?: string, version?: string);
|
|
13
12
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
14
13
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
15
14
|
getRulesList(): Rules[];
|
|
16
15
|
private checkHolderMatch;
|
|
17
|
-
|
|
18
|
-
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, orderTotalAmount, holders, isFormSubject, }: {
|
|
16
|
+
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
|
|
19
17
|
oldDiscountList: Discount[];
|
|
20
18
|
newDiscountList: Discount[];
|
|
21
19
|
productList: any[];
|
|
22
20
|
holders: {
|
|
23
21
|
form_record_id: number;
|
|
24
22
|
}[];
|
|
25
|
-
orderTotalAmount: number;
|
|
26
23
|
isFormSubject: boolean;
|
|
27
24
|
}): {
|
|
28
25
|
isAvailable: boolean;
|
|
@@ -32,18 +29,17 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
32
29
|
};
|
|
33
30
|
filterDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
34
31
|
private getUnavailableReason;
|
|
35
|
-
calcDiscount({ discountList, productList, holders, isFormSubject,
|
|
32
|
+
calcDiscount({ discountList, productList, holders, isFormSubject, }: {
|
|
36
33
|
discountList: Discount[];
|
|
37
34
|
productList: any[];
|
|
38
35
|
holders: {
|
|
39
36
|
form_record_id: number;
|
|
40
37
|
}[];
|
|
41
38
|
isFormSubject: boolean;
|
|
42
|
-
orderTotalAmount: number;
|
|
43
39
|
}, options?: {
|
|
44
40
|
isSelected?: boolean;
|
|
45
41
|
discountId?: number;
|
|
46
|
-
selectedList?:
|
|
42
|
+
selectedList?: SetDiscountSelectedParams[];
|
|
47
43
|
scan?: boolean;
|
|
48
44
|
}): DiscountResult;
|
|
49
45
|
/**
|