@pisell/private-materials 6.6.53 → 6.6.54

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.
@@ -519,7 +519,8 @@ var processItemsTax = function processItemsTax(items, state, options) {
519
519
  }
520
520
  return {
521
521
  originTax: expectedOriginTax,
522
- tax: expectedTax
522
+ tax: expectedTax,
523
+ taxDecimal: preciseTax
523
524
  };
524
525
  };
525
526
 
@@ -651,7 +652,7 @@ var getTax = function getTax(state, options) {
651
652
  computed: computed
652
653
  });
653
654
  totalOriginTax = totalOriginTax.plus(serviceResult.originTax);
654
- totalTax = totalTax.plus(serviceResult.tax);
655
+ totalTax = totalTax.plus(serviceResult.taxDecimal);
655
656
  }
656
657
 
657
658
  // 处理附加商品
@@ -662,7 +663,7 @@ var getTax = function getTax(state, options) {
662
663
  computed: computed
663
664
  });
664
665
  totalOriginTax = totalOriginTax.plus(addonsResult.originTax);
665
- totalTax = totalTax.plus(addonsResult.tax);
666
+ totalTax = totalTax.plus(addonsResult.taxDecimal);
666
667
  }
667
668
  }
668
669
  return {
@@ -108,6 +108,7 @@ export var formatProductBundle = function formatProductBundle(bundle) {
108
108
  }
109
109
  } catch (error) {}
