合并分支 'dev' 到 'test'
Dev 查看合并请求 !78
正在显示
5 个修改的文件
包含
20 行增加
和
4 行删除
| @@ -78,6 +78,7 @@ type DividendsEstimateRepository interface { | @@ -78,6 +78,7 @@ type DividendsEstimateRepository interface { | ||
| 78 | SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | 78 | SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) |
| 79 | UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | 79 | UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) |
| 80 | Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) | 80 | Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error) |
| 81 | + BatchRemove(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error) | ||
| 81 | FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error) | 82 | FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error) |
| 82 | Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error) | 83 | Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error) |
| 83 | } | 84 | } |
| @@ -104,7 +104,7 @@ func (dao *DividendsOrderDao) CountDividendsOrder(queryOptions map[string]interf | @@ -104,7 +104,7 @@ func (dao *DividendsOrderDao) CountDividendsOrder(queryOptions map[string]interf | ||
| 104 | nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) | 104 | nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) |
| 105 | query.Where("dividends_order.created_at >= ?", todayZeroTime) | 105 | query.Where("dividends_order.created_at >= ?", todayZeroTime) |
| 106 | query.Where("dividends_order.created_at < ?", nextDayZeroTime) | 106 | query.Where("dividends_order.created_at < ?", nextDayZeroTime) |
| 107 | - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { | 107 | + if count, err := query.AllWithDeleted().Count(); err != nil { |
| 108 | return 0, err | 108 | return 0, err |
| 109 | } else { | 109 | } else { |
| 110 | return count, nil | 110 | return count, nil |
| @@ -91,7 +91,7 @@ func (dao *DividendsReturnedOrderDao) CountDividendsReturnedOrder(queryOptions m | @@ -91,7 +91,7 @@ func (dao *DividendsReturnedOrderDao) CountDividendsReturnedOrder(queryOptions m | ||
| 91 | nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) | 91 | nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) |
| 92 | query.Where("dividends_returned_order.created_at >= ?", todayZeroTime) | 92 | query.Where("dividends_returned_order.created_at >= ?", todayZeroTime) |
| 93 | query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime) | 93 | query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime) |
| 94 | - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { | 94 | + if count, err := query.AllWithDeleted().Count(); err != nil { |
| 95 | return 0, err | 95 | return 0, err |
| 96 | } else { | 96 | } else { |
| 97 | return count, nil | 97 | return count, nil |
| @@ -93,7 +93,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -93,7 +93,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 93 | orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId) | 93 | orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId) |
| 94 | orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId) | 94 | orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId) |
| 95 | } | 95 | } |
| 96 | - dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) | 96 | + dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative) |
| 97 | if err3 != nil { | 97 | if err3 != nil { |
| 98 | return nil, err3 | 98 | return nil, err3 |
| 99 | } | 99 | } |
| @@ -119,7 +119,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -119,7 +119,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 119 | dividendsEstimatesRelative[i].IsCanceled = true | 119 | dividendsEstimatesRelative[i].IsCanceled = true |
| 120 | dividendsEstimatesRelative[i].Operator = operator | 120 | dividendsEstimatesRelative[i].Operator = operator |
| 121 | } | 121 | } |
| 122 | - dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) | 122 | + dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative) |
| 123 | if err4 != nil { | 123 | if err4 != nil { |
| 124 | return nil, err4 | 124 | return nil, err4 |
| 125 | } | 125 | } |
| @@ -293,6 +293,21 @@ func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain. | @@ -293,6 +293,21 @@ func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain. | ||
| 293 | return dividendsEstimate, nil | 293 | return dividendsEstimate, nil |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | +func (repository *DividendsEstimateRepository) BatchRemove(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) { | ||
| 297 | + tx := repository.transactionContext.PgTx | ||
| 298 | + var dividendsEstimateModels []*models.DividendsEstimate | ||
| 299 | + for _, dividendsEstimate := range dividendsEstimates { | ||
| 300 | + dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{ | ||
| 301 | + DividendsEstimateId: dividendsEstimate.Identify().(int64), | ||
| 302 | + }) | ||
| 303 | + } | ||
| 304 | + if _, err := tx.Model(÷ndsEstimateModels).WherePK().Delete(); err != nil { | ||
| 305 | + return dividendsEstimates, err | ||
| 306 | + } else { | ||
| 307 | + return dividendsEstimates, nil | ||
| 308 | + } | ||
| 309 | +} | ||
| 310 | + | ||
| 296 | func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsEstimate, error) { | 311 | func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsEstimate, error) { |
| 297 | tx := repository.transactionContext.PgTx | 312 | tx := repository.transactionContext.PgTx |
| 298 | dividendsEstimateModel := new(models.DividendsEstimate) | 313 | dividendsEstimateModel := new(models.DividendsEstimate) |
-
请 注册 或 登录 后发表评论