@pisell/pisellos 0.0.44 → 0.0.45

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 (127) 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 +19 -0
  5. package/dist/modules/AccountList/index.js +224 -70
  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 +5 -5
  13. package/dist/modules/Cart/index.js +32 -19
  14. package/dist/modules/Cart/types.d.ts +18 -4
  15. package/dist/modules/Cart/utils.d.ts +29 -5
  16. package/dist/modules/Cart/utils.js +72 -26
  17. package/dist/modules/Date/index.d.ts +6 -6
  18. package/dist/modules/Date/index.js +41 -55
  19. package/dist/modules/Date/types.d.ts +22 -6
  20. package/dist/modules/Date/utils.d.ts +4 -3
  21. package/dist/modules/Date/utils.js +74 -23
  22. package/dist/modules/Discount/index.d.ts +4 -4
  23. package/dist/modules/Discount/index.js +11 -11
  24. package/dist/modules/Order/index.d.ts +10 -5
  25. package/dist/modules/Order/index.js +32 -16
  26. package/dist/modules/Order/types.d.ts +10 -3
  27. package/dist/modules/Product/index.d.ts +4 -1
  28. package/dist/modules/Product/index.js +22 -0
  29. package/dist/modules/Product/types.d.ts +7 -3
  30. package/dist/modules/ProductList/index.js +11 -5
  31. package/dist/modules/Resource/utils.js +1 -1
  32. package/dist/modules/Rules/index.d.ts +4 -4
  33. package/dist/modules/Rules/index.js +11 -11
  34. package/dist/modules/Rules/types.d.ts +1 -1
  35. package/dist/modules/Schedule/index.d.ts +8 -3
  36. package/dist/modules/Schedule/index.js +45 -5
  37. package/dist/modules/Schedule/type.d.ts +7 -7
  38. package/dist/modules/Schedule/types.d.ts +8 -8
  39. package/dist/modules/Schedule/utils.d.ts +9 -3
  40. package/dist/modules/Schedule/utils.js +77 -48
  41. package/dist/modules/Step/index.d.ts +14 -3
  42. package/dist/modules/Step/index.js +54 -2
  43. package/dist/modules/Summary/index.d.ts +5 -5
  44. package/dist/modules/Summary/index.js +7 -7
  45. package/dist/modules/Summary/types.d.ts +2 -2
  46. package/dist/modules/Summary/utils.d.ts +4 -4
  47. package/dist/modules/Summary/utils.js +3 -3
  48. package/dist/plugins/index.d.ts +3 -3
  49. package/dist/plugins/request.d.ts +3 -3
  50. package/dist/plugins/request.js +30 -30
  51. package/dist/plugins/shopStore.d.ts +1 -1
  52. package/dist/solution/BookingByStep/index.d.ts +65 -16
  53. package/dist/solution/BookingByStep/index.js +553 -216
  54. package/dist/solution/BookingByStep/types.d.ts +2 -2
  55. package/dist/solution/BookingByStep/types.js +9 -9
  56. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  57. package/dist/solution/BookingByStep/utils/products.js +3 -0
  58. package/dist/solution/BookingByStep/utils/resources.d.ts +5 -5
  59. package/dist/solution/BookingByStep/utils/resources.js +11 -11
  60. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  61. package/dist/solution/ShopDiscount/index.js +16 -16
  62. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  63. package/dist/solution/ShopDiscount/utils.js +1 -1
  64. package/lib/core/index.js +7 -2
  65. package/lib/modules/Account/index.d.ts +2 -6
  66. package/lib/modules/Account/index.js +15 -30
  67. package/lib/modules/Account/types.d.ts +12 -1
  68. package/lib/modules/AccountList/index.d.ts +19 -0
  69. package/lib/modules/AccountList/index.js +109 -12
  70. package/lib/modules/AccountList/types.d.ts +33 -1
  71. package/lib/modules/AccountList/utils.d.ts +9 -0
  72. package/lib/modules/AccountList/utils.js +39 -0
  73. package/lib/modules/BaseModule.d.ts +2 -2
  74. package/lib/modules/BaseModule.js +14 -3
  75. package/lib/modules/Cart/index.d.ts +5 -5
  76. package/lib/modules/Cart/index.js +27 -6
  77. package/lib/modules/Cart/types.d.ts +18 -4
  78. package/lib/modules/Cart/utils.d.ts +29 -5
  79. package/lib/modules/Cart/utils.js +47 -3
  80. package/lib/modules/Date/index.d.ts +6 -6
  81. package/lib/modules/Date/index.js +6 -6
  82. package/lib/modules/Date/types.d.ts +22 -6
  83. package/lib/modules/Date/utils.d.ts +4 -3
  84. package/lib/modules/Date/utils.js +37 -6
  85. package/lib/modules/Discount/index.d.ts +4 -4
  86. package/lib/modules/Discount/index.js +9 -2
  87. package/lib/modules/Guests/index.js +4 -1
  88. package/lib/modules/Order/index.d.ts +10 -5
  89. package/lib/modules/Order/index.js +11 -1
  90. package/lib/modules/Order/types.d.ts +10 -3
  91. package/lib/modules/Payment/index.js +1 -6
  92. package/lib/modules/Product/index.d.ts +4 -1
  93. package/lib/modules/Product/index.js +16 -0
  94. package/lib/modules/Product/types.d.ts +7 -3
  95. package/lib/modules/ProductList/index.js +21 -7
  96. package/lib/modules/Resource/index.js +4 -1
  97. package/lib/modules/Resource/utils.js +7 -4
  98. package/lib/modules/Rules/index.d.ts +4 -4
  99. package/lib/modules/Rules/types.d.ts +1 -1
  100. package/lib/modules/Schedule/index.d.ts +8 -3
  101. package/lib/modules/Schedule/index.js +33 -2
  102. package/lib/modules/Schedule/type.d.ts +7 -7
  103. package/lib/modules/Schedule/types.d.ts +8 -8
  104. package/lib/modules/Schedule/utils.d.ts +9 -3
  105. package/lib/modules/Schedule/utils.js +32 -4
  106. package/lib/modules/Step/index.d.ts +14 -3
  107. package/lib/modules/Step/index.js +38 -1
  108. package/lib/modules/Summary/index.d.ts +5 -5
  109. package/lib/modules/Summary/types.d.ts +2 -2
  110. package/lib/modules/Summary/utils.d.ts +4 -4
  111. package/lib/plugins/index.d.ts +3 -3
  112. package/lib/plugins/request.d.ts +3 -3
  113. package/lib/plugins/request.js +48 -11
  114. package/lib/plugins/shopStore.d.ts +1 -1
  115. package/lib/solution/BookingByStep/index.d.ts +65 -16
  116. package/lib/solution/BookingByStep/index.js +351 -39
  117. package/lib/solution/BookingByStep/types.d.ts +2 -2
  118. package/lib/solution/BookingByStep/types.js +36 -9
  119. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  120. package/lib/solution/BookingByStep/utils/products.js +3 -0
  121. package/lib/solution/BookingByStep/utils/resources.d.ts +5 -5
  122. package/lib/solution/BookingByStep/utils/resources.js +103 -52
  123. package/lib/solution/BuyTickets/index.js +34 -20
  124. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  125. package/lib/solution/ShopDiscount/index.js +10 -2
  126. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  127. package/package.json +4 -2
