@pisell/pisellos 0.0.450 → 0.0.452

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.
Files changed (29) hide show
  1. package/dist/model/strategy/adapter/walletPass/evaluator.js +5 -5
  2. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  3. package/dist/model/strategy/adapter/walletPass/type.d.ts +3 -0
  4. package/dist/model/strategy/adapter/walletPass/utils.d.ts +30 -4
  5. package/dist/model/strategy/adapter/walletPass/utils.js +96 -18
  6. package/dist/modules/Discount/index.d.ts +1 -0
  7. package/dist/modules/Discount/index.js +40 -11
  8. package/dist/modules/Discount/types.d.ts +1 -0
  9. package/dist/modules/Product/index.d.ts +1 -1
  10. package/dist/modules/Rules/index.js +18 -11
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.d.ts +1 -1
  13. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  14. package/dist/solution/ShopDiscount/index.js +123 -85
  15. package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -2
  16. package/lib/model/strategy/adapter/walletPass/index.js +2 -2
  17. package/lib/model/strategy/adapter/walletPass/type.d.ts +3 -0
  18. package/lib/model/strategy/adapter/walletPass/utils.d.ts +30 -4
  19. package/lib/model/strategy/adapter/walletPass/utils.js +55 -11
  20. package/lib/modules/Discount/index.d.ts +1 -0
  21. package/lib/modules/Discount/index.js +9 -0
  22. package/lib/modules/Discount/types.d.ts +1 -0
  23. package/lib/modules/Product/index.d.ts +1 -1
  24. package/lib/modules/Rules/index.js +10 -5
  25. package/lib/solution/BookingByStep/index.d.ts +1 -1
  26. package/lib/solution/BookingTicket/index.d.ts +1 -1
  27. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  28. package/lib/solution/ShopDiscount/index.js +14 -0
  29. package/package.json +1 -1
@@ -11,7 +11,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
13
  import { StrategyEngine } from "../../index";
14
- import { processVouchers as _processVouchers, recalculateVouchers as _recalculateVouchers, getApplicableProductIds, getMainProductPrice, getBundleItemPrice, getProductQuantity, getBundleItemIsOriginalPrice } from "./utils";
14
+ import { processVouchers as _processVouchers, recalculateVouchers as _recalculateVouchers, getApplicableProductIds, getMainProductPrice, getBundleItemPrice, getProductQuantity, getBundleItemIsOriginalPrice, getTaxAndFeeRoundingRemainder, getBundleItemTaxAndFeeRoundingRemainder, getProductDiscountDifference, getBundleItemDiscountDifference } from "./utils";
15
15
  import { locales } from "./locales";
16
16
  import Decimal from 'decimal.js';
17
17
  var defaultStrategyMetadataCustom = {
@@ -465,8 +465,8 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
465
465
  // 检查主商品是否适用
466
466
  var isMainProductApplicable = applicableProductIds === null || applicableProductIds.includes(product.product_id);
467
467
  if (isMainProductApplicable) {
468
- // 计算主商品价格(包含加减价子商品)
469
- total += getMainProductPrice(product, deductTaxAndFee) * productQuantity;
468
+ // 计算主商品价格(包含加减价子商品)= 单价 * 数量 + 舍入余数 - 商品差额
469
+ total += getMainProductPrice(product, deductTaxAndFee) * productQuantity + getTaxAndFeeRoundingRemainder(product, deductTaxAndFee) - getProductDiscountDifference(product);
470
470
  count += productQuantity;
471
471
  }
472
472
 
@@ -478,9 +478,9 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
478
478
  // 检查子商品是否适用
479
479
  var isBundleItemApplicable = applicableProductIds === null || applicableProductIds.includes(bundleItem.bundle_product_id);
480
480
  if (isBundleItemApplicable) {
481
- // 计算原价子商品价格
481
+ // 计算原价子商品价格 = 总价 + 舍入余数 - 商品差额
482
482
  var bundleItemQuantity = bundleItem.num * productQuantity;
483
- total += getBundleItemPrice(bundleItem, productQuantity, deductTaxAndFee);
483
+ total += getBundleItemPrice(bundleItem, productQuantity, deductTaxAndFee) + getBundleItemTaxAndFeeRoundingRemainder(bundleItem, deductTaxAndFee) - getBundleItemDiscountDifference(bundleItem);
484
484
  count += bundleItemQuantity;
485
485
  }
486
486
  }
@@ -5,7 +5,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
- import { getApplicableProductIds, getMainProductPrice, getBundleItemPrice, getProductQuantity, getBundleItemIsOriginalPrice } from "./utils";
8
+ import { getApplicableProductIds, getMainProductPrice, getBundleItemPrice, getProductQuantity, getBundleItemIsOriginalPrice, getTaxAndFeeRoundingRemainder, getBundleItemTaxAndFeeRoundingRemainder, getProductDiscountDifference, getBundleItemDiscountDifference } from "./utils";
9
9
 
10
10
  /**
11
11
  * Wallet Pass 适配器
@@ -149,8 +149,8 @@ var WalletPassAdapter = /*#__PURE__*/function () {
149
149
  // 检查主商品是否适用
150
150
  var isMainProductApplicable = applicableProductIds === null || applicableProductIds.includes(product.product_id);
151
151
  if (isMainProductApplicable) {
152
- // 计算主商品价格(包含加减价子商品)
153
- total += getMainProductPrice(product, deductTaxAndFee) * productQuantity;
152
+ // 计算主商品价格(包含加减价子商品)= 单价 * 数量 + 舍入余数 - 商品差额
153
+ total += getMainProductPrice(product, deductTaxAndFee) * productQuantity + getTaxAndFeeRoundingRemainder(product, deductTaxAndFee) - getProductDiscountDifference(product);
154
154
  count += productQuantity;
155
155
  }
156
156
 
@@ -162,9 +162,9 @@ var WalletPassAdapter = /*#__PURE__*/function () {
162
162
  // 检查子商品是否适用
163
163
  var isBundleItemApplicable = applicableProductIds === null || applicableProductIds.includes(bundleItem.bundle_product_id);
164
164
  if (isBundleItemApplicable) {
165
- // 计算原价子商品价格
165
+ // 计算原价子商品价格 = 总价 + 舍入余数 - 商品差额
166
166
  var bundleItemQuantity = bundleItem.num * productQuantity;
167
- total += getBundleItemPrice(bundleItem, productQuantity, deductTaxAndFee);
167
+ total += getBundleItemPrice(bundleItem, productQuantity, deductTaxAndFee) + getBundleItemTaxAndFeeRoundingRemainder(bundleItem, deductTaxAndFee) - getBundleItemDiscountDifference(bundleItem);
168
168
  count += bundleItemQuantity;
169
169
  }
170
170
  }
@@ -64,6 +64,8 @@ export interface Product {
64
64
  surcharge_rounding_remainder?: number;
65
65
  tax_fee_rounding_remainder?: number;
66
66
  main_product_selling_price: number;
67
+ /** 商品折扣差额 */
68
+ product_discount_difference?: number;
67
69
  };
68
70
  is_price_include_tax: 0 | 1;
69
71
  product_bundle: {
@@ -81,6 +83,7 @@ export interface Product {
81
83
  surcharge_fee: number;
82
84
  surcharge_rounding_remainder?: number;
83
85
  tax_fee_rounding_remainder?: number;
86
+ product_discount_difference?: number;
84
87
  };
85
88
  }[];
86
89
  }
@@ -24,18 +24,44 @@ export declare function recalculateVouchers(allVouchers: any[], selectedVouchers
24
24
  selectedWithDetails: any[];
25
25
  };
26
26
  /**
27
- * 获取主商品价格
27
+ * 获取税费和附加费的舍入余数
28
28
  * @param product 商品
29
29
  * @param isDeductTaxAndFee 是否抵扣税费与附加费
30
- * @returns 商品价格
30
+ * @returns 舍入余数(税费 + 附加费的舍入余数)
31
+ */
32
+ export declare const getTaxAndFeeRoundingRemainder: (product: Product, isDeductTaxAndFee: boolean) => number;
33
+ /**
34
+ * 获取主商品的商品差额
35
+ * @param product 商品
36
+ * @returns 商品差额(与数量无关,计算总价时需要减去)
37
+ */
38
+ export declare const getProductDiscountDifference: (product: Product) => number;
39
+ /**
40
+ * 获取主商品价格(单价,不含舍入余数)
41
+ * @param product 商品
42
+ * @param isDeductTaxAndFee 是否抵扣税费与附加费
43
+ * @returns 商品单价
31
44
  */
32
45
  export declare const getMainProductPrice: (product: Product, isDeductTaxAndFee: boolean) => number;
33
46
  /**
34
- * 获取套餐子商品价格
47
+ * 获取套餐子商品税费和附加费的舍入余数
48
+ * @param bundleItem 套餐子商品
49
+ * @param isDeductTaxAndFee 是否抵扣税费与附加费
50
+ * @returns 舍入余数(税费 + 附加费的舍入余数)
51
+ */
52
+ export declare const getBundleItemTaxAndFeeRoundingRemainder: (bundleItem: any, isDeductTaxAndFee: boolean) => number;
53
+ /**
54
+ * 获取套餐子商品的商品差额
55
+ * @param bundleItem 套餐子商品
56
+ * @returns 商品差额(与数量无关,计算总价时需要减去)
57
+ */
58
+ export declare const getBundleItemDiscountDifference: (bundleItem: any) => number;
59
+ /**
60
+ * 获取套餐子商品价格(不含舍入余数)
35
61
  * @param bundleItem 套餐子商品
36
62
  * @param parentQuantity 父商品数量
37
63
  * @param isDeductTaxAndFee 是否抵扣税费与附加费
38
- * @returns 子商品总价格
64
+ * @returns 子商品总价格(不含舍入余数)
39
65
  */
40
66
  export declare const getBundleItemPrice: (bundleItem: any, parentQuantity: number, isDeductTaxAndFee: boolean) => number;
41
67
  /**
@@ -798,14 +798,48 @@ export function recalculateVouchers(allVouchers, selectedVouchers, orderTotalAmo
798
798
  }
799
799
 
800
800
  /**
801
- * 获取主商品价格
801
+ * 获取税费和附加费的舍入余数
802
802
  * @param product 商品
803
803
  * @param isDeductTaxAndFee 是否抵扣税费与附加费
804
- * @returns 商品价格
804
+ * @returns 舍入余数(税费 + 附加费的舍入余数)
805
+ */
806
+ export var getTaxAndFeeRoundingRemainder = function getTaxAndFeeRoundingRemainder(product, isDeductTaxAndFee) {
807
+ var _product$metadata2;
808
+ if (!isDeductTaxAndFee) {
809
+ return 0;
810
+ }
811
+
812
+ // 税费舍入余数(如果价格包含税则为0)
813
+ var taxFeeRoundingRemainder = new Decimal(0);
814
+ if (product.is_price_include_tax !== 1) {
815
+ var _product$metadata;
816
+ taxFeeRoundingRemainder = new Decimal((product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.tax_fee_rounding_remainder) || 0);
817
+ }
818
+
819
+ // 附加费舍入余数
820
+ var surchargeFeeRoundingRemainder = new Decimal((product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.surcharge_rounding_remainder) || 0);
821
+ return taxFeeRoundingRemainder.add(surchargeFeeRoundingRemainder).toNumber();
822
+ };
823
+
824
+ /**
825
+ * 获取主商品的商品差额
826
+ * @param product 商品
827
+ * @returns 商品差额(与数量无关,计算总价时需要减去)
828
+ */
829
+ export var getProductDiscountDifference = function getProductDiscountDifference(product) {
830
+ var _product$metadata3;
831
+ return new Decimal((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.product_discount_difference) || 0).toNumber();
832
+ };
833
+
834
+ /**
835
+ * 获取主商品价格(单价,不含舍入余数)
836
+ * @param product 商品
837
+ * @param isDeductTaxAndFee 是否抵扣税费与附加费
838
+ * @returns 商品单价
805
839
  */
