作者 陈志颖

fix:修改公司校验

@@ -37,15 +37,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -37,15 +37,6 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
37 transactionContext.RollbackTransaction() 37 transactionContext.RollbackTransaction()
38 }() 38 }()
39 39
40 - var cashPoolRepository domain.CashPoolRepository  
41 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} {  
42 - "transactionContext": transactionContext,  
43 - }); err != nil {  
44 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
45 - } else {  
46 - cashPoolRepository = value  
47 - }  
48 -  
49 var employeeRepository domain.EmployeeRepository 40 var employeeRepository domain.EmployeeRepository
50 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ 41 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
51 "transactionContext": transactionContext, 42 "transactionContext": transactionContext,
@@ -105,6 +96,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -105,6 +96,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
105 rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemExchangedSuMoney), 64) // 平均兑换汇率 96 rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", systemExchangedCash / systemExchangedSuMoney), 64) // 平均兑换汇率
106 } 97 }
107 98
  99 + var cashPoolRepository domain.CashPoolRepository
  100 + if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
  101 + "transactionContext": transactionContext,
  102 + }); err != nil {
  103 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  104 + } else {
  105 + cashPoolRepository = value
  106 + }
  107 +
108 // 新建现金池 108 // 新建现金池
109 newCashPool := &domain.CashPool{ 109 newCashPool := &domain.CashPool{
110 CompanyId: createCashPoolCommand.CompanyId, 110 CompanyId: createCashPoolCommand.CompanyId,
@@ -143,6 +143,26 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -143,6 +143,26 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
143 transactionContext.RollbackTransaction() 143 transactionContext.RollbackTransaction()
144 }() 144 }()
145 145
  146 + var employeeRepository domain.EmployeeRepository
  147 + if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
  148 + "transactionContext": transactionContext,
  149 + }); err != nil {
  150 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  151 + } else {
  152 + employeeRepository = value
  153 + }
  154 +
  155 + // 增加公司id判断
  156 + count, _, err := employeeRepository.Find(map[string]interface{}{
  157 + "companyId": getCashPoolQuery.CompanyId,
  158 + })
  159 + if err != nil {
  160 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  161 + }
  162 + if count == 0 {
  163 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司id")
  164 + }
  165 +
146 var employeeDao *dao.EmployeeDao 166 var employeeDao *dao.EmployeeDao
147 if value, err := factory.CreateEmployeeDao(map[string]interface{}{ 167 if value, err := factory.CreateEmployeeDao(map[string]interface{}{
148 "transactionContext": transactionContext, 168 "transactionContext": transactionContext,
@@ -323,7 +323,7 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -323,7 +323,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
323 cashPoolService := service.NewCashPoolService(nil) 323 cashPoolService := service.NewCashPoolService(nil)
324 createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} 324 createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
325 activityId, _ := controller.GetInt64("activityId") 325 activityId, _ := controller.GetInt64("activityId")
326 - operatorId, _ := controller.GetInt64("operatorId") 326 + operator, _ := controller.GetInt64("operator")
327 file, h, _ := controller.GetFile("file") //获取上传的文件 327 file, h, _ := controller.GetFile("file") //获取上传的文件
328 ext := path.Ext(h.Filename) 328 ext := path.Ext(h.Filename)
329 AllowExtMap := map[string]bool{ 329 AllowExtMap := map[string]bool{
@@ -355,7 +355,7 @@ func (controller *SuMoneyController) ImportExchangeList () { @@ -355,7 +355,7 @@ func (controller *SuMoneyController) ImportExchangeList () {
355 if createExchangeCashPersonCommand.PersonName == "" || createExchangeCashPersonCommand.PersonAccount == "" || createExchangeCashPersonCommand.ExchangedSuMoney == 0{ 355 if createExchangeCashPersonCommand.PersonName == "" || createExchangeCashPersonCommand.PersonAccount == "" || createExchangeCashPersonCommand.ExchangedSuMoney == 0{
356 356
357 } 357 }
358 - createExchangeCashPersonCommand.Operator = operatorId 358 + createExchangeCashPersonCommand.Operator = operator
359 createExchangeCashPersonCommand.PersonName = row[0] 359 createExchangeCashPersonCommand.PersonName = row[0]
360 createExchangeCashPersonCommand.PersonAccount = row[1] 360 createExchangeCashPersonCommand.PersonAccount = row[1]
361 createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[2], 64) 361 createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[2], 64)