作者 陈志颖

test:测试已过期任务编辑

@@ -651,3 +651,4 @@ @@ -651,3 +651,4 @@
651 2020/11/23 17:18:21.768 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/activity/?companyId=358&offset=0&limit=20&isEnd=true.1606123101682637000 BodyData:{"code":0,"data":{"activities":[],"count":0},"msg":"ok"} 651 2020/11/23 17:18:21.768 [D] [server.go:2843] <====Send RequestId:GET./cash-pool/activity/?companyId=358&offset=0&limit=20&isEnd=true.1606123101682637000 BodyData:{"code":0,"data":{"activities":[],"count":0},"msg":"ok"}
652 2020/11/23 17:18:21.768 [D] [server.go:1925] | 127.0.0.1| 200 | 86.366848ms| match| GET  /cash-pool/activity/ r:/cash-pool/activity/ 652 2020/11/23 17:18:21.768 [D] [server.go:1925] | 127.0.0.1| 200 | 86.366848ms| match| GET  /cash-pool/activity/ r:/cash-pool/activity/
653 2020/11/23 17:40:41.529 [I] [???:0] http server Running on http://:8082 653 2020/11/23 17:40:41.529 [I] [???:0] http server Running on http://:8082
  654 +2020/11/23 17:43:38.430 [I] [???:0] http server Running on http://:8082
@@ -630,7 +630,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -630,7 +630,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
630 //currentTime := time.Now().Local() 630 //currentTime := time.Now().Local()
631 //endTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location()) 631 //endTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location())
632 for _, activity := range activities { 632 for _, activity := range activities {
633 - //if activity.Deadline.UnixNano() / 1e6 >= currentTime.UnixNano() / 1e6 {  
634 cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64) 633 cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
635 suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64) 634 suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
636 activityWithTs := map[string]interface{} { 635 activityWithTs := map[string]interface{} {
@@ -645,7 +644,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -645,7 +644,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
645 "createTime": activity.CreateTime.Local(), 644 "createTime": activity.CreateTime.Local(),
646 } 645 }
647 activitiesWithTs = append(activitiesWithTs, activityWithTs) 646 activitiesWithTs = append(activitiesWithTs, activityWithTs)
648 - //}  
649 } 647 }
650 648
651 if len(activitiesWithTs) == 0 { 649 if len(activitiesWithTs) == 0 {
@@ -235,6 +235,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT @@ -235,6 +235,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
235 if err := releaseTaskCommand.ValidateCommand(); err != nil { 235 if err := releaseTaskCommand.ValidateCommand(); err != nil {
236 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 236 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
237 } 237 }
  238 +
238 transactionContext, err := factory.CreateTransactionContext(nil) 239 transactionContext, err := factory.CreateTransactionContext(nil)
239 if err != nil { 240 if err != nil {
240 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 241 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -245,6 +246,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT @@ -245,6 +246,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
245 defer func() { 246 defer func() {
246 transactionContext.RollbackTransaction() 247 transactionContext.RollbackTransaction()
247 }() 248 }()
  249 +
248 var releaseTaskService service.ReleaseTaskService 250 var releaseTaskService service.ReleaseTaskService
249 if value, err := factory.CreateReleaseTaskService(map[string]interface{}{ 251 if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
250 "transactionContext": transactionContext, 252 "transactionContext": transactionContext,
@@ -257,6 +259,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT @@ -257,6 +259,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
257 TransactionContext: transactionContext.(*pgTransaction.TransactionContext), 259 TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
258 }) 260 })
259 } 261 }
  262 +
260 if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil { 263 if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil {
261 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 264 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
262 } else { 265 } else {
@@ -1084,6 +1087,20 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1084,6 +1087,20 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1084 taskDao = value 1087 taskDao = value
1085 } 1088 }
1086 1089
  1090 + var releaseTaskService service.ReleaseTaskService
  1091 + if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
  1092 + "transactionContext": transactionContext,
  1093 + }); err != nil {
  1094 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1095 + } else {
  1096 + releaseTaskService = value
  1097 + releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
  1098 + releaseTaskService.Subscribe(&subscriber.MmmOpenApiServiceServiceSubscriber{
  1099 + TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
  1100 + })
  1101 + }
  1102 +
  1103 + // 找到当前任务
1087 task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId}) 1104 task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId})
1088 if err != nil { 1105 if err != nil {
1089 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1106 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1143,6 +1160,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1143,6 +1160,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1143 updateData["assignedPerson"] = &domain.EmployeeInfo{} 1160 updateData["assignedPerson"] = &domain.EmployeeInfo{}
1144 } 1161 }
1145 } 1162 }
  1163 +
1146 // TODO 任务返回错误类型 1164 // TODO 任务返回错误类型
1147 if err := task.Update(updateData); err != nil { 1165 if err := task.Update(updateData); err != nil {
1148 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 1166 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -1155,6 +1173,13 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1155,6 +1173,13 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1155 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1173 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1156 } 1174 }
1157 } 1175 }
  1176 +
  1177 + if task.TaskType == domain.TASK_STATUS_EXPIRED {
  1178 + if _, err := releaseTaskService.Release(task.TaskId, task.Sponsor.Uid); err != nil {
  1179 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1180 + }
  1181 + }
  1182 +
1158 if err := transactionContext.CommitTransaction(); err != nil { 1183 if err := transactionContext.CommitTransaction(); err != nil {
1159 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1184 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1160 } 1185 }
@@ -673,6 +673,9 @@ func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) erro @@ -673,6 +673,9 @@ func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) erro
673 } 673 }
674 if bidEndTime, ok := data["bidEndTime"]; ok { 674 if bidEndTime, ok := data["bidEndTime"]; ok {
675 task.BidInfo.BidEndTime = bidEndTime.(time.Time) 675 task.BidInfo.BidEndTime = bidEndTime.(time.Time)
  676 + //task.ReceiveTime = time.Now()
  677 + //task.TaskStatus = TASK_STATUS_UNDERWAY
  678 + //task.CurrentStatus = &UnderwayStatus{}
676 } 679 }
677 if isRemind, ok := data["isRemind"]; ok { 680 if isRemind, ok := data["isRemind"]; ok {
678 task.BidInfo.IsRemind = isRemind.(bool) 681 task.BidInfo.IsRemind = isRemind.(bool)
@@ -388,7 +388,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -388,7 +388,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
388 queryWealth = queryWealth.ColumnExpr("b.su_money_expend - sum(su_money_transaction_records.su_money) AS employee_su_money") 388 queryWealth = queryWealth.ColumnExpr("b.su_money_expend - sum(su_money_transaction_records.su_money) AS employee_su_money")
389 queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY b.su_money_expend - sum(su_money_transaction_records.su_money) DESC) AS ranking") 389 queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY b.su_money_expend - sum(su_money_transaction_records.su_money) DESC) AS ranking")
390 queryWealth = queryWealth.Where(`su_money_transaction_records.record_type = ?`, 6) 390 queryWealth = queryWealth.Where(`su_money_transaction_records.record_type = ?`, 6)
391 - queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤 391 + queryWealth = queryWealth.Where(`e.status = ?`, 1)
392 //queryWealth = queryWealth.Where("su_money_transaction_records.employee->>'uid' = b.uid") 392 //queryWealth = queryWealth.Where("su_money_transaction_records.employee->>'uid' = b.uid")
393 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 393 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
394 queryWealth = queryWealth.Where("e.company_id = ?", companyId) 394 queryWealth = queryWealth.Where("e.company_id = ?", companyId)