@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.
|
|
214
|
+
_context4.prev = 0;
|
|
215
|
+
_context4.next = 3;
|
|
216
216
|
return this.getProducts();
|
|
217
|
-
case
|
|
217
|
+
case 3:
|
|
218
218
|
allProducts = _context4.sent;
|
|
219
|
-
|
|
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
|
|
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);
|
|
233
|
-
|
|
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
|
|
242
|
+
case 13:
|
|
236
243
|
processedProducts = _context4.sent;
|
|
237
|
-
|
|
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
|
|
248
|
+
case 17:
|
|
240
249
|
return _context4.abrupt("return", processedProducts);
|
|
241
|
-
case
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
priceData
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
* 应用所有已注册的格式化器
|