806
840
  export var getMainProductPrice = function getMainProductPrice(product, isDeductTaxAndFee) {
807
- var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5;
808
- var mainProductPrice = new Decimal((product === null || product === void 0 ? void 0 : product.main_product_selling_price) || ((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.main_product_selling_price) || 0);
841
+ var _product$metadata4, _product$metadata5, _product$metadata6;
842
+ var mainProductPrice = new Decimal((product === null || product === void 0 ? void 0 : product.main_product_selling_price) || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_selling_price) || 0);
809
843
  var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
810
844
  _step6;
811
845
  try {
@@ -824,14 +858,14 @@ export var getMainProductPrice = function getMainProductPrice(product, isDeductT
824
858
  } finally {
825
859
  _iterator6.f();
826
860
  }
827
- var taxFee = new Decimal((product === null || product === void 0 ? void 0 : product.tax_fee) || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_attached_bundle_tax_fee) || 0).add((product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.tax_fee_rounding_remainder) || 0);
861
+ var taxFee = new Decimal((product === null || product === void 0 ? void 0 : product.tax_fee) || (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_attached_bundle_tax_fee) || 0);
828
862
  if (product.is_price_include_tax === 1) {
829
863
  taxFee = new Decimal(0);
830
864
  }
831
865
 
832
866
  // 税费
833
867
  // 附加费
834
- var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_attached_bundle_surcharge_fee) || 0).add((product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.surcharge_rounding_remainder) || 0);
868
+ var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.main_product_attached_bundle_surcharge_fee) || 0);
835
869
 
836
870
  // 税费附加费总额
837
871
  var taxAndFeeTotal = taxFee.add(surchargeFee);
@@ -844,11 +878,45 @@ export var getMainProductPrice = function getMainProductPrice(product, isDeductT
844
878
  };
845
879
 
846
880
  /**
847
- * 获取套餐子商品价格
881
+ * 获取套餐子商品税费和附加费的舍入余数
882
+ * @param bundleItem 套餐子商品
883
+ * @param isDeductTaxAndFee 是否抵扣税费与附加费
884
+ * @returns 舍入余数(税费 + 附加费的舍入余数)
885
+ */
886
+ export var getBundleItemTaxAndFeeRoundingRemainder = function getBundleItemTaxAndFeeRoundingRemainder(bundleItem, isDeductTaxAndFee) {
887
+ var _bundleItem$metadata2;
888
+ if (!isDeductTaxAndFee) {
889
+ return 0;
890
+ }
891
+
892
+ // 税费舍入余数(如果价格包含税则为0)
893
+ var taxFeeRoundingRemainder = new Decimal(0);
894
+ if (bundleItem.is_price_include_tax !== 1) {
895
+ var _bundleItem$metadata;
896
+ taxFeeRoundingRemainder = new Decimal(((_bundleItem$metadata = bundleItem.metadata) === null || _bundleItem$metadata === void 0 ? void 0 : _bundleItem$metadata.tax_fee_rounding_remainder) || 0);
897
+ }
898
+
899
+ // 附加费舍入余数
900
+ var surchargeFeeRoundingRemainder = new Decimal(((_bundleItem$metadata2 = bundleItem.metadata) === null || _bundleItem$metadata2 === void 0 ? void 0 : _bundleItem$metadata2.surcharge_rounding_remainder) || 0);
901
+ return taxFeeRoundingRemainder.add(surchargeFeeRoundingRemainder).toNumber();
902
+ };
903
+
904
+ /**
905
+ * 获取套餐子商品的商品差额
906
+ * @param bundleItem 套餐子商品
907
+ * @returns 商品差额(与数量无关,计算总价时需要减去)
908
+ */
909
+ export var getBundleItemDiscountDifference = function getBundleItemDiscountDifference(bundleItem) {
910
+ var _bundleItem$metadata3;
911
+ return new Decimal(((_bundleItem$metadata3 = bundleItem.metadata) === null || _bundleItem$metadata3 === void 0 ? void 0 : _bundleItem$metadata3.product_discount_difference) || 0).toNumber();
912
+ };
913
+
914
+ /**
915
+ * 获取套餐子商品价格(不含舍入余数)
848
916
  * @param bundleItem 套餐子商品
849
917
  * @param parentQuantity 父商品数量
850
918
  * @param isDeductTaxAndFee 是否抵扣税费与附加费
851
- * @returns 子商品总价格
919
+ * @returns 子商品总价格(不含舍入余数)
852
920
  */
