作者 陈志颖

test:上期汇率

@@ -131,3 +131,57 @@ @@ -131,3 +131,57 @@
131 BodyData:{} 131 BodyData:{}
132 2020/11/23 11:06:28.378 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606100788340467000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":0,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"} 132 2020/11/23 11:06:28.378 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606100788340467000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":0,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
133 2020/11/23 11:06:28.378 [D] [server.go:1925] | 127.0.0.1| 200 | 38.134513ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool 133 2020/11/23 11:06:28.378 [D] [server.go:1925] | 127.0.0.1| 200 | 38.134513ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
  134 +2020/11/23 11:07:52.593 [I] [???:0] http server Running on http://:8082
  135 +2020/11/23 11:07:57.777 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=358.1606100877777207000
  136 + Auth=
  137 + BodyData:{}
  138 +2020/11/23 11:07:57.922 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606100877777207000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":0,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
  139 +2020/11/23 11:07:57.922 [D] [server.go:1925] | 127.0.0.1| 200 | 145.563659ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
  140 +2020/11/23 11:08:23.230 [D] [server.go:2843] ====>Recv User:<nil> RequestId:POST./cash-pool/activity.1606100903230741000
  141 + Auth=
  142 + BodyData:{
  143 + "companyId": 358,
  144 + "exchangeActivityName": "这是公司311的兑换活动7",
  145 + "deadline": "2021-01-05T16:00:00.000Z",
  146 + "exchangeRate": 5.1
  147 +}
  148 +2020/11/23 11:08:23.355 [D] [server.go:2843] <====Send RequestId:POST./cash-pool/activity.1606100903230741000 BodyData:{"code":0,"data":{"activityId":95,"exchangeActivityName":"这是公司311的兑换活动7","companyId":358,"exchangedCash":0,"exchangedSuMoney":0,"deadline":"2021-01-06T23:59:59+08:00","countDown":45,"rate":5.1,"createTime":"2020-11-23T11:08:23.237467+08:00"},"msg":"ok"}
  149 +2020/11/23 11:08:23.355 [D] [server.go:1925] | 127.0.0.1| 200 | 124.391819ms| match| POST  /cash-pool/activity r:/cash-pool/activity
  150 +2020/11/23 11:08:33.758 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/activity/?companyId=358&offset=0&limit=20&isEnd=false.1606100913758174000
  151 + Auth=
  152 + BodyData:{}
  153 +2020/11/23 11:08:33.863 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/activity/?companyId=358&offset=0&limit=20&isEnd=false.1606100913758174000 BodyData:{"code":0,"data":{"activities":[{"activityId":41,"companyId":358,"countDown":7,"createTime":"2020-11-17T13:21:41.997891+08:00","deadline":1606665599001,"exchangeActivityName":"12","exchangedCash":0,"exchangedSuMoney":0,"rate":3},{"activityId":95,"companyId":358,"countDown":45,"createTime":"2020-11-23T11:08:23.237467+08:00","deadline":1609948799000,"exchangeActivityName":"这是公司311的兑换活动7","exchangedCash":0,"exchangedSuMoney":0,"rate":5.1}],"count":2},"msg":"ok"}
  154 +2020/11/23 11:08:33.863 [D] [server.go:1925] | 127.0.0.1| 200 | 105.253309ms| match| GET  /cash-pool/activity/ r:/cash-pool/activity/
  155 +2020/11/23 11:08:50.399 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=358.1606100930399371000
  156 + Auth=
  157 + BodyData:{}
  158 +2020/11/23 11:08:50.433 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606100930399371000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":3,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
  159 +2020/11/23 11:08:50.434 [D] [server.go:1925] | 127.0.0.1| 200 | 35.068243ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
  160 +2020/11/23 11:38:17.877 [I] [???:0] http server Running on http://:8082
  161 +2020/11/23 11:38:26.022 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=358.1606102706022033000
  162 + Auth=
  163 + BodyData:{}
  164 +2020/11/23 11:38:27.133 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606102706022033000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":3,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
  165 +2020/11/23 11:38:27.134 [D] [server.go:1925] | 127.0.0.1| 200 | 1.112025373s| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
  166 +2020/11/23 11:38:30.677 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=358.1606102710677272000
  167 + Auth=
  168 + BodyData:{}
  169 +2020/11/23 11:38:30.760 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606102710677272000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":3,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
  170 +2020/11/23 11:38:30.760 [D] [server.go:1925] | 127.0.0.1| 200 | 83.453461ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
  171 +2020/11/23 11:41:07.866 [I] [???:0] http server Running on http://:8082
  172 +2020/11/23 11:41:14.678 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=358.1606102874678381000
  173 + Auth=
  174 + BodyData:{}
  175 +2020/11/23 11:41:14.858 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606102874678381000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":3,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
  176 +2020/11/23 11:41:14.858 [D] [server.go:1925] | 127.0.0.1| 200 | 180.639118ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
  177 +2020/11/23 11:43:00.648 [I] [???:0] http server Running on http://:8082
  178 +2020/11/23 11:43:09.903 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=358.1606102989903536000
  179 + Auth=
  180 + BodyData:{}
  181 +2020/11/23 11:43:10.158 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606102989903536000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":0,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
  182 +2020/11/23 11:43:10.158 [D] [server.go:1925] | 127.0.0.1| 200 | 255.02557ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
  183 +2020/11/23 11:43:13.946 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=358.1606102993946891000
  184 + Auth=
  185 + BodyData:{}
  186 +2020/11/23 11:43:14.139 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=358.1606102993946891000 BodyData:{"code":0,"data":{"cashPoolId":10,"cash":2001,"companyId":358,"exchangedCash":4,"unExchangeCash":1997,"exchangedSuMoney":3,"unExchangeSuMoney":3498567.67,"rate":1.33,"lastRate":0,"createTime":"2020-11-17T11:02:21.013016+08:00"},"msg":"ok"}
  187 +2020/11/23 11:43:14.139 [D] [server.go:1925] | 127.0.0.1| 200 | 192.55553ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
