@pisell/pisellos 2.2.37 → 2.2.39
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 +191 -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/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 +3 -1
- 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 +94 -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/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 -1
- 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
|
/**
|
|
@@ -115,7 +118,10 @@ var WalletPassPaymentImpl = class {
|
|
|
115
118
|
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
119
|
return {
|
|
117
120
|
walletRecommendList: [],
|
|
118
|
-
userIdentificationCodes: []
|
|
121
|
+
userIdentificationCodes: [],
|
|
122
|
+
transformList: [],
|
|
123
|
+
noApplicableVoucher: [],
|
|
124
|
+
products: []
|
|
119
125
|
};
|
|
120
126
|
}
|
|
121
127
|
if ([1, 0].includes((walletParams == null ? void 0 : walletParams.customer_id) || 0)) {
|
|
@@ -162,11 +168,28 @@ var WalletPassPaymentImpl = class {
|
|
|
162
168
|
endTime,
|
|
163
169
|
duration
|
|
164
170
|
});
|
|
165
|
-
this.paymentModule.logError(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
this.paymentModule.logError(
|
|
172
|
+
`[WalletPass] 从业务数据初始化钱包数据失败`,
|
|
173
|
+
error,
|
|
174
|
+
{
|
|
175
|
+
duration: `${duration}ms`,
|
|
176
|
+
customer_id: businessData.customer_id,
|
|
177
|
+
totalAmount: (_h = businessData.amountInfo) == null ? void 0 : _h.totalAmount
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 获取订单基础详情
|
|
185
|
+
*/
|
|
186
|
+
async getOrderBasicDetailAsync(orderId) {
|
|
187
|
+
try {
|
|
188
|
+
const response = await this.paymentModule.request.get(
|
|
189
|
+
`/order/order/${orderId}/basic-detail`
|
|
190
|
+
);
|
|
191
|
+
return (response == null ? void 0 : response.data) || {};
|
|
192
|
+
} catch (error) {
|
|
170
193
|
throw error;
|
|
171
194
|
}
|
|
172
195
|
}
|
|
@@ -175,19 +198,49 @@ var WalletPassPaymentImpl = class {
|
|
|
175
198
|
* 先获取推荐列表,再获取用户识别码列表(顺序执行)
|
|
176
199
|
*/
|
|
177
200
|
async initializeWalletDataAsync(baseParams) {
|
|
201
|
+
var _a, _b;
|
|
178
202
|
try {
|
|
179
|
-
const walletRecommendList = await this.getWalletPassRecommendListAsync(baseParams);
|
|
180
203
|
const identificationParams = {
|
|
181
204
|
...baseParams,
|
|
182
205
|
available: 2,
|
|
183
|
-
prepare_payments:
|
|
206
|
+
prepare_payments: [],
|
|
184
207
|
other_exact_codes: [],
|
|
185
208
|
filter_prepare_wallet_pass: 1
|
|
186
209
|
};
|
|
187
|
-
const
|
|
210
|
+
const [allList, orderBasicDetail] = await Promise.all([
|
|
211
|
+
this.getUserIdentificationCodeListAsync(identificationParams),
|
|
212
|
+
baseParams.payment_order_id ? this.getOrderBasicDetailAsync(baseParams.payment_order_id) : Promise.resolve(null)
|
|
213
|
+
]);
|
|
214
|
+
const walletPassEvaluator = (_b = (_a = this.paymentModule.window) == null ? void 0 : _a.getWalletPassEvaluator) == null ? void 0 : _b.call(_a);
|
|
215
|
+
if (!walletPassEvaluator) {
|
|
216
|
+
return {
|
|
217
|
+
walletRecommendList: [],
|
|
218
|
+
userIdentificationCodes: [],
|
|
219
|
+
transformList: [],
|
|
220
|
+
noApplicableVoucher: [],
|
|
221
|
+
products: []
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const products = (orderBasicDetail == null ? void 0 : orderBasicDetail.detail) || baseParams.products;
|
|
225
|
+
const res = walletPassEvaluator == null ? void 0 : walletPassEvaluator.getRecommendedVouchers({
|
|
226
|
+
orderTotalAmount: baseParams.order_wait_pay_amount,
|
|
227
|
+
products,
|
|
228
|
+
vouchers: allList
|
|
229
|
+
});
|
|
230
|
+
const { recommended, transformList, noApplicableVoucher, recommendedAmount } = res;
|
|
231
|
+
console.log(res, "resres12");
|
|
232
|
+
this.walletRecommendList = recommended;
|
|
233
|
+
this.walletInitData = {
|
|
234
|
+
transformList,
|
|
235
|
+
noApplicableVoucher,
|
|
236
|
+
products: products || []
|
|
237
|
+
};
|
|
188
238
|
return {
|
|
189
|
-
walletRecommendList,
|
|
190
|
-
userIdentificationCodes
|
|
239
|
+
walletRecommendList: recommended,
|
|
240
|
+
userIdentificationCodes: allList,
|
|
241
|
+
transformList,
|
|
242
|
+
noApplicableVoucher,
|
|
243
|
+
products: products || []
|
|
191
244
|
};
|
|
192
245
|
} catch (error) {
|
|
193
246
|
this.paymentModule.logError("[WalletPass] 初始化钱包数据失败", error, {
|
|
@@ -270,10 +323,14 @@ var WalletPassPaymentImpl = class {
|
|
|
270
323
|
});
|
|
271
324
|
return this.userIdentificationCodes;
|
|
272
325
|
} catch (error) {
|
|
273
|
-
this.paymentModule.logError(
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
326
|
+
this.paymentModule.logError(
|
|
327
|
+
"[WalletPass] 获取用户识别码列表失败",
|
|
328
|
+
error,
|
|
329
|
+
{
|
|
330
|
+
customer_id: params.customer_id,
|
|
331
|
+
available: params.available
|
|
332
|
+
}
|
|
333
|
+
);
|
|
277
334
|
return [];
|
|
278
335
|
}
|
|
279
336
|
}
|
|
@@ -471,6 +528,19 @@ var WalletPassPaymentImpl = class {
|
|
|
471
528
|
this.searchResults = [];
|
|
472
529
|
this.paymentModule.logInfo("[WalletPass] 搜索结果缓存已清除");
|
|
473
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* 获取存储的钱包初始化数据
|
|
533
|
+
*/
|
|
534
|
+
getStoredWalletInitData() {
|
|
535
|
+
return this.walletInitData;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* 清除存储的钱包初始化数据
|
|
539
|
+
*/
|
|
540
|
+
clearStoredWalletInitData() {
|
|
541
|
+
this.walletInitData = null;
|
|
542
|
+
this.paymentModule.logInfo("[WalletPass] 钱包初始化数据已清除");
|
|
543
|
+
}
|
|
474
544
|
/**
|
|
475
545
|
* 清除所有缓存数据
|
|
476
546
|
*/
|
|
@@ -479,11 +549,18 @@ var WalletPassPaymentImpl = class {
|
|
|
479
549
|
this.userIdentificationCodes = [];
|
|
480
550
|
this.searchResults = [];
|
|
481
551
|
this.walletParams = null;
|
|
552
|
+
this.walletInitData = null;
|
|
482
553
|
this.emitEvent(import_types.WalletPassHooks.OnWalletCacheCleared, {
|
|
483
554
|
clearedTypes: ["all"]
|
|
484
555
|
});
|
|
485
556
|
this.paymentModule.logInfo("[WalletPass] 所有缓存数据已清除", {
|
|
486
|
-
cleared_types: [
|
|
557
|
+
cleared_types: [
|
|
558
|
+
"walletRecommendList",
|
|
559
|
+
"userIdentificationCodes",
|
|
560
|
+
"searchResults",
|
|
561
|
+
"walletParams",
|
|
562
|
+
"walletInitData"
|
|
563
|
+
]
|
|
487
564
|
});
|
|
488
565
|
}
|
|
489
566
|
};
|
|
@@ -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;
|