@pisell/pisellos 2.1.1 → 2.1.3

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 (31) hide show
  1. package/dist/modules/Cart/utils/changePrice.d.ts +2 -2
  2. package/dist/modules/Cart/utils/changePrice.js +1 -1
  3. package/dist/modules/Discount/index.d.ts +2 -1
  4. package/dist/modules/Discount/index.js +67 -4
  5. package/dist/modules/Discount/types.d.ts +25 -0
  6. package/dist/modules/ProductList/index.d.ts +1 -2
  7. package/dist/modules/ProductList/index.js +26 -40
  8. package/dist/modules/ProductList/types.d.ts +0 -1
  9. package/dist/solution/BookingByStep/index.js +51 -35
  10. package/dist/solution/BookingByStep/types.d.ts +3 -2
  11. package/dist/solution/BookingByStep/utils/timeslots.js +161 -69
  12. package/dist/solution/BuyTickets/index.d.ts +2 -2
  13. package/dist/solution/BuyTickets/index.js +1 -1
  14. package/dist/solution/ShopDiscount/index.d.ts +1 -1
  15. package/dist/solution/ShopDiscount/index.js +6 -6
  16. package/lib/modules/Cart/utils/changePrice.d.ts +2 -2
  17. package/lib/modules/Cart/utils/changePrice.js +1 -1
  18. package/lib/modules/Discount/index.d.ts +2 -1
  19. package/lib/modules/Discount/index.js +45 -3
  20. package/lib/modules/Discount/types.d.ts +25 -0
  21. package/lib/modules/ProductList/index.d.ts +1 -2
  22. package/lib/modules/ProductList/index.js +8 -24
  23. package/lib/modules/ProductList/types.d.ts +0 -1
  24. package/lib/solution/BookingByStep/index.js +40 -28
  25. package/lib/solution/BookingByStep/types.d.ts +3 -2
  26. package/lib/solution/BookingByStep/utils/timeslots.js +103 -49
  27. package/lib/solution/BuyTickets/index.d.ts +2 -2
  28. package/lib/solution/BuyTickets/index.js +1 -1
  29. package/lib/solution/ShopDiscount/index.d.ts +1 -1
  30. package/lib/solution/ShopDiscount/index.js +2 -2
  31. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
- import { Product } from "../../Product";
1
+ import { ProductData } from "../../Product";
2
2
  import { CartItem, IUpdateItemParams } from "../types";
3
- export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<Product | undefined>, updateCart: (item: IUpdateItemParams) => void, updateItemInitInfo: (item: IUpdateItemParams) => void): Promise<void>;
3
+ export declare function updateAllCartItemPrice(cartItems: CartItem[], priceData: any, getProduct: (id: number) => Promise<ProductData | undefined>, updateCart: (item: IUpdateItemParams) => void, updateItemInitInfo: (item: IUpdateItemParams) => void): Promise<void>;
@@ -36,7 +36,7 @@ function _updateAllCartItemPrice() {
36
36
  return getProduct(item.id);
37
37
  case 4:
38
38
  cartProduct = _context.sent;
39
- productInfo = cartProduct === null || cartProduct === void 0 ? void 0 : cartProduct.getData();
39
+ productInfo = cartProduct;
40
40
  if (!productInfo) {
41
41
  productInfo = item._productOrigin;
42
42
  }
@@ -20,8 +20,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
20
20
  with_discount_card: 0 | 1;
21
21
  customer_id: number;
22
22
  }): Promise<Discount[]>;
23
- batchSearch(code: string): Promise<Discount[]>;
23
+ batchSearch(code: string, customerId?: number): Promise<Discount[]>;
24
24
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
25
+ private checkUsageCreditsLimit;
25
26
  uniqueByProductId(discountList: Discount[]): Discount[];
26
27
  filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