853
921
  export var getBundleItemPrice = function getBundleItemPrice(bundleItem, parentQuantity, isDeductTaxAndFee) {
854
922
  var _bundleItem$bundle_se2;
@@ -858,14 +926,14 @@ export var getBundleItemPrice = function getBundleItemPrice(bundleItem, parentQu
858
926
 
859
927
  // 根据 deductTaxAndFee 配置决定是否加上税费和附加费
860
928
  if (isDeductTaxAndFee) {
861
- var _bundleItem$tax_fee, _bundleItem$metadata$, _bundleItem$metadata;
929
+ var _bundleItem$tax_fee, _bundleItem$metadata$, _bundleItem$metadata4;
862
930
  // 税费
863
931
  var taxFee = new Decimal((_bundleItem$tax_fee = bundleItem.tax_fee) !== null && _bundleItem$tax_fee !== void 0 ? _bundleItem$tax_fee : 0).times(totalQuantity);
864
932
  if (bundleItem.is_price_include_tax === 1) {
865
933
  taxFee = new Decimal(0);
866
934
  }
867
935
  // 附加费
868
- var surchargeFee = new Decimal((_bundleItem$metadata$ = (_bundleItem$metadata = bundleItem.metadata) === null || _bundleItem$metadata === void 0 ? void 0 : _bundleItem$metadata.surcharge_fee) !== null && _bundleItem$metadata$ !== void 0 ? _bundleItem$metadata$ : 0).times(totalQuantity);
936
+ var surchargeFee = new Decimal((_bundleItem$metadata$ = (_bundleItem$metadata4 = bundleItem.metadata) === null || _bundleItem$metadata4 === void 0 ? void 0 : _bundleItem$metadata4.surcharge_fee) !== null && _bundleItem$metadata$ !== void 0 ? _bundleItem$metadata$ : 0).times(totalQuantity);
869
937
  bundleItemPrice = bundleItemPrice.add(taxFee).add(surchargeFee);
870
938
  }
871
939
  return bundleItemPrice.toNumber();
@@ -886,6 +954,11 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
886
954
  var unitPriceWithTax = getMainProductPrice(product, true);
887
955
  var unitPricePure = getMainProductPrice(product, false);
888
956
 
957
+ // 获取舍入余数(与数量无关,只加一次)
958
+ var roundingRemainderWithTax = getTaxAndFeeRoundingRemainder(product, true);
959
+ // 获取商品差额(与数量无关,计算总价时需要减去)
960
+ var discountDifference = getProductDiscountDifference(product);
961
+
889
962
  // 1. 添加主商品(同时计算含税和不含税两个金额,以及单价和剩余数量)
890
963
  expandedProducts.push(_objectSpread(_objectSpread({}, product), {}, {
891
964
  is_bundle_item: false,
@@ -895,10 +968,10 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
895
968
  unitPricePure: new Decimal(unitPricePure),
896
969
  // 剩余可抵扣数量
897
970
  remainingQuantity: productQuantity,
898
- // 含税费的剩余金额
899
- remainingAmountWithTax: new Decimal(unitPriceWithTax).times(productQuantity),
900
- // 纯商品金额(不含税费)
901
- remainingAmountPure: new Decimal(unitPricePure).times(productQuantity)
971
+ // 含税费的剩余金额(单价 * 数量 + 舍入余数 - 商品差额)
972
+ remainingAmountWithTax: new Decimal(unitPriceWithTax).times(productQuantity).add(roundingRemainderWithTax).sub(discountDifference),
973
+ // 纯商品金额(不含税费,也需要减去商品差额)
974
+ remainingAmountPure: new Decimal(unitPricePure).times(productQuantity).sub(discountDifference)
902
975
  }));
903
976
 
904
977
  // 2. 添加原价子商品(作为独立商品项)
@@ -910,6 +983,11 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
910
983
  var bundleUnitPriceWithTax = new Decimal(getBundleItemPrice(bundleItem, 1, true)).dividedBy(bundleItem.num);
911
984
  var bundleUnitPricePure = new Decimal(getBundleItemPrice(bundleItem, 1, false)).dividedBy(bundleItem.num);
912
985
 
986
+ // 获取子商品舍入余数(与数量无关,只加一次)
987
+ var bundleRoundingRemainder = getBundleItemTaxAndFeeRoundingRemainder(bundleItem, true);
988
+ // 获取子商品差额(与数量无关,计算总价时需要减去)
989
+ var bundleDiscountDifference = getBundleItemDiscountDifference(bundleItem);
990
+
913
991
  // 原价子商品作为独立商品
914
992
  expandedProducts.push(_objectSpread(_objectSpread({}, bundleItem), {}, {
915
993
  product_id: bundleItem.bundle_product_id,
@@ -923,10 +1001,10 @@ var expandProductsWithBundleItems = function expandProductsWithBundleItems(produ
923
1001
  unitPricePure: bundleUnitPricePure,
924
1002
  // 剩余可抵扣数量
925
1003
  remainingQuantity: bundleQuantity,
926
- // 含税费的剩余金额
927
- remainingAmountWithTax: new Decimal(getBundleItemPrice(bundleItem, productQuantity, true)),
928
- // 纯商品金额(不含税费)
929
- remainingAmountPure: new Decimal(getBundleItemPrice(bundleItem, productQuantity, false))
1004
+ // 含税费的剩余金额(总价 + 舍入余数 - 商品差额)
1005
+ remainingAmountWithTax: new Decimal(getBundleItemPrice(bundleItem, productQuantity, true)).add(bundleRoundingRemainder).sub(bundleDiscountDifference),
1006
+ // 纯商品金额(不含税费,也需要减去商品差额)
1007
+ remainingAmountPure: new Decimal(getBundleItemPrice(bundleItem, productQuantity, false)).sub(bundleDiscountDifference)
930
1008
  }));
931
1009
  }
932
1010
  });
