重构: 将卡/设备的套餐系列绑定从分配ID改为系列ID
- 数据库: 重命名 series_allocation_id → series_id - Model: IotCard 和 Device 字段重命名 - DTO: 所有请求/响应字段统一为 series_id - Store: 方法重命名,新增 GetByShopAndSeries 查询 - Service: 业务逻辑优化,系列验证和权限验证分离 - 测试: 更新所有测试用例,新增 shop_series_allocation_store_test.go - 文档: 更新 API 文档说明参数变更 BREAKING CHANGE: API 参数从 series_allocation_id 改为 series_id
This commit is contained in:
@@ -202,11 +202,11 @@ func (s *Service) triggerOneTimeCommissionForCardInTx(ctx context.Context, tx *g
|
||||
return errors.Wrap(errors.CodeDatabaseError, err, "获取卡信息失败")
|
||||
}
|
||||
|
||||
if card.SeriesAllocationID == nil {
|
||||
if card.SeriesID == nil || card.ShopID == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
allocation, err := s.shopSeriesAllocationStore.GetByID(ctx, *card.SeriesAllocationID)
|
||||
allocation, err := s.shopSeriesAllocationStore.GetByShopAndSeries(ctx, *card.ShopID, *card.SeriesID)
|
||||
if err != nil {
|
||||
return errors.Wrap(errors.CodeDatabaseError, err, "获取系列分配失败")
|
||||
}
|
||||
@@ -302,11 +302,11 @@ func (s *Service) triggerOneTimeCommissionForDeviceInTx(ctx context.Context, tx
|
||||
return errors.Wrap(errors.CodeDatabaseError, err, "获取设备信息失败")
|
||||
}
|
||||
|
||||
if device.SeriesAllocationID == nil {
|
||||
if device.SeriesID == nil || device.ShopID == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
allocation, err := s.shopSeriesAllocationStore.GetByID(ctx, *device.SeriesAllocationID)
|
||||
allocation, err := s.shopSeriesAllocationStore.GetByShopAndSeries(ctx, *device.ShopID, *device.SeriesID)
|
||||
if err != nil {
|
||||
return errors.Wrap(errors.CodeDatabaseError, err, "获取系列分配失败")
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestCalculateCommission_PurchaseOnBehalf(t *testing.T) {
|
||||
},
|
||||
ICCID: "89860000000000000001",
|
||||
ShopID: &shop.ID,
|
||||
SeriesAllocationID: &allocation.ID,
|
||||
SeriesID: &allocation.SeriesID,
|
||||
AccumulatedRecharge: 0,
|
||||
FirstCommissionPaid: false,
|
||||
}
|
||||
@@ -278,7 +278,7 @@ func TestCalculateCommission_Device_PurchaseOnBehalf(t *testing.T) {
|
||||
},
|
||||
DeviceNo: "DEV001",
|
||||
ShopID: &shop.ID,
|
||||
SeriesAllocationID: &allocation.ID,
|
||||
SeriesID: &allocation.SeriesID,
|
||||
AccumulatedRecharge: 0,
|
||||
FirstCommissionPaid: false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user