@pisell/pisellos 2.2.170 → 2.2.171
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 +15 -27
- package/dist/modules/Order/index.js +322 -695
- package/dist/modules/Order/types.d.ts +14 -49
- package/dist/modules/Order/types.js +0 -2
- package/dist/modules/Order/utils.d.ts +0 -17
- package/dist/modules/Order/utils.js +26 -97
- 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/index.d.ts +0 -1
- package/dist/modules/index.js +1 -2
- package/dist/server/modules/order/utils/filterOrders.js +6 -20
- package/dist/solution/BaseSales/index.d.ts +7 -46
- package/dist/solution/BaseSales/index.js +315 -1009
- package/dist/solution/BaseSales/types.d.ts +1 -53
- 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 -768
- 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 +15 -27
- package/lib/modules/Order/index.js +84 -336
- package/lib/modules/Order/types.d.ts +14 -49
- package/lib/modules/Order/utils.d.ts +0 -17
- package/lib/modules/Order/utils.js +18 -105
- 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/index.d.ts +0 -1
- package/lib/modules/index.js +1 -3
- package/lib/server/modules/order/utils/filterOrders.js +4 -12
- package/lib/solution/BaseSales/index.d.ts +7 -46
- package/lib/solution/BaseSales/index.js +20 -434
- package/lib/solution/BaseSales/types.d.ts +1 -53
- 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 -341
- 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 -159
- 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 -201
- 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;
|
|
@@ -42,12 +43,16 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
42
43
|
private createDefaultRulesHooks;
|
|
43
44
|
loadDiscountConfig(params: {
|
|
44
45
|
customerId: number;
|
|
45
|
-
action?: 'create'
|
|
46
|
-
|
|
47
|
-
apply?: boolean;
|
|
48
|
-
}): Promise<Discount[]>;
|
|
46
|
+
action?: 'create';
|
|
47
|
+
}): Promise<void>;
|
|
49
48
|
getDiscountList(): Discount[];
|
|
50
|
-
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
|
+
}>;
|
|
51
56
|
applyDiscount(): void;
|
|
52
57
|
initTempOrder(params: {
|
|
53
58
|
cacheId?: string;
|
|
@@ -66,7 +71,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
66
71
|
getLocalOrderByOrderNumber(orderNumber: string): Promise<Record<string, any> | null>;
|
|
67
72
|
getLocalOrderByExternalSaleNumber(externalSaleNumber: string): Promise<Record<string, any> | null>;
|
|
68
73
|
saveDraft(): Promise<void>;
|
|
69
|
-
private saveDraftInBackground;
|
|
70
74
|
private hydrateTempOrderFromLocalRecord;
|
|
71
75
|
private extractOrderIdFromSubmitResult;
|
|
72
76
|
private calculatePaymentTotal;
|
|
@@ -76,7 +80,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
76
80
|
ensureTempOrder(): OrderTempOrder;
|
|
77
81
|
restoreOrder(): OrderTempOrder;
|
|
78
82
|
getTempOrder(): OrderTempOrder | null;
|
|
79
|
-
replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
|
|
80
83
|
getOrderIdentity(): OrderIdentitySnapshot | null;
|
|
81
84
|
getOrderSyncState(): OrderSyncState;
|
|
82
85
|
getOrderAmountSnapshot(): OrderAmountSnapshot | null;
|
|
@@ -87,27 +90,20 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
87
90
|
private ensureExtend;
|
|
88
91
|
private captureProductRuntime;
|
|
89
92
|
private createLinkedProductAndBooking;
|
|
90
|
-
private getBookingUniqueIdentificationNumber;
|
|
91
|
-
private findBookingIndexByUniqueIdentificationNumber;
|
|
92
|
-
private removeLinkedBookingsForProduct;
|
|
93
93
|
private getSalesSummary;
|
|
94
94
|
recalculateSummary(options?: {
|
|
95
95
|
createIfMissing?: boolean;
|
|
96
96
|
}): Promise<OrderSummary | null>;
|
|
97
97
|
getOrderSummary(): Promise<OrderSummary>;
|
|
98
98
|
updateTempOrderNote(note: string): string;
|
|
99
|
-
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
100
|
-
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
101
|
-
syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
|
|
102
99
|
getTempOrderNote(): string;
|
|
103
100
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
104
101
|
updateTempOrderBuzzer(buzzer: string): string;
|
|
105
102
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
106
|
-
private buildTempOrderCustomer;
|
|
107
103
|
/**
|
|
108
104
|
* 更新当前 tempOrder 的客户协议字段。
|
|
109
105
|
*
|
|
110
|
-
* PaymentModal
|
|
106
|
+
* PaymentModal 只需要修改订单里的客户字段;如果外部还有客户模块需要同步,
|
|
111
107
|
* 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
|
|
112
108
|
*/
|
|
113
109
|
updateTempOrderCustomer(customer: UpdateTempOrderCustomerInput): OrderSnapshot['customer'];
|
|
@@ -152,15 +148,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
152
148
|
private shouldMergeProductToOrder;
|
|
153
149
|
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
|
|
154
150
|
private hasGoodPassDiscount;
|
|
155
|
-
|
|
156
|
-
updateOrderProductQuantity(params: UpdateOrderProductQuantityParams): Promise<OrderProduct[]>;
|
|
157
|
-
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
151
|
+
updateProductInOrder(params: UpdateProductInOrderParams): Promise<OrderProduct[]>;
|
|
158
152
|
removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
|
|
159
|
-
/**
|
|
160
|
-
* 仅清空购物车行(products / bookings / discount_list),不重置整单。
|
|
161
|
-
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
162
|
-
*/
|
|
163
|
-
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
164
153
|
/**
|
|
165
154
|
* 提交当前 Sales tempOrder。
|
|
166
155
|
*
|
|
@@ -232,9 +221,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
232
221
|
hydrateTempOrderFromRecord(record: Record<string, any>, options?: {
|
|
233
222
|
recalcOnHydrate?: boolean;
|
|
234
223
|
}): Promise<OrderTempOrder>;
|
|
235
|
-
private normalizeTempOrderForRuntime;
|
|
236
224
|
private normalizeHydratedOrderProduct;
|
|
237
225
|
getLastOrderInfo(): Record<string, any> | undefined;
|
|
238
226
|
getOrderInfo(order_id: number): Promise<any>;
|
|
239
227
|
}
|
|
240
|
-
export type {
|
|
228
|
+
export type { UpdateProductInOrderParams } from './types';
|