feat: 添加汇率服务和缓存服务,优化数据源和日志服务
refactor: 重构数据源工厂和类型定义,提升代码可维护性 fix: 修复类型转换和状态机文档中的错误 docs: 更新服务架构文档,添加新的服务闭环流程 test: 添加汇率服务单元测试 chore: 清理无用代码和注释,优化代码结构
This commit is contained in:
@@ -21,10 +21,11 @@ export class ProductController {
|
||||
*/
|
||||
static async triggerDynamicPricing(req: Request, res: Response) {
|
||||
const { id } = req.params;
|
||||
const { tenantId } = (req as any).traceContext;
|
||||
const { tenantId, shopId } = (req as any).traceContext;
|
||||
|
||||
try {
|
||||
const result = await DynamicPricingService.applyDynamicPricing(id as string);
|
||||
// 使用 generatePricingDecision 替代 applyDynamicPricing
|
||||
const result = await DynamicPricingService.generatePricingDecision(tenantId, shopId, id as string);
|
||||
res.json({ success: true, data: result });
|
||||
} catch (err: any) {
|
||||
res.status(500).json({ success: false, error: err.message });
|
||||
@@ -390,16 +391,11 @@ export class ProductController {
|
||||
* 获取动态调价建议
|
||||
*/
|
||||
static async getPriceAdvice(req: Request, res: Response) {
|
||||
const id = Number(req.params.id);
|
||||
const id = String(req.params.id);
|
||||
const { tenantId, shopId, taskId, traceId, userId } = (req as any).traceContext;
|
||||
try {
|
||||
const advice = await DynamicPricingService.calculateOptimalPrice(id, {
|
||||
minMargin: 0.15,
|
||||
maxMargin: 0.50,
|
||||
priceFloor: 5.0,
|
||||
competitorMatch: 'UNDER_1%',
|
||||
useFederatedModel: false
|
||||
});
|
||||
// 使用 generatePricingDecision 替代 calculateOptimalPrice
|
||||
const advice = await DynamicPricingService.generatePricingDecision(tenantId, shopId, id);
|
||||
|
||||
await AuditService.log({
|
||||
tenantId,
|
||||
|
||||
@@ -49,7 +49,17 @@ export class TelemetryController {
|
||||
};
|
||||
|
||||
if (pricingIds?.length > 0) {
|
||||
results.pricing = await DynamicPricingService.approveSuggestions(tenantId, pricingIds);
|
||||
// 批量执行定价决策
|
||||
let approvedCount = 0;
|
||||
for (const decisionId of pricingIds) {
|
||||
try {
|
||||
await DynamicPricingService.executePricingDecision(tenantId, decisionId);
|
||||
approvedCount++;
|
||||
} catch (err) {
|
||||
logger.error(`[TelemetryController] Failed to approve pricing decision ${decisionId}:`, err);
|
||||
}
|
||||
}
|
||||
results.pricing = approvedCount;
|
||||
}
|
||||
|
||||
if (sourcingIds?.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user