27
28
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
@@ -145,7 +145,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
145
145
  }, {
146
146
  key: "batchSearch",
147
147
  value: function () {
148
- var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code) {
148
+ var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code, customerId) {
149
149
  var result, resultDiscountList;
150
150
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
151
151
  while (1) switch (_context4.prev = _context4.next) {
@@ -156,7 +156,10 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
156
156
  translate_flag: 1,
157
157
  tags: ['good_pass', 'product_discount_card'],
158
158
  available: 1,
159
- relation_product: 1
159
+ relation_product: 1,
160
+ with: ['extensionData'],
161
+ order_behavior_count: 1,
162
+ order_behavior_count_customer_id: customerId || 1
160
163
  });
161
164
  case 2:
162
165
  result = _context4.sent;
@@ -168,7 +171,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
168
171
  }
169
172
  }, _callee4, this);
170
173
  }));
171
- function batchSearch(_x5) {
174
+ function batchSearch(_x5, _x6) {
172
175
  return _batchSearch.apply(this, arguments);
173
176
  }
174
177
  return batchSearch;
@@ -176,11 +179,71 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
176
179
  }, {
177
180
  key: "filterEnabledDiscountList",
178
181
  value: function filterEnabledDiscountList(discountList) {
182
+ var _this2 = this;
179
183
  return discountList.filter(function (discount) {
180
- return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
184
+ return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this2.checkUsageCreditsLimit(discount);
181
185
  });
182
186
  }
183
187
 
188
+ // 检查使用次数限制
189
+ }, {
190
+ key: "checkUsageCreditsLimit",
191
+ value: function checkUsageCreditsLimit(discount) {
192
+ // 如果没有 extension_data,则不需要限制
193
+ if (!discount.extension_data || discount.extension_data.length === 0) {
194
+ return true;
195
+ }
196
+
197
+ // 查找 field_key 为 usage_credits 的数据
198
+ var usageCreditsData = discount.extension_data.find(function (data) {
199
+ return data.field_key === 'usage_credits';
200
+ });
201
+
202
+ // 如果没有找到 usage_credits 数据,则不需要限制
203
+ if (!usageCreditsData) {
204
+ return true;
205
+ }
206
+ var value = usageCreditsData.value;
207
+
208
+ // 检查总次数限制
209
+ if (value.total_credits && value.total_credits > 0) {
210
+ if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
211
+ return false;
212
+ }
213
+ }
214
+
215
+ // 检查单用户限制
216
+ if (value.per_user_limit && value.per_user_limit > 0) {
217
+ if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
218
+ return false;
219
+ }
220
+ }
221
+
222
+ // 检查单日限制
223
+ if (value.max_per_day && value.max_per_day > 0) {
224
+ if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
225
+ return false;
226
+ }
227
+ }
228
+
229
+ // 检查单周限制
230
+ if (value.max_per_week && value.max_per_week > 0) {
231
+ if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
232
+ return false;
233
+ }
234
+ }
235
+
236
+ // 检查单月限制
237
+ if (value.max_per_month && value.max_per_month > 0) {
238
+ if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
239
+ return false;
240
+ }
241
+ }
242
+
243
+ // 所有检查都通过
244
+ return true;
245
+ }
246
+
184
247
  // 根据productIds去重
185
248
  }, {
186
249
  key: "uniqueByProductId",
@@ -36,6 +36,25 @@ interface ApplicableProductDetails {
36
36
  title?: string;
37
37
  };
38
38
  }
