@pisell/private-materials 6.4.70 → 6.4.72

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 (111) 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 +8 -8
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +7 -7
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +7 -7
  11. package/es/components/booking/addons/model.d.ts +1 -10
  12. package/es/components/booking/components/footer/amount.js +25 -8
  13. package/es/components/booking/components/footer/utils.d.ts +7 -0
  14. package/es/components/booking/components/footer/utils.js +46 -22
  15. package/es/components/booking/forms/model.d.ts +1 -10
  16. package/es/components/booking/hooks/useQuotation.js +69 -21
  17. package/es/components/booking/info/model.d.ts +1 -10
  18. package/es/components/booking/info/service/Lists.js +1 -1
  19. package/es/components/booking/info/service/addService/utils.d.ts +1 -1
  20. package/es/components/booking/info/service/serve.d.ts +14 -0
  21. package/es/components/booking/info/service/serve.js +22 -1
  22. package/es/components/booking/info/service2/Group/utils.js +2 -0
  23. package/es/components/booking/info/service2/utils.d.ts +1 -33
  24. package/es/components/booking/info/service2/utils.js +75 -29
  25. package/es/components/booking/info/utils.js +5 -0
  26. package/es/components/booking/info2/service/addService/index.js +146 -89
  27. package/es/components/booking/info2/service/addService/utils.d.ts +9 -1
  28. package/es/components/booking/info2/service/addService/utils.js +78 -9
  29. package/es/components/booking/info2/service/editService/index.js +235 -55
  30. package/es/components/booking/info2/utilsByBooking.js +14 -5
  31. package/es/components/booking/model.d.ts +1 -9
  32. package/es/components/booking/notes/model.d.ts +1 -10
  33. package/es/components/booking/payments/model.d.ts +1 -10
  34. package/es/components/booking/utils.d.ts +9 -1
  35. package/es/components/booking/utils.js +23 -0
  36. package/es/components/eftposPay/hooks.d.ts +1 -1
  37. package/es/components/eftposPay/store/index.d.ts +2 -2
  38. package/es/components/pay/toC/model.d.ts +1 -9
  39. package/es/components/schedules/model.d.ts +1 -9
  40. package/es/components/ticketBooking/components/addServiceVariant/MultiDayTimeSelectModal.d.ts +18 -0
  41. package/es/components/ticketBooking/components/addServiceVariant/MultiDayTimeSelectModal.js +119 -0
  42. package/es/components/ticketBooking/components/addServiceVariant/MultiDayTimeSelectModal.less +0 -0
  43. package/es/components/ticketBooking/components/addServiceVariant/addService.js +283 -138
  44. package/es/components/ticketBooking/components/ticketBooking/index.js +14 -11
  45. package/es/components/ticketBooking/hooks/pisellos/useProducts.js +106 -32
  46. package/es/components/ticketBooking/utils/index.d.ts +6 -1
  47. package/es/components/ticketBooking/utils/index.js +21 -3
  48. package/es/components/wallet/Detail/model.d.ts +1 -13
  49. package/es/components/wallet/DiscountCard/model.d.ts +1 -14
  50. package/es/components/wallet/PointCard/model.d.ts +1 -13
  51. package/es/components/wallet/RechargeableCard/model.d.ts +1 -29
  52. package/es/components/wallet/Voucher/model.d.ts +1 -13
  53. package/es/components/wallet/model.d.ts +1 -9
  54. package/es/pro/multiDayTimeSelect/MultiDayTimeSelect.d.ts +9 -0
  55. package/es/pro/multiDayTimeSelect/MultiDayTimeSelect.js +355 -0
  56. package/es/pro/multiDayTimeSelect/MultiDayTimeSelect.less +8 -0
  57. package/es/pro/multiDayTimeSelect/index.d.ts +3 -0
  58. package/es/pro/multiDayTimeSelect/index.js +1 -0
  59. package/es/pro/multiDayTimeSelect/types.d.ts +28 -0
  60. package/es/pro/multiDayTimeSelect/types.js +1 -0
  61. package/lib/components/booking/addons/model.d.ts +1 -10
  62. package/lib/components/booking/components/footer/amount.js +23 -6
  63. package/lib/components/booking/components/footer/utils.d.ts +7 -0
  64. package/lib/components/booking/components/footer/utils.js +23 -11
  65. package/lib/components/booking/forms/model.d.ts +1 -10
  66. package/lib/components/booking/hooks/useQuotation.js +45 -13
  67. package/lib/components/booking/info/model.d.ts +1 -10
  68. package/lib/components/booking/info/service/Lists.js +1 -1
  69. package/lib/components/booking/info/service/addService/utils.d.ts +1 -1
  70. package/lib/components/booking/info/service/serve.d.ts +14 -0
  71. package/lib/components/booking/info/service/serve.js +5 -0
  72. package/lib/components/booking/info/service2/Group/utils.js +2 -0
  73. package/lib/components/booking/info/service2/utils.d.ts +1 -33
  74. package/lib/components/booking/info/service2/utils.js +24 -10
  75. package/lib/components/booking/info/utils.js +4 -0
  76. package/lib/components/booking/info2/service/addService/index.js +22 -3
  77. package/lib/components/booking/info2/service/addService/utils.d.ts +9 -1
  78. package/lib/components/booking/info2/service/addService/utils.js +47 -9
  79. package/lib/components/booking/info2/service/editService/index.js +191 -31
  80. package/lib/components/booking/info2/utilsByBooking.js +19 -8
  81. package/lib/components/booking/model.d.ts +1 -9
  82. package/lib/components/booking/notes/model.d.ts +1 -10
  83. package/lib/components/booking/payments/model.d.ts +1 -10
  84. package/lib/components/booking/utils.d.ts +9 -1
  85. package/lib/components/booking/utils.js +15 -0
  86. package/lib/components/eftposPay/hooks.d.ts +1 -1
  87. package/lib/components/eftposPay/store/index.d.ts +2 -2
  88. package/lib/components/pay/toC/model.d.ts +1 -9
  89. package/lib/components/schedules/model.d.ts +1 -9
  90. package/lib/components/ticketBooking/components/addServiceVariant/MultiDayTimeSelectModal.d.ts +18 -0
  91. package/lib/components/ticketBooking/components/addServiceVariant/MultiDayTimeSelectModal.js +118 -0
  92. package/lib/components/ticketBooking/components/addServiceVariant/MultiDayTimeSelectModal.less +0 -0
  93. package/lib/components/ticketBooking/components/addServiceVariant/addService.js +185 -119
  94. package/lib/components/ticketBooking/components/ticketBooking/index.js +0 -16
  95. package/lib/components/ticketBooking/hooks/pisellos/useProducts.js +54 -9
  96. package/lib/components/ticketBooking/utils/index.d.ts +6 -1
  97. package/lib/components/ticketBooking/utils/index.js +11 -1
  98. package/lib/components/wallet/Detail/model.d.ts +1 -13
  99. package/lib/components/wallet/DiscountCard/model.d.ts +1 -14
  100. package/lib/components/wallet/PointCard/model.d.ts +1 -13
  101. package/lib/components/wallet/RechargeableCard/model.d.ts +1 -29
  102. package/lib/components/wallet/Voucher/model.d.ts +1 -13
  103. package/lib/components/wallet/model.d.ts +1 -9
  104. package/lib/pro/multiDayTimeSelect/MultiDayTimeSelect.d.ts +9 -0
  105. package/lib/pro/multiDayTimeSelect/MultiDayTimeSelect.js +304 -0
  106. package/lib/pro/multiDayTimeSelect/MultiDayTimeSelect.less +8 -0
  107. package/lib/pro/multiDayTimeSelect/index.d.ts +3 -0
  108. package/lib/pro/multiDayTimeSelect/index.js +35 -0
  109. package/lib/pro/multiDayTimeSelect/types.d.ts +28 -0
  110. package/lib/pro/multiDayTimeSelect/types.js +17 -0
  111. package/package.json +4 -4
