|
@@ -6,6 +6,8 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/issue9/conv"
|
|
|
"gorm.io/gorm"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
"youngee_b_api/model/gorm_model"
|
|
|
"youngee_b_api/model/http_model"
|
|
@@ -25,7 +27,7 @@ func GetProjecttaskList(ctx context.Context, request http_model.GetTaskListReque
|
|
|
case 1:
|
|
|
query = query.Where("supplier_id = 0 AND supplier_status = 0")
|
|
|
case 2:
|
|
|
- query = query.Where("supplier_id != 0 AND supplier_status = 2")
|
|
|
+ query = query.Where("supplier_id !=0 AND supplier_status = 2")
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -53,7 +55,18 @@ func GetProjecttaskList(ctx context.Context, request http_model.GetTaskListReque
|
|
|
|
|
|
taskInfoPointers := make([]*http_model.TaskInfo, 0, len(projecrtaskinfo))
|
|
|
for _, task := range projecrtaskinfo {
|
|
|
- boperator := getBOperator(db, task.BOperator)
|
|
|
+ var Time time.Time
|
|
|
+ switch *request.Type {
|
|
|
+ case 0:
|
|
|
+ Time = task.CreateDate
|
|
|
+ case 1:
|
|
|
+ Time = task.SignedTime
|
|
|
+ case 2:
|
|
|
+ Time = task.CompleteDate
|
|
|
+ }
|
|
|
+ boperator := getBOperator(db, task.BOperator, task.BOperatorType)
|
|
|
+ nickname, headurl := getTalentinfo(db, task.TalentID)
|
|
|
+ Iscoop := getIscoop(db, task.TalentID, request.EnterPriseId)
|
|
|
response := &http_model.TaskInfo{
|
|
|
TaskId: task.TaskID,
|
|
|
ProjectId: task.ProjectID,
|
|
@@ -67,7 +80,11 @@ func GetProjecttaskList(ctx context.Context, request http_model.GetTaskListReque
|
|
|
CurrentDefaultType: task.CurDefaultType,
|
|
|
From: determineFrom(task.SupplierId, task.SupplierStatus),
|
|
|
Boperator: boperator,
|
|
|
- CreateAt: task.CreateDate,
|
|
|
+ CreateAt: Time,
|
|
|
+ NickName: nickname,
|
|
|
+ HeadUrl: headurl,
|
|
|
+ ISCoop: Iscoop,
|
|
|
+ Sprojectid: task.SprojectId,
|
|
|
}
|
|
|
taskInfoPointers = append(taskInfoPointers, response)
|
|
|
}
|
|
@@ -78,15 +95,44 @@ func GetProjecttaskList(ctx context.Context, request http_model.GetTaskListReque
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
-func getBOperator(db *gorm.DB, bOperatorID string) string {
|
|
|
+func getBOperator(db *gorm.DB, bOperatorID string, bOperatorType int) string {
|
|
|
if bOperatorID == "" {
|
|
|
return ""
|
|
|
}
|
|
|
- var boperatorinfo gorm_model.Enterprise
|
|
|
- if err := db.Where(gorm_model.Enterprise{EnterpriseID: bOperatorID}).First(&boperatorinfo).Error; err != nil {
|
|
|
- return ""
|
|
|
+ if bOperatorType == 1 {
|
|
|
+ var boperatorinfo gorm_model.Enterprise
|
|
|
+ if err := db.Where(gorm_model.Enterprise{EnterpriseID: bOperatorID}).First(&boperatorinfo).Error; err != nil {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ return boperatorinfo.BusinessName
|
|
|
+ }
|
|
|
+ if bOperatorType == 2 {
|
|
|
+ var bsubaccount gorm_model.YounggeeSubAccount
|
|
|
+ if err := db.Where(gorm_model.YounggeeSubAccount{SubAccountId: conv.MustInt(bOperatorID)}).First(&bsubaccount).Error; err != nil {
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ return bsubaccount.SubAccountName
|
|
|
+ }
|
|
|
+ if bOperatorType == 3 {
|
|
|
+ return "管理后台"
|
|
|
+ }
|
|
|
+ return ""
|
|
|
+}
|
|
|
+
|
|
|
+func getTalentinfo(db *gorm.DB, talentID string) (string, string) {
|
|
|
+ var talentinfo gorm_model.PlatformKuaishouUserInfo
|
|
|
+ if err := db.Where(gorm_model.PlatformKuaishouUserInfo{TalentId: talentID}).First(&talentinfo).Error; err != nil {
|
|
|
+ return "", ""
|
|
|
+ }
|
|
|
+ return talentinfo.NickName, talentinfo.HeadUri
|
|
|
+}
|
|
|
+
|
|
|
+func getIscoop(db *gorm.DB, talentid string, enterpriseid string) int {
|
|
|
+ var etcoop gorm_model.EnterpriseTalentCooperate
|
|
|
+ if err := db.Where(gorm_model.EnterpriseTalentCooperate{TalentId: talentid, EnterpriseId: enterpriseid}).First(&etcoop).Error; err != nil {
|
|
|
+ return 0
|
|
|
}
|
|
|
- return boperatorinfo.BusinessName
|
|
|
+ return 1
|
|
|
}
|
|
|
|
|
|
func determineFrom(supplierID, supplierStatus int) int {
|
|
@@ -96,7 +142,7 @@ func determineFrom(supplierID, supplierStatus int) int {
|
|
|
return 1
|
|
|
}
|
|
|
|
|
|
-func PassProTaskCoop(ctx context.Context, projectId string, taskIds []string, operatorid string, operatetype int) (bool, error) {
|
|
|
+func PassProTaskCoop(ctx context.Context, projectId string, taskIds []string, operatorid string, operatetype int, Isspecial int, req http_model.PassproTaskCoopRequest) (bool, error) {
|
|
|
db := GetReadDB(ctx)
|
|
|
var count int64
|
|
|
fmt.Println("task_ids: ", taskIds)
|
|
@@ -123,12 +169,41 @@ func PassProTaskCoop(ctx context.Context, projectId string, taskIds []string, op
|
|
|
if err != nil {
|
|
|
return false, err
|
|
|
}
|
|
|
+
|
|
|
var taskstages int
|
|
|
if project.ProjectForm == 1 {
|
|
|
taskstages = 4
|
|
|
} else {
|
|
|
taskstages = 9
|
|
|
}
|
|
|
+ nextstage := [6]int{0, 0, 0, 0, 0, 0} // 数组长度为6,表示6种工具 4,9,11,13
|
|
|
+ if Isspecial == 1 {
|
|
|
+ toolList := strings.Split(project.Tools, ",")
|
|
|
+ for _, tool := range toolList {
|
|
|
+ // 将 tool 转换为整数
|
|
|
+ if t, err := strconv.Atoi(tool); err == nil && t >= 0 && t <= len(nextstage) {
|
|
|
+ nextstage[t-1] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fmt.Println(nextstage)
|
|
|
+ for i := 1; i < len(nextstage); i++ { // 从位置1开始
|
|
|
+ if nextstage[i] == 1 {
|
|
|
+ switch i {
|
|
|
+ case 1:
|
|
|
+ taskstages = 4
|
|
|
+ case 2:
|
|
|
+ taskstages = 9
|
|
|
+ case 3:
|
|
|
+ taskstages = 11
|
|
|
+ case 4:
|
|
|
+ taskstages = 13
|
|
|
+ case 5:
|
|
|
+ taskstages = 15
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//4.根据达人来源改变状态、阶段、数目
|
|
|
var tasks []gorm_model.YoungeeTaskInfo
|
|
@@ -146,6 +221,7 @@ func PassProTaskCoop(ctx context.Context, projectId string, taskIds []string, op
|
|
|
UpdateAt: time.Now(),
|
|
|
BOperator: operatorid,
|
|
|
BOperatorType: operatetype,
|
|
|
+ SelectDate: time.Now(),
|
|
|
}
|
|
|
err = tx.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ? AND task_stage = 1", taskInfo.TaskID).Updates(updateData).Error
|
|
|
if err != nil {
|
|
@@ -166,18 +242,35 @@ func PassProTaskCoop(ctx context.Context, projectId string, taskIds []string, op
|
|
|
}
|
|
|
//服务商s_project已招募人数+1
|
|
|
var sprojectinfo gorm_model.YounggeeSProjectInfo
|
|
|
- err = db.Model(gorm_model.YounggeeSProjectInfo{}).Where("project_id = ?", projectId).Find(&sprojectinfo).Error
|
|
|
+ err = db.Model(gorm_model.YounggeeSProjectInfo{}).Where(" s_project_id =?", req.SProjectId).Find(&sprojectinfo).Error
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
sprojectinfo.RecruitNum += 1
|
|
|
- err = tx.Model(gorm_model.YounggeeSProjectInfo{}).Where("project_id = ? ", projectId).Updates(projectinfo).Error
|
|
|
+ fmt.Println("......", projectinfo.RecruitNum)
|
|
|
+ err = tx.Model(gorm_model.YounggeeSProjectInfo{}).Where(" s_project_id =?", req.SProjectId).Updates(sprojectinfo).Error
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if project.ProjectForm != 1 { //非签收截止时间
|
|
|
+ var draft_default gorm_model.InfoAutoTask
|
|
|
+ err = db.Model(gorm_model.InfoAutoTask{}).Where("auto_task_id = ?", project.AutoTaskID).Find(&draft_default).Error
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ duration := time.Duration(draft_default.DraftDefault) * time.Hour
|
|
|
+ upbreakdate := gorm_model.YoungeeTaskInfo{
|
|
|
+ CurBreakAt: time.Now().Add(duration),
|
|
|
+ }
|
|
|
+ err = tx.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ? ", taskInfo.TaskID).Updates(upbreakdate).Error
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if taskInfo.SupplierId == 0 && taskInfo.SupplierStatus == 0 { //来源于公海
|
|
|
updateData := gorm_model.YoungeeTaskInfo{
|
|
|
TaskStage: taskstages,
|
|
@@ -185,6 +278,7 @@ func PassProTaskCoop(ctx context.Context, projectId string, taskIds []string, op
|
|
|
UpdateAt: time.Now(),
|
|
|
BOperator: operatorid,
|
|
|
BOperatorType: operatetype,
|
|
|
+ SelectDate: time.Now(),
|
|
|
}
|
|
|
err = tx.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ? AND task_stage = 1", taskInfo.TaskID).Updates(updateData).Error
|
|
|
if err != nil {
|
|
@@ -252,6 +346,7 @@ func RefuseproTaskCoop(ctx context.Context, taskIds []string, operatorid string,
|
|
|
UpdateAt: time.Now(),
|
|
|
BOperator: operatorid,
|
|
|
BOperatorType: operatetype,
|
|
|
+ CompleteDate: time.Now(),
|
|
|
}
|
|
|
err = tx.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ? AND task_stage = 1", taskInfo.TaskID).Updates(updateData).Error
|
|
|
}
|
|
@@ -293,7 +388,10 @@ func GetPreSketchList(ctx context.Context, request http_model.PreSketchListReque
|
|
|
return nil, err
|
|
|
}
|
|
|
taskInfoPointers := make([]*http_model.TasksketchInfo, 0, len(projecrtaskinfo))
|
|
|
+
|
|
|
for _, task := range projecrtaskinfo {
|
|
|
+ nickname, headurl := getTalentinfo(db, task.TalentID)
|
|
|
+ Iscoop := getIscoop(db, task.TalentID, request.EnterpriseId)
|
|
|
taskinfo := &http_model.TaskInfo{
|
|
|
TaskId: task.TaskID,
|
|
|
ProjectId: task.ProjectID,
|
|
@@ -306,10 +404,13 @@ func GetPreSketchList(ctx context.Context, request http_model.PreSketchListReque
|
|
|
Commentavg: task.CommitAvg,
|
|
|
CurrentDefaultType: task.CurDefaultType,
|
|
|
From: determineFrom(task.SupplierId, task.SupplierStatus),
|
|
|
+ NickName: nickname,
|
|
|
+ HeadUrl: headurl,
|
|
|
+ ISCoop: Iscoop,
|
|
|
}
|
|
|
response := &http_model.TasksketchInfo{
|
|
|
Task: taskinfo,
|
|
|
- DDl: time.Now(), //截止时间再改
|
|
|
+ DDl: task.CurBreakAt,
|
|
|
}
|
|
|
taskInfoPointers = append(taskInfoPointers, response)
|
|
|
|
|
@@ -364,11 +465,13 @@ func GetSketchList(ctx context.Context, request http_model.TasksketchlistRequest
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+ boperator := getBOperator(db, task.BOperator, task.BOperatorType)
|
|
|
response := &http_model.Tasksketchinfo{
|
|
|
Task: taskinfo,
|
|
|
SketchId: sketchinfo.SketchID,
|
|
|
SubmitAt: sketchinfo.SubmitAt,
|
|
|
AgreeAt: sketchinfo.AgreeAt,
|
|
|
+ Operator: boperator,
|
|
|
}
|
|
|
taskInfoPointers = append(taskInfoPointers, response)
|
|
|
|
|
@@ -405,6 +508,8 @@ func GetPreLinkList(ctx context.Context, request http_model.PreLinkListRequest)
|
|
|
}
|
|
|
taskInfoPointers := make([]*http_model.Tasklinkinfo, 0, len(projecrtaskinfo))
|
|
|
for _, task := range projecrtaskinfo {
|
|
|
+ nickname, headurl := getTalentinfo(db, task.TalentID)
|
|
|
+ Iscoop := getIscoop(db, task.TalentID, request.EnterpriseId)
|
|
|
taskinfo := &http_model.TaskInfo{
|
|
|
TaskId: task.TaskID,
|
|
|
ProjectId: task.ProjectID,
|
|
@@ -417,10 +522,13 @@ func GetPreLinkList(ctx context.Context, request http_model.PreLinkListRequest)
|
|
|
Commentavg: task.CommitAvg,
|
|
|
CurrentDefaultType: task.CurDefaultType,
|
|
|
From: determineFrom(task.SupplierId, task.SupplierStatus),
|
|
|
+ NickName: nickname,
|
|
|
+ HeadUrl: headurl,
|
|
|
+ ISCoop: Iscoop,
|
|
|
}
|
|
|
response := &http_model.Tasklinkinfo{
|
|
|
Task: taskinfo,
|
|
|
- DDl: time.Now(), //截止时间再改
|
|
|
+ DDl: task.CurBreakAt,
|
|
|
}
|
|
|
taskInfoPointers = append(taskInfoPointers, response)
|
|
|
|
|
@@ -457,6 +565,8 @@ func GetLinkList(ctx context.Context, request http_model.TaskLinklistRequest) (*
|
|
|
}
|
|
|
taskInfoPointers := make([]*http_model.TaskLinkinfo, 0, len(projecrtaskinfo))
|
|
|
for _, task := range projecrtaskinfo {
|
|
|
+ nickname, headurl := getTalentinfo(db, task.TalentID)
|
|
|
+ Iscoop := getIscoop(db, task.TalentID, request.EnterpriseId)
|
|
|
taskinfo := &http_model.TaskInfo{
|
|
|
TaskId: task.TaskID,
|
|
|
ProjectId: task.ProjectID,
|
|
@@ -469,12 +579,16 @@ func GetLinkList(ctx context.Context, request http_model.TaskLinklistRequest) (*
|
|
|
Commentavg: task.CommitAvg,
|
|
|
CurrentDefaultType: task.CurDefaultType,
|
|
|
From: determineFrom(task.SupplierId, task.SupplierStatus),
|
|
|
+ NickName: nickname,
|
|
|
+ HeadUrl: headurl,
|
|
|
+ ISCoop: Iscoop,
|
|
|
}
|
|
|
var linkinfo gorm_model.YounggeeLinkInfo
|
|
|
err := db.Model(&gorm_model.YounggeeLinkInfo{}).Where("task_id = ? and is_review = 0", task.TaskID).First(&linkinfo).Error
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+ boperator := getBOperator(db, task.BOperator, task.BOperatorType)
|
|
|
response := &http_model.TaskLinkinfo{
|
|
|
Task: taskinfo,
|
|
|
LinkId: linkinfo.LinkID,
|
|
@@ -482,6 +596,7 @@ func GetLinkList(ctx context.Context, request http_model.TaskLinklistRequest) (*
|
|
|
AgreeAt: linkinfo.AgreeAt,
|
|
|
LinkUrl: linkinfo.LinkUrl,
|
|
|
PhotoUrl: linkinfo.PhotoUrl,
|
|
|
+ Operator: boperator,
|
|
|
}
|
|
|
taskInfoPointers = append(taskInfoPointers, response)
|
|
|
|
|
@@ -518,6 +633,8 @@ func GetPreDataList(ctx context.Context, request http_model.PreDataListRequest)
|
|
|
}
|
|
|
taskInfoPointers := make([]*http_model.Taskdatainfo, 0, len(projecrtaskinfo))
|
|
|
for _, task := range projecrtaskinfo {
|
|
|
+ nickname, headurl := getTalentinfo(db, task.TalentID)
|
|
|
+ Iscoop := getIscoop(db, task.TalentID, request.EnterpriseId)
|
|
|
taskinfo := &http_model.TaskInfo{
|
|
|
TaskId: task.TaskID,
|
|
|
ProjectId: task.ProjectID,
|
|
@@ -530,10 +647,13 @@ func GetPreDataList(ctx context.Context, request http_model.PreDataListRequest)
|
|
|
Commentavg: task.CommitAvg,
|
|
|
CurrentDefaultType: task.CurDefaultType,
|
|
|
From: determineFrom(task.SupplierId, task.SupplierStatus),
|
|
|
+ NickName: nickname,
|
|
|
+ HeadUrl: headurl,
|
|
|
+ ISCoop: Iscoop,
|
|
|
}
|
|
|
response := &http_model.Taskdatainfo{
|
|
|
Task: taskinfo,
|
|
|
- DDl: time.Now(), //截止时间再改
|
|
|
+ DDl: task.CurBreakAt,
|
|
|
}
|
|
|
taskInfoPointers = append(taskInfoPointers, response)
|
|
|
|
|
@@ -570,22 +690,30 @@ func GetDataList(ctx context.Context, request http_model.TaskDatalistRequest) (*
|
|
|
}
|
|
|
taskInfoPointers := make([]*http_model.TaskDatainfo, 0, len(projecrtaskinfo))
|
|
|
for _, task := range projecrtaskinfo {
|
|
|
+ nickname, headurl := getTalentinfo(db, task.TalentID)
|
|
|
+ Iscoop := getIscoop(db, task.TalentID, request.EnterpriseId)
|
|
|
taskinfo := &http_model.TaskInfo{
|
|
|
- TaskId: task.TaskID,
|
|
|
- ProjectId: task.ProjectID,
|
|
|
- TalentId: task.TalentID,
|
|
|
- FansNum: task.FansNum,
|
|
|
- DraftFee: task.DraftFee,
|
|
|
- FeeFrom: task.FeeForm,
|
|
|
- TaskStage: task.TaskStage,
|
|
|
- SettleAmount: task.SettleAmount,
|
|
|
- From: determineFrom(task.SupplierId, task.SupplierStatus),
|
|
|
+ TaskId: task.TaskID,
|
|
|
+ ProjectId: task.ProjectID,
|
|
|
+ TalentId: task.TalentID,
|
|
|
+ FansNum: task.FansNum,
|
|
|
+ DraftFee: task.DraftFee,
|
|
|
+ Voteavg: task.VoteAvg,
|
|
|
+ FeeFrom: task.FeeForm,
|
|
|
+ TaskStage: task.TaskStage,
|
|
|
+ Commentavg: task.CommitAvg,
|
|
|
+ CurrentDefaultType: task.CurDefaultType,
|
|
|
+ From: determineFrom(task.SupplierId, task.SupplierStatus),
|
|
|
+ NickName: nickname,
|
|
|
+ HeadUrl: headurl,
|
|
|
+ ISCoop: Iscoop,
|
|
|
}
|
|
|
var datainfo gorm_model.YounggeeDataInfo
|
|
|
err := db.Model(&gorm_model.YounggeeDataInfo{}).Where("task_id = ? and is_review = 0", task.TaskID).First(&datainfo).Error
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+ boperator := getBOperator(db, task.BOperator, task.BOperatorType)
|
|
|
response := &http_model.TaskDatainfo{
|
|
|
Task: taskinfo,
|
|
|
DataId: datainfo.DataID,
|
|
@@ -596,6 +724,9 @@ func GetDataList(ctx context.Context, request http_model.TaskDatalistRequest) (*
|
|
|
LikeNumber: datainfo.LikeNumber,
|
|
|
CollectNumber: datainfo.CollectNumber,
|
|
|
CommentNumber: datainfo.CommentNumber,
|
|
|
+ SettleAmount: task.SettleAmount,
|
|
|
+ Breakrate: task.SketchBreakRate + task.LinkBreakRate + task.DataBreakRate,
|
|
|
+ Operator: boperator,
|
|
|
}
|
|
|
taskInfoPointers = append(taskInfoPointers, response)
|
|
|
|