@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.
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/modules/products/index.js +25 -13
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/modules/products/index.js +26 -19
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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(): "
|
|
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.
|
|
214
|
+
_context4.prev = 0;
|
|
215
|
+
_context4.next = 3;
|
|
217
216
|
return this.getProducts();
|
|
218
|
-
case
|
|
217
|
+
case 3:
|
|
219
218
|
allProducts = _context4.sent;
|
|
220
|
-
|
|
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
|
|
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);
|
|
234
|
-
|
|
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
|
|
240
|
+
case 13:
|
|
237
241
|
processedProducts = _context4.sent;
|
|
238
|
-
|
|
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
|
|
246
|
+
case 17:
|
|
241
247
|
return _context4.abrupt("return", processedProducts);
|
|
242
|
-
case
|
|
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<"
|
|
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(): "
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
priceData
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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<"
|
|
329
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
330
330
|
/**
|
|
331
331
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
332
332
|
*
|