state.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. package newcomer
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. "go-common/app/interface/main/creative/model/newcomer"
  7. "go-common/library/log"
  8. "go-common/library/sync/errgroup.v2"
  9. )
  10. //DriveStateByUser drive new hand & advanced task state
  11. func (s *Service) DriveStateByUser(c context.Context, mid int64) {
  12. res, err := s.newc.UserTasksByMID(c, mid)
  13. if err != nil {
  14. log.Error("DriveStateByUser s.newc.UserTasksByMID mid(%d)|err(%v)", mid, err)
  15. return
  16. }
  17. if len(res) == 0 {
  18. return
  19. }
  20. for _, v := range res {
  21. if s.CheckTaskState(context.Background(), &newcomer.CheckTaskStateReq{MID: v.MID, TaskID: v.TaskID}) {
  22. _, err := s.newc.UpUserTask(c, v.MID, v.TaskID)
  23. if err != nil {
  24. log.Error("DriveStateByUser s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", v.MID, v.TaskID, err)
  25. }
  26. }
  27. }
  28. }
  29. //CheckTaskState check task state by mid & task id
  30. func (s *Service) CheckTaskState(c context.Context, req *newcomer.CheckTaskStateReq) (state bool) {
  31. if req == nil {
  32. return
  33. }
  34. mid, tid := req.MID, req.TaskID
  35. if _, ok := s.TaskMapCache[tid]; !ok {
  36. return
  37. }
  38. task := s.TaskMapCache[tid]
  39. //log.Info("CheckTaskState req(%+v)|task(%+v)", req, task)
  40. switch task.TargetType {
  41. case newcomer.TargetType001, newcomer.TargetType014: //新手任务-1 该UID下开放浏览的稿件≥1 / 进阶任务- 14 该UID下开放浏览的稿件≥5
  42. cnt, err := s.arc.UpCount(c, mid)
  43. if err != nil {
  44. log.Error("CheckTaskState s.arc.UpCount mid(%d)|error(%v)", mid, err)
  45. return
  46. }
  47. if cnt >= task.TargetValue {
  48. switch task.TargetType {
  49. case newcomer.TargetType001:
  50. log.Info("CheckTaskState TargetType001 mid(%d)|count(%d)|指标:新手任务-1 该UID下开放浏览的稿件≥1", mid, cnt)
  51. case newcomer.TargetType014:
  52. log.Info("CheckTaskState TargetType014 mid(%d)|count(%d)|指标:进阶任务- 14 该UID下开放浏览的稿件≥5", mid, cnt)
  53. }
  54. state = true
  55. }
  56. case newcomer.TargetType002: //该UID分享自己视频的次数≥1
  57. case newcomer.TargetType003: //该UID在创作学院的观看记录≥1
  58. cnt, err := s.aca.PlayCount(c, mid)
  59. if err != nil {
  60. log.Error("s.aca.PlayCount error(%v)", err)
  61. return
  62. }
  63. if cnt >= task.TargetValue {
  64. log.Info("CheckTaskState TargetType003 mid(%d)|count(%d)|指标:新手任务-1 该UID在创作学院的观看记录≥1", mid, cnt)
  65. state = true
  66. }
  67. case newcomer.TargetType004, newcomer.TargetType005, newcomer.TargetType006, newcomer.TargetType007, newcomer.TargetType008, newcomer.TargetType009: //该UID下所有avid的获得评论数/...≥3/5
  68. state = s.totalStat(c, mid, int64(task.TargetValue), task.TargetType)
  69. case newcomer.TargetType010, newcomer.TargetType022: //新手任务- 10 获得10个粉丝 / 进阶任务- 22 该UID的粉丝数≥1000
  70. pl, err := s.acc.ProfileWithStat(c, mid)
  71. if err != nil {
  72. log.Error("CheckTaskState s.acc.ProfileWithStat error(%v)", err)
  73. return
  74. }
  75. if pl == nil {
  76. return
  77. }
  78. if pl.Follower >= int64(task.TargetValue) {
  79. switch task.TargetType {
  80. case newcomer.TargetType010:
  81. log.Info("CheckTaskState TargetType010 mid(%d)|follower(%d)|指标:新手任务-10 该UID的粉丝数≥10", mid, pl.Follower)
  82. case newcomer.TargetType022:
  83. log.Info("CheckTaskState TargetType022 mid(%d)|follower(%d)|指标:进阶任务-22 该UID的粉丝数≥1000", mid, pl.Follower)
  84. }
  85. state = true
  86. }
  87. case newcomer.TargetType011: //任务完成期间该UID的水印开关为打开状态
  88. wm, err := s.wm.WaterMark(c, mid)
  89. if err != nil {
  90. log.Error("CheckTaskState s.wm.WaterMark mid(%d) error(%v)", mid, err)
  91. return
  92. }
  93. if wm != nil && wm.State == 1 && wm.URL != "" {
  94. log.Info("CheckTaskState TargetType011 mid(%d)已开启水印|指标:新手任务-11 任务完成期间该UID的水印开关为打开状态", mid)
  95. state = true
  96. }
  97. case newcomer.TargetType012: //该UID的关注列表含有“哔哩哔哩创作中心”
  98. fid := creatorMID //用户哔哩哔哩创作中心 mid
  99. fl, err := s.acc.Relations(c, mid, []int64{fid}, "")
  100. if err != nil {
  101. log.Error("CheckTaskState s.acc.Relations mid(%d)|ip(%s)|error(%v)", mid, "", err)
  102. return
  103. }
  104. if fl == nil {
  105. return
  106. }
  107. if st, ok := fl[fid]; ok && (st == 6 || st == 2) {
  108. log.Info("CheckTaskState TargetType012 mid(%d)已关注创作中心|指标:新手任务-12 该UID的关注列表含有“哔哩哔哩创作中心”", mid)
  109. state = true
  110. }
  111. case newcomer.TargetType013, newcomer.TargetType015, newcomer.TargetType016, newcomer.TargetType017, newcomer.TargetType018, newcomer.TargetType019, newcomer.TargetType020, newcomer.TargetType021: //13-该UID通过手机投稿的稿件≥1 / 15-21单稿件获得1000播放...
  112. state = s.singleStat(c, mid, int64(task.TargetValue), task.TargetType)
  113. case newcomer.TargetType023: //该UID的激励计划状态为已开通
  114. ac, err := s.order.GrowAccountState(c, mid, 0) //类型 0 视频 2 专栏 3 素材
  115. if err != nil {
  116. log.Error("CheckTaskState s.order.GrowUpPlan mid(%d) error(%v)", mid, err)
  117. return
  118. }
  119. if ac == nil {
  120. return
  121. }
  122. if ac.State == 3 { //账号状态; 1: 未申请; 2: 待审核; 3: 已签约; 4.已驳回; 5.主动退出; 6:被动退出; 7:封禁
  123. log.Info("CheckTaskState TargetType023 mid(%d)已签约激励计划|指标:进阶任务-23 该UID的激励计划状态为已开通", mid)
  124. state = true
  125. }
  126. case newcomer.TargetType024: //该UID粉丝勋章为开启状态
  127. medal, err := s.medal.Medal(c, mid)
  128. if err != nil {
  129. log.Error("CheckTaskState s.medal.Medal mid(%d) error(%v)", mid, err)
  130. return
  131. }
  132. if medal == nil {
  133. return
  134. }
  135. status, err := strconv.Atoi(medal.Status)
  136. if err != nil {
  137. log.Error("CheckTaskState strconv.Atoi medal.Status(%s) error(%v)", medal.Status, err)
  138. return
  139. }
  140. if status == 2 { //勋章审核状态 -1已拒绝 0未申请 1已申请 2已开通
  141. log.Info("CheckTaskState TargetType024 mid(%d)已开通粉丝勋章|指标:进阶任务-24 该UID粉丝勋章为开启状态", mid)
  142. state = true
  143. }
  144. }
  145. return
  146. }
  147. func (s *Service) totalStat(c context.Context, mid, val int64, ty int8) (state bool) {
  148. st, err := s.data.UpStat(c, mid, time.Now().AddDate(0, 0, -1).Add(-12*time.Hour).Format("20060102"))
  149. if err != nil || st == nil {
  150. log.Error("totalStat s.data.NewStat mid(%d) st(%+v) error(%v) ", mid, st, err)
  151. return
  152. }
  153. switch ty {
  154. case newcomer.TargetType004:
  155. if st.Reply >= val {
  156. log.Info("CheckTaskState TargetType004 mid(%d)|v(%+v)|指标:新手任务-4 该UID下所有avid的获得评论数≥3", mid, st.Reply)
  157. state = true
  158. }
  159. case newcomer.TargetType005:
  160. if st.Share >= val {
  161. log.Info("CheckTaskState TargetType005 mid(%d)|v(%+v)|指标:新手任务-5 该UID下所有avid获得分享数≥3", mid, st.Share)
  162. state = true
  163. }
  164. case newcomer.TargetType006:
  165. if st.Fav >= val {
  166. log.Info("CheckTaskState TargetType006 mid(%d)|v(%+v)|指标:新手任务-6 该UID的所有avid的获得收藏数≥5", mid, st.Fav)
  167. state = true
  168. }
  169. case newcomer.TargetType007:
  170. if st.Coin >= val {
  171. log.Info("CheckTaskState TargetType007 mid(%d)|v(%+v)|指标:新手任务-7 该UID下所有avid的获得硬币数≥5", mid, st.Coin)
  172. state = true
  173. }
  174. case newcomer.TargetType008:
  175. if st.Like >= val {
  176. log.Info("CheckTaskState TargetType008 mid(%d)|v(%+v)|指标:新手任务-8 该UID下所有avid获得点赞数≥5", mid, st.Like)
  177. state = true
  178. }
  179. case newcomer.TargetType009:
  180. if st.Dm >= val {
  181. log.Info("CheckTaskState TargetType009 mid(%d)|v(%+v)|指标:新手任务-9 该UID下所有avid的获得弹幕数≥5", mid, st.Dm)
  182. state = true
  183. }
  184. }
  185. return
  186. }
  187. func (s *Service) singleStat(c context.Context, mid, val int64, ty int8) (state bool) {
  188. st, err := s.data.UpArchiveStatQuery(c, mid, time.Now().AddDate(0, 0, -1).Add(-12*time.Hour).Format("20060102"))
  189. if err != nil || st == nil {
  190. log.Error("singleStat s.data.UpArchiveStatQuery mid(%d)|err(%v)", mid, err)
  191. return
  192. }
  193. switch ty {
  194. case newcomer.TargetType013:
  195. if st.FromPhoneNum >= val {
  196. log.Info("CheckTaskState TargetType013 mid(%d)|v(%+v)|指标:进阶任务-13 用手机投稿上传视频", mid, st.FromPhoneNum)
  197. state = true
  198. }
  199. case newcomer.TargetType015:
  200. if st.PlayV >= val {
  201. log.Info("CheckTaskState TargetType015 mid(%d)|v(%+v)|指标:进阶任务-15 该UID下任意avid的获得点击量≥1000", mid, st.PlayV)
  202. state = true
  203. }
  204. case newcomer.TargetType016:
  205. if st.ReplyV >= val {
  206. log.Info("CheckTaskState TargetType016 mid(%d)|v(%+v)|指标:进阶任务-16 该UID下任意avid的评论≥30", mid, st.ReplyV)
  207. state = true
  208. }
  209. case newcomer.TargetType017:
  210. if st.ShareV >= val {
  211. log.Info("CheckTaskState TargetType017 mid(%d)|v(%+v)|指标:进阶任务-17 该UID下任意avid的获得分享数≥10", mid, st.ShareV)
  212. state = true
  213. }
  214. case newcomer.TargetType018:
  215. if st.FavV >= val {
  216. log.Info("CheckTaskState TargetType018 mid(%d)|v(%+v)|指标:进阶任务-18 该UID下任意avid的获得收藏数≥30", mid, st.FavV)
  217. state = true
  218. }
  219. case newcomer.TargetType019:
  220. if st.CoinV >= val {
  221. log.Info("CheckTaskState TargetType019 mid(%d)|v(%+v)|指标:进阶任务-19 该UID下任意avid的获得硬币数≥50", mid, st.CoinV)
  222. state = true
  223. }
  224. case newcomer.TargetType020:
  225. if st.LikeV >= val {
  226. log.Info("CheckTaskState TargetType020 mid(%d)|v(%+v)|指标:进阶任务-20 该UID下任意avid的获得点赞数≥50", mid, st.LikeV)
  227. state = true
  228. }
  229. case newcomer.TargetType021:
  230. if st.DmV >= val {
  231. log.Info("CheckTaskState TargetType021 mid(%d)|v(%+v)|指标:进阶任务-21 该UID下任意avid的获得弹幕数≥50", mid, st.DmV)
  232. state = true
  233. }
  234. }
  235. return
  236. }
  237. //syncCheckTaskStatus check task status
  238. func (s *Service) syncCheckTaskStatus(c context.Context, mid int64, tasks []*newcomer.Task) {
  239. log.Info("syncCheckTaskStatus mid(%d) | tasks count(%d)", mid, len(tasks))
  240. tsm := getTaskSortMap(tasks)
  241. if len(tsm) == 0 {
  242. return
  243. }
  244. g := &errgroup.Group{}
  245. for k := range tsm {
  246. switch k {
  247. case newcomer.ArcUpCount: //该UID下开放浏览的稿件数量
  248. g.Go(func(context.Context) error {
  249. s.arcUpCount(c, mid, tsm[newcomer.ArcUpCount])
  250. return nil
  251. })
  252. case newcomer.AcaPlayCount: //该UID在创作学院的观看记录
  253. g.Go(func(context.Context) error {
  254. s.acaPlayCount(c, mid, tsm[newcomer.AcaPlayCount])
  255. return nil
  256. })
  257. case newcomer.DataUpStat: //该UID下所有avid的最高计数
  258. g.Go(func(context.Context) error {
  259. s.dataUpStat(c, mid, tsm[newcomer.DataUpStat])
  260. return nil
  261. })
  262. case newcomer.AccProfileWithStat: //粉丝数量
  263. g.Go(func(context.Context) error {
  264. s.accProfileWithStat(c, mid, tsm[newcomer.AccProfileWithStat])
  265. return nil
  266. })
  267. case newcomer.WmWaterMark: //水印状态
  268. g.Go(func(context.Context) error {
  269. s.wmWaterMark(c, mid, tsm[newcomer.WmWaterMark])
  270. return nil
  271. })
  272. case newcomer.AccRelation: //该UID的关注列表含有“哔哩哔哩创作中心”
  273. g.Go(func(context.Context) error {
  274. s.accRelation(c, mid, tsm[newcomer.AccRelation])
  275. return nil
  276. })
  277. case newcomer.DataUpArchiveStat: //该UID下任意avid的计数
  278. g.Go(func(context.Context) error {
  279. s.dataUpArchiveStatQuery(c, mid, tsm[newcomer.DataUpArchiveStat])
  280. return nil
  281. })
  282. case newcomer.OrderGrowAccountState: //激励计划状态
  283. g.Go(func(context.Context) error {
  284. s.orderGrowAccountState(c, mid, tsm[newcomer.OrderGrowAccountState])
  285. return nil
  286. })
  287. case newcomer.MedalCheckMedal: //该UID粉丝勋章
  288. g.Go(func(context.Context) error {
  289. s.medalCheckMedal(c, mid, tsm[newcomer.MedalCheckMedal])
  290. return nil
  291. })
  292. }
  293. }
  294. g.Wait()
  295. }
  296. func (s *Service) arcUpCount(c context.Context, mid int64, tasks []*newcomer.Task) {
  297. if len(tasks) == 0 {
  298. return
  299. }
  300. cnt, err := s.arc.UpCount(c, mid)
  301. if err != nil {
  302. log.Error("arcUpCount s.arc.UpCount mid(%d)|error(%v)", mid, err)
  303. return
  304. }
  305. for _, v := range tasks {
  306. if cnt >= v.TargetValue {
  307. _, err := s.newc.UpUserTask(c, mid, v.ID)
  308. if err != nil {
  309. log.Error("arcUpCount s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  310. }
  311. log.Info("arcUpCount finish task mid(%d)|count(%d)|", mid, cnt)
  312. }
  313. }
  314. }
  315. func (s *Service) acaPlayCount(c context.Context, mid int64, tasks []*newcomer.Task) {
  316. if len(tasks) == 0 {
  317. return
  318. }
  319. cnt, err := s.aca.PlayCount(c, mid)
  320. if err != nil {
  321. log.Error("acaPlayCount s.aca.PlayCount error(%v)", err)
  322. return
  323. }
  324. for _, v := range tasks {
  325. if cnt >= v.TargetValue {
  326. _, err := s.newc.UpUserTask(c, mid, v.ID)
  327. if err != nil {
  328. log.Error("acaPlayCount s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  329. continue
  330. }
  331. log.Info("acaPlayCount finish task mid(%d)|count(%d)|", mid, cnt)
  332. }
  333. }
  334. }
  335. func (s *Service) dataUpStat(c context.Context, mid int64, tasks []*newcomer.Task) {
  336. if len(tasks) == 0 {
  337. return
  338. }
  339. st, err := s.data.UpStat(c, mid, time.Now().AddDate(0, 0, -1).Add(-12*time.Hour).Format("20060102"))
  340. if err != nil || st == nil {
  341. log.Error("dataUpStat s.data.NewStat mid(%d) st(%+v) error(%v) ", mid, st, err)
  342. return
  343. }
  344. for _, v := range tasks {
  345. val := int64(v.TargetValue)
  346. state := false
  347. switch v.TargetType {
  348. case newcomer.TargetType004:
  349. if st.Reply >= val {
  350. state = true
  351. }
  352. log.Info("dataUpStat TargetType004 mid(%d)|v(%+v)|", mid, st.Reply)
  353. case newcomer.TargetType005:
  354. if st.Share >= val {
  355. state = true
  356. }
  357. log.Info("dataUpStat TargetType005 mid(%d)|v(%+v)|", mid, st.Share)
  358. case newcomer.TargetType006:
  359. if st.Fav >= val {
  360. state = true
  361. }
  362. log.Info("dataUpStat TargetType006 mid(%d)|v(%+v)|", mid, st.Fav)
  363. case newcomer.TargetType007:
  364. if st.Coin >= val {
  365. state = true
  366. }
  367. log.Info("dataUpStat TargetType007 mid(%d)|v(%+v)|", mid, st.Coin)
  368. case newcomer.TargetType008:
  369. if st.Like >= val {
  370. state = true
  371. }
  372. log.Info("dataUpStat TargetType008 mid(%d)|v(%+v)|", mid, st.Like)
  373. case newcomer.TargetType009:
  374. if st.Dm >= val {
  375. state = true
  376. }
  377. log.Info("dataUpStat TargetType009 mid(%d)|v(%+v)|", mid, st.Dm)
  378. }
  379. if state {
  380. _, err := s.newc.UpUserTask(c, mid, v.ID)
  381. if err != nil {
  382. log.Error("dataUpStat s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  383. }
  384. }
  385. }
  386. }
  387. func (s *Service) accProfileWithStat(c context.Context, mid int64, tasks []*newcomer.Task) {
  388. if len(tasks) == 0 {
  389. return
  390. }
  391. pl, err := s.acc.ProfileWithStat(c, mid)
  392. if err != nil {
  393. log.Error("accProfileWithStat s.acc.ProfileWithStat error(%v)", err)
  394. return
  395. }
  396. if pl == nil {
  397. return
  398. }
  399. for _, v := range tasks {
  400. if pl.Follower >= int64(v.TargetValue) {
  401. _, err := s.newc.UpUserTask(c, mid, v.ID)
  402. if err != nil {
  403. log.Error("accProfileWithStat s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  404. continue
  405. }
  406. log.Info("accProfileWithStat finish task mid(%d)|follower(%d)|", mid, pl.Follower)
  407. }
  408. }
  409. }
  410. func (s *Service) wmWaterMark(c context.Context, mid int64, tasks []*newcomer.Task) {
  411. if len(tasks) == 0 {
  412. return
  413. }
  414. wm, err := s.wm.WaterMark(c, mid)
  415. if err != nil {
  416. log.Error("wmWaterMark s.wm.WaterMark mid(%d) error(%v)", mid, err)
  417. return
  418. }
  419. for _, v := range tasks {
  420. if wm != nil && wm.State == 1 && wm.URL != "" {
  421. _, err := s.newc.UpUserTask(c, mid, v.ID)
  422. if err != nil {
  423. log.Error("wmWaterMark s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  424. continue
  425. }
  426. log.Info("wmWaterMark finish task mid(%d)|state(%d)|", mid, wm.State)
  427. }
  428. }
  429. }
  430. func (s *Service) accRelation(c context.Context, mid int64, tasks []*newcomer.Task) {
  431. if len(tasks) == 0 {
  432. return
  433. }
  434. fid := creatorMID //用户哔哩哔哩创作中心 mid
  435. fl, err := s.acc.Relations(c, mid, []int64{fid}, "")
  436. if err != nil {
  437. log.Error("accRelation s.acc.Relations mid(%d)|ip(%s)|error(%v)", mid, "", err)
  438. return
  439. }
  440. if fl == nil {
  441. return
  442. }
  443. for _, v := range tasks {
  444. if st, ok := fl[fid]; ok && (st == 6 || st == 2) {
  445. _, err := s.newc.UpUserTask(c, mid, v.ID)
  446. if err != nil {
  447. log.Error("accRelation s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  448. continue
  449. }
  450. log.Info("accRelation finish task mid(%d)|state(%d)|", mid, st)
  451. }
  452. }
  453. }
  454. func (s *Service) dataUpArchiveStatQuery(c context.Context, mid int64, tasks []*newcomer.Task) {
  455. if len(tasks) == 0 {
  456. return
  457. }
  458. st, err := s.data.UpArchiveStatQuery(c, mid, time.Now().AddDate(0, 0, -1).Add(-12*time.Hour).Format("20060102"))
  459. if err != nil || st == nil {
  460. log.Error("dataUpArchiveStatQuery s.data.UpArchiveStatQuery mid(%d)|err(%v)", mid, err)
  461. return
  462. }
  463. for _, v := range tasks {
  464. val := int64(v.TargetValue)
  465. state := false
  466. switch v.TargetType {
  467. case newcomer.TargetType013:
  468. if st.FromPhoneNum >= val {
  469. log.Info("dataUpArchiveStatQuery TargetType013 mid(%d)|v(%+v)|", mid, st.FromPhoneNum)
  470. state = true
  471. }
  472. case newcomer.TargetType015:
  473. if st.PlayV >= val {
  474. log.Info("dataUpArchiveStatQuery TargetType015 mid(%d)|v(%+v)|", mid, st.PlayV)
  475. state = true
  476. }
  477. case newcomer.TargetType016:
  478. if st.ReplyV >= val {
  479. log.Info("dataUpArchiveStatQuery TargetType016 mid(%d)|v(%+v)|", mid, st.ReplyV)
  480. state = true
  481. }
  482. case newcomer.TargetType017:
  483. if st.ShareV >= val {
  484. log.Info("dataUpArchiveStatQuery TargetType017 mid(%d)|v(%+v)|", mid, st.ShareV)
  485. state = true
  486. }
  487. case newcomer.TargetType018:
  488. if st.FavV >= val {
  489. log.Info("dataUpArchiveStatQuery TargetType018 mid(%d)|v(%+v)|", mid, st.FavV)
  490. state = true
  491. }
  492. case newcomer.TargetType019:
  493. if st.CoinV >= val {
  494. log.Info("dataUpArchiveStatQuery TargetType019 mid(%d)|v(%+v)|", mid, st.CoinV)
  495. state = true
  496. }
  497. case newcomer.TargetType020:
  498. if st.LikeV >= val {
  499. log.Info("dataUpArchiveStatQuery TargetType020 mid(%d)|v(%+v)|", mid, st.LikeV)
  500. state = true
  501. }
  502. case newcomer.TargetType021:
  503. if st.DmV >= val {
  504. log.Info("dataUpArchiveStatQuery TargetType021 mid(%d)|v(%+v)|", mid, st.DmV)
  505. state = true
  506. }
  507. }
  508. if state {
  509. _, err := s.newc.UpUserTask(c, mid, v.ID)
  510. if err != nil {
  511. log.Error("dataUpArchiveStatQuery s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  512. }
  513. }
  514. }
  515. }
  516. func (s *Service) orderGrowAccountState(c context.Context, mid int64, tasks []*newcomer.Task) {
  517. if len(tasks) == 0 {
  518. return
  519. }
  520. ac, err := s.order.GrowAccountState(c, mid, 0)
  521. if err != nil {
  522. log.Error("orderGrowAccountState s.order.GrowUpPlan mid(%d) error(%v)", mid, err)
  523. return
  524. }
  525. if ac == nil {
  526. return
  527. }
  528. for _, v := range tasks {
  529. if ac.State == 3 { //账号状态; 1: 未申请; 2: 待审核; 3: 已签约; 4.已驳回; 5.主动退出; 6:被动退出; 7:封禁
  530. _, err := s.newc.UpUserTask(c, mid, v.ID)
  531. if err != nil {
  532. log.Error("orderGrowAccountState s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  533. continue
  534. }
  535. log.Info("orderGrowAccountState finish task mid(%d)|state(%d)|", mid, ac.State)
  536. }
  537. }
  538. }
  539. func (s *Service) medalCheckMedal(c context.Context, mid int64, tasks []*newcomer.Task) {
  540. if len(tasks) == 0 {
  541. return
  542. }
  543. medal, err := s.medal.Medal(c, mid)
  544. if err != nil {
  545. log.Error("medalCheckMedal s.medal.Medal mid(%d) error(%v)", mid, err)
  546. return
  547. }
  548. if medal == nil {
  549. return
  550. }
  551. for _, v := range tasks {
  552. status, err := strconv.Atoi(medal.Status)
  553. if err != nil {
  554. log.Error("medalCheckMedal strconv.Atoi medal.Status(%s) error(%v)", medal.Status, err)
  555. continue
  556. }
  557. if status == 2 { //勋章审核状态 -1已拒绝 0未申请 1已申请 2已开通
  558. _, err := s.newc.UpUserTask(c, mid, v.ID)
  559. if err != nil {
  560. log.Error("medalCheckMedal s.newc.UpUserTask mid(%d)|task id(%d)|err(%v)", mid, v.ID, err)
  561. continue
  562. }
  563. log.Info("medalCheckMedal finish task mid(%d)|state(%d)|", mid, status)
  564. }
  565. }
  566. }
  567. func getTaskSortMap(tasks []*newcomer.Task) map[int8][]*newcomer.Task {
  568. taskSortMap := make(map[int8][]*newcomer.Task)
  569. for _, v := range tasks {
  570. switch v.TargetType {
  571. case newcomer.TargetType001, newcomer.TargetType014:
  572. taskSortMap[newcomer.ArcUpCount] = append(taskSortMap[newcomer.ArcUpCount], v)
  573. case newcomer.TargetType002: //分享
  574. case newcomer.TargetType003:
  575. taskSortMap[newcomer.AcaPlayCount] = append(taskSortMap[newcomer.AcaPlayCount], v)
  576. case newcomer.TargetType004, newcomer.TargetType005, newcomer.TargetType006, newcomer.TargetType007, newcomer.TargetType008, newcomer.TargetType009:
  577. taskSortMap[newcomer.DataUpStat] = append(taskSortMap[newcomer.DataUpStat], v)
  578. case newcomer.TargetType010, newcomer.TargetType022:
  579. taskSortMap[newcomer.AccProfileWithStat] = append(taskSortMap[newcomer.AccProfileWithStat], v)
  580. case newcomer.TargetType011:
  581. taskSortMap[newcomer.WmWaterMark] = append(taskSortMap[newcomer.WmWaterMark], v)
  582. case newcomer.TargetType012:
  583. taskSortMap[newcomer.AccRelation] = append(taskSortMap[newcomer.AccRelation], v)
  584. case newcomer.TargetType013, newcomer.TargetType015, newcomer.TargetType016, newcomer.TargetType017, newcomer.TargetType018, newcomer.TargetType019, newcomer.TargetType020, newcomer.TargetType021:
  585. taskSortMap[newcomer.DataUpArchiveStat] = append(taskSortMap[newcomer.DataUpArchiveStat], v)
  586. case newcomer.TargetType023:
  587. taskSortMap[newcomer.OrderGrowAccountState] = append(taskSortMap[newcomer.OrderGrowAccountState], v)
  588. case newcomer.TargetType024:
  589. taskSortMap[newcomer.MedalCheckMedal] = append(taskSortMap[newcomer.MedalCheckMedal], v)
  590. }
  591. }
  592. return taskSortMap
  593. }