@pisell/pisellos 3.0.4 → 3.0.6

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 (189) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +20 -1
  5. package/dist/modules/AccountList/index.js +243 -75
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +8 -5
  13. package/dist/modules/Cart/index.js +101 -25
  14. package/dist/modules/Cart/types.d.ts +82 -5
  15. package/dist/modules/Cart/types.js +22 -0
  16. package/dist/modules/Cart/utils.d.ts +106 -13
  17. package/dist/modules/Cart/utils.js +289 -76
  18. package/dist/modules/Date/index.d.ts +6 -6
  19. package/dist/modules/Date/index.js +41 -58
  20. package/dist/modules/Date/types.d.ts +22 -6
  21. package/dist/modules/Date/utils.d.ts +4 -3
  22. package/dist/modules/Date/utils.js +81 -30
  23. package/dist/modules/Discount/index.d.ts +4 -4
  24. package/dist/modules/Discount/index.js +11 -11
  25. package/dist/modules/Order/index.d.ts +11 -5
  26. package/dist/modules/Order/index.js +47 -18
  27. package/dist/modules/Order/types.d.ts +10 -3
  28. package/dist/modules/Order/utils.d.ts +10 -0
  29. package/dist/modules/Order/utils.js +15 -0
  30. package/dist/modules/Product/index.d.ts +14 -1
  31. package/dist/modules/Product/index.js +35 -0
  32. package/dist/modules/Product/types.d.ts +27 -3
  33. package/dist/modules/ProductList/index.js +11 -5
  34. package/dist/modules/Resource/types.d.ts +1 -0
  35. package/dist/modules/Resource/utils.js +1 -1
  36. package/dist/modules/Rules/index.d.ts +3 -3
  37. package/dist/modules/Rules/index.js +121 -53
  38. package/dist/modules/Rules/types.d.ts +5 -1
  39. package/dist/modules/Schedule/index.d.ts +18 -0
  40. package/dist/modules/Schedule/index.js +111 -0
  41. package/dist/modules/Schedule/type.d.ts +157 -0
  42. package/dist/modules/Schedule/type.js +1 -0
  43. package/dist/modules/Schedule/types.d.ts +182 -0
  44. package/dist/modules/Schedule/types.js +1 -0
  45. package/dist/modules/Schedule/utils.d.ts +67 -0
  46. package/dist/modules/Schedule/utils.js +729 -0
  47. package/dist/modules/Step/index.d.ts +14 -3
  48. package/dist/modules/Step/index.js +54 -2
  49. package/dist/modules/Summary/index.d.ts +12 -5
  50. package/dist/modules/Summary/index.js +33 -7
  51. package/dist/modules/Summary/types.d.ts +23 -2
  52. package/dist/modules/Summary/utils.d.ts +14 -4
  53. package/dist/modules/Summary/utils.js +46 -4
  54. package/dist/modules/index.d.ts +10 -0
  55. package/dist/modules/index.js +11 -1
  56. package/dist/plugins/index.d.ts +3 -3
  57. package/dist/plugins/request.d.ts +3 -3
  58. package/dist/plugins/request.js +30 -30
  59. package/dist/plugins/shopStore.d.ts +1 -1
  60. package/dist/solution/BookingByStep/index.d.ts +97 -24
  61. package/dist/solution/BookingByStep/index.js +1024 -322
  62. package/dist/solution/BookingByStep/types.d.ts +3 -10
  63. package/dist/solution/BookingByStep/types.js +11 -15
  64. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  65. package/dist/solution/BookingByStep/utils/products.js +3 -0
  66. package/dist/solution/BookingByStep/utils/resources.d.ts +60 -6
  67. package/dist/solution/BookingByStep/utils/resources.js +293 -52
  68. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  69. package/dist/solution/ShopDiscount/index.js +16 -16
  70. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  71. package/dist/solution/ShopDiscount/utils.js +1 -1
  72. package/lib/core/index.js +7 -2
  73. package/lib/modules/Account/index.d.ts +2 -6
  74. package/lib/modules/Account/index.js +15 -30
  75. package/lib/modules/Account/types.d.ts +12 -1
  76. package/lib/modules/AccountList/index.d.ts +20 -1
  77. package/lib/modules/AccountList/index.js +122 -13
  78. package/lib/modules/AccountList/types.d.ts +33 -1
  79. package/lib/modules/AccountList/utils.d.ts +9 -0
  80. package/lib/modules/AccountList/utils.js +39 -0
  81. package/lib/modules/BaseModule.d.ts +2 -2
  82. package/lib/modules/BaseModule.js +14 -3
  83. package/lib/modules/Cart/index.d.ts +8 -5
  84. package/lib/modules/Cart/index.js +81 -8
  85. package/lib/modules/Cart/types.d.ts +82 -5
  86. package/lib/modules/Cart/types.js +20 -2
  87. package/lib/modules/Cart/utils.d.ts +106 -13
  88. package/lib/modules/Cart/utils.js +188 -45
  89. package/lib/modules/Date/index.d.ts +6 -6
  90. package/lib/modules/Date/index.js +13 -28
  91. package/lib/modules/Date/types.d.ts +22 -6
  92. package/lib/modules/Date/utils.d.ts +4 -3
  93. package/lib/modules/Date/utils.js +47 -13
  94. package/lib/modules/Discount/index.d.ts +4 -4
  95. package/lib/modules/Discount/index.js +9 -2
  96. package/lib/modules/Guests/index.js +4 -1
  97. package/lib/modules/Order/index.d.ts +11 -5
  98. package/lib/modules/Order/index.js +24 -3
  99. package/lib/modules/Order/types.d.ts +10 -3
  100. package/lib/modules/Order/utils.d.ts +10 -0
  101. package/lib/modules/Order/utils.js +45 -0
  102. package/lib/modules/Payment/index.js +1 -6
  103. package/lib/modules/Product/index.d.ts +14 -1
  104. package/lib/modules/Product/index.js +19 -0
  105. package/lib/modules/Product/types.d.ts +27 -3
  106. package/lib/modules/ProductList/index.js +21 -7
  107. package/lib/modules/Resource/index.js +4 -1
  108. package/lib/modules/Resource/types.d.ts +1 -0
  109. package/lib/modules/Resource/utils.js +7 -4
  110. package/lib/modules/Rules/index.d.ts +3 -3
  111. package/lib/modules/Rules/index.js +118 -43
  112. package/lib/modules/Rules/types.d.ts +5 -1
  113. package/lib/modules/Schedule/index.d.ts +18 -0
  114. package/lib/modules/Schedule/index.js +81 -0
  115. package/lib/modules/Schedule/type.d.ts +157 -0
  116. package/lib/modules/Schedule/type.js +17 -0
  117. package/lib/modules/Schedule/types.d.ts +182 -0
  118. package/lib/modules/Schedule/types.js +17 -0
  119. package/lib/modules/Schedule/utils.d.ts +67 -0
  120. package/lib/modules/Schedule/utils.js +600 -0
  121. package/lib/modules/Step/index.d.ts +14 -3
  122. package/lib/modules/Step/index.js +38 -1
  123. package/lib/modules/Summary/index.d.ts +12 -5
  124. package/lib/modules/Summary/index.js +15 -1
  125. package/lib/modules/Summary/types.d.ts +23 -2
  126. package/lib/modules/Summary/utils.d.ts +14 -4
  127. package/lib/modules/Summary/utils.js +30 -1
  128. package/lib/modules/index.d.ts +10 -0
  129. package/lib/modules/index.js +21 -1
  130. package/lib/plugins/index.d.ts +3 -3
  131. package/lib/plugins/request.d.ts +3 -3
  132. package/lib/plugins/request.js +48 -11
  133. package/lib/plugins/shopStore.d.ts +1 -1
  134. package/lib/solution/BookingByStep/index.d.ts +97 -24
  135. package/lib/solution/BookingByStep/index.js +693 -145
  136. package/lib/solution/BookingByStep/types.d.ts +3 -10
  137. package/lib/solution/BookingByStep/types.js +37 -14
  138. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  139. package/lib/solution/BookingByStep/utils/products.js +3 -0
  140. package/lib/solution/BookingByStep/utils/resources.d.ts +60 -6
  141. package/lib/solution/BookingByStep/utils/resources.js +286 -54
  142. package/lib/solution/BuyTickets/index.js +34 -20
  143. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  144. package/lib/solution/ShopDiscount/index.js +10 -2
  145. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  146. package/package.json +4 -2
  147. package/dist/core/index.d.ts.map +0 -1
  148. package/dist/effects/index.d.ts.map +0 -1
  149. package/dist/index.d.ts.map +0 -1
  150. package/dist/modules/Account/index.d.ts.map +0 -1
  151. package/dist/modules/Account/types.d.ts.map +0 -1
  152. package/dist/modules/AccountList/types.d.ts.map +0 -1
  153. package/dist/modules/Cart/index.d.ts.map +0 -1
  154. package/dist/modules/Cart/types.d.ts.map +0 -1
  155. package/dist/modules/Date/types.d.ts.map +0 -1
  156. package/dist/modules/Date/utils.d.ts.map +0 -1
  157. package/dist/modules/Guests/index.d.ts.map +0 -1
  158. package/dist/modules/Guests/types.d.ts.map +0 -1
  159. package/dist/modules/Order/index.d.ts.map +0 -1
  160. package/dist/modules/Order/types.d.ts.map +0 -1
  161. package/dist/modules/Payment/index.d.ts.map +0 -1
  162. package/dist/modules/Payment/types.d.ts.map +0 -1
  163. package/dist/modules/Product/index.d.ts.map +0 -1
  164. package/dist/modules/Product/types.d.ts.map +0 -1
  165. package/dist/modules/ProductList/types.d.ts.map +0 -1
  166. package/dist/modules/Resource/index.d.ts.map +0 -1
  167. package/dist/modules/Resource/types.d.ts.map +0 -1
  168. package/dist/modules/Resource/utils.d.ts.map +0 -1
  169. package/dist/modules/Rules/types.d.ts.map +0 -1
  170. package/dist/modules/Step/index.d.ts.map +0 -1
  171. package/dist/modules/Step/tyeps.d.ts.map +0 -1
  172. package/dist/modules/Summary/index.d.ts.map +0 -1
  173. package/dist/modules/Summary/types.d.ts.map +0 -1
  174. package/dist/modules/Summary/utils.d.ts.map +0 -1
  175. package/dist/modules/index.d.ts.map +0 -1
  176. package/dist/plugins/index.d.ts.map +0 -1
  177. package/dist/plugins/request.d.ts.map +0 -1
  178. package/dist/plugins/shopStore.d.ts.map +0 -1
  179. package/dist/plugins/window.d.ts.map +0 -1
  180. package/dist/solution/BookingByStep/types.d.ts.map +0 -1
  181. package/dist/solution/BookingByStep/utils/products.d.ts.map +0 -1
  182. package/dist/solution/BuyTickets/index.d.ts.map +0 -1
  183. package/dist/solution/BuyTickets/types.d.ts.map +0 -1
  184. package/dist/solution/PlaceOrder/index.d.ts.map +0 -1
  185. package/dist/solution/ShopDiscount/types.d.ts.map +0 -1
  186. package/dist/solution/ShopDiscount/utils.d.ts.map +0 -1
  187. package/dist/solution/index.d.ts.map +0 -1
  188. package/dist/store/createStore.d.ts.map +0 -1
  189. package/dist/types/index.d.ts.map +0 -1
