fix(planting-service): PlantingOrderPaidEvent 添加 accountSequence 字段

Bug 3 修复: wallet-service 结算待领取奖励时需要 accountSequence

- PlantingOrderPaidEvent 事件 data 添加 accountSequence 字段
- markAsPaid(accountSequence) 方法接收并传递 accountSequence
- payOrder 调用 markAsPaid 时传入 accountSequence
- 更新相关单元测试

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-13 06:13:59 -08:00
parent 28864e6160
commit c93f43546e
4 changed files with 11 additions and 7 deletions

View File

@ -259,7 +259,8 @@ export class PlantingApplicationService {
try {
// 6. 标记已支付 (内存操作)
// 注意:资金分配已移至 reward-service
order.markAsPaid();
// accountSequence 用于 wallet-service 结算用户的待领取奖励
order.markAsPaid(accountSequence || '');
// 7. 使用事务保存本地数据库的所有变更 + Outbox事件
// 这确保了订单状态、用户持仓、批次数据、以及事件发布的原子性

View File

@ -90,7 +90,7 @@ describe('PlantingOrder', () => {
jest.advanceTimersByTime(5000);
order.confirmProvinceCity();
order.markAsPaid();
order.markAsPaid('D25121300001');
expect(order.status).toBe(PlantingOrderStatus.PAID);
expect(order.paidAt).not.toBeNull();
@ -101,7 +101,7 @@ describe('PlantingOrder', () => {
it('应该拒绝未确认省市的支付', () => {
const order = PlantingOrder.create(BigInt(1), 1);
expect(() => order.markAsPaid()).toThrow('订单状态错误');
expect(() => order.markAsPaid('D25121300001')).toThrow('订单状态错误');
});
});
@ -113,7 +113,7 @@ describe('PlantingOrder', () => {
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
jest.advanceTimersByTime(5000);
order.confirmProvinceCity();
order.markAsPaid();
order.markAsPaid('D25121300001');
const allocations = [
new FundAllocation(FundAllocationTargetType.COST_ACCOUNT, 400, 'ACC1'),
@ -175,7 +175,7 @@ describe('PlantingOrder', () => {
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
jest.advanceTimersByTime(5000);
order.confirmProvinceCity();
order.markAsPaid();
order.markAsPaid('D25121300001');
const allocations = [
new FundAllocation(FundAllocationTargetType.COST_ACCOUNT, 100, 'ACC1'),
@ -204,7 +204,7 @@ describe('PlantingOrder', () => {
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
jest.advanceTimersByTime(5000);
order.confirmProvinceCity();
order.markAsPaid();
order.markAsPaid('D25121300001');
expect(() => order.cancel()).toThrow('只有未支付的订单才能取消');

View File

@ -215,8 +215,9 @@ export class PlantingOrder {
/**
*
* @param accountSequence wallet-service
*/
markAsPaid(): void {
markAsPaid(accountSequence: string): void {
this.ensureStatus(PlantingOrderStatus.PROVINCE_CITY_CONFIRMED);
this._status = PlantingOrderStatus.PAID;
@ -226,6 +227,7 @@ export class PlantingOrder {
new PlantingOrderPaidEvent(this.orderNo, {
orderNo: this.orderNo,
userId: this.userId.toString(),
accountSequence,
treeCount: this.treeCount.value,
totalAmount: this.totalAmount,
provinceCode: this._provinceCitySelection!.provinceCode,

View File

@ -10,6 +10,7 @@ export class PlantingOrderPaidEvent implements DomainEvent {
public readonly data: {
orderNo: string;
userId: string;
accountSequence: string;
treeCount: number;
totalAmount: number;
provinceCode: string;