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:
parent
28864e6160
commit
c93f43546e
|
|
@ -259,7 +259,8 @@ export class PlantingApplicationService {
|
||||||
try {
|
try {
|
||||||
// 6. 标记已支付 (内存操作)
|
// 6. 标记已支付 (内存操作)
|
||||||
// 注意:资金分配已移至 reward-service
|
// 注意:资金分配已移至 reward-service
|
||||||
order.markAsPaid();
|
// accountSequence 用于 wallet-service 结算用户的待领取奖励
|
||||||
|
order.markAsPaid(accountSequence || '');
|
||||||
|
|
||||||
// 7. 使用事务保存本地数据库的所有变更 + Outbox事件
|
// 7. 使用事务保存本地数据库的所有变更 + Outbox事件
|
||||||
// 这确保了订单状态、用户持仓、批次数据、以及事件发布的原子性
|
// 这确保了订单状态、用户持仓、批次数据、以及事件发布的原子性
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ describe('PlantingOrder', () => {
|
||||||
jest.advanceTimersByTime(5000);
|
jest.advanceTimersByTime(5000);
|
||||||
order.confirmProvinceCity();
|
order.confirmProvinceCity();
|
||||||
|
|
||||||
order.markAsPaid();
|
order.markAsPaid('D25121300001');
|
||||||
|
|
||||||
expect(order.status).toBe(PlantingOrderStatus.PAID);
|
expect(order.status).toBe(PlantingOrderStatus.PAID);
|
||||||
expect(order.paidAt).not.toBeNull();
|
expect(order.paidAt).not.toBeNull();
|
||||||
|
|
@ -101,7 +101,7 @@ describe('PlantingOrder', () => {
|
||||||
it('应该拒绝未确认省市的支付', () => {
|
it('应该拒绝未确认省市的支付', () => {
|
||||||
const order = PlantingOrder.create(BigInt(1), 1);
|
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', '广州市');
|
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
|
||||||
jest.advanceTimersByTime(5000);
|
jest.advanceTimersByTime(5000);
|
||||||
order.confirmProvinceCity();
|
order.confirmProvinceCity();
|
||||||
order.markAsPaid();
|
order.markAsPaid('D25121300001');
|
||||||
|
|
||||||
const allocations = [
|
const allocations = [
|
||||||
new FundAllocation(FundAllocationTargetType.COST_ACCOUNT, 400, 'ACC1'),
|
new FundAllocation(FundAllocationTargetType.COST_ACCOUNT, 400, 'ACC1'),
|
||||||
|
|
@ -175,7 +175,7 @@ describe('PlantingOrder', () => {
|
||||||
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
|
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
|
||||||
jest.advanceTimersByTime(5000);
|
jest.advanceTimersByTime(5000);
|
||||||
order.confirmProvinceCity();
|
order.confirmProvinceCity();
|
||||||
order.markAsPaid();
|
order.markAsPaid('D25121300001');
|
||||||
|
|
||||||
const allocations = [
|
const allocations = [
|
||||||
new FundAllocation(FundAllocationTargetType.COST_ACCOUNT, 100, 'ACC1'),
|
new FundAllocation(FundAllocationTargetType.COST_ACCOUNT, 100, 'ACC1'),
|
||||||
|
|
@ -204,7 +204,7 @@ describe('PlantingOrder', () => {
|
||||||
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
|
order.selectProvinceCity('440000', '广东省', '440100', '广州市');
|
||||||
jest.advanceTimersByTime(5000);
|
jest.advanceTimersByTime(5000);
|
||||||
order.confirmProvinceCity();
|
order.confirmProvinceCity();
|
||||||
order.markAsPaid();
|
order.markAsPaid('D25121300001');
|
||||||
|
|
||||||
expect(() => order.cancel()).toThrow('只有未支付的订单才能取消');
|
expect(() => order.cancel()).toThrow('只有未支付的订单才能取消');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,8 +215,9 @@ export class PlantingOrder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标记为已支付
|
* 标记为已支付
|
||||||
|
* @param accountSequence 用户账户序列号,用于 wallet-service 结算待领取奖励
|
||||||
*/
|
*/
|
||||||
markAsPaid(): void {
|
markAsPaid(accountSequence: string): void {
|
||||||
this.ensureStatus(PlantingOrderStatus.PROVINCE_CITY_CONFIRMED);
|
this.ensureStatus(PlantingOrderStatus.PROVINCE_CITY_CONFIRMED);
|
||||||
|
|
||||||
this._status = PlantingOrderStatus.PAID;
|
this._status = PlantingOrderStatus.PAID;
|
||||||
|
|
@ -226,6 +227,7 @@ export class PlantingOrder {
|
||||||
new PlantingOrderPaidEvent(this.orderNo, {
|
new PlantingOrderPaidEvent(this.orderNo, {
|
||||||
orderNo: this.orderNo,
|
orderNo: this.orderNo,
|
||||||
userId: this.userId.toString(),
|
userId: this.userId.toString(),
|
||||||
|
accountSequence,
|
||||||
treeCount: this.treeCount.value,
|
treeCount: this.treeCount.value,
|
||||||
totalAmount: this.totalAmount,
|
totalAmount: this.totalAmount,
|
||||||
provinceCode: this._provinceCitySelection!.provinceCode,
|
provinceCode: this._provinceCitySelection!.provinceCode,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ export class PlantingOrderPaidEvent implements DomainEvent {
|
||||||
public readonly data: {
|
public readonly data: {
|
||||||
orderNo: string;
|
orderNo: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
|
accountSequence: string;
|
||||||
treeCount: number;
|
treeCount: number;
|
||||||
totalAmount: number;
|
totalAmount: number;
|
||||||
provinceCode: string;
|
provinceCode: string;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue