bugfix: 完成数量超过限制不报错

This commit is contained in:
cjy 2025-10-22 13:05:50 +08:00
parent 0e284a8d6f
commit 3638845d6e

View File

@ -5,10 +5,11 @@ import (
"micro-bundle/internal/model"
"micro-bundle/pkg/app"
commonErr "micro-bundle/pkg/err"
"time"
"strings"
"time"
"github.com/google/uuid"
"go.uber.org/zap"
"gorm.io/gorm"
)
@ -493,22 +494,46 @@ func UpdateTaskProgress(req *CompleteTaskRequest) error {
case "video":
newCompleteCount := assignRecord.CompleteVideoCount + req.CompleteCount
if newCompleteCount > assignRecord.AssignVideoCount {
tx.Rollback()
return commonErr.ReturnError(nil, "完成数量超出限制", "视频完成数量不能超过指派数量")
// 记录超限日志,但不返回错误
app.ModuleClients.Lg.Info("视频完成数量超出限制",
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
zap.String("employeeName", req.EmployeeName),
zap.String("employeeNum", req.EmployeeNum),
zap.Int("currentCompleteCount", assignRecord.CompleteVideoCount),
zap.Int("requestCompleteCount", req.CompleteCount),
zap.Int("newCompleteCount", newCompleteCount),
zap.Int("assignVideoCount", assignRecord.AssignVideoCount),
)
}
updateData["complete_video_count"] = newCompleteCount
case "post":
newCompleteCount := assignRecord.CompletePostCount + req.CompleteCount
if newCompleteCount > assignRecord.AssignPostCount {
tx.Rollback()
return commonErr.ReturnError(nil, "完成数量超出限制", "图文完成数量不能超过指派数量")
// 记录超限日志,但不返回错误
app.ModuleClients.Lg.Info("图文完成数量超出限制",
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
zap.String("employeeName", req.EmployeeName),
zap.String("employeeNum", req.EmployeeNum),
zap.Int("currentCompleteCount", assignRecord.CompletePostCount),
zap.Int("requestCompleteCount", req.CompleteCount),
zap.Int("newCompleteCount", newCompleteCount),
zap.Int("assignPostCount", assignRecord.AssignPostCount),
)
}
updateData["complete_post_count"] = newCompleteCount
case "data":
newCompleteCount := assignRecord.CompleteDataCount + req.CompleteCount
if newCompleteCount > assignRecord.AssignDataCount {
tx.Rollback()
return commonErr.ReturnError(nil, "完成数量超出限制", "数据完成数量不能超过指派数量")
// 记录超限日志,但不返回错误
app.ModuleClients.Lg.Info("数据完成数量超出限制",
zap.String("assignRecordsUUID", assignRecord.AssignRecordsUUID),
zap.String("employeeName", req.EmployeeName),
zap.String("employeeNum", req.EmployeeNum),
zap.Int("currentCompleteCount", assignRecord.CompleteDataCount),
zap.Int("requestCompleteCount", req.CompleteCount),
zap.Int("newCompleteCount", newCompleteCount),
zap.Int("assignDataCount", assignRecord.AssignDataCount),
)
}
updateData["complete_data_count"] = newCompleteCount
default: