@pisell/pisellos 2.1.172 → 2.1.174
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/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +12 -63
- 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/Cart/utils/changePrice.js +16 -9
- package/dist/modules/Discount/availability.d.ts +7 -0
- package/dist/modules/Discount/availability.js +52 -0
- package/dist/modules/Discount/entitlementPass.d.ts +34 -0
- package/dist/modules/Discount/entitlementPass.js +147 -0
- package/dist/modules/Discount/entitlementState.d.ts +8 -0
- package/dist/modules/Discount/entitlementState.js +205 -0
- package/dist/modules/Discount/index.d.ts +12 -3
- package/dist/modules/Discount/index.js +211 -17
- package/dist/modules/Discount/types.d.ts +42 -22
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- 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 +67 -1
- package/dist/modules/Order/index.js +923 -30
- package/dist/modules/Order/types.d.ts +176 -12
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +128 -0
- package/dist/modules/Order/utils.js +621 -5
- 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/types.d.ts +7 -0
- 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/entitlementLines.d.ts +8 -0
- package/dist/modules/Rules/entitlementLines.js +157 -0
- package/dist/modules/Rules/index.d.ts +17 -11
- package/dist/modules/Rules/index.js +495 -726
- package/dist/modules/Rules/types.d.ts +2 -4
- 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 +67 -57
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +6 -1
- package/dist/plugins/window.d.ts +3 -2
- package/dist/solution/BookingByStep/index.d.ts +17 -3
- package/dist/solution/BookingByStep/index.js +322 -247
- package/dist/solution/BookingByStep/types.d.ts +4 -1
- package/dist/solution/BookingByStep/types.js +7 -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 +158 -0
- package/dist/solution/ScanOrder/index.js +3474 -0
- package/dist/solution/ScanOrder/types.d.ts +307 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +172 -0
- package/dist/solution/ScanOrder/utils.js +796 -0
- package/dist/solution/ShopDiscount/index.d.ts +6 -2
- package/dist/solution/ShopDiscount/index.js +194 -110
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.js +1 -2
- package/dist/solution/ShopDiscount/utils.d.ts +1 -0
- package/dist/solution/ShopDiscount/utils.js +52 -27
- package/dist/solution/VenueBooking/index.d.ts +225 -0
- package/dist/solution/VenueBooking/index.js +3749 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +156 -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/dist/types/index.d.ts +1 -0
- 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 +49 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +7 -36
- 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/Cart/utils/changePrice.js +13 -9
- package/lib/modules/Discount/availability.d.ts +7 -0
- package/lib/modules/Discount/availability.js +91 -0
- package/lib/modules/Discount/entitlementPass.d.ts +34 -0
- package/lib/modules/Discount/entitlementPass.js +184 -0
- package/lib/modules/Discount/entitlementState.d.ts +8 -0
- package/lib/modules/Discount/entitlementState.js +206 -0
- package/lib/modules/Discount/index.d.ts +12 -3
- package/lib/modules/Discount/index.js +123 -12
- package/lib/modules/Discount/types.d.ts +42 -22
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- 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 +67 -1
- package/lib/modules/Order/index.js +529 -1
- package/lib/modules/Order/types.d.ts +176 -12
- package/lib/modules/Order/utils.d.ts +128 -0
- package/lib/modules/Order/utils.js +514 -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/types.d.ts +7 -0
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +5 -4
- 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/entitlementLines.d.ts +8 -0
- package/lib/modules/Rules/entitlementLines.js +158 -0
- package/lib/modules/Rules/index.d.ts +17 -11
- package/lib/modules/Rules/index.js +548 -798
- package/lib/modules/Rules/types.d.ts +2 -4
- 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 +45 -34
- package/lib/modules/index.d.ts +5 -0
- package/lib/modules/index.js +11 -1
- package/lib/plugins/window.d.ts +3 -2
- package/lib/solution/BookingByStep/index.d.ts +17 -3
- package/lib/solution/BookingByStep/index.js +45 -4
- package/lib/solution/BookingByStep/types.d.ts +4 -1
- package/lib/solution/BookingByStep/types.js +15 -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 +158 -0
- package/lib/solution/ScanOrder/index.js +2135 -0
- package/lib/solution/ScanOrder/types.d.ts +307 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +172 -0
- package/lib/solution/ScanOrder/utils.js +658 -0
- package/lib/solution/ShopDiscount/index.d.ts +6 -2
- package/lib/solution/ShopDiscount/index.js +94 -50
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +1 -0
- package/lib/solution/ShopDiscount/utils.js +48 -11
- package/lib/solution/VenueBooking/index.d.ts +225 -0
- package/lib/solution/VenueBooking/index.js +2073 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +156 -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/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -40,6 +40,9 @@ var import_utils = require("./utils");
|
|
|
40
40
|
var import_types = require("../../modules/Rules/types");
|
|
41
41
|
var import_decimal = __toESM(require("decimal.js"));
|
|
42
42
|
var import_lodash_es = require("lodash-es");
|
|
43
|
+
var import_entitlementPass = require("../../modules/Discount/entitlementPass");
|
|
44
|
+
var import_availability = require("../../modules/Discount/availability");
|
|
45
|
+
var import_entitlementState = require("../../modules/Discount/entitlementState");
|
|
43
46
|
var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
44
47
|
constructor(name, version) {
|
|
45
48
|
super(name, version);
|
|
@@ -47,6 +50,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
47
50
|
this.defaultVersion = "1.0.0";
|
|
48
51
|
this.isSolution = true;
|
|
49
52
|
this.options = {};
|
|
53
|
+
this.entitlementPassEnabled = false;
|
|
50
54
|
this.store = {
|
|
51
55
|
customer: null,
|
|
52
56
|
productList: [],
|
|
@@ -57,9 +61,18 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
57
61
|
currentBookingTime: "",
|
|
58
62
|
filteredDiscountList: [],
|
|
59
63
|
bookingSubject: void 0,
|
|
60
|
-
|
|
64
|
+
orderId: void 0
|
|
61
65
|
};
|
|
62
66
|
}
|
|
67
|
+
// 由使用多次卡的预约组件显式开启,其他入口沿用原券流程。
|
|
68
|
+
setEntitlementPassEnabled(enabled) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
this.entitlementPassEnabled = enabled;
|
|
71
|
+
(_a = this.store.rules) == null ? void 0 : _a.setEntitlementPassEnabled(enabled);
|
|
72
|
+
if (!enabled) {
|
|
73
|
+
(_b = this.store.discount) == null ? void 0 : _b.setDiscountList(this.getDiscountList().filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item)));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
63
76
|
// =========== 生命周期方法 ===========
|
|
64
77
|
async initialize(core, options) {
|
|
65
78
|
var _a, _b;
|
|
@@ -133,9 +146,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
133
146
|
`${this.name}:onCustomerChange`,
|
|
134
147
|
(customer) => {
|
|
135
148
|
var _a;
|
|
136
|
-
if (((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) && this.getDiscountList().length)
|
|
149
|
+
if (!this.entitlementPassEnabled && ((_a = this.options.otherParams) == null ? void 0 : _a.cacheId) && this.getDiscountList().length)
|
|
137
150
|
return;
|
|
138
|
-
}
|
|
139
151
|
this.loadPrepareConfig({
|
|
140
152
|
customerId: customer.id,
|
|
141
153
|
action: "create",
|
|
@@ -186,18 +198,19 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
186
198
|
// }
|
|
187
199
|
// 设置客户
|
|
188
200
|
async setCustomer(customer) {
|
|
189
|
-
var _a;
|
|
201
|
+
var _a, _b;
|
|
190
202
|
if (((_a = this.store.customer) == null ? void 0 : _a.id) !== customer.id) {
|
|
191
203
|
this.store.customer = customer;
|
|
204
|
+
if (this.entitlementPassEnabled) {
|
|
205
|
+
const retained = this.getDiscountList().filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item) || item.isEditMode || item.isScan && String(item.customer_id) === String(customer.id));
|
|
206
|
+
await ((_b = this.store.discount) == null ? void 0 : _b.setDiscountList(retained));
|
|
207
|
+
}
|
|
192
208
|
await this.core.effects.emit(
|
|
193
209
|
`${this.name}:onCustomerChange`,
|
|
194
210
|
customer
|
|
195
211
|
);
|
|
196
212
|
}
|
|
197
213
|
}
|
|
198
|
-
setOriginTotalAmount(amount) {
|
|
199
|
-
this.store.orderTotalAmount = amount;
|
|
200
|
-
}
|
|
201
214
|
// 设置holders
|
|
202
215
|
setHolders(holders) {
|
|
203
216
|
this.store.holders = holders;
|
|
@@ -205,6 +218,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
205
218
|
setBookingSubject(bookingSubject) {
|
|
206
219
|
this.store.bookingSubject = bookingSubject;
|
|
207
220
|
}
|
|
221
|
+
setOrderId(id) {
|
|
222
|
+
this.store.orderId = id;
|
|
223
|
+
}
|
|
208
224
|
// 计算优惠券
|
|
209
225
|
calcDiscount(productList, options) {
|
|
210
226
|
var _a;
|
|
@@ -217,12 +233,13 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
217
233
|
{
|
|
218
234
|
productList,
|
|
219
235
|
discountList: this.getDiscountList(),
|
|
220
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
221
236
|
holders: this.store.holders || [],
|
|
222
237
|
isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
|
|
223
238
|
},
|
|
224
239
|
options
|
|
225
240
|
) || { productList, discountList: this.getDiscountList() };
|
|
241
|
+
if (this.entitlementPassEnabled)
|
|
242
|
+
this.store.productList = newProductList || productList;
|
|
226
243
|
if (newDiscountList) {
|
|
227
244
|
newDiscountList = this.setDiscountList(newDiscountList);
|
|
228
245
|
}
|
|
@@ -280,9 +297,14 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
280
297
|
}
|
|
281
298
|
// 扫码输入code
|
|
282
299
|
async scanCode(code, customerId) {
|
|
283
|
-
var _a, _b, _c;
|
|
300
|
+
var _a, _b, _c, _d, _e;
|
|
284
301
|
try {
|
|
285
|
-
const
|
|
302
|
+
const resultDiscountWithReason = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, {
|
|
303
|
+
customerId,
|
|
304
|
+
orderId: this.store.orderId,
|
|
305
|
+
withEntitlementPass: this.entitlementPassEnabled
|
|
306
|
+
})) || { discountList: [], unavailableReasonKey: null };
|
|
307
|
+
const { discountList: resultDiscountList, unavailableReasonKey } = resultDiscountWithReason;
|
|
286
308
|
const rulesModule = this.store.rules;
|
|
287
309
|
if (!rulesModule) {
|
|
288
310
|
return {
|
|
@@ -298,7 +320,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
298
320
|
type: "server",
|
|
299
321
|
isAvailable: false,
|
|
300
322
|
productList: this.store.productList || [],
|
|
301
|
-
discountList: this.getDiscountList()
|
|
323
|
+
discountList: this.getDiscountList(),
|
|
324
|
+
unavailableReasonKey
|
|
302
325
|
};
|
|
303
326
|
}
|
|
304
327
|
const withScanList = resultDiscountList.map((item) => {
|
|
@@ -308,7 +331,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
308
331
|
};
|
|
309
332
|
});
|
|
310
333
|
const currentSelectedDiscountList = this.getDiscountList().filter((n) => n.isSelected);
|
|
311
|
-
if (currentSelectedDiscountList.length && currentSelectedDiscountList.some((n) => withScanList.some((m) => m.id === n.id))) {
|
|
334
|
+
if (!withScanList.some(import_entitlementPass.isEntitlementPass) && currentSelectedDiscountList.length && currentSelectedDiscountList.some((n) => withScanList.some((m) => m.id === n.id))) {
|
|
312
335
|
return {
|
|
313
336
|
type: "clientCalc",
|
|
314
337
|
isAvailable: true,
|
|
@@ -319,13 +342,13 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
319
342
|
const {
|
|
320
343
|
productList: newProductList,
|
|
321
344
|
discountList: newDiscountList,
|
|
345
|
+
evaluatedDiscountList,
|
|
322
346
|
isAvailable,
|
|
323
347
|
unavailableReason
|
|
324
348
|
} = rulesModule.isDiscountListAvailable({
|
|
325
349
|
productList: this.store.productList || [],
|
|
326
350
|
oldDiscountList: this.getDiscountList(),
|
|
327
351
|
newDiscountList: withScanList,
|
|
328
|
-
orderTotalAmount: this.store.orderTotalAmount || 0,
|
|
329
352
|
holders: this.store.holders || [],
|
|
330
353
|
isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
|
|
331
354
|
}) || {
|
|
@@ -333,22 +356,42 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
333
356
|
productList: this.store.productList || [],
|
|
334
357
|
discountList: this.getDiscountList()
|
|
335
358
|
};
|
|
359
|
+
let isAccepted = isAvailable;
|
|
336
360
|
if (isAvailable) {
|
|
361
|
+
if (this.entitlementPassEnabled)
|
|
362
|
+
this.setProductList(newProductList || []);
|
|
337
363
|
this.setDiscountList(newDiscountList || []);
|
|
338
364
|
this.store.originalDiscountList = newDiscountList || [];
|
|
339
|
-
this.
|
|
365
|
+
if (!this.entitlementPassEnabled)
|
|
366
|
+
this.setProductList(newProductList || []);
|
|
340
367
|
if (this.isWalkIn() && resultDiscountList.length && ((_c = this.options.otherParams) == null ? void 0 : _c.platform) === "shop") {
|
|
341
368
|
await this.getCustomerWallet(
|
|
342
369
|
resultDiscountList[0].customer_id
|
|
343
370
|
);
|
|
344
371
|
}
|
|
345
372
|
}
|
|
373
|
+
if (!isAvailable) {
|
|
374
|
+
const ids = new Set(withScanList.map((item) => String(item.id)));
|
|
375
|
+
const retainable = (evaluatedDiscountList || []).filter((item) => ids.has(String(item.id)) && (0, import_entitlementPass.isEntitlementPass)(item) && !(0, import_availability.getDiscountLifecycleReason)(item));
|
|
376
|
+
if (retainable.length) {
|
|
377
|
+
this.setDiscountList((0, import_entitlementState.retainScannedEntitlements)(this.getDiscountList(), retainable));
|
|
378
|
+
isAccepted = true;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (this.entitlementPassEnabled) {
|
|
382
|
+
this.store.originalDiscountList = this.getDiscountList();
|
|
383
|
+
await ((_d = this.store.discount) == null ? void 0 : _d.setOriginalDiscountList(this.getDiscountList()));
|
|
384
|
+
}
|
|
346
385
|
return {
|
|
347
386
|
type: "clientCalc",
|
|
348
387
|
isAvailable: isAvailable || false,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
388
|
+
isAccepted,
|
|
389
|
+
productList: isAvailable ? newProductList : this.store.productList || [],
|
|
390
|
+
discountList: this.getDiscountList(),
|
|
391
|
+
unavailableReason,
|
|
392
|
+
unavailableReasonKey: ((_e = (evaluatedDiscountList || []).find(
|
|
393
|
+
(item) => withScanList.some((scanned) => String(scanned.id) === String(item.id)) && item.reasonCode
|
|
394
|
+
)) == null ? void 0 : _e.reasonCode) || unavailableReasonKey
|
|
352
395
|
};
|
|
353
396
|
} catch (error) {
|
|
354
397
|
console.error("[ShopDiscount] 扫码出错:", error);
|
|
@@ -386,7 +429,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
386
429
|
}
|
|
387
430
|
// 设置优惠券列表
|
|
388
431
|
setDiscountList(discountList) {
|
|
389
|
-
var _a;
|
|
432
|
+
var _a, _b;
|
|
390
433
|
const productList = this.store.productList || [];
|
|
391
434
|
const editModeDiscountList = [];
|
|
392
435
|
productList.forEach((item) => {
|
|
@@ -394,7 +437,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
394
437
|
if (item.booking_id) {
|
|
395
438
|
const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(item);
|
|
396
439
|
(item.discount_list || []).forEach((discount) => {
|
|
397
|
-
var _a3,
|
|
440
|
+
var _a3, _b2, _c, _d, _e;
|
|
398
441
|
if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
|
|
399
442
|
const index = editModeDiscountList.findIndex((n) => {
|
|
400
443
|
var _a4;
|
|
@@ -403,12 +446,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
403
446
|
if (index !== -1) {
|
|
404
447
|
editModeDiscountList[index] = {
|
|
405
448
|
...editModeDiscountList[index],
|
|
406
|
-
metadata: {
|
|
407
|
-
...discount.metadata || {},
|
|
408
|
-
num: (((_b = (_a3 = editModeDiscountList == null ? void 0 : editModeDiscountList[index]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b.num) || 1) + (((_c = discount.metadata) == null ? void 0 : _c.num) || 1)
|
|
409
|
-
},
|
|
410
449
|
amount: new import_decimal.default(discount.amount || 0).plus(new import_decimal.default(editModeDiscountList[index].amount || 0)).toNumber(),
|
|
411
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
450
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_a3 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a3.product_discount_difference) || 0).plus(new import_decimal.default(editModeDiscountList[index].savedAmount || 0)).toNumber()
|
|
412
451
|
};
|
|
413
452
|
} else {
|
|
414
453
|
if (discount.type && !discount.tag) {
|
|
@@ -416,30 +455,26 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
416
455
|
}
|
|
417
456
|
editModeDiscountList.push({
|
|
418
457
|
...discount,
|
|
419
|
-
metadata: {
|
|
420
|
-
...discount.metadata || {},
|
|
421
|
-
num: ((_e = discount.metadata) == null ? void 0 : _e.num) || 1
|
|
422
|
-
},
|
|
423
458
|
name: discount.name || discount.discount.title.auto,
|
|
424
459
|
isEditMode: true,
|
|
425
460
|
limited_relation_product_data: {},
|
|
426
|
-
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((
|
|
461
|
+
savedAmount: new import_decimal.default(discount.amount || 0).times((product == null ? void 0 : product.quantity) || (product == null ? void 0 : product.num) || 1).plus(((_b2 = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b2.product_discount_difference) || 0).toNumber(),
|
|
427
462
|
isAvailable: true,
|
|
428
|
-
id: ((
|
|
429
|
-
format_title: ((
|
|
463
|
+
id: ((_c = discount.discount) == null ? void 0 : _c.resource_id) || discount.id,
|
|
464
|
+
format_title: ((_d = discount.discount) == null ? void 0 : _d.title) || discount.format_title,
|
|
430
465
|
isDisabled: true,
|
|
431
466
|
isSelected: true,
|
|
432
|
-
product_id: ((
|
|
467
|
+
product_id: ((_e = discount.discount) == null ? void 0 : _e.product_id) || discount.product_id
|
|
433
468
|
});
|
|
434
469
|
}
|
|
435
470
|
}
|
|
436
471
|
});
|
|
437
472
|
}
|
|
438
473
|
});
|
|
439
|
-
const newDiscountList = [
|
|
440
|
-
...editModeDiscountList,
|
|
441
|
-
...discountList.filter((item) => !item.isDisabled)
|
|
442
|
-
];
|
|
474
|
+
const newDiscountList = this.entitlementPassEnabled ? (0, import_entitlementState.withCommittedEntitlementDetails)([
|
|
475
|
+
...editModeDiscountList.filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item)),
|
|
476
|
+
...discountList.filter((item) => (0, import_entitlementPass.isEntitlementPass)(item) || !item.isDisabled)
|
|
477
|
+
], productList, ((_a = this.hooks) == null ? void 0 : _a.getProduct) || ((item) => item)) : [...editModeDiscountList, ...discountList.filter((item) => !item.isDisabled && !(0, import_entitlementPass.isEntitlementPass)(item))];
|
|
443
478
|
const isProductFree = (id) => {
|
|
444
479
|
var _a2;
|
|
445
480
|
const targetProduct = productList.find((n) => n.id === id);
|
|
@@ -469,7 +504,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
469
504
|
item.isDisabledForProductUsed = false;
|
|
470
505
|
}
|
|
471
506
|
});
|
|
472
|
-
(
|
|
507
|
+
(_b = this.store.discount) == null ? void 0 : _b.setDiscountList(newDiscountList);
|
|
473
508
|
this.emitDiscountListChange(newDiscountList);
|
|
474
509
|
return newDiscountList;
|
|
475
510
|
}
|
|
@@ -486,7 +521,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
486
521
|
});
|
|
487
522
|
if (result == null ? void 0 : result.data) {
|
|
488
523
|
const { ...customer } = result.data;
|
|
489
|
-
this.setCustomer(customer);
|
|
524
|
+
const customerUpdate = this.setCustomer(customer);
|
|
525
|
+
if (this.entitlementPassEnabled)
|
|
526
|
+
await customerUpdate;
|
|
490
527
|
await this.core.effects.emit(
|
|
491
528
|
`${this.name}:onScanCustomerChange`,
|
|
492
529
|
customer
|
|
@@ -515,29 +552,36 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
515
552
|
}
|
|
516
553
|
// 加载准备配置
|
|
517
554
|
async loadPrepareConfig(params) {
|
|
518
|
-
var _a, _b, _c, _d, _e;
|
|
555
|
+
var _a, _b, _c, _d, _e, _f;
|
|
519
556
|
try {
|
|
557
|
+
const entitlementPassEnabled = this.entitlementPassEnabled;
|
|
558
|
+
const orderId = this.store.orderId;
|
|
520
559
|
const customerId = params.customerId || ((_a = this.getCustomer()) == null ? void 0 : _a.id);
|
|
521
560
|
const goodPassList = await ((_b = this.store.discount) == null ? void 0 : _b.loadPrepareConfig({
|
|
522
561
|
customer_id: customerId,
|
|
523
|
-
action: "create",
|
|
562
|
+
action: orderId ? "edit" : "create",
|
|
524
563
|
with_good_pass: 1,
|
|
525
564
|
with_discount_card: 1,
|
|
526
565
|
with_wallet_pass_holder: 1,
|
|
527
|
-
|
|
566
|
+
...this.entitlementPassEnabled ? { with_entitlement_pass: 1, filter_order_wallet_pass_usage: 0 } : {},
|
|
567
|
+
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
568
|
+
...orderId ? { order_id: orderId } : {}
|
|
528
569
|
}));
|
|
529
|
-
|
|
530
|
-
|
|
570
|
+
if (entitlementPassEnabled !== this.entitlementPassEnabled)
|
|
571
|
+
return;
|
|
572
|
+
if (entitlementPassEnabled && (String(customerId) !== String((_c = this.getCustomer()) == null ? void 0 : _c.id) || String(orderId) !== String(this.store.orderId)))
|
|
573
|
+
return;
|
|
574
|
+
const newDiscountList = (0, import_entitlementState.mergeEntitlementDiscountLists)(
|
|
575
|
+
this.getDiscountList(),
|
|
576
|
+
goodPassList || [],
|
|
577
|
+
(_d = this.store.discount) == null ? void 0 : _d.getOriginalDiscountList()
|
|
531
578
|
);
|
|
532
|
-
const scanDiscountIds = scanDiscount.map((n) => n.id);
|
|
533
|
-
const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
|
|
534
|
-
const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
|
|
535
579
|
this.store.originalDiscountList = newDiscountList;
|
|
536
|
-
await ((
|
|
537
|
-
const filteredDiscountList = this.filterDiscountListByBookingTime(
|
|
580
|
+
await ((_e = this.store.discount) == null ? void 0 : _e.setOriginalDiscountList(newDiscountList));
|
|
581
|
+
const filteredDiscountList = newDiscountList.filter((item) => (0, import_entitlementPass.isEntitlementPass)(item) || this.filterDiscountListByBookingTime([item], this.store.currentBookingTime).length > 0);
|
|
538
582
|
this.store.filteredDiscountList = filteredDiscountList;
|
|
539
583
|
this.setDiscountList(filteredDiscountList || []);
|
|
540
|
-
if ((
|
|
584
|
+
if ((_f = this.store.productList) == null ? void 0 : _f.length) {
|
|
541
585
|
const result = this.calcDiscount(this.store.productList);
|
|
542
586
|
await this.core.effects.emit(
|
|
543
587
|
`${this.name}:onLoadPrepareCalcResult`,
|
|
@@ -546,7 +590,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
546
590
|
}
|
|
547
591
|
await this.core.effects.emit(
|
|
548
592
|
`${this.name}:onLoadDiscountList`,
|
|
549
|
-
|
|
593
|
+
filteredDiscountList
|
|
550
594
|
);
|
|
551
595
|
} catch (error) {
|
|
552
596
|
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
@@ -23,7 +23,6 @@ export interface ShopDiscountState {
|
|
|
23
23
|
discount: DiscountModule | null;
|
|
24
24
|
rules: RulesModule | null;
|
|
25
25
|
productList: Record<string, any>[];
|
|
26
|
-
orderTotalAmount?: number;
|
|
27
26
|
holders?: {
|
|
28
27
|
form_record_id: number;
|
|
29
28
|
form_id?: number;
|
|
@@ -36,6 +35,7 @@ export interface ShopDiscountState {
|
|
|
36
35
|
type?: 'form' | 'customer';
|
|
37
36
|
[key: string]: any;
|
|
38
37
|
};
|
|
38
|
+
orderId?: number;
|
|
39
39
|
}
|
|
40
40
|
export interface SetDiscountSelectedParams {
|
|
41
41
|
discountId: number;
|
|
@@ -89,3 +89,4 @@ export declare const calculateOrderLevelDiscountAllocation: (discount: Discount,
|
|
|
89
89
|
discountAmount: number;
|
|
90
90
|
difference: number;
|
|
91
91
|
}>;
|
|
92
|
+
export declare const getDiscountTimeUnavailableReason: (discount: Discount, useTime: string) => 'not_started' | 'time_limit' | 'outside_schedule' | undefined;
|
|
@@ -35,6 +35,7 @@ __export(utils_exports, {
|
|
|
35
35
|
getDiscountAmount: () => getDiscountAmount,
|
|
36
36
|
getDiscountListAmount: () => getDiscountListAmount,
|
|
37
37
|
getDiscountListAmountTotal: () => getDiscountListAmountTotal,
|
|
38
|
+
getDiscountTimeUnavailableReason: () => getDiscountTimeUnavailableReason,
|
|
38
39
|
isAllNormalProduct: () => isAllNormalProduct,
|
|
39
40
|
isNormalProductByDurationSchedule: () => isNormalProductByDurationSchedule,
|
|
40
41
|
isOrderLevelFixedAmountDiscount: () => isOrderLevelFixedAmountDiscount,
|
|
@@ -43,6 +44,11 @@ __export(utils_exports, {
|
|
|
43
44
|
module.exports = __toCommonJS(utils_exports);
|
|
44
45
|
var import_decimal = __toESM(require("decimal.js"));
|
|
45
46
|
var import_dayjs = __toESM(require("dayjs"));
|
|
47
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
48
|
+
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
|
|
49
|
+
var import_entitlementPass = require("../../modules/Discount/entitlementPass");
|
|
50
|
+
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
51
|
+
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
46
52
|
var uniqueById = (arr, key = "id") => {
|
|
47
53
|
const seen = /* @__PURE__ */ new Set();
|
|
48
54
|
return arr.filter((item) => !seen.has(item[key]) && seen.add(item[key]));
|
|
@@ -56,18 +62,14 @@ var isAllNormalProduct = (items) => {
|
|
|
56
62
|
};
|
|
57
63
|
var getDiscountAmount = (discount, total, price) => {
|
|
58
64
|
var _a;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
discountedPrice = Math.max(new import_decimal.default(price).minus(new import_decimal.default(discount.par_value || 0)).toNumber(), 0);
|
|
66
|
-
} else {
|
|
67
|
-
discountedPrice = new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
68
|
-
}
|
|
65
|
+
if ((0, import_entitlementPass.isFullCoveragePass)(discount)) {
|
|
66
|
+
return new import_decimal.default(price).minus(new import_decimal.default(price || 0)).toNumber();
|
|
67
|
+
}
|
|
68
|
+
const isFixedAmount = ((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.discount_card_type) === "fixed_amount";
|
|
69
|
+
if (isFixedAmount) {
|
|
70
|
+
return Math.max(new import_decimal.default(price).minus(new import_decimal.default((discount.amount ?? discount.par_value) || 0)).toNumber(), 0);
|
|
69
71
|
}
|
|
70
|
-
return
|
|
72
|
+
return new import_decimal.default(100).minus(discount.par_value || 0).div(100).mul(new import_decimal.default(price)).toNumber();
|
|
71
73
|
};
|
|
72
74
|
var getDiscountListAmountTotal = (discount) => {
|
|
73
75
|
return discount.reduce((acc, cur) => {
|
|
@@ -297,6 +299,8 @@ var filterDiscountListByBookingTime = (discountList, bookingTime) => {
|
|
|
297
299
|
}
|
|
298
300
|
return discountList.filter((discount) => {
|
|
299
301
|
var _a, _b;
|
|
302
|
+
if ((0, import_entitlementPass.isEntitlementPass)(discount))
|
|
303
|
+
return !getDiscountTimeUnavailableReason(discount, bookingTime);
|
|
300
304
|
if (((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.validity_type) === "custom_schedule_validity") {
|
|
301
305
|
return getDateIsInSchedule(bookingTime, ((_b = discount.custom_schedule_snapshot) == null ? void 0 : _b.data) || []);
|
|
302
306
|
}
|
|
@@ -395,6 +399,38 @@ var calculateOrderLevelDiscountAllocation = (discount, applicableProducts) => {
|
|
|
395
399
|
}
|
|
396
400
|
return result;
|
|
397
401
|
};
|
|
402
|
+
var getDiscountTimeUnavailableReason = (discount, useTime) => {
|
|
403
|
+
var _a, _b, _c, _d, _e;
|
|
404
|
+
const useTimeDayjs = (0, import_dayjs.default)(useTime);
|
|
405
|
+
if (!useTimeDayjs.isValid())
|
|
406
|
+
return "time_limit";
|
|
407
|
+
try {
|
|
408
|
+
if (((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.validity_type) === "custom_schedule_validity") {
|
|
409
|
+
return getDateIsInSchedule(useTime, ((_b = discount.custom_schedule_snapshot) == null ? void 0 : _b.data) || []) ? void 0 : "outside_schedule";
|
|
410
|
+
}
|
|
411
|
+
const isHasStart = !!discount.start_date && !!discount.start_time;
|
|
412
|
+
const startDate = (0, import_dayjs.default)(`${discount.start_date} ${discount.start_time}`);
|
|
413
|
+
if (isHasStart) {
|
|
414
|
+
if (!startDate.isValid())
|
|
415
|
+
return "time_limit";
|
|
416
|
+
if (useTimeDayjs.isBefore(startDate))
|
|
417
|
+
return "not_started";
|
|
418
|
+
}
|
|
419
|
+
const expireTime = discount.expire_time ? (0, import_dayjs.default)(discount.expire_time) : null;
|
|
420
|
+
const isBeforeExpire = expireTime ? expireTime.isValid() && useTimeDayjs.isBefore(expireTime) : true;
|
|
421
|
+
if (!isBeforeExpire)
|
|
422
|
+
return "time_limit";
|
|
423
|
+
const validity = (_d = (_c = discount.extension_data) == null ? void 0 : _c.find(
|
|
424
|
+
(field) => field.field_key === "valid_times"
|
|
425
|
+
)) == null ? void 0 : _d.value;
|
|
426
|
+
if ((validity == null ? void 0 : validity.restrict_use_by_schedule) === true && !getDateIsInSchedule(useTime, ((_e = discount.custom_schedule_snapshot) == null ? void 0 : _e.data) || [])) {
|
|
427
|
+
return "outside_schedule";
|
|
428
|
+
}
|
|
429
|
+
return void 0;
|
|
430
|
+
} catch (error) {
|
|
431
|
+
return "time_limit";
|
|
432
|
+
}
|
|
433
|
+
};
|
|
398
434
|
// Annotate the CommonJS export names for ESM import in node:
|
|
399
435
|
0 && (module.exports = {
|
|
400
436
|
calculateOrderLevelDiscountAllocation,
|
|
@@ -403,6 +439,7 @@ var calculateOrderLevelDiscountAllocation = (discount, applicableProducts) => {
|
|
|
403
439
|
getDiscountAmount,
|
|
404
440
|
getDiscountListAmount,
|
|
405
441
|
getDiscountListAmountTotal,
|
|
442
|
+
getDiscountTimeUnavailableReason,
|
|
406
443
|
isAllNormalProduct,
|
|
407
444
|
isNormalProductByDurationSchedule,
|
|
408
445
|
isOrderLevelFixedAmountDiscount,
|