39
+ interface UsageCreditsValue {
40
+ total_credits: number;
41
+ per_user_limit: number;
42
+ max_per_day: number;
43
+ max_per_week: number;
44
+ max_per_month: number;
45
+ }
46
+ interface ExtensionData {
47
+ id: number;
48
+ shop_id: number;
49
+ product_id: number;
50
+ field_id: number;
51
+ field_key: string;
52
+ type: string;
53
+ value: UsageCreditsValue | Record<string, any> | string | number | boolean | any[];
54
+ created_at: string | null;
55
+ updated_at: string | null;
56
+ deleted_at: string | null;
57
+ }
39
58
  export interface Discount {
40
59
  id: number;
41
60
  product_name: string;
@@ -70,6 +89,12 @@ export interface Discount {
70
89
  appliedProductDetails: ApplicableProductDetails[];
71
90
  isDisabledForProductUsed?: boolean;
72
91
  amount?: number;
92
+ extension_data?: ExtensionData[];
93
+ total_order_behavior_count?: number;
94
+ today_order_behavior_count?: number;
95
+ week_order_behavior_count?: number;
96
+ month_order_behavior_count?: number;
97
+ customer_order_behavior_count?: number;
73
98
  }
74
99
  export interface DiscountState {
75
100
  discountList: Discount[];
@@ -1,6 +1,5 @@
1
1
  import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Product } from '../Product';
4
3
  import { ProductData } from '../Product/types';
5
4
  export * from './types';
6
5
  export declare class ProductList extends BaseModule implements Module {
@@ -26,7 +25,7 @@ export declare class ProductList extends BaseModule implements Module {
26
25
  channel?: string;
27
26
  }): Promise<any>;
28
27
  getProducts(): Promise<ProductData[]>;
29
- getProduct(id: number): Promise<Product | undefined>;
28
+ getProduct(id: number): Promise<ProductData | undefined>;
30
29
  addProduct(products: ProductData[]): Promise<void>;
31
30
  selectProducts(products: ProductData[]): Promise<void>;
32
31
  }
@@ -16,7 +16,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
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
18
  import { BaseModule } from "../BaseModule";
19
- import { Product } from "../Product";
20
19
  import { ProductListHooks } from "./types";
21
20
  import { cloneDeep } from 'lodash-es';
22
21
  export * from "./types";
@@ -46,12 +45,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
46
45
  this.store = options.store;
47
46
  this.otherParams = options.otherParams || {};
48
47
  if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
49
- this.store.list = options.initialState.list;
48
+ this.store.list = options.initialState.list.slice().sort(function (a, b) {
49
+ return Number(b.sort) - Number(a.sort);
50
+ });
50
51
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
51
- this.storeChange();
52
52
  } else {
53
53
  this.store.list = [];
54
- this.store.productMap = new Map();
55
54
  this.store.selectProducts = [];
56
55
  }
57
56
  this.request = core.getPlugin('request');
@@ -70,28 +69,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
70
69
  key: "storeChange",
71
70
  value: function () {
72
71
  var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, value) {
73
- var _this$store$list,
74
- _this2 = this;
75
72
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
76
73
  while (1) switch (_context2.prev = _context2.next) {
77
74
  case 0:
78
- (_this$store$list = this.store.list) === null || _this$store$list === void 0 || _this$store$list.forEach(function (product) {
79
- var productModule = _this2.store.productMap.get("product-".concat(product.id));
80
- if (!productModule) {
81
- var newProductModule = new Product("product_".concat(product.id.toString()));
82
- _this2.core.registerModule(newProductModule, {
83
- initialState: product
84
- });
85
- _this2.store.productMap.set(product.id.toString(), newProductModule);
86
- } else {
87
- productModule.updateData(product);
88
- }
89
- });
90
- case 1:
91
75
  case "end":
92
76
  return _context2.stop();
93
77
  }
94
- }, _callee2, this);
78
+ }, _callee2);
95
79
  }));
96
80
  function storeChange(_x3, _x4) {
97
81
  return _storeChange.apply(this, arguments);
@@ -103,7 +87,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
103
87
  value: function () {
104
88
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
105
89
  var _this$otherParams;
106
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, cacheId, userPlugin, customer_id, _userPlugin$get, productsData;
90
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, cacheId, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
107
91
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
108
92
  while (1) switch (_context3.prev = _context3.next) {
109
93
  case 0:
@@ -150,9 +134,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
150
134
  });
151
135
  case 6:
152
136
  productsData = _context3.sent;
153
- this.addProduct(productsData.data.list);
154
- return _context3.abrupt("return", productsData.data.list);
155
- case 9:
137
+ sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
138
+ return Number(b.sort) - Number(a.sort);
139
+ });
140
+ this.addProduct(sortedList);
141
+ return _context3.abrupt("return", sortedList);
142
+ case 10:
156
143
  case "end":
157
144
  return _context3.stop();
158
145
  }
@@ -228,15 +215,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
228
215
  _context6.next = 2;
229
216
  return this.core.effects.emit(ProductListHooks.onGetProduct, this.store.list);
