local_life_info.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. package youngee_task_service
  2. import (
  3. "fmt"
  4. "github.com/gogf/gf/frame/g"
  5. "github.com/gogf/gf/net/ghttp"
  6. "github.com/gogf/gf/os/glog"
  7. "github.com/gogf/gf/os/gtime"
  8. "github.com/gogf/gf/util/gconv"
  9. "math"
  10. "sort"
  11. "strconv"
  12. "strings"
  13. "youngmini_server/app/dao"
  14. "youngmini_server/app/model"
  15. "youngmini_server/app/model/youngee_talent_model"
  16. "youngmini_server/app/utils"
  17. )
  18. func GetLocalLifeList(r *ghttp.Request) *TalentHttpResult {
  19. pageIndex := r.GetQueryInt("idx", -1)
  20. cntPerPage := r.GetQueryInt("cnt", -1)
  21. //组合筛选
  22. platform := r.Get("platform", nil) //抖音、快手、红Book、B站、微博
  23. taskForm := r.Get("task_form", nil) //任务形式,1-2分别代表线下探店,素材分发
  24. contentType := r.Get("contenttype", nil) //图文形式、视频形式
  25. createTime := r.Get("createTime", nil) //任务上线时间
  26. //todo 城市参数?
  27. //Location := r.GetQueryString("city", "") //门店store所属城市,
  28. //排根据浏览量排序
  29. viewOrder := r.GetQueryInt("pageViewOrder", -1) //根据哪个字段排序
  30. //仅稿费”+“稿费+赠品"。这个在recruit表中,得到列表之后进行排序
  31. feeForm := r.GetInt("feeform", 0)
  32. searchValue := r.Get("searchvalue")
  33. if pageIndex == -1 || cntPerPage == -1 || cntPerPage == 0 {
  34. return &TalentHttpResult{Code: -1, Msg: "参数错误"}
  35. }
  36. // 构造查询的条件
  37. startId := pageIndex * cntPerPage
  38. // whereStr := fmt.Sprintf("(project_status >= %d and project_status <> %d and project_type = 1)", projectStatusRecruiting, projectStatusInvalid)
  39. whereStr := fmt.Sprintf("(task_status >= %d and local_type = 1)", projectStatusRecruiting)
  40. if taskForm != nil {
  41. whereStr += " and task_mode = " + taskForm.(string)
  42. }
  43. if createTime != nil {
  44. switch createTime.(string) {
  45. case "1": // 近7天
  46. whereStr += " AND created_at >= (NOW() - INTERVAL 7 DAY)"
  47. case "2": // 近30天
  48. whereStr += " AND created_at >= (NOW() - INTERVAL 30 DAY)"
  49. case "3": // 近90天
  50. whereStr += " AND created_at >= (NOW() - INTERVAL 90 DAY)"
  51. default:
  52. // 无效的过滤条件,跳过
  53. return &TalentHttpResult{
  54. Code: -2,
  55. Msg: "无效的创建时间过滤条件",
  56. }
  57. }
  58. }
  59. if contentType != nil {
  60. whereStr += " and content_type = " + contentType.(string)
  61. }
  62. if platform != nil {
  63. whereStr += " and local_platform = " + platform.(string)
  64. }
  65. if searchValue != nil {
  66. whereStr += " and local_name like '%" + searchValue.(string) + "%'"
  67. }
  68. fmt.Println("whereStr:-----》 ", whereStr)
  69. // 查询所有project
  70. var localList = []youngee_talent_model.YounggeeLocalLifeInfo{}
  71. err := g.Model("younggee_local_life_info").Where(whereStr).Scan(&localList)
  72. if err != nil {
  73. return &TalentHttpResult{Code: -3, Msg: "查询数据库失败"}
  74. }
  75. // 判断请求页面是否超过最大页面
  76. c, err := g.DB().Model("younggee_local_life_info").Fields("local_id").Where(whereStr).Count()
  77. if c <= 0 {
  78. return &TalentHttpResult{Code: -4, Msg: "has no fullproject", Data: nil}
  79. }
  80. maxPage := c / cntPerPage
  81. if c%cntPerPage > 0 {
  82. maxPage += 1
  83. }
  84. if pageIndex+1 > maxPage {
  85. return &TalentHttpResult{Code: -5, Msg: "over max page"}
  86. }
  87. var localInfoList = youngee_talent_model.LocalInfoList{}
  88. err = g.DB().Model("younggee_local_life_info").WithAll().Where(whereStr).
  89. Order("task_status ASC,recruit_ddl DESC").Limit(startId, cntPerPage).Scan(&localInfoList.LocalInfos)
  90. if err != nil {
  91. return &TalentHttpResult{Code: -6, Msg: err.Error()}
  92. }
  93. // 遍历projectList
  94. for i, local := range localInfoList.LocalInfos {
  95. //处理浏览量
  96. localViewKey := "local:view:" + gconv.String(local.LocalId)
  97. //redis中取浏览量 返回的是gvar.Var类型。 不存咋则为nil。经过viewCount.Int变成0
  98. viewCount, err := g.Redis().DoVar("GET", localViewKey)
  99. if err != nil {
  100. glog.Error(err)
  101. return &TalentHttpResult{Code: 0, Msg: "Redis error"}
  102. }
  103. localInfoList.LocalInfos[i].WatchNum = viewCount.Int()
  104. // 根据 WatchedNum 从高到低排序
  105. if viewOrder != -1 {
  106. sort.Slice(localInfoList.LocalInfos, func(i, j int) bool {
  107. return localInfoList.LocalInfos[i].WatchNum > localInfoList.LocalInfos[j].WatchNum
  108. })
  109. }
  110. // 统计 RecruitStrategys 数组中的最低粉丝量和最高粉丝量
  111. var minFollowers, maxFollowers int
  112. // 初始值可以设为极大/极小值
  113. minFollowers = math.MaxInt32
  114. maxFollowers = math.MinInt32
  115. // 遍历 RecruitStrategys,找出最低粉丝量和最高粉丝量
  116. for _, strategy := range local.RecruitStrategys {
  117. if strategy.FollowersLow < minFollowers {
  118. minFollowers = strategy.FollowersLow
  119. }
  120. if strategy.FollowersUp > maxFollowers {
  121. maxFollowers = strategy.FollowersUp
  122. }
  123. }
  124. // 如果需要,可以将这些值保存到 ProjectInfo 中,供后续使用
  125. localInfoList.LocalInfos[i].MinFollowers = minFollowers
  126. localInfoList.LocalInfos[i].MaxFollowers = maxFollowers
  127. //稿费的展示情况
  128. allFeeFormNoFee := true // 假设都是无费置换
  129. var hasSelfPrice bool
  130. var minOffer, maxOffer int
  131. for _, strategy := range local.RecruitStrategys {
  132. if strategy.FeeForm != 1 { // 如果存在非无费置换的策略
  133. allFeeFormNoFee = false
  134. }
  135. if strategy.FeeForm == 3 { // 存在自报价
  136. hasSelfPrice = true
  137. }
  138. if strategy.FeeForm == 2 { // 一口价策略
  139. if strategy.TOffer < minOffer || minOffer == 0 {
  140. minOffer = strategy.TOffer
  141. }
  142. if strategy.TOffer > maxOffer {
  143. maxOffer = strategy.TOffer
  144. }
  145. }
  146. }
  147. // 根据判断结果设置 IsShowOffer 和 HaveSelfPrice
  148. if allFeeFormNoFee {
  149. local.IsShowOffer = 2 // 不展示稿费
  150. } else {
  151. local.IsShowOffer = 1 // 展示稿费
  152. if hasSelfPrice {
  153. local.HaveSelfOffer = 1 //存在自报价
  154. } else {
  155. local.HaveSelfOffer = 2 //不存在自报价
  156. }
  157. localInfoList.LocalInfos[i].MaxOffer = maxOffer
  158. localInfoList.LocalInfos[i].MinOffer = minOffer
  159. }
  160. }
  161. localInfoList.MaxPage = maxPage
  162. var filteredLocalInfo []*youngee_talent_model.YounggeeLocalLifeInfo
  163. //筛选出“仅稿费”+“稿费+赠品”任务,
  164. //只要策略中有 无费置换 之外的fee_form就是有稿费,donate=1就是有赠品
  165. if feeForm != 0 {
  166. for _, local := range localInfoList.LocalInfos {
  167. if local.Donate == 1 {
  168. filteredLocalInfo = append(filteredLocalInfo, local)
  169. continue // 如果满足条件1,直接跳过后续条件判断
  170. }
  171. // 条件2:RecruitStrategy 中存在 fee_form 不等于 1 的数据
  172. for _, strategy := range local.RecruitStrategys {
  173. if strategy.FeeForm != 1 {
  174. filteredLocalInfo = append(filteredLocalInfo, local)
  175. break // 找到符合条件的策略,跳出当前循环,避免重复添加
  176. }
  177. }
  178. }
  179. localInfoList.LocalInfos = filteredLocalInfo
  180. }
  181. return &TalentHttpResult{Code: 0, Msg: "success", Data: localInfoList}
  182. }
  183. func GetLocalLifeDetail(r *ghttp.Request) *TalentHttpResult {
  184. tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
  185. local_id := r.GetQueryString("local_id", "")
  186. s_local_id := r.GetQueryString("s_local_id", "")
  187. localInfoSupplier := youngee_talent_model.LocalInfoSupplier{}
  188. if s_local_id != "" {
  189. // 来自服务商
  190. err := g.DB().Model("younggee_s_local__info").Where("s_local_id=?", s_local_id).Scan(&localInfoSupplier)
  191. if err != nil {
  192. fmt.Println("projectInfoSupplier err:", err.Error())
  193. }
  194. }
  195. // Redis key
  196. loalViewKey := "local:view:" + local_id
  197. userViewedKey := "user:viewed:" + tid + ":" + local_id
  198. if local_id == "" {
  199. return &TalentHttpResult{Code: -2, Msg: "parse param error"}
  200. }
  201. //在redis中增加浏览量
  202. // Check if the user has already viewed the product
  203. //DoVar方便进行类型转化
  204. viewed, err := g.Redis().DoVar("GET", userViewedKey)
  205. if err != nil {
  206. glog.Error(err)
  207. return &TalentHttpResult{Code: 0, Msg: "Redis error"}
  208. }
  209. var talentCategory []*youngee_talent_model.YounggeeTalentCategory
  210. err = g.DB().Model("younggee_talent_category").Scan(&talentCategory)
  211. if err != nil {
  212. // 处理查询错误
  213. return &TalentHttpResult{Code: -1, Msg: err.Error()}
  214. }
  215. // 创建一个数字到汉字的映射
  216. categoryMap := make(map[string]string)
  217. for _, category := range talentCategory {
  218. categoryMap[fmt.Sprint(category.Id)] = category.Category
  219. }
  220. var LocalDetail *youngee_talent_model.LocalInfoDetail
  221. err = g.DB().Model("younggee_local_life_info").WithAll().Where("local_id", local_id).Scan(&LocalDetail)
  222. if err != nil {
  223. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  224. }
  225. //填充收藏信息
  226. collectionInfo := []youngee_talent_model.LocalCollection{}
  227. err = g.DB().Model("younggee_local_collect_info").Where("local_id=? and talent_id = ?", local_id, tid).Scan(&collectionInfo)
  228. if err != nil {
  229. return &TalentHttpResult{Code: -1, Msg: err.Error()}
  230. }
  231. //已被收藏
  232. if len(collectionInfo) != 0 && collectionInfo[0].Deleted == 0 { //有数据 且 没取消收藏
  233. LocalDetail.IsCollected = 1
  234. } else {
  235. LocalDetail.IsCollected = 0 //没数据 或 有数据但取消了收藏
  236. }
  237. // 将 TalentType 转换为逗号隔开的汉字字符串
  238. talentTypes := strings.Split(LocalDetail.TalentType, ",")
  239. var result []string
  240. for _, t := range talentTypes {
  241. if name, ok := categoryMap[t]; ok {
  242. result = append(result, name)
  243. }
  244. }
  245. // 将结果拼接成逗号隔开的字符串
  246. resultStr := strings.Join(result, ",")
  247. LocalDetail.TalentType = resultStr
  248. var younggeePhoto []*youngee_talent_model.YounggeeProductPhoto
  249. teamBuyingId := LocalDetail.TeamBuyingId
  250. if teamBuyingId != 0 {
  251. err := g.DB().Model("younggee_product_photo").Where("team_buying_id", teamBuyingId).Scan(&younggeePhoto)
  252. if err != nil {
  253. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  254. }
  255. }
  256. StoreId := LocalDetail.StoreId
  257. if StoreId != 0 {
  258. err := g.DB().Model("younggee_product_photo").Where("store_id", StoreId).Scan(&younggeePhoto)
  259. if err != nil {
  260. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  261. }
  262. fmt.Println("younggeePhoto", younggeePhoto)
  263. }
  264. fmt.Println("younggeePhoto", younggeePhoto)
  265. LocalDetail.YounggeeProductPhoto = younggeePhoto
  266. //违约
  267. //if LocalDetail.AutoTaskId != 0 && LocalDetail.AutoDefaultId != 0 {
  268. // one, _ := g.DB().Model("info_auto_default_handle").Where("auto_default_id=?", LocalDetail.AutoDefaultId).One()
  269. // one2, _ := g.DB().Model("info_auto_task").Where("auto_task_id=?", LocalDetail.AutoTaskId).One()
  270. // LocalDetail.DraftDefault.BreakPecent = one["sketch_replace_not_upload"].Int()
  271. // LocalDetail.LinkDefault.BreakPecent = one["link_replace_not_upload"].Int()
  272. // LocalDetail.DataDefault.BreakPecent = one["data_replace_not_upload"].Int()
  273. // LocalDetail.DraftDefault.BreakTime = one2["draft_default"].Int()
  274. // LocalDetail.DraftDefault.BreakTime = one2["link_breach"].Int()
  275. // LocalDetail.DraftDefault.BreakTime = one2["case_close_default"].Int()
  276. //}
  277. if viewed.IsNil() {
  278. // User hasn't viewed this product yet, increase the view count
  279. _, err = g.Redis().Do("INCR", loalViewKey)
  280. if err != nil {
  281. glog.Error(err)
  282. return &TalentHttpResult{Code: 0, Msg: "Redis error"}
  283. }
  284. // Mark the product as viewed by this user
  285. _, err = g.Redis().Do("SET", userViewedKey, true)
  286. if err != nil {
  287. glog.Error(err)
  288. return &TalentHttpResult{Code: 0, Msg: "Redis error"}
  289. }
  290. }
  291. viewNum, err := g.Redis().DoVar("GET", loalViewKey)
  292. if err != nil {
  293. fmt.Println("获取浏览量失败")
  294. }
  295. LocalDetail.WatchedNum = viewNum.Int()
  296. //浏览历史
  297. currentDate := gtime.Now().Format("Ymd")
  298. // 设计 Redis Key
  299. redisBrowseKey := fmt.Sprintf("browseLocal:%s:%s", currentDate, tid)
  300. fmt.Println("redis浏览记录的key为——————————", redisBrowseKey)
  301. _, err = g.Redis().Do("SADD", redisBrowseKey, local_id)
  302. if err != nil {
  303. return &TalentHttpResult{Code: 0, Msg: "Redis 存浏览历史数据失败"}
  304. }
  305. // 设置 Key 的过期时间为 7 天
  306. _, err = g.Redis().Do("EXPIRE", redisBrowseKey, 7*24*60*60) // 7 天的秒数
  307. if err != nil {
  308. return &TalentHttpResult{Code: 0, Msg: "Redis 设置过期时间失败"}
  309. }
  310. if LocalDetail.EnterpriseId != "" { //project来自商家
  311. var enterprise *youngee_talent_model.Enterprise
  312. err = g.DB().Model("enterprise").WithAll().Where("enterprise_id", LocalDetail.EnterpriseId).Scan(&enterprise)
  313. if err != nil {
  314. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  315. }
  316. LocalDetail.Enterprise = enterprise
  317. }
  318. if s_local_id != "" {
  319. // 来自服务商
  320. var younggeeSupplier *youngee_talent_model.YounggeeSupplier
  321. err = g.DB().Model("younggee_supplier").WithAll().Where("supplier_id", localInfoSupplier.SupplierID).Scan(&younggeeSupplier)
  322. if err != nil {
  323. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  324. }
  325. LocalDetail.YounggeeSupplier = younggeeSupplier
  326. LocalDetail.LocalInfoSupplier = &localInfoSupplier
  327. }
  328. return &TalentHttpResult{Code: 0, Msg: "success", Data: LocalDetail}
  329. }
  330. // 查询所有任务
  331. func GetLocalTaskBriefList(r *ghttp.Request) *TalentHttpResult {
  332. tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
  333. if err != nil {
  334. return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
  335. }
  336. taskType := r.GetInt("task_type", 0) //任务类型
  337. if taskType == 0 {
  338. return &TalentHttpResult{Code: -1, Msg: "task_type is nil"}
  339. }
  340. // 构造查询条件tid和taskType
  341. whereStr := fmt.Sprintf("talent_id = %s and local_type = %d", tid, taskType)
  342. // 获取任务列表
  343. var taskList []*youngee_talent_model.YoungeeLocalTaskInfo
  344. //此达人下,所有快手账号的任务都展示
  345. err = g.Model("youngee_local_task_info").Where(whereStr).Scan(&taskList)
  346. if err != nil {
  347. return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
  348. }
  349. //后续根据 PlatformId 快速查找平台信息。platformMap的key是PlatformId,value是平台具体描述
  350. platformMap := make(map[string]model.InfoThirdPlatform)
  351. platformInfo := []*model.InfoThirdPlatform{}
  352. if len(taskList) != 0 {
  353. err := g.Model(dao.InfoThirdPlatform.Table).Scan(&platformInfo)
  354. if err != nil {
  355. return &TalentHttpResult{Code: -1, Msg: "Get platform failed"}
  356. }
  357. for i, _ := range platformInfo {
  358. platformMap[strconv.Itoa(platformInfo[i].PlatformId)] = *platformInfo[i]
  359. }
  360. }
  361. //为每个任务根据项目id查询项目名称和主图
  362. //taskBriefList存了各个阶段的tasklist
  363. taskBriefList := youngee_talent_model.LocalTaskInfoBriefList{}
  364. for _, v := range taskList { //taskList含所有任务
  365. //获取具体的招募策略,taskInfo中
  366. var localDetail *youngee_talent_model.LocalInfoDetail
  367. err := g.Model("younggee_local_life_info").WithAll().Where("local_id = ?", v.LocalId).Scan(&localDetail)
  368. if err != nil {
  369. return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
  370. }
  371. var account *youngee_talent_model.KuaishouUserInfo
  372. fmt.Println("openid---->", v.OpenId)
  373. err = g.Model("platform_kuaishou_user_info").Where("platform_id = ? and talent_id = ? and open_id = ?", localDetail.LocalPlatform, tid, v.OpenId).Scan(&account)
  374. //拿快手平台验证是否过期
  375. //expired := youngee_talent_service.CheckKuaishouTokenExp(account.OpenId)
  376. //account.Expired = expired
  377. if err != nil {
  378. return &TalentHttpResult{Code: -1, Msg: "Get account info failed"}
  379. }
  380. //taskInfoBrief含需要展示在页面的内容,被加入各阶段List
  381. taskInfoBrief := &youngee_talent_model.LocalTaskInfoBrief{
  382. TaskId: v.TaskId,
  383. PlatformIconUrl: platformMap[strconv.Itoa(localDetail.PlatformInfo.PlatformId)].PlatformIcon,
  384. //PlatformName: platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
  385. //PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
  386. ProjectName: localDetail.LocalName,
  387. //ProductPhotoSnap: localDetail.ProductPhotoSnap,
  388. TaskStatus: v.TaskStatus,
  389. TaskStage: v.TaskStage,
  390. LinkStatus: v.LinkStatus,
  391. DataStatus: v.DataStatus,
  392. //ScriptStatus: v.ScriptStatus,
  393. SketchStatus: v.SketchStatus,
  394. TaskReward: v.TaskReward,
  395. BreakRate: v.ScriptBreakRate + v.SketchBreakRate + v.LinkBreakRate + v.DataBreakRate,
  396. CurBreakAt: v.CurBreakAt,
  397. FeeForm: v.FeeForm,
  398. LocalDetail: localDetail,
  399. TaskInfo: v,
  400. AccountInfo: account, //含是否过期,粉丝数,作品数目
  401. }
  402. taskBriefList.AllTaskInfoList = append(taskBriefList.AllTaskInfoList, taskInfoBrief)
  403. //1:已报名, 2:申请成功, 3:申请失败, 4:待预约探店, 5:预约确认中 6:预约成功 , 7:待传探底图片, 8:脚本待审, 9:待传初稿, 10:初稿待审,
  404. //11:待传链接, 12:链接待审, 13:待传数据, 14:数据待审, 15:已结案, 16:解约, 17:终止合作(过渡态)',
  405. if v.TaskStage <= 2 {
  406. taskBriefList.SignUpTaskInfoList = append(taskBriefList.SignUpTaskInfoList, taskInfoBrief)
  407. } else if v.TaskStage == 4 { //如果是线下探店
  408. taskBriefList.WaitBookList = append(taskBriefList.WaitBookList, taskInfoBrief)
  409. } else if v.TaskStage <= 14 && v.TaskStage >= 5 {
  410. taskBriefList.GoingOnTaskInfoList = append(taskBriefList.GoingOnTaskInfoList, taskInfoBrief)
  411. } else if v.TaskStage == 15 {
  412. taskBriefList.WaitToPayInfoList = append(taskBriefList.WaitToPayInfoList, taskInfoBrief)
  413. } else {
  414. taskBriefList.CompletedTaskInfoList = append(taskBriefList.CompletedTaskInfoList, taskInfoBrief)
  415. }
  416. }
  417. return &TalentHttpResult{Code: 0, Msg: "success", Data: taskBriefList}
  418. }
  419. func GetLocalTaskDetail(r *ghttp.Request) *TalentHttpResult {
  420. taskId := r.Get("task_id", "")
  421. if taskId == "" {
  422. return &TalentHttpResult{Code: -1, Msg: "task_id is empty"}
  423. }
  424. var task *youngee_talent_model.YoungeeLocalTaskInfo
  425. err := g.Model("youngee_local_task_info").Where("task_id = ?", taskId).Scan(&task)
  426. if err != nil {
  427. return &TalentHttpResult{Code: -1, Msg: "Get task info failed"}
  428. }
  429. var localDetail *youngee_talent_model.LocalInfoDetail
  430. err = g.Model(youngee_talent_model.LocalInfoDetail{}).WithAll().Where("local_id", task.LocalId).Scan(&localDetail)
  431. if err != nil {
  432. return &TalentHttpResult{Code: -3, Msg: "data query failed"}
  433. }
  434. var productPhoto *youngee_talent_model.YounggeeProductPhoto
  435. err = g.Model("younggee_product_photo").Where("store_id = ? and symbol = 1", localDetail.StoreId).Scan(&productPhoto)
  436. if err != nil {
  437. return &TalentHttpResult{Code: -3, Msg: "data query failed"}
  438. }
  439. var withdrawStatus = 1
  440. var taskIncome *model.YounggeeTalentIncome
  441. err = g.Model(dao.YounggeeTalentIncome.Table).Where("task_id = ? and income_type = 1", taskId).Scan(&taskIncome)
  442. if err != nil {
  443. return &TalentHttpResult{Code: -3, Msg: "Get task income detail failed."}
  444. }
  445. if taskIncome != nil {
  446. withdrawStatus = taskIncome.WithdrawStatus + 1
  447. }
  448. taskDetail := &youngee_talent_model.LocalTaskDetail{}
  449. if localDetail.LocalType == 1 {
  450. var strategy *youngee_talent_model.RecruitStrategy
  451. err = g.DB().Model("recruit_strategy").Where("project_id = ? and strategy_id = ?", task.LocalId, task.StrategyId).Scan(&strategy)
  452. if err != nil {
  453. return &TalentHttpResult{Code: -3, Msg: "data query failed"}
  454. }
  455. taskDetail = &youngee_talent_model.LocalTaskDetail{
  456. TaskInfo: task,
  457. LocalDetail: localDetail,
  458. ProductPhoto: productPhoto, //首页图片
  459. Strategy: strategy,
  460. WithdrawStatus: withdrawStatus,
  461. }
  462. } else {
  463. taskDetail = &youngee_talent_model.LocalTaskDetail{
  464. TaskInfo: task,
  465. LocalDetail: localDetail,
  466. ProductPhoto: productPhoto,
  467. WithdrawStatus: withdrawStatus,
  468. }
  469. }
  470. return &TalentHttpResult{Code: 0, Msg: "success", Data: taskDetail}
  471. }