@@ -25,6 +25,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
25
25
  request_timezone: string;
26
26
  }): Promise<Discount[]>;
27
27
  batchSearch(code: string, customerId?: number): Promise<Discount[]>;
28
+ batchSearchByProductIds(productIds: number[]): Promise<any>;
28
29
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
29
30
  private checkUsageCreditsLimit;
30
31
  uniqueByProductId(discountList: Discount[]): Discount[];
@@ -208,6 +208,35 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
208
208
  }
209
209
  return batchSearch;
210
210
  }()
211
+ }, {
212
+ key: "batchSearchByProductIds",
213
+ value: function () {
214
+ var _batchSearchByProductIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productIds) {
215
+ var result;
216
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
217
+ while (1) switch (_context6.prev = _context6.next) {
218
+ case 0:
219
+ _context6.next = 2;
220
+ return this.request.get("/machinecode/batch-search", {
221
+ ids: productIds,
222
+ translate_flag: 1,
223
+ tags: ['good_pass', 'product_discount_card'],
224
+ relation_product: 1
225
+ });
226
+ case 2:
227
+ result = _context6.sent;
228
+ return _context6.abrupt("return", (result === null || result === void 0 ? void 0 : result.data) || []);
229
+ case 4:
230
+ case "end":
231
+ return _context6.stop();
232
+ }
233
+ }, _callee6, this);
234
+ }));
235
+ function batchSearchByProductIds(_x8) {
236
+ return _batchSearchByProductIds.apply(this, arguments);
237
+ }
238
+ return batchSearchByProductIds;
239
+ }()
211
240
  }, {
212
241
  key: "filterEnabledDiscountList",
213
242
  value: function filterEnabledDiscountList(discountList) {
@@ -309,21 +338,21 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
309
338
  }, {
310
339
  key: "destroy",
311
340
  value: function () {
312
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
313
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
314
- while (1) switch (_context6.prev = _context6.next) {
341
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
342
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
343
+ while (1) switch (_context7.prev = _context7.next) {
315
344
  case 0:
316
345
  this.store.discountList = [];
317
346
  this.core.effects.offByModuleDestroy(this.name);
318
- _context6.next = 4;
347
+ _context7.next = 4;
319
348
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
320
349
  case 4:
321
350
  console.log('[Discount] 已销毁');
322
351
  case 5:
323
352
  case "end":
324
- return _context6.stop();
353
+ return _context7.stop();
325
354
  }
326
- }, _callee6, this);
355
+ }, _callee7, this);
327
356
  }));
