@pisell/pisellos 2.1.45 → 2.1.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.
@@ -14,6 +14,8 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
14
14
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
15
  setDiscountList(discountList: Discount[]): Promise<void>;
16
16
  getDiscountList(): Discount[];
17
+ setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
18
+ getOriginalDiscountList(): Discount[];
17
19
  loadPrepareConfig(params: {
18
20
  action?: 'create';
19
21
  with_good_pass: 0 | 1;
@@ -46,7 +46,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
46
46
  key: "initialize",
47
47
  value: function () {
48
48
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
49
- var _options$initialState, _options$otherParams, _options$otherParams2;
49
+ var _options$initialState, _options$initialState2, _options$otherParams, _options$otherParams2;
50
50
  return _regeneratorRuntime().wrap(function _callee$(_context) {
51
51
  while (1) switch (_context.prev = _context.next) {
52
52
  case 0:
@@ -57,6 +57,11 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
57
57
  } else {
58
58
  this.store.discountList = [];
59
59
  }
60
+ if (Array.isArray(options === null || options === void 0 || (_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.originalDiscountList)) {
61
+ this.store.originalDiscountList = options === null || options === void 0 ? void 0 : options.initialState.originalDiscountList;
62
+ } else {
63
+ this.store.originalDiscountList = [];
64
+ }
60
65
  if (options !== null && options !== void 0 && (_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
61
66
  this.openCache = options.otherParams.openCache;
62
67
  this.cacheId = options.otherParams.cacheId;
@@ -69,17 +74,17 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
69
74
  this.request = core.getPlugin('request');
70
75
  this.window = core.getPlugin('window');
71
76
  if (this.request) {
72
- _context.next = 9;
77
+ _context.next = 10;
73
78
  break;
74
79
  }
75
80
  throw new Error('discount模块需要 request 插件支持');
76
- case 9:
81
+ case 10:
77
82
  if (this.window) {
78
- _context.next = 11;
83
+ _context.next = 12;
79
84
  break;
80
85
  }
81
86
  throw new Error('discount模块需要 window 插件支持');
82
- case 11:
87
+ case 12:
83
88
  case "end":
84
89
  return _context.stop();
85
90
  }
@@ -116,28 +121,54 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
116
121
  value: function getDiscountList() {
117
122
  return this.store.discountList;
118
123
  }
124
+
125
+ // 设置原始优惠券列表
126
+ }, {
127
+ key: "setOriginalDiscountList",
128
+ value: function () {
129
+ var _setOriginalDiscountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(originalDiscountList) {
130
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
131
+ while (1) switch (_context3.prev = _context3.next) {
132
+ case 0:
133
+ this.store.originalDiscountList = originalDiscountList;
134
+ case 1:
135
+ case "end":
136
+ return _context3.stop();
137
+ }
138
+ }, _callee3, this);
139
+ }));
140
+ function setOriginalDiscountList(_x4) {
141
+ return _setOriginalDiscountList.apply(this, arguments);
142
+ }
143
+ return setOriginalDiscountList;
144
+ }() // 获取原始优惠券列表
145
+ }, {
146
+ key: "getOriginalDiscountList",
147
+ value: function getOriginalDiscountList() {
148
+ return this.store.originalDiscountList || [];
149
+ }
119
150
  }, {
120
151
  key: "loadPrepareConfig",
121
152
  value: function () {
122
- var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
153
+ var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
123
154
  var _prepareConfig$data, _prepareConfig$data2;
124
155
  var prepareConfig, goodPassList;
125
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
126
- while (1) switch (_context3.prev = _context3.next) {
156
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
157
+ while (1) switch (_context4.prev = _context4.next) {
127
158
  case 0:
128
- _context3.next = 2;
159
+ _context4.next = 2;
129
160
  return this.request.post("/order/prepare/config", params);
130
161
  case 2:
131
- prepareConfig = _context3.sent;
162
+ prepareConfig = _context4.sent;
132
163
  goodPassList = this.filterEnabledDiscountList([].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []))) || []; // this.setDiscountList(goodPassList);
133
- return _context3.abrupt("return", goodPassList);
164
+ return _context4.abrupt("return", goodPassList);
134
165
  case 5:
135
166
  case "end":
136
- return _context3.stop();
167
+ return _context4.stop();
137
168
  }
138
- }, _callee3, this);
169
+ }, _callee4, this);
139
170
  }));