230
217
  case 2:
231
- product = this.store.productMap.get("".concat(id));
232
- if (!product) {
233
- _context6.next = 5;
234
- break;
235
- }
236
- return _context6.abrupt("return", product);
237
- case 5:
238
- return _context6.abrupt("return", undefined);
239
- case 6:
218
+ product = this.store.list.find(function (product) {
219
+ return product.id === id;
220
+ });
221
+ return _context6.abrupt("return", product ? cloneDeep(product) : undefined);
222
+ case 4:
240
223
  case "end":
241
224
  return _context6.stop();
242
225
  }
@@ -251,27 +234,30 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
251
234
  key: "addProduct",
252
235
  value: function () {
253
236
  var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
254
- var _this3 = this;
237
+ var _this2 = this;
255
238
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
256
239
  while (1) switch (_context7.prev = _context7.next) {
257
240
  case 0:
258
- // 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
259
241
  // list 需要根据 id 去重
260
242
  if (!this.store.list) {
261
243
  this.store.list = [];
262
244
  }
263
245
  products.forEach(function (n) {
264
- var index = _this3.store.list.findIndex(function (m) {
246
+ var index = _this2.store.list.findIndex(function (m) {
265
247
  return m.id === n.id;
266
248
  });
267
249
  if (index === -1) {
268
- _this3.store.list.push(n);
250
+ _this2.store.list.push(n);
269
251
  } else {
270
- _this3.store.list[index] = n;
252
+ _this2.store.list[index] = n;
271
253
  }
272
254
  });
273
- this.storeChange();
274
- case 3:
255
+ // 根据 sort 值做降序排序(数字越大越靠前)
256
+ this.store.list.sort(function (a, b) {
257
+ return Number(b.sort) - Number(a.sort);
258
+ });
259
+ this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
260
+ case 4:
275
261
  case "end":
276
262
  return _context7.stop();
277
263
  }
@@ -1,7 +1,6 @@
1
1
  import { ProductData } from '../Product/types';
2
2
  export interface ProductListData {
3
3
  list: ProductData[];
4
- productMap: Map<string, any>;
5
4
  selectProducts: ProductData[];
6
5
  }
7
6
  export declare enum ProductListHooks {
@@ -701,6 +701,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
701
701
  _params$useCache,
702
702
  useCache,
703
703
  tempProducts,
704
+ _this$store$currentPr,
704
705
  dateRange,
705
706
  tempStartDate,
706
707
  tempEndDate,
@@ -732,8 +733,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
732
733
  }
733
734
  // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
734
735
  if (this.store.currentProduct) {
735
- tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct.getData()), {}, {
736
- _schedule: this.store.currentProduct.getOtherParams()['schedule']
736
+ tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct), {}, {
737
+ _schedule: (_this$store$currentPr = this.store.currentProductMeta) === null || _this$store$currentPr === void 0 ? void 0 : _this$store$currentPr['schedule']
737
738
  })];
738
739
  }
739
740
  dateRange = this.store.date.getDateRange();
@@ -1280,7 +1281,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1280
1281
  // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1281