328
357
  function destroy() {
329
358
  return _destroy.apply(this, arguments);
@@ -333,18 +362,18 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
333
362
  }, {
334
363
  key: "clear",
335
364
  value: function () {
336
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
337
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
338
- while (1) switch (_context7.prev = _context7.next) {
365
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
366
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
367
+ while (1) switch (_context8.prev = _context8.next) {
339
368
  case 0:
340
369
  this.store.discountList = [];
341
370
  this.store.originalDiscountList = [];
342
371
  console.log('[Discount] clear');
343
372
  case 3:
344
373
  case "end":
345
- return _context7.stop();
374
+ return _context8.stop();
346
375
  }
347
- }, _callee7, this);
376
+ }, _callee8, this);
348
377
  }));
349
378
  function clear() {
350
379
  return _clear.apply(this, arguments);
@@ -137,6 +137,7 @@ export interface Discount {
137
137
  num?: number;
138
138
  start_date?: string;
139
139
  start_time?: string;
140
+ discount_rule_uncheck_flag?: boolean;
140
141
  }
141
142
  export interface DiscountState {
142
143
  discountList: Discount[];
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -295,13 +295,6 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
295
295
  orderTotalAmount = _ref2.orderTotalAmount,
296
296
  holders = _ref2.holders,
297
297
  isFormSubject = _ref2.isFormSubject;
298
- // 识别出来是不是在编辑的界面里又新增了商品
299
- // 这种情况下,如果有可用的优惠券,也会自动勾选上
300
- var isEditModeAddNewProduct = productList.find(function (n) {
301
- return n.booking_id;
302
- }) && productList.find(function (n) {
303
- return !n.booking_id;
304
- });
305
298
  var editModeDiscount = [];
306
299
  var addModeDiscount = [];
307
300
  discountList.forEach(function (discount) {
@@ -352,7 +345,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
352
345
  _id: product._id,
353
346
  parentId: product._id,
354
347
  quantity: product.quantity,
355
- num: product.num
348
+ num: product.num,
349
+ booking_id: product.booking_id
356
350
  });
357
351
 
358
352
  // 2. 展开 bundle 子商品
@@ -376,7 +370,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
376
370
  origin_total: new Decimal(bundleItem.price || 0).mul(bundleItem.num || 1).toNumber(),
377
371
  original_price: bundleItem.original_price,
378
372
  // 继承主商品属性
379
- booking_id: product.booking_id,
373
+ booking_id: bundleItem.booking_id,
380
374
  discount_list: bundleItem.discount_list || []
381
375
  });
