local_life_info.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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 float64
  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.GetQueryInt("s_local_id", 0)
  187. var localInfoSupplier *youngee_talent_model.LocalInfoSupplier
  188. if s_local_id != 0 {
  189. // 来自服务商
  190. err := g.DB().Model("younggee_s_local_life_info").Where("s_local_id=?", s_local_id).Scan(&localInfoSupplier)
  191. if err != nil {
  192. fmt.Println("projectInfoSupplier err:", err.Error())
  193. }
  194. local_id = localInfoSupplier.LocalID //获取local_id
  195. }
  196. // Redis key
  197. loalViewKey := "local:view:" + local_id
  198. userViewedKey := "user:viewed:" + tid + ":" + local_id
  199. //在redis中增加浏览量
  200. // Check if the user has already viewed the product
  201. //DoVar方便进行类型转化
  202. viewed, err := g.Redis().DoVar("GET", userViewedKey)
  203. if err != nil {
  204. glog.Error(err)
  205. return &TalentHttpResult{Code: 0, Msg: "Redis error"}
  206. }
  207. var talentCategory []*youngee_talent_model.YounggeeTalentCategory
  208. err = g.DB().Model("younggee_talent_category").Scan(&talentCategory)
  209. if err != nil {
  210. // 处理查询错误
  211. return &TalentHttpResult{Code: -1, Msg: err.Error()}
  212. }
  213. // 创建一个数字到汉字的映射
  214. categoryMap := make(map[string]string)
  215. for _, category := range talentCategory {
  216. categoryMap[fmt.Sprint(category.Id)] = category.Category
  217. }
  218. var LocalDetail *youngee_talent_model.LocalInfoDetail
  219. err = g.DB().Model("younggee_local_life_info").WithAll().Where("local_id", local_id).Scan(&LocalDetail)
  220. if err != nil {
  221. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  222. }
  223. //填充收藏信息
  224. collectionInfo := []youngee_talent_model.LocalCollection{}
  225. err = g.DB().Model("younggee_local_collect_info").Where("local_id=? and talent_id = ?", local_id, tid).Scan(&collectionInfo)
  226. if err != nil {
  227. return &TalentHttpResult{Code: -1, Msg: err.Error()}
  228. }
  229. //已被收藏
  230. if len(collectionInfo) != 0 && collectionInfo[0].Deleted == 0 { //有数据 且 没取消收藏
  231. LocalDetail.IsCollected = 1
  232. } else {
  233. LocalDetail.IsCollected = 0 //没数据 或 有数据但取消了收藏
  234. }
  235. // 将 TalentType 转换为逗号隔开的汉字字符串
  236. talentTypes := strings.Split(LocalDetail.TalentType, ",")
  237. var result []string
  238. for _, t := range talentTypes {
  239. if name, ok := categoryMap[t]; ok {
  240. result = append(result, name)
  241. }
  242. }
  243. // 将结果拼接成逗号隔开的字符串
  244. resultStr := strings.Join(result, ",")
  245. LocalDetail.TalentType = resultStr
  246. var younggeePhoto []*youngee_talent_model.YounggeeProductPhoto
  247. teamBuyingId := LocalDetail.TeamBuyingId
  248. if teamBuyingId != 0 {
  249. err := g.DB().Model("younggee_product_photo").Where("team_buying_id", teamBuyingId).Scan(&younggeePhoto)
  250. if err != nil {
  251. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  252. }
  253. }
  254. StoreId := LocalDetail.StoreId
  255. if StoreId != 0 {
  256. err := g.DB().Model("younggee_product_photo").Where("store_id", StoreId).Scan(&younggeePhoto)
  257. if err != nil {
  258. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  259. }
  260. fmt.Println("younggeePhoto", younggeePhoto)
  261. }
  262. fmt.Println("younggeePhoto", younggeePhoto)
  263. LocalDetail.YounggeeProductPhoto = younggeePhoto
  264. //违约
  265. //if LocalDetail.AutoTaskId != 0 && LocalDetail.AutoDefaultId != 0 {
  266. // one, _ := g.DB().Model("info_auto_default_handle").Where("auto_default_id=?", LocalDetail.AutoDefaultId).One()
  267. // one2, _ := g.DB().Model("info_auto_task").Where("auto_task_id=?", LocalDetail.AutoTaskId).One()
  268. // LocalDetail.DraftDefault.BreakPecent = one["sketch_replace_not_upload"].Int()
  269. // LocalDetail.LinkDefault.BreakPecent = one["link_replace_not_upload"].Int()
  270. // LocalDetail.DataDefault.BreakPecent = one["data_replace_not_upload"].Int()
  271. // LocalDetail.DraftDefault.BreakTime = one2["draft_default"].Int()
  272. // LocalDetail.DraftDefault.BreakTime = one2["link_breach"].Int()
  273. // LocalDetail.DraftDefault.BreakTime = one2["case_close_default"].Int()
  274. //}
  275. if viewed.IsNil() {
  276. // User hasn't viewed this product yet, increase the view count
  277. _, err = g.Redis().Do("INCR", loalViewKey)
  278. if err != nil {
  279. glog.Error(err)
  280. return &TalentHttpResult{Code: 0, Msg: "Redis error"}
  281. }
  282. // Mark the product as viewed by this user
  283. _, err = g.Redis().Do("SET", userViewedKey, true)
  284. if err != nil {
  285. glog.Error(err)
  286. return &TalentHttpResult{Code: 0, Msg: "Redis error"}
  287. }
  288. }
  289. viewNum, err := g.Redis().DoVar("GET", loalViewKey)
  290. if err != nil {
  291. fmt.Println("获取浏览量失败")
  292. }
  293. LocalDetail.WatchedNum = viewNum.Int()
  294. //浏览历史
  295. currentDate := gtime.Now().Format("Ymd")
  296. // 设计 Redis Key
  297. redisBrowseKey := fmt.Sprintf("browseLocal:%s:%s", currentDate, tid)
  298. fmt.Println("redis浏览记录的key为——————————", redisBrowseKey)
  299. _, err = g.Redis().Do("SADD", redisBrowseKey, local_id)
  300. if err != nil {
  301. return &TalentHttpResult{Code: 0, Msg: "Redis 存浏览历史数据失败"}
  302. }
  303. // 设置 Key 的过期时间为 7 天
  304. _, err = g.Redis().Do("EXPIRE", redisBrowseKey, 7*24*60*60) // 7 天的秒数
  305. if err != nil {
  306. return &TalentHttpResult{Code: 0, Msg: "Redis 设置过期时间失败"}
  307. }
  308. //奖励形式
  309. LocalDetail.IsShowDraft = 0 // 默认不展示稿费
  310. LocalDetail.HaveGift = 0 // 默认没有赠品
  311. for _, strategy := range LocalDetail.RecruitStrategys {
  312. if strategy.FeeForm != 1 { // 如果存在非无费置换的策略
  313. LocalDetail.IsShowDraft = 1
  314. break // 找到一个非无费置换的策略就可以了
  315. }
  316. }
  317. if LocalDetail.Donate == 1 { // 是否赠送达人套餐
  318. LocalDetail.HaveGift = 1 // 有赠品
  319. }
  320. if LocalDetail.EnterpriseId != "" { //project来自商家
  321. var enterprise *youngee_talent_model.Enterprise
  322. err = g.DB().Model("enterprise").WithAll().Where("enterprise_id", LocalDetail.EnterpriseId).Scan(&enterprise)
  323. if err != nil {
  324. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  325. }
  326. LocalDetail.Enterprise = enterprise
  327. }
  328. if s_local_id != 0 {
  329. // 来自服务商
  330. var younggeeSupplier *youngee_talent_model.YounggeeSupplier
  331. err = g.DB().Model("younggee_supplier").WithAll().Where("supplier_id", localInfoSupplier.SupplierID).Scan(&younggeeSupplier)
  332. if err != nil {
  333. return &TalentHttpResult{Code: -3, Msg: err.Error()}
  334. }
  335. LocalDetail.YounggeeSupplier = younggeeSupplier
  336. LocalDetail.LocalInfoSupplier = localInfoSupplier
  337. }
  338. return &TalentHttpResult{Code: 0, Msg: "success", Data: LocalDetail}
  339. }
  340. // 查询所有任务
  341. func GetLocalTaskBriefList(r *ghttp.Request) *TalentHttpResult {
  342. tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
  343. if err != nil {
  344. return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
  345. }
  346. taskType := r.GetInt("task_type", 0) //任务类型
  347. if taskType == 0 {
  348. return &TalentHttpResult{Code: -1, Msg: "task_type is nil"}
  349. }
  350. // 构造查询条件tid和taskType
  351. whereStr := fmt.Sprintf("talent_id = %s and local_type = %d", tid, taskType)
  352. // 获取任务列表
  353. var taskList []*youngee_talent_model.YoungeeLocalTaskInfo
  354. //此达人下,所有快手账号的任务都展示
  355. err = g.Model("youngee_local_task_info").Where(whereStr).Scan(&taskList)
  356. if err != nil {
  357. return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
  358. }
  359. //后续根据 PlatformId 快速查找平台信息。platformMap的key是PlatformId,value是平台具体描述
  360. platformMap := make(map[string]model.InfoThirdPlatform)
  361. platformInfo := []*model.InfoThirdPlatform{}
  362. if len(taskList) != 0 {
  363. err := g.Model(dao.InfoThirdPlatform.Table).Scan(&platformInfo)
  364. if err != nil {
  365. return &TalentHttpResult{Code: -1, Msg: "Get platform failed"}
  366. }
  367. for i, _ := range platformInfo {
  368. platformMap[strconv.Itoa(platformInfo[i].PlatformId)] = *platformInfo[i]
  369. }
  370. }
  371. //为每个任务根据项目id查询项目名称和主图
  372. //taskBriefList存了各个阶段的tasklist
  373. taskBriefList := youngee_talent_model.LocalTaskInfoBriefList{}
  374. for _, v := range taskList { //taskList含所有任务
  375. //获取具体的招募策略,taskInfo中
  376. var localDetail *youngee_talent_model.LocalInfoDetail
  377. err := g.Model("younggee_local_life_info").WithAll().Where("local_id = ?", v.LocalId).Scan(&localDetail)
  378. if err != nil {
  379. return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
  380. }
  381. var account *youngee_talent_model.KuaishouUserInfo
  382. fmt.Println("openid---->", v.OpenId)
  383. err = g.Model("platform_kuaishou_user_info").Where("platform_id = ? and talent_id = ? and open_id = ?", localDetail.LocalPlatform, tid, v.OpenId).Scan(&account)
  384. //拿快手平台验证是否过期
  385. //expired := youngee_talent_service.CheckKuaishouTokenExp(account.OpenId)
  386. //account.Expired = expired
  387. if err != nil {
  388. return &TalentHttpResult{Code: -1, Msg: "Get account info failed"}
  389. }
  390. //taskInfoBrief含需要展示在页面的内容,被加入各阶段List
  391. taskInfoBrief := &youngee_talent_model.LocalTaskInfoBrief{
  392. TaskId: v.TaskId,
  393. PlatformIconUrl: platformMap[strconv.Itoa(localDetail.PlatformInfo.PlatformId)].PlatformIcon,
  394. //PlatformName: platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
  395. //PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
  396. ProjectName: localDetail.LocalName,
  397. //ProductPhotoSnap: localDetail.ProductPhotoSnap,
  398. TaskStatus: v.TaskStatus,
  399. TaskStage: v.TaskStage,
  400. LinkStatus: v.LinkStatus,
  401. DataStatus: v.DataStatus,
  402. //ScriptStatus: v.ScriptStatus,
  403. SketchStatus: v.SketchStatus,
  404. TaskReward: v.TaskReward,
  405. BreakRate: v.ScriptBreakRate + v.SketchBreakRate + v.LinkBreakRate + v.DataBreakRate,
  406. CurBreakAt: v.CurBreakAt,
  407. FeeForm: v.FeeForm,
  408. LocalDetail: localDetail,
  409. TaskInfo: v,
  410. AccountInfo: account, //含是否过期,粉丝数,作品数目
  411. }
  412. taskBriefList.AllTaskInfoList = append(taskBriefList.AllTaskInfoList, taskInfoBrief)
  413. //1:已报名, 2:申请成功, 3:申请失败, 4:待预约探店, 5:预约确认中 6:预约成功 , 7:待传探底图片, 8:脚本待审, 9:待传初稿, 10:初稿待审,
  414. //11:待传链接, 12:链接待审, 13:待传数据, 14:数据待审, 15:已结案, 16:解约, 17:终止合作(过渡态)',
  415. if v.TaskStage <= 2 {
  416. taskBriefList.SignUpTaskInfoList = append(taskBriefList.SignUpTaskInfoList, taskInfoBrief)
  417. } else if v.TaskStage == 4 { //如果是线下探店
  418. taskBriefList.WaitBookList = append(taskBriefList.WaitBookList, taskInfoBrief)
  419. } else if v.TaskStage <= 14 && v.TaskStage >= 5 {
  420. taskBriefList.GoingOnTaskInfoList = append(taskBriefList.GoingOnTaskInfoList, taskInfoBrief)
  421. } else if v.TaskStage == 15 {
  422. taskBriefList.WaitToPayInfoList = append(taskBriefList.WaitToPayInfoList, taskInfoBrief)
  423. } else {
  424. taskBriefList.CompletedTaskInfoList = append(taskBriefList.CompletedTaskInfoList, taskInfoBrief)
  425. }
  426. }
  427. return &TalentHttpResult{Code: 0, Msg: "success", Data: taskBriefList}
  428. }
  429. func GetLocalTaskDetail(r *ghttp.Request) *TalentHttpResult {
  430. taskId := r.Get("task_id", "")
  431. if taskId == "" {
  432. return &TalentHttpResult{Code: -1, Msg: "task_id is empty"}
  433. }
  434. var task *youngee_talent_model.YoungeeLocalTaskInfo
  435. err := g.Model("youngee_local_task_info").Where("task_id = ?", taskId).Scan(&task)
  436. if err != nil {
  437. return &TalentHttpResult{Code: -1, Msg: "Get task info failed"}
  438. }
  439. var localDetail *youngee_talent_model.LocalInfoDetail
  440. err = g.Model(youngee_talent_model.LocalInfoDetail{}).WithAll().Where("local_id", task.LocalId).Scan(&localDetail)
  441. if err != nil {
  442. return &TalentHttpResult{Code: -3, Msg: "data query failed"}
  443. }
  444. var productPhoto *youngee_talent_model.YounggeeProductPhoto
  445. err = g.Model("younggee_product_photo").Where("store_id = ? and symbol = 1", localDetail.StoreId).Scan(&productPhoto)
  446. if err != nil {
  447. return &TalentHttpResult{Code: -3, Msg: "data query failed"}
  448. }
  449. var withdrawStatus = 1
  450. var taskIncome *model.YounggeeTalentIncome
  451. err = g.Model(dao.YounggeeTalentIncome.Table).Where("task_id = ? and income_type = 1", taskId).Scan(&taskIncome)
  452. if err != nil {
  453. return &TalentHttpResult{Code: -3, Msg: "Get task income detail failed."}
  454. }
  455. if taskIncome != nil {
  456. withdrawStatus = taskIncome.WithdrawStatus + 1
  457. }
  458. taskDetail := &youngee_talent_model.LocalTaskDetail{}
  459. if localDetail.LocalType == 1 {
  460. var strategy *youngee_talent_model.RecruitStrategy
  461. err = g.DB().Model("recruit_strategy").Where("project_id = ? and strategy_id = ?", task.LocalId, task.StrategyId).Scan(&strategy)
  462. if err != nil {
  463. return &TalentHttpResult{Code: -3, Msg: "data query failed"}
  464. }
  465. taskDetail = &youngee_talent_model.LocalTaskDetail{
  466. TaskInfo: task,
  467. LocalDetail: localDetail,
  468. ProductPhoto: productPhoto, //首页图片
  469. Strategy: strategy,
  470. WithdrawStatus: withdrawStatus,
  471. }
  472. } else {
  473. taskDetail = &youngee_talent_model.LocalTaskDetail{
  474. TaskInfo: task,
  475. LocalDetail: localDetail,
  476. ProductPhoto: productPhoto,
  477. WithdrawStatus: withdrawStatus,
  478. }
  479. }
  480. return &TalentHttpResult{Code: 0, Msg: "success", Data: taskDetail}
  481. }