@pisell/pisellos 2.0.67 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/core/index.js +1 -2
  2. package/dist/effects/index.d.ts +3 -4
  3. package/dist/effects/index.js +6 -15
  4. package/dist/modules/AccountList/index.d.ts +1 -7
  5. package/dist/modules/AccountList/index.js +14 -81
  6. package/dist/modules/AccountList/types.d.ts +0 -28
  7. package/dist/modules/AccountList/types.js +0 -8
  8. package/dist/modules/Cart/utils/changePrice.d.ts +2 -2
  9. package/dist/modules/Cart/utils/changePrice.js +1 -1
  10. package/dist/modules/ProductList/index.d.ts +3 -14
  11. package/dist/modules/ProductList/index.js +33 -67
  12. package/dist/modules/ProductList/types.d.ts +0 -1
  13. package/dist/modules/Rules/index.js +14 -27
  14. package/dist/modules/Rules/types.d.ts +0 -1
  15. package/dist/modules/index.d.ts +0 -1
  16. package/dist/modules/index.js +0 -1
  17. package/dist/plugins/window.d.ts +0 -1
  18. package/dist/solution/BookingByStep/index.js +50 -34
  19. package/dist/solution/BookingByStep/types.d.ts +3 -2
  20. package/dist/solution/BookingByStep/utils/resources.js +12 -4
  21. package/dist/solution/BuyTickets/index.d.ts +2 -2
  22. package/dist/solution/BuyTickets/index.js +1 -1
  23. package/dist/solution/ShopDiscount/index.js +2 -4
  24. package/dist/solution/index.d.ts +0 -1
  25. package/dist/solution/index.js +0 -1
  26. package/dist/types/index.d.ts +1 -3
  27. package/lib/core/index.js +1 -1
  28. package/lib/effects/index.d.ts +3 -4
  29. package/lib/effects/index.js +1 -4
  30. package/lib/modules/AccountList/index.d.ts +1 -7
  31. package/lib/modules/AccountList/index.js +0 -27
  32. package/lib/modules/AccountList/types.d.ts +0 -28
  33. package/lib/modules/Cart/utils/changePrice.d.ts +2 -2
  34. package/lib/modules/Cart/utils/changePrice.js +1 -1
  35. package/lib/modules/ProductList/index.d.ts +3 -14
  36. package/lib/modules/ProductList/index.js +14 -54
  37. package/lib/modules/ProductList/types.d.ts +0 -1
  38. package/lib/modules/Rules/index.js +12 -20
  39. package/lib/modules/Rules/types.d.ts +0 -1
  40. package/lib/modules/index.d.ts +0 -1
  41. package/lib/modules/index.js +0 -2
  42. package/lib/plugins/window.d.ts +0 -1
  43. package/lib/solution/BookingByStep/index.js +39 -27
  44. package/lib/solution/BookingByStep/types.d.ts +3 -2
  45. package/lib/solution/BookingByStep/utils/resources.js +12 -4
  46. package/lib/solution/BuyTickets/index.d.ts +2 -2
  47. package/lib/solution/BuyTickets/index.js +1 -1
  48. package/lib/solution/ShopDiscount/index.js +1 -2
  49. package/lib/solution/index.d.ts +0 -1
  50. package/lib/solution/index.js +0 -2
  51. package/lib/types/index.d.ts +1 -3
  52. package/package.json +1 -1
  53. package/dist/modules/Customer/constants.d.ts +0 -7
  54. package/dist/modules/Customer/constants.js +0 -12
  55. package/dist/modules/Customer/index.d.ts +0 -122
  56. package/dist/modules/Customer/index.js +0 -697
  57. package/dist/modules/Customer/types.d.ts +0 -146
  58. package/dist/modules/Customer/types.js +0 -41
  59. package/dist/solution/BookingTicket/index.d.ts +0 -172
  60. package/dist/solution/BookingTicket/index.js +0 -665
  61. package/dist/solution/BookingTicket/types.d.ts +0 -68
  62. package/dist/solution/BookingTicket/types.js +0 -43
  63. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  64. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
  65. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
  66. package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -174
  67. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -81
  68. package/dist/solution/BookingTicket/utils/scan/index.js +0 -285
  69. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  70. package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
  71. package/dist/utils/task.d.ts +0 -40
  72. package/dist/utils/task.js +0 -171
  73. package/dist/utils/watch.d.ts +0 -102
  74. package/dist/utils/watch.js +0 -294
  75. package/lib/modules/Customer/constants.d.ts +0 -7
  76. package/lib/modules/Customer/constants.js +0 -39
  77. package/lib/modules/Customer/index.d.ts +0 -122
  78. package/lib/modules/Customer/index.js +0 -440
  79. package/lib/modules/Customer/types.d.ts +0 -146
  80. package/lib/modules/Customer/types.js +0 -37
  81. package/lib/solution/BookingTicket/index.d.ts +0 -172
  82. package/lib/solution/BookingTicket/index.js +0 -399
  83. package/lib/solution/BookingTicket/types.d.ts +0 -68
  84. package/lib/solution/BookingTicket/types.js +0 -72
  85. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  86. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
  87. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -16
  88. package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -125
  89. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -81
  90. package/lib/solution/BookingTicket/utils/scan/index.js +0 -210
  91. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  92. package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
  93. package/lib/utils/task.d.ts +0 -40
  94. package/lib/utils/task.js +0 -109
  95. package/lib/utils/watch.d.ts +0 -102
  96. package/lib/utils/watch.js +0 -217
