local_life_info.go 20 KB

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