@pisell/pisellos 2.0.66 → 2.0.68

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.
@@ -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
  }
@@ -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 {
@@ -8,6 +7,7 @@ export declare class ProductList extends BaseModule implements Module {
8
7
  protected defaultVersion: string;
9
8
  private store;
10
9
  private request;
10
+ private otherParams;
11
11
  constructor(name?: string, version?: string);
12
12
  initialize(core: PisellCore, options: any): Promise<void>;
13
13
  storeChange(path?: string, value?: any): Promise<void>;
@@ -30,7 +30,7 @@ export declare class ProductList extends BaseModule implements Module {
30
30
  channel?: string;
31
31
  }): Promise<any>;
32
32
  getProducts(): Promise<ProductData[]>;
33
- getProduct(id: number): Promise<Product | undefined>;
33
+ getProduct(id: number): Promise<ProductData | undefined>;
34
34
  addProduct(products: ProductData[]): Promise<void>;
35
35
  selectProducts(products: ProductData[]): Promise<void>;
36
36
  /**
@@ -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";
@@ -31,6 +30,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
31
30
  _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
32
31
  _defineProperty(_assertThisInitialized(_this), "store", void 0);
33
32
  _defineProperty(_assertThisInitialized(_this), "request", void 0);
33
+ _defineProperty(_assertThisInitialized(_this), "otherParams", {});
34
34
  return _this;
35
35
  }
36
36
  _createClass(ProductList, [{
@@ -43,17 +43,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
43
43
  case 0:
44
44
  this.core = core;
45
45
  this.store = options.store;
46
+ this.otherParams = options.otherParams || {};
46
47
  if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
47
- 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
+ });
48
51
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
49
- this.storeChange();
50
52
  } else {
51
53
  this.store.list = [];
52
- this.store.productMap = new Map();
53
54
  this.store.selectProducts = [];
54
55
  }
55
56
  this.request = core.getPlugin('request');
56
- case 4:
57
+ case 5:
57
58
  case "end":
58
59
  return _context.stop();
59
60
  }
@@ -68,28 +69,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
68
69
  key: "storeChange",
69
70
  value: function () {
70
71
  var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, value) {
71
- var _this$store$list,
72
- _this2 = this;
73
72
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
74
73
  while (1) switch (_context2.prev = _context2.next) {
75
74
  case 0:
76
- (_this$store$list = this.store.list) === null || _this$store$list === void 0 || _this$store$list.forEach(function (product) {
77
- var productModule = _this2.store.productMap.get("product-".concat(product.id));
78
- if (!productModule) {
79
- var newProductModule = new Product("product_".concat(product.id.toString()));
80
- _this2.core.registerModule(newProductModule, {
81
- initialState: product
82
- });
83
- _this2.store.productMap.set(product.id.toString(), newProductModule);
84
- } else {
85
- productModule.updateData(product);
86
- }
87
- });
88
- case 1:
89
75
  case "end":
90
76
  return _context2.stop();
91
77
  }
92
- }, _callee2, this);
78
+ }, _callee2);
93
79
  }));
94
80
  function storeChange(_x3, _x4) {
95
81
  return _storeChange.apply(this, arguments);
@@ -100,7 +86,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
100
86
  key: "loadProducts",
101
87
  value: function () {
102
88
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref) {
103
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData;
89
+ var _this$otherParams;
90
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
104
91
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
105
92
  while (1) switch (_context3.prev = _context3.next) {
106
93
  case 0:
@@ -144,15 +131,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
144
131
  // client_schedule_ids: schedule_ids,
145
132
  schedule_date: schedule_date,
146
133
  with_schedule: with_schedule,
147
- schedule_datetime: schedule_datetime
134
+ schedule_datetime: schedule_datetime,
135
+ application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel
148
136
  }, {
149
137
  useCache: true
150
138
  });
151
139
  case 6:
152
140
  productsData = _context3.sent;
153
- this.addProduct(productsData.data.list);
154
- return _context3.abrupt("return", productsData.data.list);
155
- case 9:
141
+ sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
142
+ return Number(b.sort) - Number(a.sort);
143
+ });
144
+ this.addProduct(sortedList);
145
+ return _context3.abrupt("return", sortedList);
146
+ case 10:
156
147
  case "end":
157
148
  return _context3.stop();
158
149
  }
@@ -228,15 +219,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
228
219
  _context6.next = 2;
229
220
  return this.core.effects.emit(ProductListHooks.onGetProduct, this.store.list);
230
221
  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:
222
+ product = this.store.list.find(function (product) {
223
+ return product.id === id;
224
+ });
225
+ return _context6.abrupt("return", product ? cloneDeep(product) : undefined);
226
+ case 4:
240
227
  case "end":
241
228
  return _context6.stop();
242
229
  }
@@ -251,27 +238,30 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
251
238
  key: "addProduct",
252
239
  value: function () {
253
240
  var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
254
- var _this3 = this;
241
+ var _this2 = this;
255
242
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
256
243
  while (1) switch (_context7.prev = _context7.next) {
257
244
  case 0:
258
- // 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
259
245
  // list 需要根据 id 去重
260
246
  if (!this.store.list) {
261
247
  this.store.list = [];
262
248
  }
263
249
  products.forEach(function (n) {
264
- var index = _this3.store.list.findIndex(function (m) {
250
+ var index = _this2.store.list.findIndex(function (m) {
265
251
  return m.id === n.id;
266
252
  });
267
253
  if (index === -1) {
268
- _this3.store.list.push(n);
254
+ _this2.store.list.push(n);
269
255
  } else {
270
- _this3.store.list[index] = n;
256
+ _this2.store.list[index] = n;
271
257
  }
272
258
  });
273
- this.storeChange();
274
- case 3:
259
+ // 根据 sort 值做降序排序(数字越大越靠前)
260
+ this.store.list.sort(function (a, b) {
261
+ return Number(b.sort) - Number(a.sort);
262
+ });
263
+ this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
264
+ case 4:
275
265
  case "end":
276
266
  return _context7.stop();
277
267
  }
@@ -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 {
@@ -297,19 +297,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
297
297
 
298
298
  // 记录可抵扣的商品详情
299
299
  var applicableProducts = discountApplicableProducts.get(discount.id) || [];
300
- applicableProducts.push({
300
+ var discountType = discount.tag || discount.type;
301
+ var productData = {
301
302
  amount: product.price,
302
- type: discount.tag || discount.type,
303
- tag: discount.tag || discount.type,
303
+ type: discountType,
304
+ tag: discountType,
304
305
  discount: {
305
306
  resource_id: discount.id,
306
307
  title: discount.format_title,
307
308
  original_amount: product.origin_total,
308
309
  pre_value: discount.par_value,
309
310
  product_id: originProduct.id
310
- },
311
- num: product.num || 1
312
- });
311
+ }
312
+ };
313
+
314
+ // 如果 discount.tag 或者 discount.type 是 good_pass,则不需要添加 num 属性
315
+ if (discountType !== 'good_pass') {
316
+ productData.num = product.num || 1;
317
+ }
318
+ applicableProducts.push(productData);
313
319
  discountApplicableProducts.set(discount.id, applicableProducts);
314
320
  }
315
321
  });
@@ -451,18 +457,23 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
451
457
 
452
458
  // 计算使用折扣卡/商品券以后,单个商品的总 total
453
459
  var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
460
+ var discountType = _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag;
454
461
  var discountDetail = {
455
462
  amount: new Decimal(productOriginTotal).minus(new Decimal(targetProductTotal)).toNumber(),
456
- type: _selectedDiscount.tag === 'product_discount_card' ? 'discount_card' : _selectedDiscount.tag,
463
+ type: discountType,
457
464
  discount: {
458
465
  resource_id: _selectedDiscount.id,
459
466
  title: _selectedDiscount.format_title,
460
467
  original_amount: productOriginTotal,
461
468
  product_id: originProduct.id,
462
469
  percent: _selectedDiscount.par_value
463
- },
464
- num: product.num || 1
470
+ }
465
471
  };
472
+
473
+ // 如果 discount.tag 或者 discount.type 是 good_pass,则不需要添加 num 属性
474
+ if ((_selectedDiscount.tag || _selectedDiscount.type) !== 'good_pass') {
475
+ discountDetail.num = product.num || 1;
476
+ }
466
477
  appliedProducts.push(discountDetail);
467
478
  appliedDiscountProducts.set(_selectedDiscount.id, appliedProducts);
468
479
 
@@ -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();
@@ -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];
@@ -281,7 +281,9 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
281
281
  onlyComputed: true,
282
282
  // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
283
283
  metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
284
- combined_resource: resourcesMap[id].combined_resource
284
+ combined_resource: resourcesMap[id].combined_resource,
285
+ form_name: item.title,
286
+ resource_name: resourcesMap[id].main_field
285
287
  })
286
288
  }));
287
289
  }
@@ -292,7 +294,9 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
292
294
  resourceType: item.type,
293
295
  children: combiningResources,
294
296
  metadata: _objectSpread(_objectSpread({}, resourcesMap[d].metadata), {}, {
295
- combined_resource: resourcesMap[d].combined_resource
297
+ combined_resource: resourcesMap[d].combined_resource,
298
+ form_name: item.title,
299
+ resource_name: resourcesMap[d].main_field
296
300
  })
297
301
  }));
298
302
  }
@@ -315,7 +319,9 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
315
319
  onlyComputed: true,
316
320
  // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
317
321
  metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
318
- combined_resource: resourcesMap[id].combined_resource
322
+ combined_resource: resourcesMap[id].combined_resource,
323
+ form_name: item.title,
324
+ resource_name: resourcesMap[id].main_field
319
325
  })
320
326
  }));
321
327
  }
@@ -327,7 +333,9 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
327
333
  is_default: 1,
328
334
  children: combiningResources,
329
335
  metadata: _objectSpread(_objectSpread({}, resourcesMap[d].metadata), {}, {
330
- combined_resource: resourcesMap[d].combined_resource
336
+ combined_resource: resourcesMap[d].combined_resource,
337
+ form_name: item.title,
338
+ resource_name: resourcesMap[d].main_field
331
339
  })
332
340
  }));
333
341
  }
@@ -1,5 +1,5 @@
1
1
  import { Module, PisellCore } from '../../types';
2
- import { Product, ProductData } from '../../modules/';
2
+ import { ProductData } from '../../modules/';
3
3
  import { BaseModule } from '../../modules/BaseModule';
4
4
  export * from './types';
5
5
  export declare class BuyTicketsImpl extends BaseModule implements Module {
@@ -16,7 +16,7 @@ export declare class BuyTicketsImpl extends BaseModule implements Module {
16
16
  loadProductsByCategory(categoryId: number): Promise<void>;
17
17
  destroy(): Promise<void>;
18
18
  getProducts(): Promise<ProductData[]>;
19
- getProduct(id: number): Promise<Product>;
19
+ getProduct(id: number): Promise<ProductData>;
20
20
  listSubmit(data: Record<string, any>): Promise<{
21
21
  status: boolean;
22
22
  data: any;
@@ -238,7 +238,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
238
238
  }
239
239
  return _context6.abrupt("return", otherProduct);
240
240
  case 10:
241
- return _context6.abrupt("return", Promise.reject('Not fund product for id: ' + id));
241
+ throw new Error("Product not found: ".concat(id));
242
242
  case 11:
243
243
  case "end":
244
244
  return _context6.stop();
@@ -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>;
@@ -40,7 +40,7 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
40
40
  const cartProduct = await getProduct(
41
41
  item.id
42
42
  );
43
- let productInfo = cartProduct == null ? void 0 : cartProduct.getData();
43
+ let productInfo = cartProduct;
44
44
  if (!productInfo) {
45
45
  productInfo = item._productOrigin;
46
46
  }
@@ -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 {
@@ -8,6 +7,7 @@ export declare class ProductList extends BaseModule implements Module {
8
7
  protected defaultVersion: string;
9
8
  private store;
10
9
  private request;
10
+ private otherParams;
11
11
  constructor(name?: string, version?: string);
12
12
  initialize(core: PisellCore, options: any): Promise<void>;
13
13
  storeChange(path?: string, value?: any): Promise<void>;
@@ -30,7 +30,7 @@ export declare class ProductList extends BaseModule implements Module {
30
30
  channel?: string;
31
31
  }): Promise<any>;
32
32
  getProducts(): Promise<ProductData[]>;
33
- getProduct(id: number): Promise<Product | undefined>;
33
+ getProduct(id: number): Promise<ProductData | undefined>;
34
34
  addProduct(products: ProductData[]): Promise<void>;
35
35
  selectProducts(products: ProductData[]): Promise<void>;
36
36
  /**
@@ -24,7 +24,6 @@ __export(ProductList_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(ProductList_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
- var import_Product = require("../Product");
28
27
  var import_types = require("./types");
29
28
  var import_lodash_es = require("lodash-es");
30
29
  __reExport(ProductList_exports, require("./types"), module.exports);
@@ -33,36 +32,23 @@ var ProductList = class extends import_BaseModule.BaseModule {
33
32
  super(name, version);
34
33
  this.defaultName = "productList";
35
34
  this.defaultVersion = "1.0.0";
35
+ this.otherParams = {};
36
36
  }
37
37
  async initialize(core, options) {
38
38
  var _a;
39
39
  this.core = core;
40
40
  this.store = options.store;
41
+ this.otherParams = options.otherParams || {};
41
42
  if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
42
- this.store.list = options.initialState.list;
43
+ this.store.list = options.initialState.list.slice().sort((a, b) => Number(b.sort) - Number(a.sort));
43
44
  this.core.effects.emit(`${this.name}:changed`, this.store.list);
44
- this.storeChange();
45
45
  } else {
46
46
  this.store.list = [];
47
- this.store.productMap = /* @__PURE__ */ new Map();
48
47
  this.store.selectProducts = [];
49
48
  }
