作者 陈志颖

fix:未创建现金池报错信息修改

@@ -438,3 +438,43 @@ @@ -438,3 +438,43 @@
438 BodyData:{} 438 BodyData:{}
439 2020/11/22 21:41:06.515 [D] [server.go:2843] <====Send RequestId:GET./list-interval/?companyId=381&offset=0&limit=20.1606052466500650000 BodyData:{"code":0,"data":{"count":3,"listIntervals":[{"listIntervalId":21,"companyId":381,"intervalStartTime":"2020-12-18T00:00:00+08:00","intervalEndTime":"2020-12-20T23:59:59+08:00"},{"listIntervalId":20,"companyId":381,"intervalStartTime":"2020-11-17T12:01:54.851528+08:00","intervalEndTime":"2020-11-20T12:01:54.851528+08:00"},{"listIntervalId":7,"companyId":381,"intervalStartTime":"2020-11-10T12:01:54.851528+08:00","intervalEndTime":"2020-11-16T12:01:54.851528+08:00"}]},"msg":"ok"} 439 2020/11/22 21:41:06.515 [D] [server.go:2843] <====Send RequestId:GET./list-interval/?companyId=381&offset=0&limit=20.1606052466500650000 BodyData:{"code":0,"data":{"count":3,"listIntervals":[{"listIntervalId":21,"companyId":381,"intervalStartTime":"2020-12-18T00:00:00+08:00","intervalEndTime":"2020-12-20T23:59:59+08:00"},{"listIntervalId":20,"companyId":381,"intervalStartTime":"2020-11-17T12:01:54.851528+08:00","intervalEndTime":"2020-11-20T12:01:54.851528+08:00"},{"listIntervalId":7,"companyId":381,"intervalStartTime":"2020-11-10T12:01:54.851528+08:00","intervalEndTime":"2020-11-16T12:01:54.851528+08:00"}]},"msg":"ok"}
440 2020/11/22 21:41:06.515 [D] [server.go:1925] | 127.0.0.1| 200 | 15.218351ms| match| GET  /list-interval/ r:/list-interval/ 440 2020/11/22 21:41:06.515 [D] [server.go:1925] | 127.0.0.1| 200 | 15.218351ms| match| GET  /list-interval/ r:/list-interval/
  441 +2020/11/22 21:44:19.290 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity.1606052659290749000
  442 + Auth=
  443 + BodyData:{
  444 + "companyId": 311,
  445 + "exchangeActivityName": "这是公司311的兑换活动7",
  446 + "deadline": "2021-01-04T16:00:00.000Z",
  447 + "exchangeRate": 5
  448 +}
  449 +2020/11/22 21:44:19.364 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity.1606052659290749000 BodyData:{"code":0,"data":{"activityId":92,"exchangeActivityName":"这是公司311的兑换活动7","companyId":311,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2021-01-05T23:59:59+08:00","countDown":45,"rate":5,"createTime":"2020-11-22T21:44:19.36318+08:00"},"msg":"ok"}
  450 +2020/11/22 21:44:19.364 [D] [server.go:1925] | 127.0.0.1| 200 | 74.183207ms| match| POST  /cash-pool/activity r:/cash-pool/activity
  451 +2020/11/22 21:44:23.211 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity.1606052663211747000
  452 + Auth=
  453 + BodyData:{
  454 + "companyId": 311,
  455 + "exchangeActivityName": "这是公司311的兑换活动7",
  456 + "deadline": "2021-01-04T16:00:00.000Z",
  457 + "exchangeRate": 5
  458 +}
  459 +2020/11/22 21:44:23.236 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity.1606052663211747000 BodyData:{"code":501,"msg":"内部服务出错:兑换活动截止时间不能重合"}
  460 +2020/11/22 21:44:23.236 [D] [server.go:1925] | 127.0.0.1| 200 | 25.067107ms| match| POST  /cash-pool/activity r:/cash-pool/activity
  461 +2020/11/22 21:44:27.802 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity.1606052667802560000
  462 + Auth=
  463 + BodyData:{
  464 + "companyId": 311,
  465 + "exchangeActivityName": "这是公司311的兑换活动7",
  466 + "deadline": "2021-01-05T16:00:00.000Z",
  467 + "exchangeRate": 5
  468 +}
  469 +2020/11/22 21:44:27.840 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity.1606052667802560000 BodyData:{"code":0,"data":{"activityId":93,"exchangeActivityName":"这是公司311的兑换活动7","companyId":311,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2021-01-06T23:59:59+08:00","countDown":46,"rate":5,"createTime":"2020-11-22T21:44:27.822562+08:00"},"msg":"ok"}
  470 +2020/11/22 21:44:27.840 [D] [server.go:1925] | 127.0.0.1| 200 | 38.447584ms| match| POST  /cash-pool/activity r:/cash-pool/activity
  471 +2020/11/22 21:46:19.207 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity.1606052779207498000
  472 + Auth=
  473 + BodyData:{
  474 + "companyId": 311,
  475 + "exchangeActivityName": "这是公司311的兑换活动7",
  476 + "deadline": "2028-01-05T16:00:00.000Z",
  477 + "exchangeRate": 5
  478 +}
  479 +2020/11/22 21:46:19.214 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity.1606052779207498000 BodyData:{"code":0,"data":{"activityId":94,"exchangeActivityName":"这是公司311的兑换活动7","companyId":311,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2028-01-06T23:59:59+08:00","countDown":2602,"rate":5,"createTime":"2020-11-22T21:46:19.209323+08:00"},"msg":"ok"}
  480 +2020/11/22 21:46:19.214 [D] [server.go:1925] | 127.0.0.1| 200 | 7.123034ms| match| POST  /cash-pool/activity r:/cash-pool/activity
@@ -817,21 +817,21 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -817,21 +817,21 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
817 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId))) 817 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
818 } 818 }
819 819
  820 + // 获取当前公司现金池
  821 + _, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{
  822 + "companyId": activityFound.CompanyId,
  823 + })
  824 + if err != nil {
  825 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  826 + }
  827 + if len(cashPoolsFound) == 0 {
  828 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "当前公司未创建现金池")
  829 + }
  830 +
820 // 获取当前兑换活动汇率 831 // 获取当前兑换活动汇率
821 activityFoundRate := activityFound.Rate 832 activityFoundRate := activityFound.Rate
822 833
823 if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率 834 if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
824 - // 获取当前公司现金池  
825 - _, cashPoolsFound, err := cashPoolRepository.Find(map[string]interface{}{  
826 - "companyId": activityFound.CompanyId,  
827 - })  
828 - if err != nil {  
829 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
830 - }  
831 - if len(cashPoolsFound) == 0 {  
832 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(activityFound.CompanyId)))  
833 - }  
834 -  
835 // 判断兑换活动清单中现金总金额是否超过平台未兑换现金值 835 // 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
836 if activityFound.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash { 836 if activityFound.ExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolsFound[0].UnExchangeCash {
837 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 837 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
@@ -912,7 +912,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -912,7 +912,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
912 if cashPoolUpdated == nil { 912 if cashPoolUpdated == nil {
913 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 913 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
914 } 914 }
915 - } else { // 未更新兑换活动汇率 TODO 更新截止时间 915 + } else { // 未更新兑换活动汇率
916 updateExchangeCashActivityCommand.ExchangedCash = activityFound.ExchangedCash 916 updateExchangeCashActivityCommand.ExchangedCash = activityFound.ExchangedCash
917 } 917 }
918 918