作者 陈志颖

fix:增加新建现金池时公司id的判断

... ... @@ -36,6 +36,23 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
defer func() {
transactionContext.RollbackTransaction()
}()
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
}
count, _, err := cashPoolRepository.Find(map[string]interface{}{
"companyId": createCashPoolCommand.CompanyId,
})
if count == 0 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
}
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 计算系统平均兑换汇率
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
... ... @@ -49,28 +66,14 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if systemSuMoneyStatistics == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
}
systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
systemCashStatistics, err := employeeDao.CalculateSystemCash(createCashPoolCommand.CompanyId)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if systemCashStatistics == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
}
systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64)
systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
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
}
// 计算系统平均兑换汇率
var rate float64
if systemExchangedSuMoney == 0 {
... ... @@ -422,7 +425,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
}
}
// 更新兑换现金活动,名称,截止日期、汇率
// TODO 更新兑换现金活动
func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) {
if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ...