@pisell/pisellos 2.0.16 → 2.0.17
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.
|
@@ -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
|
|
@@ -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;
|