hailin
53df97839d
fix(reporting-service): 修复 roleType 可能为 undefined 的类型错误
...
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 10:21:36 -08:00
hailin
347e5ce3de
fix(reporting-service): 修复授权事件区域名称显示 undefined
...
不同授权事件使用不同的字段名:
- province 事件:provinceCode/provinceName
- city 事件:cityCode/cityName
- community 事件:communityName
- 通用:regionCode/regionName
现在正确处理所有变体,避免显示 "undefined undefined 完成授权"
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 09:51:11 -08:00
hailin
68841abbf4
fix(reporting-service): 修复错误的 Kafka topic 订阅
...
- 充值事件:blockchain.deposit.credited → wallet.acks (过滤 wallet.deposit.credited)
- 权益事件:authorization.benefit.applied → 整合到 authorization-events (过滤 benefit.activated)
原来订阅的 topic 不存在,导致事件无法消费。现已修复为正确的 topic。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 06:01:08 -08:00
hailin
38fff077dd
feat(reporting-service): 新增多种活动事件类型
...
扩展仪表板"最近活动"功能,新增以下活动类型:
活动类型新增:
- kyc_submitted: KYC认证提交
- kyc_approved: KYC认证通过
- kyc_rejected: KYC认证拒绝
- contract_signed: 合同签署
- deposit: 充值到账
- withdrawal: 提现成功
- benefit_applied: 权益申请
监听的 Kafka Topics:
- identity.KYCSubmitted
- identity.KYCApproved
- identity.KYCRejected
- contract.signed
- blockchain.deposit.credited
- wallet.withdrawals (仅处理 completed 事件)
- authorization.benefit.applied
所有新增事件处理器均使用幂等创建,防止重复记录。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 05:51:26 -08:00
hailin
65bd6a857f
fix(reporting-service): 添加活动记录幂等性处理
...
问题:Kafka 消息重试或重复消费时,同一事件会被记录多次活动,
导致"最近活动"显示重复条目,统计数据也会被重复累加。
修复:
1. 仓储层新增 exists() 和 createIfNotExists() 方法
2. 所有事件消费者改用幂等创建,仅首次创建时累加统计
3. 添加数据库唯一约束 uk_sa_entity_activity 作为最后防线
4. 迁移脚本会自动清理历史重复数据
影响的事件:
- identity.UserAccountCreated
- identity.UserAccountAutoCreated
- authorization-events
- planting.order.paid
- reporting.report.generated
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 05:46:43 -08:00
hailin
84aa8181a9
fix(reporting-service): 兼容 referral-service 的认种事件格式
...
- planting.order.paid 事件现在由 referral-service 发送
- 消息格式为 { eventName, data: {...} },与原 planting-service 格式不同
- 添加兼容逻辑,同时支持两种格式
- 修复今日认种统计为0的问题
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 06:58:33 -08:00
hailin
66ace25935
fix(reporting): remove userId dependency in planting.order.paid handler
...
- Change userId to optional in PlantingOrderPaidEvent interface
- Add accountSequence field for user identification
- Remove relatedUserId from activity creation (was causing BigInt error)
- Store accountSequence in metadata instead
Fixes: TypeError: Cannot convert undefined to a BigInt
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-05 00:05:56 -08:00
hailin
49cdeb4aef
fix(reporting-service): fix planting.order.paid event message format
...
planting-service 发送的消息是直接数据格式,不包含 payload 包装,
修正 ActivityEventConsumerController 以适配实际消息格式。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 23:32:32 -08:00
hailin
e684068eae
feat(reporting): 实现事件驱动的仪表板统计架构
...
## 概述
将 reporting-service Dashboard 从 HTTP API 调用改为事件驱动架构,
通过消费 Kafka 事件在本地维护统计数据,实现微服务间解耦。
## 架构变更
之前: Dashboard → HTTP → planting/authorization/identity-service
现在: 各服务 → Kafka → reporting-service → 本地统计表 → Dashboard
## 新增表
- RealtimeStats: 每日实时统计 (认种数/订单数/新用户/授权数)
- GlobalStats: 全局累计统计 (总认种/总用户/总公司数)
## 新增仓储
- IRealtimeStatsRepository: 实时统计接口及实现
- IGlobalStatsRepository: 全局统计接口及实现
## Kafka 消费者更新
- identity.UserAccountCreated: 累加用户统计
- identity.UserAccountAutoCreated: 累加用户统计
- authorization-events: 累加省/市公司统计
- planting.order.paid: 累加认种统计
## Dashboard 服务更新
- getStats(): 从 GlobalStats/RealtimeStats 读取,计算环比变化
- getTrendData(): 从 RealtimeStats 获取趋势数据
## 优势
- 消除跨服务 HTTP 调用延迟
- 统计数据实时更新
- 微服务间完全解耦
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-18 00:25:31 -08:00