@pisell/pisellos 2.0.16 → 2.0.18
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/Cart/utils.d.ts +0 -5
- package/dist/modules/Cart/utils.js +17 -8
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/Rules/index.d.ts +2 -1
- package/dist/modules/Rules/index.js +7 -5
- package/dist/solution/ShopDiscount/index.js +1 -1
- package/lib/modules/Cart/utils.d.ts +0 -5
- package/lib/modules/Cart/utils.js +17 -7
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/Rules/index.d.ts +2 -1
- package/lib/modules/Rules/index.js +7 -5
- package/lib/solution/ShopDiscount/index.js +1 -1
- package/package.json +1 -1
|
@@ -542,16 +542,18 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
542
542
|
|
|
543
543
|
// 判定商品是否有定金规则
|
|
544
544
|
if ((product === null || product === void 0 || (_product$custom_depos2 = product.custom_deposit_data) === null || _product$custom_depos2 === void 0 ? void 0 : _product$custom_depos2.has_deposit) == 1) {
|
|
545
|
-
var protocols = [];
|
|
546
545
|
var total = new Decimal(0);
|
|
547
546
|
var _ref2 = (product === null || product === void 0 ? void 0 : product.custom_deposit_data) || {},
|
|
548
547
|
deposit_fixed = _ref2.deposit_fixed,
|
|
549
548
|
deposit_percentage = _ref2.deposit_percentage,
|
|
550
|
-
deposit_policy_data = _ref2.deposit_policy_data
|
|
551
|
-
|
|
552
|
-
|
|
549
|
+
deposit_policy_data = _ref2.deposit_policy_data,
|
|
550
|
+
self_deposit_policy_ids = _ref2.self_deposit_policy_ids;
|
|
551
|
+
// 所有协议数据
|
|
552
|
+
var allProtocols = deposit_policy_data || [];
|
|
553
553
|
// 是否存在定金,主商品has_deposit为1,但是自身没有定金设置,需要判定子商品是否存在定金,如果不存在最终判定也是不存在定金
|
|
554
554
|
var productHasDeposit = false;
|
|
555
|
+
// 关联的定金协议id
|
|
556
|
+
var protocolIds = [];
|
|
555
557
|
|
|
556
558
|
// 判断主商品是否有定金规则
|
|
557
559
|
if (typeof deposit_fixed === 'string' && typeof deposit_percentage === 'string') {
|
|
@@ -564,19 +566,22 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
564
566
|
result = _handleProductDeposit.result;
|
|
565
567
|
if (result) {
|
|
566
568
|
total = depositTotal;
|
|
569
|
+
protocolIds.push.apply(protocolIds, _toConsumableArray(self_deposit_policy_ids || []));
|
|
567
570
|
productHasDeposit = true;
|
|
568
571
|
}
|
|
569
572
|
} else {
|
|
570
573
|
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
571
|
-
total = bundle.reduce(function (accumulator,
|
|
574
|
+
total = bundle.reduce(function (accumulator, currBundleProduct) {
|
|
575
|
+
var depositData = currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.custom_deposit_data;
|
|
572
576
|
var _handleProductDeposit2 = handleProductDeposit({
|
|
573
|
-
depositData:
|
|
574
|
-
total:
|
|
575
|
-
num:
|
|
577
|
+
depositData: depositData,
|
|
578
|
+
total: currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.price,
|
|
579
|
+
num: (currBundleProduct === null || currBundleProduct === void 0 ? void 0 : currBundleProduct.num) || 1
|
|
576
580
|
}),
|
|
577
581
|
depositTotal = _handleProductDeposit2.depositTotal,
|
|
578
582
|
result = _handleProductDeposit2.result;
|
|
579
583
|
if (result) {
|
|
584
|
+
protocolIds.push.apply(protocolIds, _toConsumableArray((depositData === null || depositData === void 0 ? void 0 : depositData.self_deposit_policy_ids) || []));
|
|
580
585
|
productHasDeposit = true;
|
|
581
586
|
return accumulator.plus(depositTotal);
|
|
582
587
|
}
|
|
@@ -585,6 +590,10 @@ export var getProductDeposit = function getProductDeposit(params) {
|
|
|
585
590
|
}
|
|
586
591
|
}
|
|
587
592
|
if (productHasDeposit) {
|
|
593
|
+
var ids = new Set(protocolIds);
|
|
594
|
+
var protocols = allProtocols.filter(function (item) {
|
|
595
|
+
return ids.has(item.id);
|
|
596
|
+
});
|
|
588
597
|
return {
|
|
589
598
|
total: total.toNumber(),
|
|
590
599
|
protocols: protocols
|
|
@@ -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>;
|
|
@@ -111,6 +111,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
111
111
|
var result = this.calcDiscount({
|
|
112
112
|
discountList: mergedDiscountList,
|
|
113
113
|
productList: _toConsumableArray(productList)
|
|
114
|
+
}, {
|
|
115
|
+
scan: true
|
|
114
116
|
});
|
|
115
117
|
|
|
116
118
|
// 检查是否有产品使用了新折扣
|
|
@@ -214,7 +216,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
214
216
|
|
|
215
217
|
// 编辑的商品 使用了优惠券不可用
|
|
216
218
|
var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
|
|
217
|
-
return discount.id;
|
|
219
|
+
return discount.id && discount.type === 'good_pass';
|
|
218
220
|
}));
|
|
219
221
|
|
|
220
222
|
// 判断优惠券是否适用于该商品
|
|
@@ -244,7 +246,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
244
246
|
var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5;
|
|
245
247
|
var product = _this3.hooks.getProduct(originProduct);
|
|
246
248
|
if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length && product !== null && product !== void 0 && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.every(function (discount) {
|
|
247
|
-
return discount.id;
|
|
249
|
+
return discount.id && discount.type === 'good_pass';
|
|
248
250
|
})) {
|
|
249
251
|
processedProductsMap.set(product._id, originProduct);
|
|
250
252
|
return;
|
|
@@ -308,7 +310,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
308
310
|
}
|
|
309
311
|
return;
|
|
310
312
|
}
|
|
311
|
-
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined') {
|
|
313
|
+
if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined' && !(options !== null && options !== void 0 && options.scan)) {
|
|
312
314
|
return;
|
|
313
315
|
}
|
|
314
316
|
|
|
@@ -366,7 +368,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
366
368
|
var product = _this3.hooks.getProduct(originProduct);
|
|
367
369
|
var getDefaultProduct = function getDefaultProduct() {
|
|
368
370
|
if (product.isClient) {
|
|
369
|
-
_this3.hooks.setProduct(originProduct, {
|
|
371
|
+
return _this3.hooks.setProduct(originProduct, {
|
|
370
372
|
discount_list: [],
|
|
371
373
|
price: product.price,
|
|
372
374
|
origin_total: getProductOriginTotalPrice({
|
|
@@ -385,7 +387,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
385
387
|
})
|
|
386
388
|
});
|
|
387
389
|
} else {
|
|
388
|
-
_this3.hooks.setProduct(originProduct, {
|
|
390
|
+
return _this3.hooks.setProduct(originProduct, {
|
|
389
391
|
discount_list: [],
|
|
390
392
|
total: product.total,
|
|
391
393
|
origin_total: product.origin_total,
|
|
@@ -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,
|
|
@@ -441,11 +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 || [];
|
|
448
452
|
let productHasDeposit = false;
|
|
453
|
+
const protocolIds = [];
|
|
449
454
|
if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
|
|
450
455
|
const { depositTotal, result } = handleProductDeposit({
|
|
451
456
|
depositData: product == null ? void 0 : product.custom_deposit_data,
|
|
@@ -454,17 +459,20 @@ var getProductDeposit = (params) => {
|
|
|
454
459
|
});
|
|
455
460
|
if (result) {
|
|
456
461
|
total = depositTotal;
|
|
462
|
+
protocolIds.push(...self_deposit_policy_ids || []);
|
|
457
463
|
productHasDeposit = true;
|
|
458
464
|
}
|
|
459
465
|
} else {
|
|
460
466
|
if (bundle == null ? void 0 : bundle.length) {
|
|
461
|
-
total = bundle.reduce((accumulator,
|
|
467
|
+
total = bundle.reduce((accumulator, currBundleProduct) => {
|
|
468
|
+
const depositData = currBundleProduct == null ? void 0 : currBundleProduct.custom_deposit_data;
|
|
462
469
|
const { depositTotal, result } = handleProductDeposit({
|
|
463
|
-
depositData
|
|
464
|
-
total:
|
|
465
|
-
num:
|
|
470
|
+
depositData,
|
|
471
|
+
total: currBundleProduct == null ? void 0 : currBundleProduct.price,
|
|
472
|
+
num: (currBundleProduct == null ? void 0 : currBundleProduct.num) || 1
|
|
466
473
|
});
|
|
467
474
|
if (result) {
|
|
475
|
+
protocolIds.push(...(depositData == null ? void 0 : depositData.self_deposit_policy_ids) || []);
|
|
468
476
|
productHasDeposit = true;
|
|
469
477
|
return accumulator.plus(depositTotal);
|
|
470
478
|
}
|
|
@@ -473,6 +481,8 @@ var getProductDeposit = (params) => {
|
|
|
473
481
|
}
|
|
474
482
|
}
|
|
475
483
|
if (productHasDeposit) {
|
|
484
|
+
const ids = new Set(protocolIds);
|
|
485
|
+
const protocols = allProtocols.filter((item) => ids.has(item.id));
|
|
476
486
|
return { total: total.toNumber(), protocols };
|
|
477
487
|
}
|
|
478
488
|
return null;
|
|
@@ -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,
|
|
@@ -271,7 +271,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
271
271
|
if (item.booking_id) {
|
|
272
272
|
(item.discount_list || []).forEach((discount) => {
|
|
273
273
|
var _a2, _b, _c;
|
|
274
|
-
if (discount.id) {
|
|
274
|
+
if (discount.id && discount.type === "good_pass") {
|
|
275
275
|
editModeDiscountList.push({
|
|
276
276
|
...discount,
|
|
277
277
|
isEditMode: true,
|