382
376
  });
@@ -514,6 +508,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
514
508
  // 🔥 扁平化商品列表(包含主商品和bundle子商品)
515
509
  var flattenedList = flattenProductsWithBundle(productList);
516
510
 
511
+ // 识别出来是不是在编辑的界面里又新增了商品
512
+ // 这种情况下,如果有可用的优惠券,也会自动勾选上
513
+ var isEditModeAddNewProduct = flattenedList.find(function (n) {
514
+ return n.booking_id;
515
+ }) && flattenedList.find(function (n) {
516
+ return !n.booking_id;
517
+ });
518
+
517
519
  // 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
518
520
  var sortedFlattenedList = flattenedList.sort(function (a, b) {
519
521
  var _ref3, _a$original_price, _ref4, _b$original_price;
@@ -896,7 +898,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
896
898
  discount_product_id: discount.product_id
897
899
  },
898
900
  metadata: {
899
- num: num
901
+ num: num,
902
+ discount_rule_uncheck_flag: discount === null || discount === void 0 ? void 0 : discount.discount_rule_uncheck_flag
900
903
  }
901
904
  };
902
905
  applicableProducts.push(productData);
@@ -1259,10 +1262,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1259
1262
  // 前端使用的num数量,为了计算优惠金额
1260
1263
  _num: isGoodPass ? 1 : product.num,
1261
1264
  config: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.config,
1262
- metadata: _objectSpread({
1265
+ metadata: _objectSpread(_objectSpread({
1263
1266
  num: 1
1264
1267
  }, productDiscountDifference !== undefined && {
1265
1268
  product_discount_difference: productDiscountDifference
1269
+ }), {}, {
1270
+ discount_rule_uncheck_flag: _selectedDiscount === null || _selectedDiscount === void 0 ? void 0 : _selectedDiscount.discount_rule_uncheck_flag
1266
1271
  })
1267
1272
  };
1268
1273
  appliedProducts.push(discountDetail);
@@ -1348,6 +1353,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1348
1353
  metadata: {
1349
1354
  // 🔥 使用拆分后的唯一 _id
1350
1355
  custom_product_bundle_map_id: uniqueId,
1356
+ discount_rule_uncheck_flag: _selectedDiscount2 === null || _selectedDiscount2 === void 0 ? void 0 : _selectedDiscount2.discount_rule_uncheck_flag,
1351
1357
  num: 1
1352
1358
  },
1353
1359
  _num: 1,
@@ -1432,6 +1438,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1432
1438
  metadata: _objectSpread({
1433
1439
  // 🔥 使用唯一的 _id
1434
1440
  custom_product_bundle_map_id: _uniqueId,
1441
+ discount_rule_uncheck_flag: _selectedDiscount3 === null || _selectedDiscount3 === void 0 ? void 0 : _selectedDiscount3.discount_rule_uncheck_flag,
1435
1442
  num: product.num || 1
1436
1443
  }, _productDiscountDifference !== undefined && {
1437
1444
  product_discount_difference: _productDiscountDifference
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -39,6 +39,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
39
39
  discountList: Discount[];
40
40
  };
41
41
  setProductList(productList: Record<string, any>[]): void;
42
+ batchSearchByProductIds(productIds: number[]): Promise<Discount[]>;
42
43
  scanCode(code: string, customerId?: number): Promise<{
43
44
  isAvailable: boolean;
44
45
  productList: Record<string, any>[];