@pisell/pisellos 0.0.59 → 0.0.61

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 (83) hide show
  1. package/dist/modules/Cart/index.d.ts +2 -1
  2. package/dist/modules/Cart/index.js +28 -1
  3. package/dist/modules/Cart/types.d.ts +15 -0
  4. package/dist/modules/Cart/types.js +11 -0
  5. package/dist/modules/Cart/utils.d.ts +1 -0
  6. package/dist/modules/Cart/utils.js +2 -4
  7. package/dist/modules/Date/index.js +1 -2
  8. package/dist/modules/Date/utils.js +9 -9
  9. package/dist/solution/BookingByStep/index.d.ts +2 -1
  10. package/dist/solution/BookingByStep/index.js +49 -20
  11. package/dist/solution/BookingByStep/utils/resources.js +3 -2
  12. package/lib/modules/Cart/index.d.ts +2 -1
  13. package/lib/modules/Cart/index.js +26 -0
  14. package/lib/modules/Cart/types.d.ts +15 -0
  15. package/lib/modules/Cart/types.js +9 -0
  16. package/lib/modules/Cart/utils.d.ts +1 -0
  17. package/lib/modules/Cart/utils.js +2 -3
  18. package/lib/modules/Date/index.js +7 -21
  19. package/lib/modules/Date/utils.js +12 -9
  20. package/lib/solution/BookingByStep/index.d.ts +2 -1
  21. package/lib/solution/BookingByStep/index.js +42 -28
  22. package/lib/solution/BookingByStep/utils/resources.js +2 -2
  23. package/package.json +1 -1
  24. package/dist/core/index.d.ts.map +0 -1
  25. package/dist/effects/index.d.ts.map +0 -1
  26. package/dist/index.d.ts.map +0 -1
  27. package/dist/modules/Account/index.d.ts.map +0 -1
  28. package/dist/modules/Account/types.d.ts.map +0 -1
  29. package/dist/modules/AccountList/index.d.ts.map +0 -1
  30. package/dist/modules/AccountList/types.d.ts.map +0 -1
  31. package/dist/modules/AccountList/utils.d.ts.map +0 -1
  32. package/dist/modules/BaseModule.d.ts.map +0 -1
  33. package/dist/modules/Cart/index.d.ts.map +0 -1
  34. package/dist/modules/Cart/types.d.ts.map +0 -1
  35. package/dist/modules/Cart/utils.d.ts.map +0 -1
  36. package/dist/modules/Date/index.d.ts.map +0 -1
  37. package/dist/modules/Date/types.d.ts.map +0 -1
  38. package/dist/modules/Date/utils.d.ts.map +0 -1
  39. package/dist/modules/Discount/index.d.ts.map +0 -1
  40. package/dist/modules/Discount/types.d.ts.map +0 -1
  41. package/dist/modules/Guests/index.d.ts.map +0 -1
  42. package/dist/modules/Guests/types.d.ts.map +0 -1
  43. package/dist/modules/Order/index.d.ts.map +0 -1
  44. package/dist/modules/Order/types.d.ts.map +0 -1
  45. package/dist/modules/Order/utils.d.ts.map +0 -1
  46. package/dist/modules/Payment/index.d.ts.map +0 -1
  47. package/dist/modules/Payment/types.d.ts.map +0 -1
  48. package/dist/modules/Product/index.d.ts.map +0 -1
  49. package/dist/modules/Product/types.d.ts.map +0 -1
  50. package/dist/modules/ProductList/index.d.ts.map +0 -1
  51. package/dist/modules/ProductList/types.d.ts.map +0 -1
  52. package/dist/modules/Resource/index.d.ts.map +0 -1
  53. package/dist/modules/Resource/types.d.ts.map +0 -1
  54. package/dist/modules/Resource/utils.d.ts.map +0 -1
  55. package/dist/modules/Rules/index.d.ts.map +0 -1
  56. package/dist/modules/Rules/types.d.ts.map +0 -1
  57. package/dist/modules/Schedule/index.d.ts.map +0 -1
  58. package/dist/modules/Schedule/type.d.ts.map +0 -1
  59. package/dist/modules/Schedule/types.d.ts.map +0 -1
  60. package/dist/modules/Schedule/utils.d.ts.map +0 -1
  61. package/dist/modules/Step/index.d.ts.map +0 -1
  62. package/dist/modules/Step/tyeps.d.ts.map +0 -1
  63. package/dist/modules/Summary/index.d.ts.map +0 -1
  64. package/dist/modules/Summary/types.d.ts.map +0 -1
  65. package/dist/modules/Summary/utils.d.ts.map +0 -1
  66. package/dist/modules/index.d.ts.map +0 -1
  67. package/dist/plugins/index.d.ts.map +0 -1
  68. package/dist/plugins/request.d.ts.map +0 -1
  69. package/dist/plugins/shopStore.d.ts.map +0 -1
  70. package/dist/plugins/window.d.ts.map +0 -1
  71. package/dist/solution/BookingByStep/index.d.ts.map +0 -1
  72. package/dist/solution/BookingByStep/types.d.ts.map +0 -1
  73. package/dist/solution/BookingByStep/utils/products.d.ts.map +0 -1
  74. package/dist/solution/BookingByStep/utils/resources.d.ts.map +0 -1
  75. package/dist/solution/BuyTickets/index.d.ts.map +0 -1
  76. package/dist/solution/BuyTickets/types.d.ts.map +0 -1
  77. package/dist/solution/PlaceOrder/index.d.ts.map +0 -1
  78. package/dist/solution/ShopDiscount/index.d.ts.map +0 -1
  79. package/dist/solution/ShopDiscount/types.d.ts.map +0 -1
  80. package/dist/solution/ShopDiscount/utils.d.ts.map +0 -1
  81. package/dist/solution/index.d.ts.map +0 -1
  82. package/dist/store/createStore.d.ts.map +0 -1
  83. package/dist/types/index.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { CartItem, CartModuleAPI, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
3
+ import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
4
4
  export * from './types';
5
5
  /**
6
6
  * 购物车模块实现
@@ -66,4 +66,5 @@ export declare class CartModule extends BaseModule implements Module, CartModule
66
66
  */
67
67
  clear(): void;
68
68
  storeChange(): void;
69
+ checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
69
70
  }