1282
  if (!allOriginResources.length) {
1282
1283
  var dateList = this.store.date.getDateList();
1283
- dateList.forEach(function (n) {
1284
+ dateList === null || dateList === void 0 || dateList.forEach(function (n) {
1284
1285
  if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
1285
1286
  });
1286
1287
  }
@@ -2286,41 +2287,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2286
2287
  key: "openProductDetail",
2287
2288
  value: function () {
2288
2289
  var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
2289
- var targetProduct, targetProductData, newScheduleArr, dateRange;
2290
+ var targetProductData, newScheduleArr, dateRange;
2290
2291
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2291
2292
  while (1) switch (_context25.prev = _context25.next) {
2292
2293
  case 0:
2293
2294
  _context25.next = 2;
2294
2295
  return this.store.products.getProduct(productId);
2295
2296
  case 2:
2296
- targetProduct = _context25.sent;
2297
- if (!targetProduct) {
2298
- _context25.next = 16;
2297
+ targetProductData = _context25.sent;
2298
+ if (!targetProductData) {
2299
+ _context25.next = 17;
2299
2300
  break;
2300
2301
  }
2301
- targetProductData = targetProduct.getData();
2302
- this.store.currentProduct = targetProduct;
2302
+ this.store.currentProduct = targetProductData;
2303
+ this.store.currentProductMeta = {};
2303
2304
  // 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
2304
2305
  if (!targetProductData['schedule.ids']) {
2305
- _context25.next = 11;
2306
+ _context25.next = 12;
2306
2307
  break;
2307
2308
  }
2308
2309
  newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
2309
- targetProduct.setOtherParams('schedule', newScheduleArr);
2310
- _context25.next = 16;
2310
+ if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
2311
+ this.store.currentProductMeta.schedule = newScheduleArr;
2312
+ _context25.next = 17;
2311
2313
  break;
2312
- case 11:
2314
+ case 12:
2313
2315
  if (!targetProductData.duration) {
2314
- _context25.next = 16;
2316
+ _context25.next = 17;
2315
2317
  break;
2316
2318
  }
2317
2319
  dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
2318
2320
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
2319
- _context25.next = 15;
2321
+ _context25.next = 16;
2320
2322
  break;
2321
2323
  }
2322
2324
  return _context25.abrupt("return");
2323
- case 15:
2325
+ case 16:
2324
2326
  // this.store.date.getResourceDates({
2325
2327
  // query: {
2326
2328
  // start_date: dateRange[0].date,
@@ -2333,7 +2335,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2333
2335
  endDate: dateRange[dateRange.length - 1].date,
2334
2336
  products: [targetProductData]
2335
2337
  });
2336
- case 16:
2338
+ case 17:
2337
2339
  case "end":
2338
2340
  return _context25.stop();
2339
2341
  }
@@ -2347,8 +2349,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2347
2349
  }, {
2348
2350
  key: "closeProductDetail",
2349
2351
  value: function closeProductDetail() {
2350
- var _this$store$currentPr;
2351
- (_this$store$currentPr = this.store.currentProduct) === null || _this$store$currentPr === void 0 || _this$store$currentPr.setOtherParams('schedule', []);
2352
+ if (this.store.currentProductMeta) {
2353
+ this.store.currentProductMeta.schedule = [];
2354
+ }
2352
2355
  this.store.currentProduct = undefined;
2353
2356
  }
2354
2357
  }, {
@@ -2361,7 +2364,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2361
2364
  product = _ref10.product;
2362
2365
  var targetProduct = this.store.currentProduct;
2363
2366
  // 如果外面传递了product 优先用外面的
2364
- var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
2367
+ var targetProductData = product || targetProduct;
2365
2368
  var targetSchedules = [];
2366
2369
  // 如果外面传递了 scheduleIds,优先取入参
2367
2370
  if (scheduleIds !== null && scheduleIds !== void 0 && scheduleIds.length) {
@@ -2376,7 +2379,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2376
2379
  var cartItems = cloneDeep(this.store.cart.getItems());
2377
2380
  var resourcesMap = getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []);
2378
2381
  var selectedResources = getOthersSelectedResources(cartItems, '', resourcesMap);
2379
- var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$currentPr2 = this.store.currentProduct) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.getData()) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.product_resource) === null || _this$store$currentPr2 === void 0 ? void 0 : _this$store$currentPr2.resources) || [], selectedResources, 1);
2382
+ var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$currentPr2 = this.store.currentProduct) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.product_resource) === null || _this$store$currentPr2 === void 0 ? void 0 : _this$store$currentPr2.resources) || [], selectedResources, 1);
2380
2383
  var minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, date);
2381
2384
  var scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime);
2382
2385
  // 当前所有待选择资源的集合,先提出来,提升性能
@@ -2496,22 +2499,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2496
2499
  key: "getProductTypeById",