@@ -30,12 +30,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
32
  createCartItemOrigin: () => createCartItemOrigin,
33
+ deleteHolderFromCartItem: () => deleteHolderFromCartItem,
34
+ deleteRelationFormsFromCartItem: () => deleteRelationFormsFromCartItem,
33
35
  deleteResourceFromCartItem: () => deleteResourceFromCartItem,
34
36
  deleteTimeFromCartItem: () => deleteTimeFromCartItem,
35
37
  formatAccountToCartItem: () => formatAccountToCartItem,
36
38
  formatAccountToCartItemOrigin: () => formatAccountToCartItemOrigin,
37
39
  formatBundle: () => formatBundle,
38
40
  formatBundleToOrigin: () => formatBundleToOrigin,
41
+ formatDateToCartItem: () => formatDateToCartItem,
42
+ formatDateToCartItemOrigin: () => formatDateToCartItemOrigin,
39
43
  formatDiscountToCartItem: () => formatDiscountToCartItem,
40
44
  formatDiscountToCartItemOrigin: () => formatDiscountToCartItemOrigin,
41
45
  formatNoteToCartItem: () => formatNoteToCartItem,
@@ -44,15 +48,20 @@ __export(utils_exports, {
44
48
  formatOptionsToOrigin: () => formatOptionsToOrigin,
45
49
  formatProductToCartItem: () => formatProductToCartItem,
46
50
  formatProductToCartItemOrigin: () => formatProductToCartItemOrigin,
51
+ formatRelationFormsToCartItem: () => formatRelationFormsToCartItem,
52
+ formatRelationFormsToCartItemOrigin: () => formatRelationFormsToCartItemOrigin,
47
53
  formatResourceToCartItem: () => formatResourceToCartItem,
48
54
  formatResourceToCartItemOrigin: () => formatResourceToCartItemOrigin,
55
+ getProductDeposit: () => getProductDeposit,
49
56
  getProductOriginTotalPrice: () => getProductOriginTotalPrice,
50
57
  getProductTotalPrice: () => getProductTotalPrice,
51
58
  getUniqueId: () => getUniqueId,
59
+ handleProductDeposit: () => handleProductDeposit,
52
60
  isNormalProduct: () => isNormalProduct
53
61
  });
