@pisell/pisellos 0.0.226 → 0.0.228

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,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
5
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -39,7 +41,7 @@ export var BaseModule = /*#__PURE__*/function () {
39
41
  var currentCacheData = window.sessionStorage.getItem(fatherModule);
40
42
  var currentCacheDataObj = JSON.parse(currentCacheData || '{}');
41
43
  if (!currentCacheData || !currentCacheDataObj[cacheId]) {
42
- currentCacheDataObj = _defineProperty({}, cacheId, _defineProperty({}, this.name, {}));
44
+ currentCacheDataObj = _objectSpread(_defineProperty({}, cacheId, _defineProperty({}, this.name, {})), currentCacheDataObj);
43
45
  }
44
46
  if (!currentCacheDataObj[cacheId][this.name]) {
45
47
  currentCacheDataObj[cacheId][this.name] = {};
@@ -50,17 +52,17 @@ export var BaseModule = /*#__PURE__*/function () {
50
52
  window.sessionStorage.setItem(fatherModule, JSON.stringify(currentCacheDataObj));
51
53
  } else {
52
54
  var _currentCacheData = window.sessionStorage.getItem(cacheId);
53
- var _currentCacheDataObj2 = JSON.parse(_currentCacheData || '{}');
54
- if (!_currentCacheDataObj2) {
55
- _currentCacheDataObj2 = {};
55
+ var _currentCacheDataObj = JSON.parse(_currentCacheData || '{}');
56
+ if (!_currentCacheDataObj) {
57
+ _currentCacheDataObj = {};
56
58
  }
57
- if (!_currentCacheDataObj2[this.name]) {
58
- _currentCacheDataObj2[this.name] = {};
59
+ if (!_currentCacheDataObj[this.name]) {
60
+ _currentCacheDataObj[this.name] = {};
59
61
  }
60
62
  cacheKey.forEach(function (key) {
61
- _currentCacheDataObj2[_this.name][key] = store[key];
63
+ _currentCacheDataObj[_this.name][key] = store[key];
62
64
  });
63
- window.sessionStorage.setItem(cacheId, JSON.stringify(_currentCacheDataObj2));
65
+ window.sessionStorage.setItem(cacheId, JSON.stringify(_currentCacheDataObj));
64
66
  }
65
67
  }
66
68
  }
@@ -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 {
@@ -31,7 +30,7 @@ export declare class ProductList extends BaseModule implements Module {
31
30
  channel?: string;
32
31
  }): Promise<any>;
33
32
  getProducts(): Promise<ProductData[]>;
34
- getProduct(id: number): Promise<Product | undefined>;
33
+ getProduct(id: number): Promise<ProductData | undefined>;
35
34
  addProduct(products: ProductData[]): Promise<void>;
36
35
  selectProducts(products: ProductData[]): Promise<void>;
37
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";
@@ -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, _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;
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;
107
91
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
108
92
  while (1) switch (_context3.prev = _context3.next) {
109
93
  case 0:
@@ -127,9 +111,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
127
111
  } catch (error) {
128
112
  console.error(error);
129
113
  }
130
- debugger;
131
114
  // 如果没传schedule_date,则从
132
- _context3.next = 7;
115
+ _context3.next = 6;
133
116
  return this.request.post("/product/query", {
134
117
  open_quotation: 1,
135
118
  open_bundle: 0,
@@ -153,10 +136,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
153
136
  }, {
154
137
  useCache: true
155
138
  });
156
- case 7:
139
+ case 6:
157
140
  productsData = _context3.sent;
158
- this.addProduct(productsData.data.list);
159
- return _context3.abrupt("return", productsData.data.list);
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);
160
146
  case 10:
161
147
  case "end":
162
148
  return _context3.stop();
@@ -233,15 +219,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
233
219
  _context6.next = 2;
234
220
  return this.core.effects.emit(ProductListHooks.onGetProduct, this.store.list);
235
221
  case 2:
236
- product = this.store.productMap.get("".concat(id));
237
- if (!product) {
238
- _context6.next = 5;
239
- break;
240
- }
241
- return _context6.abrupt("return", product);
242
- case 5:
243
- return _context6.abrupt("return", undefined);
244
- 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:
245
227
  case "end":
246
228
  return _context6.stop();
247
229
  }
@@ -256,27 +238,30 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
256
238
  key: "addProduct",
