@pisell/private-materials 3.0.198 → 3.0.200

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/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +142 -142
  7. package/build/lowcode/render/default/view.js +4 -4
  8. package/build/lowcode/view.js +11 -11
  9. package/es/components/booking/addons/model.d.ts +1 -1
  10. package/es/components/booking/components/footer/utils.js +40 -15
  11. package/es/components/booking/info/service/addService/index.js +15 -2
  12. package/es/components/booking/info/service/editService/index.js +14 -3
  13. package/es/components/booking/info/service2/utils.js +6 -4
  14. package/es/components/booking/payments/index.d.ts +1 -1
  15. package/es/components/booking/utils.js +13 -1
  16. package/es/components/eftposPay/hooks.d.ts +1 -1
  17. package/es/components/shoppingCart/components/Cart/Product.js +1 -1
  18. package/es/components/shoppingCart/components/Cart/index.js +1 -1
  19. package/lib/components/booking/addons/model.d.ts +1 -1
  20. package/lib/components/booking/components/footer/utils.js +16 -3
  21. package/lib/components/booking/info/service/addService/index.js +12 -6
  22. package/lib/components/booking/info/service/editService/index.js +12 -3
  23. package/lib/components/booking/info/service2/utils.js +4 -2
  24. package/lib/components/booking/payments/index.d.ts +1 -1
  25. package/lib/components/booking/utils.js +8 -0
  26. package/lib/components/eftposPay/hooks.d.ts +1 -1
  27. package/lib/components/shoppingCart/components/Cart/Product.js +1 -1
  28. package/lib/components/shoppingCart/components/Cart/index.js +3 -3
  29. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { FormState } from "../model";