140
- function loadPrepareConfig(_x4) {
171
+ function loadPrepareConfig(_x5) {
141
172
  return _loadPrepareConfig.apply(this, arguments);
142
173
  }
143
174
  return loadPrepareConfig;
@@ -145,12 +176,12 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
145
176
  }, {
146
177
  key: "batchSearch",
147
178
  value: function () {
148
- var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code, customerId) {
179
+ var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
149
180
  var result, resultDiscountList;
150
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
151
- while (1) switch (_context4.prev = _context4.next) {
181
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
182
+ while (1) switch (_context5.prev = _context5.next) {
152
183
  case 0:
153
- _context4.next = 2;
184
+ _context5.next = 2;
154
185
  return this.request.get("/machinecode/batch-search", {
155
186
  code: code,
156
187
  translate_flag: 1,
@@ -162,16 +193,16 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
162
193
  order_behavior_count_customer_id: customerId || 1
163
194
  });
164
195
  case 2:
165
- result = _context4.sent;
196
+ result = _context5.sent;
166
197
  resultDiscountList = this.filterEnabledDiscountList((result === null || result === void 0 ? void 0 : result.data) || []) || [];
167
- return _context4.abrupt("return", resultDiscountList);
198
+ return _context5.abrupt("return", resultDiscountList);
168
199
  case 5:
169
200
  case "end":
170
- return _context4.stop();
201
+ return _context5.stop();
171
202
  }
172
- }, _callee4, this);
203
+ }, _callee5, this);
173
204
  }));
174
- function batchSearch(_x5, _x6) {
205
+ function batchSearch(_x6, _x7) {
175
206
  return _batchSearch.apply(this, arguments);
176
207
  }
177
208
  return batchSearch;
@@ -276,21 +307,21 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
276
307
  }, {
277
308
  key: "destroy",
278
309
  value: function () {
279
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
280
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
281
- while (1) switch (_context5.prev = _context5.next) {
310
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
311
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
312
+ while (1) switch (_context6.prev = _context6.next) {
282
313
  case 0:
283
314
  this.store.discountList = [];
284
315
  this.core.effects.offByModuleDestroy(this.name);
285
- _context5.next = 4;
316
+ _context6.next = 4;
286
317
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
287
318
  case 4:
288
319
  console.log('[Discount] 已销毁');
289
320
  case 5:
290
321
  case "end":
291
- return _context5.stop();
322
+ return _context6.stop();
292
323
  }
293
- }, _callee5, this);
324
+ }, _callee6, this);
294
325
  }));
295
326
  function destroy() {
296
327
  return _destroy.apply(this, arguments);
@@ -300,17 +331,18 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
300
331
  }, {
301
332
  key: "clear",
302
333
  value: function () {
303
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
304
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
305
- while (1) switch (_context6.prev = _context6.next) {
334
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
335
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
336
+ while (1) switch (_context7.prev = _context7.next) {
306
337
  case 0:
307
338
  this.store.discountList = [];
339
+ this.store.originalDiscountList = [];
308
340
  console.log('[Discount] clear');
309
- case 2:
341
+ case 3:
310
342
  case "end":
311
- return _context6.stop();
343
+ return _context7.stop();
312
344
  }
313
- }, _callee6, this);
345
+ }, _callee7, this);
314
346
  }));