@@ -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[];
@@ -2,9 +2,10 @@ var _excluded = ["form_id", "id", "times"];
2
2
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
4
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
6
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
9
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
10
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
11
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
@@ -13,26 +14,28 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
13
14
  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; }
14
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
16
  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); }
16
- import dayjs from "dayjs";
17
+ import dayjs from 'dayjs';
17
18
  /**
18
19
  * 生成当前月份的所有日期
19
20
  * @param startDate 开始日期
20
21
  * @param endDate 结束日期
22
+ * @param type 类型:按月查 | 按周查
21
23
  * @returns 日期列表
22
24
  */
23
- export var generateMonthDates = function generateMonthDates(startDate, endDate) {
24
- var start = dayjs(startDate).format("YYYY-MM-01");
25
- var end = dayjs(endDate).format("YYYY-MM-DD");
25
+ export var generateMonthDates = function generateMonthDates(startDate, endDate, type) {
26
+ // 如果是按月查询需要从01号开始,如果是按周查询以开始结束时间为准
27
+ var start = type === 'day' ? dayjs(startDate).format('YYYY-MM-DD') : dayjs(startDate).format('YYYY-MM-01');
28
+ var end = dayjs(endDate).format('YYYY-MM-DD');
26
29
  var dates = [];
27
30
  var currentDate = dayjs(start);
28
31
  while (dayjs(currentDate).isBefore(dayjs(end)) || dayjs(currentDate).isSame(dayjs(end))) {
29
32
  dates.push({
30
- date: dayjs(currentDate).format("YYYY-MM-DD"),
31
- week: dayjs(currentDate).format("ddd"),
33
+ date: dayjs(currentDate).format('YYYY-MM-DD'),
34
+ week: dayjs(currentDate).format('ddd'),
32
35
  weekNum: dayjs(currentDate).day(),
33
- status: "available"
36
+ status: 'available'
34
37
  });
35
- currentDate = dayjs(currentDate).add(1, "day");
38
+ currentDate = dayjs(currentDate).add(1, 'day');
36
39
  }
37
40
  return dates;
38
41
  };
@@ -45,7 +48,7 @@ export var generateMonthDates = function generateMonthDates(startDate, endDate)
45
48
  export var disableAllDates = function disableAllDates(dates) {
46
49
  return dates.map(function (date) {
47
50
  return _objectSpread(_objectSpread({}, date), {}, {
48
- status: "unavailable"
51
+ status: 'unavailable'
49
52
  });
50
53
  });
51
54
  };
@@ -57,11 +60,11 @@ export var disableAllDates = function disableAllDates(dates) {
57
60
  * @returns 日期列表
58
61
  */
59
62
  export var disableDatesBeforeOneDay = function disableDatesBeforeOneDay(dates, oneDay) {
60
- var day = oneDay ? dayjs(oneDay).format("YYYY-MM-DD") : dayjs().format("YYYY-MM-DD");
63
+ var day = oneDay ? dayjs(oneDay).format('YYYY-MM-DD') : dayjs().format('YYYY-MM-DD');
61
64
  return dates.map(function (date) {
62
65
  if (dayjs(date.date).isBefore(day)) {
63
66
  return _objectSpread(_objectSpread({}, date), {}, {
64
- status: "unavailable"
67
+ status: 'unavailable'
65
68
  });
66
69
  } else {
67
70
  return date;
@@ -84,7 +87,7 @@ export var handleAvailableDateByResource = function handleAvailableDateByResourc
84
87
  others = _objectWithoutProperties(resource, _excluded);
85
88
  times.forEach(function (time) {
86
89
  var start_at = time.start_at;
87
- var date = dayjs(start_at).format("YYYY-MM-DD");
90
+ var date = dayjs(start_at).format('YYYY-MM-DD');
88
91
  if (!dateMap[date]) {
89
92
  dateMap[date] = [_objectSpread(_objectSpread({
90
93
  form_id: form_id,
@@ -118,7 +121,7 @@ export var handleAvailableDateByResource = function handleAvailableDateByResourc
118
121
  });
119
122
  } else {
120
123
  return _objectSpread(_objectSpread({}, date), {}, {
121
- status: "unavailable",
124
+ status: 'unavailable',
122
125
  resource: []
123
126
  });
124
127
  }
@@ -136,33 +139,64 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
136
139
  if (!(rules !== null && rules !== void 0 && rules.length)) {
137
140
  return newDates;
138
141
  }
139
- var latestStartDate = ""; // 最晚开始日期
140
- var earliestEndDate = ""; // 最早结束日期
142
+ var scheduleMap = {}; // 日程列表
143
+ var latestStartDate = ''; // 最晚开始日期
144
+ var earliestEndDate = ''; // 最早结束日期
141
145
  var resourceFormIds = [];
142
146
  rules.forEach(function (rule) {
143
- var _rule$resourceFormIds;
147
+ var _rule$schedule, _rule$resourceFormIds;
148
+ // 如果有日程列表,需要将它去重加入到scheduleMap
149
+ if (rule !== null && rule !== void 0 && (_rule$schedule = rule.schedule) !== null && _rule$schedule !== void 0 && _rule$schedule.length) {
150
+ var _iterator = _createForOfIteratorHelper(rule.schedule),
151
+ _step;
152
+ try {
153
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
154
+ var item = _step.value;
155
+ // 判断item.date是否在dates的开始和结束日期范围内,如果不在则跳过
156
+ if (dayjs(item.date).isBefore(dayjs(newDates[0].date))) {
157
+ continue;
158
+ }
159
+ // 判断日程日期是否超过了dates中的最后一个日期,如果超过了则循环break
160
+ if (dayjs(item.date).isAfter(dayjs(newDates[newDates.length - 1].date))) {
161
+ break;
162
+ }
163
+ // 在范围内的日程如果scheduleMap中不存在,则加入到scheduleMap
164
+ if (!scheduleMap[item.date]) {
165
+ scheduleMap[item.date] = item;
166
+ } else {
167
+ if (!item.isExcluded) {
168
+ scheduleMap[item.date].isExcluded = false;
169
+ }
170
+ }
171
+ }
172
+ } catch (err) {
173
+ _iterator.e(err);
174
+ } finally {
175
+ _iterator.f();
176
+ }
177
+ }
144
178
  var _ref = (rule === null || rule === void 0 ? void 0 : rule.cut_off_time) || {},
145
179
  future_day = _ref.future_day,
146
180
  unit = _ref.unit,
147
181
  unit_type = _ref.unit_type;
148
182
  // 预定天数存在,则开始计算从当前时间开始往后推预定天数作为结束时间
149
183
  if (future_day) {
150
- var endDate = dayjs().add(future_day, "day");
184
+ var endDate = dayjs().add(future_day, 'day');
151
185
  if (!earliestEndDate || endDate.isBefore(dayjs(earliestEndDate))) {
152
- earliestEndDate = endDate.format("YYYY-MM-DD");
186
+ earliestEndDate = endDate.format('YYYY-MM-DD');
153
187
  }
154
188
  } else if (future_day === 0) {
155
189
  var _endDate = dayjs();
156
190
  if (!earliestEndDate || _endDate.isBefore(dayjs(earliestEndDate))) {
157
- earliestEndDate = _endDate.format("YYYY-MM-DD");
191
+ earliestEndDate = _endDate.format('YYYY-MM-DD');
158
192
  }
159
193
  }
160
194
 
161
195
  // 如果存在提前预约时间,则开始计算从当前时间开始往后推提前预约时间作为开始时间
162
196
  if (unit && unit_type) {
163
- var startDate = dayjs(dayjs().add(unit, unit_type).format("YYYY-MM-DD"));
197
+ var startDate = dayjs(dayjs().add(unit, unit_type).format('YYYY-MM-DD'));
164
198
  if (!latestStartDate || startDate.isAfter(dayjs(latestStartDate))) {
165
- latestStartDate = startDate.format("YYYY-MM-DD");
199
+ latestStartDate = startDate.format('YYYY-MM-DD');
166
200
  }
167
201
  }
168
202
  if (rule !== null && rule !== void 0 && (_rule$resourceFormIds = rule.resourceFormIds) !== null && _rule$resourceFormIds !== void 0 && _rule$resourceFormIds.length) {
@@ -173,8 +207,25 @@ export var handleAvailableDatesByRules = function handleAvailableDatesByRules(da
173
207
  newDates = newDates.map(function (date) {
174
208
  var _date$resource, _resourceFormIds;
175
209
  var disabledDate = _objectSpread(_objectSpread({}, date), {}, {
176
- status: "unavailable"
210
+ status: 'unavailable'
177
211
  });
212
+
213
+ // 根据日程判断日期是否可用
214
+ if (Object.keys(scheduleMap).length) {
215
+ var schedule = scheduleMap[date.date];
216
+ // 如果日程不存在 或者 日程存在但是需要排除,则设置为不可用
217
+ if (!schedule || schedule !== null && schedule !== void 0 && schedule.isExcluded) {
218
+ return _objectSpread(_objectSpread({}, date), {}, {
219
+ color: schedule === null || schedule === void 0 ? void 0 : schedule.color,
220
+ status: 'unavailable'
221
+ });
222
+ } else {
223
+ date.color = schedule === null || schedule === void 0 ? void 0 : schedule.color;
224
+ disabledDate.color = schedule === null || schedule === void 0 ? void 0 : schedule.color;
225
+ }
226
+ }
227
+
228
+ // 如果资源不存在,则设置为不可用
178
229
  if (!(date !== null && date !== void 0 && (_date$resource = date.resource) !== null && _date$resource !== void 0 && _date$resource.length)) {
179
230
  return disabledDate;
180
231
  }
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { Discount, DiscountModuleAPI } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { Discount, DiscountModuleAPI } from './types';
4
4
  export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -15,7 +15,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
15
15
  setDiscountList(discountList: Discount[]): Promise<void>;
16
16
  getDiscountList(): Discount[];
17
17
  loadPrepareConfig(params: {
18
- action?: "create";
18
+ action?: 'create';
19
19
  with_good_pass: 0 | 1;
20
20
  customer_id: number;
21
21
  }): Promise<Discount[]>;
@@ -25,8 +25,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
25
25
  var _this;
26
26
  _classCallCheck(this, DiscountModule);
27
27
  _this = _super.call(this, name, version);
28
- _defineProperty(_assertThisInitialized(_this), "defaultName", "discount");
29
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
28
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'discount');
29
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
30
30
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
31
31
  _defineProperty(_assertThisInitialized(_this), "window", void 0);
32
32
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
@@ -59,19 +59,19 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
59
59
  }
60
60
 
61
61
  // 获取依赖的插件
62
- this.request = core.getPlugin("request");
63
- this.window = core.getPlugin("window");
62
+ this.request = core.getPlugin('request');
63
+ this.window = core.getPlugin('window');
64
64
  if (this.request) {
65
65
  _context.next = 9;
66
66
  break;
67
67
  }
68
- throw new Error("discount模块需要 request 插件支持");
68
+ throw new Error('discount模块需要 request 插件支持');
69
69
  case 9:
70
70
  if (this.window) {
71
71
  _context.next = 11;
72
72
  break;
73
73
  }
74
- throw new Error("discount模块需要 window 插件支持");
74
+ throw new Error('discount模块需要 window 插件支持');
75
75
  case 11:
76
76
  case "end":
77
77
  return _context.stop();
@@ -147,7 +147,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
147
147
  return this.request.get("/machinecode/batch-search", {
148
148
  code: code,
149
149
  translate_flag: 1,
150
- tag: "good_pass",
150
+ tag: 'good_pass',
151
151
  available: 1,
152
152
  relation_product: 1
153
153
  });
@@ -170,7 +170,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
170
170
  key: "filterEnabledDiscountList",
171
171
  value: function filterEnabledDiscountList(discountList) {
172
172
  return discountList.filter(function (discount) {
173
- return discount.limit_status === "enable" && Number((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0) - Number((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0) > 0;
173
+ return discount.limit_status === 'enable' && Number((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0) - Number((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0) > 0;
174
174
  });
175
175
  }
176
176
 
@@ -178,7 +178,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
178
178
  }, {
179
179
  key: "uniqueByProductId",
180
180
  value: function uniqueByProductId(discountList) {
181
- return uniqueById(discountList, "product_id");
181
+ return uniqueById(discountList, 'product_id');
182
182
  }
183
183
  }, {
184
184
  key: "filterDiscountListByProductIds",
@@ -215,7 +215,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
215
215
  _context5.next = 4;
216
216
  return this.core.effects.emit(DiscountHooks.OnDestroy, {});
217
217
  case 4:
218
- console.log("[Discount] 已销毁");
218
+ console.log('[Discount] 已销毁');
219
219
  case 5:
220
220
  case "end":
221
221
  return _context5.stop();
@@ -235,7 +235,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
235
235
  while (1) switch (_context6.prev = _context6.next) {
236
236
  case 0:
237
237
  this.store.discountList = [];
238
- console.log("[Discount] clear");
238
+ console.log('[Discount] clear');
239
239
  case 2:
240
240
  case "end":
241
241
  return _context6.stop();
@@ -1,6 +1,7 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { OrderModuleAPI, CommitOrderParams } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { OrderModuleAPI, CommitOrderParams } from './types';
4
+ import { CartItem } from '../Cart/types';
4
5
  export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
5
6
  protected defaultName: string;
6
7
  protected defaultVersion: string;
@@ -8,7 +9,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
8
9
  private request;
9
10
  constructor(name?: string, version?: string);
10
11
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
11
- createOrder(params: CommitOrderParams["query"]): {
12
+ createOrder(params: CommitOrderParams['query']): {
12
13
  type: string;
13
14
  platform: string;
14
15
  sales_channel: string;
@@ -18,5 +19,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
18
19
  schedule_date: string;
19
20
  is_deposit: number;
20
21
  };
21
- commitOrder(order: CommitOrderParams): Promise<void>;
22
+ checkBeforeSubmitOrder(params: {
23
+ cartItems: CartItem[];
24
+ type: 'holder' | 'account';
25
+ }): boolean;
26
+ submitOrder(order: CommitOrderParams): Promise<void>;
22
27
  }
@@ -23,8 +23,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
23
23
  var _this;
24
24
  _classCallCheck(this, OrderModule);
25
25
  _this = _super.call(this, name, version);
26
- _defineProperty(_assertThisInitialized(_this), "defaultName", "order");
27
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
26
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'order');
27
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
28
28
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
29
29
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
30
30
  return _this;
@@ -38,7 +38,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
38
38
  case 0:
39
39
  this.core = core;
40
40
  this.store = options.store;
41
- this.request = this.core.getPlugin("request");
41
+ this.request = this.core.getPlugin('request');
42
42
  case 3:
43
43
  case "end":
44
44
  return _context.stop();
@@ -54,13 +54,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
54
54
  key: "createOrder",
55
55
  value: function createOrder(params) {
56
56
  var order = {
57
- type: "appointment_booking",
58
- platform: "H5",
59
- sales_channel: "my_pisel",
60
- order_sales_channel: "online_store",
57
+ type: 'appointment_booking',
58
+ platform: 'H5',
59
+ sales_channel: 'my_pisel',
60
+ order_sales_channel: 'online_store',
61
61
  bookings: [],
62
- shop_note: "",
63
- schedule_date: "",
62
+ shop_note: '',
63
+ schedule_date: '',
64
64
  is_deposit: 0
65
65
  };
66
66
  var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
@@ -72,21 +72,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
72
72
  }
73
73
  });
74
74
  var firstCartItem = params.cartItems[0];
75
- order.schedule_date = firstCartItem.start_date + " " + firstCartItem.start_time + ":00";
75
+ order.schedule_date = firstCartItem.start_date + ' ' + firstCartItem.start_time + ':00';
76
76
  order.is_deposit = is_deposit;
77
77
  }
78
78
  return order;
79
79
  }
80
80
  }, {
81
- key: "commitOrder",
81
+ key: "checkBeforeSubmitOrder",
82
+ value: function checkBeforeSubmitOrder(params) {
83
+ var cartItems = params.cartItems,
84
+ type = params.type;
85
+ if (type === 'holder') {
86
+ // 判断cartItems中是否有不存在holder_id的商品,如果有则返回false
87
+ var hasNoHolderId = cartItems.some(function (item) {
88
+ return !item.holder_id;
89
+ });
90
+ if (hasNoHolderId) {
91
+ return false;
92
+ }
93
+ }
94
+ return true;
95
+ }
96
+ }, {
97
+ key: "submitOrder",
82
98
  value: function () {
83
- var _commitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
99
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(order) {
84
100
  var url, query, fetchUrl, params;
85
101
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
86
102
  while (1) switch (_context2.prev = _context2.next) {
87
103
  case 0:
88
104
  url = order.url, query = order.query;
89
- fetchUrl = url || "/order/appointment";
105
+ fetchUrl = url || '/order/appointment';
90
106
  params = this.createOrder(query);
91
107
  return _context2.abrupt("return", this.request.post(fetchUrl, params));
92
108
  case 4:
@@ -95,10 +111,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
95
111
  }
96
112
  }, _callee2, this);
97
113
  }));
98
- function commitOrder(_x3) {
99
- return _commitOrder.apply(this, arguments);
114
+ function submitOrder(_x3) {
115
+ return _submitOrder.apply(this, arguments);
100
116
  }
101
- return commitOrder;
117
+ return submitOrder;
102
118
  }()
103
119
  }]);
104
120
  return OrderModule;
@@ -1,4 +1,4 @@
1
- import { CartItem } from "../Cart/types";
1
+ import { CartItem } from '../Cart/types';
2
2
  export declare enum OrderHooks {
3
3
  OnOrderCreate = "order:onOrderCreate",
4
4
  OnOrderUpdate = "order:onOrderUpdate",
@@ -25,10 +25,17 @@ export interface OrderModuleAPI {
25
25
  * @param params 订单信息
26
26
  * @returns 订单信息
27
27
  */
28
- createOrder: (params: CommitOrderParams["query"]) => any;
28
+ createOrder: (params: CommitOrderParams['query']) => any;
29
+ /**
30
+ * 检查购物车提交订单前是否符合条件
31
+ */
32
+ checkBeforeSubmitOrder: (params: {
33
+ cartItems: CartItem[];
34
+ type: 'holder' | 'account';
35
+ }) => boolean;
29
36
  /**
30
37
  * 提交订单
31
38
  * @param params 订单信息
32
39
  */
33
- commitOrder: (params: CommitOrderParams) => Promise<void>;
40
+ submitOrder: (params: CommitOrderParams) => Promise<void>;
34
41
  }
@@ -21,7 +21,7 @@ export declare class Product extends BaseModule implements Module {
21
21
  /**
22
22
  * 获取商品数据
23
23
  */
24
- getData(): ProductData | null;
24
+ getData(): ProductData;
25
25
  /**
26
26
  * 获取商品ID
27
27
  */
@@ -46,4 +46,7 @@ export declare class Product extends BaseModule implements Module {
46
46
  * 获取商品分类
47
47
  */
48
48
  getCategories(): ProductCategory[];
49
+ setOtherParams(key: string, value: any): void;
50
+ getOtherParams(): any;
51
+ getProductType(): "duration" | "session" | "normal";
49
52
  }
@@ -126,6 +126,28 @@ export var Product = /*#__PURE__*/function (_BaseModule) {
126
126
  value: function getCategories() {
127
127
  return this.store.categories;
128
128
  }
129
+ }, {
130
+ key: "setOtherParams",
131
+ value: function setOtherParams(key, value) {
132
+ this.otherParams[key] = value;
133
+ }
134
+ }, {
135
+ key: "getOtherParams",
136
+ value: function getOtherParams() {
137
+ return this.otherParams;
138
+ }
139
+ }, {
140
+ key: "getProductType",
141
+ value: function getProductType() {
142
+ var _this$store$schedule;
143
+ if (this.store.duration) {
144
+ return 'duration';
145
+ }
146
+ if ((_this$store$schedule = this.store['schedule.ids']) !== null && _this$store$schedule !== void 0 && _this$store$schedule.length) {
147
+ return 'session';
148
+ }
149
+ return 'normal';
150
+ }
129
151
  }]);
130
152
  return Product;
131
153
  }(BaseModule);
@@ -17,7 +17,7 @@ export interface ProductData {
17
17
  /** 商品slug */
18
18
  slug: string;
19
19
  /** draft:草稿;published:已发布;pending:待发布;archived:已归档 */
20
- status: "draft" | "published" | "pending" | "archived";
20
+ status: 'draft' | 'published' | 'pending' | 'archived';
21
21
  /** 库存数量 */
22
22
  stock_quantity: number;
23
23
  /** 销售数量 */
@@ -156,6 +156,10 @@ export interface ProductData {
156
156
  capacity?: any;
157
157
  /** 商品套餐 */
158
158
  product_bundle?: any;
159
+ /** 日程ids */
160
+ 'schedule.ids'?: number[];
161
+ /** 商品日程信息,前端临时用,随时需要回收的 */
162
+ _schedule?: any;
159
163
  /** 商品定金信息 */
160
164
  custom_deposit_data?: {
161
165
  /** 商品是否包含定金 1:是 0:否 */
@@ -434,7 +438,7 @@ export interface ProductResourceItem {
434
438
  /** 资源标题 */
435
439
  title: string;
436
440
  /** 资源编码 */
437
- code: "resource";
441
+ code: 'resource';
438
442
  /** 默认资源 */
439
443
  default_resource?: number[];
440
444
  /** 可选资源 */
@@ -443,7 +447,7 @@ export interface ProductResourceItem {
443
447
  resource_type_id: number;
444
448
  /** 选择类型 */
445
449
  select_type?: {
446
- type: "single";
450
+ type: 'single';
447
451
  min: 1;
448
452
  max: 1;
449
453
  };
@@ -42,16 +42,22 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
42
42
  key: "initialize",
43
43
  value: function () {
44
44
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
45
+ var _options$initialState;
45
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
46
47
  while (1) switch (_context.prev = _context.next) {
47
48
  case 0:
48
49
  this.core = core;
49
50
  this.store = options.store;
50
- this.store.productMap = new Map();
51
- this.store.list = [];
52
- this.store.selectProducts = [];
53
- this.storeChange();
54
- case 6:
51
+ if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
52
+ this.store.list = options.initialState.list;
53
+ this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
54
+ this.storeChange();
55
+ } else {
56
+ this.store.list = [];
57
+ this.store.productMap = new Map();
58
+ this.store.selectProducts = [];
59
+ }
60
+ case 3:
55
61
  case "end":
56
62
  return _context.stop();
57
63
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @title: 获取资源map
3
- * @description:
3
+ * @description:
4
4
  * @param {any} resourceList
5
5
  * @return {*}
6
6
  * @Author: zhiwei.Wang