@pisell/pisellos 0.0.44 → 0.0.46

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 +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 +5 -5
  13. package/dist/modules/Cart/index.js +33 -19
  14. package/dist/modules/Cart/types.d.ts +21 -7
  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 +71 -16
  53. package/dist/solution/BookingByStep/index.js +643 -227
  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 +6 -5
  59. package/dist/solution/BookingByStep/utils/resources.js +37 -19
  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 +20 -1
  69. package/lib/modules/AccountList/index.js +122 -13
  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 +28 -6
  77. package/lib/modules/Cart/types.d.ts +21 -7
  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 +71 -16
  116. package/lib/solution/BookingByStep/index.js +396 -48
  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 +6 -5
  122. package/lib/solution/BookingByStep/utils/resources.js +128 -58
  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
@@ -15,7 +15,7 @@ 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";
18
+ import dayjs from 'dayjs';
19
19
  import { BaseModule } from "../BaseModule";
20
20
  import { disableAllDates, generateMonthDates, handleAvailableDateByResource, handleAvailableDatesByRules } from "./utils";
21
21
  export var DateModule = /*#__PURE__*/function (_BaseModule) {
@@ -25,8 +25,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
25
25
  var _this;
26
26
  _classCallCheck(this, DateModule);
27
27
  _this = _super.call(this, name, version);
28
- _defineProperty(_assertThisInitialized(_this), "defaultName", "date");
29
- _defineProperty(_assertThisInitialized(_this), "defaultVersion", "1.0.0");
28
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'date');
29
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
30
30
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
31
31
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
32
32
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
@@ -44,7 +44,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
44
44
  case 0:
45
45
  this.core = core;
46
46
  this.store = options.store;
47
- this.request = this.core.getPlugin("request");
47
+ this.request = this.core.getPlugin('request');
48
48
  if (options.initialState) {
49
49
  this.store.dateRange = options.initialState.dateRange;
50
50
  this.store.dateList = options.initialState.dateList;
@@ -53,7 +53,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
53
53
  _context.next = 6;
54
54
  break;
55
55
  }
56
- throw new Error("DateModule 需要 request 插件支持");
56
+ throw new Error('DateModule 需要 request 插件支持');
57
57
  case 6:
58
58
  if ((_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
59
59
  this.openCache = options.otherParams.openCache;
@@ -84,15 +84,15 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
84
84
  return this.store.dateRange;
85
85
  }
86
86
  }, {
87
- key: "getMonthDates",
87
+ key: "getResourceDates",
88
88
  value: function () {
89
- var _getMonthDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
89
+ var _getResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
90
90
  var dates;
91
91
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
92
92
  while (1) switch (_context2.prev = _context2.next) {
93
93
  case 0:
94
94
  _context2.next = 2;
95
- return this.getAvailableTimeList(params);
95
+ return this.getResourceAvailableTimeList(params);
96
96
  case 2:
97
97
  dates = _context2.sent;
98
98
  this.store.dateList = dates;
@@ -103,57 +103,43 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
103
103
  }
104
104
  }, _callee2, this);
105
105
  }));
106
- function getMonthDates(_x3) {
107
- return _getMonthDates.apply(this, arguments);
106
+ function getResourceDates(_x3) {
107
+ return _getResourceDates.apply(this, arguments);
108
108
  }
109
- return getMonthDates;
109
+ return getResourceDates;
110
110
  }()
