Merge branch 'feat-cjy-taskBench' into dev
This commit is contained in:
commit
670a2b68d9
@ -457,21 +457,17 @@ func CompleteTaskManually(assignRecordsUUID string) error {
|
|||||||
return commonErr.ReturnError(err, "更新任务完成状态失败", "更新任务完成状态失败: ")
|
return commonErr.ReturnError(err, "更新任务完成状态失败", "更新任务完成状态失败: ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3) 统计该艺人(按手机号)当前进行中与已完成数量
|
// 3) 统计该艺人按照艺人sub_num 当前进行中与已完成数量
|
||||||
var stats struct {
|
var stats struct {
|
||||||
ProgressTaskCount int
|
ProgressTaskCount int
|
||||||
CompleteTaskCount int
|
CompleteTaskCount int
|
||||||
}
|
}
|
||||||
if err := tx.Table("task_assign_records").
|
if err := tx.Table("task_assign_records").
|
||||||
Select("sum(status = 1) as progress_task_count, sum(status = 2) as complete_task_count").
|
Select("COUNT(CASE WHEN status = 1 THEN 1 END) as progress_task_count, COUNT(CASE WHEN status = 2 THEN 1 END) as complete_task_count").
|
||||||
Where("sub_num = ?", assignRecord.SubNum).
|
Where("sub_num = ? AND deleted_at = 0", assignRecord.SubNum).
|
||||||
First(&stats).Error; err != nil {
|
Scan(&stats).Error; err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
tx.Rollback()
|
||||||
stats.ProgressTaskCount, stats.CompleteTaskCount = 0, 0
|
return commonErr.ReturnError(err, "查询艺人任务指派记录失败", "查询艺人任务指派记录失败: ")
|
||||||
} else {
|
|
||||||
tx.Rollback()
|
|
||||||
return commonErr.ReturnError(err, "查询艺人任务指派记录失败", "查询艺人任务指派记录失败: ")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4) 同步任务管理表的进行中与已完成数量(若不存在则创建)
|
// 4) 同步任务管理表的进行中与已完成数量(若不存在则创建)
|
||||||
@ -1384,15 +1380,12 @@ func GetArtistTaskStatsBySubNum(SubNum string) (int, int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := app.ModuleClients.TaskBenchDB.Table("task_assign_records").
|
err := app.ModuleClients.TaskBenchDB.Table("task_assign_records").
|
||||||
Select("sum(status = 1) as progress_task_count, sum(status = 2) as complete_task_count").
|
Select("COUNT(CASE WHEN status = 1 THEN 1 END) as progress_task_count, COUNT(CASE WHEN status = 2 THEN 1 END) as complete_task_count").
|
||||||
Where("sub_num = ?", SubNum).
|
Where("sub_num = ? AND deleted_at = 0", SubNum).
|
||||||
First(&res).Error
|
Scan(&res).Error
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == gorm.ErrRecordNotFound {
|
return 0, 0, nil
|
||||||
return 0, 0, nil
|
|
||||||
}
|
|
||||||
return 0, 0, commonErr.ReturnError(err, "查询艺人任务记录失败", "查询艺人任务记录失败: ")
|
|
||||||
}
|
}
|
||||||
return res.ProgressTaskCount, res.CompleteTaskCount, nil
|
return res.ProgressTaskCount, res.CompleteTaskCount, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user