作者 陈志颖

test:兑换活动截止时间

... ... @@ -478,3 +478,73 @@
}
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"}
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
2020/11/22 22:01:13.392 [I] [???:0] http server Running on http://:8082
2020/11/22 22:01:24.461 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=311.1606053684461108000
Auth=
BodyData:{}
2020/11/22 22:01:24.667 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=311.1606053684461108000 BodyData:{"code":0,"data":{"cashPoolId":14,"cash":2000,"companyId":311,"exchangedCash":1007,"unExchangeCash":993,"exchangedSuMoney":196,"unExchangeSuMoney":1079,"rate":5.14,"lastRate":5,"createTime":"2020-11-18T01:46:49.196257+08:00"},"msg":"ok"}
2020/11/22 22:01:24.667 [D] [server.go:1925] | 127.0.0.1| 200 | 206.362552ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
2020/11/22 22:01:26.749 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/cash-pool?companyId=311.1606053686749200000
Auth=
BodyData:{}
2020/11/22 22:01:26.776 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/cash-pool?companyId=311.1606053686749200000 BodyData:{"code":0,"data":{"cashPoolId":14,"cash":2000,"companyId":311,"exchangedCash":1007,"unExchangeCash":993,"exchangedSuMoney":196,"unExchangeSuMoney":1079,"rate":5.14,"lastRate":5,"createTime":"2020-11-18T01:46:49.196257+08:00"},"msg":"ok"}
2020/11/22 22:01:26.776 [D] [server.go:1925] | 127.0.0.1| 200 | 27.660727ms| match| GET  /cash-pool/cash-pool r:/cash-pool/cash-pool
2020/11/22 22:01:33.761 [D] [server.go:2843] ====>Recv User:<nil> RequestId:GET./cash-pool/activity/?companyId=311&offset=0&limit=20&isEnd=true.1606053693761505000
Auth=
BodyData:{}
2020/11/22 22:01:33.791 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/activity/?companyId=311&offset=0&limit=20&isEnd=true.1606053693761505000 BodyData:{"code":0,"data":{"activities":[{"activityId":79,"companyId":311,"countDown":1,"createTime":"2020-11-21T01:17:38.434336+08:00","deadline":1606060800000,"exchangeActivityName":"这是公司311的兑换活动7","exchangedCash":0,"exchangedSuMoney":0,"rate":5},{"activityId":77,"companyId":311,"countDown":1,"createTime":"2020-11-21T01:10:52.822645+08:00","deadline":1606060800000,"exchangeActivityName":"这是公司311的兑换活动7","exchangedCash":0,"exchangedSuMoney":0,"rate":5},{"activityId":78,"companyId":311,"countDown":1,"createTime":"2020-11-21T01:17:36.794075+08:00","deadline":1606060800000,"exchangeActivityName":"这是公司311的兑换活动7","exchangedCash":0,"exchangedSuMoney":0,"rate":5},{"activityId":81,"companyId":311,"countDown":2,"createTime":"2020-11-21T02:28:44.157965+08:00","deadline":1606147200000,"exchangeActivityName":"这是公司311的兑换活动7","exchangedCash":65,"exchangedSuMoney":13,"rate":5},{"activityId":83,"companyId":311,"countDown":6,"createTime":"2
2020/11/22 22:01:33.791 [D] [server.go:1925] | 127.0.0.1| 200 | 29.957451ms| match| GET  /cash-pool/activity/ r:/cash-pool/activity/
2020/11/22 22:02:18.823 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/93.1606053738823832000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司10019的兑换活动,哈哈哈",
"deadline": "2020-12-08T16:00:00.000Z",
"exchangeRate": 10
}
2020/11/22 22:02:18.879 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/93.1606053738823832000 BodyData:{"code":501,"msg":"内部服务出错:兑换活动截止时间不能重合"}
2020/11/22 22:02:18.879 [D] [server.go:1925] | 127.0.0.1| 200 | 55.769551ms| match| PUT  /cash-pool/activity/93 r:/cash-pool/activity/:activityId
2020/11/22 22:02:59.210 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/93.1606053779210695000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司10019的兑换活动,哈哈哈",
"deadline": "2020-11-22T21:44:27.822562+08:00",
"exchangeRate": 10
}
2020/11/22 22:02:59.232 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/93.1606053779210695000 BodyData:{"code":501,"msg":"内部服务出错:兑换活动截止时间不能重合"}
2020/11/22 22:02:59.232 [D] [server.go:1925] | 127.0.0.1| 200 | 21.503813ms| match| PUT  /cash-pool/activity/93 r:/cash-pool/activity/:activityId
2020/11/22 22:03:05.041 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/93.1606053785041403000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司10019的兑换活动,哈哈哈",
"deadline": "2020-11-23T21:44:27.822562+08:00",
"exchangeRate": 10
}
2020/11/22 22:03:05.059 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/93.1606053785041403000 BodyData:{"code":501,"msg":"内部服务出错:兑换活动截止时间不能重合"}
2020/11/22 22:03:05.059 [D] [server.go:1925] | 127.0.0.1| 200 | 17.980245ms| match| PUT  /cash-pool/activity/93 r:/cash-pool/activity/:activityId
2020/11/22 22:03:12.780 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/93.1606053792780230000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司10019的兑换活动,哈哈哈",
"deadline": "2020-11-26T21:44:27.822562+08:00",
"exchangeRate": 10
}
2020/11/22 22:03:12.791 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/93.1606053792780230000 BodyData:{"code":501,"msg":"内部服务出错:兑换活动截止时间不能重合"}
2020/11/22 22:03:12.796 [D] [server.go:1925] | 127.0.0.1| 200 | 16.047125ms| match| PUT  /cash-pool/activity/93 r:/cash-pool/activity/:activityId
2020/11/22 22:03:24.273 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/93.1606053804273394000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司10019的兑换活动,哈哈哈",
"deadline": "2020-12-26T21:44:27.822562+08:00",
"exchangeRate": 10
}
2020/11/22 22:03:24.283 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/93.1606053804273394000 BodyData:{"code":501,"msg":"内部服务出错:兑换活动截止时间不能重合"}
2020/11/22 22:03:24.283 [D] [server.go:1925] | 127.0.0.1| 200 | 9.873065ms| match| PUT  /cash-pool/activity/93 r:/cash-pool/activity/:activityId
2020/11/22 22:03:35.155 [D] [server.go:2843] ====>Recv User:<nil> RequestId:PUT./cash-pool/activity/93.1606053815155869000
Auth=
BodyData:{
"exchangeActivityName": "这是更新后的公司10019的兑换活动,哈哈哈",
"deadline": "2021-12-26T21:44:27.822562+08:00",
"exchangeRate": 10
}
2020/11/22 22:03:35.205 [D] [server.go:2843] <====Send RequestId:PUT./cash-pool/activity/93.1606053815155869000 BodyData:{"code":501,"msg":"内部服务出错:兑换活动截止时间不能重合"}
2020/11/22 22:03:35.205 [D] [server.go:1925] | 127.0.0.1| 200 | 49.68737ms| match| PUT  /cash-pool/activity/93 r:/cash-pool/activity/:activityId
... ...
... ... @@ -68,6 +68,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
cashPoolRepository = value
}
// 兑换现金活动仓储初始化
var exchangeActivityRepository domain.ExchangeActivityRepository
if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
exchangeActivityRepository = value
}
//公司id判断
count, _, err := employeeRepository.Find(map[string]interface{}{
"companyId": createCashPoolCommand.CompanyId,
... ... @@ -126,6 +136,21 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
// 重新计算平均兑换汇率
newRate := cashPools[0].ExchangedCash / systemExchangedSuMoney
// 获取上次兑换活动兑换汇率查询
var lastActivityRate float64
listExchangeCashActivityQuery := map[string]interface{}{
"companyId": createCashPoolCommand.CompanyId,
}
if count, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 1 {
lastActivityRate = activities[1].Rate
} else { // 未查询到相关兑换活动
lastActivityRate = 0
}
}
// 更新现金池
newCashPool := &domain.CashPool{
CashPoolId: cashPools[0].CashPoolId,
... ... @@ -136,7 +161,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
ExchangedSuMoney: systemExchangedSuMoney,
UnExchangeSuMoney: systemUnExchangeSuMoney,
Rate: newRate,
LastRate: cashPools[0].LastRate,
LastRate: lastActivityRate,
CreateTime: time.Now().Local(),
}
// 保存现金池更新
... ... @@ -337,7 +362,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, activity := range activities {
if t2.Format("2006-01-02") <= activity.Deadline.Local().Format("2006-01-02") {
if t2.Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") {
//if t2.Before(activity.Deadline.Local()) || t2.Equal(activity.Deadline.Local()) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
}
... ... @@ -936,7 +961,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, activity := range activities {
if updateExchangeCashActivityCommand.Deadline.Local().Format("2006-01-02") < activity.Deadline.Local().Format("2006-01-02") {
if updateExchangeCashActivityCommand.Deadline.Local().Format("2006-01-02") == activity.Deadline.Local().Format("2006-01-02") {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "兑换活动截止时间不能重合")
}
}
... ...
... ... @@ -342,6 +342,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
if err := searchTaskCommand.ValidateCommand(); err != nil { // 校验搜索命令
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil) // 工厂类创建事务上下文
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -352,6 +353,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
defer func() {
transactionContext.RollbackTransaction()
}()
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -360,6 +362,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
taskRepository = value
}
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -368,6 +371,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
... ... @@ -378,6 +382,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -386,6 +391,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
... ... @@ -396,6 +402,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -404,6 +411,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
... ... @@ -414,6 +422,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...