110
110
  return bundle.map(function (d) {
111
+ var _d$metadata;
111
112
  var option = formatProductOption(d.option);
112
113
  var option_price = option.reduce(function (temp, item) {
113
114
  return temp + Number(item.num) * item.custom_add_price;
@@ -135,7 +136,7 @@ export var formatProductBundle = function formatProductBundle(bundle) {
135
136
  "bundle_selling_price": Math.abs(d === null || d === void 0 ? void 0 : d.price),
136
137
  // "bundle_sum_price": d?.original_price || d?.original_total,
137
138
  "metadata": {
138
- custom_product_bundle_map_id: d._id,
139
+ custom_product_bundle_map_id: (d === null || d === void 0 || (_d$metadata = d.metadata) === null || _d$metadata === void 0 ? void 0 : _d$metadata.custom_product_bundle_map_id) || d._id,
139
140
  // 子商品单数量附加费
140
141
  "surcharge_fee": d.surcharge_fee,
141
142
  // 可选,附加费均摊舍入金额
@@ -477,7 +478,7 @@ export var getMainProductSellingPrice = function getMainProductSellingPrice(item
477
478
  * @Author: WangHan
478
479
  * @Date: 2024-12-07 14:21
479
480
  */
480
- var formatProducts = function formatProducts(item, quantity) {
481
+ var formatProducts = function formatProducts(item, quantity, options) {
481
482
  var _item$_extend36, _getMainProductSellin, _item$_extend37, _item$_extend38, _item$_extend39, _item$_extend40;
482
483
  var total = Number(item._extend.total);
483
484
  var origin_total = Number(item._extend.origin_total);
@@ -492,6 +493,9 @@ var formatProducts = function formatProducts(item, quantity) {
492
493
  d.metadata = _objectSpread(_objectSpread({}, d.metadata), {}, {
493
494
  unique_identification_number: "".concat(item._extend.unique_identification_number, "_").concat(d.discount.resource_id)
494
495
  });
496
+ if (options !== null && options !== void 0 && options.isServiceEdit && options !== null && options !== void 0 && options.isMultiDay) {
497
+ delete d.id;
498
+ }
495
499
  });
496
500
 
497
501
  // 非手动折扣
@@ -714,7 +718,10 @@ var formatBookings = function formatBookings(data, values) {
714
718
  item._extend.unique_identification_number = unique_identification_number;
715
719
  }
716
720
  var booking = _objectSpread(_objectSpread({
717
- product: formatProducts(item),
721
+ product: formatProducts(item, undefined, {
722
+ isServiceEdit: data.service.edit,
723
+ isMultiDay: isMultiDay
724
+ }),
718
725
  relation_products: formatRelationDetails(item._extend.relation_details),
719
726
  id: item.booking_id || 0,
720
727
  relation_id: item._extend.relation_id || 0,
@@ -128,7 +128,7 @@ var VoucherCard = function VoucherCard(props) {
128
128
  var val = (_ref = state.service.value || []) === null || _ref === void 0 ? void 0 : _ref.map(function (value) {
129
129
  var _value$_extend, _value$_extend2, _value$_extend3;
130
130
  return {
131
- booking_id: value.booking_id,
131
+ // booking_id: value.booking_id,
132
132
  id: value.id,
133
133
  price: value.price,
134
134
  total: value === null || value === void 0 || (_value$_extend = value._extend) === null || _value$_extend === void 0 ? void 0 : _value$_extend.total,
@@ -41,7 +41,7 @@ import { editSessionProduct } from "../../../info/utils";
41
41
  import { deleteCacheParams, getDays, getProductOriginTotalPrice, getProductTotalPrice, getServiceTimes, isSessionProduct, isWalkIn } from "../../../utils";
42
42
  import { getErrorList, getIsNoSpecAndPackage } from "../../utilsByBooking";
43
43
  import { formatResources, getDurationProps, getFlexibleOption, getMultiDay, getTimeObj, setDefaultCapacitys } from "../addService/utils";
44
- import { getProductAllDiscountList, mergeBundleWithOriginalPrice, setProductPrice } from "./utils";
44
+ import { getProductAllDiscountList, mergeBundles, setProductPrice, mergeBundleWithOriginalPrice } from "./utils";
45
45
  import NoteModal from "../../../../../plus/noteModal";
46
46
  import { DiscountKeyboard } from "../../../../../pro/priceKeyboard";
47
47
  import EditTabs from "../../../info/service/editService/EditTabs";
@@ -687,7 +687,9 @@ var Info = function Info(_, ref) {
687
687
  },
688
688
  isOS: isSession,
689
689
  customer_id: (_state$client = state.client) === null || _state$client === void 0 || (_state$client = _state$client.value) === null || _state$client === void 0 ? void 0 : _state$client.id,
690
- value: _objectSpread(_objectSpread(_objectSpread({}, item._extend.other), sessionValue), {}, {
690
+ value: _objectSpread(_objectSpread(_objectSpread({}, item._extend.other), {}, {
691
+ bundle: mergeBundles(item._extend.other)
692
+ }, sessionValue), {}, {
691
693
  quantity: values.quantity || item._extend.quantity
692
694
  })
693
695
  },
@@ -1223,6 +1225,8 @@ var Info = function Info(_, ref) {
1223
1225
  var _cacheItem$_extend$ot, _cacheItem$_extend$ot2;
1224
1226
  delete cacheItem.discount_list;
1225
1227
  (_cacheItem$_extend$ot = cacheItem._extend.other) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot = _cacheItem$_extend$ot.bundle) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot2 = _cacheItem$_extend$ot.forEach) === null || _cacheItem$_extend$ot2 === void 0 || _cacheItem$_extend$ot2.call(_cacheItem$_extend$ot, function (bundle) {
1228
+ var _bundle$metadata;
1229
+ bundle === null || bundle === void 0 || (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 || delete _bundle$metadata.custom_product_bundle_map_id;
1226
1230
  bundle === null || bundle === void 0 || delete bundle.discount_list;
1227
1231
  bundle === null || bundle === void 0 || delete bundle.booking_id;
1228
1232
  bundle === null || bundle === void 0 || delete bundle.bundle_selling_price;
@@ -32,6 +32,7 @@ export declare const setProductPrice: (cacheItem: any, { newTotal, origin_total
32
32
  * @returns 折扣列表
33
33
  */
34
34
  export declare const getProductAllDiscountList: (cacheItem: any) => any;
35
+ export declare const mergeBundles: (other: any) => any[];
35
36
  /**
36
37
  * 合并 bundle 数据,基于 id 和 product_id 匹配,price 优先使用 originalOther 中的值
37
38
  * @param other - callback 返回的新数据
@@ -149,6 +149,22 @@ export var getProductAllDiscountList = function getProductAllDiscountList(cacheI
149
149
  (_discountList = discountList).push.apply(_discountList, _toConsumableArray(bundleDiscountList));
150
150
  return discountList;
151
151
  };
152
+ export var mergeBundles = function mergeBundles(other) {
153
+ var bundle = (other === null || other === void 0 ? void 0 : other.bundle) || [];
154
+ var newBundle = [];
155
+ bundle.forEach(function (item) {
156
+ var newItem = newBundle.find(function (newItem) {
157
+ return newItem.id === item.id;
158
+ });
159
+ if (newItem) {
160
+ newItem.num += item.num || 1;
161
+ newItem.quantity += item.quantity || 1;
162
+ } else {
163
+ newBundle.push(_objectSpread({}, item));
164
+ }
165
+ });
166
+ return newBundle;
167
+ };
152
168
 
153
169
  /**
154
170
  * 合并 bundle 数据,基于 id 和 product_id 匹配,price 优先使用 originalOther 中的值
@@ -189,7 +189,7 @@ var Payments = Provider(function (props) {
189
189
  className: "payment-list-item-surcharge"
190
190
  }, "(", locales.getText("pisell2.text.surcharge"), " ", formatAmount(item.service_fee, 2, (state === null || state === void 0 ? void 0 : state.amountSymbol) || "$"), ")") : null, /*#__PURE__*/React.createElement("div", {
191
191
  className: "payment-list-item-date"
192
- }, dayjs(item.payment_time).format("HH:mm YYYY/MM/DD"), /*#__PURE__*/React.createElement("span", {
192
+ }, dayjs(item.payment_time || item.created_at).format("HH:mm YYYY/MM/DD"), /*#__PURE__*/React.createElement("span", {
193
193
  className: "payment-list-item-platform-type"
194
194
  }, item.platform && locales.getText("pisell2.text.platform.type")(item.platform))))))));
195
195
  }
@@ -323,7 +323,7 @@ var processItemsTax = (items, state, options) => {
323
323
  }
324
324
  }
325
325
  }
326
- return { originTax: expectedOriginTax, tax: expectedTax };
326
+ return { originTax: expectedOriginTax, tax: expectedTax, taxDecimal: preciseTax };
327
327
  };
328
328
  var clearTaxFee = (state) => {
329
329
  var _a, _b;
@@ -376,7 +376,7 @@ var getTax = (state, options) => {
376
376
  computed
377
377
  });
378
378
  totalOriginTax = totalOriginTax.plus(serviceResult.originTax);
379
- totalTax = totalTax.plus(serviceResult.tax);
379
+ totalTax = totalTax.plus(serviceResult.taxDecimal);
380
380
  }
381
381
  if ((_c = state == null ? void 0 : state.addons) == null ? void 0 : _c.value) {
382
382
  const addonsResult = processItemsTax(state.addons.value, state, {
@@ -385,7 +385,7 @@ var getTax = (state, options) => {
385
385
  computed
386
386
  });
387
387
  totalOriginTax = totalOriginTax.plus(addonsResult.originTax);
388
- totalTax = totalTax.plus(addonsResult.tax);
388
+ totalTax = totalTax.plus(addonsResult.taxDecimal);
389
389
  }
390
390
  }
391
391
  return {
@@ -111,13 +111,14 @@ var formatProductBundle = (bundle) => {
111
111
  } catch (error) {
112
112
  }
113
113
  return bundle.map((d) => {
114
+ var _a;
114
115
  const option = formatProductOption(d.option);
115
116
  const option_price = option.reduce((temp, item) => {
116
117
  return temp + Number(item.num) * item.custom_add_price;
117
118
  }, 0);
118
119
  const product_discount_difference = ((d == null ? void 0 : d.discount_list) || []).reduce((pre, cur) => {
119
- var _a;
120
- return pre + (((_a = cur == null ? void 0 : cur.metadata) == null ? void 0 : _a.product_discount_difference) || 0);
120
+ var _a2;
121
+ return pre + (((_a2 = cur == null ? void 0 : cur.metadata) == null ? void 0 : _a2.product_discount_difference) || 0);
121
122
  }, 0);
122
123
  return {
123
124
  "is_charge_tax": d.is_charge_tax,
@@ -138,7 +139,7 @@ var formatProductBundle = (bundle) => {
138
139
  "bundle_selling_price": Math.abs(d == null ? void 0 : d.price),
139
140
  // "bundle_sum_price": d?.original_price || d?.original_total,
140
141
  "metadata": {
141
- custom_product_bundle_map_id: d._id,
142
+ custom_product_bundle_map_id: ((_a = d == null ? void 0 : d.metadata) == null ? void 0 : _a.custom_product_bundle_map_id) || d._id,
142
143
  // 子商品单数量附加费
143
144
  "surcharge_fee": d.surcharge_fee,
144
145
  // 可选,附加费均摊舍入金额
@@ -370,7 +371,7 @@ var getMainProductSellingPrice = (item) => {
370
371
  }
371
372
  return new import_decimal.default((_f = item._extend) == null ? void 0 : _f.main_product_selling_price).add(optionPrice).toNumber();
372
373
  };
373
- var formatProducts = (item, quantity) => {
374
+ var formatProducts = (item, quantity, options) => {
374
375
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
375
376
  const total = Number(item._extend.total);
376
377
  const origin_total = Number(item._extend.origin_total);
@@ -384,6 +385,9 @@ var formatProducts = (item, quantity) => {
384
385
  ...d.metadata,
385
386
  unique_identification_number: `${item._extend.unique_identification_number}_${d.discount.resource_id}`
386
387
  };
388
+ if ((options == null ? void 0 : options.isServiceEdit) && (options == null ? void 0 : options.isMultiDay)) {
389
+ delete d.id;
390
+ }
387
391
  });
388
392
  const notManualDiscount = discount_list.filter(
389
393
  (item2) => item2.type !== "product"
@@ -524,7 +528,10 @@ var formatBookings = (data, values) => {
524
528
  item._extend.unique_identification_number = unique_identification_number;
525
529
  }
526
530
  const booking = {
527
- product: formatProducts(item),
531
+ product: formatProducts(item, void 0, {
532
+ isServiceEdit: data.service.edit,
533
+ isMultiDay
534
+ }),
528
535
  relation_products: formatRelationDetails(item._extend.relation_details),
529
536
  id: item.booking_id || 0,
530
537
  relation_id: item._extend.relation_id || 0,
@@ -111,7 +111,7 @@ var VoucherCard = (props) => {
111
111
  const val = (_a2 = state.service.value || []) == null ? void 0 : _a2.map((value) => {
112
112
  var _a3, _b2, _c2;
113
113
  return {
114
- booking_id: value.booking_id,
114
+ // booking_id: value.booking_id,
115
115
  id: value.id,
116
116
  price: value.price,
117
117
  total: (_a3 = value == null ? void 0 : value._extend) == null ? void 0 : _a3.total,
@@ -528,6 +528,7 @@ var Info = (_, ref) => {
528
528
  customer_id: (_e2 = (_d2 = state.client) == null ? void 0 : _d2.value) == null ? void 0 : _e2.id,
529
529
  value: {
530
530
  ...item._extend.other,
531
+ bundle: (0, import_utils8.mergeBundles)(item._extend.other),
531
532
  ...sessionValue,
532
533
  quantity: values.quantity || item._extend.quantity
533
534
  }
@@ -1023,6 +1024,8 @@ var Info = (_, ref) => {
1023
1024
  var _a2, _b2, _c2;
1024
1025
  delete cacheItem.discount_list;
1025
1026
  (_c2 = (_b2 = (_a2 = cacheItem._extend.other) == null ? void 0 : _a2.bundle) == null ? void 0 : _b2.forEach) == null ? void 0 : _c2.call(_b2, (bundle) => {
1027
+ var _a3;
1028
+ (_a3 = bundle == null ? void 0 : bundle.metadata) == null ? true : delete _a3.custom_product_bundle_map_id;
1026
1029
  bundle == null ? true : delete bundle.discount_list;
1027
1030
  bundle == null ? true : delete bundle.booking_id;
1028
1031
  bundle == null ? true : delete bundle.bundle_selling_price;
@@ -32,6 +32,7 @@ export declare const setProductPrice: (cacheItem: any, { newTotal, origin_total
32
32
  * @returns 折扣列表
33
33
  */
34
34
  export declare const getProductAllDiscountList: (cacheItem: any) => any;
35
+ export declare const mergeBundles: (other: any) => any[];
35
36
  /**
36
37
  * 合并 bundle 数据,基于 id 和 product_id 匹配,price 优先使用 originalOther 中的值
37
38
  * @param other - callback 返回的新数据
@@ -32,6 +32,7 @@ __export(utils_exports, {
32
32
  getAutoAllocationStorage: () => getAutoAllocationStorage,
33
33
  getProductAllDiscountList: () => getProductAllDiscountList,
34
34
  mergeBundleWithOriginalPrice: () => mergeBundleWithOriginalPrice,
35
+ mergeBundles: () => mergeBundles,
35
36
  setAutoAllocationStorage: () => setAutoAllocationStorage,
36
37
  setProductPrice: () => setProductPrice
37
38
  });
@@ -96,6 +97,20 @@ var getProductAllDiscountList = (cacheItem) => {
96
97
  discountList.push(...bundleDiscountList);
97
98
  return discountList;
98
99
  };
100
+ var mergeBundles = (other) => {
101
+ const bundle = (other == null ? void 0 : other.bundle) || [];
102
+ const newBundle = [];
103
+ bundle.forEach((item) => {
104
+ const newItem = newBundle.find((newItem2) => newItem2.id === item.id);
105
+ if (newItem) {
106
+ newItem.num += item.num || 1;
107
+ newItem.quantity += item.quantity || 1;
108
+ } else {
109
+ newBundle.push({ ...item });
110
+ }
111
+ });
112
+ return newBundle;
113
+ };
99
114
  var mergeBundleWithOriginalPrice = (other, originalOther) => {
100
115
  var _a, _b;
101
116
  if (!((_a = other == null ? void 0 : other.bundle) == null ? void 0 : _a.length) || !((_b = originalOther == null ? void 0 : originalOther.bundle) == null ? void 0 : _b.length)) return other;
@@ -115,6 +130,7 @@ var mergeBundleWithOriginalPrice = (other, originalOther) => {
115
130
  getAutoAllocationStorage,
116
131
  getProductAllDiscountList,
117
132
  mergeBundleWithOriginalPrice,
133
+ mergeBundles,
118
134
  setAutoAllocationStorage,
119
135
  setProductPrice
120
136
  });
@@ -134,7 +134,7 @@ var Payments = (0, import_model.Provider)((props) => {
134
134
  item.service_fee,
135
135
  2,
136
136
  (state == null ? void 0 : state.amountSymbol) || "$"
137
- ), ")") : null, /* @__PURE__ */ import_react.default.createElement("div", { className: "payment-list-item-date" }, (0, import_dayjs.default)(item.payment_time).format(
137
+ ), ")") : null, /* @__PURE__ */ import_react.default.createElement("div", { className: "payment-list-item-date" }, (0, import_dayjs.default)(item.payment_time || item.created_at).format(
138
138
  "HH:mm YYYY/MM/DD"
139
139
  ), /* @__PURE__ */ import_react.default.createElement("span", { className: "payment-list-item-platform-type" }, item.platform && import_utils.locales.getText("pisell2.text.platform.type")(
140
140
  item.platform
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "6.6.53",
3
+ "version": "6.6.54",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -62,9 +62,9 @@
62
62
  "@react-spring/web": "^9.6.1",
63
63
  "@use-gesture/react": "^10.3.1",
64
64
  "@pisell/utils": "3.0.2",
65
- "@pisell/materials": "6.6.14",
65
+ "@pisell/icon": "0.0.11",
66
66
  "@pisell/date-picker": "3.0.7",
67
- "@pisell/icon": "0.0.11"
67
+ "@pisell/materials": "6.6.15"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.0.0",