作者 陈志颖

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

@@ -36,6 +36,23 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -36,6 +36,23 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
36 defer func() { 36 defer func() {
37 transactionContext.RollbackTransaction() 37 transactionContext.RollbackTransaction()
38 }() 38 }()
  39 + var cashPoolRepository domain.CashPoolRepository
  40 + if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
  41 + "transactionContext": transactionContext,
  42 + }); err != nil {
  43 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  44 + } else {
  45 + cashPoolRepository = value
  46 + }
  47 + count, _, err := cashPoolRepository.Find(map[string]interface{}{
  48 + "companyId": createCashPoolCommand.CompanyId,
  49 + })
  50 + if count == 0 {
  51 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
  52 + }
  53 + if err != nil {
  54 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  55 + }
39 // 计算系统平均兑换汇率 56 // 计算系统平均兑换汇率
40 var employeeDao *dao.EmployeeDao 57 var employeeDao *dao.EmployeeDao
41 if value, err := factory.CreateEmployeeDao(map[string]interface{}{ 58 if value, err := factory.CreateEmployeeDao(map[string]interface{}{
@@ -49,28 +66,14 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -49,28 +66,14 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
49 if err != nil { 66 if err != nil {
50 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 67 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
51 } 68 }
52 - if systemSuMoneyStatistics == nil {  
53 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")  
54 - }  
55 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) 69 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64)
56 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) 70 systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)
57 systemCashStatistics, err := employeeDao.CalculateSystemCash(createCashPoolCommand.CompanyId) 71 systemCashStatistics, err := employeeDao.CalculateSystemCash(createCashPoolCommand.CompanyId)
58 if err != nil { 72 if err != nil {
59 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 73 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
60 } 74 }
61 - if systemCashStatistics == nil {  
62 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")  
63 - }  
64 systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64) 75 systemExchangedCash := systemCashStatistics["systemExchangedCash"].(float64)
65 systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64) 76 systemUnExchangeCash := systemCashStatistics["systemUnExchangeCash"].(float64)
66 - var cashPoolRepository domain.CashPoolRepository  
67 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} {  
68 - "transactionContext": transactionContext,  
69 - }); err != nil {  
70 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
71 - } else {  
72 - cashPoolRepository = value  
73 - }  
74 // 计算系统平均兑换汇率 77 // 计算系统平均兑换汇率
75 var rate float64 78 var rate float64
76 if systemExchangedSuMoney == 0 { 79 if systemExchangedSuMoney == 0 {
@@ -422,7 +425,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA @@ -422,7 +425,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
422 } 425 }
423 } 426 }
424 427
425 -// 更新兑换现金活动,名称,截止日期、汇率 428 +// TODO 更新兑换现金活动
426 func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) { 429 func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) {
427 if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil { 430 if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil {
428 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 431 return nil, application.ThrowError(application.ARG_ERROR, err.Error())