@@ -141,7 +141,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -141,7 +141,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
141 listExchangeCashActivityQuery := map[string]interface{}{ 141 listExchangeCashActivityQuery := map[string]interface{}{
142 "companyId": createCashPoolCommand.CompanyId, 142 "companyId": createCashPoolCommand.CompanyId,
143 "order": "deadline DESC", 143 "order": "deadline DESC",
144 - "offset": 1, 144 + "nearest": true,
145 "limit": 1, 145 "limit": 1,
146 } 146 }
147 if count, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 147 if count, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
@@ -257,7 +257,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -257,7 +257,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
257 listExchangeCashActivityQuery := map[string]interface{}{ 257 listExchangeCashActivityQuery := map[string]interface{}{
258 "companyId": getCashPoolQuery.CompanyId, 258 "companyId": getCashPoolQuery.CompanyId,
259 "order": "deadline DESC", 259 "order": "deadline DESC",
260 - "offset": 1, 260 + "nearest": true,
261 "limit": 1, 261 "limit": 1,
262 } 262 }
263 if count, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 263 if count, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
@@ -98,6 +98,12 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i @@ -98,6 +98,12 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i
98 query = query.Where(`exchange_cash_activity.count_down > ?`, 0) 98 query = query.Where(`exchange_cash_activity.count_down > ?`, 0)
99 } 99 }
100 } 100 }
  101 + if nearest, ok := queryOptions["nearest"]; ok && nearest.(bool) != false {
  102 + t := time.Now().Local()
  103 + //endTime := time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, 0, time.Local)
  104 + query = query.Where(`exchange_cash_activity.deadline <= ?`, t)
  105 + query = query.Where(`exchange_cash_activity.count_down = ?`, 0)
  106 + }
101 if deadline, ok := queryOptions["deadline"]; ok && deadline != "" { 107 if deadline, ok := queryOptions["deadline"]; ok && deadline != "" {
102 t, _ := time.ParseInLocation("2006-01-02", deadline.(string), time.Local) 108 t, _ := time.ParseInLocation("2006-01-02", deadline.(string), time.Local)
103 newDeadlineStart := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local) 109 newDeadlineStart := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.Local)