@pisell/pisellos 2.1.174 → 2.1.176
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/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/dist/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/dist/modules/Discount/index.d.ts +3 -6
- package/dist/modules/Discount/index.js +23 -125
- package/dist/modules/Discount/types.d.ts +5 -34
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +13 -6
- package/dist/modules/Rules/index.d.ts +2 -12
- package/dist/modules/Rules/index.js +113 -377
- package/dist/modules/Rules/types.d.ts +2 -2
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +7 -5
- package/dist/solution/ScanOrder/index.js +123 -31
- package/dist/solution/ScanOrder/resourceSchedule.d.ts +12 -0
- package/dist/solution/ScanOrder/resourceSchedule.js +300 -0
- package/dist/solution/ScanOrder/types.d.ts +9 -1
- package/dist/solution/ShopDiscount/index.d.ts +0 -3
- package/dist/solution/ShopDiscount/index.js +78 -161
- package/dist/solution/ShopDiscount/utils.d.ts +0 -1
- package/dist/solution/ShopDiscount/utils.js +1 -40
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -2
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -4
- package/lib/modules/Discount/index.d.ts +3 -6
- package/lib/modules/Discount/index.js +16 -66
- package/lib/modules/Discount/types.d.ts +5 -34
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +8 -1
- package/lib/modules/Rules/index.d.ts +2 -12
- package/lib/modules/Rules/index.js +69 -303
- package/lib/modules/Rules/types.d.ts +2 -2
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +7 -5
- package/lib/solution/ScanOrder/index.js +90 -12
- package/lib/solution/ScanOrder/resourceSchedule.d.ts +12 -0
- package/lib/solution/ScanOrder/resourceSchedule.js +272 -0
- package/lib/solution/ScanOrder/types.d.ts +9 -1
- package/lib/solution/ShopDiscount/index.d.ts +0 -3
- package/lib/solution/ShopDiscount/index.js +28 -78
- package/lib/solution/ShopDiscount/utils.d.ts +0 -1
- package/lib/solution/ShopDiscount/utils.js +1 -42
- package/package.json +1 -1
- package/dist/modules/Discount/availability.d.ts +0 -7
- package/dist/modules/Discount/availability.js +0 -52
- package/dist/modules/Discount/entitlementPass.d.ts +0 -34
- package/dist/modules/Discount/entitlementPass.js +0 -147
- package/dist/modules/Discount/entitlementState.d.ts +0 -8
- package/dist/modules/Discount/entitlementState.js +0 -205
- package/dist/modules/Rules/entitlementLines.d.ts +0 -8
- package/dist/modules/Rules/entitlementLines.js +0 -157
- package/lib/modules/Discount/availability.d.ts +0 -7
- package/lib/modules/Discount/availability.js +0 -91
- package/lib/modules/Discount/entitlementPass.d.ts +0 -34
- package/lib/modules/Discount/entitlementPass.js +0 -184
- package/lib/modules/Discount/entitlementState.d.ts +0 -8
- package/lib/modules/Discount/entitlementState.js +0 -206
- package/lib/modules/Rules/entitlementLines.d.ts +0 -8
- package/lib/modules/Rules/entitlementLines.js +0 -158
|
@@ -36,8 +36,6 @@ var import_utils = require("../../solution/ShopDiscount/utils");
|
|
|
36
36
|
var import_BaseModule = require("../BaseModule");
|
|
37
37
|
var import_types = require("./types");
|
|
38
38
|
var import_decimal = __toESM(require("decimal.js"));
|
|
39
|
-
var import_entitlementPass = require("./entitlementPass");
|
|
40
|
-
var import_availability = require("./availability");
|
|
41
39
|
var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
42
40
|
constructor(name, version) {
|
|
43
41
|
super(name, version);
|
|
@@ -94,34 +92,23 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
94
92
|
return this.store.originalDiscountList || [];
|
|
95
93
|
}
|
|
96
94
|
async loadPrepareConfig(params) {
|
|
97
|
-
var _a, _b
|
|
95
|
+
var _a, _b;
|
|
98
96
|
const prepareConfig = await this.request.post(
|
|
99
97
|
`/order/prepare/config`,
|
|
100
98
|
params
|
|
101
99
|
);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
...((_b = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _b.discount_card_list) || []
|
|
106
|
-
].filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item)));
|
|
107
|
-
}
|
|
108
|
-
const entitlementPassList = ((_c = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _c.entitlement_pass_list) || [];
|
|
109
|
-
const ids = new Set(entitlementPassList.map((item) => String(item.id)));
|
|
110
|
-
const rawDiscountList = [
|
|
111
|
-
...entitlementPassList,
|
|
112
|
-
...(((_d = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _d.good_pass_list) || []).filter((item) => !ids.has(String(item.id))),
|
|
113
|
-
...(((_e = prepareConfig == null ? void 0 : prepareConfig.data) == null ? void 0 : _e.discount_card_list) || []).filter((item) => !ids.has(String(item.id)))
|
|
114
|
-
];
|
|
115
|
-
await this.setOriginalDiscountList(rawDiscountList);
|
|
116
|
-
const goodPassList = this.filterEnabledDiscountList(rawDiscountList);
|
|
100
|
+
const goodPassList = this.filterEnabledDiscountList(
|
|
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) || []]
|
|
102
|
+
) || [];
|
|
117
103
|
return goodPassList;
|
|
118
104
|
}
|
|
119
|
-
async batchSearch(code,
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
const params = {
|
|
105
|
+
async batchSearch(code, options) {
|
|
106
|
+
const { customerId, orderId } = options || {};
|
|
107
|
+
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
123
108
|
code,
|
|
124
109
|
translate_flag: 1,
|
|
110
|
+
tags: ["good_pass", "product_discount_card"],
|
|
111
|
+
// available: 1,
|
|
125
112
|
relation_product: 1,
|
|
126
113
|
with: ["extensionData", "customScheduleSnapshot", "holder.detail"],
|
|
127
114
|
order_behavior_count: 1,
|
|
@@ -129,45 +116,9 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
129
116
|
...orderId ? { order_behavior_count_order_id: orderId } : {},
|
|
130
117
|
unified_status_info_flag: 1,
|
|
131
118
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
...params,
|
|
136
|
-
tags: ["good_pass", "product_discount_card"]
|
|
137
|
-
});
|
|
138
|
-
return this.filterEnabledDiscountListWithReason(((result2 == null ? void 0 : result2.data) || []).filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item)));
|
|
139
|
-
}
|
|
140
|
-
const search = (query) => this.request.get(`/machinecode/batch-search`, query).then(
|
|
141
|
-
(value) => ({ status: "fulfilled", value }),
|
|
142
|
-
(reason) => ({ status: "rejected", reason })
|
|
143
|
-
);
|
|
144
|
-
const [legacy, entitlement] = await Promise.all([
|
|
145
|
-
search({
|
|
146
|
-
...params,
|
|
147
|
-
tags: ["good_pass", "product_discount_card"]
|
|
148
|
-
}),
|
|
149
|
-
search({
|
|
150
|
-
...params,
|
|
151
|
-
tags: ["entitlement_pass"],
|
|
152
|
-
with_franchisor_data: 1,
|
|
153
|
-
unified_status_info_flag: 1,
|
|
154
|
-
with: [...params.with, "franchiseeWalletPass:shop_id,source_shop_id,product_id,use"]
|
|
155
|
-
})
|
|
156
|
-
]);
|
|
157
|
-
const entitlementList = (entitlement.status === "fulfilled" ? ((_a = entitlement.value) == null ? void 0 : _a.data) || [] : []).filter(import_entitlementPass.isEntitlementPass);
|
|
158
|
-
const legacyList = legacy.status === "fulfilled" ? ((_b = legacy.value) == null ? void 0 : _b.data) || [] : [];
|
|
159
|
-
const ids = new Set(entitlementList.map((item) => String(item.id)));
|
|
160
|
-
const result = this.filterEnabledDiscountListWithReason([
|
|
161
|
-
...entitlementList,
|
|
162
|
-
...legacyList.filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item) && !ids.has(String(item.id)))
|
|
163
|
-
]);
|
|
164
|
-
if (!result.discountList.length) {
|
|
165
|
-
if (legacy.status === "rejected")
|
|
166
|
-
throw legacy.reason;
|
|
167
|
-
if (entitlement.status === "rejected")
|
|
168
|
-
throw entitlement.reason;
|
|
169
|
-
}
|
|
170
|
-
return result;
|
|
119
|
+
});
|
|
120
|
+
const resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result == null ? void 0 : result.data) || []) || [];
|
|
121
|
+
return resultDiscountWithReason;
|
|
171
122
|
}
|
|
172
123
|
async batchSearchByProductIds(productIds) {
|
|
173
124
|
const result = await this.request.get(`/machinecode/batch-search`, {
|
|
@@ -180,7 +131,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
180
131
|
}
|
|
181
132
|
filterEnabledDiscountList(discountList) {
|
|
182
133
|
return discountList.filter(
|
|
183
|
-
(discount) =>
|
|
134
|
+
(discount) => discount.limit_status === "enable" && 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) && this.checkUsageCreditsLimit(discount)
|
|
184
135
|
);
|
|
185
136
|
}
|
|
186
137
|
// 检查使用次数限制
|
|
@@ -224,8 +175,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
224
175
|
}
|
|
225
176
|
// 过滤启用且可用的优惠券,并返回校验失败原因
|
|
226
177
|
filterEnabledDiscountListWithReason(discountList) {
|
|
227
|
-
|
|
228
|
-
let lists = discountList.filter((item) => !(0, import_entitlementPass.isEntitlementPass)(item)).filter((discount) => discount.limit_status === "enable").filter((discount) => {
|
|
178
|
+
let lists = discountList.filter((discount) => discount.limit_status === "enable").filter((discount) => {
|
|
229
179
|
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);
|
|
230
180
|
return remaining;
|
|
231
181
|
}).map((discount) => {
|
|
@@ -238,8 +188,8 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
|
|
|
238
188
|
const availableLists = lists.filter((item) => !item.usageLimitFailKey && item.unified_available_status !== 0);
|
|
239
189
|
const currentFailDiscount = lists.find((item) => item.usageLimitFailKey);
|
|
240
190
|
return {
|
|
241
|
-
discountList:
|
|
242
|
-
unavailableReasonKey:
|
|
191
|
+
discountList: availableLists,
|
|
192
|
+
unavailableReasonKey: currentFailDiscount == null ? void 0 : currentFailDiscount.usageLimitFailKey
|
|
243
193
|
};
|
|
244
194
|
}
|
|
245
195
|
// 检查使用次数限制,并返回校验失败原因
|
|
@@ -45,8 +45,6 @@ interface ApplicableProductDetails {
|
|
|
45
45
|
num: number;
|
|
46
46
|
metadata?: {
|
|
47
47
|
product_discount_difference?: number;
|
|
48
|
-
num?: number;
|
|
49
|
-
custom_product_bundle_map_id?: string;
|
|
50
48
|
};
|
|
51
49
|
discount?: {
|
|
52
50
|
fixed_amount?: number;
|
|
@@ -65,17 +63,10 @@ interface UsageCreditsValue {
|
|
|
65
63
|
max_per_week: number;
|
|
66
64
|
max_per_month: number;
|
|
67
65
|
}
|
|
68
|
-
export type IncludedUses = {
|
|
69
|
-
type: 'limited';
|
|
70
|
-
value: number;
|
|
71
|
-
} | {
|
|
72
|
-
type: 'unlimited';
|
|
73
|
-
value: null;
|
|
74
|
-
};
|
|
75
66
|
export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
|
|
76
67
|
export interface DiscountWithReason {
|
|
77
68
|
discountList: Discount[];
|
|
78
|
-
unavailableReasonKey: DiscountFilterRejectKey |
|
|
69
|
+
unavailableReasonKey: DiscountFilterRejectKey | null;
|
|
79
70
|
}
|
|
80
71
|
interface ExtensionData {
|
|
81
72
|
id: number;
|
|
@@ -102,39 +93,19 @@ export interface Discount {
|
|
|
102
93
|
used_par_value: string;
|
|
103
94
|
limit_status: string;
|
|
104
95
|
limited_relation_product_data: Limitedrelationproductdata;
|
|
105
|
-
balance
|
|
96
|
+
balance: string;
|
|
106
97
|
format_title: Formattitle;
|
|
107
98
|
metadata?: {
|
|
108
99
|
discount_card_type?: 'fixed_amount' | 'percent';
|
|
109
100
|
custom_product_bundle_map_id?: string;
|
|
110
101
|
validity_type?: "custom_schedule_validity" | "fixed_validity";
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
holder?: {
|
|
102
|
+
discount_calculation_mode: 'item_level' | 'order_level';
|
|
103
|
+
holder: {
|
|
114
104
|
type: "customer" | "custom";
|
|
115
105
|
};
|
|
116
106
|
};
|
|
117
107
|
product: Product;
|
|
118
|
-
type
|
|
119
|
-
shop_id?: number;
|
|
120
|
-
customer_id?: number | string | null;
|
|
121
|
-
holder?: {
|
|
122
|
-
holder_type?: string;
|
|
123
|
-
holder_id?: number | string | Array<number | string>;
|
|
124
|
-
[key: string]: any;
|
|
125
|
-
};
|
|
126
|
-
config?: {
|
|
127
|
-
isAvailable?: boolean;
|
|
128
|
-
maxUsagePerOrder?: number;
|
|
129
|
-
[key: string]: any;
|
|
130
|
-
};
|
|
131
|
-
reason?: string;
|
|
132
|
-
reasonCode?: string;
|
|
133
|
-
is_franchisor_pass?: number;
|
|
134
|
-
franchisee_wallet_pass?: {
|
|
135
|
-
use?: string;
|
|
136
|
-
};
|
|
137
|
-
committedAppliedProductDetails?: ApplicableProductDetails[];
|
|
108
|
+
type: "product" | 'good_pass';
|
|
138
109
|
resource_id?: number;
|
|
139
110
|
savedAmount?: number;
|
|
140
111
|
isEditMode?: boolean;
|
|
@@ -33,6 +33,7 @@ export interface OpenDataConfig {
|
|
|
33
33
|
'sale.sale_number_prefix'?: string | null;
|
|
34
34
|
'sale.enabled_item_rules'?: number[];
|
|
35
35
|
'fulfillment.enable_pickup'?: boolean;
|
|
36
|
+
'fulfillment.handover_mode'?: string[] | null;
|
|
36
37
|
'fulfillment.overdue_reminder'?: boolean;
|
|
37
38
|
'fulfillment.manual_input_type'?: string;
|
|
38
39
|
'fulfillment.enable_auto_complete'?: boolean;
|
|
@@ -70,6 +70,13 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
70
70
|
console.error(error);
|
|
71
71
|
}
|
|
72
72
|
const _platform = (_c = (_b = this.core) == null ? void 0 : _b.context) == null ? void 0 : _c.platform;
|
|
73
|
+
const channelMap = {
|
|
74
|
+
online_store: "online-store",
|
|
75
|
+
scan_to_order: "online-store",
|
|
76
|
+
scan_to_order_2: "online-store",
|
|
77
|
+
scan_to_order_3: "online-store"
|
|
78
|
+
};
|
|
79
|
+
const saleChannel = channelMap[(_d = this.otherParams) == null ? void 0 : _d.channel] || ((_e = this.otherParams) == null ? void 0 : _e.channel);
|
|
73
80
|
const productsData = await this.request.post(
|
|
74
81
|
`/product/query`,
|
|
75
82
|
{
|
|
@@ -96,7 +103,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
96
103
|
with_count,
|
|
97
104
|
// client_schedule_ids: schedule_ids,
|
|
98
105
|
schedule_date,
|
|
99
|
-
application_code: _platform === "shop" ?
|
|
106
|
+
application_code: _platform === "shop" ? saleChannel : "online-store",
|
|
100
107
|
with_schedule,
|
|
101
108
|
schedule_datetime,
|
|
102
109
|
is_eject: 1
|
|
@@ -8,26 +8,17 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
8
8
|
protected defaultVersion: string;
|
|
9
9
|
private store;
|
|
10
10
|
private hooks;
|
|
11
|
-
private entitlementPassEnabled;
|
|
12
|
-
private defaultWalletPassEvaluator?;
|
|
13
|
-
setEntitlementPassEnabled(enabled: boolean): void;
|
|
14
|
-
private getWalletPassEvaluator;
|
|
15
11
|
constructor(name?: string, version?: string);
|
|
16
12
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
17
13
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
18
14
|
getRulesList(): Rules[];
|
|
19
|
-
private normalizeHolderRecordIds;
|
|
20
|
-
/**
|
|
21
|
-
* 商品未开启 Holder 选择时跳过匹配;已开启时,特定 form Holder 卡
|
|
22
|
-
* 只适用于同一 Holder Record,是否必填不影响匹配规则。
|
|
23
|
-
*/
|
|
24
15
|
private checkHolderMatch;
|
|
25
16
|
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
|
|
26
17
|
oldDiscountList: Discount[];
|
|
27
18
|
newDiscountList: Discount[];
|
|
28
19
|
productList: any[];
|
|
29
20
|
holders: {
|
|
30
|
-
form_record_id: number
|
|
21
|
+
form_record_id: number;
|
|
31
22
|
}[];
|
|
32
23
|
isFormSubject: boolean;
|
|
33
24
|
}): {
|
|
@@ -35,7 +26,6 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
35
26
|
discountList: Discount[];
|
|
36
27
|
productList: any[];
|
|
37
28
|
unavailableReason?: UnavailableReason;
|
|
38
|
-
evaluatedDiscountList?: Discount[];
|
|
39
29
|
};
|
|
40
30
|
filterDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
41
31
|
private getUnavailableReason;
|
|
@@ -43,7 +33,7 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
43
33
|
discountList: Discount[];
|
|
44
34
|
productList: any[];
|
|
45
35
|
holders: {
|
|
46
|
-
form_record_id: number
|
|
36
|
+
form_record_id: number;
|
|
47
37
|
}[];
|
|
48
38
|
isFormSubject: boolean;
|
|
49
39
|
}, options?: {
|