@@ -0,0 +1,118 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/components/ticketBooking/components/addServiceVariant/MultiDayTimeSelectModal.tsx
30
+ var MultiDayTimeSelectModal_exports = {};
31
+ __export(MultiDayTimeSelectModal_exports, {
32
+ default: () => MultiDayTimeSelectModal_default
33
+ });
34
+ module.exports = __toCommonJS(MultiDayTimeSelectModal_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_dayjs = __toESM(require("dayjs"));
37
+ var import_materials = require("@pisell/materials");
38
+ var import_utils = require("@pisell/utils");
39
+ var import_multiDayTimeSelect = __toESM(require("../../../../pro/multiDayTimeSelect"));
40
+ var import_MultiDayTimeSelectModal = require("./MultiDayTimeSelectModal.less");
41
+ var MultiDayTimeSelectModal = ({
42
+ open,
43
+ productName,
44
+ locale = "en",
45
+ defaultStartDate,
46
+ loading = false,
47
+ maxDays = 30,
48
+ separateStartEnd = false,
49
+ onConfirm,
50
+ onCancel
51
+ }) => {
52
+ const [value, setValue] = (0, import_react.useState)(null);
53
+ const formRef = (0, import_react.useRef)(null);
54
+ (0, import_react.useEffect)(() => {
55
+ if (open) {
56
+ const startDate = defaultStartDate || (0, import_dayjs.default)();
57
+ const endDate = startDate.add(1, "day");
58
+ const initialValue = {
59
+ startDate,
60
+ endDate,
61
+ duration: 1
62
+ };
63
+ setValue(initialValue);
64
+ }
65
+ }, [open, defaultStartDate]);
66
+ const handleChange = (newValue) => {
67
+ setValue(newValue);
68
+ };
69
+ const handleConfirm = async () => {
70
+ var _a;
71
+ try {
72
+ await ((_a = formRef.current) == null ? void 0 : _a.validate());
73
+ if (value) {
74
+ onConfirm(value.startDate, value.endDate, value.duration);
75
+ }
76
+ } catch (error) {
77
+ }
78
+ };
79
+ const handleCancel = () => {
80
+ if (loading) return;
81
+ onCancel();
82
+ };
83
+ return /* @__PURE__ */ import_react.default.createElement(
84
+ import_materials.PisellModal,
85
+ {
86
+ open,
87
+ title: productName || import_utils.locales.getText("pisell2.text.product_name"),
88
+ onCancel: handleCancel,
89
+ onOk: handleConfirm,
90
+ okText: import_utils.locales.getText("pisell2.text.confirm"),
91
+ cancelText: import_utils.locales.getText("pisell2.text.cancel"),
92
+ width: 600,
93
+ destroyOnClose: true,
94
+ confirmLoading: loading,
95
+ closable: !loading,
96
+ maskClosable: !loading,
97
+ headerDivider: false,
98
+ footerDivider: false,
99
+ cancelButtonProps: {
100
+ disabled: loading
101
+ }
102
+ },
103
+ /* @__PURE__ */ import_react.default.createElement(
104
+ import_multiDayTimeSelect.default,
105
+ {
106
+ ref: formRef,
107
+ maxDays,
108
+ defaultStartDate,
109
+ separateStartEnd,
110
+ value: value || void 0,
111
+ onChange: handleChange,
112
+ locale,
113
+ disabled: loading
114
+ }
115
+ )
116
+ );
117
+ };
118
+ var MultiDayTimeSelectModal_default = MultiDayTimeSelectModal;
@@ -50,6 +50,8 @@ var import_pisellos = require("../../hooks/pisellos");
50
50
  var import_utils7 = require("./utils");
51
51
  var import_materials = require("@pisell/materials");
52
52
  var import_IsActiveContext = require("../../context/IsActiveContext");
53
+ var import_utils8 = require("../../../booking/info/service2/Group/utils");
54
+ var import_MultiDayTimeSelectModal = __toESM(require("./MultiDayTimeSelectModal"));
53
55
  var productListLayout = {
54
56
  grid: true,
55
57
  config: "12:12"
@@ -89,6 +91,9 @@ var AddSerivce = (props) => {
89
91
  );
90
92
  const [currentProduct, setCurrentProduct] = (0, import_react.useState)(null);
91
93
  const [firstLoading, setFirstLoading] = (0, import_react.useState)(true);
94
+ const [multiDayModalOpen, setMultiDayModalOpen] = (0, import_react.useState)(false);
95
+ const [multiDayModalLoading, setMultiDayModalLoading] = (0, import_react.useState)(false);
96
+ const [pendingMultiDayData, setPendingMultiDayData] = (0, import_react.useState)(null);
92
97
  const stateRef = (0, import_react.useRef)(state);
93
98
  stateRef.current = state;
94
99
  const { getProducts, products, loading } = (0, import_pisellos.useProducts)(notAvailableRef);
@@ -194,10 +199,161 @@ var AddSerivce = (props) => {
194
199
  }, 0);
195
200
  }