@@ -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,20 +7,16 @@ 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>;
14
- loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, }: {
14
+ loadProducts({ category_ids, product_ids, collection, schedule_date, cacheId }: {
15
15
  category_ids?: number[];
16
16
  product_ids?: number[];
17
17
  collection?: number | string[];
18
18
  schedule_date?: string;
19
19
  cacheId?: string;
20
- customer_id?: number;
21
- menu_list_ids?: number[];
22
- schedule_datetime?: string;
23
- with_count?: string[];
24
- with_schedule?: number;
25
20
  }): Promise<any>;
26
21
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
27
22
  ids?: number[];
@@ -30,13 +25,7 @@ export declare class ProductList extends BaseModule implements Module {
30
25
  channel?: string;
31
26
  }): Promise<any>;
32
27
  getProducts(): Promise<ProductData[]>;
33
- getProduct(id: number): Promise<Product | undefined>;
28
+ getProduct(id: number): Promise<ProductData | undefined>;
34
29
  addProduct(products: ProductData[]): Promise<void>;
35
30
  selectProducts(products: ProductData[]): Promise<void>;
36
- /**
37
- * 根据商品编码或条码搜索商品
38
- * @param code 商品编码或条码
39
- * @returns 匹配的商品列表,如果没有匹配则返回空数组
40
- */
41
- findProductsByCodeOrBarcode(code: string): ProductData[];
42
31
  }
@@ -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,54 +32,36 @@ 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 = [],
69
55
  product_ids = [],
70
56
  collection = [],
71
- menu_list_ids = [],
72
- customer_id: paramsCustomerId,
73
- with_count = [],
74
- schedule_datetime,
75
57
  schedule_date,
76
- cacheId,
77
- with_schedule
58
+ cacheId
78
59
  }) {
79
- var _a;
60
+ var _a, _b;
80
61
  let userPlugin = this.core.getPlugin("user");
81
62
  let customer_id = void 0;
82
63
  try {
83
- customer_id = paramsCustomerId || ((_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id);
64
+ customer_id = (_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id;
84
65
  } catch (error) {
85
66
  console.error(error);
86
67
  }
@@ -106,17 +87,15 @@ var ProductList = class extends import_BaseModule.BaseModule {
106
87
  ids: product_ids,
107
88
  collection,
108
89
  front_end_cache_id: cacheId,
109
- menu_list_ids,
110
- with_count,
111
90
  // client_schedule_ids: schedule_ids,
112
91
  schedule_date,
113
- with_schedule,
114
- schedule_datetime
92
+ application_code: (_b = this.otherParams) == null ? void 0 : _b.channel
115
93
  },
116
94
  { useCache: true }
117
95
  );
118
- this.addProduct(productsData.data.list);
119
- return productsData.data.list;
96
+ const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
97
+ this.addProduct(sortedList);
98
+ return sortedList;
120
99
  }
121
100
  async loadProductsPrice({
122
101
  ids = [],
@@ -148,10 +127,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
148
127
  import_types.ProductListHooks.onGetProduct,
149
128
  this.store.list
150
129
  );
151
- const product = this.store.productMap.get(`${id}`);
152
- if (product)
153
- return product;
154
- return void 0;
130
+ const product = this.store.list.find((product2) => product2.id === id);
131
+ return product ? (0, import_lodash_es.cloneDeep)(product) : void 0;
155
132
  }
156
133
  async addProduct(products) {
157
134
  if (!this.store.list) {
@@ -165,29 +142,12 @@ var ProductList = class extends import_BaseModule.BaseModule {
165
142
  this.store.list[index] = n;
166
143
  }
167
144
  });
168
- this.storeChange();
145
+ this.store.list.sort((a, b) => Number(b.sort) - Number(a.sort));
146
+ this.core.effects.emit(`${this.name}:changed`, this.store.list);
169
147
  }