50
49
  this.request = core.getPlugin("request");
51
50
  }
52
51
  async storeChange(path, value) {
53
- var _a;
54
- (_a = this.store.list) == null ? void 0 : _a.forEach((product) => {
55
- const productModule = this.store.productMap.get(`product-${product.id}`);
56
- if (!productModule) {
57
- const newProductModule = new import_Product.Product(
58
- `product_${product.id.toString()}`
59
- );
60
- this.core.registerModule(newProductModule, { initialState: product });
61
- this.store.productMap.set(product.id.toString(), newProductModule);
62
- } else {
63
- productModule.updateData(product);
64
- }
65
- });
66
52
  }
67
53
  async loadProducts({
68
54
  category_ids = [],
@@ -76,7 +62,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
76
62
  cacheId,
77
63
  with_schedule
78
64
  }) {
79
- var _a;
65
+ var _a, _b;
80
66
  let userPlugin = this.core.getPlugin("user");
81
67
  let customer_id = void 0;
82
68
  try {
@@ -111,12 +97,14 @@ var ProductList = class extends import_BaseModule.BaseModule {
111
97
  // client_schedule_ids: schedule_ids,
112
98
  schedule_date,
113
99
  with_schedule,
114
- schedule_datetime
100
+ schedule_datetime,
101
+ application_code: (_b = this.otherParams) == null ? void 0 : _b.channel
115
102
  },
116
103
  { useCache: true }
117
104
  );
118
- this.addProduct(productsData.data.list);
119
- return productsData.data.list;
105
+ const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
106
+ this.addProduct(sortedList);
107
+ return sortedList;
120
108
  }
