@pisell/pisellos 3.0.75 → 3.0.77

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.
@@ -130,6 +130,7 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
130
130
  return cartItem;
131
131
  };
132
132
  export var formatProductToCartItemOrigin = function formatProductToCartItemOrigin(params) {
133
+ var _origin$product;
133
134
  var cartItem = params.cartItem,
134
135
  product = params.product,
135
136
  bundle = params.bundle,
@@ -138,14 +139,24 @@ export var formatProductToCartItemOrigin = function formatProductToCartItemOrigi
138
139
  _params$quantity2 = params.quantity,
139
140
  quantity = _params$quantity2 === void 0 ? 1 : _params$quantity2;
140
141
  var origin = cartItem._origin;
142
+ var product_discount_difference = (((_origin$product = origin.product) === null || _origin$product === void 0 ? void 0 : _origin$product.discount_list) || []).filter(function (item) {
143
+ var _item$metadata;
144
+ return !(item !== null && item !== void 0 && (_item$metadata = item.metadata) !== null && _item$metadata !== void 0 && _item$metadata.custom_product_bundle_map_id);
145
+ }).reduce(function (pre, cur) {
146
+ var _cur$metadata;
147
+ return pre + ((cur === null || cur === void 0 || (_cur$metadata = cur.metadata) === null || _cur$metadata === void 0 ? void 0 : _cur$metadata.product_discount_difference) || 0);
148
+ }, 0);
141
149
  if (product) {
142
- var _origin$product, _origin$product2, _product$duration, _product$duration2;
150
+ var _origin$product2, _origin$product3, _product$duration, _product$duration2;
143
151
  origin.product = _objectSpread(_objectSpread({}, origin.product || {}), {}, {
144
152
  num: quantity,
145
153
  product_id: product.id,
146
154
  product_variant_id: product_variant_id || 0,
147
- product_bundle: ((_origin$product = origin.product) === null || _origin$product === void 0 ? void 0 : _origin$product.product_bundle) || [],
148
- product_option_item: ((_origin$product2 = origin.product) === null || _origin$product2 === void 0 ? void 0 : _origin$product2.product_option_item) || []
155
+ product_bundle: ((_origin$product2 = origin.product) === null || _origin$product2 === void 0 ? void 0 : _origin$product2.product_bundle) || [],
156
+ product_option_item: ((_origin$product3 = origin.product) === null || _origin$product3 === void 0 ? void 0 : _origin$product3.product_option_item) || [],
157
+ metadata: {
158
+ product_discount_difference: product_discount_difference
159
+ }
149
160
  });
150
161
  // 时长类型
151
162
  origin.sub_type = product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.type;
@@ -183,6 +194,7 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
183
194
  // 一个商品折扣卡只能存在于一张
184
195
  // if (currentValue.type !== 'good_pass') {
185
196
  price = getDiscountAmount({
197
+ amount: currentValue.amount,
186
198
  tag: currentValue.type,
187
199
  par_value: currentValue.discount.percent,
188
200
  metadata: {
@@ -303,6 +315,10 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
303
315
  var _d$originBundleItem;
304
316
  return (d === null || d === void 0 ? void 0 : d[key]) || (d === null || d === void 0 || (_d$originBundleItem = d.originBundleItem) === null || _d$originBundleItem === void 0 ? void 0 : _d$originBundleItem[key]);
305
317
  };
318
+ var product_discount_difference = ((d === null || d === void 0 ? void 0 : d.discount_list) || []).reduce(function (pre, cur) {
319
+ var _cur$metadata2;
320
+ return pre + ((cur === null || cur === void 0 || (_cur$metadata2 = cur.metadata) === null || _cur$metadata2 === void 0 ? void 0 : _cur$metadata2.product_discount_difference) || 0);
321
+ }, 0);
306
322
  return {
307
323
  bundle_group_id: getBundleValueByKey('group_id'),
308
324
  bundle_id: d.id,
@@ -315,7 +331,8 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
315
331
  discount_list: d.discount_list,
316
332
  "bundle_selling_price": d === null || d === void 0 ? void 0 : d.price,
317
333
  metadata: {
318
- custom_product_bundle_map_id: d._id
334
+ custom_product_bundle_map_id: d._id,
335
+ product_discount_difference: product_discount_difference
319
336
  }
320
337
  };
321
338
  });
@@ -299,9 +299,9 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
299
299
  }
300
300
  if (discount.appliedProductDetails) {
301
301
  return discount.appliedProductDetails.reduce(function (total, product) {
302
- var _product$discount;
302
+ var _product$discount, _product$metadata;
303
303
  var price = new Decimal((product === null || product === void 0 || (_product$discount = product.discount) === null || _product$discount === void 0 ? void 0 : _product$discount.fixed_amount) || 0).mul((product === null || product === void 0 ? void 0 : product._num) || 1);
304
- return new Decimal(total).plus(price).toNumber();
304
+ return new Decimal(total).plus(price).add((product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.product_discount_difference) || 0).toNumber();
305
305
  }, 0);
306
306
  }
307
307
  }
@@ -33,6 +33,9 @@ interface ApplicableProductDetails {
33
33
  title: string;
34
34
  original_amount: string;
35
35
  num: number;
36
+ metadata?: {
37
+ product_discount_difference?: number;
38
+ };
36
39
  discount?: {
37
40
  fixed_amount?: number;
38
41
  product_id?: number;
@@ -81,6 +84,10 @@ export interface Discount {
81
84
  discount_card_type?: 'fixed_amount' | 'percent';
82
85
  custom_product_bundle_map_id?: string;
83
86
  validity_type?: "custom_schedule_validity" | "fixed_validity";
87
+ discount_calculation_mode: 'item_level' | 'order_level';
88
+ holder: {
89
+ type: "customer" | "custom";
90
+ };
84
91
  };
85
92
  product: Product;
86
93
  type: "product" | 'good_pass';
@@ -89,7 +96,9 @@ export interface Discount {
89
96
  isEditMode?: boolean;
90
97
  isScan?: boolean;
91
98
  discount?: {
99
+ discount_product_id: number;
92
100
  resource_id: number;
101
+ discount_calculation_mode: 'item_level' | 'order_level';
93
102
  };
94
103
  isManualSelect?: boolean;
95
104
  isDisabled?: boolean;