111
111
  }, {
112
112
  key: "getDateList",
113
+ value: function getDateList() {
114
+ return this.store.dateList;
115
+ }
116
+ }, {
117
+ key: "getResourceAvailableTimeList",
113
118
  value: function () {
114
- var _getDateList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
119
+ var _getResourceAvailableTimeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
120
+ var url, query, rules, type, fetchUrl, _ref, start_date, end_date, resource_ids, dates, _res$data, res;
115
121
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
116
122
  while (1) switch (_context3.prev = _context3.next) {
117
123
  case 0:
118
- return _context3.abrupt("return", this.store.dateList);
119
- case 1:
120
- case "end":
121
- return _context3.stop();
122
- }
123
- }, _callee3, this);
124
- }));
125
- function getDateList() {
126
- return _getDateList.apply(this, arguments);
127
- }
128
- return getDateList;
129
- }()
130
- }, {
131
- key: "getAvailableTimeList",
132
- value: function () {
133
- var _getAvailableTimeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
134
- var url, query, rules, fetchUrl, _ref, start_date, end_date, resource_ids, dates, _res$data, res;
135
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
136
- while (1) switch (_context4.prev = _context4.next) {
137
- case 0:
138
- url = params.url, query = params.query, rules = params.rules;
139
- fetchUrl = url || "/schedule/resource/list";
124
+ url = params.url, query = params.query, rules = params.rules, type = params.type;
125
+ fetchUrl = url || '/schedule/resource/list';
140
126
  _ref = query || {}, start_date = _ref.start_date, end_date = _ref.end_date, resource_ids = _ref.resource_ids;
141
127
  if (!(!start_date || !end_date)) {
142
- _context4.next = 5;
128
+ _context3.next = 5;
143
129
  break;
144
130
  }
145
- return _context4.abrupt("return", []);
131
+ return _context3.abrupt("return", []);
146
132
  case 5:
147
133
  // 1.生成当前月份的所有日期,默认都是可用的
148
- dates = generateMonthDates(start_date, end_date); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
134
+ dates = generateMonthDates(start_date, end_date, type); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
149
135
  if (!(!(resource_ids !== null && resource_ids !== void 0 && resource_ids.length) || dayjs(end_date).isBefore(dayjs()))) {
150
- _context4.next = 8;
136
+ _context3.next = 8;
151
137
  break;
152
138
  }
153
- return _context4.abrupt("return", disableAllDates(dates));
139
+ return _context3.abrupt("return", disableAllDates(dates));
154
140
  case 8:
155
- _context4.prev = 8;
156
- _context4.next = 11;
141
+ _context3.prev = 8;
142
+ _context3.next = 11;
157
143
  return this.request.get(fetchUrl, {
158
144
  start_date: start_date,
159
145
  end_date: end_date,
@@ -163,12 +149,12 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
163
149
  useCache: true
164
150
  });
165
151
  case 11:
166
- res = _context4.sent;
152
+ res = _context3.sent;
167
153
  if (res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && _res$data.length) {
168
- _context4.next = 14;
154
+ _context3.next = 14;
169
155
  break;
170
156
  }
171
- return _context4.abrupt("return", disableAllDates(dates));
157
+ return _context3.abrupt("return", disableAllDates(dates));
172
158
  case 14:
173
159
  // 2.根据资源times判定哪些日期内存在可用资源
174
160
  dates = handleAvailableDateByResource(res.data, dates);
@@ -177,22 +163,22 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
177
163
  if (rules !== null && rules !== void 0 && rules.length) {
178
164
  dates = handleAvailableDatesByRules(dates, rules);
179
165
  }
180
- return _context4.abrupt("return", dates);
166
+ return _context3.abrupt("return", dates);
181
167
  case 19:
182
- _context4.prev = 19;
183
- _context4.t0 = _context4["catch"](8);
184
- console.log("getAvailableTimeList_error", _context4.t0);
185
- return _context4.abrupt("return", disableAllDates(dates));
168
+ _context3.prev = 19;
169
+ _context3.t0 = _context3["catch"](8);
170
+ console.log('getAvailableTimeList_error', _context3.t0);
171
+ return _context3.abrupt("return", disableAllDates(dates));
186
172
  case 23:
187
173
  case "end":
188
- return _context4.stop();
174
+ return _context3.stop();
189
175
  }
190
- }, _callee4, this, [[8, 19]]);
176
+ }, _callee3, this, [[8, 19]]);
191
177
  }));
192
- function getAvailableTimeList(_x4) {
193
- return _getAvailableTimeList.apply(this, arguments);
178
+ function getResourceAvailableTimeList(_x4) {
179
+ return _getResourceAvailableTimeList.apply(this, arguments);
194
180
  }
195
- return getAvailableTimeList;
181
+ return getResourceAvailableTimeList;
196
182
  }()
197
183
  }, {
198
184
  key: "clearDateRange",
@@ -207,7 +193,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
207
193
  cacheId: this.cacheId,
208
194
  fatherModule: this.fatherModule,
209
195
  store: this.store,
210
- cacheKey: ["dateRange", "dateList"]
196
+ cacheKey: ['dateRange', 'dateList']
211
197
  });
212
198
  }
213
199
  }
@@ -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
  }