@pisell/pisellos 2.0.48 → 2.0.50

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.
@@ -425,6 +425,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
425
425
  }));
426
426
  }
427
427
  for (var _i = 0; _i < splitCount; _i++) {
428
+ var _originProduct$_produ, _product$discount_lis10;
428
429
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
429
430
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[_i];
430
431
  // 标记优惠券为已使用
@@ -434,8 +435,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
434
435
  var appliedProducts = appliedDiscountProducts.get(_selectedDiscount.id) || [];
435
436
 
436
437
  // 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
437
-
438
438
  var productOriginTotal = product.origin_total || product.total || 0;
439
+ // 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
440
+ if (Number((originProduct === null || originProduct === void 0 || (_originProduct$_produ = originProduct._productInit) === null || _originProduct$_produ === void 0 ? void 0 : _originProduct$_produ.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
441
+ productOriginTotal = product.total;
442
+ }
443
+ // 如果当前 product 有 discount_list,则必须从 origin_total 拿
444
+ if ((_product$discount_lis10 = product.discount_list) !== null && _product$discount_lis10 !== void 0 && _product$discount_lis10.length) {
445
+ productOriginTotal = product.origin_total;
446
+ }
439
447
 
440
448
  // 计算使用折扣卡/商品券以后,单个商品的总 total
441
449
  var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
@@ -1436,7 +1436,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1436
1436
  var resources = [];
1437
1437
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
1438
1438
  dateRange.forEach(function (n) {
1439
- resources.push.apply(resources, _toConsumableArray(_this10.store.date.getResourcesListByDate(n.date) || []));
1439
+ if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1440
1440
  });
1441
1441
  }
1442
1442
  var cartItems = this.store.cart.getItems().filter(function (n) {
@@ -1673,10 +1673,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1673
1673
  }
1674
1674
  // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1675
1675
  if (!AllResources.length) {
1676
- var dateList = this.store.date.getDateList();
1677
- dateList.forEach(function (n) {
1678
- if (n.resource) AllResources.push.apply(AllResources, _toConsumableArray(n.resource));
1676
+ var firstDateCartItem = cartItems === null || cartItems === void 0 ? void 0 : cartItems.find(function (n) {
1677
+ return n.start_date;
1679
1678
  });
1679
+ if (firstDateCartItem !== null && firstDateCartItem !== void 0 && firstDateCartItem.start_date) {
1680
+ var dateResources = this.store.date.getResourcesListByDate(firstDateCartItem.start_date);
1681
+ AllResources.push.apply(AllResources, _toConsumableArray(dateResources || []));
1682
+ } else {
1683
+ var dateList = this.store.date.getDateList();
1684
+ dateList.forEach(function (n) {
1685
+ if (n.resource) AllResources.push.apply(AllResources, _toConsumableArray(n.resource));
1686
+ });
1687
+ }
1680
1688
  }
1681
1689
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1682
1690
  var allCartItems = cloneDeep(this.store.cart.getItems());
@@ -207,7 +207,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
207
207
  });
208
208
  console.log(sortedProductList, "sortedProductListsortedProductList");
209
209
  sortedProductList.forEach((originProduct, i) => {
210
- var _a, _b, _c, _d, _e, _f;
210
+ var _a, _b, _c, _d, _e, _f, _g, _h;
211
211
  const product = this.hooks.getProduct(originProduct);
212
212
  if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag || discount.type)))) {
213
213
  processedProductsMap.set(product._id, [originProduct]);
@@ -297,7 +297,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
297
297
  const selectedDiscount2 = selectedDiscountCard || applicableDiscounts[i2];
298
298
  usedDiscounts.set(selectedDiscount2.id, true);
299
299
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
300
- const productOriginTotal = product.origin_total || product.total || 0;
300
+ let productOriginTotal = product.origin_total || product.total || 0;
301
+ if (Number(((_g = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _g.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
302
+ productOriginTotal = product.total;
303
+ }
304
+ if ((_h = product.discount_list) == null ? void 0 : _h.length) {
305
+ productOriginTotal = product.origin_total;
306
+ }
301
307
  const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
302
308
  const discountDetail = {
303
309
  amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
@@ -826,7 +826,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
826
826
  const resources = [];
827
827
  if (dateRange == null ? void 0 : dateRange.length) {
828
828
  dateRange.forEach((n) => {
829
- resources.push(...this.store.date.getResourcesListByDate(n.date) || []);
829
+ if (n.resource)
830
+ resources.push(...n.resource);
830
831
  });
831
832
  }
832
833
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
@@ -1055,11 +1056,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1055
1056
  });
1056
1057
  }
1057
1058
  if (!AllResources.length) {
1058
- const dateList = this.store.date.getDateList();
1059
- dateList.forEach((n) => {
1060
- if (n.resource)
1061
- AllResources.push(...n.resource);
1062
- });
1059
+ const firstDateCartItem = cartItems == null ? void 0 : cartItems.find((n) => n.start_date);
1060
+ if (firstDateCartItem == null ? void 0 : firstDateCartItem.start_date) {
1061
+ const dateResources = this.store.date.getResourcesListByDate(firstDateCartItem.start_date);
1062
+ AllResources.push(...dateResources || []);
1063
+ } else {
1064
+ const dateList = this.store.date.getDateList();
1065
+ dateList.forEach((n) => {
1066
+ if (n.resource)
1067
+ AllResources.push(...n.resource);
1068
+ });
1069
+ }
1063
1070
  }
1064
1071
  const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(AllResources));
1065
1072
  const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.0.48",
4
+ "version": "2.0.50",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",