@@ -22,7 +22,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
22
22
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
23
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
24
  import { BaseModule } from "../BaseModule";
25
- import { ECartItemInfoType } from "./types";
25
+ import { ECartItemCheckType, ECartItemInfoType } from "./types";
26
26
  import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFromCartItem, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatRelationFormsToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
27
27
  import { cloneDeep } from 'lodash-es';
28
28
  export * from "./types";
@@ -443,6 +443,33 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
443
443
  });
444
444
  }
445
445
  }
446
+ }, {
447
+ key: "checkCartItemByType",
448
+ value: function checkCartItemByType(cartItem, type) {
449
+ var result = false;
450
+ var _ref = cartItem._origin || {},
451
+ holder = _ref.holder,
452
+ metadata = _ref.metadata,
453
+ resources = _ref.resources,
454
+ start_date = _ref.start_date,
455
+ end_date = _ref.end_date,
456
+ relation_forms = _ref.relation_forms;
457
+ switch (type) {
458
+ case ECartItemCheckType.Account:
459
+ result = !!holder || !!(metadata !== null && metadata !== void 0 && metadata.account);
460
+ break;
461
+ case ECartItemCheckType.Resource:
462
+ result = !!(resources !== null && resources !== void 0 && resources.length);
463
+ break;
464
+ case ECartItemCheckType.Date:
465
+ result = !!start_date && !!end_date;
466
+ break;
467
+ case ECartItemCheckType.RelationForms:
468
+ result = !!(relation_forms !== null && relation_forms !== void 0 && relation_forms.length);
469
+ break;
470
+ }
471
+ return result;
472
+ }
446
473
  }]);
447
474
  return CartModule;
448
475
  }(BaseModule);
@@ -20,6 +20,19 @@ export declare enum ECartItemInfoType {
20
20
  /** 账户信息 */
21
21
  Holder = "holder"
22
22
  }