315
347
  function clear() {
316
348
  return _clear.apply(this, arguments);
@@ -72,6 +72,7 @@ export interface Discount {
72
72
  format_title: Formattitle;
73
73
  metadata?: {
74
74
  discount_card_type?: 'fixed_amount' | 'percent';
75
+ validity_type?: "custom_schedule_validity" | "fixed_validity";
75
76
  };
76
77
  product: Product;
77
78
  type: "product" | 'good_pass';
@@ -98,9 +99,13 @@ export interface Discount {
98
99
  week_order_behavior_count?: number;
99
100
  month_order_behavior_count?: number;
100
101
  customer_order_behavior_count?: number;
102
+ custom_schedule_snapshot?: {
103
+ data: any[];
104
+ };
101
105
  }
102
106
  export interface DiscountState {
103
107
  discountList: Discount[];
108
+ originalDiscountList?: Discount[];
104
109
  }
105
110
  export interface DiscountModuleAPI {
106
111
  setDiscountList: (discountList: Discount[]) => Promise<void>;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -24,10 +24,11 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
24
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
25
  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); }
26
26
  import { BaseModule } from "../BaseModule";
27
- import { uniqueById, getDiscountAmount } from "../../solution/ShopDiscount/utils";
27
+ import { uniqueById, getDiscountAmount, filterDiscountListByBookingTime } from "../../solution/ShopDiscount/utils";
28
28
  import { getProductOriginTotalPrice, getProductTotalPrice } from "../Cart/utils";
29
29
  import Decimal from 'decimal.js';
30
30
  import { isBoolean } from 'lodash-es';
31
+ import dayjs from 'dayjs';
31
32
  export var RulesModule = /*#__PURE__*/function (_BaseModule) {
32
33
  _inherits(RulesModule, _BaseModule);
33
34
  var _super = _createSuper(RulesModule);
@@ -304,7 +305,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
304
305
  addModeDiscount.forEach(function (discount) {
305
306
  var _product$discount_lis2, _product$discount_lis3;
306
307
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
307
-
308
+ var timeLimit = true;
309
+ timeLimit = !!filterDiscountListByBookingTime([discount], ((product === null || product === void 0 ? void 0 : product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
308
310
  // 是符合折扣的商品
309
311
  var isLimitedProduct = limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id);
310
312
 
@@ -314,7 +316,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
314
316
  }));
315
317
 
316
318
  // 判断优惠券是否适用于该商品
317
- if (isAvailableProduct && isLimitedProduct) {
319
+ if (isAvailableProduct && isLimitedProduct && timeLimit) {
318
320
  var _discountApplicabilit, _discount$metadata;
319
321
  // 记录此优惠券适用的商品
320
322
  (_discountApplicabilit = discountApplicability.get(discount.id)) === null || _discountApplicabilit === void 0 || _discountApplicabilit.push(product.id);
@@ -374,6 +376,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
374
376
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
375
377
  if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
376
378
  var limitedData = discount.limited_relation_product_data;
379
+ var timeLimit = true;
380
+ timeLimit = !!filterDiscountListByBookingTime([discount], (product.startDate || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
381
+ if (!timeLimit) {
382
+ return false;
383
+ }
377
384
 
378
385
  // 判断优惠券是否适用于该商品
379
386
  if (limitedData.type === 'product_all') {
@@ -40,6 +40,7 @@ type ProductDetail = {
40
40
  num?: number;
41
41
  quantity: number;
42
42
  vouchersApplicable?: boolean;
43
+ startDate?: any;
43
44
  };
44
45
  export interface RulesParamsHooks {
45
46
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -2313,6 +2313,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2313
2313
  }
2314
2314
  });
2315
2315
  });
2316
+ this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateBookingDate"), {});
2316
2317
  }
2317
2318
  }, {
2318
2319
  key: "getScheduleDataByIds",
@@ -18,6 +18,8 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
18
18
  private initializePlugins;
19
19
  private registerDependentModules;
20
20
  private registerEventListeners;
21
+ getCurrentBookingTime(): string | null;
22
+ private filterDiscountListByBookingTime;
21
23
  setCustomer(customer: Customer): Promise<void>;
22
24
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
23
25
  productList: Record<string, any>[];
@@ -27,6 +27,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
27
27
  import { BaseModule } from "../../modules/BaseModule";
28
28
  import { DiscountModule } from "../../modules/Discount";
29
29
  import { RulesModule } from "../../modules/Rules";
30
+ import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, isAllNormalProduct } from "./utils";
30
31
  import Decimal from 'decimal.js';
31
32
  import { isBoolean } from 'lodash-es';
32
33
  export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
@@ -50,7 +51,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
50
51
  productList: [],
51
52
  discount: null,
52
53
  rules: null,
53
- originalDiscountList: []
54
+ originalDiscountList: [],
55
+ currentBookingTime: "",
56
+ filteredDiscountList: []
54
57
  };
55
58
  return _this;
56
59
  }
