|
@@ -3,10 +3,6 @@ package db
|
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
- "github.com/caixw/lib.go/conv"
|
|
|
- "github.com/sirupsen/logrus"
|
|
|
- "github.com/tidwall/gjson"
|
|
|
- "gorm.io/gorm"
|
|
|
"log"
|
|
|
"reflect"
|
|
|
"strconv"
|
|
@@ -15,6 +11,11 @@ import (
|
|
|
"youngee_m_api/model/gorm_model"
|
|
|
"youngee_m_api/model/http_model"
|
|
|
"youngee_m_api/util"
|
|
|
+
|
|
|
+ "github.com/caixw/lib.go/conv"
|
|
|
+ "github.com/sirupsen/logrus"
|
|
|
+ "github.com/tidwall/gjson"
|
|
|
+ "gorm.io/gorm"
|
|
|
)
|
|
|
|
|
|
func CreatePricingStrategy(ctx context.Context, req *http_model.AddPricingRequest) (string, string, error) {
|
|
@@ -812,6 +813,7 @@ func GetAutoInvalidTask() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+// 图文-初稿超时违约判断
|
|
|
func GetAutoDraftDefaultInPicTask() error {
|
|
|
db := GetReadDB(context.Background())
|
|
|
var projectInfos []*gorm_model.ProjectInfo
|
|
@@ -819,157 +821,74 @@ func GetAutoDraftDefaultInPicTask() error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- // 项目类型为 实体商品寄拍、虚拟产品测评、线下探店打卡 均为正常的 收发货情况,以签收状况作为判断条件
|
|
|
var projectIds []int64
|
|
|
- // 存储素材微原创的项目id,此情况单独处理,它不涉及到物流,也不涉及到脚本,初稿上一个状态直接就是支付。
|
|
|
- var specialProjectIds []int64
|
|
|
- projectIdToAutoTaskIdMap := map[int64]int{}
|
|
|
- // 项目id 对 违约定时任务id 的map
|
|
|
- projectIdToAutoDefaultIdMap := map[int64]int{}
|
|
|
- // taskId 对 稿费形式的 map
|
|
|
- taskIdToFeeFormMap := make(map[int]int)
|
|
|
- TaskIdToProjectId := make(map[int]int)
|
|
|
- var taskNeedModIds []int
|
|
|
- var specialTaskNeedModIds []int
|
|
|
- // 已提交初稿的任务记录id
|
|
|
- var submitTaskNeedModIds []int
|
|
|
+ projectIdToAutoTaskIdMap := map[int64]int{} // 项目id 对 定时任务id 的map
|
|
|
+ projectIdToAutoDefaultIdMap := map[int64]int{} // 项目id 对 违约扣款设置id 的map
|
|
|
+ taskIdToFeeFormMap := make(map[int]int) // taskId 对 稿费形式的 map
|
|
|
+ TaskIdToProjectId := make(map[int]int) // taskId 对 项目id的 map
|
|
|
+ var taskNeedModIds []int // 首次提交初稿的任务记录id
|
|
|
+ var submitTaskNeedModIds []int // 修改后提交初稿的任务记录id
|
|
|
+ // 构造map及list
|
|
|
for _, projectInfo := range projectInfos {
|
|
|
- if projectInfo.ProjectForm == 4 {
|
|
|
- specialProjectIds = append(specialProjectIds, projectInfo.ProjectID)
|
|
|
- specialProjectInfo := gorm_model.ProjectInfo{}
|
|
|
- db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(gorm_model.ProjectInfo{}).Where("project_id = ?", projectInfo.ProjectID).First(&specialProjectInfo)
|
|
|
- dbStart := GetReadDB(context.Background())
|
|
|
- var DraftDefaultInPic int32
|
|
|
- dbStart.Model(gorm_model.InfoAutoTask{}).Select("draft_default_in_pic").Where("auto_task_id = ?", specialProjectInfo.AutoTaskID).First(&DraftDefaultInPic)
|
|
|
- dd, _ := time.ParseDuration(conv.MustString(DraftDefaultInPic, "") + "h")
|
|
|
- t1 := projectInfo.PayAt.Add(dd)
|
|
|
- if !projectInfo.PayAt.IsZero() && projectInfo.AutoSketchBreakAt.IsZero() {
|
|
|
- db1.Model(gorm_model.ProjectInfo{}).Where("project_id = ?", projectInfo.ProjectID).Updates(&gorm_model.ProjectInfo{AutoSketchBreakAt: &t1})
|
|
|
- fmt.Println("已添加素材微原创的初稿违约自动处理时间")
|
|
|
- }
|
|
|
- } else {
|
|
|
- projectIds = append(projectIds, projectInfo.ProjectID)
|
|
|
- }
|
|
|
+ projectIds = append(projectIds, projectInfo.ProjectID)
|
|
|
projectIdToAutoTaskIdMap[projectInfo.ProjectID] = int(projectInfo.AutoTaskID)
|
|
|
projectIdToAutoDefaultIdMap[projectInfo.ProjectID] = int(projectInfo.AutoDefaultID)
|
|
|
}
|
|
|
- //fmt.Println("projectIds:", projectIds)
|
|
|
- //fmt.Println("specialProjectIds:", specialProjectIds)
|
|
|
- for _, specialProjectId := range specialProjectIds {
|
|
|
- db2 := GetReadDB(context.Background())
|
|
|
- var taskInfos []gorm_model.YoungeeTaskInfo
|
|
|
- db2.Model(gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND cur_default_type = ?", specialProjectId, 0).Find(&taskInfos)
|
|
|
- for _, taskInfo := range taskInfos {
|
|
|
- TaskIdToProjectId[taskInfo.TaskId] = int(specialProjectId)
|
|
|
- taskIdToFeeFormMap[taskInfo.TaskId] = taskInfo.FeeForm
|
|
|
- specialTaskNeedMod := gorm_model.YoungeeTaskInfo{}
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- // 保存所有初稿上传状态为 1或 3 的任务记录的id
|
|
|
- db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskInfo.TaskId).First(&specialTaskNeedMod)
|
|
|
- if specialTaskNeedMod.SketchStatus == 1 && taskInfo.TaskStage == 10 {
|
|
|
- specialTaskNeedModIds = append(specialTaskNeedModIds, taskInfo.TaskId)
|
|
|
- }
|
|
|
- if specialTaskNeedMod.SketchStatus == 3 && taskInfo.TaskStage == 10 {
|
|
|
- submitTaskNeedModIds = append(submitTaskNeedModIds, taskInfo.TaskId)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //fmt.Println("specialTaskNeedModIds:", specialTaskNeedModIds)
|
|
|
- for _, specialTaskNeedModId := range specialTaskNeedModIds {
|
|
|
- projectNeedMod := gorm_model.ProjectInfo{}
|
|
|
- db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(gorm_model.ProjectInfo{}).Where("project_id = ?", TaskIdToProjectId[specialTaskNeedModId]).First(&projectNeedMod)
|
|
|
- var sketchDefaultRate int
|
|
|
- if taskIdToFeeFormMap[specialTaskNeedModId] == 1 {
|
|
|
- db6 := GetReadDB(context.Background())
|
|
|
- db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_replace_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[int64(TaskIdToProjectId[specialTaskNeedModId])]).Find(&sketchDefaultRate)
|
|
|
- } else {
|
|
|
- db6 := GetReadDB(context.Background())
|
|
|
- db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_other_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[int64(TaskIdToProjectId[specialTaskNeedModId])]).Find(&sketchDefaultRate)
|
|
|
- }
|
|
|
- if projectNeedMod.AutoSketchBreakAt.Sub(time.Now()) <= 0 && !projectNeedMod.AutoSketchBreakAt.IsZero() {
|
|
|
- db2 := GetReadDB(context.Background())
|
|
|
- err1 := db2.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: specialTaskNeedModId, ProjectID: TaskIdToProjectId[specialTaskNeedModId], BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", specialTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", specialTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount})
|
|
|
- fmt.Println("已创建素材微原创的任务初稿违约记录")
|
|
|
- }
|
|
|
- }
|
|
|
for _, projectId := range projectIds {
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
var taskInfos []gorm_model.YoungeeTaskInfo
|
|
|
- db1.Model(gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND cur_default_type = ? ", projectId, 0).Find(&taskInfos)
|
|
|
+ db1.Model(gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND task_status = ? AND task_stage = ? AND cur_default_type = ?", projectId, 2, 9, 0).Find(&taskInfos)
|
|
|
for _, taskInfo := range taskInfos {
|
|
|
TaskIdToProjectId[taskInfo.TaskId] = int(projectId)
|
|
|
taskNeedMod := gorm_model.YoungeeTaskInfo{}
|
|
|
db2 := GetReadDB(context.Background())
|
|
|
// 保存所有满足物流状态为3 且 初稿上传状态为 1或 3 的任务记录的id
|
|
|
db2.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskInfo.TaskId).First(&taskNeedMod)
|
|
|
- if taskNeedMod.LogisticsStatus == 3 && taskNeedMod.ScriptStatus == 1 {
|
|
|
+ taskIdToFeeFormMap[taskInfo.TaskId] = taskInfo.FeeForm
|
|
|
+ if taskNeedMod.TaskStage == 9 && taskNeedMod.ScriptStatus == 1 {
|
|
|
taskNeedModIds = append(taskNeedModIds, taskInfo.TaskId)
|
|
|
}
|
|
|
- if taskNeedMod.LogisticsStatus == 3 && taskNeedMod.ScriptStatus == 3 {
|
|
|
+ if taskNeedMod.TaskStage == 9 && taskNeedMod.ScriptStatus == 3 {
|
|
|
submitTaskNeedModIds = append(submitTaskNeedModIds, taskInfo.TaskId)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //fmt.Println("projectIdToAutoTaskIdMap:", projectIdToAutoTaskIdMap)
|
|
|
- //fmt.Println("TaskIdToProjectId:", TaskIdToProjectId)
|
|
|
- //fmt.Println("taskNeedModIds:", taskNeedModIds)
|
|
|
+ // 判断应首次上传初稿的任务
|
|
|
for _, taskNeedModId := range taskNeedModIds {
|
|
|
- // 获取 autoTaskId 及其对应的限制时间、
|
|
|
- //fmt.Println("taskNeedModId:", taskNeedModId)
|
|
|
+ // 获取 autoTaskId 及其对应的限制时间
|
|
|
autoTaskId := projectIdToAutoTaskIdMap[int64(TaskIdToProjectId[taskNeedModId])]
|
|
|
dbStart := GetReadDB(context.Background())
|
|
|
var DraftDefaultInPic int32
|
|
|
dbStart.Model(gorm_model.InfoAutoTask{}).Select("draft_default_in_pic").Where("auto_task_id = ?", autoTaskId).First(&DraftDefaultInPic)
|
|
|
- //fmt.Println("t:", autoTaskInfo.DraftDefaultInPic)
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
+
|
|
|
taskLogisticNeedMod := gorm_model.YoungeeTaskLogistics{}
|
|
|
db3.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id = ?", taskNeedModId).First(&taskLogisticNeedMod)
|
|
|
+
|
|
|
+ // 查询违约扣款比例
|
|
|
var sketchDefaultRate int
|
|
|
- if taskIdToFeeFormMap[taskNeedModId] == 1 {
|
|
|
+ if taskIdToFeeFormMap[taskNeedModId] == 1 { // 稿费形式为产品置换
|
|
|
db6 := GetReadDB(context.Background())
|
|
|
db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_replace_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[int64(TaskIdToProjectId[taskNeedModId])]).Find(&sketchDefaultRate)
|
|
|
- } else {
|
|
|
+ } else { // 稿费形式为其他
|
|
|
db6 := GetReadDB(context.Background())
|
|
|
db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_other_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[int64(TaskIdToProjectId[taskNeedModId])]).Find(&sketchDefaultRate)
|
|
|
}
|
|
|
+
|
|
|
+ // 添加初稿违约自动处理时间
|
|
|
if taskLogisticNeedMod.AutoSketchBreakAt.IsZero() {
|
|
|
dd, _ := time.ParseDuration(conv.MustString(DraftDefaultInPic, "") + "h")
|
|
|
db4 := GetReadDB(context.Background())
|
|
|
- logisticNeedMod := gorm_model.YoungeeTaskLogistics{}
|
|
|
- db4.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id = ?", taskNeedModId).First(&logisticNeedMod)
|
|
|
- if logisticNeedMod.ThingsType == 1 && !logisticNeedMod.SignedTime.IsZero() {
|
|
|
- db4.Where("task_id = ?", taskNeedModId).Updates(&gorm_model.YoungeeTaskLogistics{
|
|
|
- AutoSketchBreakAt: taskLogisticNeedMod.SignedTime.Add(dd),
|
|
|
- })
|
|
|
- fmt.Println("已添加实物的图片初稿违约自动处理时间")
|
|
|
- }
|
|
|
- if logisticNeedMod.ThingsType != 1 && !logisticNeedMod.AutoSignAt.IsZero() {
|
|
|
- db4.Where("task_id = ?", taskNeedModId).Updates(&gorm_model.YoungeeTaskLogistics{
|
|
|
- AutoSketchBreakAt: taskLogisticNeedMod.AutoSignAt.Add(dd),
|
|
|
- })
|
|
|
- fmt.Println("已添加虚拟产品及线下探店的图片初稿违约自动处理时间")
|
|
|
- }
|
|
|
+ db4.Where("task_id = ?", taskNeedModId).Updates(&gorm_model.YoungeeTaskLogistics{
|
|
|
+ AutoSketchBreakAt: taskLogisticNeedMod.SignedTime.Add(dd),
|
|
|
+ })
|
|
|
+ taskLogisticNeedMod.AutoSketchBreakAt = taskLogisticNeedMod.SignedTime.Add(dd)
|
|
|
+ fmt.Println("已添加图片初稿违约自动处理时间")
|
|
|
}
|
|
|
- db7 := GetReadDB(context.Background())
|
|
|
- taskLogisticNeedMod2 := gorm_model.YoungeeTaskLogistics{}
|
|
|
- db7.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id = ?", taskNeedModId).First(&taskLogisticNeedMod2)
|
|
|
- if !taskLogisticNeedMod2.AutoSketchBreakAt.IsZero() && taskLogisticNeedMod2.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
+
|
|
|
+ // 判断是否超时违约
|
|
|
+ if taskLogisticNeedMod.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
+ // 超时违约处理
|
|
|
db5 := GetReadDB(context.Background())
|
|
|
err1 := db5.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
TaskID: taskNeedModId, ProjectID: TaskIdToProjectId[taskNeedModId], BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
@@ -978,22 +897,29 @@ func GetAutoDraftDefaultInPicTask() error {
|
|
|
}
|
|
|
taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskLogisticNeedMod2.TaskID).Find(&taskInfo).Error
|
|
|
+ err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskLogisticNeedMod.TaskID).Find(&taskInfo).Error
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.LinkBreakRate+taskInfo.DataBreakRate+sketchDefaultRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db8 := GetReadDB(context.Background())
|
|
|
- db8.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskLogisticNeedMod2.TaskID).Updates(
|
|
|
+ db8.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskLogisticNeedMod.TaskID).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount})
|
|
|
fmt.Println("已创建图文类型的初稿违约记录")
|
|
|
}
|
|
|
}
|
|
|
+ // 判断应修改后上传初稿的任务
|
|
|
for _, submitTaskNeedModId := range submitTaskNeedModIds {
|
|
|
+ // 获取 autoTaskId 及其对应的限制时间
|
|
|
db2 := GetReadDB(context.Background())
|
|
|
var DraftDefaultInMv int32
|
|
|
db2.Model(&gorm_model.InfoAutoTask{}).Select("draft_default_in_mv").Where("auto_task_id = ?", projectIdToAutoTaskIdMap[int64(TaskIdToProjectId[submitTaskNeedModId])]).First(&DraftDefaultInMv)
|
|
|
dd, _ := time.ParseDuration(conv.MustString(DraftDefaultInMv, "") + "h")
|
|
|
+
|
|
|
+ // 查询违约扣款比例
|
|
|
var sketchDefaultRate int
|
|
|
if taskIdToFeeFormMap[submitTaskNeedModId] == 1 {
|
|
|
db6 := GetReadDB(context.Background())
|
|
@@ -1002,65 +928,50 @@ func GetAutoDraftDefaultInPicTask() error {
|
|
|
db6 := GetReadDB(context.Background())
|
|
|
db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_other_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[int64(TaskIdToProjectId[submitTaskNeedModId])]).Find(&sketchDefaultRate)
|
|
|
}
|
|
|
+ // 添加初稿违约自动处理时间
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
var taskSketchInfo gorm_model.YounggeeSketchInfo
|
|
|
- db1.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ?", submitTaskNeedModId).Order("reject_at desc").First(&taskSketchInfo)
|
|
|
+ db1.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ? and is_review = 1", submitTaskNeedModId).Order("reject_at desc").First(&taskSketchInfo)
|
|
|
if taskSketchInfo.AutoSketchBreakAt.IsZero() {
|
|
|
err4 := db1.Where("task_id = ?", submitTaskNeedModId).Updates(&gorm_model.YounggeeSketchInfo{AutoSketchBreakAt: taskSketchInfo.RejectAt.Add(dd)}).Error
|
|
|
if err4 != nil {
|
|
|
return err4
|
|
|
}
|
|
|
+ taskSketchInfo.AutoSketchBreakAt = taskSketchInfo.RejectAt.Add(dd)
|
|
|
fmt.Println("已添加图文形式的初稿违约自动处理时间")
|
|
|
- if taskSketchInfo.RejectAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
- db4 := GetReadDB(context.Background())
|
|
|
- err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: submitTaskNeedModId, ProjectID: TaskIdToProjectId[submitTaskNeedModId], BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- db5 := GetReadDB(context.Background())
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- err2 = db5.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- fmt.Println("创建时已违约则创建已提交初稿的图文类型的初稿违约记录")
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断是否违约
|
|
|
+ if taskSketchInfo.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
+ db4 := GetReadDB(context.Background())
|
|
|
+ err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
+ TaskID: submitTaskNeedModId, ProjectID: TaskIdToProjectId[submitTaskNeedModId], BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
+ if err1 != nil {
|
|
|
+ return err1
|
|
|
}
|
|
|
- } else {
|
|
|
- if taskSketchInfo.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
- db4 := GetReadDB(context.Background())
|
|
|
- err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: submitTaskNeedModId, ProjectID: TaskIdToProjectId[submitTaskNeedModId], BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- fmt.Println("创建已提交初稿的图文类型的初稿违约记录")
|
|
|
+ taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
+ dbt := GetReadDB(context.Background())
|
|
|
+ err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Find(&taskInfo).Error
|
|
|
+ if err2 != nil {
|
|
|
+ return err2
|
|
|
+ }
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(sketchDefaultRate+taskInfo.DataBreakRate+taskInfo.LinkBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
}
|
|
|
+ db3 := GetReadDB(context.Background())
|
|
|
+ err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(
|
|
|
+ &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
+ if err2 != nil {
|
|
|
+ return err2
|
|
|
+ }
|
|
|
+ fmt.Println("创建已提交初稿的图文类型的初稿违约记录")
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+// 视频-初稿超时违约判断
|
|
|
func GetAutoDraftDefaultInMvTask() error {
|
|
|
db := GetReadDB(context.Background())
|
|
|
var VideoProjectIds []int64
|
|
@@ -1068,7 +979,6 @@ func GetAutoDraftDefaultInMvTask() error {
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- //fmt.Println("VideoProjectIds:", VideoProjectIds)
|
|
|
// 任务id 对 项目id 的map
|
|
|
taskIdToProjectIdMap := map[int]int64{}
|
|
|
// 项目id 对 定时任务id 的map
|
|
@@ -1078,25 +988,24 @@ func GetAutoDraftDefaultInMvTask() error {
|
|
|
// taskId 对 稿费形式的 map
|
|
|
taskIdToFeeFormMap := make(map[int]int)
|
|
|
var videoTaskIds []int
|
|
|
+
|
|
|
+ // 构造map及list
|
|
|
for _, VideoProjectId := range VideoProjectIds {
|
|
|
db2 := GetReadDB(context.Background())
|
|
|
autoIds := gorm_model.ProjectInfo{}
|
|
|
- db2.Select([]string{"auto_task_id", "auto_default_id"}).Model(&gorm_model.ProjectInfo{}).Where("project_id = ?", VideoProjectId).First(&autoIds)
|
|
|
+ db2.Model(&gorm_model.ProjectInfo{}).Select([]string{"auto_task_id", "auto_default_id"}).Where("project_id = ?", VideoProjectId).First(&autoIds)
|
|
|
projectIdToAutoTaskIdMap[VideoProjectId] = int(autoIds.AutoTaskID)
|
|
|
projectIdToAutoDefaultIdMap[VideoProjectId] = int(autoIds.AutoDefaultID)
|
|
|
|
|
|
var videoTaskInfos []*gorm_model.YoungeeTaskInfo
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND cur_default_type = ? ", VideoProjectId, 0).Find(&videoTaskInfos)
|
|
|
+ db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND task_status = ? AND task_stage = ? AND cur_default_type = ? ", VideoProjectId, 2, 9, 0).Find(&videoTaskInfos)
|
|
|
for _, videoTaskInfo := range videoTaskInfos {
|
|
|
taskIdToProjectIdMap[videoTaskInfo.TaskId] = VideoProjectId
|
|
|
taskIdToFeeFormMap[videoTaskInfo.TaskId] = videoTaskInfo.FeeForm
|
|
|
videoTaskIds = append(videoTaskIds, videoTaskInfo.TaskId)
|
|
|
}
|
|
|
}
|
|
|
- //fmt.Println("taskIdToProjectIdMap:", taskIdToProjectIdMap)
|
|
|
- //fmt.Println("projectIdToAutoTaskIdMap:", projectIdToAutoTaskIdMap)
|
|
|
- //fmt.Println("videoTaskIds:", videoTaskIds)
|
|
|
// 首次提交初稿的任务记录id
|
|
|
var videoTaskNeedModIds []int
|
|
|
// 已提交初稿的任务记录id
|
|
@@ -1104,18 +1013,17 @@ func GetAutoDraftDefaultInMvTask() error {
|
|
|
for _, videoTaskId := range videoTaskIds {
|
|
|
var taskInfo gorm_model.YoungeeTaskInfo
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
- // 保存所有初稿上传状态为 1 且任务状态为10 的任务记录的id
|
|
|
+ // 保存所有初稿上传状态为 1 且任务阶段为9 的任务记录的id
|
|
|
db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskId).First(&taskInfo)
|
|
|
- if taskInfo.SketchStatus == 1 && taskInfo.TaskStage == 10 {
|
|
|
+ if taskInfo.SketchStatus == 1 && taskInfo.TaskStage == 9 {
|
|
|
videoTaskNeedModIds = append(videoTaskNeedModIds, videoTaskId)
|
|
|
}
|
|
|
- // 保存所有初稿上传状态为 3 且任务状态为10 的任务记录的id
|
|
|
- if taskInfo.SketchStatus == 3 && taskInfo.TaskStage == 10 {
|
|
|
+ // 保存所有初稿上传状态为 3 且任务阶段为9 的任务记录的id
|
|
|
+ if taskInfo.SketchStatus == 3 && taskInfo.TaskStage == 9 {
|
|
|
submitVideoTaskNeedModIds = append(submitVideoTaskNeedModIds, videoTaskId)
|
|
|
}
|
|
|
}
|
|
|
- //fmt.Println("videoTaskNeedModIds:", videoTaskNeedModIds)
|
|
|
- //fmt.Println("submitVideoTaskNeedModIds:", submitVideoTaskNeedModIds)
|
|
|
+ // 判断应首次提交初稿的任务
|
|
|
for _, videoTaskNeedModId := range videoTaskNeedModIds {
|
|
|
db2 := GetReadDB(context.Background())
|
|
|
var DraftDefaultInMv int32
|
|
@@ -1133,55 +1041,39 @@ func GetAutoDraftDefaultInMvTask() error {
|
|
|
var taskScriptInfo gorm_model.YounggeeScriptInfo
|
|
|
db1.Model(gorm_model.YounggeeScriptInfo{}).Where("task_id = ? AND is_ok = ?", videoTaskNeedModId, 1).Find(&taskScriptInfo)
|
|
|
if taskScriptInfo.AutoSketchBreakAt.IsZero() {
|
|
|
- db1.Where("task_id = ?", videoTaskNeedModId).Updates(&gorm_model.YounggeeScriptInfo{AutoSketchBreakAt: taskScriptInfo.AutoAgreeAt.Add(dd)})
|
|
|
+ db1.Where("task_id = ?", videoTaskNeedModId).Updates(&gorm_model.YounggeeScriptInfo{AutoSketchBreakAt: taskScriptInfo.AgreeAt.Add(dd)})
|
|
|
+ taskScriptInfo.AutoSketchBreakAt = taskScriptInfo.AgreeAt.Add(dd)
|
|
|
fmt.Println("已添加视频形式的初稿违约自动处理时间")
|
|
|
- if taskScriptInfo.AutoAgreeAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
- db4 := GetReadDB(context.Background())
|
|
|
- err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: videoTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[videoTaskNeedModId]), BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- fmt.Println("创建时已违约则创建视频类型的初稿违约记录")
|
|
|
+ }
|
|
|
+
|
|
|
+ if taskScriptInfo.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
+ db4 := GetReadDB(context.Background())
|
|
|
+ err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
+ TaskID: videoTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[videoTaskNeedModId]), BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
+ if err1 != nil {
|
|
|
+ return err1
|
|
|
}
|
|
|
- } else {
|
|
|
- if taskScriptInfo.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
- db4 := GetReadDB(context.Background())
|
|
|
- err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: videoTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[videoTaskNeedModId]), BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- fmt.Println("已创建视频类型的初稿违约记录")
|
|
|
+ taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
+ dbt := GetReadDB(context.Background())
|
|
|
+ err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Find(&taskInfo).Error
|
|
|
+ if err2 != nil {
|
|
|
+ return err2
|
|
|
}
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.LinkBreakRate+taskInfo.DataBreakRate+sketchDefaultRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
+ db3 := GetReadDB(context.Background())
|
|
|
+ err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Updates(
|
|
|
+ &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
+ if err2 != nil {
|
|
|
+ return err2
|
|
|
+ }
|
|
|
+ fmt.Println("已创建视频类型的初稿违约记录")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 判断应修改后上传初稿的任务
|
|
|
for _, submitVideoTaskNeedModId := range submitVideoTaskNeedModIds {
|
|
|
db2 := GetReadDB(context.Background())
|
|
|
var DraftDefaultInMv int32
|
|
@@ -1197,58 +1089,39 @@ func GetAutoDraftDefaultInMvTask() error {
|
|
|
}
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
var taskSketchInfo gorm_model.YounggeeSketchInfo
|
|
|
- db1.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Order("reject_at desc").First(&taskSketchInfo)
|
|
|
+ db1.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ? and is_review = 1", submitVideoTaskNeedModId).Order("reject_at desc").First(&taskSketchInfo)
|
|
|
if taskSketchInfo.AutoSketchBreakAt.IsZero() {
|
|
|
err4 := db1.Where("task_id = ?", submitVideoTaskNeedModId).Updates(&gorm_model.YounggeeSketchInfo{AutoSketchBreakAt: taskSketchInfo.RejectAt.Add(dd)}).Error
|
|
|
if err4 != nil {
|
|
|
return err4
|
|
|
}
|
|
|
+ taskSketchInfo.AutoSketchBreakAt = taskSketchInfo.RejectAt.Add(dd)
|
|
|
fmt.Println("已添加视频形式的初稿违约自动处理时间")
|
|
|
- if taskSketchInfo.RejectAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
- db4 := GetReadDB(context.Background())
|
|
|
- err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: submitVideoTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[submitVideoTaskNeedModId]), BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- fmt.Println("创建时已违约则创建已提交初稿的视频类型的初稿违约记录")
|
|
|
+ }
|
|
|
+ if taskSketchInfo.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
+ db4 := GetReadDB(context.Background())
|
|
|
+ err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
+ TaskID: submitVideoTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[submitVideoTaskNeedModId]), BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
+ if err1 != nil {
|
|
|
+ return err1
|
|
|
}
|
|
|
- } else {
|
|
|
- if taskSketchInfo.AutoSketchBreakAt.Sub(time.Now()) <= 0 {
|
|
|
- db4 := GetReadDB(context.Background())
|
|
|
- err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: submitVideoTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[submitVideoTaskNeedModId]), BreakType: 2, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- fmt.Println("创建已提交初稿的视频类型的初稿违约记录")
|
|
|
+ taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
+ dbt := GetReadDB(context.Background())
|
|
|
+ err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Find(&taskInfo).Error
|
|
|
+ if err2 != nil {
|
|
|
+ return err2
|
|
|
}
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.LinkBreakRate+taskInfo.DataBreakRate+sketchDefaultRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
+ db3 := GetReadDB(context.Background())
|
|
|
+ err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Updates(
|
|
|
+ &gorm_model.YoungeeTaskInfo{CurDefaultType: 3, SketchBreakRate: sketchDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
+ if err2 != nil {
|
|
|
+ return err2
|
|
|
+ }
|
|
|
+ fmt.Println("创建已提交初稿的视频类型的初稿违约记录")
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
@@ -1257,15 +1130,10 @@ func GetAutoDraftDefaultInMvTask() error {
|
|
|
func GetAutoScriptDefaultTask() error {
|
|
|
db := GetReadDB(context.Background())
|
|
|
var VideoProjectIds []int64
|
|
|
- var specialProjectIds []int
|
|
|
- err := db.Select("project_id").Model(gorm_model.ProjectInfo{}).Where("project_type = ? AND content_type = ? AND project_form != 4", 1, 2).Find(&VideoProjectIds).Error
|
|
|
+ err := db.Select("project_id").Model(gorm_model.ProjectInfo{}).Where("project_type = ? AND content_type = ?", 1, 2).Find(&VideoProjectIds).Error
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- db.Select("project_id").Model(gorm_model.ProjectInfo{}).Where("project_type = ? AND content_type = ? AND project_form = 4", 1, 2).Find(&specialProjectIds)
|
|
|
- //fmt.Println("VideoProjectIds:", VideoProjectIds)
|
|
|
- //fmt.Println("specialProjectIds:", specialProjectIds)
|
|
|
-
|
|
|
// 任务id 对 项目id 的map
|
|
|
taskIdToProjectIdMap := map[int]int64{}
|
|
|
// 项目id 对 定时任务id 的map
|
|
@@ -1274,116 +1142,40 @@ func GetAutoScriptDefaultTask() error {
|
|
|
projectIdToAutoDefaultIdMap := map[int64]int{}
|
|
|
// taskId 对 稿费形式的 map
|
|
|
taskIdToFeeFormMap := make(map[int]int)
|
|
|
- // 素材微原创的任务id
|
|
|
- var specialVideoTaskIds []int
|
|
|
- // 需要判断是否违约的素材微原创的任务id
|
|
|
- var specialTaskNeedModIds []int
|
|
|
// 首次提交脚本的任务记录id
|
|
|
var videoTaskNeedModIds []int
|
|
|
// 已提交脚本的任务记录id
|
|
|
var submitVideoTaskNeedModIds []int
|
|
|
- for _, specialProjectId := range specialProjectIds {
|
|
|
- db2 := GetReadDB(context.Background())
|
|
|
- var projectInfo gorm_model.ProjectInfo
|
|
|
- db2.Model(&gorm_model.ProjectInfo{}).Where("project_id = ?", specialProjectId).First(&projectInfo)
|
|
|
- projectIdToAutoTaskIdMap[int64(specialProjectId)] = int(projectInfo.AutoTaskID)
|
|
|
- projectIdToAutoDefaultIdMap[int64(specialProjectId)] = int(projectInfo.AutoDefaultID)
|
|
|
- var ScriptDefault int32
|
|
|
- dbStart := GetReadDB(context.Background())
|
|
|
- dbStart.Model(gorm_model.InfoAutoTask{}).Select("script_default").Where("auto_task_id = ?", projectInfo.AutoTaskID).First(&ScriptDefault)
|
|
|
- dd, _ := time.ParseDuration(conv.MustString(ScriptDefault, "") + "h")
|
|
|
- t3 := projectInfo.PayAt.Add(dd)
|
|
|
- if !projectInfo.PayAt.IsZero() && projectInfo.AutoScriptBreakAt.IsZero() {
|
|
|
- db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(gorm_model.ProjectInfo{}).Where("project_id = ?", projectInfo.ProjectID).Updates(&gorm_model.ProjectInfo{AutoScriptBreakAt: &t3})
|
|
|
- fmt.Println("已添加素材微原创的脚本违约自动处理时间")
|
|
|
- }
|
|
|
- var videoTaskInfos []*gorm_model.YoungeeTaskInfo
|
|
|
- db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND cur_default_type = ? ", specialProjectId, 0).Find(&videoTaskInfos)
|
|
|
- for _, videoTaskInfo := range videoTaskInfos {
|
|
|
- taskIdToProjectIdMap[videoTaskInfo.TaskId] = int64(specialProjectId)
|
|
|
- specialVideoTaskIds = append(specialVideoTaskIds, videoTaskInfo.TaskId)
|
|
|
- specialTaskNeedMod := gorm_model.YoungeeTaskInfo{}
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- // 保存所有脚本上传状态为 1 且任务状态为8 的任务记录的id
|
|
|
- db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskInfo.TaskId).First(&specialTaskNeedMod)
|
|
|
- if specialTaskNeedMod.ScriptStatus == 1 && specialTaskNeedMod.TaskStage == 8 {
|
|
|
- specialTaskNeedModIds = append(specialTaskNeedModIds, videoTaskInfo.TaskId)
|
|
|
- }
|
|
|
- // 保存所有脚本上传状态为 3 且任务状态为8 的任务记录的id
|
|
|
- if specialTaskNeedMod.ScriptStatus == 3 && specialTaskNeedMod.TaskStage == 8 {
|
|
|
- submitVideoTaskNeedModIds = append(submitVideoTaskNeedModIds, videoTaskInfo.TaskId)
|
|
|
- }
|
|
|
- taskIdToFeeFormMap[videoTaskInfo.TaskId] = videoTaskInfo.FeeForm
|
|
|
- }
|
|
|
- }
|
|
|
- //fmt.Println("submitVideoTaskNeedModIds:", submitVideoTaskNeedModIds)
|
|
|
- //fmt.Println("specialTaskNeedModIds:", specialTaskNeedModIds)
|
|
|
- for _, specialTaskNeedModId := range specialTaskNeedModIds {
|
|
|
- projectNeedMod := gorm_model.ProjectInfo{}
|
|
|
- db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(gorm_model.ProjectInfo{}).Where("project_id = ?", taskIdToProjectIdMap[specialTaskNeedModId]).First(&projectNeedMod)
|
|
|
- if projectNeedMod.AutoScriptBreakAt.Sub(time.Now()) <= 0 && !projectNeedMod.AutoScriptBreakAt.IsZero() {
|
|
|
- var scriptDefaultRate int
|
|
|
- if taskIdToFeeFormMap[specialTaskNeedModId] == 1 {
|
|
|
- db6 := GetReadDB(context.Background())
|
|
|
- db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_replace_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[taskIdToProjectIdMap[specialTaskNeedModId]]).Find(&scriptDefaultRate)
|
|
|
- } else {
|
|
|
- db6 := GetReadDB(context.Background())
|
|
|
- db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_other_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[taskIdToProjectIdMap[specialTaskNeedModId]]).Find(&scriptDefaultRate)
|
|
|
- }
|
|
|
- db2 := GetReadDB(context.Background())
|
|
|
- err1 := db2.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
- TaskID: specialTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[specialTaskNeedModId]), BreakType: 1, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
|
- if err1 != nil {
|
|
|
- return err1
|
|
|
- }
|
|
|
- taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
- dbt := GetReadDB(context.Background())
|
|
|
- err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", specialTaskNeedModId).Find(&taskInfo).Error
|
|
|
- if err2 != nil {
|
|
|
- return err2
|
|
|
- }
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", specialTaskNeedModId).Updates(
|
|
|
- &gorm_model.YoungeeTaskInfo{CurDefaultType: 1, ScriptBreakRate: scriptDefaultRate, SettleAmount: settleAmount})
|
|
|
- fmt.Println("已创建素材微原创的任务脚本违约记录")
|
|
|
- }
|
|
|
- }
|
|
|
var videoTaskIds []int
|
|
|
+ // 构造map及list
|
|
|
for _, VideoProjectId := range VideoProjectIds {
|
|
|
db2 := GetReadDB(context.Background())
|
|
|
var autoTaskId int
|
|
|
- db2.Select("auto_task_id").Model(&gorm_model.ProjectInfo{}).Where("project_id = ?", VideoProjectId).First(&autoTaskId)
|
|
|
+ db2.Model(&gorm_model.ProjectInfo{}).Select("auto_task_id").Where("project_id = ?", VideoProjectId).First(&autoTaskId)
|
|
|
projectIdToAutoTaskIdMap[VideoProjectId] = autoTaskId
|
|
|
var videoTaskInfos []*gorm_model.YoungeeTaskInfo
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND cur_default_type = ? ", VideoProjectId, 0).Find(&videoTaskInfos)
|
|
|
+ db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND task_status = ? AND task_stage = ? AND cur_default_type = ? ", VideoProjectId, 2, 7, 0).Find(&videoTaskInfos)
|
|
|
for _, videoTaskInfo := range videoTaskInfos {
|
|
|
taskIdToProjectIdMap[videoTaskInfo.TaskId] = VideoProjectId
|
|
|
+ taskIdToFeeFormMap[videoTaskInfo.TaskId] = videoTaskInfo.FeeForm
|
|
|
videoTaskIds = append(videoTaskIds, videoTaskInfo.TaskId)
|
|
|
}
|
|
|
}
|
|
|
- //fmt.Println("taskIdToProjectIdMap:", taskIdToProjectIdMap)
|
|
|
- //fmt.Println("projectIdToAutoTaskIdMap:", projectIdToAutoTaskIdMap)
|
|
|
- //fmt.Println("videoTaskIds:", videoTaskIds)
|
|
|
for _, videoTaskId := range videoTaskIds {
|
|
|
var taskInfo gorm_model.YoungeeTaskInfo
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
// 保存所有脚本上传状态为 1 且任务状态为8 的任务记录的id
|
|
|
db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskId).First(&taskInfo)
|
|
|
- if taskInfo.ScriptStatus == 1 && taskInfo.TaskStage == 8 {
|
|
|
+ if taskInfo.ScriptStatus == 1 && taskInfo.TaskStage == 7 {
|
|
|
videoTaskNeedModIds = append(videoTaskNeedModIds, videoTaskId)
|
|
|
}
|
|
|
// 保存所有脚本上传状态为 3 且任务状态为8 的任务记录的id
|
|
|
- if taskInfo.ScriptStatus == 3 && taskInfo.TaskStage == 8 {
|
|
|
+ if taskInfo.ScriptStatus == 3 && taskInfo.TaskStage == 7 {
|
|
|
submitVideoTaskNeedModIds = append(submitVideoTaskNeedModIds, videoTaskId)
|
|
|
}
|
|
|
}
|
|
|
- //fmt.Println("videoTaskNeedModIds:", videoTaskNeedModIds)
|
|
|
- //fmt.Println("submitVideoTaskNeedModIds:", submitVideoTaskNeedModIds)
|
|
|
+ // 判断应首次上传脚本的任务
|
|
|
for _, videoTaskNeedModId := range videoTaskNeedModIds {
|
|
|
db2 := GetReadDB(context.Background())
|
|
|
var ScriptDefault int32
|
|
@@ -1401,9 +1193,9 @@ func GetAutoScriptDefaultTask() error {
|
|
|
db6.Model(gorm_model.InfoAutoDefaultHandle{}).Select("script_other_time_out").Where("auto_default_id = ?", projectIdToAutoDefaultIdMap[taskIdToProjectIdMap[videoTaskNeedModId]]).Find(&scriptDefaultRate)
|
|
|
}
|
|
|
if taskLogisticInfo.AutoScriptBreakAt.IsZero() {
|
|
|
- db1.Where("task_id = ?", videoTaskNeedModId).Updates(&gorm_model.YoungeeTaskLogistics{AutoScriptBreakAt: taskLogisticInfo.AutoSignAt.Add(dd)})
|
|
|
+ db1.Where("task_id = ?", videoTaskNeedModId).Updates(&gorm_model.YoungeeTaskLogistics{AutoScriptBreakAt: taskLogisticInfo.SignedTime.Add(dd)})
|
|
|
fmt.Println("已添加视频形式的脚本违约自动处理时间")
|
|
|
- if taskLogisticInfo.AutoSignAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
+ if taskLogisticInfo.SignedTime.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
db4 := GetReadDB(context.Background())
|
|
|
err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
TaskID: videoTaskNeedModId, ProjectID: int(taskIdToProjectIdMap[videoTaskNeedModId]), BreakType: 1, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
@@ -1416,7 +1208,10 @@ func GetAutoScriptDefaultTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.LinkBreakRate+scriptDefaultRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 1, ScriptBreakRate: scriptDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1439,7 +1234,10 @@ func GetAutoScriptDefaultTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.LinkBreakRate+scriptDefaultRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", videoTaskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 1, ScriptBreakRate: scriptDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1458,7 +1256,7 @@ func GetAutoScriptDefaultTask() error {
|
|
|
dd, _ := time.ParseDuration(conv.MustString(ScriptDefault, "") + "h")
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
var taskScriptInfo gorm_model.YounggeeScriptInfo
|
|
|
- db1.Model(gorm_model.YounggeeScriptInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Order("reject_at desc").First(&taskScriptInfo)
|
|
|
+ db1.Model(gorm_model.YounggeeScriptInfo{}).Where("task_id = ? and is_review = 1", submitVideoTaskNeedModId).Order("reject_at desc").First(&taskScriptInfo)
|
|
|
var scriptDefaultRate int
|
|
|
if taskIdToFeeFormMap[submitVideoTaskNeedModId] == 1 {
|
|
|
db6 := GetReadDB(context.Background())
|
|
@@ -1480,12 +1278,22 @@ func GetAutoScriptDefaultTask() error {
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
}
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- err2 := db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Updates(&gorm_model.YoungeeTaskInfo{
|
|
|
- CurDefaultType: 1, ScriptBreakRate: scriptDefaultRate}).Error
|
|
|
+ taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
+ dbt := GetReadDB(context.Background())
|
|
|
+ err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Find(&taskInfo).Error
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.LinkBreakRate+scriptDefaultRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
+ db3 := GetReadDB(context.Background())
|
|
|
+ err3 := db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Updates(&gorm_model.YoungeeTaskInfo{
|
|
|
+ CurDefaultType: 1, ScriptBreakRate: scriptDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
+ if err3 != nil {
|
|
|
+ return err3
|
|
|
+ }
|
|
|
fmt.Println("创建时已违约则创建已提交脚本的视频类型的脚本违约记录")
|
|
|
}
|
|
|
} else {
|
|
@@ -1496,12 +1304,22 @@ func GetAutoScriptDefaultTask() error {
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
}
|
|
|
- db3 := GetReadDB(context.Background())
|
|
|
- err2 := db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Updates(&gorm_model.YoungeeTaskInfo{
|
|
|
- CurDefaultType: 1, ScriptBreakRate: scriptDefaultRate}).Error
|
|
|
+ taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
+ dbt := GetReadDB(context.Background())
|
|
|
+ err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Find(&taskInfo).Error
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.LinkBreakRate+scriptDefaultRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
+ db3 := GetReadDB(context.Background())
|
|
|
+ err3 := db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitVideoTaskNeedModId).Updates(&gorm_model.YoungeeTaskInfo{
|
|
|
+ CurDefaultType: 1, ScriptBreakRate: scriptDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
+ if err3 != nil {
|
|
|
+ return err3
|
|
|
+ }
|
|
|
fmt.Println("创建已提交脚本的视频类型的脚本违约记录")
|
|
|
}
|
|
|
}
|
|
@@ -1534,7 +1352,7 @@ func GetAutoLinkBreachTask() error {
|
|
|
projectIdToAutoDefaultIdMap[projectId] = int(autoIds.AutoDefaultID)
|
|
|
var taskInfos []*gorm_model.YoungeeTaskInfo
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
- db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND cur_default_type = ? ", projectId, 0).Find(&taskInfos)
|
|
|
+ db1.Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND task_status = ? AND task_stage = ? AND cur_default_type = ? ", projectId, 2, 11, 0).Find(&taskInfos)
|
|
|
for _, taskInfo := range taskInfos {
|
|
|
taskIdToProjectIdMap[taskInfo.TaskId] = projectId
|
|
|
taskIds = append(taskIds, taskInfo.TaskId)
|
|
@@ -1552,11 +1370,11 @@ func GetAutoLinkBreachTask() error {
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
// 保存所有链接上传状态为 1 且任务状态为12 的任务记录的id
|
|
|
db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskId).First(&taskInfo)
|
|
|
- if taskInfo.LinkStatus == 1 && taskInfo.TaskStage == 12 {
|
|
|
+ if taskInfo.LinkStatus == 1 && taskInfo.TaskStage == 11 {
|
|
|
taskNeedModIds = append(taskNeedModIds, taskId)
|
|
|
}
|
|
|
// 保存所有链接上传状态为 3 且任务状态为12 的任务记录的id
|
|
|
- if taskInfo.LinkStatus == 3 && taskInfo.TaskStage == 12 {
|
|
|
+ if taskInfo.LinkStatus == 3 && taskInfo.TaskStage == 11 {
|
|
|
submitTaskNeedModIds = append(submitTaskNeedModIds, taskId)
|
|
|
}
|
|
|
}
|
|
@@ -1579,9 +1397,9 @@ func GetAutoLinkBreachTask() error {
|
|
|
var taskSketchInfo gorm_model.YounggeeSketchInfo
|
|
|
db1.Model(gorm_model.YounggeeSketchInfo{}).Where("task_id = ? AND is_ok = ?", taskNeedModId, 1).Find(&taskSketchInfo)
|
|
|
if taskSketchInfo.AutoLinkBreakAt.IsZero() {
|
|
|
- db1.Where("task_id = ?", taskNeedModId).Updates(&gorm_model.YounggeeSketchInfo{AutoLinkBreakAt: taskSketchInfo.AutoAgreeAt.Add(dd)})
|
|
|
+ db1.Where("task_id = ?", taskNeedModId).Updates(&gorm_model.YounggeeSketchInfo{AutoLinkBreakAt: taskSketchInfo.AgreeAt.Add(dd)})
|
|
|
fmt.Println("已添加链接违约自动处理时间")
|
|
|
- if taskSketchInfo.AutoAgreeAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
+ if taskSketchInfo.AgreeAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
db4 := GetReadDB(context.Background())
|
|
|
err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
TaskID: taskNeedModId, ProjectID: int(taskIdToProjectIdMap[taskNeedModId]), BreakType: 3, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
@@ -1594,7 +1412,10 @@ func GetAutoLinkBreachTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(linkDefaultRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 5, LinkBreakRate: linkDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1617,7 +1438,10 @@ func GetAutoLinkBreachTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(linkDefaultRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 5, LinkBreakRate: linkDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1664,7 +1488,10 @@ func GetAutoLinkBreachTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(linkDefaultRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 5, LinkBreakRate: linkDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1687,7 +1514,10 @@ func GetAutoLinkBreachTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(linkDefaultRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 5, LinkBreakRate: linkDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1724,7 +1554,7 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
projectIdToAutoDefaultIdMap[projectId] = int(autoIds.AutoDefaultID)
|
|
|
var taskInfos []int32
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
- db1.Select("task_id").Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND cur_default_type = ? ", projectId, 0).Find(&taskInfos)
|
|
|
+ db1.Select("task_id").Model(&gorm_model.YoungeeTaskInfo{}).Where("project_id = ? AND task_status = ? AND task_stage = ? AND cur_default_type = ? ", projectId, 2, 13, 0).Find(&taskInfos)
|
|
|
for _, taskInfo := range taskInfos {
|
|
|
taskIdToProjectIdMap[int(taskInfo)] = projectId
|
|
|
taskIds = append(taskIds, int(taskInfo))
|
|
@@ -1745,11 +1575,11 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
// 保存所有数据上传状态为 1 且任务状态为14 的任务记录的id
|
|
|
db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskId).First(&taskInfo)
|
|
|
- if taskInfo.DataStatus == 1 && taskInfo.TaskStage == 14 {
|
|
|
+ if taskInfo.DataStatus == 1 && taskInfo.TaskStage == 13 {
|
|
|
taskNeedModIds = append(taskNeedModIds, taskId)
|
|
|
}
|
|
|
// 保存所有数据上传状态为 3 且任务状态为14 的任务记录的id
|
|
|
- if taskInfo.DataStatus == 3 && taskInfo.TaskStage == 14 {
|
|
|
+ if taskInfo.DataStatus == 3 && taskInfo.TaskStage == 13 {
|
|
|
submitTaskNeedModIds = append(submitTaskNeedModIds, taskId)
|
|
|
}
|
|
|
taskIdToFeeFormMap[taskId] = taskInfo.FeeForm
|
|
@@ -1775,9 +1605,9 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
var taskLinkInfo gorm_model.YounggeeLinkInfo
|
|
|
db1.Model(gorm_model.YounggeeLinkInfo{}).Where("task_id = ? AND is_ok = ?", taskNeedModId, 1).Find(&taskLinkInfo)
|
|
|
if taskLinkInfo.AutoDataBreakAt.IsZero() {
|
|
|
- db1.Where("task_id = ?", taskNeedModId).Updates(&gorm_model.YounggeeLinkInfo{AutoDataBreakAt: taskLinkInfo.AutoAgreeAt.Add(dd)})
|
|
|
+ db1.Where("task_id = ?", taskNeedModId).Updates(&gorm_model.YounggeeLinkInfo{AutoDataBreakAt: taskLinkInfo.AgreeAt.Add(dd)})
|
|
|
fmt.Println("已添加数据违约自动处理时间")
|
|
|
- if taskLinkInfo.AutoAgreeAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
+ if taskLinkInfo.AgreeAt.Add(dd).Sub(time.Now()) <= 0 {
|
|
|
db4 := GetReadDB(context.Background())
|
|
|
err1 := db4.Model(gorm_model.YoungeeContractInfo{}).Create(&gorm_model.YoungeeContractInfo{
|
|
|
TaskID: taskNeedModId, ProjectID: int(taskIdToProjectIdMap[taskNeedModId]), BreakType: 4, BreakAt: time.Now(), DefaultStatus: 1}).Error
|
|
@@ -1790,7 +1620,10 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+dataDefaultRate+taskInfo.LinkBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 7, DataBreakRate: dataDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1813,7 +1646,11 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+dataDefaultRate+taskInfo.LinkBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
+ fmt.Println("settleAmount: ", settleAmount)
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 7, DataBreakRate: dataDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1840,7 +1677,7 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
}
|
|
|
db1 := GetReadDB(context.Background())
|
|
|
var taskDataInfo gorm_model.YounggeeDataInfo
|
|
|
- db1.Model(gorm_model.YounggeeDataInfo{}).Where("task_id = ?", submitTaskNeedModId).Order("reject_at desc").First(&taskDataInfo)
|
|
|
+ db1.Model(gorm_model.YounggeeDataInfo{}).Where("task_id = ? and is_review = 1", submitTaskNeedModId).Order("reject_at desc").First(&taskDataInfo)
|
|
|
if taskDataInfo.AutoDataBreakAt.IsZero() {
|
|
|
err4 := db1.Where("task_id = ?", submitTaskNeedModId).Updates(&gorm_model.YounggeeDataInfo{AutoDataBreakAt: taskDataInfo.RejectAt.Add(dd)}).Error
|
|
|
if err4 != nil {
|
|
@@ -1860,7 +1697,10 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|
|
|
- settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+taskInfo.DataBreakRate+taskInfo.SketchBreakRate+taskInfo.ScriptBreakRate)/1000)
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+dataDefaultRate+taskInfo.LinkBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(
|
|
|
&gorm_model.YoungeeTaskInfo{CurDefaultType: 7, DataBreakRate: dataDefaultRate, SettleAmount: settleAmount}).Error
|
|
@@ -1877,9 +1717,19 @@ func GetAutoCaseCloseDefaultTask() error {
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
}
|
|
|
+ taskInfo := gorm_model.YoungeeTaskInfo{}
|
|
|
+ dbt := GetReadDB(context.Background())
|
|
|
+ err2 := dbt.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Find(&taskInfo).Error
|
|
|
+ if err2 != nil {
|
|
|
+ return err2
|
|
|
+ }
|
|
|
+ settleAmount := taskInfo.TaskReward * (1.0 - float64(taskInfo.SketchBreakRate+dataDefaultRate+taskInfo.LinkBreakRate+taskInfo.ScriptBreakRate)/100)
|
|
|
+ if settleAmount < 0 {
|
|
|
+ settleAmount = float64(0.01)
|
|
|
+ }
|
|
|
db3 := GetReadDB(context.Background())
|
|
|
- err2 := db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(&gorm_model.YoungeeTaskInfo{
|
|
|
- CurDefaultType: 7, DataBreakRate: dataDefaultRate}).Error
|
|
|
+ err2 = db3.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", submitTaskNeedModId).Updates(
|
|
|
+ &gorm_model.YoungeeTaskInfo{CurDefaultType: 7, DataBreakRate: dataDefaultRate, SettleAmount: settleAmount}).Error
|
|
|
if err2 != nil {
|
|
|
return err2
|
|
|
}
|