23
+ /**
24
+ * 购物车商品检查类型
25
+ */
26
+ export declare enum ECartItemCheckType {
27
+ /** 账户信息 */
28
+ Account = "account",
29
+ /** 资源信息 */
30
+ Resource = "resource",
31
+ /** 时间信息 */
32
+ Date = "date",
33
+ /** 关联表单信息 */
34
+ RelationForms = "relationForms"
35
+ }
23
36
  export interface CartModuleAPI {
24
37
  /** 添加商品到购物车 */
25
38
  addItem: (item: IAddItemParams) => Promise<void>;
@@ -41,6 +54,8 @@ export interface CartModuleAPI {
41
54
  clear: () => void;
42
55
  /** 清除购物车商品中的信息 */
43
56
  deleteCartItemInfo: (type: ECartItemInfoType, _id?: string) => void;
57
+ /** 检查购物车商品 */
58
+ checkCartItemByType: (cartItem: CartItem, type: ECartItemCheckType) => boolean;
44
59
  }
45
60
  /**
46
61
  * 购物车商品接口
@@ -17,6 +17,17 @@ export var ECartItemInfoType = /*#__PURE__*/function (ECartItemInfoType) {
17
17
  return ECartItemInfoType;
18
18
  }({});
19
19
 
20
+ /**
21
+ * 购物车商品检查类型
22
+ */
23
+ export var ECartItemCheckType = /*#__PURE__*/function (ECartItemCheckType) {
24
+ ECartItemCheckType["Account"] = "account";
25
+ ECartItemCheckType["Resource"] = "resource";
26
+ ECartItemCheckType["Date"] = "date";
27
+ ECartItemCheckType["RelationForms"] = "relationForms";
28
+ return ECartItemCheckType;
29
+ }({});
30
+
20
31
  /**
21
32
  * 购物车商品接口
22
33
  */
@@ -28,6 +28,7 @@ export declare const createCartItemOrigin: () => {
28
28
  end_time: null;
29
29
  end_date: null;
30
30
  metadata: {};
31
+ holder: null;
31
32
  };
32
33
  /**
33
34
  * 格式化商品到购物车
@@ -63,10 +63,9 @@ export var createCartItemOrigin = function createCartItemOrigin() {
63
63
  // 所选结束时间
64
64
  end_date: null,
65
65
  // 额外信息
66
- metadata: {}
67
-
66
+ metadata: {},
68
67
  // holder相关
69
- // holder: null,
68
+ holder: null
70
69
  };
71
70
  };
72
71
 
@@ -105,7 +104,6 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
105
104
  cartItem.isNormalProduct = isNormalProduct(product);
106
105
  cartItem.is_charge_tax = product === null || product === void 0 ? void 0 : product.is_charge_tax;
107
106
  }
108
- console.log('cartItem>>>>>>', cartItem);
109
107
  if (bundle !== null && bundle !== void 0 && bundle.length) {
110
108
  cartItem.bundle = formatBundle(bundle);
111
109
  }
@@ -15,7 +15,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
15
15
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
- import dayjs from 'dayjs';
19
18
  import { BaseModule } from "../BaseModule";
20
19
  import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
21
20
  export var DateModule = /*#__PURE__*/function (_BaseModule) {
@@ -132,7 +131,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
132
131
  case 5:
133
132
  // 1.生成当前月份的所有日期,默认都是可用的
134
133
  dates = generateMonthDates(start_date, end_date, type); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
135
- if (!(!(resource_ids !== null && resource_ids !== void 0 && resource_ids.length) || dayjs(end_date).isBefore(dayjs().startOf('day')))) {
134
+ if (resource_ids !== null && resource_ids !== void 0 && resource_ids.length) {
136
135
  _context3.next = 8;
137
136
  break;
138
137
  }
@@ -28,7 +28,7 @@ export var generateMonthDates = function generateMonthDates(startDate, endDate,
28
28
  var end = dayjs(endDate).format('YYYY-MM-DD');
29
29
  var dates = [];
30
30
  var currentDate = dayjs(start);
31
- while (dayjs(currentDate).isBefore(dayjs(end)) || dayjs(currentDate).isSame(dayjs(end))) {
31
+ while (dayjs(currentDate).isBefore(dayjs(end), 'day') || dayjs(currentDate).isSame(dayjs(end), 'day')) {
32
32
  dates.push({
33
33
  date: dayjs(currentDate).format('YYYY-MM-DD'),
34
34
  week: dayjs(currentDate).format('ddd'),
@@ -62,7 +62,7 @@ export var disableAllDates = function disableAllDates(dates) {
62
62
  export var disableDatesBeforeOneDay = function disableDatesBeforeOneDay(dates, oneDay) {
63
63
  var day = oneDay ? dayjs(oneDay).format('YYYY-MM-DD') : dayjs().format('YYYY-MM-DD');
64
64
  return dates.map(function (date) {
65
- if (dayjs(date.date).isBefore(day)) {
65
+ if (dayjs(date.date).isBefore(day, 'day')) {
66
66
  return _objectSpread(_objectSpread({}, date), {}, {
67
67
  status: 'unavailable'
68
68
  });
@@ -153,11 +153,11 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
153
153
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
154
154
  var item = _step.value;
155
155
  // 判断item.date是否在dates的开始和结束日期范围内,如果不在则跳过
156
- if (dayjs(item.date).isBefore(dayjs(newDates[0].date))) {
156
+ if (dayjs(item.date).isBefore(dayjs(newDates[0].date), 'day')) {
157
157
  continue;
158
158
  }
159
159
  // 判断日程日期是否超过了dates中的最后一个日期,如果超过了则循环break
160
- if (dayjs(item.date).isAfter(dayjs(newDates[newDates.length - 1].date))) {
160
+ if (dayjs(item.date).isAfter(dayjs(newDates[newDates.length - 1].date), 'day')) {
161
161
  break;
162
162
  }
163
163
  // 在范围内的日程如果scheduleMap中不存在,则加入到scheduleMap
@@ -182,12 +182,12 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
182
182
  // 预定天数存在,则开始计算从当前时间开始往后推预定天数作为结束时间
183
183
  if (future_day) {
184
184
  var endDate = dayjs().add(future_day, 'day');
185
- if (!earliestEndDate || endDate.isBefore(dayjs(earliestEndDate))) {
185
+ if (!earliestEndDate || endDate.isBefore(dayjs(earliestEndDate), 'day')) {
186
186
  earliestEndDate = endDate.format('YYYY-MM-DD');
187
187
  }
188
188
  } else if (future_day === 0) {
189
189
  var _endDate = dayjs();
190
- if (!earliestEndDate || _endDate.isBefore(dayjs(earliestEndDate))) {
190
+ if (!earliestEndDate || _endDate.isBefore(dayjs(earliestEndDate), 'day')) {
191
191
  earliestEndDate = _endDate.format('YYYY-MM-DD');
192
192
  }
193
193
  }
@@ -195,7 +195,7 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
195
195
  // 如果存在提前预约时间,则开始计算从当前时间开始往后推提前预约时间作为开始时间
196
196
  if (unit && unit_type) {
197
197
  var startDate = dayjs(dayjs().add(unit, unit_type).format('YYYY-MM-DD'));
198
- if (!latestStartDate || startDate.isAfter(dayjs(latestStartDate))) {
198
+ if (!latestStartDate || startDate.isAfter(dayjs(latestStartDate), 'day')) {
199
199
  latestStartDate = startDate.format('YYYY-MM-DD');
200
200
  }
201
201
  }
@@ -231,11 +231,11 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
231
231
  }
232
232
  if (latestStartDate || earliestEndDate) {
233
233
  // 如果时间在最早开始时间之前,则设置为不可用
234
- if (latestStartDate && dayjs(date.date).isBefore(latestStartDate)) {
234
+ if (latestStartDate && dayjs(date.date).isBefore(latestStartDate, 'day')) {
235
235
  return disabledDate;
236
236
  }
237
237
  // 如果时间在最早结束时间之后,则设置为不可用
238
- if (earliestEndDate && dayjs(date.date).isAfter(earliestEndDate)) {
238
+ if (earliestEndDate && dayjs(date.date).isAfter(earliestEndDate, 'day')) {
239
239
  return disabledDate;
240
240
  }
241
241
  }
@@ -2,7 +2,7 @@ import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { Response } from '../../plugins';
4
4
  import { BookingByStepState } from './types';
5
- import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem, ECartItemInfoType } from '../../modules';
5
+ import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem, ECartItemInfoType, ECartItemCheckType } from '../../modules';
6
6
  import { Account } from '../../modules/Account/types';
7
7
  import { IStep } from '../../modules/Step/tyeps';
8
8
  import { TimeSliceItem } from './utils/resources';
@@ -131,6 +131,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
131
131
  * 从购物车中按类别删除信息
132
132
  */
133
133
  deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
134
+ checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
134
135
  destroy(): void;
135
136
  getResourcesList(): any[];
136
137
  getResourcesListByCartItem(id: string | number): {
@@ -192,12 +192,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
192
192
  key: "loadProducts",
193
193
  value: function () {
194
194
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
195
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, productsData;
195
+ var _schedule_ids;
196
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_ids_data, productsData;
196
197
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
197
198
  while (1) switch (_context2.prev = _context2.next) {
198
199
  case 0:
199
200
  _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$schedule_ids = _ref.schedule_ids, schedule_ids = _ref$schedule_ids === void 0 ? [] : _ref$schedule_ids;
200
- _context2.next = 3;
201
+ // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
202
+ if (!((_schedule_ids = schedule_ids) !== null && _schedule_ids !== void 0 && _schedule_ids.length)) {
203
+ schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map(function (n) {
204
+ return n.id;
205
+ });
206
+ if (schedule_ids_data.length) {
207
+ schedule_ids = schedule_ids_data;
208
+ }
209
+ }
210
+ _context2.next = 4;
201
211
  return this.request.post("/product/query", {
202
212
  open_quotation: 1,
203
213
  open_bundle: 1,
@@ -214,11 +224,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
214
224
  }, {
215
225
  useCache: true
216
226
  });
217
- case 3:
227
+ case 4:
218
228
  productsData = _context2.sent;
219
229
  this.store.products.addProduct(productsData.data.list);
220
230
  return _context2.abrupt("return", productsData.data.list);
221
- case 6:
231
+ case 7:
222
232
  case "end":
223
233
  return _context2.stop();
224
234
  }
@@ -309,14 +319,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
309
319
  case 0:
310
320
  startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
311
321
  // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
312
- if (dayjs(startDate).isBefore(dayjs())) {
322
+ if (dayjs(startDate).isBefore(dayjs(), 'day')) {
313
323
  startDate = dayjs().format('YYYY-MM-DD');
314
324
  }
315
325
  // 1.生成当前月份的所有日期,默认都不可用
316
326
  dates = generateMonthDates(startDate, endDate);
317
327
  dates = disableAllDates(dates);
318
328
  // 如果 endDate 在今天之前,则不用查接口,直接返回 dates
319
- if (!dayjs(endDate).isBefore(dayjs())) {
329
+ if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
320
330
  _context5.next = 6;
321
331
  break;
322
332
  }
@@ -332,7 +342,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
332
342
  res = _context5.sent;
333
343
  this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
334
344
  // 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
335
- if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs()))) {
345
+ if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
336
346
  _context5.next = 12;
337
347
  break;
338
348
  }
@@ -641,7 +651,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
641
651
  params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
642
652
  // 开始日期如果小于今天,直接以今天当做开始日期
643
653
  products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
644
- if (dayjs(startDate).isBefore(dayjs()) && (dayjs(endDate).isAfter(dayjs()) || dayjs(endDate).isSame(dayjs()))) {
654
+ if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
645
655
  startDate = dayjs().format('YYYY-MM-DD');
646
656
  }
647
657
  tempProducts = products || this.store.cart.getItems().map(function (p) {
@@ -878,7 +888,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
878
888
  cartItems = this.store.cart.getItems();
879
889
  newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
880
890
  newCartItems.forEach(function (item) {
881
- var _item$_productOrigin;
891
+ var _item$_productOrigin, _item$_origin;
882
892
  item._origin.resources = item._origin.resources.map(function (n) {
883
893
  var newResourcesItem = cloneDeep(n);
884
894
  delete newResourcesItem.id;
@@ -890,7 +900,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
890
900
  capacity: (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.capacity,
891
901
  product_bundle: item._origin.product.product_bundle
892
902
  });
903
+ var currentCapacity = getSumCapacity({
904
+ capacity: formatCapacity
905
+ });
906
+ if (!((_item$_origin = item._origin) !== null && _item$_origin !== void 0 && _item$_origin.metadata)) {
907
+ item._origin.metadata = {};
908
+ }
893
909
  item._origin.metadata.capacity = formatCapacity;
910
+ item._origin.number = currentCapacity;
894
911
  });
895
912
  return _context20.abrupt("return", this.store.order.submitOrder({
896
913
  query: {
@@ -1082,6 +1099,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1082
1099
  value: function deleteCartItemInfo(type, _id) {
1083
1100
  this.store.cart.deleteCartItemInfo(type, _id);
1084
1101
  }
1102
+ }, {
1103
+ key: "checkCartItemByType",
1104
+ value: function checkCartItemByType(cartItem, type) {
1105
+ return this.store.cart.checkCartItemByType(cartItem, type);
1106
+ }
1085
1107
  }, {
1086
1108
  key: "destroy",
1087
1109
  value: function destroy() {
@@ -1193,7 +1215,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1193
1215
  key: "getResourcesListByCartItem",
1194
1216
  value: function getResourcesListByCartItem(id) {
1195
1217
  var _targetCartItem$_prod2, _targetCartItem$_prod3;
1196
- var cartItems = this.store.cart.getItems();
1218
+ var cartItems = cloneDeep(this.store.cart.getItems());
1197
1219
  var dateRange = this.store.date.getDateRange();
1198
1220
  var resources = [];
1199
1221
  dateRange.forEach(function (n) {
@@ -1265,7 +1287,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1265
1287
  countMap = _ref8.countMap,
1266
1288
  capacity = _ref8.capacity;
1267
1289
  var dateRange = this.store.date.getDateRange();
1268
- var cartItems = this.store.cart.getItems();
1290
+ var cartItems = cloneDeep(this.store.cart.getItems());
1269
1291
  // 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
1270
1292
  var accountCartItems = cartItems.filter(function (n) {
1271
1293
  return n.holder_id === holder_id;
@@ -1459,7 +1481,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1459
1481
  } else {
1460
1482
  var _item$_productOrigin8, _productResources$fin;
1461
1483
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1462
- var allCartItems = _this7.store.cart.getItems();
1484
+ var allCartItems = cloneDeep(_this7.store.cart.getItems());
1463
1485
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1464
1486
  var selectedResources = [];
1465
1487
  if (item.holder_id) {
@@ -1497,7 +1519,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1497
1519
  }
1498
1520
  });
1499
1521
  };
1500
- var cartItems = this.store.cart.getItems();
1522
+ var cartItems = cloneDeep(this.store.cart.getItems());
1501
1523
 
1502
1524
  // 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
1503
1525
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
@@ -1516,11 +1538,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1516
1538
  }, {
1517
1539
  key: "getTimeSlotByAllResources",
1518
1540
  value: function getTimeSlotByAllResources(resources_code) {
1519
- var _this8 = this;
1541
+ var _this8 = this,
1542
+ _cartItems$,
1543
+ _cartItems$2;
1520
1544
  var dateRange = this.store.date.getDateRange();
1521
1545
  // 取出购物车中所有一已选择的第一步资源
1522
1546
  var resources = [];
1523
- var cartItems = this.store.cart.getItems();
1547
+ var cartItems = cloneDeep(this.store.cart.getItems());
1524
1548
  // if (cartItems?.[0].start_date) return [];
1525
1549
  var resourceIds = [];
1526
1550
  cartItems.forEach(function (item) {
@@ -1559,15 +1583,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1559
1583
  } else {
1560
1584
  checkDuration(cartItems);
1561
1585
  }
1586
+ // 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
1587
+ // 同时 session 类商品的流程也不应该调用这个方法
1588
+ if (!(cartItems !== null && cartItems !== void 0 && (_cartItems$ = cartItems[0]) !== null && _cartItems$ !== void 0 && _cartItems$.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$2 = cartItems[0]) !== null && _cartItems$2 !== void 0 && _cartItems$2.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration)) {
1589
+ return [];
1590
+ }
1562
1591
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].start_date && !dateRange) {
1563
- var _cartItems$, _cartItems$2;
1592
+ var _cartItems$3, _cartItems$4;
1564
1593
  dateRange = [{
1565
1594
  date: cartItems === null || cartItems === void 0 ? void 0 : cartItems[0].start_date,
1566
1595
  status: 'available',
1567
1596
  week: '',
1568
1597
  weekNum: 0
1569
1598
  }, {
1570
- date: (cartItems === null || cartItems === void 0 || (_cartItems$ = cartItems[0]) === null || _cartItems$ === void 0 ? void 0 : _cartItems$.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$2 = cartItems[0]) === null || _cartItems$2 === void 0 ? void 0 : _cartItems$2.start_date) || '',
1599
+ date: (cartItems === null || cartItems === void 0 || (_cartItems$3 = cartItems[0]) === null || _cartItems$3 === void 0 ? void 0 : _cartItems$3.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$4 = cartItems[0]) === null || _cartItems$4 === void 0 ? void 0 : _cartItems$4.start_date) || '',
1571
1600
  status: 'available',
1572
1601
  week: '',
1573
1602
  weekNum: 0
@@ -1591,7 +1620,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1591
1620
  value: function submitTimeSlot(timeSlots) {
1592
1621
  var _this9 = this;
1593
1622
  // 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
1594
- var cartItems = this.store.cart.getItems();
1623
+ var cartItems = cloneDeep(this.store.cart.getItems());
1595
1624
 
1596
1625
  // 按账号分组
1597
1626
  var itemsByAccount = cartItems.reduce(function (acc, item) {
@@ -1711,7 +1740,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1711
1740
  var targetResourceDate = resourcesDates.find(function (n) {
1712
1741
  return n.date === date;
1713
1742
  });
1714
- var cartItems = this.store.cart.getItems();
1743
+ var cartItems = cloneDeep(this.store.cart.getItems());
1715
1744
  var resourcesMap = getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []);
1716
1745
  var selectedResources = getOthersSelectedResources(cartItems, '', resourcesMap);
1717
1746
  var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$currentPr2 = this.store.currentProduct) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.getData()) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.product_resource) === null || _this$store$currentPr2 === void 0 ? void 0 : _this$store$currentPr2.resources) || [], selectedResources, 1);
@@ -1803,7 +1832,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1803
1832
  });
1804
1833
  // 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
1805
1834
  if (date) {
1806
- var cartItems = this.store.cart.getItems();
1835
+ var cartItems = cloneDeep(this.store.cart.getItems());
1807
1836
  var cartItemsByDate = cartItems.filter(function (n) {
1808
1837
  return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
1809
1838
  });
@@ -231,7 +231,7 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
231
231
  return item.default_resource.indexOf(d) == -1;
232
232
  });
233
233
  var optional_resource = item.optional_resource.reduce(function (childAcc, d) {
234
- if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id) && capacity <= resourcesMap[d].capacity) {
234
+ if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
235
235
  // 拼装组合资源的数据
236
236
  var combiningResources = [];
237
237
  if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
@@ -253,7 +253,7 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
253
253
  return childAcc;
254
254
  }, []);
255
255
  var default_resource = item.default_resource.reduce(function (childAcc, d) {
256
- if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id) && capacity <= resourcesMap[d].capacity) {
256
+ if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
257
257
  // 拼装组合资源的数据
258
258
  var combiningResources = [];
259
259
  if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
@@ -282,6 +282,7 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
282
282
  var latestTime = d.times.reduce(function (latest, current) {
283
283
  return dayjs(current.end_at).isAfter(dayjs(latest.end_at)) ? current : latest;
284
284
  }, d.times[0]);
285
+ // TODO,在这拉时间切片出来,如果可用 timeSlots.length > 1 才可以被选择
285
286
  return dayjs(latestTime.end_at).isAfter(dayjs());
286
287
  });
287
288
  item.form_id = form_id;
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { CartItem, CartModuleAPI, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
3
+ import { CartItem, CartModuleAPI, ECartItemCheckType, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
4
4
  export * from './types';
5
5
  /**
6
6
  * 购物车模块实现
@@ -66,4 +66,5 @@ export declare class CartModule extends BaseModule implements Module, CartModule
66
66
  */
67
67
  clear(): void;
68
68
  storeChange(): void;
69
+ checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
69
70
  }
@@ -274,6 +274,32 @@ var CartModule = class extends import_BaseModule.BaseModule {
274
274
  });
275
275
  }
276
276
  }
277
+ checkCartItemByType(cartItem, type) {
278
+ let result = false;
279
+ const {
280
+ holder,
281
+ metadata,
282
+ resources,
283
+ start_date,
284
+ end_date,
285
+ relation_forms
286
+ } = cartItem._origin || {};
287
+ switch (type) {
288
+ case import_types.ECartItemCheckType.Account:
289
+ result = !!holder || !!(metadata == null ? void 0 : metadata.account);
290
+ break;
291
+ case import_types.ECartItemCheckType.Resource:
292
+ result = !!(resources == null ? void 0 : resources.length);
293
+ break;
294
+ case import_types.ECartItemCheckType.Date:
295
+ result = !!start_date && !!end_date;
296
+ break;
297
+ case import_types.ECartItemCheckType.RelationForms:
298
+ result = !!(relation_forms == null ? void 0 : relation_forms.length);
299
+ break;
300
+ }
301
+ return result;
302
+ }
277
303
  };
278
304
  // Annotate the CommonJS export names for ESM import in node:
279
305
  0 && (module.exports = {
@@ -20,6 +20,19 @@ export declare enum ECartItemInfoType {
20
20
  /** 账户信息 */
21
21
  Holder = "holder"
22
22
  }
23
+ /**
24
+ * 购物车商品检查类型
25
+ */
26
+ export declare enum ECartItemCheckType {
27
+ /** 账户信息 */
28
+ Account = "account",
29
+ /** 资源信息 */
30
+ Resource = "resource",
31
+ /** 时间信息 */
32
+ Date = "date",
33
+ /** 关联表单信息 */
34
+ RelationForms = "relationForms"
35
+ }
23
36
  export interface CartModuleAPI {
24
37
  /** 添加商品到购物车 */
25
38
  addItem: (item: IAddItemParams) => Promise<void>;
@@ -41,6 +54,8 @@ export interface CartModuleAPI {
41
54
  clear: () => void;
42
55
  /** 清除购物车商品中的信息 */
43
56
  deleteCartItemInfo: (type: ECartItemInfoType, _id?: string) => void;
57
+ /** 检查购物车商品 */
58
+ checkCartItemByType: (cartItem: CartItem, type: ECartItemCheckType) => boolean;
44
59
  }
45
60
  /**
46
61
  * 购物车商品接口
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var types_exports = {};
21
21
  __export(types_exports, {
22
22
  CartHooks: () => CartHooks,
23
+ ECartItemCheckType: () => ECartItemCheckType,
23
24
  ECartItemInfoType: () => ECartItemInfoType
24
25
  });
25
26
  module.exports = __toCommonJS(types_exports);
@@ -37,8 +38,16 @@ var ECartItemInfoType = /* @__PURE__ */ ((ECartItemInfoType2) => {
37
38
  ECartItemInfoType2["Holder"] = "holder";
38
39
  return ECartItemInfoType2;
39
40
  })(ECartItemInfoType || {});
41
+ var ECartItemCheckType = /* @__PURE__ */ ((ECartItemCheckType2) => {
42
+ ECartItemCheckType2["Account"] = "account";
43
+ ECartItemCheckType2["Resource"] = "resource";
44
+ ECartItemCheckType2["Date"] = "date";
45
+ ECartItemCheckType2["RelationForms"] = "relationForms";
46
+ return ECartItemCheckType2;
47
+ })(ECartItemCheckType || {});
40
48
  // Annotate the CommonJS export names for ESM import in node:
41
49
  0 && (module.exports = {
42
50
  CartHooks,
51
+ ECartItemCheckType,
43
52
  ECartItemInfoType
44
53
  });
@@ -28,6 +28,7 @@ export declare const createCartItemOrigin: () => {
28
28
  end_time: null;
29
29
  end_date: null;
30
30
  metadata: {};
31
+ holder: null;
31
32
  };
32
33
  /**
33
34
  * 格式化商品到购物车
@@ -103,9 +103,9 @@ var createCartItemOrigin = () => {
103
103
  // 所选结束时间
104
104
  end_date: null,
105
105
  // 额外信息
106
- metadata: {}
106
+ metadata: {},
107
107
  // holder相关
108
- // holder: null,
108
+ holder: null
109
109
  };
110
110
  };
111
111
  var formatProductToCartItem = (params) => {
@@ -130,7 +130,6 @@ var formatProductToCartItem = (params) => {
130
130
  cartItem.isNormalProduct = isNormalProduct(product);
131
131
  cartItem.is_charge_tax = product == null ? void 0 : product.is_charge_tax;
132
132
  }
133
- console.log("cartItem>>>>>>", cartItem);
134
133
  if (bundle == null ? void 0 : bundle.length) {
135
134
  cartItem.bundle = formatBundle(bundle);
136
135
  }