@@ -207,6 +210,55 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
207
210
 
208
211
  // =========== 公共 API ===========
209
212
 
213
+ // 设置预约时间
214
+ // public async setBookingTime(bookingTime: string | null): Promise<void> {
215
+ // if (this.store.currentBookingTime !== bookingTime) {
216
+ // this.store.currentBookingTime = bookingTime;
217
+ //
218
+ // // 更新过滤后的优惠券列表
219
+ // await this.updateFilteredDiscountList();
220
+ // }
221
+ // }
222
+
223
+ // 获取当前预约时间
224
+ }, {
225
+ key: "getCurrentBookingTime",
226
+ value: function getCurrentBookingTime() {
227
+ return this.store.currentBookingTime;
228
+ }
229
+
230
+ // 根据预约时间过滤优惠券列表
231
+ }, {
232
+ key: "filterDiscountListByBookingTime",
233
+ value: function filterDiscountListByBookingTime(discountList, bookingTime) {
234
+ // 如果全部是普通商品,不需要过滤,直接返回当前数据
235
+ if (isAllNormalProduct(this.store.productList || [])) {
236
+ return discountList;
237
+ }
238
+
239
+ // 否则使用 bookingTime 进行过滤
240
+ return _filterDiscountListByBookingTime(discountList, bookingTime);
241
+ }
242
+
243
+ // 更新过滤后的优惠券列表
244
+ // private async updateFilteredDiscountList(): Promise<void> {
245
+ // const originalList = this.store.originalDiscountList;
246
+ // const filteredList = this.filterDiscountListByBookingTime(originalList, this.store.currentBookingTime);
247
+ //
248
+ // this.store.filteredDiscountList = filteredList;
249
+ //
250
+ // // 更新 DiscountModule 中的优惠券列表
251
+ // this.setDiscountList(filteredList);
252
+ //
253
+ // if (this.store.productList?.length) {
254
+ // const result = this.calcDiscount(this.store.productList);
255
+ // await this.core.effects.emit(
256
+ // ShopDiscountHooks.onLoadPrepareCalcResult,
257
+ // result,
258
+ // );
259
+ // }
260
+ // }
261
+
210
262
  // 设置客户
211
263
  }, {
212
264
  key: "setCustomer",
@@ -652,7 +704,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
652
704
  key: "loadPrepareConfig",
653
705
  value: function () {
654
706
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
655
- var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, _result3;
707
+ var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
656
708
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
657
709
  while (1) switch (_context9.prev = _context9.next) {
658
710
  case 0:
@@ -678,31 +730,37 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
678
730
  newGoodPassList = goodPassList === null || goodPassList === void 0 ? void 0 : goodPassList.filter(function (n) {
679
731
  return !scanDiscountIds.includes(n.id);
680
732
  });
681
- newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || []));
733
+ newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
682
734
  this.store.originalDiscountList = newDiscountList;
683
- this.setDiscountList(newDiscountList || []);
735
+ _context9.next = 12;
736
+ return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
737
+ case 12:
738
+ // 根据当前预约时间过滤优惠券列表
739
+ filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
740
+ this.store.filteredDiscountList = filteredDiscountList;
741
+ this.setDiscountList(filteredDiscountList || []);
684
742
  if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
685
- _context9.next = 15;
743
+ _context9.next = 19;
686
744
  break;
687
745
  }
688
746
  _result3 = this.calcDiscount(this.store.productList);
689
- _context9.next = 15;
747
+ _context9.next = 19;
690
748
  return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