3
- export declare const Provider: (ComponentUi: any) => (props: any) => any, Context: import("react").Context<{
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
4
  state: FormState;
5
5
  } & {
6
6
  dispatch: (params: {
@@ -147,6 +147,29 @@ var formatHolders = function formatHolders(state, item, values) {
147
147
  return obj;
148
148
  };
149
149
 
150
+ /**
151
+ * @title: 格式化商品单价
152
+ * @description:
153
+ * @param {any} item
154
+ * @return {*}
155
+ * @Author: WangHan
156
+ * @Date: 2024-12-23 12:05
157
+ */
158
+ var formatProductPrice = function formatProductPrice(item) {
159
+ var _item$_extend2, _item$_extend3;
160
+ var other = (_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.other;
161
+ var price = Number((_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.price);
162
+
163
+ // 单规格, 单价 + 单规格价格
164
+ if (other !== null && other !== void 0 && other.option) {
165
+ var _other$option;
166
+ price = other === null || other === void 0 ? void 0 : (_other$option = other.option) === null || _other$option === void 0 ? void 0 : _other$option.reduce(function (pre, cur) {
167
+ return pre + Number(cur.price) * Number(cur.num);
168
+ }, price);
169
+ }
170
+ return price;
171
+ };
172
+
150
173
  /**
151
174
  * @title: 格式化商品数据
152
175
  * @description:
@@ -156,7 +179,7 @@ var formatHolders = function formatHolders(state, item, values) {
156
179
  * @Date: 2024-12-07 14:21
157
180
  */
158
181
  var formatProducts = function formatProducts(item) {
159
- var _item$_extend2, _item$_extend2$other;
182
+ var _item$_extend4, _item$_extend4$other, _item$_extend5, _item$_extend5$other, _item$_extend6, _item$_extend6$other;
160
183
  var total = Number(item._extend.total);
161
184
  var origin_total = Number(item._extend.origin_total);
162
185
  var discount_amount = origin_total - total;
@@ -165,7 +188,7 @@ var formatProducts = function formatProducts(item) {
165
188
  var discount_type = discount_amount < 0 ? 'change_price' : 'discount';
166
189
  return {
167
190
  "num": item._extend.quantity,
168
- "price": item._extend.price,
191
+ "price": formatProductPrice(item),
169
192
  "product_id": (item === null || item === void 0 ? void 0 : item.product_id) || item.id,
170
193
  "discount_amount": discount_amount,
171
194
  "product_discount_reason": item._extend.discount_reason || '',
@@ -175,8 +198,10 @@ var formatProducts = function formatProducts(item) {
175
198
  "discount_per": item._extend.discount_per,
176
199
  "discount_type": item._extend.discount_type || discount_type,
177
200
  "order_detail_id": item._extend.order_detail_id || 0,
178
- "product_bundle": formatProductBundle((_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : (_item$_extend2$other = _item$_extend2.other) === null || _item$_extend2$other === void 0 ? void 0 : _item$_extend2$other.bundle),
179
- "bundle_edit": item._extend.bundle_edit
201
+ "product_bundle": formatProductBundle((_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : (_item$_extend4$other = _item$_extend4.other) === null || _item$_extend4$other === void 0 ? void 0 : _item$_extend4$other.bundle),
202
+ "bundle_edit": item._extend.bundle_edit,
203
+ "product_option_item": formatProductOption((_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : (_item$_extend5$other = _item$_extend5.other) === null || _item$_extend5$other === void 0 ? void 0 : _item$_extend5$other.option),
204
+ "product_variant_id": ((_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : (_item$_extend6$other = _item$_extend6.other) === null || _item$_extend6$other === void 0 ? void 0 : _item$_extend6$other.product_variant_id) || 0
180
205
  };
181
206
  };
182
207
 
@@ -194,8 +219,8 @@ var formatDayRelationProducts = function formatDayRelationProducts(data, booking
194
219
 
195
220
  // 过滤出卡片中的普通商品
196
221
  var relation_products = list === null || list === void 0 ? void 0 : list.filter(function (item) {
197
- var _item$_extend3;
198
- var holderId = (_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.holder_id;
222
+ var _item$_extend7;
223
+ var holderId = (_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.holder_id;
199
224
  var bookingHolderId = booking_item._extend.holder_id;
200
225
  var isAppointment = appointmentTypes.includes(item.extension_type);
201
226
  return holderId && holderId === bookingHolderId && !isAppointment;
@@ -221,15 +246,15 @@ var formatAppointmentProductLists = function formatAppointmentProductLists(data)
221
246
 
222
247
  // 找出预约商品
223
248
  list = list.filter(function (item) {
224
- var _item$_extend4;
225
- return ((_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.holder_id) && appointmentTypes.includes(item.extension_type);
249
+ var _item$_extend8;
250
+ return ((_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.holder_id) && appointmentTypes.includes(item.extension_type);
226
251
  });
227
252
 
228
253
  // 对预约商品列表根据holder_id进行分组
229
254
  var groupMap = new Map();
230
255
  list.forEach(function (item) {
231
- var _item$_extend5;
232
- var key = (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.holder_id; // 分组键
256
+ var _item$_extend9;
257
+ var key = (_item$_extend9 = item._extend) === null || _item$_extend9 === void 0 ? void 0 : _item$_extend9.holder_id; // 分组键
233
258
  if (!groupMap.has(key)) {
234
259
  groupMap.set(key, []);
235
260
  }
@@ -286,9 +311,9 @@ var formatBookings = function formatBookings(data, values) {
286
311
 
287
312
  // 跨日预约下的普通商品
288
313
  if (isDay) {
289
- var _item$_extend6, _item$_extend7, _item$_extend8, _item$_extend9;
290
- var startDate = ((_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.startDate) || ((_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.start_date);
291
- var endDate = ((_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.endDate) || ((_item$_extend9 = item._extend) === null || _item$_extend9 === void 0 ? void 0 : _item$_extend9.end_date);
314
+ var _item$_extend10, _item$_extend11, _item$_extend12, _item$_extend13;
315
+ var startDate = ((_item$_extend10 = item._extend) === null || _item$_extend10 === void 0 ? void 0 : _item$_extend10.startDate) || ((_item$_extend11 = item._extend) === null || _item$_extend11 === void 0 ? void 0 : _item$_extend11.start_date);
316
+ var endDate = ((_item$_extend12 = item._extend) === null || _item$_extend12 === void 0 ? void 0 : _item$_extend12.endDate) || ((_item$_extend13 = item._extend) === null || _item$_extend13 === void 0 ? void 0 : _item$_extend13.end_date);
292
317
  var _formatDayTime = formatDayTime({
293
318
  startDate: startDate,
294
319
  endDate: endDate
@@ -351,8 +376,8 @@ var formatRelationProducts = function formatRelationProducts(data) {
351
376
  var list = ((_data$service = data.service) === null || _data$service === void 0 ? void 0 : _data$service.value) || [];
352
377
  // open items 下的商品
353
378
  list = list.filter(function (item) {
354
- var _item$_extend10;
355
- return !((_item$_extend10 = item._extend) !== null && _item$_extend10 !== void 0 && _item$_extend10.holder_id);
379
+ var _item$_extend14;
380
+ return !((_item$_extend14 = item._extend) !== null && _item$_extend14 !== void 0 && _item$_extend14.holder_id);
356
381
  });
357
382
  var relationProducts = [];
358
383
  relationProducts = list.map(function (item) {
@@ -292,6 +292,11 @@ var Info = function Info(props) {
292
292
  var handleSelectProduct = useMemoizedFn(function (item, type) {
293
293
  // 是否有单规格 组合规格 套餐, 如果没有不需要打开弹窗
294
294
  var isEject = type === 'detail' || item.bundle_group_count > 0;
295
+
296
+ // 跨日预约开启单规格 组合规格 套餐
297
+ if (isDay) {
298
+ isEject = type === 'detail' || item.bundle_group_count > 0 || item.option_group_count > 0 || item.is_variant > 0;
299
+ }
295
300
  var lock = false;
296
301
  state.action({
297
302
  type: 'pisell1.handleOpenProductModal',
@@ -299,14 +304,15 @@ var Info = function Info(props) {
299
304
  id: item.id,
300
305
  date: state.date.value.format('YYYY-MM-DD'),
301
306
  showConfig: {
302
- option: false,
307
+ option: isDay ? true : false,
303
308
  session: false,
304
- variant: false,
309
+ variant: isDay ? true : false,
305
310
  package: true
306
311
  },
307
312
  is_eject: isEject ? 1 : 0
308
313
  },
309
314
  callback: function callback(e) {
315
+ var _cacheItem$_extend, _cacheItem$_extend$ot;
310
316
  // 防止选择商品弹窗多次触发callback
311
317
  if (lock) {
312
318
  return;
@@ -338,6 +344,13 @@ var Info = function Info(props) {
338
344
  cacheItem._extend.sub_type = 'days';
339
345
  }
340
346
  var _total = getProductTotalPrice(cacheItem);
347
+
348
+ // 如果有多规格,则更新商品的单价
349
+ if (cacheItem !== null && cacheItem !== void 0 && (_cacheItem$_extend = cacheItem._extend) !== null && _cacheItem$_extend !== void 0 && (_cacheItem$_extend$ot = _cacheItem$_extend.other) !== null && _cacheItem$_extend$ot !== void 0 && _cacheItem$_extend$ot.product_variant_id) {
350
+ var _cacheItem$_extend2, _cacheItem$_extend2$o;
351
+ cacheItem._extend.price = Number((_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : (_cacheItem$_extend2$o = _cacheItem$_extend2.other) === null || _cacheItem$_extend2$o === void 0 ? void 0 : _cacheItem$_extend2$o.price);
352
+ }
353
+
341
354
  // 用于折扣 可修改
342
355
  cacheItem._extend.total = _total;
343
356
  // 用于储存原价
@@ -640,6 +640,7 @@ var Info = function Info(_, ref) {
640
640
  * @Date: 2024-08-28 17:08
641
641
  */
642
642
  var handleEdit = useMemoizedFn(function (e) {
643
+ var _item$_extend, _item$_extend$other, _item$_extend2, _item$_extend2$other;
643
644
  // 当前商品
644
645
  var item = state.service.cacheItem;
645
646
 
@@ -653,14 +654,18 @@ var Info = function Info(_, ref) {
653
654
  id: item.id,
654
655
  date: state.date.value.format('YYYY-MM-DD'),
655
656
  showConfig: {
656
- option: false,
657
+ option: isDay ? true : false,
657
658
  session: false,
658
- variant: false,
659
+ variant: isDay ? true : false,
659
660
  package: true
660
661
  },
661
- value: item._extend.other
662
+ value: _objectSpread(_objectSpread({}, item._extend.other), {}, {
663
+ product_variant: ((_item$_extend = item._extend) === null || _item$_extend === void 0 ? void 0 : (_item$_extend$other = _item$_extend.other) === null || _item$_extend$other === void 0 ? void 0 : _item$_extend$other.product_variant_id) || 0,
664
+ product_option: ((_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : (_item$_extend2$other = _item$_extend2.other) === null || _item$_extend2$other === void 0 ? void 0 : _item$_extend2$other.option) || []
665
+ })
662
666
  },
663
667
  callback: function callback(e) {
668
+ var _cacheItem$_extend, _cacheItem$_extend$ot;
664
669
  // 重新生成商品
665
670
  var cacheItem = _objectSpread(_objectSpread({}, item), {}, {
666
671
  product_id: item.id,
@@ -676,6 +681,12 @@ var Info = function Info(_, ref) {
676
681
  // 获取商品总价
677
682
  var _total = getProductTotalPrice(cacheItem);
678
683
 
684
+ // 如果有多规格,则更新商品的单价
685
+ if (cacheItem !== null && cacheItem !== void 0 && (_cacheItem$_extend = cacheItem._extend) !== null && _cacheItem$_extend !== void 0 && (_cacheItem$_extend$ot = _cacheItem$_extend.other) !== null && _cacheItem$_extend$ot !== void 0 && _cacheItem$_extend$ot.product_variant_id) {
686
+ var _cacheItem$_extend2, _cacheItem$_extend2$o;
687
+ cacheItem._extend.price = Number((_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : (_cacheItem$_extend2$o = _cacheItem$_extend2.other) === null || _cacheItem$_extend2$o === void 0 ? void 0 : _cacheItem$_extend2$o.price);
688
+ }
689
+
679
690
  // 用于折扣 可修改
680
691
  cacheItem._extend.total = _total;
681
692
 
@@ -163,9 +163,10 @@ export var isAppointment = function isAppointment(item, state) {
163
163
  */
164
164
  export var formatProducts = function formatProducts(lists, state) {
165
165
  if (!(lists !== null && lists !== void 0 && lists.length)) return [];
166
+ console.log(lists, 'wh_lists');
166
167
  try {
167
168
  return lists.map(function (item) {
168
- var _item$_extend, _item$_extend3, _item$_extend3$other, _item$_extend4, _item$_extend4$other, _resourceItem, _item$_extend5;
169
+ var _item$_extend, _item$_extend3, _item$_extend3$other, _item$_extend4, _item$_extend4$other, _item$_extend5, _item$_extend5$other, _resourceItem, _item$_extend6;
169
170
  var _isAppointment = isAppointment(item, state);
170
171
  var clientTitle = getHolderName(state, item === null || item === void 0 ? void 0 : (_item$_extend = item._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.holder_id);
171
172
  var resourceItem = {};
@@ -185,6 +186,7 @@ export var formatProducts = function formatProducts(lists, state) {
185
186
  num: item === null || item === void 0 ? void 0 : item._extend.quantity,
186
187
  bundle: item === null || item === void 0 ? void 0 : (_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : (_item$_extend3$other = _item$_extend3.other) === null || _item$_extend3$other === void 0 ? void 0 : _item$_extend3$other.bundle,
187
188
  options: item === null || item === void 0 ? void 0 : (_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : (_item$_extend4$other = _item$_extend4.other) === null || _item$_extend4$other === void 0 ? void 0 : _item$_extend4$other.option,
189
+ product_option_string: item === null || item === void 0 ? void 0 : (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : (_item$_extend5$other = _item$_extend5.other) === null || _item$_extend5$other === void 0 ? void 0 : _item$_extend5$other.product_option_string,
188
190
  _showAction: false,
189
191
  _actionText: locales.getText("page.booking.text.add-time"),
190
192
  _errorMessage: errorMessage,
@@ -192,7 +194,7 @@ export var formatProducts = function formatProducts(lists, state) {
192
194
  date: !_isAppointment ? null : state === null || state === void 0 ? void 0 : state.date,
193
195
  relation_form_name: !_isAppointment ? '' : ((_resourceItem = resourceItem) === null || _resourceItem === void 0 ? void 0 : _resourceItem.labelText) || item.relation_form_name,
194
196
  holder_title: clientTitle,
195
- resource: !_isAppointment ? null : item === null || item === void 0 ? void 0 : (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.resource,
197
+ resource: !_isAppointment ? null : item === null || item === void 0 ? void 0 : (_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.resource,
196
198
  relation_details: []
197
199
  })
198
200
  });
@@ -338,8 +340,8 @@ export var isHasDayAppointmentProduct = function isHasDayAppointmentProduct(stat
338
340
  // 如果该购物车中没选择任何商品,则不需要验证,所以直接用1来填充
339
341
  // services: !holderProducts?.length ? [1] : holderProducts?.filter((d: any) => appointmentTypes.includes(d.extension_type))
340
342
  services: services.filter(function (item) {
341
- var _item$_extend6;
342
- return ((_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.holder_id) == d.form_record_id && appointmentTypes.includes(item.extension_type);
343
+ var _item$_extend7;
344
+ return ((_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.holder_id) == d.form_record_id && appointmentTypes.includes(item.extension_type);
343
345
  })
344
346
  });
345
347
  });
@@ -5,5 +5,5 @@ export interface InfoProps {
5
5
  globalState: any;
6
6
  setGlobalState: any;
7
7
  }
8
- declare const Payments: (props: any) => any;
8
+ declare const Payments: any;
9
9
  export default Payments;
@@ -706,18 +706,30 @@ export var getServerItemExtend = function getServerItemExtend(state, cacheItem,
706
706
  return _extend;
707
707
  };
708
708
 
709
- // 商品价格: (商品价格 + (套餐价格 + 单规格价格 * 单规格数量) * 套餐数量) * 商品数量
709
+ // 商品价格: (商品价格 + (套餐价格 + 单规格价格 * 单规格数量) * 套餐数量 + 单规格价格 * 单规格数量) * 商品数量
710
710
  export var getProductTotalPrice = function getProductTotalPrice(item) {
711
711
  var _item$_extend;
712
712
  var price = 0;
713
713
  price += Number(item._extend.price);
714
714
  var other = (_item$_extend = item._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.other;
715
+
716
+ // 多规格
717
+ if (other !== null && other !== void 0 && other.product_variant_id) {
718
+ price = Number(other === null || other === void 0 ? void 0 : other.price);
719
+ }
715
720
  if (other !== null && other !== void 0 && other.bundle) {
716
721
  // bundle
717
722
  price = other === null || other === void 0 ? void 0 : other.bundle.reduce(function (accumulator, currentValue) {
718
723
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
719
724
  }, price);
720
725
  }
726
+
727
+ // 单规格
728
+ if (other !== null && other !== void 0 && other.option) {
729
+ price = other === null || other === void 0 ? void 0 : other.option.reduce(function (accumulator, currentValue) {
730
+ return accumulator + Number(currentValue.price) * Number(currentValue.num);
731
+ }, price);
732
+ }
721
733
  price = price;
722
734
  return price;
723
735
  };
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"payo" | "tyro" | "windcave" | "stripe">;
22
+ readonly eftposRef: React.MutableRefObject<"windcave" | "tyro" | "payo" | "stripe">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  };
25
25
  /**
@@ -73,7 +73,7 @@ var Product = function Product(props) {
73
73
  className: "pisell-lowcode__shopping-cart-content"
74
74
  }, clearCart, lists === null || lists === void 0 ? void 0 : lists.map(function (item) {
75
75
  return /*#__PURE__*/React.createElement(ProductCard, _extends({
76
- key: item.id,
76
+ key: item._id,
77
77
  dataSource: item,
78
78
  onAction: function onAction(e) {
79
79
  return _onAction === null || _onAction === void 0 ? void 0 : _onAction(e);
@@ -39,7 +39,7 @@ var Cart = function Cart() {
39
39
  return _objectSpread(_objectSpread({}, item), {}, {
40
40
  label: /*#__PURE__*/React.createElement("div", {
41
41
  className: "pisell-lowcode__shopping-cart-label"
42
- }, "".concat(item === null || item === void 0 ? void 0 : item.label, " ").concat((item === null || item === void 0 ? void 0 : item.key) > 0 ? locales.getText('pisell2.text.shopping-cart.item')(item === null || item === void 0 ? void 0 : (_item$products = item.products) === null || _item$products === void 0 ? void 0 : _item$products.length) : '')),
42
+ }, "".concat(item === null || item === void 0 ? void 0 : item.label, " ").concat(locales.getText('pisell2.text.shopping-cart.item')(item === null || item === void 0 ? void 0 : (_item$products = item.products) === null || _item$products === void 0 ? void 0 : _item$products.length))),
43
43
  children: (item === null || item === void 0 ? void 0 : (_item$products2 = item.products) === null || _item$products2 === void 0 ? void 0 : _item$products2.length) > 0 ? /*#__PURE__*/React.createElement(Product, {
44
44
  id: item === null || item === void 0 ? void 0 : item.key,
45
45
  lists: item === null || item === void 0 ? void 0 : item.products
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { FormState } from "../model";
3
- export declare const Provider: (ComponentUi: any) => (props: any) => any, Context: import("react").Context<{
3
+ export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
4
4
  state: FormState;
5
5
  } & {
6
6
  dispatch: (params: {
@@ -140,15 +140,26 @@ var formatHolders = (state, item, values) => {
140
140
  }
141
141
  return obj;
142
142
  };
143
+ var formatProductPrice = (item) => {
144
+ var _a, _b, _c;
145
+ const other = (_a = item._extend) == null ? void 0 : _a.other;
146
+ let price = Number((_b = item._extend) == null ? void 0 : _b.price);
147
+ if (other == null ? void 0 : other.option) {
148
+ price = (_c = other == null ? void 0 : other.option) == null ? void 0 : _c.reduce((pre, cur) => {
149
+ return pre + Number(cur.price) * Number(cur.num);
150
+ }, price);
151
+ }
152
+ return price;
153
+ };
143
154
  var formatProducts = (item) => {
144
- var _a, _b;
155
+ var _a, _b, _c, _d, _e, _f;
145
156
  const total = Number(item._extend.total);
146
157
  const origin_total = Number(item._extend.origin_total);
147
158
  const discount_amount = origin_total - total;
148
159
  const discount_type = discount_amount < 0 ? "change_price" : "discount";
149
160
  return {
150
161
  "num": item._extend.quantity,
151
- "price": item._extend.price,
162
+ "price": formatProductPrice(item),
152
163
  "product_id": (item == null ? void 0 : item.product_id) || item.id,
153
164
  "discount_amount": discount_amount,
154
165
  "product_discount_reason": item._extend.discount_reason || "",
@@ -159,7 +170,9 @@ var formatProducts = (item) => {
159
170
  "discount_type": item._extend.discount_type || discount_type,
160
171
  "order_detail_id": item._extend.order_detail_id || 0,
161
172
  "product_bundle": formatProductBundle((_b = (_a = item._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.bundle),
162
- "bundle_edit": item._extend.bundle_edit
173
+ "bundle_edit": item._extend.bundle_edit,
174
+ "product_option_item": formatProductOption((_d = (_c = item._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.option),
175
+ "product_variant_id": ((_f = (_e = item._extend) == null ? void 0 : _e.other) == null ? void 0 : _f.product_variant_id) || 0
163
176
  };
164
177
  };
165
178
  var formatDayRelationProducts = (data, booking_item) => {
@@ -215,7 +215,10 @@ var Info = (props) => {
215
215
  };
216
216
  const handleSelectProduct = (0, import_ahooks.useMemoizedFn)(
217
217
  (item, type) => {
218
- const isEject = type === "detail" || item.bundle_group_count > 0;
218
+ let isEject = type === "detail" || item.bundle_group_count > 0;
219
+ if (isDay) {
220
+ isEject = type === "detail" || item.bundle_group_count > 0 || item.option_group_count > 0 || item.is_variant > 0;
221
+ }
219
222
  let lock = false;
220
223
  state.action({
221
224
  type: "pisell1.handleOpenProductModal",
@@ -223,15 +226,15 @@ var Info = (props) => {
223
226
  id: item.id,
224
227
  date: state.date.value.format("YYYY-MM-DD"),
225
228
  showConfig: {
226
- option: false,
229
+ option: isDay ? true : false,
227
230
  session: false,
228
- variant: false,
231
+ variant: isDay ? true : false,
229
232
  package: true
230
233
  },
231
234
  is_eject: isEject ? 1 : 0
232
235
  },
233
236
  callback: (e) => {
234
- var _a2, _b2;
237
+ var _a2, _b2, _c2, _d2, _e, _f;
235
238
  if (lock) {
236
239
  return;
237
240
  }
@@ -259,11 +262,14 @@ var Info = (props) => {
259
262
  cacheItem._extend.sub_type = "days";
260
263
  }
261
264
  let _total = (0, import_utils3.getProductTotalPrice)(cacheItem);
265
+ if ((_b2 = (_a2 = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a2.other) == null ? void 0 : _b2.product_variant_id) {
266
+ cacheItem._extend.price = Number((_d2 = (_c2 = cacheItem._extend) == null ? void 0 : _c2.other) == null ? void 0 : _d2.price);
267
+ }
262
268
  cacheItem._extend.total = _total;
263
269
  cacheItem._extend.origin_total = _total;
264
270
  const _isEdit = !!state.service.cacheItem;
265
271
  if (_isEdit) {
266
- cacheItem._id = (_a2 = state.service.cacheItem) == null ? void 0 : _a2._id;
272
+ cacheItem._id = (_e = state.service.cacheItem) == null ? void 0 : _e._id;
267
273
  cacheItem.new = 0;
268
274
  }
269
275
  if (renderMode === "current") {
@@ -275,7 +281,7 @@ var Info = (props) => {
275
281
  } else if (state.renderType === "eventBooking") {
276
282
  cacheItem.autoClose = false;
277
283
  } else {
278
- cacheItem.autoClose = !_isEdit && (cacheItem._extend.resource || cacheItem._extend.resource === 0 || (((_b2 = state.service) == null ? void 0 : _b2.resourcesOrigin) || []).length === 1);
284
+ cacheItem.autoClose = !_isEdit && (cacheItem._extend.resource || cacheItem._extend.resource === 0 || (((_f = state.service) == null ? void 0 : _f.resourcesOrigin) || []).length === 1);
279
285
  }
280
286
  dispatch({
281
287
  type: "setService",
@@ -399,6 +399,7 @@ var Info = (_, ref) => {
399
399
  useEndDate
400
400
  ]);
401
401
  const handleEdit = (0, import_ahooks.useMemoizedFn)((e) => {
402
+ var _a2, _b2, _c2, _d2;
402
403
  const item = state.service.cacheItem;
403
404
  let values = form.getFieldsValue();
404
405
  state.action({
@@ -407,14 +408,19 @@ var Info = (_, ref) => {
407
408
  id: item.id,
408
409
  date: state.date.value.format("YYYY-MM-DD"),
409
410
  showConfig: {
410
- option: false,
411
+ option: isDay ? true : false,
411
412
  session: false,
412
- variant: false,
413
+ variant: isDay ? true : false,
413
414
  package: true
414
415
  },
415
- value: item._extend.other
416
+ value: {
417
+ ...item._extend.other,
418
+ product_variant: ((_b2 = (_a2 = item._extend) == null ? void 0 : _a2.other) == null ? void 0 : _b2.product_variant_id) || 0,
419
+ product_option: ((_d2 = (_c2 = item._extend) == null ? void 0 : _c2.other) == null ? void 0 : _d2.option) || []
420
+ }
416
421
  },
417
422
  callback: (e2) => {
423
+ var _a3, _b3, _c3, _d3;
418
424
  let cacheItem = {
419
425
  ...item,
420
426
  product_id: item.id,
@@ -430,6 +436,9 @@ var Info = (_, ref) => {
430
436
  new: 0
431
437
  };
432
438
  let _total = (0, import_utils3.getProductTotalPrice)(cacheItem);
439
+ if ((_b3 = (_a3 = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a3.other) == null ? void 0 : _b3.product_variant_id) {
440
+ cacheItem._extend.price = Number((_d3 = (_c3 = cacheItem._extend) == null ? void 0 : _c3.other) == null ? void 0 : _d3.price);
441
+ }
433
442
  cacheItem._extend.total = _total;
434
443
  cacheItem._extend.origin_total = _total;
435
444
  dispatch({
@@ -137,9 +137,10 @@ var isAppointment = (item, state) => {
137
137
  var formatProducts = (lists, state) => {
138
138
  if (!(lists == null ? void 0 : lists.length))
139
139
  return [];
140
+ console.log(lists, "wh_lists");
140
141
  try {
141
142
  return lists.map((item) => {
142
- var _a, _b, _c, _d, _e, _f, _g;
143
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
143
144
  const _isAppointment = isAppointment(item, state);
144
145
  const clientTitle = getHolderName(state, (_a = item == null ? void 0 : item._extend) == null ? void 0 : _a.holder_id);
145
146
  let resourceItem = {};
@@ -159,6 +160,7 @@ var formatProducts = (lists, state) => {
159
160
  num: item == null ? void 0 : item._extend.quantity,
160
161
  bundle: (_d = (_c = item == null ? void 0 : item._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle,
161
162
  options: (_f = (_e = item == null ? void 0 : item._extend) == null ? void 0 : _e.other) == null ? void 0 : _f.option,
163
+ product_option_string: (_h = (_g = item == null ? void 0 : item._extend) == null ? void 0 : _g.other) == null ? void 0 : _h.product_option_string,
162
164
  _showAction: false,
163
165
  _actionText: import_utils2.locales.getText("page.booking.text.add-time"),
164
166
  _errorMessage: errorMessage,
@@ -167,7 +169,7 @@ var formatProducts = (lists, state) => {
167
169
  date: !_isAppointment ? null : state == null ? void 0 : state.date,
168
170
  relation_form_name: !_isAppointment ? "" : (resourceItem == null ? void 0 : resourceItem.labelText) || item.relation_form_name,
169
171
  holder_title: clientTitle,
170
- resource: !_isAppointment ? null : (_g = item == null ? void 0 : item._extend) == null ? void 0 : _g.resource,
172
+ resource: !_isAppointment ? null : (_i = item == null ? void 0 : item._extend) == null ? void 0 : _i.resource,
171
173
  relation_details: []
172
174
  }
173
175
  };
@@ -5,5 +5,5 @@ export interface InfoProps {
5
5
  globalState: any;
6
6
  setGlobalState: any;
7
7
  }
8
- declare const Payments: (props: any) => any;
8
+ declare const Payments: any;
9
9
  export default Payments;
@@ -571,11 +571,19 @@ var getProductTotalPrice = (item) => {
571
571
  let price = 0;
572
572
  price += Number(item._extend.price);
573
573
  let other = (_a = item._extend) == null ? void 0 : _a.other;
574
+ if (other == null ? void 0 : other.product_variant_id) {
575
+ price = Number(other == null ? void 0 : other.price);
576
+ }
574
577
  if (other == null ? void 0 : other.bundle) {
575
578
  price = other == null ? void 0 : other.bundle.reduce((accumulator, currentValue) => {
576
579
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
577
580
  }, price);
578
581
  }
582
+ if (other == null ? void 0 : other.option) {
583
+ price = other == null ? void 0 : other.option.reduce((accumulator, currentValue) => {
584
+ return accumulator + Number(currentValue.price) * Number(currentValue.num);
585
+ }, price);
586
+ }
579
587
  price = price;
580
588
  return price;
581
589
  };
@@ -19,7 +19,7 @@ export declare const useStoreRef: <T extends {
19
19
  readonly netRef: React.MutableRefObject<boolean | undefined>;
20
20
  readonly symbolRef: React.MutableRefObject<string>;
21
21
  readonly amountRef: React.MutableRefObject<string | number>;
22
- readonly eftposRef: React.MutableRefObject<"payo" | "tyro" | "windcave" | "stripe">;
22
+ readonly eftposRef: React.MutableRefObject<"windcave" | "tyro" | "payo" | "stripe">;
23
23
  readonly clientRef: React.MutableRefObject<ClientEnum>;
24
24
  };
25
25
  /**
@@ -74,7 +74,7 @@ var Product = (props) => {
74
74
  return /* @__PURE__ */ import_react.default.createElement(
75
75
  import_materials.ProductCard,
76
76
  {
77
- key: item.id,
77
+ key: item._id,
78
78
  dataSource: item,
79
79
  onAction: (e) => onAction == null ? void 0 : onAction(e),
80
80
  onDelete: (e) => handleChange(e, "delete"),
@@ -50,9 +50,9 @@ var Cart = () => {
50
50
  var _a, _b;
51
51
  return {
52
52
  ...item,
53
- label: /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__shopping-cart-label" }, `${item == null ? void 0 : item.label} ${(item == null ? void 0 : item.key) > 0 ? import_utils.locales.getText("pisell2.text.shopping-cart.item")(
54
- (_a = item == null ? void 0 : item.products) == null ? void 0 : _a.length
55
- ) : ""}`),
53
+ label: /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__shopping-cart-label" }, `${item == null ? void 0 : item.label} ${import_utils.locales.getText(
54
+ "pisell2.text.shopping-cart.item"
55
+ )((_a = item == null ? void 0 : item.products) == null ? void 0 : _a.length)}`),
56
56
  children: ((_b = item == null ? void 0 : item.products) == null ? void 0 : _b.length) > 0 ? /* @__PURE__ */ import_react.default.createElement(import_Product.default, { id: item == null ? void 0 : item.key, lists: item == null ? void 0 : item.products }) : /* @__PURE__ */ import_react.default.createElement(import_Empty.default, { id: item == null ? void 0 : item.key }),
57
57
  showArrow: platform === "shop"
58
58
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.198",
3
+ "version": "3.0.200",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -60,9 +60,9 @@
60
60
  "rc-virtual-list": "^3.11.3",
61
61
  "decimal.js": "^10.4.3",
62
62
  "@pisell/utils": "1.0.42",
63
- "@pisell/materials": "3.0.58",
64
63
  "@pisell/icon": "0.0.11",
65
- "@pisell/date-picker": "3.0.1"
64
+ "@pisell/date-picker": "3.0.1",
65
+ "@pisell/materials": "3.0.60"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": "^18.0.0",