@pisell/pisellos 2.2.3 → 2.2.5

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.
@@ -129,7 +129,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
129
129
  }, {
130
130
  cache: {
131
131
  mode: RequestModeENUM.REMOTE_LOCAL,
132
- updateCache: true,
133
132
  type: "indexDB"
134
133
  }
135
134
  });
@@ -212,37 +211,53 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
212
211
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
213
212
  while (1) switch (_context4.prev = _context4.next) {
214
213
  case 0:
215
- _context4.next = 2;
214
+ _context4.prev = 0;
215
+ _context4.next = 3;
216
216
  return this.getProducts();
217
- case 2:
217
+ case 3:
218
218
  allProducts = _context4.sent;
219
- _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;
220
222
  return this.loadProductsPrice({
221
223
  ids: allProducts.map(function (product) {
222
224
  return product.id;
225
+ }).sort(function (a, b) {
226
+ return a - b;
223
227
  }),
224
228
  schedule_date: schedule_date
225
229
  });
226
- case 5:
230
+ case 7:
227
231
  priceData = _context4.sent;
232
+ console.log("[ProductsModule] \uD83C\uDF10 \u83B7\u53D6\u5546\u54C1\u62A5\u4EF7\u5355\u4EF7\u683C\u6210\u529F", priceData);
228
233
  // 3. 构建上下文(包含价格数据,合并外部传入的额外上下文)
229
234
  context = _objectSpread({
230
235
  schedule_date: schedule_date,
231
236
  priceData: priceData
232
- }, extraContext); // 4. 通过格式化器流程处理商品(包括价格应用、字段扩展等)
233
- _context4.next = 9;
237
+ }, extraContext);
238
+ 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");
239
+ // 4. 通过格式化器流程处理商品(包括价格应用、字段扩展等)
240
+ _context4.next = 13;
234
241
  return this.applyFormatters(allProducts, context);
235
- case 9:
242
+ case 13:
236
243
  processedProducts = _context4.sent;
237
- _context4.next = 12;
244
+ 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);
245
+ // 5. 触发钩子事件(用于外部监听)
246
+ _context4.next = 17;
238
247
  return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
239
- case 12:
248
+ case 17:
240
249
  return _context4.abrupt("return", processedProducts);
241
- case 13:
250
+ case 20:
251
+ _context4.prev = 20;
252
+ _context4.t0 = _context4["catch"](0);
253
+ console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context4.t0);
254
+ case 23:
255
+ return _context4.abrupt("return", []);
256
+ case 24:
242
257
  case "end":
243
258
  return _context4.stop();
244
259
  }
245
- }, _callee4, this);
260
+ }, _callee4, this, [[0, 20]]);
246
261
  }));
247
262
  function prepareProductsWithPrice(_x6, _x7) {
248
263
  return _prepareProductsWithPrice.apply(this, arguments);
@@ -90,7 +90,6 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
90
90
  {
91
91
  cache: {
92
92
  mode: import_plugins.RequestModeENUM.REMOTE_LOCAL,
93
- updateCache: true,
94
93
  type: "indexDB"
95
94
  }
96
95
  }
@@ -126,23 +125,32 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
126
125
  * @private
127
126
  */
128
127
  async prepareProductsWithPrice(schedule_date, extraContext) {
129
- const allProducts = await this.getProducts();
130
- const priceData = await this.loadProductsPrice({
131
- ids: allProducts.map((product) => product.id),
132
- schedule_date
133
- });
134
- const context = {
135
- schedule_date,
136
- priceData,
137
- ...extraContext
138
- // 合并 Server 层传入的额外数据(如 scheduleList)
139
- };
140
- const processedProducts = await this.applyFormatters(allProducts, context);
141
- await this.core.effects.emit(
142
- import_types.ProductsHooks.onProductsPriceApplied,
143
- processedProducts
144
- );
145
- 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).sort((a, b) => a - b),
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 [];
146
154
  }
147
155
  /**
148
156
  * 应用所有已注册的格式化器
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.3",
4
+ "version": "2.2.5",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",