170
148
  async selectProducts(products) {
171
149
  this.store.selectProducts = products;
172
150
  }
173
- /**
174
- * 根据商品编码或条码搜索商品
175
- * @param code 商品编码或条码
176
- * @returns 匹配的商品列表,如果没有匹配则返回空数组
177
- */
178
- findProductsByCodeOrBarcode(code) {
179
- if (!code || typeof code !== "string") {
180
- return [];
181
- }
182
- const trimmedCode = code.trim();
183
- if (!trimmedCode) {
184
- return [];
185
- }
186
- const matchingProducts = this.store.list.filter((product) => {
187
- return product.code && product.code.trim() === trimmedCode || product.barcode && product.barcode.trim() === trimmedCode;
188
- });
189
- return (0, import_lodash_es.cloneDeep)(matchingProducts);
190
- }
191
151
  };
192
152
  // Annotate the CommonJS export names for ESM import in node:
193
153
  0 && (module.exports = {
@@ -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 {
@@ -37,7 +37,6 @@ var import_types = require("./types");
37
37
  var import_utils = require("../../solution/ShopDiscount/utils");
38
38
  var import_utils2 = require("../Cart/utils");
39
39
  var import_decimal = __toESM(require("decimal.js"));
40
- var import_lodash_es = require("lodash-es");
41
40
  var RulesModule = class extends import_BaseModule.BaseModule {
42
41
  constructor(name, version) {
43
42
  super(name, version);
@@ -189,23 +188,19 @@ var RulesModule = class extends import_BaseModule.BaseModule {
189
188
  if (isAvailableProduct && isLimitedProduct) {
190
189
  (_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
191
190
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
192
- const discountType = discount.tag || discount.type;
193
- const productData = {
191
+ applicableProducts.push({
194
192
  amount: product.price,
195
- type: discountType,
196
- tag: discountType,
193
+ type: discount.tag || discount.type,
194
+ tag: discount.tag || discount.type,
197
195
  discount: {
198
196
  resource_id: discount.id,
199
197
  title: discount.format_title,
200
198
  original_amount: product.origin_total,
201
199
  pre_value: discount.par_value,
202
200
  product_id: originProduct.id
203
- }
204
- };
205
- if (discountType !== "good_pass") {
206
- productData.num = product.num || 1;
207
- }
208
- applicableProducts.push(productData);
201
+ },
202
+ num: product.num || 1
203
+ });
209
204
  discountApplicableProducts.set(discount.id, applicableProducts);
210
205
  }
211
206
  });
@@ -220,9 +215,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
220
215
  }
221
216
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
222
217
  var _a2;
223
- if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
218
+ if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
224
219
  return false;
225
- if ((Number(product.total) <= 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
220
+ if ((Number(product.total) === 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
226
221
  var _a3;
227
222
  return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
228
223
  })) && (discount.tag || discount.type) !== "good_pass")
@@ -247,7 +242,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
247
242
  }))) {
248
243
  isManualDiscount = false;
249
244
  }