121
109
  async loadProductsPrice({
122
110
  ids = [],
@@ -148,10 +136,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
148
136
  import_types.ProductListHooks.onGetProduct,
149
137
  this.store.list
150
138
  );
151
- const product = this.store.productMap.get(`${id}`);
152
- if (product)
153
- return product;
154
- return void 0;
139
+ const product = this.store.list.find((product2) => product2.id === id);
140
+ return product ? (0, import_lodash_es.cloneDeep)(product) : void 0;
155
141
  }
156
142
  async addProduct(products) {
157
143
  if (!this.store.list) {
@@ -165,7 +151,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
165
151
  this.store.list[index] = n;
166
152
  }
167
153
  });
168
- this.storeChange();
154
+ this.store.list.sort((a, b) => Number(b.sort) - Number(a.sort));
155
+ this.core.effects.emit(`${this.name}:changed`, this.store.list);
169
156
  }
170
157
  async selectProducts(products) {
171
158
  this.store.selectProducts = products;
@@ -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 {
@@ -189,19 +189,23 @@ var RulesModule = class extends import_BaseModule.BaseModule {
189
189
  if (isAvailableProduct && isLimitedProduct) {
190
190
  (_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
191
191
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
192
- applicableProducts.push({
192
+ const discountType = discount.tag || discount.type;
193
+ const productData = {
193
194
  amount: product.price,
194
- type: discount.tag || discount.type,
195
- tag: discount.tag || discount.type,
195
+ type: discountType,
196
+ tag: discountType,
196
197
  discount: {
197
198
  resource_id: discount.id,
198
199
  title: discount.format_title,
199
200
  original_amount: product.origin_total,
200
201
  pre_value: discount.par_value,
201
202
  product_id: originProduct.id
202
- },
203
- num: product.num || 1
204
- });
203
+ }
204
+ };
205
+ if (discountType !== "good_pass") {
206
+ productData.num = product.num || 1;
207
+ }
208
+ applicableProducts.push(productData);
205
209
  discountApplicableProducts.set(discount.id, applicableProducts);
206
210
  }
207
211
  });
@@ -310,18 +314,21 @@ var RulesModule = class extends import_BaseModule.BaseModule {
310
314
  productOriginTotal = product.total;
311
315
  }
312
316
  const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
317
+ const discountType = selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag;
313
318
  const discountDetail = {
314
319
  amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
315
- type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
320
+ type: discountType,
316
321
  discount: {
317
322
  resource_id: selectedDiscount2.id,
318
323
  title: selectedDiscount2.format_title,
319
324
  original_amount: productOriginTotal,
320
325
  product_id: originProduct.id,
321
326
  percent: selectedDiscount2.par_value
322
- },
323
- num: product.num || 1
327
+ }
324
328
  };