2497
2500
  value: function () {
2498
2501
  var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
2499
- var product;
2502
+ var productData, _productData$schedule;
2500
2503
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2501
2504
  while (1) switch (_context26.prev = _context26.next) {
2502
2505
  case 0:
2503
2506
  _context26.next = 2;
2504
2507
  return this.store.products.getProduct(id);
2505
2508
  case 2:
2506
- product = _context26.sent;
2507
- if (!product) {
2508
- _context26.next = 5;
2509
+ productData = _context26.sent;
2510
+ if (!productData) {
2511
+ _context26.next = 9;
2509
2512
  break;
2510
2513
  }
2511
- return _context26.abrupt("return", product.getProductType());
2512
- case 5:
2513
- return _context26.abrupt("return", 'normal');
2514
+ if (!productData.duration) {
2515
+ _context26.next = 6;
2516
+ break;
2517
+ }
2518
+ return _context26.abrupt("return", 'duration');
2514
2519
  case 6:
2520
+ if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
2521
+ _context26.next = 8;
2522
+ break;
2523
+ }
2524
+ return _context26.abrupt("return", 'session');
2525
+ case 8:
2526
+ return _context26.abrupt("return", 'normal');
2527
+ case 9:
2528
+ return _context26.abrupt("return", 'normal');
2529
+ case 10:
2515
2530
  case "end":
2516
2531
  return _context26.stop();
2517
2532
  }
@@ -2683,7 +2698,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2683
2698
  key: "getAvailableDateForSessionOptimize",
2684
2699
  value: function () {
2685
2700
  var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2686
- var _this$store$currentPr3, _this$store$currentPr4, _this$store$currentPr5, _tempProducts, _this$store$currentPr6;
2701
+ var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
2687
2702
  var params,
2688
2703
  startDate,
2689
2704
  endDate,
@@ -2729,7 +2744,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2729
2744
  endDate = tempEndDate;
2730
2745
 
2731
2746
  // 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
2732
- cache = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getOtherParams()['timeSlotBySchedule'];
2747
+ cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
2733
2748
  if (!cache) {
2734
2749
  _context29.next = 13;
2735
2750
  break;
@@ -2745,8 +2760,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2745
2760
  });
2746
2761
  case 13:
2747
2762
  // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
2748
- tempProducts = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getData();
2749
- schedule = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['schedule'];
2763
+ tempProducts = this.store.currentProduct;
2764
+ schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
2750
2765
  filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
2751
2766
  tempResourceIds = getResourcesIdsByProduct(tempProducts);
2752
2767
  _context29.next = 19;
@@ -2906,17 +2921,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2906
2921
  this.store.date.setDateList(dates);
2907
2922
 
2908
2923
  // 缓存这次结果,以防后面他小幅度范围内去修改天数
2909
- (_this$store$currentPr6 = this.store.currentProduct) === null || _this$store$currentPr6 === void 0 || _this$store$currentPr6.setOtherParams('timeSlotBySchedule', {
2924
+ if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
2925
+ this.store.currentProductMeta.timeSlotBySchedule = {
2910
2926
  dateList: dates,
2911
2927
  firstAvailableDate: firstAvailableDate,
2912
2928
  startDate: startDate,
2913
2929
  endDate: dayjs(currentDate).format('YYYY-MM-DD')
2914
- });
2930
+ };
2915
2931
  return _context29.abrupt("return", {
2916
2932
  dateList: dates,
2917
2933
  firstAvailableDate: firstAvailableDate
2918
2934
  });
2919
- case 38:
2935
+ case 39:
2920
2936
  case "end":
2921
2937
  return _context29.stop();
2922
2938
  }
@@ -1,4 +1,4 @@
1
- import { ProductList, CartModule, Product, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from '../../modules';
1
+ import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, ScheduleModule } from '../../modules';
2
2
  export interface BookingByStepState {
3
3
  cart: CartModule;
4
4
  summary: SummaryModule;
@@ -11,7 +11,8 @@ export interface BookingByStepState {
11
11
  accountList: AccountListModule;
12
12
  order: OrderModule;
13
13
  payment: PaymentModule;
14
- currentProduct?: Product;
14
+ currentProduct?: ProductData;
15
+ currentProductMeta?: Record<string, any>;
15
16
  schedule: ScheduleModule;
16
17
  }
17
18
  export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];