作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !78
... ... @@ -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)
}
... ...
... ... @@ -104,7 +104,7 @@ func (dao *DividendsOrderDao) CountDividendsOrder(queryOptions map[string]interf
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("dividends_order.created_at >= ?", todayZeroTime)
query.Where("dividends_order.created_at < ?", nextDayZeroTime)
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
if count, err := query.AllWithDeleted().Count(); err != nil {
return 0, err
} else {
return count, nil
... ...
... ... @@ -91,7 +91,7 @@ func (dao *DividendsReturnedOrderDao) CountDividendsReturnedOrder(queryOptions m
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("dividends_returned_order.created_at >= ?", todayZeroTime)
query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime)
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
if count, err := query.AllWithDeleted().Count(); err != nil {
return 0, err
} else {
return count, nil
... ...
... ... @@ -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)
... ...