@pisell/pisellos 2.2.173 → 2.2.175
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/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Customer/index.d.ts +0 -6
- package/dist/modules/Customer/index.js +83 -129
- package/dist/modules/Customer/types.d.ts +0 -2
- package/dist/modules/Discount/index.d.ts +4 -2
- package/dist/modules/Discount/index.js +93 -8
- package/dist/modules/Discount/types.d.ts +7 -1
- package/dist/modules/Order/index.d.ts +17 -33
- package/dist/modules/Order/index.js +395 -757
- package/dist/modules/Order/types.d.ts +17 -58
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +1 -39
- package/dist/modules/Order/utils.js +31 -219
- package/dist/modules/Quotation/index.js +5 -16
- package/dist/modules/Rules/index.d.ts +0 -4
- package/dist/modules/Rules/index.js +10 -26
- package/dist/modules/SalesSummary/index.js +2 -4
- package/dist/modules/Schedule/index.js +2 -6
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/index.js +6 -10
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/server/modules/products/index.js +94 -113
- package/dist/server/modules/schedule/index.js +6 -13
- package/dist/solution/BaseSales/index.d.ts +7 -53
- package/dist/solution/BaseSales/index.js +339 -1160
- package/dist/solution/BaseSales/types.d.ts +1 -67
- package/dist/solution/BaseSales/types.js +1 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -65
- package/dist/solution/BaseSales/utils.js +8 -46
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -133
- package/dist/solution/BookingTicket/index.js +175 -776
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/BookingTicket/types.js +0 -3
- package/dist/solution/ScanOrder/index.d.ts +3 -9
- package/dist/solution/ScanOrder/index.js +128 -231
- package/dist/solution/ScanOrder/utils.js +8 -46
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +23 -18
- package/dist/solution/VenueBooking/index.d.ts +9 -5
- package/dist/solution/VenueBooking/index.js +55 -103
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/lib/modules/Customer/index.d.ts +0 -6
- package/lib/modules/Customer/index.js +11 -26
- package/lib/modules/Customer/types.d.ts +0 -2
- package/lib/modules/Discount/index.d.ts +4 -2
- package/lib/modules/Discount/index.js +63 -8
- package/lib/modules/Discount/types.d.ts +7 -1
- package/lib/modules/Order/index.d.ts +17 -33
- package/lib/modules/Order/index.js +148 -402
- package/lib/modules/Order/types.d.ts +17 -58
- package/lib/modules/Order/utils.d.ts +1 -39
- package/lib/modules/Order/utils.js +22 -197
- package/lib/modules/Quotation/index.js +6 -17
- package/lib/modules/Rules/index.d.ts +0 -4
- package/lib/modules/Rules/index.js +14 -22
- package/lib/modules/SalesSummary/index.js +2 -4
- package/lib/modules/Schedule/index.js +1 -3
- package/lib/modules/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/index.js +0 -2
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/server/modules/products/index.js +12 -23
- package/lib/server/modules/schedule/index.js +1 -2
- package/lib/solution/BaseSales/index.d.ts +7 -53
- package/lib/solution/BaseSales/index.js +20 -527
- package/lib/solution/BaseSales/types.d.ts +1 -67
- package/lib/solution/BaseSales/types.js +1 -3
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -70
- package/lib/solution/BaseSales/utils.js +6 -46
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -133
- package/lib/solution/BookingTicket/index.js +8 -349
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/BookingTicket/types.js +0 -6
- package/lib/solution/ScanOrder/index.d.ts +3 -9
- package/lib/solution/ScanOrder/index.js +66 -147
- package/lib/solution/ScanOrder/utils.js +6 -46
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +4 -2
- package/lib/solution/VenueBooking/index.d.ts +9 -5
- package/lib/solution/VenueBooking/index.js +14 -50
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
- package/package.json +2 -2
- package/dist/modules/BookingContext/index.d.ts +0 -37
- package/dist/modules/BookingContext/index.js +0 -436
- package/dist/modules/BookingContext/types.d.ts +0 -102
- package/dist/modules/BookingContext/types.js +0 -51
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -193
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -137
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -215
- package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/dist/modules/BookingContext/utils/flexible.js +0 -56
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
- package/dist/modules/BookingContext/utils/index.d.ts +0 -11
- package/dist/modules/BookingContext/utils/index.js +0 -11
- package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/dist/modules/BookingContext/utils/noResource.js +0 -77
- package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/dist/modules/BookingContext/utils/productExtend.js +0 -339
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
- package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
- package/dist/modules/BookingContext/utils/resources.js +0 -486
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/dist/modules/Order/utils/manualProductDiscount.js +0 -212
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
- package/lib/modules/BookingContext/index.d.ts +0 -37
- package/lib/modules/BookingContext/index.js +0 -297
- package/lib/modules/BookingContext/types.d.ts +0 -102
- package/lib/modules/BookingContext/types.js +0 -34
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -207
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -141
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -75
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -198
- package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
- package/lib/modules/BookingContext/utils/flexible.js +0 -80
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
- package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
- package/lib/modules/BookingContext/utils/index.d.ts +0 -11
- package/lib/modules/BookingContext/utils/index.js +0 -43
- package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
- package/lib/modules/BookingContext/utils/noResource.js +0 -90
- package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
- package/lib/modules/BookingContext/utils/productExtend.js +0 -283
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
- package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
- package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
- package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
- package/lib/modules/BookingContext/utils/resources.js +0 -377
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
- package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
- package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
- package/lib/modules/Order/utils/manualProductDiscount.js +0 -207
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
- package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -113
- package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
|
@@ -12,10 +12,6 @@ export declare function buildPriceBreakdown(params: {
|
|
|
12
12
|
}) => number;
|
|
13
13
|
};
|
|
14
14
|
}): PriceBreakdownEntry[];
|
|
15
|
-
export declare function buildVenueResourceMetadata(params: {
|
|
16
|
-
mapping: ResourceProductMapping;
|
|
17
|
-
rawResource: VenueResourceRawData | undefined;
|
|
18
|
-
}): Record<string, any>;
|
|
19
15
|
export interface BuildVenueBookingParams {
|
|
20
16
|
group: MergedSlotGroup;
|
|
21
17
|
resourceId: number | string;
|
|
@@ -89,16 +89,6 @@ export function buildPriceBreakdown(params) {
|
|
|
89
89
|
}
|
|
90
90
|
return entries;
|
|
91
91
|
}
|
|
92
|
-
export function buildVenueResourceMetadata(params) {
|
|
93
|
-
var _rawResource$form_nam, _ref, _rawResource$main_fie, _rawResource$combined;
|
|
94
|
-
var mapping = params.mapping,
|
|
95
|
-
rawResource = params.rawResource;
|
|
96
|
-
return {
|
|
97
|
-
form_name: (_rawResource$form_nam = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_name) !== null && _rawResource$form_nam !== void 0 ? _rawResource$form_nam : '',
|
|
98
|
-
resource_name: (_ref = (_rawResource$main_fie = rawResource === null || rawResource === void 0 ? void 0 : rawResource.main_field) !== null && _rawResource$main_fie !== void 0 ? _rawResource$main_fie : mapping.resourceName) !== null && _ref !== void 0 ? _ref : '',
|
|
99
|
-
combined_resource: (_rawResource$combined = rawResource === null || rawResource === void 0 ? void 0 : rawResource.combined_resource) !== null && _rawResource$combined !== void 0 ? _rawResource$combined : null
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
92
|
export function buildVenueBookingEntry(params) {
|
|
103
93
|
var _rawResource$form_id;
|
|
104
94
|
var group = params.group,
|
|
@@ -24,12 +24,6 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
|
|
|
24
24
|
* @param operation 操作名称
|
|
25
25
|
*/
|
|
26
26
|
private handleCustomerListError;
|
|
27
|
-
/**
|
|
28
|
-
* 查询客户列表但不写入 customerList / pagination 状态。
|
|
29
|
-
*
|
|
30
|
-
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
31
|
-
*/
|
|
32
|
-
queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
|
|
33
27
|
/**
|
|
34
28
|
* 获取客户列表
|
|
35
29
|
* @param params 查询参数
|
|
@@ -75,7 +75,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
75
75
|
} else {
|
|
76
76
|
this.store.currentPage = 1;
|
|
77
77
|
}
|
|
78
|
-
if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number"
|
|
78
|
+
if (typeof ((_e = options == null ? void 0 : options.initialState) == null ? void 0 : _e.pageSize) === "number") {
|
|
79
79
|
this.store.pageSize = options.initialState.pageSize;
|
|
80
80
|
} else {
|
|
81
81
|
this.store.pageSize = import_constants.DEFAULT_PAGE_SIZE;
|
|
@@ -152,20 +152,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
152
152
|
this.store.error
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
|
-
/**
|
|
156
|
-
* 查询客户列表但不写入 customerList / pagination 状态。
|
|
157
|
-
*
|
|
158
|
-
* 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
|
|
159
|
-
*/
|
|
160
|
-
async queryCustomerList(params = {}) {
|
|
161
|
-
const { customerList, total, page, pageSize } = await this.fetchCustomerListData(params);
|
|
162
|
-
return {
|
|
163
|
-
list: customerList,
|
|
164
|
-
total,
|
|
165
|
-
page,
|
|
166
|
-
pageSize
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
155
|
/**
|
|
170
156
|
* 获取客户列表
|
|
171
157
|
* @param params 查询参数
|
|
@@ -183,6 +169,10 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
183
169
|
this.store.total = total;
|
|
184
170
|
this.store.hasMore = page * pageSize < total;
|
|
185
171
|
this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
|
|
172
|
+
await this.core.effects.emit(
|
|
173
|
+
`${this.name}:onCustomerListUpdate`,
|
|
174
|
+
this.store
|
|
175
|
+
);
|
|
186
176
|
this.triggerPaginationChange({
|
|
187
177
|
page,
|
|
188
178
|
pageSize,
|
|
@@ -202,10 +192,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
202
192
|
} finally {
|
|
203
193
|
this.store.loading = false;
|
|
204
194
|
this.storeChange();
|
|
205
|
-
await this.core.effects.emit(
|
|
206
|
-
`${this.name}:onCustomerListUpdate`,
|
|
207
|
-
this.store
|
|
208
|
-
);
|
|
209
195
|
}
|
|
210
196
|
}
|
|
211
197
|
/**
|
|
@@ -366,13 +352,12 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
366
352
|
try {
|
|
367
353
|
this.store.loadingMore = true;
|
|
368
354
|
this.store.error = null;
|
|
369
|
-
const
|
|
355
|
+
const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData({
|
|
370
356
|
skip: nextPage,
|
|
371
357
|
num: this.store.pageSize,
|
|
372
358
|
...this.store.searchParams
|
|
373
359
|
// 使用存储的搜索条件
|
|
374
|
-
};
|
|
375
|
-
const { customerList: newCustomers, total, page, pageSize } = await this.fetchCustomerListData(loadMoreParams);
|
|
360
|
+
});
|
|
376
361
|
const updatedCustomerList = [...this.store.customerList, ...(0, import_lodash_es.cloneDeep)(newCustomers)];
|
|
377
362
|
this.store.customerList = updatedCustomerList;
|
|
378
363
|
this.store.currentPage = page;
|
|
@@ -387,6 +372,10 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
387
372
|
hasMore: this.store.hasMore
|
|
388
373
|
}
|
|
389
374
|
);
|
|
375
|
+
await this.core.effects.emit(
|
|
376
|
+
`${this.name}:onCustomerListUpdate`,
|
|
377
|
+
this.store
|
|
378
|
+
);
|
|
390
379
|
this.triggerPaginationChange({
|
|
391
380
|
page,
|
|
392
381
|
pageSize,
|
|
@@ -407,10 +396,6 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
|
|
|
407
396
|
} finally {
|
|
408
397
|
this.store.loadingMore = false;
|
|
409
398
|
this.storeChange();
|
|
410
|
-
await this.core.effects.emit(
|
|
411
|
-
`${this.name}:onCustomerListUpdate`,
|
|
412
|
-
this.store
|
|
413
|
-
);
|
|
414
399
|
}
|
|
415
400
|
}
|
|
416
401
|
/**
|
|
@@ -110,8 +110,6 @@ export interface CustomerState {
|
|
|
110
110
|
export interface CustomerModuleAPI {
|
|
111
111
|
/** 获取客户列表 */
|
|
112
112
|
getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
|
|
113
|
-
/** 查询客户列表但不更新列表分页状态 */
|
|
114
|
-
queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
|
|
115
113
|
/** 设置客户列表 */
|
|
116
114
|
setCustomerList: (customers: ShopCustomer[], total?: number) => void;
|
|
117
115
|
/** 设置当前选择的客户 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Discount, DiscountModuleAPI } from './types';
|
|
3
|
+
import { Discount, DiscountModuleAPI, DiscountWithReason } from './types';
|
|
4
4
|
export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
|
|
5
5
|
protected defaultName: string;
|
|
6
6
|
protected defaultVersion: string;
|
|
@@ -28,9 +28,11 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
28
28
|
batchSearch(code: string, options?: {
|
|
29
29
|
customerId?: number;
|
|
30
30
|
orderId?: number;
|
|
31
|
-
}): Promise<
|
|
31
|
+
}): Promise<DiscountWithReason>;
|
|
32
32
|
filterEnabledDiscountList(discountList: Discount[]): Discount[];
|
|
33
33
|
private checkUsageCreditsLimit;
|
|
34
|
+
filterEnabledDiscountListWithReason(discountList: Discount[]): DiscountWithReason;
|
|
35
|
+
private checkUsageCreditsLimitWithFailKey;
|
|
34
36
|
uniqueByProductId(discountList: Discount[]): Discount[];
|
|
35
37
|
filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
|
|
36
38
|
calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
|
|
@@ -97,12 +97,8 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
97
97
|
`/order/prepare/config`,
|
|
98
98
|
params
|
|
99
99
|
);
|
|
100
|
-
const rawDiscountList = [
|
|
101
|
-
...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [],
|
|
102
|
-
...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []
|
|
103
|
-
];
|
|
104
100
|
const goodPassList = this.filterEnabledDiscountList(
|
|
105
|
-
|
|
101
|
+
[...((_a = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _a.good_pass_list) || [], ...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []]
|
|
106
102
|
) || [];
|
|
107
103
|
return goodPassList;
|
|
108
104
|
}
|
|
@@ -112,16 +108,17 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
112
108
|
code,
|
|
113
109
|
translate_flag: 1,
|
|
114
110
|
tags: ["good_pass", "product_discount_card"],
|
|
115
|
-
available: 1,
|
|
111
|
+
// available: 1,
|
|
116
112
|
relation_product: 1,
|
|
117
113
|
with: ["extensionData", "customScheduleSnapshot", "holder.detail"],
|
|
118
114
|
order_behavior_count: 1,
|
|
119
115
|
order_behavior_count_customer_id: customerId || 1,
|
|
120
116
|
...orderId ? { order_behavior_count_order_id: orderId } : {},
|
|
117
|
+
unified_status_info_flag: 1,
|
|
121
118
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
122
119
|
});
|
|
123
|
-
const
|
|
124
|
-
return
|
|
120
|
+
const resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result == null ? void 0 : result.data) || []) || [];
|
|
121
|
+
return resultDiscountWithReason;
|
|
125
122
|
}
|
|
126
123
|
filterEnabledDiscountList(discountList) {
|
|
127
124
|
return discountList.filter(
|
|
@@ -167,6 +164,64 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
167
164
|
}
|
|
168
165
|
return true;
|
|
169
166
|
}
|
|
167
|
+
// 过滤启用且可用的优惠券,并返回校验失败原因
|
|
168
|
+
filterEnabledDiscountListWithReason(discountList) {
|
|
169
|
+
let lists = discountList.filter((discount) => discount.limit_status === "enable").filter((discount) => {
|
|
170
|
+
const remaining = new import_decimal.default((discount == null ? void 0 : discount.par_value) || 0).minus(new import_decimal.default((discount == null ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
|
|
171
|
+
return remaining;
|
|
172
|
+
}).map((discount) => {
|
|
173
|
+
const limitFailKey = this.checkUsageCreditsLimitWithFailKey(discount);
|
|
174
|
+
return {
|
|
175
|
+
...discount,
|
|
176
|
+
usageLimitFailKey: limitFailKey
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
const availableLists = lists.filter((item) => !item.usageLimitFailKey && item.unified_available_status !== 0);
|
|
180
|
+
const currentFailDiscount = lists.find((item) => item.usageLimitFailKey);
|
|
181
|
+
return {
|
|
182
|
+
discountList: availableLists,
|
|
183
|
+
unavailableReasonKey: currentFailDiscount == null ? void 0 : currentFailDiscount.usageLimitFailKey
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// 检查使用次数限制,并返回校验失败原因
|
|
187
|
+
checkUsageCreditsLimitWithFailKey(discount) {
|
|
188
|
+
if (!discount.extension_data || discount.extension_data.length === 0) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const usageCreditsData = discount.extension_data.find(
|
|
192
|
+
(data) => data.field_key === "usage_credits"
|
|
193
|
+
);
|
|
194
|
+
if (!usageCreditsData) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const value = usageCreditsData.value;
|
|
198
|
+
if (value.total_credits && value.total_credits > 0) {
|
|
199
|
+
if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
|
|
200
|
+
return "total_credits";
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (value.per_user_limit && value.per_user_limit > 0) {
|
|
204
|
+
if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
|
|
205
|
+
return "per_user_limit";
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (value.max_per_day && value.max_per_day > 0) {
|
|
209
|
+
if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
|
|
210
|
+
return "max_per_day";
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (value.max_per_week && value.max_per_week > 0) {
|
|
214
|
+
if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
|
|
215
|
+
return "max_per_week";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (value.max_per_month && value.max_per_month > 0) {
|
|
219
|
+
if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
|
|
220
|
+
return "max_per_month";
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
170
225
|
// 根据productIds去重
|
|
171
226
|
uniqueByProductId(discountList) {
|
|
172
227
|
return (0, import_utils.uniqueById)(discountList, "product_id");
|
|
@@ -63,6 +63,11 @@ interface UsageCreditsValue {
|
|
|
63
63
|
max_per_week: number;
|
|
64
64
|
max_per_month: number;
|
|
65
65
|
}
|
|
66
|
+
export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
67
|
+
export interface DiscountWithReason {
|
|
68
|
+
discountList: Discount[];
|
|
69
|
+
unavailableReasonKey: DiscountFilterRejectKey | null;
|
|
70
|
+
}
|
|
66
71
|
interface ExtensionData {
|
|
67
72
|
id: number;
|
|
68
73
|
shop_id: number;
|
|
@@ -135,7 +140,6 @@ export interface Discount {
|
|
|
135
140
|
appliedProductDetails: ApplicableProductDetails[];
|
|
136
141
|
isDisabledForProductUsed?: boolean;
|
|
137
142
|
amount?: number;
|
|
138
|
-
customer_id?: number | string | null;
|
|
139
143
|
extension_data?: ExtensionData[];
|
|
140
144
|
total_order_behavior_count?: number;
|
|
141
145
|
today_order_behavior_count?: number;
|
|
@@ -148,6 +152,8 @@ export interface Discount {
|
|
|
148
152
|
num?: number;
|
|
149
153
|
start_date?: string;
|
|
150
154
|
start_time?: string;
|
|
155
|
+
usageLimitFailKey?: string | null;
|
|
156
|
+
unified_available_status?: number | undefined | null;
|
|
151
157
|
}
|
|
152
158
|
export interface DiscountState {
|
|
153
159
|
discountList: Discount[];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams,
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, UpdateProductInOrderParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView
|
|
6
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView } from './types';
|
|
7
7
|
import type { ICustomer } from '../AccountList/types';
|
|
8
8
|
import type { Discount } from '../Discount/types';
|
|
9
|
+
import { UnavailableReason } from '../Rules/types';
|
|
9
10
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
10
11
|
protected defaultName: string;
|
|
11
12
|
protected defaultVersion: string;
|
|
@@ -24,7 +25,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
24
25
|
* Only selected discounts get a non-zero value.
|
|
25
26
|
*/
|
|
26
27
|
static populateSavedAmounts(productList: Array<Record<string, any>>, discountList: Array<Record<string, any>>): void;
|
|
27
|
-
private applyProductDiscountPrices;
|
|
28
28
|
constructor(name?: string, version?: string);
|
|
29
29
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
30
30
|
/**
|
|
@@ -43,22 +43,23 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
43
43
|
private createDefaultRulesHooks;
|
|
44
44
|
loadDiscountConfig(params: {
|
|
45
45
|
customerId: number;
|
|
46
|
-
action?: 'create'
|
|
47
|
-
|
|
48
|
-
apply?: boolean;
|
|
49
|
-
}): Promise<Discount[]>;
|
|
46
|
+
action?: 'create';
|
|
47
|
+
}): Promise<void>;
|
|
50
48
|
getDiscountList(): Discount[];
|
|
51
|
-
scanCode(code: string, customerId?: number): Promise<
|
|
49
|
+
scanCode(code: string, customerId?: number): Promise<{
|
|
50
|
+
isAvailable: boolean;
|
|
51
|
+
discountList: Discount[];
|
|
52
|
+
type: 'server' | 'clientCalc';
|
|
53
|
+
unavailableReason?: UnavailableReason;
|
|
54
|
+
unavailableReasonKey?: string | null;
|
|
55
|
+
}>;
|
|
52
56
|
applyDiscount(): void;
|
|
53
57
|
initTempOrder(params: {
|
|
54
58
|
cacheId?: string;
|
|
55
59
|
salesSummaryModuleName?: string;
|
|
56
60
|
}): void;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
60
|
-
isTempOrderPersistEnabled(): boolean;
|
|
61
|
-
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
|
|
61
|
+
private getTempOrderStorageKey;
|
|
62
|
+
private restoreTempOrderFromStorage;
|
|
62
63
|
persistTempOrder(): void;
|
|
63
64
|
private createDefaultTempOrderInstance;
|
|
64
65
|
private createExternalSaleNumber;
|
|
@@ -70,7 +71,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
70
71
|
getLocalOrderByOrderNumber(orderNumber: string): Promise<Record<string, any> | null>;
|
|
71
72
|
getLocalOrderByExternalSaleNumber(externalSaleNumber: string): Promise<Record<string, any> | null>;
|
|
72
73
|
saveDraft(): Promise<void>;
|
|
73
|
-
private saveDraftInBackground;
|
|
74
74
|
private hydrateTempOrderFromLocalRecord;
|
|
75
75
|
private extractOrderIdFromSubmitResult;
|
|
76
76
|
private calculatePaymentTotal;
|
|
@@ -80,7 +80,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
80
80
|
ensureTempOrder(): OrderTempOrder;
|
|
81
81
|
restoreOrder(): OrderTempOrder;
|
|
82
82
|
getTempOrder(): OrderTempOrder | null;
|
|
83
|
-
replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
|
|
84
83
|
getOrderIdentity(): OrderIdentitySnapshot | null;
|
|
85
84
|
getOrderSyncState(): OrderSyncState;
|
|
86
85
|
getOrderAmountSnapshot(): OrderAmountSnapshot | null;
|
|
@@ -91,27 +90,20 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
91
90
|
private ensureExtend;
|
|
92
91
|
private captureProductRuntime;
|
|
93
92
|
private createLinkedProductAndBooking;
|
|
94
|
-
private getBookingUniqueIdentificationNumber;
|
|
95
|
-
private findBookingIndexByUniqueIdentificationNumber;
|
|
96
|
-
private removeLinkedBookingsForProduct;
|
|
97
93
|
private getSalesSummary;
|
|
98
94
|
recalculateSummary(options?: {
|
|
99
95
|
createIfMissing?: boolean;
|
|
100
96
|
}): Promise<OrderSummary | null>;
|
|
101
97
|
getOrderSummary(): Promise<OrderSummary>;
|
|
102
98
|
updateTempOrderNote(note: string): string;
|
|
103
|
-
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
104
|
-
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
105
|
-
syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
|
|
106
99
|
getTempOrderNote(): string;
|
|
107
100
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
108
101
|
updateTempOrderBuzzer(buzzer: string): string;
|
|
109
102
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
110
|
-
private buildTempOrderCustomer;
|
|
111
103
|
/**
|
|
112
104
|
* 更新当前 tempOrder 的客户协议字段。
|
|
113
105
|
*
|
|
114
|
-
* PaymentModal
|
|
106
|
+
* PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
|
|
115
107
|
* 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
|
|
116
108
|
*/
|
|
117
109
|
updateTempOrderCustomer(customer: UpdateTempOrderCustomerInput): OrderSnapshot['customer'];
|
|
@@ -156,15 +148,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
156
148
|
private shouldMergeProductToOrder;
|
|
157
149
|
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
|
|
158
150
|
private hasGoodPassDiscount;
|
|
159
|
-
|
|
160
|
-
updateOrderProductQuantity(params: UpdateOrderProductQuantityParams): Promise<OrderProduct[]>;
|
|
161
|
-
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
151
|
+
updateProductInOrder(params: UpdateProductInOrderParams): Promise<OrderProduct[]>;
|
|
162
152
|
removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
|
|
163
|
-
/**
|
|
164
|
-
* 仅清空购物车行(products / bookings),不重置整单。
|
|
165
|
-
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
166
|
-
*/
|
|
167
|
-
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
168
153
|
/**
|
|
169
154
|
* 提交当前 Sales tempOrder。
|
|
170
155
|
*
|
|
@@ -236,9 +221,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
236
221
|
hydrateTempOrderFromRecord(record: Record<string, any>, options?: {
|
|
237
222
|
recalcOnHydrate?: boolean;
|
|
238
223
|
}): Promise<OrderTempOrder>;
|
|
239
|
-
private normalizeTempOrderForRuntime;
|
|
240
224
|
private normalizeHydratedOrderProduct;
|
|
241
225
|
getLastOrderInfo(): Record<string, any> | undefined;
|
|
242
226
|
getOrderInfo(order_id: number): Promise<any>;
|
|
243
227
|
}
|
|
244
|
-
export type {
|
|
228
|
+
export type { UpdateProductInOrderParams } from './types';
|