54
62
  module.exports = __toCommonJS(utils_exports);
55
63
  var import_dayjs = __toESM(require("dayjs"));
64
+ var import_decimal = __toESM(require("decimal.js"));
56
65
  var getUniqueId = (prefix = "", maxLength = 11) => {
57
66
  return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
58
67
  };
@@ -77,8 +86,8 @@ var createCartItemOrigin = () => {
77
86
  // 资源相关
78
87
  // 资源状态 -固定
79
88
  like_status: "common",
80
- // 资源类型
81
- relation_type: "",
89
+ // 资源类型 - 固定--谭景琳备注:马天宇说现在平行资源是不传这个的
90
+ // relation_type: "form",
82
91
  // 所选资源
83
92
  resources: null,
84
93
  // 日程id - 固定
@@ -94,20 +103,27 @@ var createCartItemOrigin = () => {
94
103
  // 所选结束时间
95
104
  end_date: null,
96
105
  // 额外信息
97
- metadata: {}
106
+ metadata: {},
98
107
  // holder相关
99
- // holder: null,
108
+ holder: null
100
109
  };
101
110
  };
102
111
  var formatProductToCartItem = (params) => {
112
+ var _a;
103
113
  const { cartItem, product, bundle, options } = params;
114
+ const num = 1;
104
115
  if (product) {
105
116
  cartItem.id = product == null ? void 0 : product.id;
106
117
  cartItem.name = product == null ? void 0 : product.title;
107
118
  cartItem.price = product == null ? void 0 : product.price;
108
- cartItem.total = getProductTotalPrice({ product, bundle, options });
109
- cartItem.origin_total = getProductOriginTotalPrice({ product, bundle, options });
110
- cartItem.num = 1;
119
+ cartItem.num = num;
120
+ cartItem.total = getProductTotalPrice({ product, bundle, options, num });
121
+ cartItem.origin_total = getProductOriginTotalPrice({
122
+ product,
123
+ bundle,
124
+ options,
125
+ num
126
+ });
111
127
  cartItem.image = product == null ? void 0 : product.cover;
112
128
  cartItem.like_status = "common";
113
129
  cartItem.duration = product == null ? void 0 : product.duration;
@@ -120,6 +136,15 @@ var formatProductToCartItem = (params) => {
120
136
  if (options == null ? void 0 : options.length) {
121
137
  cartItem.options = formatOptions(options);
122
138
  }
139
+ if (((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) == 1) {
140
+ cartItem.deposit = getProductDeposit({
141
+ cartItem,
142
+ product,
143
+ bundle,
144
+ options,
145
+ num
146
+ });
147
+ }
123
148
  const oringin = formatProductToCartItemOrigin(params);
124
149
  cartItem._origin = oringin;
125
150
  return cartItem;
@@ -179,7 +204,16 @@ var formatAccountToCartItemOrigin = (params) => {
179
204
  const { cartItem, account } = params;
180
205
  let origin = cartItem._origin;
181
206
  if (account) {
182
- origin.metadata.account = account;
207
+ if ((account == null ? void 0 : account.type) === "holder") {
208
+ const { customer_id, form_id, form_record_id } = (account == null ? void 0 : account._origin) || {};
209
+ origin.holder = {
210
+ customer_id,
211
+ form_id,
212
+ form_record: form_record_id ? [form_record_id] : null
213
+ };
214
+ } else {
215
+ origin.metadata.account = account;
216
+ }
183
217
  }
184
218
  return origin;
185
219
  };
@@ -213,18 +247,32 @@ var formatResourceToCartItemOrigin = (params) => {
213
247
  let origin = cartItem._origin;
214
248
  if (resources && (resources == null ? void 0 : resources.length)) {
215
249
  origin.resources = [];
216
- resources.forEach((resource) => {
217
- origin.resources.push({
218
- relation_type: "form",
219
- like_status: "common",
220
- id: resource.id,
221
- main_field: resource.main_field,
222
- resourceType: resource.resourceType,
223
- form_id: resource.form_id,
224
- relation_id: resource.id,
225
- capacity: (resource == null ? void 0 : resource.capacity) || 0
250
+ const checkResourcesFormat = (resources2, arr) => {
251
+ resources2.forEach((resource) => {
252
+ var _a;
253
+ const childArr = [];
254
+ if ((_a = resource == null ? void 0 : resource.children) == null ? void 0 : _a.length) {
255
+ checkResourcesFormat(resource.children, childArr);
256
+ }
257
+ const obj = {
258
+ relation_type: "form",
259
+ like_status: "common",
260
+ id: resource.id,
261
+ main_field: resource.main_field,
262
+ resourceType: resource.resourceType,
263
+ form_id: resource.form_id,
264
+ relation_id: resource.id,
265
+ capacity: (resource == null ? void 0 : resource.capacity) || 0,
266
+ metadata: (resource == null ? void 0 : resource.metadata) || {}
267
+ // 后端可以在这里挂一个前端用于计算的数据
268
+ };
269
+ if (childArr.length) {
270
+ obj.children = childArr;
271
+ }
272
+ arr.push(obj);
226
273
  });
227
- });
274
+ };
275
+ checkResourcesFormat(resources, origin.resources);
228
276
  const { startTime, endTime } = resources[0];
229
277
  if (startTime && endTime) {
230
278
  origin.select_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
@@ -243,34 +291,38 @@ var formatResourceToCartItemOrigin = (params) => {
243
291
  }
244
292
  return origin;
245
293
  };
246
- var deleteResourceFromCartItem = (cartItem) => {
247
- cartItem.resource_id = void 0;
248
- cartItem.relation_form_name = void 0;
249
- cartItem.start_date = void 0;
250
- cartItem.start_time = void 0;
251
- cartItem.end_date = void 0;
252
- cartItem.end_time = void 0;
253
- delete cartItem._resourceOrigin;
254
- cartItem._origin.resources = null;
255
- cartItem._origin.select_date = null;
256
- cartItem._origin.start_date = null;
257
- cartItem._origin.start_time = null;
258
- cartItem._origin.end_date = null;
259
- cartItem._origin.end_time = null;
294
+ var formatRelationFormsToCartItem = (params) => {
295
+ const { cartItem } = params;
296
+ const oringin = formatRelationFormsToCartItemOrigin(params);
297
+ cartItem._origin = oringin;
260
298
  return cartItem;
261
299
  };
262
- var deleteTimeFromCartItem = (cartItem) => {
263
- cartItem.start_date = void 0;
264
- cartItem.start_time = void 0;
265
- cartItem.end_date = void 0;
266
- cartItem.end_time = void 0;
267
- cartItem._origin.select_date = null;
268
- cartItem._origin.start_date = null;
269
- cartItem._origin.start_time = null;
270
- cartItem._origin.end_date = null;
271
- cartItem._origin.end_time = null;
300
+ var formatRelationFormsToCartItemOrigin = (params) => {
301
+ const { cartItem, relationForms } = params;
302
+ const origin = cartItem._origin;
303
+ origin.relation_forms = relationForms;
304
+ return origin;
305
+ };
306
+ var formatDateToCartItem = (params) => {
307
+ const { cartItem, date } = params;
308
+ cartItem.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
309
+ cartItem.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
310
+ cartItem.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
311
+ cartItem.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
312
+ const oringin = formatDateToCartItemOrigin(params);
313
+ cartItem._origin = oringin;
272
314
  return cartItem;
273
315
  };
316
+ var formatDateToCartItemOrigin = (params) => {
317
+ const { cartItem, date } = params;
318
+ const origin = cartItem._origin;
319
+ origin.select_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
320
+ origin.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
321
+ origin.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
322
+ origin.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
323
+ origin.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
324
+ return origin;
325
+ };
274
326
  var formatNoteToCartItem = (params) => {
275
327
  const { cartItem, note } = params;
276
328
  cartItem.note = note;
@@ -351,6 +403,7 @@ var isNormalProduct = (product) => {
351
403
  };
352
404
  var getProductTotalPrice = (params) => {
353
405
  const { product, bundle, options } = params;
406
+ const num = params.num || 1;
354
407
  let price = Number(product.price);
355
408
  if (bundle == null ? void 0 : bundle.length) {
356
409
  price = bundle.reduce((accumulator, currentValue) => {
@@ -362,10 +415,11 @@ var getProductTotalPrice = (params) => {
362
415
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
363
416
  }, price);
364
417
  }
365
- return price;
418
+ return price * num;
366
419
  };
367
420
  var getProductOriginTotalPrice = (params) => {
368
421
  const { product, bundle, options } = params;
422
+ const num = (params == null ? void 0 : params.num) || 1;
369
423
  let price = Number(product.original_price);
370
424
  if (isNaN(price) || price === 0) {
371
425
  return void 0;
@@ -380,17 +434,102 @@ var getProductOriginTotalPrice = (params) => {
380
434
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
381
435
  }, price);
382
436
  }
383
- return price;
437
+ return price * num;
438
+ };
439
+ var getProductDeposit = (params) => {
440
+ var _a;
441
+ const { cartItem, product, bundle, options } = params;
442
+ const num = (params == null ? void 0 : params.num) || 1;
443
+ if (((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) == 1) {
444
+ const protocols = [];
445
+ let total = new import_decimal.default(0);
446
+ const { deposit_fixed, deposit_percentage, deposit_policy_data } = (product == null ? void 0 : product.custom_deposit_data) || {};
447
+ protocols.push(...deposit_policy_data || []);
448
+ if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
449
+ const { depositTotal, result } = handleProductDeposit({
450
+ depositData: product == null ? void 0 : product.custom_deposit_data,
451
+ total: cartItem.total || 0,
452
+ num
453
+ });
454
+ if (result) {
455
+ total = depositTotal;
456
+ }
457
+ } else {
458
+ if (bundle == null ? void 0 : bundle.length) {
459
+ total = bundle.reduce((accumulator, currentBundleProduct) => {
460
+ const { depositTotal, result } = handleProductDeposit({
461
+ depositData: currentBundleProduct == null ? void 0 : currentBundleProduct.custom_deposit_data,
462
+ total: currentBundleProduct.price,
463
+ num: currentBundleProduct.num
464
+ });
465
+ if (result) {
466
+ return accumulator.plus(depositTotal);
467
+ }
468
+ return accumulator;
469
+ }, new import_decimal.default(0));
470
+ }
471
+ }
472
+ return { total: total.toNumber(), protocols };
473
+ }
474
+ return null;
475
+ };
476
+ var handleProductDeposit = (params) => {
477
+ const { depositData, total, num } = params;
478
+ if (!depositData) {
479
+ return { result: false, depositTotal: new import_decimal.default(0) };
480
+ }
481
+ const { deposit_fixed, deposit_percentage } = depositData || {};
482
+ if (typeof deposit_fixed === "string" && typeof deposit_percentage === "string") {
483
+ const depositFixed = (0, import_decimal.default)(deposit_fixed || 0);
484
+ const depositPercent = (0, import_decimal.default)(deposit_percentage || 0);
485
+ const productTotalPrice = (0, import_decimal.default)(total || 0);
486
+ const deposit = depositFixed.plus(depositPercent.times(productTotalPrice));
487
+ return { depositTotal: deposit.times(num), result: true };
488
+ }
489
+ return { result: false, depositTotal: new import_decimal.default(0) };
490
+ };
491
+ var deleteResourceFromCartItem = (cartItem) => {
492
+ cartItem.resource_id = void 0;
493
+ cartItem.relation_form_name = void 0;
494
+ delete cartItem._resourceOrigin;
495
+ cartItem._origin.resources = null;
496
+ return cartItem;
497
+ };
498
+ var deleteTimeFromCartItem = (cartItem) => {
499
+ cartItem.start_date = void 0;
500
+ cartItem.start_time = void 0;
501
+ cartItem.end_date = void 0;
502
+ cartItem.end_time = void 0;
503
+ cartItem._origin.select_date = null;
504
+ cartItem._origin.start_date = null;
505
+ cartItem._origin.start_time = null;
506
+ cartItem._origin.end_date = null;
507
+ cartItem._origin.end_time = null;
508
+ return cartItem;
509
+ };
510
+ var deleteRelationFormsFromCartItem = (cartItem) => {
511
+ cartItem._origin.relation_forms = null;
512
+ return cartItem;
513
+ };
514
+ var deleteHolderFromCartItem = (cartItem) => {
515
+ cartItem.holder_id = void 0;
516
+ cartItem.holder_title = void 0;
517
+ cartItem._origin.holder = null;
518
+ return cartItem;
384
519
  };
385
520
  // Annotate the CommonJS export names for ESM import in node:
386
521
  0 && (module.exports = {
387
522
  createCartItemOrigin,
523
+ deleteHolderFromCartItem,
524
+ deleteRelationFormsFromCartItem,
388
525
  deleteResourceFromCartItem,
389
526
  deleteTimeFromCartItem,
390
527
  formatAccountToCartItem,
391
528
  formatAccountToCartItemOrigin,
392
529
  formatBundle,
393
530
  formatBundleToOrigin,
531
+ formatDateToCartItem,
532
+ formatDateToCartItemOrigin,
394
533
  formatDiscountToCartItem,
395
534
  formatDiscountToCartItemOrigin,
396
535
  formatNoteToCartItem,
@@ -399,10 +538,14 @@ var getProductOriginTotalPrice = (params) => {
399
538
  formatOptionsToOrigin,
400
539
  formatProductToCartItem,
401
540
  formatProductToCartItemOrigin,
541
+ formatRelationFormsToCartItem,
542
+ formatRelationFormsToCartItemOrigin,
402
543
  formatResourceToCartItem,
403
544
  formatResourceToCartItemOrigin,
545
+ getProductDeposit,
404
546
  getProductOriginTotalPrice,
405
547
  getProductTotalPrice,
406
548
  getUniqueId,
549
+ handleProductDeposit,
407
550
  isNormalProduct
408
551
  });
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from './types';
4
4
  export declare class DateModule extends BaseModule implements Module, DateModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -13,9 +13,9 @@ export declare class DateModule extends BaseModule implements Module, DateModule
13
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
14
  setDateRange(dateRange: ITime[]): void;
15
15
  getDateRange(): ITime[];
16
- getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
- getDateList(): Promise<ITime[]>;
18
- getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
16
+ getResourceDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
+ getDateList(): ITime[];
18
+ getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
19
19
  clearDateRange(): void;
20
20
  storeChange(): void;
21
21
  }
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __export = (target, all) => {
8
6
  for (var name in all)
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
16
14
  }
17
15
  return to;
18
16
  };
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
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
18
 
29
19
  // src/modules/Date/index.ts
@@ -32,7 +22,6 @@ __export(Date_exports, {
32
22
  DateModule: () => DateModule
33
23
  });
34
24
  module.exports = __toCommonJS(Date_exports);
35
- var import_dayjs = __toESM(require("dayjs"));
36
25
  var import_BaseModule = require("../BaseModule");
37
26
  var import_utils = require("./utils");
38
27
  var DateModule = class extends import_BaseModule.BaseModule {
@@ -68,37 +57,33 @@ var DateModule = class extends import_BaseModule.BaseModule {
68
57
  getDateRange() {
69
58
  return this.store.dateRange;
70
59
  }
71
- async getMonthDates(params) {
72
- const dates = await this.getAvailableTimeList(params);
60
+ async getResourceDates(params) {
61
+ const dates = await this.getResourceAvailableTimeList(params);
73
62
  this.store.dateList = dates;
74
63
  return dates;
75
64
  }
76
- async getDateList() {
65
+ getDateList() {
77
66
  return this.store.dateList;
78
67
  }
79
- async getAvailableTimeList(params) {
68
+ async getResourceAvailableTimeList(params) {
80
69
  var _a;
81
- const { url, query, rules } = params;
70
+ const { url, query, rules, type } = params;
82
71
  const fetchUrl = url || "/schedule/resource/list";
83
72
  const { start_date, end_date, resource_ids } = query || {};
84
73
  if (!start_date || !end_date) {
85
74
  return [];
86
75
  }
87
- let dates = (0, import_utils.generateMonthDates)(start_date, end_date);
88
- if (!(resource_ids == null ? void 0 : resource_ids.length) || (0, import_dayjs.default)(end_date).isBefore((0, import_dayjs.default)())) {
76
+ let dates = (0, import_utils.generateMonthDates)(start_date, end_date, type);
77
+ if (!(resource_ids == null ? void 0 : resource_ids.length)) {
89
78
  return (0, import_utils.disableAllDates)(dates);
90
79
  }
91
80
  try {
92
- const res = await this.request.get(
93
- fetchUrl,
94
- {
95
- start_date,
96
- end_date,
97
- resource_ids,
98
- front_end_cache_id: this.cacheId
99
- },
100
- { useCache: true }
101
- );
81
+ const res = await this.request.get(fetchUrl, {
82
+ start_date,
83
+ end_date,
84
+ resource_ids,
85
+ front_end_cache_id: this.cacheId
86
+ });
102
87
  if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
103
88
  return (0, import_utils.disableAllDates)(dates);
104
89
  }
@@ -20,33 +20,39 @@ export interface ITime {
20
20
  date: string;
21
21
  week: string;
22
22
  weekNum: number;
23
- status: "unavailable" | "available";
23
+ status: 'unavailable' | 'available';
24
24
  resource?: any[];
25
+ color?: string[];
25
26
  }
26
27
  /**
27
28
  * 日期模块 API
28
29
  */
29
30
  export interface DateModuleAPI {
30
31
  /**
31
- * 获取可用时间列表
32
+ * 获取资源可用时间列表
32
33
  */
33
- getAvailableTimeList: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
34
+ getResourceAvailableTimeList: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
34
35
  /**
35
36
  * 设置日期范围
36
37
  */
37
38
  setDateRange: (range: ITime[]) => void;
38
39
  /**
39
- * 获取月份日期
40
+ * 获取资源日期
40
41
  */
41
- getMonthDates: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
42
+ getResourceDates: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
42
43
  }
43
44
  export interface IGetAvailableTimeListParams {
44
45
  url?: string;
46
+ /** 查询参数 */
45
47
  query?: {
48
+ /** 开始日期 */
46
49
  start_date: string;
50
+ /** 结束日期 */
47
51
  end_date: string;
52
+ /** 资源ID */
48
53
  resource_ids?: Array<number | string>;
49
54
  };
55
+ /** 规则 */
50
56
  rules?: Array<{
51
57
  /**
52
58
  * 提前量
@@ -54,11 +60,21 @@ export interface IGetAvailableTimeListParams {
54
60
  cut_off_time?: {
55
61
  future_day?: number;
56
62
  unit?: number;
57
- unit_type?: "minutes" | "hours" | "days";
63
+ unit_type?: 'minutes' | 'hours' | 'days';
58
64
  };
59
65
  /**
60
66
  * 资源ID
61
67
  */
62
68
  resourceFormIds?: number[];
69
+ /**
70
+ * 日程ID
71
+ */
72
+ schedule?: {
73
+ date: string;
74
+ color?: string[];
75
+ isExcluded: boolean;
76
+ }[];
63
77
  }>;
78
+ /** 类型:按月查 | 按日查 */
79
+ type?: 'month' | 'day';
64
80
  }
@@ -1,11 +1,12 @@
1
- import { IGetAvailableTimeListParams, ITime } from "./types";
1
+ import { IGetAvailableTimeListParams, ITime } from './types';
2
2
  /**
3
3
  * 生成当前月份的所有日期
4
4
  * @param startDate 开始日期
5
5
  * @param endDate 结束日期
6
+ * @param type 类型:按月查 | 按周查
6
7
  * @returns 日期列表
7
8
  */
8
- export declare const generateMonthDates: (startDate: string, endDate: string) => ITime[];
9
+ export declare const generateMonthDates: (startDate: string, endDate: string, type?: 'month' | 'day') => ITime[];
9
10
  /**
10
11
  * 禁用所有日期
11
12
  * @param dates 日期列表
@@ -32,4 +33,4 @@ export declare const handleAvailableDateByResource: (resources: any[], dates: IT
32
33
  * @param rules 提前量规则
33
34
  * @returns 日期列表
34
35
  */
35
- export declare const handleAvailableDatesByRules: (dates: ITime[], rules: IGetAvailableTimeListParams["rules"]) => ITime[];
36
+ export declare const handleAvailableDatesByRules: (dates: ITime[], rules: IGetAvailableTimeListParams['rules']) => ITime[];
@@ -37,12 +37,12 @@ __export(utils_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(utils_exports);
39
39
  var import_dayjs = __toESM(require("dayjs"));
40
- var generateMonthDates = (startDate, endDate) => {
41
- const start = (0, import_dayjs.default)(startDate).format("YYYY-MM-01");
40
+ var generateMonthDates = (startDate, endDate, type) => {
41
+ const start = type === "day" ? (0, import_dayjs.default)(startDate).format("YYYY-MM-DD") : (0, import_dayjs.default)(startDate).format("YYYY-MM-01");
42
42
  const end = (0, import_dayjs.default)(endDate).format("YYYY-MM-DD");
43
43
  const dates = [];
44
44
  let currentDate = (0, import_dayjs.default)(start);
45
- while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(end)) || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(end))) {
45
+ while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(end), "day") || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(end), "day")) {
46
46
  dates.push({
47
47
  date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
48
48
  week: (0, import_dayjs.default)(currentDate).format("ddd"),
@@ -59,7 +59,7 @@ var disableAllDates = (dates) => {
59
59
  var disableDatesBeforeOneDay = (dates, oneDay) => {
60
60
  const day = oneDay ? (0, import_dayjs.default)(oneDay).format("YYYY-MM-DD") : (0, import_dayjs.default)().format("YYYY-MM-DD");
61
61
  return dates.map((date) => {
62
- if ((0, import_dayjs.default)(date.date).isBefore(day)) {
62
+ if ((0, import_dayjs.default)(date.date).isBefore(day, "day")) {
63
63
  return { ...date, status: "unavailable" };
64
64
  } else {
65
65
  return date;
@@ -100,44 +100,78 @@ var handleAvailableDatesByRules = (dates, rules) => {
100
100
  if (!(rules == null ? void 0 : rules.length)) {
101
101
  return newDates;
102
102
  }
103
+ let scheduleMap = {};
103
104
  let latestStartDate = "";
104
105
  let earliestEndDate = "";
105
106
  let resourceFormIds = [];
106
107
  rules.forEach((rule) => {
107
- var _a;
108
+ var _a, _b;
109
+ if ((_a = rule == null ? void 0 : rule.schedule) == null ? void 0 : _a.length) {
110
+ for (const item of rule.schedule) {
111
+ if ((0, import_dayjs.default)(item.date).isBefore((0, import_dayjs.default)(newDates[0].date), "day")) {
112
+ continue;
113
+ }
114
+ if ((0, import_dayjs.default)(item.date).isAfter(
115
+ (0, import_dayjs.default)(newDates[newDates.length - 1].date),
116
+ "day"
117
+ )) {
118
+ break;
119
+ }
120
+ if (!scheduleMap[item.date]) {
121
+ scheduleMap[item.date] = item;
122
+ } else {
123
+ if (!item.isExcluded) {
124
+ scheduleMap[item.date].isExcluded = false;
125
+ }
126
+ }
127
+ }
128
+ }
108
129
  const { future_day, unit, unit_type } = (rule == null ? void 0 : rule.cut_off_time) || {};
109
130
  if (future_day) {
110
131
  const endDate = (0, import_dayjs.default)().add(future_day, "day");
111
- if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate))) {
132
+ if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
112
133
  earliestEndDate = endDate.format("YYYY-MM-DD");
113
134
  }
114
135
  } else if (future_day === 0) {
115
136
  const endDate = (0, import_dayjs.default)();
116
- if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate))) {
137
+ if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
117
138
  earliestEndDate = endDate.format("YYYY-MM-DD");
118
139
  }
119
140
  }
120
141
  if (unit && unit_type) {
121
- const startDate = (0, import_dayjs.default)((0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD"));
122
- if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate))) {
142
+ const startDate = (0, import_dayjs.default)(
143
+ (0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD")
144
+ );
145
+ if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate), "day")) {
123
146
  latestStartDate = startDate.format("YYYY-MM-DD");
124
147
  }
125
148
  }
126
- if ((_a = rule == null ? void 0 : rule.resourceFormIds) == null ? void 0 : _a.length) {
127
- resourceFormIds = [.../* @__PURE__ */ new Set([...resourceFormIds, ...rule == null ? void 0 : rule.resourceFormIds])];
149
+ if ((_b = rule == null ? void 0 : rule.resourceFormIds) == null ? void 0 : _b.length) {
150
+ resourceFormIds = [
151
+ .../* @__PURE__ */ new Set([...resourceFormIds, ...rule == null ? void 0 : rule.resourceFormIds])
152
+ ];
128
153
  }
129
154
  });
130
155
  newDates = newDates.map((date) => {
131
156
  var _a;
132
157
  const disabledDate = { ...date, status: "unavailable" };
158
+ if (Object.keys(scheduleMap).length) {
159
+ const schedule = scheduleMap[date.date];
160
+ if (!schedule || (schedule == null ? void 0 : schedule.isExcluded)) {
161
+ return { ...date, color: schedule == null ? void 0 : schedule.color, status: "unavailable" };
162
+ } else {
163
+ date.color = schedule == null ? void 0 : schedule.color;
164
+ disabledDate.color = schedule == null ? void 0 : schedule.color;
165
+ }
166
+ }
133
167
  if (!((_a = date == null ? void 0 : date.resource) == null ? void 0 : _a.length)) {
134
168
  return disabledDate;
135
169
  }
136
170
  if (latestStartDate || earliestEndDate) {
137
- if (latestStartDate && (0, import_dayjs.default)(date.date).isBefore(latestStartDate)) {
171
+ if (latestStartDate && (0, import_dayjs.default)(date.date).isBefore(latestStartDate, "day")) {
138
172
  return disabledDate;
139
173
  }
140
- if (earliestEndDate && (0, import_dayjs.default)(date.date).isAfter(earliestEndDate)) {
174
+ if (earliestEndDate && (0, import_dayjs.default)(date.date).isAfter(earliestEndDate, "day")) {
141
175
  return disabledDate;
142
176
  }
143
177
  }