作者 陈志颖

fix:修复现金池为空时统计问题

... ... @@ -2,6 +2,7 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/statistics/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
... ... @@ -271,6 +272,27 @@ func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStati
employeeDao = value
}
// 判断现金池是否存在
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cashPoolRepository = value
}
countCashPools, _, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(systemCashStatisticsCommand))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if countCashPools == 0 { // 现金池为空时处理
return map[string]interface{} {
"systemExchangedCash" : 0,
"systemUnExchangeCash": 0,
}, nil
}
if systemCashStatistics, err := employeeDao.CalculateSystemCash(systemCashStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -87,7 +87,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
cashPoolRepository = value
}
countCashPools, _, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand));
countCashPools, _, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...