@pisell/pisellos 2.2.22 → 2.2.24

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 (31) hide show
  1. package/dist/modules/Cart/utils/cartProduct.js +21 -4
  2. package/dist/modules/Customer/index.js +1 -1
  3. package/dist/modules/Discount/index.js +3 -3
  4. package/dist/modules/Discount/types.d.ts +9 -0
  5. package/dist/modules/Order/utils.js +1 -1
  6. package/dist/modules/Rules/index.js +401 -102
  7. package/dist/modules/Summary/utils.d.ts +6 -1
  8. package/dist/modules/Summary/utils.js +36 -1
  9. package/dist/server/modules/products/index.js +1 -0
  10. package/dist/solution/BookingByStep/index.d.ts +1 -0
  11. package/dist/solution/BookingByStep/index.js +12 -1
  12. package/dist/solution/Checkout/index.js +181 -108
  13. package/dist/solution/ShopDiscount/index.js +4 -3
  14. package/dist/solution/ShopDiscount/utils.d.ts +24 -0
  15. package/dist/solution/ShopDiscount/utils.js +135 -1
  16. package/lib/modules/Cart/utils/cartProduct.js +22 -6
  17. package/lib/modules/Customer/index.js +1 -1
  18. package/lib/modules/Discount/index.js +3 -3
  19. package/lib/modules/Discount/types.d.ts +9 -0
  20. package/lib/modules/Order/utils.js +1 -1
  21. package/lib/modules/Rules/index.js +290 -63
  22. package/lib/modules/Summary/utils.d.ts +6 -1
  23. package/lib/modules/Summary/utils.js +27 -3
  24. package/lib/server/modules/products/index.js +1 -0
  25. package/lib/solution/BookingByStep/index.d.ts +1 -0
  26. package/lib/solution/BookingByStep/index.js +12 -1
  27. package/lib/solution/Checkout/index.js +45 -6
  28. package/lib/solution/ShopDiscount/index.js +6 -6
  29. package/lib/solution/ShopDiscount/utils.d.ts +24 -0
  30. package/lib/solution/ShopDiscount/utils.js +88 -1
  31. package/package.json +1 -1
@@ -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
  });
@@ -154,7 +154,7 @@ export var CustomerModule = /*#__PURE__*/function (_BaseModule) {
154
154
  skip: skip,
155
155
  num: num,
156
156
  sort_by: SORT_BY,
157
- with: ['latestWalletDetail.wallet', 'contactsInfo'],
157
+ with: ['latestWalletDetail.wallet', 'contactsInfo', 'formRecord'],
158
158
  search_wallet_flag: 1,
159
159
  search_wallet_pass_flag: 1
160
160
  }, search && {
@@ -188,7 +188,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
188
188
  tags: ['good_pass', 'product_discount_card'],
189
189
  available: 1,
190
190
  relation_product: 1,
191
- with: ['extensionData', 'holder.detail'],
191
+ with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
192
192
  order_behavior_count: 1,
193
193
  order_behavior_count_customer_id: customerId || 1
194
194
  });
@@ -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;
@@ -56,7 +56,7 @@ export var getAllDiscountList = function getAllDiscountList(cartItem) {
56
56
  var _cartItem$_origin, _cartItem$_origin2;
57
57
  var discountList = (cartItem === null || cartItem === void 0 || (_cartItem$_origin = cartItem._origin) === null || _cartItem$_origin === void 0 || (_cartItem$_origin = _cartItem$_origin.product) === null || _cartItem$_origin === void 0 ? void 0 : _cartItem$_origin.discount_list) || [];
58
58
  ((cartItem === null || cartItem === void 0 || (_cartItem$_origin2 = cartItem._origin) === null || _cartItem$_origin2 === void 0 || (_cartItem$_origin2 = _cartItem$_origin2.product) === null || _cartItem$_origin2 === void 0 ? void 0 : _cartItem$_origin2.product_bundle) || []).forEach(function (item) {
59
- discountList = [].concat(_toConsumableArray(discountList), _toConsumableArray(item.discount_list || []));
59
+ discountList = [].concat(_toConsumableArray(discountList), _toConsumableArray((item === null || item === void 0 ? void 0 : item.discount_list) || []));
60
60
  item.discount_list = undefined;
61
61
  });
62
62
  return discountList;