257
239
  value: function () {
258
240
  var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(products) {
259
- var _this3 = this;
241
+ var _this2 = this;
260
242
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
261
243
  while (1) switch (_context7.prev = _context7.next) {
262
244
  case 0:
263
- // 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
264
245
  // list 需要根据 id 去重
265
246
  if (!this.store.list) {
266
247
  this.store.list = [];
267
248
  }
268
249
  products.forEach(function (n) {
269
- var index = _this3.store.list.findIndex(function (m) {
250
+ var index = _this2.store.list.findIndex(function (m) {
270
251
  return m.id === n.id;
271
252
  });
272
253
  if (index === -1) {
273
- _this3.store.list.push(n);
254
+ _this2.store.list.push(n);
274
255
  } else {
275
- _this3.store.list[index] = n;
256
+ _this2.store.list[index] = n;
276
257
  }
277
258
  });
278
- this.storeChange();
279
- 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:
280
265
  case "end":
281
266
  return _context7.stop();
282
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 {
@@ -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();
@@ -1416,13 +1417,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1416
1417
  }, {
1417
1418
  key: "destroy",
1418
1419
  value: function destroy() {
1419
- var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
1420
+ var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi, _this$store$schedule, _this$store$summary, _this$store$order;
1420
1421
  (_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
1421
1422
  (_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
1422
1423
  (_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
1423
1424
  (_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
1424
1425
  (_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
1425
1426
  (_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
1427
+ (_this$store$schedule = this.store.schedule) === null || _this$store$schedule === void 0 || _this$store$schedule.destroy();
1428
+ (_this$store$summary = this.store.summary) === null || _this$store$summary === void 0 || _this$store$summary.destroy();
1429
+ (_this$store$order = this.store.order) === null || _this$store$order === void 0 || _this$store$order.destroy();
1426
1430
  this.core.effects.offByModuleDestroy(this.name);
1427
1431
  this.core.unregisterModule(this);
1428
1432
  }
@@ -2286,41 +2290,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2286
2290
  key: "openProductDetail",
2287
2291
  value: function () {
2288
2292
  var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
2289
- var targetProduct, targetProductData, newScheduleArr, dateRange;
2293
+ var targetProductData, newScheduleArr, dateRange;
2290
2294
  return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2291
2295
  while (1) switch (_context25.prev = _context25.next) {
2292
2296
  case 0:
2293
2297
  _context25.next = 2;
2294
2298
  return this.store.products.getProduct(productId);
2295
2299
  case 2:
2296
- targetProduct = _context25.sent;
2297
- if (!targetProduct) {
2298
- _context25.next = 16;
2300
+ targetProductData = _context25.sent;
2301
+ if (!targetProductData) {
2302
+ _context25.next = 17;
2299
2303
  break;
2300
2304
  }
2301
- targetProductData = targetProduct.getData();
2302
- this.store.currentProduct = targetProduct;
2305
+ this.store.currentProduct = targetProductData;
2306
+ this.store.currentProductMeta = {};
2303
2307
  // 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
2304
2308
  if (!targetProductData['schedule.ids']) {
2305
- _context25.next = 11;
2309
+ _context25.next = 12;
2306
2310
  break;
2307
2311
  }
2308
2312
  newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
2309
- targetProduct.setOtherParams('schedule', newScheduleArr);
2310
- _context25.next = 16;
2313
+ if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
2314
+ this.store.currentProductMeta.schedule = newScheduleArr;
2315
+ _context25.next = 17;
2311
2316
  break;
2312
- case 11:
2317
+ case 12:
2313
2318
  if (!targetProductData.duration) {
2314
- _context25.next = 16;
2319
+ _context25.next = 17;
2315
2320
  break;
2316
2321
  }
2317
2322
  dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
2318
2323
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
2319
- _context25.next = 15;
2324
+ _context25.next = 16;
2320
2325
  break;
2321
2326
  }
2322
2327
  return _context25.abrupt("return");
2323
- case 15:
2328
+ case 16:
2324
2329
  // this.store.date.getResourceDates({
2325
2330
  // query: {
2326
2331
  // start_date: dateRange[0].date,
@@ -2333,7 +2338,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2333
2338
  endDate: dateRange[dateRange.length - 1].date,
2334
2339
  products: [targetProductData]
2335
2340
  });
2336
- case 16:
2341
+ case 17:
2337
2342
  case "end":
2338
2343
  return _context25.stop();
2339
2344
  }
@@ -2347,8 +2352,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2347
2352
  }, {
2348
2353
  key: "closeProductDetail",
2349
2354
  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', []);
2355
+ if (this.store.currentProductMeta) {
2356
+ this.store.currentProductMeta.schedule = [];
2357
+ }
2352
2358
  this.store.currentProduct = undefined;
2353
2359
  }
2354
2360
  }, {
@@ -2361,7 +2367,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2361
2367
  product = _ref10.product;
2362
2368
  var targetProduct = this.store.currentProduct;
2363
2369
  // 如果外面传递了product 优先用外面的
2364
- var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
2370
+ var targetProductData = product || targetProduct;
2365
2371
  var targetSchedules = [];
2366
2372
  // 如果外面传递了 scheduleIds,优先取入参
2367
2373
  if (scheduleIds !== null && scheduleIds !== void 0 && scheduleIds.length) {
@@ -2376,7 +2382,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2376
2382
  var cartItems = cloneDeep(this.store.cart.getItems());
2377
2383
  var resourcesMap = getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []);
2378
2384
  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);
2385
+ 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
2386
  var minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, date);
2381
2387
  var scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime);
2382
2388
  // 当前所有待选择资源的集合,先提出来,提升性能
@@ -2496,22 +2502,34 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2496
2502
  key: "getProductTypeById",
2497
2503
  value: function () {
2498
2504
  var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
2499
- var product;
2505
+ var productData, _productData$schedule;
2500
2506
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2501
2507
  while (1) switch (_context26.prev = _context26.next) {
2502
2508
  case 0:
2503
2509
  _context26.next = 2;
2504
2510
  return this.store.products.getProduct(id);
2505
2511
  case 2:
2506
- product = _context26.sent;
2507
- if (!product) {
2508
- _context26.next = 5;
2512
+ productData = _context26.sent;
2513
+ if (!productData) {
2514
+ _context26.next = 9;
2509
2515
  break;
2510
2516
  }
2511
- return _context26.abrupt("return", product.getProductType());
2512
- case 5:
2513
- return _context26.abrupt("return", 'normal');
2517
+ if (!productData.duration) {
2518
+ _context26.next = 6;
2519
+ break;
2520
+ }
2521
+ return _context26.abrupt("return", 'duration');
2514
2522
  case 6:
2523
+ if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
2524
+ _context26.next = 8;
2525
+ break;
2526
+ }
2527
+ return _context26.abrupt("return", 'session');
2528
+ case 8:
2529
+ return _context26.abrupt("return", 'normal');
2530
+ case 9:
2531
+ return _context26.abrupt("return", 'normal');
2532
+ case 10:
2515
2533
  case "end":
2516
2534
  return _context26.stop();
2517
2535
  }
@@ -2683,7 +2701,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2683
2701
  key: "getAvailableDateForSessionOptimize",
2684
2702
  value: function () {
2685
2703
  var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2686
- var _this$store$currentPr3, _this$store$currentPr4, _this$store$currentPr5, _tempProducts, _this$store$currentPr6;
2704
+ var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
2687
2705
  var params,
2688
2706
  startDate,
2689
2707
  endDate,
@@ -2729,7 +2747,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2729
2747
  endDate = tempEndDate;
2730
2748
 
2731
2749
  // 先去读缓存结果,因为正常 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'];
2750
+ cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
2733
2751
  if (!cache) {
2734
2752
  _context29.next = 13;
2735
2753
  break;
@@ -2745,8 +2763,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2745
2763
  });
2746
2764
  case 13:
2747
2765
  // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
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'];
2766
+ tempProducts = this.store.currentProduct;
2767
+ schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
2750
2768
  filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
2751
2769
  tempResourceIds = getResourcesIdsByProduct(tempProducts);
2752
2770
  _context29.next = 19;
@@ -2906,17 +2924,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2906
2924
  this.store.date.setDateList(dates);
2907
2925
 
2908
2926
  // 缓存这次结果,以防后面他小幅度范围内去修改天数
2909
- (_this$store$currentPr6 = this.store.currentProduct) === null || _this$store$currentPr6 === void 0 || _this$store$currentPr6.setOtherParams('timeSlotBySchedule', {
2927
+ if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
2928
+ this.store.currentProductMeta.timeSlotBySchedule = {
2910
2929
  dateList: dates,
2911
2930
  firstAvailableDate: firstAvailableDate,
2912
2931
  startDate: startDate,
2913
2932
  endDate: dayjs(currentDate).format('YYYY-MM-DD')
2914
- });
2933
+ };
2915
2934
  return _context29.abrupt("return", {
2916
2935
  dateList: dates,
2917
2936
  firstAvailableDate: firstAvailableDate
2918
2937
  });
2919
- case 38:
2938
+ case 39:
2920
2939
  case "end":
2921
2940
  return _context29.stop();
2922
2941
  }
@@ -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];
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -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();
@@ -50,7 +50,9 @@ var BaseModule = class {
50
50
  currentCacheDataObj = {
51
51
  [cacheId]: {
52
52
  [this.name]: {}
53
- }
53
+ },
54
+ // 防止有其他 cacheid 的数据
55
+ ...currentCacheDataObj
54
56
  };
55
57
  }
56
58
  if (!currentCacheDataObj[cacheId][this.name]) {
@@ -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 {
@@ -31,7 +30,7 @@ export declare class ProductList extends BaseModule implements Module {
31
30
  channel?: string;
32
31
  }): Promise<any>;
33
32
  getProducts(): Promise<ProductData[]>;
34
- getProduct(id: number): Promise<Product | undefined>;
33
+ getProduct(id: number): Promise<ProductData | undefined>;
35
34
  addProduct(products: ProductData[]): Promise<void>;
36
35
  selectProducts(products: ProductData[]): Promise<void>;
37
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);
@@ -41,30 +40,15 @@ var ProductList = class extends import_BaseModule.BaseModule {
41
40
  this.store = options.store;
42
41
  this.otherParams = options.otherParams || {};
43
42
  if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
44
- this.store.list = options.initialState.list;
43
+ this.store.list = options.initialState.list.slice().sort((a, b) => Number(b.sort) - Number(a.sort));
45
44
  this.core.effects.emit(`${this.name}:changed`, this.store.list);
46
- this.storeChange();
47
45
  } else {
48
46
  this.store.list = [];
49
- this.store.productMap = /* @__PURE__ */ new Map();
50
47
  this.store.selectProducts = [];
51
48
  }
52
49
  this.request = core.getPlugin("request");
53
50
  }
54
51
  async storeChange(path, value) {
55
- var _a;
56
- (_a = this.store.list) == null ? void 0 : _a.forEach((product) => {
57
- const productModule = this.store.productMap.get(`product-${product.id}`);
58
- if (!productModule) {
59
- const newProductModule = new import_Product.Product(
60
- `product_${product.id.toString()}`
61
- );
62
- this.core.registerModule(newProductModule, { initialState: product });
63
- this.store.productMap.set(product.id.toString(), newProductModule);
64
- } else {
65
- productModule.updateData(product);
66
- }
67
- });
68
52
  }
69
53
  async loadProducts({
70
54
  category_ids = [],
@@ -86,7 +70,6 @@ var ProductList = class extends import_BaseModule.BaseModule {
86
70
  } catch (error) {
87
71
  console.error(error);
88
72
  }
89
- debugger;
90
73
  const productsData = await this.request.post(
91
74
  `/product/query`,
92
75
  {
@@ -119,8 +102,9 @@ var ProductList = class extends import_BaseModule.BaseModule {
119
102
  },
120
103
  { useCache: true }
121
104
  );
122
- this.addProduct(productsData.data.list);
123
- 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;
124
108
  }
125
109
  async loadProductsPrice({
126
110
  ids = [],
@@ -152,10 +136,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
152
136
  import_types.ProductListHooks.onGetProduct,
153
137
  this.store.list
154
138
  );
155
- const product = this.store.productMap.get(`${id}`);
156
- if (product)
157
- return product;
158
- 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;
159
141
  }
160
142
  async addProduct(products) {
161
143
  if (!this.store.list) {
@@ -169,7 +151,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
169
151
  this.store.list[index] = n;
170
152
  }
171
153
  });
172
- 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);
173
156
  }
174
157
  async selectProducts(products) {
175
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 {
@@ -389,7 +389,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
389
389
  }
390
390
  // 获取商品/服务的可用日期
391
391
  async getAvailableDate(params = {}) {
392
- var _a, _b, _c;
392
+ var _a, _b, _c, _d;
393
393
  let { products, startDate, endDate, type, useCache = true } = params;
394
394
  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"))) {
395
395
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
@@ -406,14 +406,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
406
406
  if (this.store.currentProduct) {
407
407
  tempProducts = [
408
408
  {
409
- ...this.store.currentProduct.getData(),
410
- _schedule: this.store.currentProduct.getOtherParams()["schedule"]
409
+ ...this.store.currentProduct,
410
+ _schedule: (_a = this.store.currentProductMeta) == null ? void 0 : _a["schedule"]
411
411
  }
412
412
  ];
413
413
  }
414
414
  let dateRange = this.store.date.getDateRange();
415
- const tempStartDate = startDate || ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date);
416
- 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);
415
+ const tempStartDate = startDate || ((_b = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _b.date);
416
+ 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);
417
417
  if (!tempProducts.length) {
418
418
  return [];
419
419
  }
@@ -808,13 +808,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
808
808
  return errorCartItemIds;
809
809
  }
810
810
  destroy() {
811
- var _a, _b, _c, _d, _e, _f;
811
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
812
812
  (_a = this.store.cart) == null ? void 0 : _a.destroy();
813
813
  (_b = this.store.step) == null ? void 0 : _b.destroy();
814
814
  (_c = this.store.products) == null ? void 0 : _c.destroy();
815
815
  (_d = this.store.guests) == null ? void 0 : _d.destroy();
816
816
  (_e = this.store.date) == null ? void 0 : _e.destroy();
817
817
  (_f = this.store.accountList) == null ? void 0 : _f.destroy();
818
+ (_g = this.store.schedule) == null ? void 0 : _g.destroy();
819
+ (_h = this.store.summary) == null ? void 0 : _h.destroy();
820
+ (_i = this.store.order) == null ? void 0 : _i.destroy();
818
821
  this.core.effects.offByModuleDestroy(this.name);
819
822
  this.core.unregisterModule(this);
820
823
  }
@@ -1595,15 +1598,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1595
1598
  }
1596
1599
  // 打开某个商品详情的弹窗,OS 层这边会记录当前选中的商品,适用于 session 类商品预约
1597
1600
  async openProductDetail(productId) {
1598
- const targetProduct = await this.store.products.getProduct(productId);
1599
- if (targetProduct) {
1600
- const targetProductData = targetProduct.getData();
1601
- this.store.currentProduct = targetProduct;
1601
+ const targetProductData = await this.store.products.getProduct(productId);
1602
+ if (targetProductData) {
1603
+ this.store.currentProduct = targetProductData;
1604
+ this.store.currentProductMeta = {};
1602
1605
  if (targetProductData["schedule.ids"]) {
1603
1606
  const newScheduleArr = this.getScheduleDataByIds(
1604
1607
  targetProductData["schedule.ids"]
1605
1608
  );
1606
- targetProduct.setOtherParams("schedule", newScheduleArr);
1609
+ if (!this.store.currentProductMeta)
1610
+ this.store.currentProductMeta = {};
1611
+ this.store.currentProductMeta.schedule = newScheduleArr;
1607
1612
  } else if (targetProductData.duration) {
1608
1613
  const dateRange = this.store.date.getDateRange();
1609
1614
  if (!(dateRange == null ? void 0 : dateRange.length))
@@ -1617,8 +1622,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1617
1622
  }
1618
1623
  }
1619
1624
  closeProductDetail() {
1620
- var _a;
1621
- (_a = this.store.currentProduct) == null ? void 0 : _a.setOtherParams("schedule", []);
1625
+ if (this.store.currentProductMeta) {
1626
+ this.store.currentProductMeta.schedule = [];
1627
+ }
1622
1628
  this.store.currentProduct = void 0;
1623
1629
  }
1624
1630
  getTimeslotBySchedule({
@@ -1627,9 +1633,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1627
1633
  resources,
1628
1634
  product
1629
1635
  }) {
1630
- var _a, _b, _c, _d, _e, _f;
1636
+ var _a, _b, _c, _d, _e;
1631
1637
  const targetProduct = this.store.currentProduct;
1632
- const targetProductData = product || (targetProduct == null ? void 0 : targetProduct.getData());
1638
+ const targetProductData = product || targetProduct;
1633
1639
  let targetSchedules = [];
1634
1640
  if (scheduleIds == null ? void 0 : scheduleIds.length) {
1635
1641
  targetSchedules = this.store.schedule.getScheduleListByIds(scheduleIds);
@@ -1649,7 +1655,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1649
1655
  );
1650
1656
  const productResources = (0, import_resources.getResourcesByProduct)(
1651
1657
  resourcesMap,
1652
- resources || ((_c = (_b = (_a = this.store.currentProduct) == null ? void 0 : _a.getData()) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
1658
+ resources || ((_b = (_a = this.store.currentProduct) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
1653
1659
  selectedResources,
1654
1660
  1
1655
1661
  );
@@ -1670,9 +1676,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1670
1676
  return -1;
1671
1677
  return 0;
1672
1678
  });
1673
- const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
1679
+ const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
1674
1680
  (n) => n.status === 1
1675
- )) == null ? void 0 : _f.id;
1681
+ )) == null ? void 0 : _e.id;
1676
1682
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1677
1683
  const resourcesUseableMap = {};
1678
1684
  let count = 0;
@@ -1746,9 +1752,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1746
1752
  return this.otherData[key];
1747
1753
  }
1748
1754
  async getProductTypeById(id) {
1749
- const product = await this.store.products.getProduct(id);
1750
- if (product) {
1751
- return product.getProductType();
1755
+ var _a;
1756
+ const productData = await this.store.products.getProduct(id);
1757
+ if (productData) {
1758
+ if (productData.duration) {
1759
+ return "duration";
1760
+ }
1761
+ if ((_a = productData["schedule.ids"]) == null ? void 0 : _a.length) {
1762
+ return "session";
1763
+ }
1764
+ return "normal";
1752
1765
  }
1753
1766
  return "normal";
1754
1767
  }
@@ -1909,7 +1922,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1909
1922
  return results;
1910
1923
  }
1911
1924
  async getAvailableDateForSessionOptimize(params = {}) {
1912
- var _a, _b, _c, _d, _e, _f;
1925
+ var _a, _b, _c, _d;
1913
1926
  let { startDate, endDate } = params;
1914
1927
  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"))) {
1915
1928
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
@@ -1925,7 +1938,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1925
1938
  tempEndDate = endDate || "";
1926
1939
  }
1927
1940
  endDate = tempEndDate;
1928
- const cache = (_a = this.store.currentProduct) == null ? void 0 : _a.getOtherParams()["timeSlotBySchedule"];
1941
+ const cache = (_a = this.store.currentProductMeta) == null ? void 0 : _a["timeSlotBySchedule"];
1929
1942
  if (cache) {
1930
1943
  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")) {
1931
1944
  this.store.date.setDateList(cache.dateList);
@@ -1936,8 +1949,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1936
1949
  }
1937
1950
  }
