作者 陈志颖

feat:分红预算单增加删除

... ... @@ -78,6 +78,7 @@ type DividendsEstimateRepository interface {
SaveMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
UpdateMany(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error)
BatchRemove(dividendsEstimates []*DividendsEstimate) ([]*DividendsEstimate, error)
FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error)
Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error)
}
... ...
... ... @@ -93,7 +93,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId)
orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum] = append(orderGoodMaps[dividendsEstimatesRelative[i].OrderOrReturnedOrderNum], dividendsEstimatesRelative[i].OrderGoodId)
}
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative)
if err3 != nil {
return nil, err3
}
... ... @@ -119,7 +119,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
dividendsEstimatesRelative[i].IsCanceled = true
dividendsEstimatesRelative[i].Operator = operator
}
dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.BatchRemove(dividendsEstimatesRelative)
if err4 != nil {
return nil, err4
}
... ...
... ... @@ -293,6 +293,21 @@ func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.
return dividendsEstimate, nil
}
func (repository *DividendsEstimateRepository) BatchRemove(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) {
tx := repository.transactionContext.PgTx
var dividendsEstimateModels []*models.DividendsEstimate
for _, dividendsEstimate := range dividendsEstimates {
dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{
DividendsEstimateId: dividendsEstimate.Identify().(int64),
})
}
if _, err := tx.Model(&dividendsEstimateModels).WherePK().Delete(); err != nil {
return dividendsEstimates, err
} else {
return dividendsEstimates, nil
}
}
func (repository *DividendsEstimateRepository) FindOne(queryOptions map[string]interface{}) (*domain.DividendsEstimate, error) {
tx := repository.transactionContext.PgTx
dividendsEstimateModel := new(models.DividendsEstimate)
... ...