智盟项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/task/md"
  6. "applet/app/utils"
  7. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok"
  8. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  9. "encoding/json"
  10. "github.com/tidwall/gjson"
  11. "time"
  12. )
  13. func TikTokTaskRelate() {
  14. p := 1
  15. for {
  16. param := map[string]interface{}{
  17. "page_no": p,
  18. "page_size": 100,
  19. }
  20. api, _ := tik_tok.TaskApi("get_agency_user_bind_record/", TikTokTaskToken(), zhios_third_party_utils.SerializeStr(param))
  21. user := gjson.Get(api, "data.results").String()
  22. if user == "" {
  23. break
  24. }
  25. var userData = make([]md.TikTokTaskRelate, 0)
  26. json.Unmarshal([]byte(user), &userData)
  27. if len(userData) == 0 {
  28. break
  29. }
  30. for _, v := range userData {
  31. var tmp model.TikTokPlanTeam
  32. db.ZhimengDb.Where("team_id=? and tik_tok_id=?", v.AgentId, v.DouyinId).Get(&tmp)
  33. if tmp.Id == 0 {
  34. tmp = model.TikTokPlanTeam{
  35. TeamId: utils.Int64ToStr(v.AgentId),
  36. Ext: v.AgencyTalentUid,
  37. TikTokId: v.DouyinId,
  38. IsShow: 1,
  39. Time: time.Unix(int64(v.BindTime), 0),
  40. }
  41. db.ZhimengDb.Insert(&tmp)
  42. }
  43. }
  44. p++
  45. }
  46. }