1938
1951
  let tempProducts;
1939
- tempProducts = (_b = this.store.currentProduct) == null ? void 0 : _b.getData();
1940
- const schedule = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["schedule"];
1952
+ tempProducts = this.store.currentProduct;
1953
+ const schedule = (_b = this.store.currentProductMeta) == null ? void 0 : _b["schedule"];
1941
1954
  const filteredSchedule = (0, import_resources.filterScheduleByDateRange)(
1942
1955
  schedule,
1943
1956
  startDate || "",
@@ -1954,7 +1967,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1954
1967
  let dates = [];
1955
1968
  let currentDate = (0, import_dayjs.default)(startDate);
1956
1969
  let firstAvailableDate = "";
1957
- const openResources = ((_e = (_d = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.filter(
1970
+ const openResources = ((_d = (_c = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
1958
1971
  (m) => m.status === 1
1959
1972
  )) || [];
1960
1973
  const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
@@ -2055,12 +2068,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2055
2068
  }
2056
2069
  dates = (0, import_utils3.handleAvailableDateByResource)(res.data, dates);
2057
2070
  this.store.date.setDateList(dates);
2058
- (_f = this.store.currentProduct) == null ? void 0 : _f.setOtherParams("timeSlotBySchedule", {
2071
+ if (!this.store.currentProductMeta)
2072
+ this.store.currentProductMeta = {};
2073
+ this.store.currentProductMeta.timeSlotBySchedule = {
2059
2074
  dateList: dates,
2060
2075
  firstAvailableDate,
2061
2076
  startDate,
2062
2077
  endDate: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD")
2063
- });
2078
+ };
2064
2079
  return {
2065
2080
  dateList: dates,
2066
2081
  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];
@@ -111,7 +111,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
111
111
  * 获取当前的客户搜索条件
112
112
  * @returns 当前搜索条件
113
113
  */
114
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
114
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
115
115
  /**
116
116
  * 获取客户列表状态(包含滚动加载相关状态)
117
117
  * @returns 客户状态
@@ -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": "0.0.226",
4
+ "version": "0.0.228",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",