feat: 实现服务层核心功能与文档更新
refactor(ProductService): 修复createProduct方法和其他方法错误 fix(InventoryAgingService): 修复AGING_THRESHOLD_DAYS引用问题 fix(InventoryService): 修复predictSKUDemand方法 refactor(ChatBotController): 从tsoa风格改为Express风格 fix(CommandCenterController): 修复类型问题 fix(AdAutoService): 修复stock可能为undefined的问题 docs: 更新SERVICE_MAP、DOMAIN_MODEL等架构文档 chore: 启动前端服务(运行在http://localhost:8000)
This commit is contained in:
@@ -6,6 +6,7 @@ import { MultiTenantCore } from '../domains/Tenant/MultiTenantCore';
|
||||
import { Product } from '../models/Product';
|
||||
import { logger } from '../utils/logger';
|
||||
import { AgingInventoryService } from './AgingInventoryService';
|
||||
import { InventoryAgingService } from './InventoryAgingService';
|
||||
import { AIService } from './AIService';
|
||||
import { ArbitrageService } from './ArbitrageService';
|
||||
import { CompetitorService } from './CompetitorService';
|
||||
@@ -180,10 +181,10 @@ export class ProductService {
|
||||
|
||||
const agingData = [];
|
||||
for (const sku of product.skus) {
|
||||
const info = await AgingInventoryService.analyzeSKUAging(id.toString(), sku.skuId);
|
||||
const suggestions = info.map(item => ({
|
||||
const info = await InventoryAgingService.analyzeAging(tenantId);
|
||||
const suggestions = info.filter(item => item.skuId === sku.skuId).map(item => ({
|
||||
...item,
|
||||
clearance: AgingInventoryService.getClearanceSuggestion(item.ageDays)
|
||||
clearance: item.suggestedAction
|
||||
}));
|
||||
agingData.push({ skuId: sku.skuId, agingInfo: suggestions });
|
||||
}
|
||||
@@ -281,7 +282,7 @@ export class ProductService {
|
||||
static async trackSupplyChain(tenantId: string, id: number) {
|
||||
const product = await this.getById(tenantId, id);
|
||||
if (!product) return null;
|
||||
return await SupplyChainService.traceSourceFactory(product.mainImage);
|
||||
return await SupplyChainService.traceSourceFactory(tenantId, id.toString(), product.mainImage);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,6 +391,33 @@ export class ProductService {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品
|
||||
*/
|
||||
static async createProduct(params: {
|
||||
tenantId: string;
|
||||
platform: string;
|
||||
title: string;
|
||||
description: string;
|
||||
price: number;
|
||||
images: string;
|
||||
status: string;
|
||||
}): Promise<string> {
|
||||
const { tenantId, platform, title, description, price, images, status } = params;
|
||||
|
||||
const productData: Partial<Product> = {
|
||||
platform,
|
||||
title,
|
||||
description,
|
||||
price,
|
||||
images: JSON.parse(images),
|
||||
status
|
||||
};
|
||||
|
||||
const id = await this.create(tenantId, productData);
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* [CORE_DEV_08] 集成向量化存储 & [CORE_DEV_11] CDC 拦截
|
||||
*/
|
||||
@@ -449,7 +477,7 @@ export class ProductService {
|
||||
});
|
||||
|
||||
// [BIZ_GOV_20] 发布业务事件到总线,触发自动审计
|
||||
DomainEventBus.getInstance().publish({
|
||||
DomainEventBus.getInstance().publish('STOCK_UPDATE', {
|
||||
tenantId,
|
||||
module: 'INVENTORY',
|
||||
action: 'STOCK_UPDATE',
|
||||
|
||||
Reference in New Issue
Block a user