329
+ if ((selectedDiscount2.tag || selectedDiscount2.type) !== "good_pass") {
330
+ discountDetail.num = product.num || 1;
331
+ }
325
332
  appliedProducts.push(discountDetail);
326
333
  appliedDiscountProducts.set(selectedDiscount2.id, appliedProducts);
327
334
  if (product.isClient) {
@@ -390,7 +390,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
390
390
  }
391
391
  // 获取商品/服务的可用日期
392
392
  async getAvailableDate(params = {}) {
393
- var _a, _b, _c;
393
+ var _a, _b, _c, _d;
394
394
  let { products, startDate, endDate, type, useCache = true } = params;
395
395
  if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
396
396
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
@@ -407,14 +407,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
407
407
  if (this.store.currentProduct) {
408
408
  tempProducts = [
409
409
  {
410
- ...this.store.currentProduct.getData(),
411
- _schedule: this.store.currentProduct.getOtherParams()["schedule"]
410
+ ...this.store.currentProduct,
411
+ _schedule: (_a = this.store.currentProductMeta) == null ? void 0 : _a["schedule"]
412
412
  }
413
413
  ];
414
414
  }
415
415
  let dateRange = this.store.date.getDateRange();
416
- const tempStartDate = startDate || ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date);
417
- const tempEndDate = endDate || ((_b = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _b.date) || ((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date);
416
+ const tempStartDate = startDate || ((_b = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _b.date);
417
+ const tempEndDate = endDate || ((_c = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _c.date) || ((_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date);
418
418
  if (!tempProducts.length) {
419
419
  return [];
420
420
  }
@@ -1596,15 +1596,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1596
1596
  }
1597
1597
  // 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
1598
1598
  async openProductDetail(productId) {
1599
- const targetProduct = await this.store.products.getProduct(productId);
1600
- if (targetProduct) {
1601
- const targetProductData = targetProduct.getData();
1602
- this.store.currentProduct = targetProduct;
1599
+ const targetProductData = await this.store.products.getProduct(productId);
1600
+ if (targetProductData) {
1601
+ this.store.currentProduct = targetProductData;
1602
+ this.store.currentProductMeta = {};
1603
1603
  if (targetProductData["schedule.ids"]) {
1604
1604
  const newScheduleArr = this.getScheduleDataByIds(
1605
1605
  targetProductData["schedule.ids"]
1606
1606
  );
1607
- targetProduct.setOtherParams("schedule", newScheduleArr);
1607
+ if (!this.store.currentProductMeta)
1608
+ this.store.currentProductMeta = {};
1609
+ this.store.currentProductMeta.schedule = newScheduleArr;
1608
1610
  } else if (targetProductData.duration) {
1609
1611
  const dateRange = this.store.date.getDateRange();
1610
1612
  if (!(dateRange == null ? void 0 : dateRange.length))
@@ -1618,8 +1620,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1618
1620
  }
1619
1621
  }
1620
1622
  closeProductDetail() {
1621
- var _a;
1622
- (_a = this.store.currentProduct) == null ? void 0 : _a.setOtherParams("schedule", []);
1623
+ if (this.store.currentProductMeta) {
1624
+ this.store.currentProductMeta.schedule = [];
1625
+ }
1623
1626
  this.store.currentProduct = void 0;
1624
1627
  }
1625
1628
  getTimeslotBySchedule({
@@ -1628,9 +1631,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1628
1631
  resources,
1629
1632
  product
1630
1633
  }) {
1631
- var _a, _b, _c, _d, _e, _f;
1634
+ var _a, _b, _c, _d, _e;
1632
1635
  const targetProduct = this.store.currentProduct;
1633
- const targetProductData = product || (targetProduct == null ? void 0 : targetProduct.getData());
1636
+ const targetProductData = product || targetProduct;
1634
1637
  let targetSchedules = [];
1635
1638
  if (scheduleIds == null ? void 0 : scheduleIds.length) {
1636
1639
  targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
@@ -1650,7 +1653,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1650
1653
  );
1651
1654
  const productResources = (0, import_resources.getResourcesByProduct)(
1652
1655
  resourcesMap,
1653
- resources || ((_c = (_b = (_a = this.store.currentProduct) == null ? void 0 : _a.getData()) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
1656
+ resources || ((_b = (_a = this.store.currentProduct) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
1654
1657
  selectedResources,
1655
1658
  1
1656
1659
  );
@@ -1671,9 +1674,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1671
1674
  return -1;
1672
1675
  return 0;
1673
1676
  });
1674
- const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
1677
+ const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
1675
1678
  (n) => n.status === 1
1676
- )) == null ? void 0 : _f.id;
1679
+ )) == null ? void 0 : _e.id;
1677
1680
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1678
1681
  const resourcesUseableMap = {};
1679
1682
  let count = 0;
@@ -1747,9 +1750,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1747
1750
  return this.otherData[key];
1748
1751
  }
1749
1752
  async getProductTypeById(id) {
1750
- const product = await this.store.products.getProduct(id);
1751
- if (product) {
1752
- return product.getProductType();
1753
+ var _a;
1754
+ const productData = await this.store.products.getProduct(id);
1755
+ if (productData) {
1756
+ if (productData.duration) {
1757
+ return "duration";
1758
+ }
1759
+ if ((_a = productData["schedule.ids"]) == null ? void 0 : _a.length) {
1760
+ return "session";
1761
+ }
1762
+ return "normal";
1753
1763
  }
1754
1764
  return "normal";
1755
1765
  }
@@ -1910,7 +1920,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1910
1920
  return results;
1911
1921
  }
1912
1922
  async getAvailableDateForSessionOptimize(params = {}) {
1913
- var _a, _b, _c, _d, _e, _f;
1923
+ var _a, _b, _c, _d;
1914
1924
  let { startDate, endDate } = params;
1915
1925
  if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
1916
1926
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
@@ -1926,7 +1936,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1926
1936
  tempEndDate = endDate || "";
1927
1937
  }
1928
1938
  endDate = tempEndDate;
1929
- const cache = (_a = this.store.currentProduct) == null ? void 0 : _a.getOtherParams()["timeSlotBySchedule"];
1939
+ const cache = (_a = this.store.currentProductMeta) == null ? void 0 : _a["timeSlotBySchedule"];
1930
1940
  if (cache) {
1931
1941
  if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
1932
1942
  this.store.date.setDateList(cache.dateList);
@@ -1937,8 +1947,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1937
1947
  }
1938
1948
  }
1939
1949
  let tempProducts;
1940
- tempProducts = (_b = this.store.currentProduct) == null ? void 0 : _b.getData();
1941
- const schedule = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["schedule"];
1950
+ tempProducts = this.store.currentProduct;
1951
+ const schedule = (_b = this.store.currentProductMeta) == null ? void 0 : _b["schedule"];
1942
1952
  const filteredSchedule = (0, import_resources.filterScheduleByDateRange)(
1943
1953
  schedule,
1944
1954
  startDate || "",
@@ -1955,7 +1965,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1955
1965
  let dates = [];
1956
1966
  let currentDate = (0, import_dayjs.default)(startDate);
1957
1967
  let firstAvailableDate = "";
1958
- const openResources = ((_e = (_d = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.filter(
1968
+ const openResources = ((_d = (_c = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
1959
1969
  (m) => m.status === 1
1960
1970
  )) || [];
1961
1971
  const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
@@ -2056,12 +2066,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2056
2066
  }
2057
2067
  dates = (0, import_utils3.handleAvailableDateByResource)(res.data, dates);
2058
2068
  this.store.date.setDateList(dates);
2059
- (_f = this.store.currentProduct) == null ? void 0 : _f.setOtherParams("timeSlotBySchedule", {
2069
+ if (!this.store.currentProductMeta)
2070
+ this.store.currentProductMeta = {};
2071
+ this.store.currentProductMeta.timeSlotBySchedule = {
2060
2072
  dateList: dates,
2061
2073
  firstAvailableDate,
2062
2074
  startDate,
2063
2075
  endDate: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD")
2064
- });
2076
+ };
2065
2077
  return {
2066
2078
  dateList: dates,
2067
2079
  firstAvailableDate
@@ -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];
@@ -215,7 +215,9 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
215
215
  // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
216
216
  metadata: {
217
217
  ...resourcesMap[id].metadata,
218
- combined_resource: resourcesMap[id].combined_resource
218
+ combined_resource: resourcesMap[id].combined_resource,
219
+ form_name: item.title,
220
+ resource_name: resourcesMap[id].main_field
219
221
  }
220
222
  })
221
223
  );
@@ -230,7 +232,9 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
230
232
  children: combiningResources,
231
233
  metadata: {
232
234
  ...resourcesMap[d].metadata,
233
- combined_resource: resourcesMap[d].combined_resource
235
+ combined_resource: resourcesMap[d].combined_resource,
236
+ form_name: item.title,
237
+ resource_name: resourcesMap[d].main_field
234
238
  }
235
239
  })
236
240
  );
@@ -259,7 +263,9 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
259
263
  // 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
260
264
  metadata: {
261
265
  ...resourcesMap[id].metadata,
262
- combined_resource: resourcesMap[id].combined_resource
266
+ combined_resource: resourcesMap[id].combined_resource,
267
+ form_name: item.title,
268
+ resource_name: resourcesMap[id].main_field
263
269
  }
264
270
  })