691
- case 15:
692
- _context9.next = 17;
693
- return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
694
- case 17:
695
- _context9.next = 22;
696
- break;
697
749
  case 19:
698
- _context9.prev = 19;
750
+ _context9.next = 21;
751
+ return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
752
+ case 21:
753
+ _context9.next = 26;
754
+ break;
755
+ case 23:
756
+ _context9.prev = 23;
699
757
  _context9.t0 = _context9["catch"](0);
700
758
  console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
701
- case 22:
759
+ case 26:
702
760
  case "end":
703
761
  return _context9.stop();
704
762
  }
705
- }, _callee9, this, [[0, 19]]);
763
+ }, _callee9, this, [[0, 23]]);
706
764
  }));
707
765
  function loadPrepareConfig(_x9) {
708
766
  return _loadPrepareConfig.apply(this, arguments);
@@ -1,5 +1,6 @@
1
- import { DiscountModule, Discount } from '../../modules/Discount';
1
+ import { DiscountModule } from '../../modules/Discount';
2
2
  import { RulesModule } from '../../modules/Rules';
3
+ import { Discount } from "../../modules/Discount/types";
3
4
  export declare enum ShopDiscountHooks {
4
5
  onInited = "shopDiscount:onInited",
5
6
  onDestroy = "shopDiscount:onDestroy",
@@ -23,6 +24,8 @@ export interface ShopDiscountState {
23
24
  rules: RulesModule | null;
24
25
  productList: Record<string, any>[];
25
26
  originalDiscountList: Discount[];
27
+ currentBookingTime: string | null;
28
+ filteredDiscountList: Discount[];
26
29
  }
27
30
  export interface SetDiscountSelectedParams {
28
31
  discountId: number;
@@ -1,5 +1,7 @@
1
1
  import { Discount } from "../../modules/Discount/types";
2
2
  export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
3
+ export declare const isNormalProductByDurationSchedule: (item: any) => boolean;
4
+ export declare const isAllNormalProduct: (items: any[]) => boolean;
3
5
  /**
4
6
  * 获取折扣金额 基于折扣卡类型计算
5
7
  * 商品券:直接返回商品价格
@@ -10,3 +12,49 @@ export declare const uniqueById: <T>(arr: T[], key?: string) => T[];
10
12
  * @returns
11
13
  */
12
14
  export declare const getDiscountAmount: (discount: Discount, total: number, price: number) => number;
15
+ export interface ScheduleItem {
16
+ id: number;
17
+ name: string | {
18
+ [key: string]: string;
19
+ };
20
+ type: 'standard' | 'time-slots' | 'designation';
21
+ start_time: string | null;
22
+ end_time: string | null;
23
+ repeat_type: 'none' | 'daily' | 'weekly';
24
+ repeat_rule: {
25
+ end: {
26
+ type: 'never' | 'date' | 'occurrence';
27
+ end_date: string | null;
28
+ occurrence: number | null;
29
+ };
30
+ frequency: number;
31
+ excluded_date: Array<{
32
+ start: string;
33
+ end: string;
34
+ }>;
35
+ included_date: Array<{
36
+ start: string;
37
+ end: string;
38
+ }>;
39
+ frequency_date: number[];
40
+ } | null;
41
+ designation: Array<{
42
+ start_date: string;
43
+ start_time: string;
44
+ end_date: string;
45
+ end_time: string;
46
+ }> | null;
47
+ is_all: number;
48
+ time_slot: Array<{
49
+ start_time: string;
50
+ end_time: string;
51
+ }>;
52
+ }
53
+ export declare const getDateIsInSchedule: (dateTime: string, scheduleList: ScheduleItem[]) => boolean;
54
+ /**
55
+ * 根据预约时间过滤优惠券列表
56
+ * @param discountList 优惠券列表
57
+ * @param bookingTime 预约时间 (格式: YYYY-MM-DD HH:mm:ss)
58
+ * @returns 过滤后的优惠券列表
59
+ */
60
+ export declare const filterDiscountListByBookingTime: (discountList: Discount[], bookingTime: string | null) => Discount[];