@pisell/pisellos 3.0.16 → 3.0.19
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/modules/AccountList/index.d.ts +6 -3
- package/dist/modules/AccountList/index.js +67 -45
- package/dist/modules/Cart/utils.js +29 -12
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Product/types.d.ts +4 -0
- package/dist/modules/Rules/index.d.ts +2 -1
- package/dist/modules/Rules/index.js +7 -5
- package/dist/solution/BookingByStep/index.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +295 -86
- package/dist/solution/BookingByStep/utils/resources.js +18 -12
- package/dist/solution/ShopDiscount/index.js +1 -1
- package/lib/modules/AccountList/index.d.ts +6 -3
- package/lib/modules/AccountList/index.js +32 -9
- package/lib/modules/Cart/utils.js +24 -8
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Product/types.d.ts +4 -0
- package/lib/modules/Rules/index.d.ts +2 -1
- package/lib/modules/Rules/index.js +7 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +283 -82
- package/lib/solution/BookingByStep/utils/resources.js +6 -12
- package/lib/solution/ShopDiscount/index.js +1 -1
- package/package.json +1 -1
|
@@ -245,7 +245,11 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
245
245
|
return item.default_resource.indexOf(d) == -1;
|
|
246
246
|
});
|
|
247
247
|
var optional_resource = item.optional_resource.reduce(function (childAcc, d) {
|
|
248
|
-
|
|
248
|
+
var _resourcesMap$d;
|
|
249
|
+
// 如果其他资源选择过,并且这个资源是单个预约,则不可以选中此资源
|
|
250
|
+
// TODO: 如果容量超了这里怎么处理?
|
|
251
|
+
var isSelectSingleResources = ((_resourcesMap$d = resourcesMap[d]) === null || _resourcesMap$d === void 0 ? void 0 : _resourcesMap$d.resourceType) === 'single' && selectedResources.includes(resourcesMap[d].id);
|
|
252
|
+
if (resourcesMap[d] && !isSelectSingleResources) {
|
|
249
253
|
// 拼装组合资源的数据
|
|
250
254
|
var combiningResources = [];
|
|
251
255
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
@@ -277,7 +281,9 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
277
281
|
return childAcc;
|
|
278
282
|
}, []);
|
|
279
283
|
var default_resource = item.default_resource.reduce(function (childAcc, d) {
|
|
280
|
-
|
|
284
|
+
var _resourcesMap$d2;
|
|
285
|
+
var isSelectSingleResources = ((_resourcesMap$d2 = resourcesMap[d]) === null || _resourcesMap$d2 === void 0 ? void 0 : _resourcesMap$d2.resourceType) === 'single' && selectedResources.includes(resourcesMap[d].id);
|
|
286
|
+
if (resourcesMap[d] && !isSelectSingleResources) {
|
|
281
287
|
// 拼装组合资源的数据
|
|
282
288
|
var combiningResources = [];
|
|
283
289
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
@@ -592,9 +598,9 @@ export var getOthersSelectedResources = function getOthersSelectedResources(cart
|
|
|
592
598
|
return acc;
|
|
593
599
|
}
|
|
594
600
|
acc.push.apply(acc, _toConsumableArray(n.metadata.combined_resource.resource_ids));
|
|
595
|
-
n.metadata.combined_resource.resource_ids.forEach(
|
|
596
|
-
|
|
597
|
-
});
|
|
601
|
+
// n.metadata.combined_resource.resource_ids.forEach((m: number) => {
|
|
602
|
+
// if (resourcesMap[m]) resourcesMap[m].capacity -= d.num || 0;
|
|
603
|
+
// });
|
|
598
604
|
} else {
|
|
599
605
|
// 如果当前选中的不是组合资源,但是是别的组合资源里的子资源,则还需要把别的组合资源也加进来
|
|
600
606
|
// 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
|
|
@@ -602,13 +608,13 @@ export var getOthersSelectedResources = function getOthersSelectedResources(cart
|
|
|
602
608
|
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
603
609
|
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
604
610
|
acc.push(m.id);
|
|
605
|
-
resourcesMap[m.id].capacity -=
|
|
611
|
+
// if (resourcesMap[m.id]) resourcesMap[m.id].capacity -= d.num || 0;
|
|
606
612
|
}
|
|
607
613
|
}
|
|
608
614
|
});
|
|
609
615
|
}
|
|
610
616
|
acc.push(n.id);
|
|
611
|
-
resourcesMap[n.id].capacity -=
|
|
617
|
+
// if (resourcesMap[n.id]) resourcesMap[n.id].capacity -= currentCapacity || 0;
|
|
612
618
|
});
|
|
613
619
|
}
|
|
614
620
|
}
|
|
@@ -639,9 +645,9 @@ export var getOthersCartSelectedResources = function getOthersCartSelectedResour
|
|
|
639
645
|
return acc;
|
|
640
646
|
}
|
|
641
647
|
acc.push.apply(acc, _toConsumableArray(n.metadata.combined_resource.resource_ids));
|
|
642
|
-
n.metadata.combined_resource.resource_ids.forEach(
|
|
643
|
-
|
|
644
|
-
});
|
|
648
|
+
// n.metadata.combined_resource.resource_ids.forEach((m: number) => {
|
|
649
|
+
// resourcesMap[m].capacity -= n.num;
|
|
650
|
+
// });
|
|
645
651
|
} else {
|
|
646
652
|
// 如果当前选中的不是组合资源,但是是别的组合资源里的子资源,则还需要把别的组合资源也加进来
|
|
647
653
|
// 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
|
|
@@ -649,14 +655,14 @@ export var getOthersCartSelectedResources = function getOthersCartSelectedResour
|
|
|
649
655
|
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
650
656
|
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
651
657
|
acc.push(m.id);
|
|
652
|
-
resourcesMap[m.id].capacity -= n.num;
|
|
658
|
+
// resourcesMap[m.id].capacity -= n.num;
|
|
653
659
|
}
|
|
654
660
|
}
|
|
655
661
|
});
|
|
656
662
|
}
|
|
657
663
|
acc.push(n.id);
|
|
658
664
|
// push 完以后,把 resourceMap 的 capacity 减掉当前的商品数量
|
|
659
|
-
resourcesMap[n.id].capacity -=
|
|
665
|
+
// resourcesMap[n.id].capacity -= currentCapacity || 0;
|
|
660
666
|
});
|
|
661
667
|
}
|
|
662
668
|
}
|
|
@@ -434,7 +434,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
434
434
|
productList.forEach(function (item) {
|
|
435
435
|
if (item.booking_id) {
|
|
436
436
|
(item.discount_list || []).forEach(function (discount) {
|
|
437
|
-
if (discount.id) {
|
|
437
|
+
if (discount.id && discount.type === 'good_pass') {
|
|
438
438
|
var _discount$discount, _discount$discount2, _discount$discount3;
|
|
439
439
|
editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
|
|
440
440
|
isEditMode: true,
|
|
@@ -16,6 +16,7 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
16
16
|
* 创建账号并添加到列表中
|
|
17
17
|
* @param account 账号信息
|
|
18
18
|
* @param needEmit 是否需要触发事件
|
|
19
|
+
* @param type 添加类型
|
|
19
20
|
*/
|
|
20
21
|
private createAccountAndAdd;
|
|
21
22
|
addAccount(account: Account): Promise<AccountModule>;
|
|
@@ -30,10 +31,12 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
30
31
|
storeChange(): void;
|
|
31
32
|
/**
|
|
32
33
|
* 批量添加holder类型账号
|
|
33
|
-
* @param holders 账号信息列表
|
|
34
|
-
* @param customerId 账户id
|
|
35
34
|
*/
|
|
36
|
-
addHolderAccounts(
|
|
35
|
+
addHolderAccounts(params: {
|
|
36
|
+
holders: IHolder[];
|
|
37
|
+
customerId: number;
|
|
38
|
+
type?: 'unshift' | 'push';
|
|
39
|
+
}): Promise<AccountModule[]>;
|
|
37
40
|
/**
|
|
38
41
|
* 获取holder类型账户列表
|
|
39
42
|
* @param params
|
|
@@ -69,19 +69,30 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
69
69
|
* 创建账号并添加到列表中
|
|
70
70
|
* @param account 账号信息
|
|
71
71
|
* @param needEmit 是否需要触发事件
|
|
72
|
+
* @param type 添加类型
|
|
72
73
|
*/
|
|
73
|
-
async createAccountAndAdd(account, needEmit = true) {
|
|
74
|
+
async createAccountAndAdd(account, needEmit = true, type) {
|
|
74
75
|
const tempAccountModule = this.store.accounts.find(
|
|
75
76
|
(a) => a.getId() === account.id
|
|
76
77
|
);
|
|
77
78
|
if (tempAccountModule) {
|
|
78
79
|
return tempAccountModule;
|
|
79
80
|
}
|
|
80
|
-
this.store.accountList
|
|
81
|
+
const newAccountList = [...this.store.accountList || []];
|
|
82
|
+
if (type === "unshift") {
|
|
83
|
+
newAccountList.unshift(account);
|
|
84
|
+
} else {
|
|
85
|
+
newAccountList.push(account);
|
|
86
|
+
}
|
|
87
|
+
this.store.accountList = newAccountList;
|
|
81
88
|
const accountModule = new import_Account.AccountModule(`account_${account.id}`);
|
|
82
89
|
this.core.registerModule(accountModule);
|
|
83
90
|
accountModule.setAccountInfo(account);
|
|
84
|
-
|
|
91
|
+
if (type === "unshift") {
|
|
92
|
+
this.store.accounts = [accountModule, ...this.store.accounts || []];
|
|
93
|
+
} else {
|
|
94
|
+
this.store.accounts = [...this.store.accounts || [], accountModule];
|
|
95
|
+
}
|
|
85
96
|
if (needEmit) {
|
|
86
97
|
await this.core.effects.emit(
|
|
87
98
|
import_types.AccountListHooks.OnAccountListUpdate,
|
|
@@ -250,15 +261,22 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
250
261
|
}
|
|
251
262
|
/**
|
|
252
263
|
* 批量添加holder类型账号
|
|
253
|
-
* @param holders 账号信息列表
|
|
254
|
-
* @param customerId 账户id
|
|
255
264
|
*/
|
|
256
|
-
async addHolderAccounts(
|
|
265
|
+
async addHolderAccounts(params) {
|
|
266
|
+
const { holders, customerId, type = "push" } = params;
|
|
257
267
|
const accountModules = [];
|
|
258
268
|
for (const holder of holders) {
|
|
259
269
|
const account = (0, import_utils.createHolderAccount)(holder, customerId);
|
|
260
|
-
const accountModule = await this.createAccountAndAdd(
|
|
261
|
-
|
|
270
|
+
const accountModule = await this.createAccountAndAdd(
|
|
271
|
+
account,
|
|
272
|
+
false,
|
|
273
|
+
type
|
|
274
|
+
);
|
|
275
|
+
if (type === "unshift") {
|
|
276
|
+
accountModules.unshift(accountModule);
|
|
277
|
+
} else {
|
|
278
|
+
accountModules.push(accountModule);
|
|
279
|
+
}
|
|
262
280
|
}
|
|
263
281
|
await this.core.effects.emit(
|
|
264
282
|
import_types.AccountListHooks.OnAccountListUpdate,
|
|
@@ -282,8 +300,13 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
282
300
|
num: num || 100,
|
|
283
301
|
skip: skip || 1
|
|
284
302
|
});
|
|
303
|
+
this.store.accountList = [];
|
|
304
|
+
this.store.accounts = [];
|
|
285
305
|
if ((_b = (_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) == null ? void 0 : _b.length) {
|
|
286
|
-
await this.addHolderAccounts(
|
|
306
|
+
await this.addHolderAccounts({
|
|
307
|
+
holders: res.data.list,
|
|
308
|
+
customerId: customer_id
|
|
309
|
+
});
|
|
287
310
|
}
|
|
288
311
|
} catch (error) {
|
|
289
312
|
console.error(error);
|
|
@@ -441,10 +441,16 @@ var getProductDeposit = (params) => {
|
|
|
441
441
|
const { cartItem, product, bundle, options } = params;
|
|
442
442
|
const num = (params == null ? void 0 : params.num) || 1;
|
|
443
443
|
if (((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) == 1) {
|
|
444
|
-
const protocols = [];
|
|
445
444
|
let total = new import_decimal.default(0);
|
|
446
|
-
const {
|
|
447
|
-
|
|
445
|
+
const {
|
|
446
|
+
deposit_fixed,
|
|
447
|
+
deposit_percentage,
|
|
448
|
+
deposit_policy_data,
|
|
449
|
+
self_deposit_policy_ids
|
|
450
|
+
} = (product == null ? void 0 : product.custom_deposit_data) || {};
|
|
451
|
+
const allProtocols = deposit_policy_data || [];
|
|
452
|
+
let productHasDeposit = false;
|
|
453
|
+
const protocolIds = [];
|
|
448
454
|
if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
|
|
449
455
|
const { depositTotal, result } = handleProductDeposit({
|
|
450
456
|
depositData: product == null ? void 0 : product.custom_deposit_data,
|
|
@@ -453,23 +459,33 @@ var getProductDeposit = (params) => {
|
|
|
453
459
|
});
|
|
454
460
|
if (result) {
|
|
455
461
|
total = depositTotal;
|
|
462
|
+
protocolIds.push(...self_deposit_policy_ids || []);
|
|
463
|
+
productHasDeposit = true;
|
|
456
464
|
}
|
|
457
465
|
} else {
|
|
458
466
|
if (bundle == null ? void 0 : bundle.length) {
|
|
459
|
-
total = bundle.reduce((accumulator,
|
|
467
|
+
total = bundle.reduce((accumulator, currBundleProduct) => {
|
|
468
|
+
const depositData = currBundleProduct == null ? void 0 : currBundleProduct.custom_deposit_data;
|
|
460
469
|
const { depositTotal, result } = handleProductDeposit({
|
|
461
|
-
depositData
|
|
462
|
-
total:
|
|
463
|
-
num:
|
|
470
|
+
depositData,
|
|
471
|
+
total: currBundleProduct == null ? void 0 : currBundleProduct.price,
|
|
472
|
+
num: (currBundleProduct == null ? void 0 : currBundleProduct.num) || 1
|
|
464
473
|
});
|
|
465
474
|
if (result) {
|
|
475
|
+
protocolIds.push(...(depositData == null ? void 0 : depositData.self_deposit_policy_ids) || []);
|
|
476
|
+
productHasDeposit = true;
|
|
466
477
|
return accumulator.plus(depositTotal);
|
|
467
478
|
}
|
|
468
479
|
return accumulator;
|
|
469
480
|
}, new import_decimal.default(0));
|
|
470
481
|
}
|
|
471
482
|
}
|
|
472
|
-
|
|
483
|
+
if (productHasDeposit) {
|
|
484
|
+
const ids = new Set(protocolIds);
|
|
485
|
+
const protocols = allProtocols.filter((item) => ids.has(item.id));
|
|
486
|
+
return { total: total.toNumber(), protocols };
|
|
487
|
+
}
|
|
488
|
+
return null;
|
|
473
489
|
}
|
|
474
490
|
return null;
|
|
475
491
|
};
|
|
@@ -168,6 +168,8 @@ export interface ProductData {
|
|
|
168
168
|
deposit_fixed?: string;
|
|
169
169
|
/** 定金百分比 */
|
|
170
170
|
deposit_percentage?: string;
|
|
171
|
+
/** 关联的定金协议id */
|
|
172
|
+
self_deposit_policy_ids?: number[];
|
|
171
173
|
/** 定金协议数据 */
|
|
172
174
|
deposit_policy_data?: Array<{
|
|
173
175
|
/** 定金协议id */
|
|
@@ -457,4 +459,6 @@ export interface ProductResourceItem {
|
|
|
457
459
|
updated_at: string;
|
|
458
460
|
/** 可用资源列表 */
|
|
459
461
|
renderList?: any[];
|
|
462
|
+
/** 资源类型 */
|
|
463
|
+
type: 'single' | 'multiple' | 'capacity';
|
|
460
464
|
}
|
|
@@ -25,7 +25,8 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
25
25
|
productList: any[];
|
|
26
26
|
}, options?: {
|
|
27
27
|
isSelected?: boolean;
|
|
28
|
-
discountId
|
|
28
|
+
discountId?: number;
|
|
29
|
+
scan?: boolean;
|
|
29
30
|
}): DiscountResult;
|
|
30
31
|
destroy(): Promise<void>;
|
|
31
32
|
clear(): Promise<void>;
|
|
@@ -65,6 +65,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
65
65
|
const result = this.calcDiscount({
|
|
66
66
|
discountList: mergedDiscountList,
|
|
67
67
|
productList: [...productList]
|
|
68
|
+
}, {
|
|
69
|
+
scan: true
|
|
68
70
|
});
|
|
69
71
|
let hasApplicableDiscount = false;
|
|
70
72
|
const newDiscountIds = newDiscountList.map((discount) => discount.id);
|
|
@@ -134,7 +136,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
134
136
|
var _a, _b, _c;
|
|
135
137
|
const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
|
|
136
138
|
const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
|
|
137
|
-
const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id)));
|
|
139
|
+
const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && discount2.type === "good_pass")));
|
|
138
140
|
if (isAvailableProduct && isLimitedProduct) {
|
|
139
141
|
(_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
|
|
140
142
|
const applicableProducts = discountApplicableProducts.get(discount.id) || [];
|
|
@@ -154,7 +156,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
154
156
|
sortedProductList.forEach((originProduct) => {
|
|
155
157
|
var _a, _b, _c;
|
|
156
158
|
const product = this.hooks.getProduct(originProduct);
|
|
157
|
-
if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id))) {
|
|
159
|
+
if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && discount.type === "good_pass"))) {
|
|
158
160
|
processedProductsMap.set(product._id, originProduct);
|
|
159
161
|
return;
|
|
160
162
|
}
|
|
@@ -213,7 +215,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
213
215
|
}
|
|
214
216
|
return;
|
|
215
217
|
}
|
|
216
|
-
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined") {
|
|
218
|
+
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined" && !(options == null ? void 0 : options.scan)) {
|
|
217
219
|
return;
|
|
218
220
|
}
|
|
219
221
|
usedDiscounts.set(selectedDiscount.id, true);
|
|
@@ -268,7 +270,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
268
270
|
const product = this.hooks.getProduct(originProduct);
|
|
269
271
|
const getDefaultProduct = () => {
|
|
270
272
|
if (product.isClient) {
|
|
271
|
-
this.hooks.setProduct(originProduct, {
|
|
273
|
+
return this.hooks.setProduct(originProduct, {
|
|
272
274
|
discount_list: [],
|
|
273
275
|
price: product.price,
|
|
274
276
|
origin_total: (0, import_utils2.getProductOriginTotalPrice)({
|
|
@@ -287,7 +289,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
287
289
|
})
|
|
288
290
|
});
|
|
289
291
|
} else {
|
|
290
|
-
this.hooks.setProduct(originProduct, {
|
|
292
|
+
return this.hooks.setProduct(originProduct, {
|
|
291
293
|
discount_list: [],
|
|
292
294
|
total: product.total,
|
|
293
295
|
origin_total: product.origin_total,
|
|
@@ -147,6 +147,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
147
147
|
checkCartItems(type: ECartItemCheckType): string[];
|
|
148
148
|
destroy(): void;
|
|
149
149
|
getResourcesList(): any[];
|
|
150
|
+
checkResourceListForDate(): boolean;
|
|
150
151
|
getResourcesListByCartItem(id: string | number): {
|
|
151
152
|
id: number | undefined;
|
|
152
153
|
_id: string;
|