265
271
  );
@@ -275,7 +281,9 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
275
281
  children: combiningResources,
276
282
  metadata: {
277
283
  ...resourcesMap[d].metadata,
278
- combined_resource: resourcesMap[d].combined_resource
284
+ combined_resource: resourcesMap[d].combined_resource,
285
+ form_name: item.title,
286
+ resource_name: resourcesMap[d].main_field
279
287
  }
280
288
  })
281
289
  );
@@ -1,5 +1,5 @@
1
1
  import { Module, PisellCore } from '../../types';
2
- import { Product, ProductData } from '../../modules/';
2
+ import { ProductData } from '../../modules/';
3
3
  import { BaseModule } from '../../modules/BaseModule';
4
4
  export * from './types';
5
5
  export declare class BuyTicketsImpl extends BaseModule implements Module {
@@ -16,7 +16,7 @@ export declare class BuyTicketsImpl extends BaseModule implements Module {
16
16
  loadProductsByCategory(categoryId: number): Promise<void>;
17
17
  destroy(): Promise<void>;
18
18
  getProducts(): Promise<ProductData[]>;
19
- getProduct(id: number): Promise<Product>;
19
+ getProduct(id: number): Promise<ProductData>;
20
20
  listSubmit(data: Record<string, any>): Promise<{
21
21
  status: boolean;
22
22
  data: any;
@@ -98,7 +98,7 @@ var BuyTicketsImpl = class extends import_BaseModule.BaseModule {
98
98
  return mainProduct;
99
99
  if (otherProduct)
100
100
  return otherProduct;
101
- return Promise.reject("Not fund product for id: " + id);
101
+ throw new Error(`Product not found: ${id}`);
102
102
  }
103
103
  // 商品列表页提交
104
104
  async listSubmit(data) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.0.66",
4
+ "version": "2.0.68",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",