|
@@ -11,7 +11,9 @@ import (
|
|
|
"sort"
|
|
|
"strconv"
|
|
|
"youngmini_server/app/dao"
|
|
|
+ "youngmini_server/app/model"
|
|
|
"youngmini_server/app/model/youngee_talent_model"
|
|
|
+ "youngmini_server/app/service/youngee_talent_service"
|
|
|
"youngmini_server/app/utils"
|
|
|
)
|
|
|
|
|
@@ -335,3 +337,254 @@ func GetLocalLifeDetail(r *ghttp.Request) *TalentHttpResult {
|
|
|
|
|
|
return &TalentHttpResult{Code: 0, Msg: "success", Data: LocalDetail}
|
|
|
}
|
|
|
+
|
|
|
+// 查询所有任务
|
|
|
+func GetLocalTaskBriefList(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构造查询条件
|
|
|
+ whereStr := fmt.Sprintf("talent_id = '%s'", tid)
|
|
|
+
|
|
|
+ // 获取任务列表
|
|
|
+ var taskList []*youngee_talent_model.YoungeeLocalTaskInfo
|
|
|
+ //此达人下,所有快手账号的任务都展示
|
|
|
+ err = g.Model("youngee_local_task_info").Where(whereStr).Scan(&taskList)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ //后续根据 PlatformId 快速查找平台信息。platformMap的key是PlatformId,value是平台具体描述
|
|
|
+ platformMap := make(map[string]model.InfoThirdPlatform)
|
|
|
+ platformInfo := []*model.InfoThirdPlatform{}
|
|
|
+ if len(taskList) != 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查询项目名称和主图
|
|
|
+ //taskBriefList存了各个阶段的tasklist
|
|
|
+ taskBriefList := youngee_talent_model.LocalTaskInfoBriefList{}
|
|
|
+ for _, v := range taskList { //taskList含所有任务
|
|
|
+ //获取具体的招募策略,taskInfo中
|
|
|
+ var localDetail *youngee_talent_model.LocalInfoDetail
|
|
|
+ err := g.Model("younggee_local_life_info").WithAll().Where("local_id = ?", v.LocalId).Scan(&localDetail)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
|
|
|
+ }
|
|
|
+ var account *youngee_talent_model.KuaishouUserInfo
|
|
|
+ fmt.Println("openid---->", v.OpenId)
|
|
|
+ err = g.Model("platform_kuaishou_user_info").Where("platform_id = ? and talent_id = ? and open_id = ?", localDetail.LocalPlatform, tid, v.OpenId).Scan(&account)
|
|
|
+ //拿快手平台验证是否过期
|
|
|
+ expired := youngee_talent_service.CheckKuaishouTokenExp(account.OpenId)
|
|
|
+ account.Expired = expired
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get account info failed"}
|
|
|
+ }
|
|
|
+ //taskInfoBrief含需要展示在页面的内容,被加入各阶段List
|
|
|
+ taskInfoBrief := &youngee_talent_model.LocalTaskInfoBrief{
|
|
|
+ TaskId: v.TaskId,
|
|
|
+ PlatformIconUrl: platformMap[strconv.Itoa(localDetail.PlatformInfo.PlatformId)].PlatformIcon,
|
|
|
+ //PlatformName: platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
|
|
|
+ //PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
|
|
|
+
|
|
|
+ ProjectName: localDetail.LocalName,
|
|
|
+ //ProductPhotoSnap: localDetail.ProductPhotoSnap,
|
|
|
+ TaskStatus: v.TaskStatus,
|
|
|
+ TaskStage: v.TaskStage,
|
|
|
+ LinkStatus: v.LinkStatus,
|
|
|
+ DataStatus: v.DataStatus,
|
|
|
+ //ScriptStatus: v.ScriptStatus,
|
|
|
+ SketchStatus: v.SketchStatus,
|
|
|
+ TaskReward: v.TaskReward,
|
|
|
+ BreakRate: v.ScriptBreakRate + v.SketchBreakRate + v.LinkBreakRate + v.DataBreakRate,
|
|
|
+ CurBreakAt: v.CurBreakAt,
|
|
|
+ FeeForm: v.FeeForm,
|
|
|
+ LocalDetail: localDetail,
|
|
|
+ TaskInfo: v,
|
|
|
+ AccountInfo: account, //含是否过期,粉丝数,作品数目
|
|
|
+
|
|
|
+ }
|
|
|
+ taskBriefList.AllTaskInfoList = append(taskBriefList.AllTaskInfoList, taskInfoBrief)
|
|
|
+
|
|
|
+ if v.TaskStage <= 2 {
|
|
|
+ taskBriefList.SignUpTaskInfoList = append(taskBriefList.SignUpTaskInfoList, taskInfoBrief)
|
|
|
+ } else if v.TaskStage == 4 { //如果是线下探店
|
|
|
+ taskBriefList.WaitBookList = append(taskBriefList.WaitBookList, taskInfoBrief)
|
|
|
+ } else if v.TaskStage <= 14 && v.TaskStage >= 5 {
|
|
|
+ taskBriefList.GoingOnTaskInfoList = append(taskBriefList.GoingOnTaskInfoList, taskInfoBrief)
|
|
|
+ } else {
|
|
|
+ taskBriefList.CompletedTaskInfoList = append(taskBriefList.CompletedTaskInfoList, taskInfoBrief)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: taskBriefList}
|
|
|
+}
|
|
|
+
|
|
|
+func GetLocalTaskDetail(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ taskId := r.GetQueryInt("task_id", -1)
|
|
|
+
|
|
|
+ var task *youngee_talent_model.YoungeeLocalTaskInfo
|
|
|
+ err := g.Model("youngee_local_task_info").Where("task_id = ?", taskId).Scan(&task)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get task info failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ var localDetail *youngee_talent_model.LocalInfoDetail
|
|
|
+ err = g.Model(youngee_talent_model.ProjectDetail{}).WithAll().Where("local_id", task.LocalId).Scan(&localDetail)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -3, Msg: "data query failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ var productPhoto *youngee_talent_model.YounggeeProductPhoto
|
|
|
+ err = g.Model("younggee_product_photo").Where("store_id = ? and symbol = 1", localDetail.StoreId).Scan(&productPhoto)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -3, Msg: "data query failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ var withdrawStatus = 1
|
|
|
+ var taskIncome *model.YounggeeTalentIncome
|
|
|
+ err = g.Model(dao.YounggeeTalentIncome.Table).Where("task_id = ? and income_type = 1", taskId).Scan(&taskIncome)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -3, Msg: "Get task income detail failed."}
|
|
|
+ }
|
|
|
+ if taskIncome != nil {
|
|
|
+ withdrawStatus = taskIncome.WithdrawStatus + 1
|
|
|
+ }
|
|
|
+
|
|
|
+ taskDetail := &youngee_talent_model.LocalTaskDetail{}
|
|
|
+ if localDetail.LocalType == 1 {
|
|
|
+ var strategy *youngee_talent_model.RecruitStrategy
|
|
|
+ err = g.Model(dao.RecruitStrategy.Table).Where("local_id = ? and strategy_id = ?", task.LocalId, task.StrategyId).Scan(&strategy)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -3, Msg: "data query failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ taskDetail = &youngee_talent_model.LocalTaskDetail{
|
|
|
+ TaskInfo: task,
|
|
|
+ LocalDetail: localDetail,
|
|
|
+ ProductPhoto: productPhoto,
|
|
|
+ Strategy: strategy,
|
|
|
+ WithdrawStatus: withdrawStatus,
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ taskDetail = &youngee_talent_model.LocalTaskDetail{
|
|
|
+ TaskInfo: task,
|
|
|
+ LocalDetail: localDetail,
|
|
|
+ ProductPhoto: productPhoto,
|
|
|
+ WithdrawStatus: withdrawStatus,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: taskDetail}
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+func GetLocalTaskBook(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ taskId := r.Get("task_id")
|
|
|
+ res, err := g.DB().Model("younggee_book_info").Where("is_review = 1 and task_id = ?", taskId).OrderDesc("create_at").All()
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: err.Error()}
|
|
|
+ }
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: res}
|
|
|
+}
|
|
|
+
|
|
|
+// 添加初稿service done
|
|
|
+func AddLocalTaskBook(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ var bookInfoReq *youngee_talent_model.AddLocalTaskBookRequest
|
|
|
+ //解析添加初稿的图文
|
|
|
+ err := r.ParseForm(&bookInfoReq)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: err.Error()}
|
|
|
+ }
|
|
|
+
|
|
|
+ taskbookInfo := []youngee_talent_model.LocalTaskBookInfo{}
|
|
|
+
|
|
|
+ err = g.DB().Model("younggee_book_info").Where("task_id = ? ", bookInfoReq.TaskId).OrderDesc("create_at").Scan(&taskbookInfo)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -2, Msg: "YounggeeSketchInfo find failed"}
|
|
|
+ }
|
|
|
+ //上传过但是被拒了
|
|
|
+ var condition1 bool = len(taskbookInfo) != 0 && taskbookInfo[0].IsReview == 1 && taskbookInfo[0].IsOk == 0
|
|
|
+ //没有上传过初稿
|
|
|
+ var condition2 bool = len(taskbookInfo) == 0
|
|
|
+
|
|
|
+ bookInfo := youngee_talent_model.LocalTaskBookInfo{
|
|
|
+ TaskId: bookInfoReq.TaskId,
|
|
|
+ Day: bookInfoReq.Day,
|
|
|
+ Time: bookInfoReq.Time,
|
|
|
+ CreateAt: gtime.Now(),
|
|
|
+ IsReview: 0,
|
|
|
+ IsSubmit: 0, //忽略
|
|
|
+ IsOk: 0,
|
|
|
+ }
|
|
|
+ //只有这两种情况才能上传探店时间
|
|
|
+ if condition1 || condition2 {
|
|
|
+ //插入新数据
|
|
|
+ _, err := g.DB().Model("younggee_book_info").Data(bookInfo).InsertAndGetId()
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchInfo insert failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改task表中的字段待添加变成已添加,待修改变成已修改
|
|
|
+ bookStatus, err := g.DB().Model(model.YoungeeTaskInfo{}).Fields("book_status").Where("task_id = ?", bookInfoReq.TaskId).Value()
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -5, Msg: "Get task info failed"}
|
|
|
+ }
|
|
|
+ if bookStatus.Int64() == 1 {
|
|
|
+ _, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", bookInfoReq.TaskId).Update(g.Map{"bookStatus": 2})
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
|
|
|
+ }
|
|
|
+ } else if bookStatus.Int64() == 3 {
|
|
|
+ _, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", bookInfoReq.TaskId).Update(g.Map{"bookStatus": 4})
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //task设置为预约确认中
|
|
|
+ _, err = g.DB().Model("youngee_local_task_info").Data(g.Map{"task_stage": "5"}).Where("task_id = ?", bookInfoReq.TaskId).Update()
|
|
|
+
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success"}
|
|
|
+}
|
|
|
+
|
|
|
+func AddLocalTaskPhoto(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ var bookInfoReq *youngee_talent_model.AddLocalTaskPhotoRequest
|
|
|
+ //解析添加初稿的图文
|
|
|
+ err := r.ParseForm(&bookInfoReq)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: err.Error()}
|
|
|
+ }
|
|
|
+
|
|
|
+ bookPhotoInfo := youngee_talent_model.YounggeeBookPhoto{
|
|
|
+ TaskId: bookInfoReq.TaskId,
|
|
|
+ PhotoUrl: bookInfoReq.PhotoUrl,
|
|
|
+ CreateAt: gtime.Now(),
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改task表中的字段待添加变成已添加,待修改变成已修改
|
|
|
+ _, err = g.DB().Model("younggee_book_photo").Data(&bookPhotoInfo).Insert()
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -5, Msg: "Get task info failed"}
|
|
|
+ }
|
|
|
+ _, err = g.DB().Model("youngee_local_task_info").Where("task_id = ?", bookInfoReq.TaskId).Data(g.Map{"task_stage": 9}).Update()
|
|
|
+ _, err = g.DB().Model("youngee_local_task_info").Where("task_id = ?", bookInfoReq.TaskId).Data(g.Map{"book_status": 5}).Update()
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -5, Msg: "Get task info failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success"}
|
|
|
+}
|