refactor: 重构项目结构并优化类型定义

- 移除extension模块,将功能迁移至node-agent
- 修复类型导出问题,使用export type明确类型导出
- 统一数据库连接方式,从直接导入改为使用config/database
- 更新文档中的项目结构描述
- 添加多个服务的实用方法,如getForecast、getBalances等
- 修复类型错误和TS1205警告
- 优化RedisService调用方式
- 添加新的实体类型定义
- 更新审计日志格式,统一字段命名
This commit is contained in:
2026-03-21 15:04:06 +08:00
parent 888d3844f3
commit 15ee1758f5
286 changed files with 9110 additions and 21453 deletions

View File

@@ -12,12 +12,16 @@ export class TaxIncentivesService {
*/
static async discoverIncentives(tenantId: string, countryCode: string, traceId: string): Promise<void> {
// 1. 获取该地区的最新税务政策 (模拟调用 AI 服务分析全球税法库)
const policies = await AIService.searchTaxPolicies(countryCode);
const result = await AIService.searchTaxPolicies({
countryCode: countryCode,
keywords: ['tax incentive', 'e-commerce'],
category: 'general'
});
for (const policy of policies) {
for (const policy of result.policies) {
// 检查是否已记录
const existing = await db('cf_tax_incentives')
.where({ tenant_id: tenantId, country_code: countryCode, policy_name: policy.name })
.where({ tenant_id: tenantId, country_code: countryCode, policy_name: policy.title })
.first();
if (!existing) {
@@ -25,21 +29,25 @@ export class TaxIncentivesService {
const [id] = await trx('cf_tax_incentives').insert({
tenant_id: tenantId,
country_code: countryCode,
policy_name: policy.name,
description: policy.description,
estimated_savings: policy.estimatedSavings,
policy_name: policy.title,
description: policy.summary,
estimated_savings: policy.relevance * 1000,
status: 'DISCOVERED'
});
// 审计记录
await AuditService.log({
tenant_id: tenantId,
tenantId: tenantId,
action: 'TAX_INCENTIVE_DISCOVERED',
target_type: 'TAX_INCENTIVE',
target_id: id.toString(),
trace_id: traceId,
new_data: JSON.stringify({ policyName: policy.name, estimatedSavings: policy.estimatedSavings }),
metadata: JSON.stringify({ countryCode })
resourceType: 'TAX_INCENTIVE',
resourceId: id.toString(),
traceId: traceId,
userId: 'SYSTEM',
module: 'TAX_INCENTIVE',
source: 'node',
result: 'success',
afterSnapshot: { policyName: policy.title, relevance: policy.relevance },
metadata: { countryCode }
});
});
}