250
- if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
245
+ if (applicableDiscounts.length === 0 || isManualDiscount) {
251
246
  if (product.isClient) {
252
247
  processedProductsMap.set(
253
248
  product._id,
@@ -314,21 +309,18 @@ var RulesModule = class extends import_BaseModule.BaseModule {
314
309
  productOriginTotal = product.total;
315
310
  }
316
311
  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;
318
312
  const discountDetail = {
319
313
  amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
320
- type: discountType,
314
+ type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
321
315
  discount: {
322
316
  resource_id: selectedDiscount2.id,
323
317
  title: selectedDiscount2.format_title,
324
318
  original_amount: productOriginTotal,
325
319
  product_id: originProduct.id,
326
320
  percent: selectedDiscount2.par_value
327
- }
321
+ },
322
+ num: product.num || 1
328
323
  };
329
- if ((selectedDiscount2.tag || selectedDiscount2.type) !== "good_pass") {
330
- discountDetail.num = product.num || 1;
331
- }
332
324
  appliedProducts.push(discountDetail);
333
325
  appliedDiscountProducts.set(selectedDiscount2.id, appliedProducts);
334
326
  if (product.isClient) {
@@ -39,7 +39,6 @@ type ProductDetail = {
39
39
  original_price?: number | string;
40
40
  num?: number;
41
41
  quantity: number;
42
- vouchersApplicable?: boolean;
43
42
  };
44
43
  export interface RulesParamsHooks {
45
44
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -3,7 +3,6 @@ export * from './ProductList';
3
3
  export * from './Cart';
4
4
  export * from './Account';
5
5
  export * from './AccountList';
6
- export * from './Customer';
7
6
  export * from './Date';
8
7
  export * from './Guests';
9
8
  export * from './Order';
@@ -21,7 +21,6 @@ __reExport(modules_exports, require("./ProductList"), module.exports);
21
21
  __reExport(modules_exports, require("./Cart"), module.exports);
22
22
  __reExport(modules_exports, require("./Account"), module.exports);
23
23
  __reExport(modules_exports, require("./AccountList"), module.exports);
24
- __reExport(modules_exports, require("./Customer"), module.exports);
25
24
  __reExport(modules_exports, require("./Date"), module.exports);
26
25
  __reExport(modules_exports, require("./Guests"), module.exports);
27
26
  __reExport(modules_exports, require("./Order"), module.exports);
@@ -37,7 +36,6 @@ __reExport(modules_exports, require("./Schedule"), module.exports);
37
36
  ...require("./Cart"),
38
37
  ...require("./Account"),
39
38
  ...require("./AccountList"),
40
- ...require("./Customer"),
41
39
  ...require("./Date"),
42
40
  ...require("./Guests"),
43
41
  ...require("./Order"),
@@ -13,7 +13,6 @@ export interface WindowPlugin extends Plugin {
13
13
  navigator: Partial<Navigator>;
14
14
  document: Partial<Document>;
15
15
  history: History;
16
- interaction?: any;
17
16
  }
18
17
  /**
19
18
  * 简单的 Storage 接口实现
@@ -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) {
@@ -38,7 +38,6 @@ var import_types = require("./types");
38
38
  var import_Discount = require("../../modules/Discount");
39
39
  var import_Rules = require("../../modules/Rules");
40
40
  var import_decimal = __toESM(require("decimal.js"));
41
- var import_lodash_es = require("lodash-es");
42
41
  var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
43
42
  constructor(name, version) {
44
43
  super(name, version);
@@ -338,7 +337,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
338
337
  var _a2;
339
338
  const targetProduct = productList.find((n) => n.id === id);
340
339
  const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
341
- return Number(product == null ? void 0 : product.total) <= 0 && (Number(product == null ? void 0 : product.origin_total) <= 0 || !(product == null ? void 0 : product.origin_total)) || (0, import_lodash_es.isBoolean)(product == null ? void 0 : product.vouchersApplicable) && !(product == null ? void 0 : product.vouchersApplicable);
340
+ return Number(product == null ? void 0 : product.total) === 0 && (Number(product == null ? void 0 : product.origin_total) === 0 || !(product == null ? void 0 : product.origin_total));
342
341
  };
343
342
  const allUsedProductIds = newDiscountList.map((n) => {
344
343
  var _a2;
@@ -1,4 +1,3 @@
1
1
  export * from './BuyTickets';
2
2
  export * from './BookingByStep';
3
- export * from './BookingTicket';
4
3
  export * from './ShopDiscount';
@@ -18,12 +18,10 @@ var solution_exports = {};
18
18
  module.exports = __toCommonJS(solution_exports);
19
19
  __reExport(solution_exports, require("./BuyTickets"), module.exports);
20
20
  __reExport(solution_exports, require("./BookingByStep"), module.exports);
21
- __reExport(solution_exports, require("./BookingTicket"), module.exports);
22
21
  __reExport(solution_exports, require("./ShopDiscount"), module.exports);
23
22
  // Annotate the CommonJS export names for ESM import in node:
24
23
  0 && (module.exports = {
25
24
  ...require("./BuyTickets"),
26
25
  ...require("./BookingByStep"),
27
- ...require("./BookingTicket"),
28
26
  ...require("./ShopDiscount")
29
27
  });
@@ -38,9 +38,7 @@ export interface PisellCore {
38
38
  getModuleExports: <T = any>(name: string) => T | null;
39
39
  hasModule: (name: string) => boolean;
40
40
  effects: {
41
- on: (event: string, callback: (payload: any) => void) => () => void;
42
- once: (event: string, callback: (payload: any) => void) => () => void;
43
- off: (event: string, callback: (payload: any) => void) => void;
41
+ on: (event: string, callback: (payload: any) => void) => void;
44
42
  emit: (event: string, payload: any, value?: any) => Promise<{
45
43
  status: boolean;
46
44
  data: any;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.0.67",
4
+ "version": "2.1.2",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,7 +0,0 @@
1
- export declare const SORT_BY = "id";
2
- export declare const DEFAULT_PAGE_SIZE = 20;
3
- export declare const DEFAULT_CUSTOMER: {
4
- id: number;
5
- nickname: string;
6
- name: string;
7
- };