@pisell/pisellos 2.1.52 → 2.1.54
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +3 -0
- package/dist/model/strategy/adapter/index.js +4 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/dist/model/strategy/adapter/walletPass/evaluator.js +496 -0
- package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/dist/model/strategy/adapter/walletPass/example.js +258 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/index.js +182 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/locales.js +23 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +163 -0
- package/dist/model/strategy/adapter/walletPass/type.js +1 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/adapter/walletPass/utils.js +965 -0
- package/dist/model/strategy/index.d.ts +94 -0
- package/dist/model/strategy/index.js +551 -0
- package/dist/model/strategy/strategy-example.d.ts +5 -0
- package/dist/model/strategy/strategy-example.js +331 -0
- package/dist/model/strategy/type.d.ts +228 -0
- package/dist/model/strategy/type.js +94 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +11 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Discount/types.d.ts +15 -0
- package/dist/modules/Payment/index.d.ts +2 -1
- package/dist/modules/Payment/index.js +10 -7
- package/dist/modules/Payment/utils.js +3 -0
- package/dist/modules/Payment/walletpass.d.ts +23 -0
- package/dist/modules/Payment/walletpass.js +191 -95
- package/dist/modules/Rules/index.d.ts +15 -3
- package/dist/modules/Rules/index.js +194 -28
- package/dist/modules/Rules/types.d.ts +5 -0
- package/dist/modules/Summary/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +6 -0
- package/dist/modules/Summary/utils.js +21 -0
- package/dist/plugins/window.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/utils/capacity.js +1 -2
- package/dist/solution/Checkout/index.js +2 -0
- package/dist/solution/ShopDiscount/index.d.ts +4 -0
- package/dist/solution/ShopDiscount/index.js +26 -5
- package/dist/solution/ShopDiscount/types.d.ts +6 -0
- package/dist/solution/ShopDiscount/utils.js +26 -11
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/model/index.d.ts +1 -0
- package/lib/model/index.js +23 -0
- package/lib/model/strategy/adapter/index.d.ts +3 -0
- package/lib/model/strategy/adapter/index.js +45 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +420 -0
- package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
- package/lib/model/strategy/adapter/walletPass/example.js +207 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/index.js +142 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/locales.js +51 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +163 -0
- package/lib/model/strategy/adapter/walletPass/type.js +17 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +660 -0
- package/lib/model/strategy/index.d.ts +94 -0
- package/lib/model/strategy/index.js +413 -0
- package/lib/model/strategy/strategy-example.d.ts +5 -0
- package/lib/model/strategy/strategy-example.js +318 -0
- package/lib/model/strategy/type.d.ts +228 -0
- package/lib/model/strategy/type.js +44 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +9 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +1 -1
- package/lib/modules/Discount/types.d.ts +15 -0
- package/lib/modules/Payment/index.d.ts +2 -1
- package/lib/modules/Payment/index.js +1 -0
- package/lib/modules/Payment/utils.js +3 -0
- package/lib/modules/Payment/walletpass.d.ts +23 -0
- package/lib/modules/Payment/walletpass.js +94 -17
- package/lib/modules/Rules/index.d.ts +15 -3
- package/lib/modules/Rules/index.js +409 -195
- package/lib/modules/Rules/types.d.ts +5 -0
- package/lib/modules/Summary/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +6 -0
- package/lib/modules/Summary/utils.js +15 -0
- package/lib/plugins/window.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -2
- package/lib/solution/Checkout/index.js +2 -0
- package/lib/solution/ShopDiscount/index.d.ts +4 -0
- package/lib/solution/ShopDiscount/index.js +18 -4
- package/lib/solution/ShopDiscount/types.d.ts +6 -0
- package/lib/solution/ShopDiscount/utils.js +10 -6
- package/package.json +1 -1
|
@@ -25,6 +25,9 @@ __export(utils_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(utils_exports);
|
|
27
27
|
var getAvailableMaxAmount = (data) => {
|
|
28
|
+
if (typeof data._available_max_amount === "number") {
|
|
29
|
+
return data._available_max_amount;
|
|
30
|
+
}
|
|
28
31
|
return data.tag !== "point_card" ? data.available_max_amount : data == null ? void 0 : data.recommended_usage_amount;
|
|
29
32
|
};
|
|
30
33
|
var formatWalletPassList2PreparePayments = (list) => {
|
|
@@ -9,6 +9,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
9
9
|
private userIdentificationCodes;
|
|
10
10
|
private searchResults;
|
|
11
11
|
private walletParams;
|
|
12
|
+
private walletInitData;
|
|
12
13
|
constructor(paymentModule: PaymentModule);
|
|
13
14
|
/**
|
|
14
15
|
* 发送事件的辅助方法
|
|
@@ -37,7 +38,14 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
37
38
|
initializeWalletDataFromBusinessAsync(businessData: WalletInitBusinessData): Promise<{
|
|
38
39
|
walletRecommendList: WalletRecommendItem[];
|
|
39
40
|
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
41
|
+
transformList: any[];
|
|
42
|
+
noApplicableVoucher: any[];
|
|
43
|
+
products: any[];
|
|
40
44
|
}>;
|
|
45
|
+
/**
|
|
46
|
+
* 获取订单基础详情
|
|
47
|
+
*/
|
|
48
|
+
getOrderBasicDetailAsync(orderId: string): Promise<any>;
|
|
41
49
|
/**
|
|
42
50
|
* 初始化钱包数据
|
|
43
51
|
* 先获取推荐列表,再获取用户识别码列表(顺序执行)
|
|
@@ -45,6 +53,9 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
45
53
|
initializeWalletDataAsync(baseParams: WalletDeductionRecommendParams): Promise<{
|
|
46
54
|
walletRecommendList: WalletRecommendItem[];
|
|
47
55
|
userIdentificationCodes: UserIdentificationCodeItem[];
|
|
56
|
+
transformList: any[];
|
|
57
|
+
noApplicableVoucher: any[];
|
|
58
|
+
products: any[];
|
|
48
59
|
}>;
|
|
49
60
|
getWalletPassRecommendListAsync(params: WalletDeductionRecommendParams): Promise<WalletRecommendItem[]>;
|
|
50
61
|
formatWalletPassList2PreparePayments(list: WalletRecommendItem[]): {
|
|
@@ -92,6 +103,18 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
|
|
|
92
103
|
* 清除搜索结果缓存
|
|
93
104
|
*/
|
|
94
105
|
clearSearchResults(): void;
|
|
106
|
+
/**
|
|
107
|
+
* 获取存储的钱包初始化数据
|
|
108
|
+
*/
|
|
109
|
+
getStoredWalletInitData(): {
|
|
110
|
+
transformList: any[];
|
|
111
|
+
noApplicableVoucher: any[];
|
|
112
|
+
products: any[];
|
|
113
|
+
} | null;
|
|
114
|
+
/**
|
|
115
|
+
* 清除存储的钱包初始化数据
|
|
116
|
+
*/
|
|
117
|
+
clearStoredWalletInitData(): void;
|
|
95
118
|
/**
|
|
96
119
|
* 清除所有缓存数据
|
|
97
120
|
*/
|
|
@@ -31,6 +31,7 @@ var WalletPassPaymentImpl = class {
|
|
|
31
31
|
this.userIdentificationCodes = [];
|
|
32
32
|
this.searchResults = [];
|
|
33
33
|
this.walletParams = null;
|
|
34
|
+
this.walletInitData = null;
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* 发送事件的辅助方法
|
|
@@ -42,7 +43,9 @@ var WalletPassPaymentImpl = class {
|
|
|
42
43
|
const fullEventName = `${this.paymentModule.name}:${eventName}`;
|
|
43
44
|
this.paymentModule.core.effects.emit(fullEventName, data);
|
|
44
45
|
} catch (error) {
|
|
45
|
-
this.paymentModule.logError("[WalletPass] 发送事件失败", error, {
|
|
46
|
+
this.paymentModule.logError("[WalletPass] 发送事件失败", error, {
|
|
47
|
+
hook
|
|
48
|
+
});
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
@@ -112,7 +115,10 @@ var WalletPassPaymentImpl = class {
|
|
|
112
115
|
if (Number(((_a = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _a.totalAmount) || 0) < 0 || Number(((_b = businessData == null ? void 0 : businessData.amountInfo) == null ? void 0 : _b.subTotal) || 0) < 0) {
|
|
113
116
|
return {
|
|
114
117
|
walletRecommendList: [],
|
|
115
|
-
userIdentificationCodes: []
|
|
118
|
+
userIdentificationCodes: [],
|
|
119
|
+
transformList: [],
|
|
120
|
+
noApplicableVoucher: [],
|
|
121
|
+
products: []
|
|
116
122
|
};
|
|
117
123
|
}
|
|
118
124
|
this.emitEvent(import_types.WalletPassHooks.OnWalletInitializationStarted, {
|
|
@@ -153,11 +159,28 @@ var WalletPassPaymentImpl = class {
|
|
|
153
159
|
endTime,
|
|
154
160
|
duration
|
|
155
161
|
});
|
|
156
|
-
this.paymentModule.logError(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
this.paymentModule.logError(
|
|
163
|
+
`[WalletPass] 从业务数据初始化钱包数据失败`,
|
|
164
|
+
error,
|
|
165
|
+
{
|
|
166
|
+
duration: `${duration}ms`,
|
|
167
|
+
customer_id: businessData.customer_id,
|
|
168
|
+
totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* 获取订单基础详情
|
|
176
|
+
*/
|
|
177
|
+
async getOrderBasicDetailAsync(orderId) {
|
|
178
|
+
try {
|
|
179
|
+
const response = await this.paymentModule.request.get(
|
|
180
|
+
`/order/order/${orderId}/basic-detail`
|
|
181
|
+
);
|
|
182
|
+
return (response == null ? void 0 : response.data) || {};
|
|
183
|
+
} catch (error) {
|
|
161
184
|
throw error;
|
|
162
185
|
}
|
|
163
186
|
}
|
|
@@ -166,19 +189,49 @@ var WalletPassPaymentImpl = class {
|
|
|
166
189
|
* 先获取推荐列表,再获取用户识别码列表(顺序执行)
|
|
167
190
|
*/
|
|
168
191
|
async initializeWalletDataAsync(baseParams) {
|
|
192
|
+
var _a, _b;
|
|
169
193
|
try {
|
|
170
|
-
const walletRecommendList = await this.getWalletPassRecommendListAsync(baseParams);
|
|
171
194
|
const identificationParams = {
|
|
172
195
|
...baseParams,
|
|
173
196
|
available: 2,
|
|
174
|
-
prepare_payments:
|
|
197
|
+
prepare_payments: [],
|
|
175
198
|
other_exact_codes: [],
|
|
176
199
|
filter_prepare_wallet_pass: 1
|
|
177
200
|
};
|
|
178
|
-
const
|
|
201
|
+
const [allList, orderBasicDetail] = await Promise.all([
|
|
202
|
+
this.getUserIdentificationCodeListAsync(identificationParams),
|
|
203
|
+
baseParams.payment_order_id ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
|
|
204
|
+
]);
|
|
205
|
+
const walletPassEvaluator = (_b = (_a = this.paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
|
|
206
|
+
if (!walletPassEvaluator) {
|
|
207
|
+
return {
|
|
208
|
+
walletRecommendList: [],
|
|
209
|
+
userIdentificationCodes: [],
|
|
210
|
+
transformList: [],
|
|
211
|
+
noApplicableVoucher: [],
|
|
212
|
+
products: []
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const products = (orderBasicDetail == null ? void 0 : orderBasicDetail.detail) || baseParams.products;
|
|
216
|
+
const res = walletPassEvaluator == null ? void 0 : walletPassEvaluator.getRecommendedVouchers({
|
|
217
|
+
orderTotalAmount: baseParams.order_wait_pay_amount,
|
|
218
|
+
products,
|
|
219
|
+
vouchers: allList
|
|
220
|
+
});
|
|
221
|
+
const { recommended, transformList, noApplicableVoucher, recommendedAmount } = res;
|
|
222
|
+
console.log(res, "resres12");
|
|
223
|
+
this.walletRecommendList = recommended;
|
|
224
|
+
this.walletInitData = {
|
|
225
|
+
transformList,
|
|
226
|
+
noApplicableVoucher,
|
|
227
|
+
products: products || []
|
|
228
|
+
};
|
|
179
229
|
return {
|
|
180
|
-
walletRecommendList,
|
|
181
|
-
userIdentificationCodes
|
|
230
|
+
walletRecommendList: recommended,
|
|
231
|
+
userIdentificationCodes: allList,
|
|
232
|
+
transformList,
|
|
233
|
+
noApplicableVoucher,
|
|
234
|
+
products: products || []
|
|
182
235
|
};
|
|
183
236
|
} catch (error) {
|
|
184
237
|
this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
|
|
@@ -261,10 +314,14 @@ var WalletPassPaymentImpl = class {
|
|
|
261
314
|
});
|
|
262
315
|
return this.userIdentificationCodes;
|
|
263
316
|
} catch (error) {
|
|
264
|
-
this.paymentModule.logError(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
317
|
+
this.paymentModule.logError(
|
|
318
|
+
"[WalletPass] 获取用户识别码列表失败",
|
|
319
|
+
error,
|
|
320
|
+
{
|
|
321
|
+
customer_id: params.customer_id,
|
|
322
|
+
available: params.available
|
|
323
|
+
}
|
|
324
|
+
);
|
|
268
325
|
return [];
|
|
269
326
|
}
|
|
270
327
|
}
|
|
@@ -462,6 +519,19 @@ var WalletPassPaymentImpl = class {
|
|
|
462
519
|
this.searchResults = [];
|
|
463
520
|
this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
|
|
464
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* 获取存储的钱包初始化数据
|
|
524
|
+
*/
|
|
525
|
+
getStoredWalletInitData() {
|
|
526
|
+
return this.walletInitData;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* 清除存储的钱包初始化数据
|
|
530
|
+
*/
|
|
531
|
+
clearStoredWalletInitData() {
|
|
532
|
+
this.walletInitData = null;
|
|
533
|
+
this.paymentModule.logInfo("[WalletPass] 钱包初始化数据已清除");
|
|
534
|
+
}
|
|
465
535
|
/**
|
|
466
536
|
* 清除所有缓存数据
|
|
467
537
|
*/
|
|
@@ -470,11 +540,18 @@ var WalletPassPaymentImpl = class {
|
|
|
470
540
|
this.userIdentificationCodes = [];
|
|
471
541
|
this.searchResults = [];
|
|
472
542
|
this.walletParams = null;
|
|
543
|
+
this.walletInitData = null;
|
|
473
544
|
this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
|
|
474
545
|
clearedTypes: ["all"]
|
|
475
546
|
});
|
|
476
547
|
this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
|
|
477
|
-
cleared_types: [
|
|
548
|
+
cleared_types: [
|
|
549
|
+
"walletRecommendList",
|
|
550
|
+
"userIdentificationCodes",
|
|
551
|
+
"searchResults",
|
|
552
|
+
"walletParams",
|
|
553
|
+
"walletInitData"
|
|
554
|
+
]
|
|
478
555
|
});
|
|
479
556
|
}
|
|
480
557
|
};
|
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
4
|
-
import { Discount } from
|
|
4
|
+
import { Discount } from '../Discount/types';
|
|
5
5
|
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
|
+
import { WindowPlugin } from '../../plugins';
|
|
6
7
|
export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
|
|
7
8
|
protected defaultName: string;
|
|
8
9
|
protected defaultVersion: string;
|
|
9
10
|
private store;
|
|
11
|
+
window: WindowPlugin;
|
|
10
12
|
private hooks;
|
|
11
13
|
constructor(name?: string, version?: string);
|
|
12
14
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
13
15
|
setRulesList(rulesList: Rules[]): Promise<void>;
|
|
14
16
|
getRulesList(): Rules[];
|
|
15
|
-
|
|
17
|
+
getWalletPassEvaluator(): import("../..").WalletPassEvaluator | undefined;
|
|
18
|
+
private checkHolderMatch;
|
|
19
|
+
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, orderTotalAmount, }: {
|
|
16
20
|
oldDiscountList: Discount[];
|
|
17
21
|
newDiscountList: Discount[];
|
|
18
22
|
productList: any[];
|
|
23
|
+
holders: {
|
|
24
|
+
form_record_id: number;
|
|
25
|
+
}[];
|
|
26
|
+
orderTotalAmount: number;
|
|
19
27
|
}): {
|
|
20
28
|
isAvailable: boolean;
|
|
21
29
|
discountList: Discount[];
|
|
22
30
|
productList: any[];
|
|
23
31
|
};
|
|
24
|
-
calcDiscount({ discountList, productList, }: {
|
|
32
|
+
calcDiscount({ discountList, productList, holders, orderTotalAmount }: {
|
|
25
33
|
discountList: Discount[];
|
|
26
34
|
productList: any[];
|
|
35
|
+
holders: {
|
|
36
|
+
form_record_id: number;
|
|
37
|
+
}[];
|
|
38
|
+
orderTotalAmount: number;
|
|
27
39
|
}, options?: {
|
|
28
40
|
isSelected?: boolean;
|
|
29
41
|
discountId?: number;
|