196
201
  );
202
+ const processAddService = (0, import_ahooks.useMemoizedFn)(async (item, _detail, e, notShowToast, startDate, endDate) => {
203
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
204
+ const other = JSON.parse(JSON.stringify(e));
205
+ other.session = e.session;
206
+ let cacheItem = {
207
+ ..._detail,
208
+ product_id: item.id,
209
+ _id: (0, import_utils.getUniqueId)(),
210
+ _key: e.key,
211
+ _extend: {
212
+ start_date: startDate,
213
+ quantity: (e == null ? void 0 : e.quantity) || 1,
214
+ price: _detail.price,
215
+ product_name: item.title,
216
+ other,
217
+ end_date: endDate
218
+ },
219
+ new: 1
220
+ };
221
+ let _total = (0, import_utils2.getProductTotalPrice)(cacheItem);
222
+ cacheItem._extend.total = _total;
223
+ cacheItem._extend.origin_total = _total;
224
+ const _isEdit = !!stateRef.current.service.cacheItem;
225
+ if (_isEdit) {
226
+ cacheItem._id = (_a2 = stateRef.current.service.cacheItem) == null ? void 0 : _a2._id;
227
+ cacheItem.new = 0;
228
+ }
229
+ if (renderMode === "current") {
230
+ cacheItem.currentDefaultTime = stateRef.current.date.value.format("HH:mm");
231
+ }
232
+ cacheItem = (0, import_utils3.getProductExtend)({
233
+ cacheItem,
234
+ state: stateRef.current,
235
+ isDisabledTime: true
236
+ });
237
+ const isMultiDay = (0, import_utils3.isMultiDayProduct)(cacheItem);
238
+ const getMultiDayCacheItem = async (isConcatBookings) => {
239
+ cacheItem = await (0, import_utils3.getMultiDay)({
240
+ start_date: cacheItem._extend.start_date,
241
+ end_date: cacheItem._extend.end_date,
242
+ state: stateRef.current,
243
+ cacheItem
244
+ });
245
+ cacheItem = (0, import_utils8.createBookingItemsByGroup)(cacheItem);
246
+ if (isConcatBookings) {
247
+ cacheItem = (0, import_utils8.concatBookings)(cacheItem);
248
+ }
249
+ };
250
+ if (stateRef.current.renderType === "eventBooking") {
251
+ cacheItem.autoClose = false;
252
+ }
253
+ if (cacheItem.autoClose) {
254
+ cacheItem.autoClose = false;
255
+ cacheItem._serviceKey = (0, import_utils6.genServiceKey)(cacheItem);
256
+ if (isMultiDay) {
257
+ await getMultiDayCacheItem();
258
+ }
259
+ let { list: _list, quantity } = (0, import_utils6.addService)(
260
+ [...stateRef.current.service.value],
261
+ cacheItem,
262
+ stateRef.current,
263
+ isMultiDay
264
+ );
265
+ if (!notShowToast) {
266
+ handleAddToast(cacheItem.title, quantity || 1);
267
+ }
268
+ window.dispatchEvent(
269
+ new CustomEvent("onAddNewService", {
270
+ detail: {
271
+ cacheItem
272
+ }
273
+ })
274
+ );
275
+ try {
276
+ if (((_f2 = (_e2 = (_d2 = (_c2 = (_b2 = context.appHelper.utils.store) == null ? void 0 : _b2.getState) == null ? void 0 : _c2.call(_b2)) == null ? void 0 : _d2.global) == null ? void 0 : _e2.globalConfig) == null ? void 0 : _f2.id) === 2155) {
277
+ const val = _list == null ? void 0 : _list.map((s) => {
278
+ return {
279
+ product_id: s == null ? void 0 : s.product_id,
280
+ detailId: s == null ? void 0 : s.id,
281
+ detailProductId: s == null ? void 0 : s.product_id,
282
+ product_name: s == null ? void 0 : s.title,
283
+ price: s == null ? void 0 : s.price,
284
+ _id: s == null ? void 0 : s._id,
285
+ _key: s == null ? void 0 : s._key,
286
+ _serviceKey: s == null ? void 0 : s._serviceKey
287
+ };
288
+ });
289
+ const sendData = {
290
+ product_id: item == null ? void 0 : item.id,
291
+ detailId: _detail == null ? void 0 : _detail.id,
292
+ detailProductId: _detail == null ? void 0 : _detail.product_id,
293
+ product_name: item == null ? void 0 : item.title,
294
+ price: _detail == null ? void 0 : _detail.price,
295
+ serviceVal: val
296
+ };
297
+ (0, import_utils.sendWarningLog)({
298
+ title: "addService",
299
+ content: [
300
+ { key: "添加数据", value: JSON.stringify(sendData) },
301
+ {
302
+ key: "日期",
303
+ value: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
304
+ }
305
+ ]
306
+ });
307
+ }
308
+ } catch (error) {
309
+ }
310
+ dispatch({
311
+ type: "setService",
312
+ payload: {
313
+ addModal: false,
314
+ value: _list,
315
+ edit: true,
316
+ changeService: false
317
+ }
318
+ });
319
+ } else {
320
+ (_g2 = window.openBookingEditModal) == null ? void 0 : _g2.call(window);
321
+ if (isMultiDay) {
322
+ await getMultiDayCacheItem(true);
323
+ }
324
+ dispatch({
325
+ type: "setService",
326
+ payload: {
327
+ editModal: true,
328
+ cacheItem,
329
+ addModal: !cacheItem.autoClose,
330
+ changeService: false
331
+ }
332
+ });
333
+ onEdit == null ? void 0 : onEdit(cacheItem);
334
+ }
335
+ });
336
+ const handleMultiDayConfirm = (0, import_ahooks.useMemoizedFn)(async (startDate, endDate, duration) => {
337
+ if (!pendingMultiDayData) return;
338
+ setMultiDayModalLoading(true);
339
+ try {
340
+ const { item, detail, e, notShowToast } = pendingMultiDayData;
341
+ await processAddService(item, detail, e, notShowToast, startDate, endDate);
342
+ setPendingMultiDayData(null);
343
+ setMultiDayModalOpen(false);
344
+ } catch (error) {
345
+ console.error("添加跨日商品失败:", error);
346
+ } finally {
347
+ setMultiDayModalLoading(false);
348
+ }
349
+ });
350
+ const handleMultiDayCancel = (0, import_ahooks.useMemoizedFn)(() => {
351
+ setMultiDayModalOpen(false);
352
+ setPendingMultiDayData(null);
353
+ });
197
354
  const handleSelectProduct = (0, import_ahooks.useMemoizedFn)(
198
355
  (item, type = "select") => {
199
356
  var _a2, _b2, _c2, _d2;
200
- console.log("handleSelectProduct");
201
357
  if (!(0, import_utils4.isNormalProductByDurationSchedule)(item)) {
202
358
  if (!Array.isArray((_a2 = state.service) == null ? void 0 : _a2.resourcesOrigin) || !state.service.resourcesOrigin.length) {
203
359
  dispatch({
@@ -236,7 +392,7 @@ var AddSerivce = (props) => {
236
392
  }
237
393
  }
238
394
  const callback = async (e, extension_type, detail, notShowToast) => {
239
- var _a3, _b3, _c3, _d3, _e2, _f2, _g2;
395
+ debugger;
240
396
  setCurrentProduct(null);
241
397
  if (lock) {
242
398
  return;
@@ -253,116 +409,18 @@ var AddSerivce = (props) => {
253
409
  return;
254
410
  }
255
411
  const _detail = detail || item;
256
- const other = JSON.parse(JSON.stringify(e));
257
- other.session = e.session;
258
- let cacheItem = {
259
- ..._detail,
260
- product_id: item.id,
261
- _id: (0, import_utils.getUniqueId)(),
262
- _key: e.key,
263
- _extend: {
264
- start_date: state.date.value,
265
- quantity: (e == null ? void 0 : e.quantity) || 1,
266
- price: _detail.price,
267
- product_name: item.title,
268
- other
269
- },
270
- new: 1
271
- };
272
- let _total = (0, import_utils2.getProductTotalPrice)(cacheItem);
273
- cacheItem._extend.total = _total;
274
- cacheItem._extend.origin_total = _total;
275
- const _isEdit = !!state.service.cacheItem;
276
- if (_isEdit) {
277
- cacheItem._id = (_a3 = state.service.cacheItem) == null ? void 0 : _a3._id;
278
- cacheItem.new = 0;
279
- }
280
- if (renderMode === "current") {
281
- cacheItem.currentDefaultTime = state.date.value.format("HH:mm");
282
- }
283
- cacheItem = (0, import_utils3.getProductExtend)({
284
- cacheItem,
285
- state,
286
- isDisabledTime: true
287
- });
288
- if (state.renderType === "eventBooking") {
289
- cacheItem.autoClose = false;
290
- }
291
- if (cacheItem.autoClose) {
292
- cacheItem.autoClose = false;
293
- cacheItem._serviceKey = (0, import_utils6.genServiceKey)(cacheItem);
294
- let { list: _list, quantity } = (0, import_utils6.addService)(
295
- [...stateRef.current.service.value],
296
- cacheItem,
297
- state
298
- );
299
- if (!notShowToast) {
300
- handleAddToast(cacheItem.title, quantity || 1);
301
- }
302
- window.dispatchEvent(
303
- new CustomEvent("onAddNewService", {
304
- detail: {
305
- cacheItem
306
- }
307
- })
308
- );
309
- try {
310
- if (((_f2 = (_e2 = (_d3 = (_c3 = (_b3 = context.appHelper.utils.store) == null ? void 0 : _b3.getState) == null ? void 0 : _c3.call(_b3)) == null ? void 0 : _d3.global) == null ? void 0 : _e2.globalConfig) == null ? void 0 : _f2.id) === 2155) {
311
- const val = _list == null ? void 0 : _list.map((s) => {
312
- return {
313
- product_id: s == null ? void 0 : s.product_id,
314
- detailId: s == null ? void 0 : s.id,
315
- detailProductId: s == null ? void 0 : s.product_id,
316
- product_name: s == null ? void 0 : s.title,
317
- price: s == null ? void 0 : s.price,
318
- _id: s == null ? void 0 : s._id,
319
- _key: s == null ? void 0 : s._key,
320
- _serviceKey: s == null ? void 0 : s._serviceKey
321
- };
322
- });
323
- const sendData = {
324
- product_id: item == null ? void 0 : item.id,
325
- detailId: _detail == null ? void 0 : _detail.id,
326
- detailProductId: _detail == null ? void 0 : _detail.product_id,
327
- product_name: item == null ? void 0 : item.title,
328
- price: _detail == null ? void 0 : _detail.price,
329
- serviceVal: val
330
- };
331
- (0, import_utils.sendWarningLog)({
332
- title: "addService",
333
- content: [
334
- { key: "添加数据", value: JSON.stringify(sendData) },
335
- {
336
- key: "日期",
337
- value: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
338
- }
339
- ]
340
- });
341
- }
342
- } catch (error) {
343
- }
344
- dispatch({
345
- type: "setService",
346
- payload: {
347
- addModal: false,
348
- value: _list,
349
- edit: true,
350
- changeService: false
351
- }
352
- });
353
- } else {
354
- (_g2 = window.openBookingEditModal) == null ? void 0 : _g2.call(window);
355
- dispatch({
356
- type: "setService",
357
- payload: {
358
- editModal: true,
359
- cacheItem,
360
- addModal: !cacheItem.autoClose,
361
- changeService: false
362
- }
412
+ const isMultiDay = (0, import_utils3.isMultiDayProduct)(_detail || item);
413
+ if (isMultiDay) {
414
+ setPendingMultiDayData({
415
+ item,
416
+ detail: _detail,
417
+ e,
418
+ notShowToast
363
419
  });
364
- onEdit == null ? void 0 : onEdit(cacheItem);
420
+ setMultiDayModalOpen(true);
421
+ return;
365
422
  }
423
+ await processAddService(item, _detail, e, notShowToast, state.date.value);
366
424
  };
367
425
  if (cacheValues) {
368
426
  const productId = item.id.toString();
@@ -412,13 +470,6 @@ var AddSerivce = (props) => {
412
470
  );
413
471
  const renderList = (0, import_react.useMemo)(() => {
414
472
  let _list = products || [];
415
- if ((0, import_utils4.isDaysBooking)(state)) {
416
- if (!(0, import_utils4.holderId)(state)) {
417
- _list = _list.filter(
418
- (item) => (0, import_utils4.isNormalProductByDurationSchedule)(item)
419
- );
420
- }
421
- }
422
473
  return _list;
423
474
  }, [products, state == null ? void 0 : state.activeCartId]);
424
475
  const currentDate = (0, import_react.useMemo)(() => {
@@ -453,6 +504,7 @@ var AddSerivce = (props) => {
453
504
  return resolvedConfig;
454
505
  }, [productDisplayConfig]);
455
506
  return (0, import_react.useMemo)(() => {
507
+ var _a2;
456
508
  if (renderMode === "current") {
457
509
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
458
510
  import_ProductDisplayAdapter.default,
@@ -463,7 +515,18 @@ var AddSerivce = (props) => {
463
515
  currentProductId: currentProduct == null ? void 0 : currentProduct.id,
464
516
  onSelectProduct: handleSelectProduct
465
517
  }
466
- ), /* @__PURE__ */ import_react.default.createElement(import_notAvailable.default, { ref: notAvailableRef }));
518
+ ), /* @__PURE__ */ import_react.default.createElement(import_notAvailable.default, { ref: notAvailableRef }), /* @__PURE__ */ import_react.default.createElement(
519
+ import_MultiDayTimeSelectModal.default,
520
+ {
521
+ open: multiDayModalOpen,
522
+ productName: (_a2 = pendingMultiDayData == null ? void 0 : pendingMultiDayData.item) == null ? void 0 : _a2.title,
523
+ locale: state == null ? void 0 : state.locale,
524
+ defaultStartDate: state.date.value,
525
+ loading: multiDayModalLoading,
526
+ onConfirm: handleMultiDayConfirm,
527
+ onCancel: handleMultiDayCancel
528
+ }
529
+ ));
467
530
  }
468
531
  return null;
469
532
  }, [
@@ -478,7 +541,10 @@ var AddSerivce = (props) => {
478
541
  loading,
479
542
  currentProduct,
480
543
  isBooking4,
481
- finalDisplayConfig
544
+ finalDisplayConfig,
545
+ multiDayModalOpen,
546
+ pendingMultiDayData,
547
+ multiDayModalLoading
482
548
  ]);
483
549
  };
484
550
  var addService_default = AddSerivce;
@@ -642,22 +642,6 @@ var TicketBooking = (props) => {
642
642
  }
643
643
  });
644
644
  setTimeout(() => {
645
- var _a2, _b2, _c2, _d2, _e2;
646
- if ((_b2 = (_a2 = state.modalState.service) == null ? void 0 : _a2.value) == null ? void 0 : _b2.length) {
647
- let _list = (_e2 = (_c2 = state.bookingFunctions) == null ? void 0 : _c2.updateServiceDate) == null ? void 0 : _e2.call(
648
- _c2,
649
- (_d2 = state.modalState.service) == null ? void 0 : _d2.value,
650
- date,
651
- false
652
- );
653
- _setModalState({
654
- service: {
655
- ...state.modalState.service,
656
- value: _list,
657
- edit: true
658
- }
659
- });
660
- }
661
645
  }, 100);
662
646
  };
663
647
  const _setShopOpeningHours = () => {
@@ -27,18 +27,24 @@ var import_bookingTicket = require("./bookingTicket");
27
27
  var import_react = require("react");
28
28
  var import_OsKeyContext = require("../../context/OsKeyContext");
29
29
  var import_productCache = require("../../utils/productCache");
30
+ var import_hooks = require("../../../../hooks");
31
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
30
32
  var useProducts = (notAvailableRef) => {
33
+ var _a;
31
34
  const bookingTicket = (0, import_bookingTicket.useBookingTicket)();
32
35
  const osKey = (0, import_OsKeyContext.useOsKey)();
33
36
  const [products, setProducts] = (0, import_react.useState)([]);
34
37
  const [loading, setLoading] = (0, import_react.useState)(true);
35
38
  const isFirstLoadRef = (0, import_react.useRef)(true);
36
39
  const isFirstLoadDataRef = (0, import_react.useRef)(true);
40
+ const context = (0, import_hooks.useEngineContext)();
41
+ const { getApp } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
42
+ const app = getApp();
37
43
  const getProducts = (0, import_ahooks.useMemoizedFn)(async (params) => {
38
- var _a;
44
+ var _a2, _b, _c, _d, _e;
39
45
  if (isFirstLoadRef.current && osKey) {
40
46
  const cachedProducts = (0, import_productCache.getProductCache)(osKey);
41
- if (cachedProducts) {
47
+ if (cachedProducts && cachedProducts.length > 0) {
42
48
  setProducts(cachedProducts);
43
49
  setLoading(false);
44
50
  }
@@ -46,23 +52,62 @@ var useProducts = (notAvailableRef) => {
46
52
  } else {
47
53
  setLoading(true);
48
54
  }
49
- try {
50
- const freshProducts = await bookingTicket.loadProducts(params);
55
+ const maxRetries = 3;
56
+ let lastError = null;
57
+ let freshProducts = [];
58
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
59
+ try {
60
+ console.log(`[ProductCache] 尝试加载数据,第 ${attempt}/${maxRetries} 次`);
61
+ freshProducts = await bookingTicket.loadProducts(params);
62
+ if (freshProducts && freshProducts.length > 0) {
63
+ console.log(`[ProductCache] 第 ${attempt} 次尝试成功,获取到 ${freshProducts.length} 条数据`);
64
+ break;
65
+ }
66
+ console.log(`[ProductCache] 第 ${attempt} 次尝试返回空数据`);
67
+ if (attempt < maxRetries) {
68
+ console.log(`[ProductCache] 等待 1 秒后重试...`);
69
+ await sleep(1e3);
70
+ }
71
+ } catch (error) {
72
+ lastError = error;
73
+ console.log(`[ProductCache] 第 ${attempt} 次尝试失败:`, error);
74
+ (_b = (_a2 = app == null ? void 0 : app.logger) == null ? void 0 : _a2.addLog) == null ? void 0 : _b.call(_a2, {
75
+ type: "info",
76
+ title: `[getProduct] bookingTicket.loadProducts error (attempt ${attempt}/${maxRetries})`,
77
+ metadata: {
78
+ error,
79
+ attempt
80
+ }
81
+ });
82
+ if (attempt < maxRetries) {
83
+ console.log(`[ProductCache] 等待 1 秒后重试...`);
84
+ await sleep(1e3);
85
+ }
86
+ }
87
+ }
88
+ if (freshProducts && freshProducts.length > 0) {
51
89
  isFirstLoadDataRef.current = false;
52
90
  setProducts(freshProducts);
53
91
  if (osKey) {
54
92
  (0, import_productCache.setProductCache)(osKey, freshProducts);
55
93
  console.log("[ProductCache] 已更新缓存");
56
94
  }
57
- } catch (error) {
58
- if ((error == null ? void 0 : error.code) === 607100 && (isFirstLoadDataRef.current || products.length > 0)) {
59
- (_a = notAvailableRef.current) == null ? void 0 : _a.open();
95
+ setLoading(false);
96
+ } else {
97
+ console.log("[ProductCache] 3次尝试后仍未获取到数据");
98
+ (_d = (_c = app == null ? void 0 : app.logger) == null ? void 0 : _c.addLog) == null ? void 0 : _d.call(_c, {
99
+ type: "error",
100
+ title: "[getProduct] 3次尝试后仍未获取到数据",
101
+ metadata: {
102
+ error: lastError
103
+ }
104
+ });
105
+ if ((lastError == null ? void 0 : lastError.code) === 607100 && (isFirstLoadDataRef.current || products.length > 0)) {
106
+ (_e = notAvailableRef.current) == null ? void 0 : _e.open();
60
107
  }
61
108
  setLoading(false);
62
109
  setProducts([]);
63
110
  isFirstLoadDataRef.current = false;
64
- } finally {
65
- setLoading(false);
66
111
  }
67
112
  });
68
113
  return {
@@ -15,9 +15,14 @@ export declare const restoreProductOtherData: (data: any) => {
15
15
  quantity: number;
16
16
  } | undefined;
17
17
  export declare const isSameProduct: (a: any, b: any) => boolean;
18
- export declare const addService: (list: any[], addItem: any, state: any) => {
18
+ export declare const addService: (list: any[], addItem: any, state: any, isMultiDay?: boolean) => {
19
+ list: any[];
20
+ count: number;
21
+ quantity?: undefined;
22
+ } | {
19
23
  list: any[];
20
24
  quantity: any;
25
+ count?: undefined;
21
26
  };
22
27
  export declare const addServiceScroll: (rowKey: string, cacheItem: any) => void;
23
28
  export declare const getCartProductOverlay: (state: any) => any;
@@ -68,6 +68,7 @@ module.exports = __toCommonJS(utils_exports);
68
68
  var import_dayjs = __toESM(require("dayjs"));
69
69
  var import_utils = require("../../booking/info/service2/utils");
70
70
  var import_utils2 = require("@pisell/utils");
71
+ var import_utils3 = require("../../booking/info2/service/addService/utils");
71
72
  var import_productCache = require("./productCache");
72
73
  var formatDateToStr = (date) => {
73
74
  const format = (val) => {
@@ -170,9 +171,15 @@ var isSameProduct = (a, b) => {
170
171
  }
171
172
  return ((_f = (_e = a._extend) == null ? void 0 : _e.other) == null ? void 0 : _f.rowKey) === ((_h = (_g = b._extend) == null ? void 0 : _g.other) == null ? void 0 : _h.rowKey) && a._serviceKey === b._serviceKey;
172
173
  };
173
- var addService = (list, addItem, state) => {
174
+ var addService = (list, addItem, state, isMultiDay) => {
174
175
  let value = list;
175
176
  let count;
177
+ if (isMultiDay && (0, import_utils2.isArr)(addItem)) {
178
+ return {
179
+ list: [...addItem, ...value],
180
+ count: 1
181
+ };
182
+ }
176
183
  if (!(0, import_utils.isNormalProductByDurationSchedule)(addItem) && !getIsOverlayProduct(addItem, state)) {
177
184
  value.unshift(addItem);
178
185
  count = addItem._extend.quantity;
@@ -248,6 +255,9 @@ var getIsOverlayProduct = (item, state) => {
248
255
  };
249
256
  var getIsShowNumber = (item, state) => {
250
257
  const isBookingTicket2 = state.isBookingTicket2;
258
+ if ((0, import_utils3.isMultiDayProduct)(item)) {
259
+ return false;
260
+ }
251
261
  return (0, import_utils.isNormalProductByDurationSchedule)(item) || isBookingTicket2 && getIsOverlayProduct(item, state);
252
262
  };
253
263
  var genServiceKey = (item) => {
@@ -1,13 +1 @@
1
- /// <reference types="react" />
2
- interface RechargeState {
3
- addWalletCard: any;
4
- }
5
- export declare const Provider: (ComponentUi: any) => any, Context: import("react").Context<{
6
- walletDetailState: RechargeState;
7
- } & {
8
- dispatch: (params: {
9
- type: string;
10
- payload: any;
11
- }) => void;
12
- }>;
13
- export {};
1
+ export declare const Provider: any, Context: any;