作者 陈志颖

test:测试已过期任务编辑

... ... @@ -651,3 +651,4 @@
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"}
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/
2020/11/23 17:40:41.529 [I] [???:0] http server Running on http://:8082
2020/11/23 17:43:38.430 [I] [???:0] http server Running on http://:8082
... ...
... ... @@ -630,7 +630,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
//currentTime := time.Now().Local()
//endTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 23, 59, 59, 0, currentTime.Location())
for _, activity := range activities {
//if activity.Deadline.UnixNano() / 1e6 >= currentTime.UnixNano() / 1e6 {
cash, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedCash), 64)
suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
activityWithTs := map[string]interface{} {
... ... @@ -645,7 +644,6 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
"createTime": activity.CreateTime.Local(),
}
activitiesWithTs = append(activitiesWithTs, activityWithTs)
//}
}
if len(activitiesWithTs) == 0 {
... ...
... ... @@ -235,6 +235,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
if err := releaseTaskCommand.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())
... ... @@ -245,6 +246,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
defer func() {
transactionContext.RollbackTransaction()
}()
var releaseTaskService service.ReleaseTaskService
if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -257,6 +259,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -1084,6 +1087,20 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
taskDao = value
}
var releaseTaskService service.ReleaseTaskService
if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
releaseTaskService = value
releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
releaseTaskService.Subscribe(&subscriber.MmmOpenApiServiceServiceSubscriber{
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 找到当前任务
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -1143,6 +1160,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
updateData["assignedPerson"] = &domain.EmployeeInfo{}
}
}
// TODO 任务返回错误类型
if err := task.Update(updateData); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ... @@ -1155,6 +1173,13 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if task.TaskType == domain.TASK_STATUS_EXPIRED {
if _, err := releaseTaskService.Release(task.TaskId, task.Sponsor.Uid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ...
... ... @@ -673,6 +673,9 @@ func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) erro
}
if bidEndTime, ok := data["bidEndTime"]; ok {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
//task.ReceiveTime = time.Now()
//task.TaskStatus = TASK_STATUS_UNDERWAY
//task.CurrentStatus = &UnderwayStatus{}
}
if isRemind, ok := data["isRemind"]; ok {
task.BidInfo.IsRemind = isRemind.(bool)
... ...
... ... @@ -388,7 +388,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
queryWealth = queryWealth.ColumnExpr("b.su_money_expend - sum(su_money_transaction_records.su_money) AS employee_su_money")
queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY b.su_money_expend - sum(su_money_transaction_records.su_money) DESC) AS ranking")
queryWealth = queryWealth.Where(`su_money_transaction_records.record_type = ?`, 6)
queryWealth = queryWealth.Where(`e.status = ?`, 1) // 离职员工过滤
queryWealth = queryWealth.Where(`e.status = ?`, 1)
//queryWealth = queryWealth.Where("su_money_transaction_records.employee->>'uid' = b.uid")
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryWealth = queryWealth.Where("e.company_id = ?", companyId)
... ...