|
@@ -1,13 +1,12 @@
|
|
|
package youngee_sectask_service
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"github.com/gogf/gf/frame/g"
|
|
|
"github.com/gogf/gf/net/ghttp"
|
|
|
- "strconv"
|
|
|
"youngmini_server/app/dao"
|
|
|
"youngmini_server/app/model"
|
|
|
"youngmini_server/app/model/youngee_talent_model"
|
|
|
- "youngmini_server/app/system/sectask"
|
|
|
"youngmini_server/app/utils"
|
|
|
)
|
|
|
|
|
@@ -18,91 +17,37 @@ func GetExeSecTaskList(r *ghttp.Request) *TalentHttpResult {
|
|
|
return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
}
|
|
|
taskStageKey := r.GetQueryInt("taskStage", 0)
|
|
|
- var whereCondition g.Map
|
|
|
+ var whereStr string
|
|
|
switch taskStageKey {
|
|
|
case 4:
|
|
|
- // 获取 TaskStage >= 2 且 <= 10 的数据
|
|
|
- whereCondition = g.Map{
|
|
|
- dao.YounggeeSecTaskInfo.Columns.TalentId: tid,
|
|
|
- dao.YounggeeSecTaskInfo.Columns.TaskStage: g.Slice{2, 3, 4, 5, 6, 7, 8, 9, 10},
|
|
|
- }
|
|
|
+ // 返回指定talentId的所有数据
|
|
|
+ whereStr = fmt.Sprintf("talent_id='%s'", tid)
|
|
|
case 5:
|
|
|
- // 获取 TaskStage = 9 的数据
|
|
|
- whereCondition = g.Map{
|
|
|
- dao.YounggeeSecTaskInfo.Columns.TalentId: tid,
|
|
|
- dao.YounggeeSecTaskInfo.Columns.TaskStage: 9,
|
|
|
- }
|
|
|
+ // 返回待领悬赏
|
|
|
+ whereStr = fmt.Sprintf("talent_id='%s' AND reward_stage = 1", tid)
|
|
|
default:
|
|
|
return &TalentHttpResult{Code: -2, Msg: "parse param error"}
|
|
|
}
|
|
|
|
|
|
- // 获取任务列表
|
|
|
- //var taskList []*model.YounggeeSecTaskInfo
|
|
|
- var SecTask []*sectask.ListSecTaskSql
|
|
|
-
|
|
|
- err = g.Model(dao.YounggeeSecTaskInfo.Table).Where(whereCondition).Scan(&SecTask)
|
|
|
+ //查task表全部数据
|
|
|
+ var secTaskInfoList []youngee_talent_model.SecTaskInfoDetail
|
|
|
+ err = g.DB().Model(youngee_talent_model.SecTaskInfoDetail{}).WithAll().
|
|
|
+ Where(whereStr).
|
|
|
+ Order("task_ddl DESC").
|
|
|
+ Scan(&secTaskInfoList)
|
|
|
if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: err.Error()}
|
|
|
}
|
|
|
|
|
|
- platformMap := make(map[string]model.InfoThirdPlatform)
|
|
|
- var platformInfo []*model.InfoThirdPlatform
|
|
|
- if len(SecTask) != 0 {
|
|
|
- err := g.Model(dao.InfoThirdPlatform.Table).Scan(&platformInfo)
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get platform failed"}
|
|
|
- }
|
|
|
-
|
|
|
- for i, _ := range platformInfo {
|
|
|
- platformMap[strconv.Itoa(platformInfo[i].PlatformId)] = *platformInfo[i]
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 为每个任务根据项目id查询项目名称和主图
|
|
|
- var taskBriefList []*youngee_talent_model.SecTaskInfoBrief
|
|
|
- for _, v := range SecTask {
|
|
|
- whereCondition = g.Map{
|
|
|
- dao.YounggeeSelectionInfo.Columns.SelectionId: v.SelectionId,
|
|
|
- }
|
|
|
- selectionInfo, err := g.Model(dao.YounggeeSelectionInfo.Table).Where(whereCondition).One()
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
|
|
|
- }
|
|
|
- whereCondition = g.Map{
|
|
|
- dao.YoungeePlatformAccountInfo.Columns.PlatformId: selectionInfo[dao.YounggeeSelectionInfo.Columns.Platform],
|
|
|
- dao.YoungeePlatformAccountInfo.Columns.TalentId: v.TalentId,
|
|
|
- }
|
|
|
- account, err := g.Model(dao.YoungeePlatformAccountInfo.Table).Where(whereCondition).One()
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get account info failed"}
|
|
|
- }
|
|
|
- taskInfoBrief := &youngee_talent_model.SecTaskInfoBrief{
|
|
|
- TaskId: v.TaskId,
|
|
|
- PlatformIconUrl: platformMap[selectionInfo[dao.YounggeeSelectionInfo.Columns.Platform].String()].PlatformIcon,
|
|
|
- PlatformName: platformMap[selectionInfo[dao.YounggeeSelectionInfo.Columns.Platform].String()].PlatformName,
|
|
|
- PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
|
|
|
- SelectionName: selectionInfo[dao.YounggeeSelectionInfo.Columns.SelectionName].String(),
|
|
|
- ProductPhotoSnap: selectionInfo[dao.YounggeeSelectionInfo.Columns.ProductPhotoSnap].String(),
|
|
|
- TaskStatus: v.TaskStatus,
|
|
|
- TaskStage: v.TaskStage,
|
|
|
- AssignmentStatus: v.AssignmentStatus,
|
|
|
- TaskReward: v.TaskReward,
|
|
|
- TalentPayment: v.TalentPayment,
|
|
|
- SampleMode: v.SampleMode,
|
|
|
- TaskDdl: v.TaskDdl,
|
|
|
- }
|
|
|
- taskBriefList = append(taskBriefList, taskInfoBrief)
|
|
|
- }
|
|
|
-
|
|
|
- return &TalentHttpResult{Code: 0, Msg: "success", Data: taskBriefList}
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: secTaskInfoList}
|
|
|
}
|
|
|
|
|
|
// 获取选品任务详情
|
|
|
func GetSecTaskDetail(r *ghttp.Request) *TalentHttpResult {
|
|
|
taskId := r.GetQueryInt("task_id", -1)
|
|
|
|
|
|
- var secTask *model.YounggeeSecTaskInfo
|
|
|
- err := g.Model(dao.YounggeeSecTaskInfo.Table).Where("task_id = ?", taskId).Scan(&secTask)
|
|
|
+ var secTask *youngee_talent_model.SecTaskInfoDetail
|
|
|
+ err := g.DB().Model("younggee_sec_task_info").WithAll().Where("task_id = ?", taskId).Scan(&secTask)
|
|
|
if err != nil {
|
|
|
g.Log().Error("Get selection task info failed: " + err.Error())
|
|
|
return &TalentHttpResult{Code: -1, Msg: "Get task info failed"}
|
|
@@ -149,3 +94,21 @@ func GetSecTaskDetail(r *ghttp.Request) *TalentHttpResult {
|
|
|
|
|
|
return &TalentHttpResult{Code: 0, Msg: "success", Data: taskDetail}
|
|
|
}
|
|
|
+
|
|
|
+// 带货是否满足悬赏条件 if 满足 更新状态
|
|
|
+func UpdateRewardStage(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ //达人id获取
|
|
|
+ tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
+ sid := r.GetQueryString("selection_id")
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent id failed"}
|
|
|
+ }
|
|
|
+ SecTaskInfo := &youngee_talent_model.SecTaskInfoDetail{}
|
|
|
+ _, err = g.DB().Model(SecTaskInfo).Data("reward_stage", 1).Where("talent_id =? and selection_id =?", tid, sid).Update()
|
|
|
+ if err != nil {
|
|
|
+ // 查询失败(未找到结果),返回失败结果
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "update failed", Data: nil}
|
|
|
+ }
|
|
|
+ // 查询成功,返回成功结果和数据
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: SecTaskInfo}
|
|
|
+}
|