@pisell/pisellos 2.1.47 → 2.1.48

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.
@@ -498,15 +498,18 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
498
498
 
499
499
  // 找到适用于此商品的所有优惠券,仅考虑isSelected不为false的优惠券
500
500
  var applicableDiscounts = sortedDiscountList.filter(function (discount) {
501
- var _product$discount_lis3;
501
+ var _product$discount_lis3, _product$discount_lis4;
502
502
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
503
503
  // 商品券时主商品价格为0不可用
504
- if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === 'good_pass') return false;
505
-
506
- // 折扣卡商品价格为0时不可用
507
504
  if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.find(function (n) {
508
505
  var _n$discount;
509
506
  return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
507
+ })) && (discount.tag || discount.type) === 'good_pass') return false;
508
+
509
+ // 折扣卡商品价格为0时不可用
510
+ if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.find(function (n) {
511
+ var _n$discount2;
512
+ return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === discount.id;
510
513
  })) && (discount.tag || discount.type) !== 'good_pass') return false;
511
514
  // 如果优惠券已被使用,则跳过
512
515
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
@@ -546,12 +549,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
546
549
  // 如果是手动折扣,则不适用优惠券
547
550
  var isManualDiscount = false;
548
551
  if (flatItem.type === 'main') {
549
- var _product$discount_lis4, _product7, _product7$every;
552
+ var _product$discount_lis5, _product7, _product7$every;
550
553
  // 主商品:判断自身是否手动折扣
551
554
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
552
555
  var _ref3;
553
556
  return !((_ref3 = item.discount_list || []) !== null && _ref3 !== void 0 && _ref3.length);
554
- }) && (!((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.length) || ((_product7 = product) === null || _product7 === void 0 || (_product7 = _product7.discount_list) === null || _product7 === void 0 || (_product7$every = _product7.every) === null || _product7$every === void 0 ? void 0 : _product7$every.call(_product7, function (item) {
557
+ }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product7 = product) === null || _product7 === void 0 || (_product7 = _product7.discount_list) === null || _product7 === void 0 || (_product7$every = _product7.every) === null || _product7$every === void 0 ? void 0 : _product7$every.call(_product7, function (item) {
555
558
  return item.type === 'product';
556
559
  })));
557
560
  } else {
@@ -570,9 +573,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
570
573
 
571
574
  // 勾选时覆盖手动折扣
572
575
  if (options !== null && options !== void 0 && options.discountId) {
573
- var _product$discount_lis5;
576
+ var _product$discount_lis6;
574
577
  // 主商品:检查自己的 discount_list
575
- if (flatItem.type === 'main' && (_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.some(function (item) {
578
+ if (flatItem.type === 'main' && (_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.some(function (item) {
576
579
  var _item$discount;
577
580
  return ((_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) === options.discountId;
578
581
  })) {
@@ -580,8 +583,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
580
583
  }
581
584
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
582
585
  if (flatItem.type === 'bundle') {
583
- var _product$discount_lis6, _flatItem$parentProdu;
584
- if ((_product$discount_lis6 = product.discount_list) !== null && _product$discount_lis6 !== void 0 && _product$discount_lis6.some(function (item) {
586
+ var _product$discount_lis7, _flatItem$parentProdu;
587
+ if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
585
588
  var _item$discount2;
586
589
  return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
587
590
  }) || (_flatItem$parentProdu = flatItem.parentProduct) !== null && _flatItem$parentProdu !== void 0 && (_flatItem$parentProdu = _flatItem$parentProdu.discount_list) !== null && _flatItem$parentProdu !== void 0 && _flatItem$parentProdu.some(function (item) {
@@ -593,9 +596,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
593
596
  }
594
597
  }
595
598
  if (options !== null && options !== void 0 && options.selectedList) {
596
- var _product$discount_lis7;
599
+ var _product$discount_lis8;
597
600
  // 主商品:检查自己的 discount_list
598
- if (flatItem.type === 'main' && (_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
601
+ if (flatItem.type === 'main' && (_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
599
602
  var _options$selectedList;
600
603
  return options === null || options === void 0 || (_options$selectedList = options.selectedList) === null || _options$selectedList === void 0 ? void 0 : _options$selectedList.some(function (n) {
601
604
  var _item$discount4;
@@ -606,8 +609,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
606
609
  }
607
610
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
608
611
  if (flatItem.type === 'bundle') {
609
- var _product$discount_lis8, _flatItem$parentProdu2;
610
- if ((_product$discount_lis8 = product.discount_list) !== null && _product$discount_lis8 !== void 0 && _product$discount_lis8.some(function (item) {
612
+ var _product$discount_lis9, _flatItem$parentProdu2;
613
+ if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
611
614
  var _options$selectedList2;
612
615
  return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
613
616
  var _item$discount5;
@@ -697,7 +700,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
697
700
  }));
698
701
  }
699
702
  for (var i = 0; i < splitCount; i++) {
700
- var _product$discount_lis9, _originProduct, _selectedDiscount$met;
703
+ var _product$discount_lis10, _originProduct, _selectedDiscount$met;
701
704
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
702
705
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[i];
703
706
  // 标记优惠券为已使用
@@ -709,7 +712,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
709
712
  // 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
710
713
  var productOriginTotal = product.origin_total || product.total || 0;
711
714
  // 如果当前 product 有 discount_list,则先从 origin_total 拿
712
- if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.length && product.origin_total) {
715
+ if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length && product.origin_total) {
713
716
  productOriginTotal = product.origin_total;
714
717
  }
715
718
  // 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
@@ -334,12 +334,15 @@ var RulesModule = class extends import_BaseModule.BaseModule {
334
334
  return;
335
335
  }
336
336
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
337
- var _a2;
338
- if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
339
- return false;
337
+ var _a2, _b2;
340
338
  if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
341
339
  var _a3;
342
340
  return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
341
+ })) && (discount.tag || discount.type) === "good_pass")
342
+ return false;
343
+ if ((Number(product.price) <= 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
344
+ var _a3;
345
+ return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
343
346
  })) && (discount.tag || discount.type) !== "good_pass")
344
347
  return false;
345
348
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.47",
4
+ "version": "2.1.48",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",