@pisell/pisellos 2.2.2 → 2.2.4

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.
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -127,10 +127,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
127
127
  customer_id: customer_id,
128
128
  schedule_date: schedule_date
129
129
  }, {
130
- useCache: true,
131
130
  cache: {
132
131
  mode: RequestModeENUM.REMOTE_LOCAL,
133
- updateCache: true,
134
132
  type: "indexDB"
135
133
  }
136
134
  });
@@ -213,37 +211,51 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
213
211
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
214
212
  while (1) switch (_context4.prev = _context4.next) {
215
213
  case 0:
216
- _context4.next = 2;
214
+ _context4.prev = 0;
215
+ _context4.next = 3;
217
216
  return this.getProducts();
218
- case 2:
217
+ case 3:
219
218
  allProducts = _context4.sent;
220
- _context4.next = 5;
219
+ console.log("[ProductsModule] \uD83C\uDF10 \u5F00\u59CB\u83B7\u53D6\u5546\u54C1\u62A5\u4EF7\u5355\u4EF7\u683C");
220
+ // 2. 获取价格数据
221
+ _context4.next = 7;
221
222
  return this.loadProductsPrice({
222
223
  ids: allProducts.map(function (product) {
223
224
  return product.id;
224
225
  }),
225
226
  schedule_date: schedule_date
226
227
  });
227
- case 5:
228
+ case 7:
228
229
  priceData = _context4.sent;
230
+ console.log("[ProductsModule] \uD83C\uDF10 \u83B7\u53D6\u5546\u54C1\u62A5\u4EF7\u5355\u4EF7\u683C\u6210\u529F", priceData);
229
231
  // 3. 构建上下文(包含价格数据,合并外部传入的额外上下文)
230
232
  context = _objectSpread({
231
233
  schedule_date: schedule_date,
232
234
  priceData: priceData
233
- }, extraContext); // 4. 通过格式化器流程处理商品(包括价格应用、字段扩展等)
234
- _context4.next = 9;
235
+ }, extraContext);
236
+ console.log("[ProductsModule] \uD83C\uDF10 \u901A\u8FC7\u683C\u5F0F\u5316\u5668\u6D41\u7A0B\u5904\u7406\u5546\u54C1\uFF08\u5305\u62EC\u4EF7\u683C\u5E94\u7528\u3001\u5B57\u6BB5\u6269\u5C55\u7B49\uFF09");
237
+ // 4. 通过格式化器流程处理商品(包括价格应用、字段扩展等)
238
+ _context4.next = 13;
235
239
  return this.applyFormatters(allProducts, context);
236
- case 9:
240
+ case 13:
237
241
  processedProducts = _context4.sent;
238
- _context4.next = 12;
242
+ console.log("[ProductsModule] \uD83C\uDF10 \u901A\u8FC7\u683C\u5F0F\u5316\u5668\u6D41\u7A0B\u5904\u7406\u5546\u54C1\uFF08\u5305\u62EC\u4EF7\u683C\u5E94\u7528\u3001\u5B57\u6BB5\u6269\u5C55\u7B49\uFF09\u6210\u529F", processedProducts);
243
+ // 5. 触发钩子事件(用于外部监听)
244
+ _context4.next = 17;
239
245
  return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
240
- case 12:
246
+ case 17:
241
247
  return _context4.abrupt("return", processedProducts);
242
- case 13:
248
+ case 20:
249
+ _context4.prev = 20;
250
+ _context4.t0 = _context4["catch"](0);
251
+ console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context4.t0);
252
+ case 23:
253
+ return _context4.abrupt("return", []);
254
+ case 24:
243
255
  case "end":
244
256
  return _context4.stop();
245
257
  }
246
- }, _callee4, this);
258
+ }, _callee4, this, [[0, 20]]);
247
259
  }));
248
260
  function prepareProductsWithPrice(_x6, _x7) {
249
261
  return _prepareProductsWithPrice.apply(this, arguments);
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  };
327
327
  setOtherData(key: string, value: any): void;
328
328
  getOtherData(key: string): any;
329
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
329
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
330
330
  /**
331
331
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
332
332
  *
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -88,10 +88,8 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
88
88
  schedule_date
89
89
  },
90
90
  {
91
- useCache: true,
92
91
  cache: {
93
92
  mode: import_plugins.RequestModeENUM.REMOTE_LOCAL,
94
- updateCache: true,
95
93
  type: "indexDB"
96
94
  }
97
95
  }
@@ -127,23 +125,32 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
127
125
  * @private
128
126
  */
129
127
  async prepareProductsWithPrice(schedule_date, extraContext) {
130
- const allProducts = await this.getProducts();
131
- const priceData = await this.loadProductsPrice({
132
- ids: allProducts.map((product) => product.id),
133
- schedule_date
134
- });
135
- const context = {
136
- schedule_date,
137
- priceData,
138
- ...extraContext
139
- // 合并 Server 层传入的额外数据(如 scheduleList)
140
- };
141
- const processedProducts = await this.applyFormatters(allProducts, context);
142
- await this.core.effects.emit(
143
- import_types.ProductsHooks.onProductsPriceApplied,
144
- processedProducts
145
- );
146
- return processedProducts;
128
+ try {
129
+ const allProducts = await this.getProducts();
130
+ console.log(`[ProductsModule] 🌐 开始获取商品报价单价格`);
131
+ const priceData = await this.loadProductsPrice({
132
+ ids: allProducts.map((product) => product.id),
133
+ schedule_date
134
+ });
135
+ console.log(`[ProductsModule] 🌐 获取商品报价单价格成功`, priceData);
136
+ const context = {
137
+ schedule_date,
138
+ priceData,
139
+ ...extraContext
140
+ // 合并 Server 层传入的额外数据(如 scheduleList)
141
+ };
142
+ console.log(`[ProductsModule] 🌐 通过格式化器流程处理商品(包括价格应用、字段扩展等)`);
143
+ const processedProducts = await this.applyFormatters(allProducts, context);
144
+ console.log(`[ProductsModule] 🌐 通过格式化器流程处理商品(包括价格应用、字段扩展等)成功`, processedProducts);
145
+ await this.core.effects.emit(
146
+ import_types.ProductsHooks.onProductsPriceApplied,
147
+ processedProducts
148
+ );
149
+ return processedProducts;
150
+ } catch (err) {
151
+ console.log(`[ProductsModule] 🌐 ERROR`, err);
152
+ }
153
+ return [];
147
154
  }
148
155
  /**
149
156
  * 应用所有已注册的格式化器
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  };
327
327
  setOtherData(key: string, value: any): void;
328
328
  getOtherData(key: string): any;
329
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
329
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
330
330
  /**
331
331
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
332
332
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.2",
4
+ "version": "2.2.4",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",