@pisell/pisellos 2.2.42 → 2.2.43
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 +497 -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 +165 -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/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 +196 -95
- package/dist/modules/Rules/index.d.ts +8 -3
- package/dist/modules/Rules/index.js +143 -23
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +0 -9
- package/dist/modules/Schedule/index.js +2 -18
- 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/Checkout/index.js +24 -23
- package/dist/solution/RegisterAndLogin/config.js +1 -339
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +13 -3
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- 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 +421 -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 +165 -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/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 +99 -17
- package/lib/modules/Rules/index.d.ts +8 -3
- package/lib/modules/Rules/index.js +352 -187
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +0 -9
- package/lib/modules/Schedule/index.js +0 -11
- 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/Checkout/index.js +3 -3
- package/lib/solution/RegisterAndLogin/config.js +1 -265
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +8 -2
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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
|
/**
|
|
@@ -87,6 +90,11 @@ var WalletPassPaymentImpl = class {
|
|
|
87
90
|
order_wait_pay_amount: walletParams.order_wait_pay_amount,
|
|
88
91
|
products_count: ((_b = walletParams.products) == null ? void 0 : _b.length) || 0
|
|
89
92
|
});
|
|
93
|
+
this.walletInitData = {
|
|
94
|
+
transformList: [],
|
|
95
|
+
noApplicableVoucher: [],
|
|
96
|
+
products: products || []
|
|
97
|
+
};
|
|
90
98
|
return walletParams;
|
|
91
99
|
}
|
|
92
100
|
/**
|
|
@@ -115,7 +123,10 @@ var WalletPassPaymentImpl = class {
|
|
|
115
123
|
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) {
|
|
116
124
|
return {
|
|
117
125
|
walletRecommendList: [],
|
|
118
|
-
userIdentificationCodes: []
|
|
126
|
+
userIdentificationCodes: [],
|
|
127
|
+
transformList: [],
|
|
128
|
+
noApplicableVoucher: [],
|
|
129
|
+
products: []
|
|
119
130
|
};
|
|
120
131
|
}
|
|
121
132
|
if ([1, 0].includes((walletParams == null ? void 0 : walletParams.customer_id) || 0)) {
|
|
@@ -162,11 +173,28 @@ var WalletPassPaymentImpl = class {
|
|
|
162
173
|
endTime,
|
|
163
174
|
duration
|
|
164
175
|
});
|
|
165
|
-
this.paymentModule.logError(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
176
|
+
this.paymentModule.logError(
|
|
177
|
+
`[WalletPass] 从业务数据初始化钱包数据失败`,
|
|
178
|
+
error,
|
|
179
|
+
{
|
|
180
|
+
duration: `${duration}ms`,
|
|
181
|
+
customer_id: businessData.customer_id,
|
|
182
|
+
totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 获取订单基础详情
|
|
190
|
+
*/
|
|
191
|
+
async getOrderBasicDetailAsync(orderId) {
|
|
192
|
+
try {
|
|
193
|
+
const response = await this.paymentModule.request.get(
|
|
194
|
+
`/order/order/${orderId}/basic-detail`
|
|
195
|
+
);
|
|
196
|
+
return (response == null ? void 0 : response.data) || {};
|
|
197
|
+
} catch (error) {
|
|
170
198
|
throw error;
|
|
171
199
|
}
|
|
172
200
|
}
|
|
@@ -175,19 +203,49 @@ var WalletPassPaymentImpl = class {
|
|
|
175
203
|
* 先获取推荐列表,再获取用户识别码列表(顺序执行)
|
|
176
204
|
*/
|
|
177
205
|
async initializeWalletDataAsync(baseParams) {
|
|
206
|
+
var _a, _b;
|
|
178
207
|
try {
|
|
179
|
-
const walletRecommendList = await this.getWalletPassRecommendListAsync(baseParams);
|
|
180
208
|
const identificationParams = {
|
|
181
209
|
...baseParams,
|
|
182
210
|
available: 2,
|
|
183
|
-
prepare_payments:
|
|
211
|
+
prepare_payments: [],
|
|
184
212
|
other_exact_codes: [],
|
|
185
213
|
filter_prepare_wallet_pass: 1
|
|
186
214
|
};
|
|
187
|
-
const
|
|
215
|
+
const [allList, orderBasicDetail] = await Promise.all([
|
|
216
|
+
this.getUserIdentificationCodeListAsync(identificationParams),
|
|
217
|
+
baseParams.payment_order_id ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
|
|
218
|
+
]);
|
|
219
|
+
const walletPassEvaluator = (_b = (_a = this.paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
|
|
220
|
+
if (!walletPassEvaluator) {
|
|
221
|
+
return {
|
|
222
|
+
walletRecommendList: [],
|
|
223
|
+
userIdentificationCodes: [],
|
|
224
|
+
transformList: [],
|
|
225
|
+
noApplicableVoucher: [],
|
|
226
|
+
products: []
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const products = (orderBasicDetail == null ? void 0 : orderBasicDetail.detail) || baseParams.products;
|
|
230
|
+
const res = walletPassEvaluator == null ? void 0 : walletPassEvaluator.getRecommendedVouchers({
|
|
231
|
+
orderTotalAmount: baseParams.order_wait_pay_amount,
|
|
232
|
+
products,
|
|
233
|
+
vouchers: allList
|
|
234
|
+
});
|
|
235
|
+
const { recommended, transformList, noApplicableVoucher, recommendedAmount } = res;
|
|
236
|
+
console.log(res, "resres12");
|
|
237
|
+
this.walletRecommendList = recommended;
|
|
238
|
+
this.walletInitData = {
|
|
239
|
+
transformList,
|
|
240
|
+
noApplicableVoucher,
|
|
241
|
+
products: products || []
|
|
242
|
+
};
|
|
188
243
|
return {
|
|
189
|
-
walletRecommendList,
|
|
190
|
-
userIdentificationCodes
|
|
244
|
+
walletRecommendList: recommended,
|
|
245
|
+
userIdentificationCodes: allList,
|
|
246
|
+
transformList,
|
|
247
|
+
noApplicableVoucher,
|
|
248
|
+
products: products || []
|
|
191
249
|
};
|
|
192
250
|
} catch (error) {
|
|
193
251
|
this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
|
|
@@ -270,10 +328,14 @@ var WalletPassPaymentImpl = class {
|
|
|
270
328
|
});
|
|
271
329
|
return this.userIdentificationCodes;
|
|
272
330
|
} catch (error) {
|
|
273
|
-
this.paymentModule.logError(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
331
|
+
this.paymentModule.logError(
|
|
332
|
+
"[WalletPass] 获取用户识别码列表失败",
|
|
333
|
+
error,
|
|
334
|
+
{
|
|
335
|
+
customer_id: params.customer_id,
|
|
336
|
+
available: params.available
|
|
337
|
+
}
|
|
338
|
+
);
|
|
277
339
|
return [];
|
|
278
340
|
}
|
|
279
341
|
}
|
|
@@ -471,6 +533,19 @@ var WalletPassPaymentImpl = class {
|
|
|
471
533
|
this.searchResults = [];
|
|
472
534
|
this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
|
|
473
535
|
}
|
|
536
|
+
/**
|
|
537
|
+
* 获取存储的钱包初始化数据
|
|
538
|
+
*/
|
|
539
|
+
getStoredWalletInitData() {
|
|
540
|
+
return this.walletInitData;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* 清除存储的钱包初始化数据
|
|
544
|
+
*/
|
|
545
|
+
clearStoredWalletInitData() {
|
|
546
|
+
this.walletInitData = null;
|
|
547
|
+
this.paymentModule.logInfo("[WalletPass] 钱包初始化数据已清除");
|
|
548
|
+
}
|
|
474
549
|
/**
|
|
475
550
|
* 清除所有缓存数据
|
|
476
551
|
*/
|
|
@@ -479,11 +554,18 @@ var WalletPassPaymentImpl = class {
|
|
|
479
554
|
this.userIdentificationCodes = [];
|
|
480
555
|
this.searchResults = [];
|
|
481
556
|
this.walletParams = null;
|
|
557
|
+
this.walletInitData = null;
|
|
482
558
|
this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
|
|
483
559
|
clearedTypes: ["all"]
|
|
484
560
|
});
|
|
485
561
|
this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
|
|
486
|
-
cleared_types: [
|
|
562
|
+
cleared_types: [
|
|
563
|
+
"walletRecommendList",
|
|
564
|
+
"userIdentificationCodes",
|
|
565
|
+
"searchResults",
|
|
566
|
+
"walletParams",
|
|
567
|
+
"walletInitData"
|
|
568
|
+
]
|
|
487
569
|
});
|
|
488
570
|
}
|
|
489
571
|
};
|
|
@@ -1,22 +1,26 @@
|
|
|
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[];
|
|
17
|
+
getWalletPassEvaluator(): import("../..").WalletPassEvaluator | undefined;
|
|
15
18
|
private checkHolderMatch;
|
|
16
|
-
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
|
|
19
|
+
isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, orderTotalAmount, holders, isFormSubject, }: {
|
|
17
20
|
oldDiscountList: Discount[];
|
|
18
21
|
newDiscountList: Discount[];
|
|
19
22
|
productList: any[];
|
|
23
|
+
orderTotalAmount: number;
|
|
20
24
|
holders: {
|
|
21
25
|
form_record_id: number;
|
|
22
26
|
}[];
|
|
@@ -26,13 +30,14 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
26
30
|
discountList: Discount[];
|
|
27
31
|
productList: any[];
|
|
28
32
|
};
|
|
29
|
-
calcDiscount({ discountList, productList, holders, isFormSubject, }: {
|
|
33
|
+
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
30
34
|
discountList: Discount[];
|
|
31
35
|
productList: any[];
|
|
32
36
|
holders: {
|
|
33
37
|
form_record_id: number;
|
|
34
38
|
}[];
|
|
35
39
|
isFormSubject: boolean;
|
|
40
|
+
orderTotalAmount: number;
|
|
36
41
|
}, options?: {
|
|
37
42
|
isSelected?: boolean;
|
|
38
43
|
discountId?: number;
|