智盟项目
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

361 rader
17 KiB

  1. package svc
  2. import (
  3. "applet/app/cfg"
  4. offical "applet/app/db/official"
  5. md2 "applet/app/es/md"
  6. md3 "applet/app/md"
  7. "applet/app/task/md"
  8. "applet/app/utils"
  9. "applet/app/utils/cache"
  10. "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
  11. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok"
  12. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  13. "encoding/json"
  14. "fmt"
  15. "github.com/jinzhu/copier"
  16. "github.com/syyongx/php2go"
  17. "github.com/tidwall/gjson"
  18. "strings"
  19. "time"
  20. )
  21. func TikTokTask() {
  22. //doc, _ := es.FirstDoc(md2.ZhiosTikTokTaskEsIndex, "tik_tok_task_tt99fdef4006c36ff001")
  23. //fmt.Println(string(doc.Source))
  24. //return
  25. //es.CreateIndexIfNotExists(md2.ZhiosTikTokTaskEsIndex, md2.ZhiosTikTokTaskEsMapping)
  26. //es.CreateIndexIfNotExists(md2.ZhiosTikTokTaskDetailEsIndex, md2.ZhiosTikTokTaskDetailEsMapping)
  27. appidList := offical.MasterListCfgGetOneData("0", "tik_tok_task_appid")
  28. split := strings.Split(appidList, ";")
  29. for _, v := range split {
  30. endTime := time.Now().Unix()
  31. startTime := endTime - 7*86400
  32. if endTime > time.Now().Unix() {
  33. endTime = time.Now().Unix()
  34. }
  35. param := map[string]interface{}{
  36. "appid": v,
  37. "create_start_time": startTime,
  38. "create_end_time": endTime,
  39. }
  40. api, _ := tik_tok.TaskApi("query_app_task_id/", TikTokTaskToken(), zhios_third_party_utils.SerializeStr(param))
  41. taskIds := gjson.Get(api, "data.task_ids").String()
  42. fmt.Println(taskIds)
  43. if taskIds == "" || taskIds == "[]" {
  44. fmt.Println(endTime)
  45. offical.MasterListCfgSave("0", "tik_tok_task_appid_time_"+v, utils.Int64ToStr(endTime))
  46. continue
  47. }
  48. CommAddTask("tik_tok_task_"+v, taskIds)
  49. var tmp = make([]int64, 0)
  50. json.Unmarshal([]byte(taskIds), &tmp)
  51. GetTaskDetail(v, tmp)
  52. fmt.Println(endTime)
  53. offical.MasterListCfgSave("0", "tik_tok_task_appid_time_"+v, utils.Int64ToStr(endTime))
  54. }
  55. }
  56. func GetTaskDetail(appId string, tmp []int64) {
  57. data := md3.KujiangData
  58. var kujiang []md.KuJiang
  59. json.Unmarshal([]byte(data), &kujiang)
  60. kujiangMap := make(map[string]md.KuJiang)
  61. for _, v := range kujiang {
  62. kujiangMap[utils.IntToStr(v.BookId)] = v
  63. }
  64. xinghes := map[string]string{
  65. "7377197073747263522": "https://pan.baidu.com/s/1MZIxhxCu8OmxxcyRGJgWZw?pwd=szb7",
  66. "7377173468921561107": "https://pan.baidu.com/s/1ln8r84Y5d-mKR6aaG-6icQ?pwd=ssdy",
  67. "7376820249691324457": "https://pan.baidu.com/s/16qnmC03QmYGxfvfHpVOPbg?pwd=ks1p",
  68. "7376445276631875647": "https://pan.baidu.com/s/1CRNqanQDrzPpkrhCDxa3rQ?pwd=p8ot",
  69. "7376060139776032818": "https://pan.baidu.com/s/1b8HMzsiQCULZW3wYXro1qw?pwd=8sdo",
  70. "7374948827419213834": "https://pan.baidu.com/s/1Tkyt0TvamMMvD1LD-Nmamg?pwd=b05e",
  71. "7374701175310221339": "https://pan.baidu.com/s/1JOzWUcJeVwu9NShnieBMXw?pwd=kqjj",
  72. "7374581090054389801": "https://pan.baidu.com/s/1PKT83xe0hMIuat0D81iumQ?pwd=1akn",
  73. "7373833654033809447": "https://pan.baidu.com/s/15cMH1ds8gT0CGymSBO1NIQ?pwd=sqfr",
  74. "7373480427329159203": "https://pan.baidu.com/s/1-OYIB1RmTXl3SeynP3Dy7Q?pwd=d2tx",
  75. "7372912752035119144": "https://pan.baidu.com/s/1ICIGA5SBCXNwugJM3IxaoA?pwd=eae0",
  76. "7372349272928403482": "https://pan.baidu.com/s/1zms9c0CG07-2kZVFKxYzVw?pwd=fie2",
  77. "7372080132082778152": "https://pan.baidu.com/s/125VKEkXRa3FkgTdR7gqhvw?pwd=wrbx",
  78. "7372009394361401344": "https://pan.baidu.com/s/1acDqOnZEfv6IIFEAUl5ffQ?pwd=1nyb",
  79. "7372013980895985701": "https://pan.baidu.com/s/1azZYwHx1jWLjtz8gc2leFA?pwd=a53c",
  80. "7371376162850750501": "https://pan.baidu.com/s/14vjCx7AKi0gIsljs-0XGuw?pwd=ib54",
  81. "7371371539645661211": "https://pan.baidu.com/s/1Xy0x6qlQDjR7LIjkX01nGA?pwd=oik9",
  82. "7371366982576308287": "https://pan.baidu.com/s/1VjwcogPOHuy25te9zEBERw?pwd=29sq",
  83. "7371001858434793526": "https://pan.baidu.com/s/1lcXNSZ9z6be83v4UehkM-w?pwd=oy0r",
  84. "7371001571926081590": "https://pan.baidu.com/s/1ETttvHJd2_fDNuJRuCaKsQ?pwd=dv28",
  85. "7370904753900945460": "https://pan.baidu.com/s/1PVM9Jpaf93V_--0d1UW9Dg?pwd=bogh",
  86. "7370911902962221119": "https://pan.baidu.com/s/1DQAvDk8zE0glH81TRvQhfg?pwd=ye4u",
  87. "7370857345389297699": "https://pan.baidu.com/s/1MhJYTpXqUgPnOrJ2mvVClQ?pwd=mo78",
  88. "7369875298587836455": "https://pan.baidu.com/s/1P5mGA0QKiRcHHgE1Bzz1cg?s4pn",
  89. "7369875429492113419": "https://pan.baidu.com/s/1ZHldm5KDXka_5arInJiDQw?pwd=avqw",
  90. "7369888148781809698": "https://pan.baidu.com/s/1ErZRBvvMOQlaZcyuDHfB_g?pwd=lo2y",
  91. "7369813564837642281": "https://pan.baidu.com/s/1-Ks0ArP_8mKIsNgDAqI7PA?pwd=d86a",
  92. "7369751707867283506": "https://pan.baidu.com/s/14qOLJey1bWEA0pqFF6xhgw?pwd=5cmc",
  93. "7369503459801956371": "https://pan.baidu.com/s/1vyXKrJeuvx5x4w-acbVa6A?pwd=qugd",
  94. "7369391591624163364": "https://pan.baidu.com/s/1eM2tbZ8yj6zIDqovSO49_A?pwd=aqg2",
  95. "7369392341066498111": "https://pan.baidu.com/s/12t76uMp_3sn8hdMDoXwppg?pwd=tpfe",
  96. "7369148051795017740": "https://pan.baidu.com/s/13_S-8fE21nqSofjgx_rWKw?pwd=uns8",
  97. "7369059651461283894": "https://pan.baidu.com/s/1Fqbpz35M8dwxX8tFhpyQhQ?pwd=uexq",
  98. "7369037096285175808": "https://pan.baidu.com/s/1_Y2LnJeAG1-QJUCNegiKuA?pwd=jcjv",
  99. "7368762632674803751": "https://pan.baidu.com/s/1bjiyXlw_sMQ9YR4YALu3ZQ?pwd=aic8",
  100. "7368679769661079564": "https://pan.baidu.com/s/1Rrqm6C_VCP9pTLIiytJFew?pwd=0w3y",
  101. "7368678622070489139": "https://pan.baidu.com/s/1ImxFZxOihIxmpKs7FQNC-A?pwd=6dgz",
  102. "7368653781052981283": "https://pan.baidu.com/s/15jtQvEYxQujqY3C_zeE_fA?pwd=mcy5",
  103. "7368329261691961371": "https://pan.baidu.com/s/171ZRDKRRU3aP7ZMBDy0vsQ?pwd=sipq",
  104. "7368324603678031882": "https://pan.baidu.com/s/1B5Qh3vs3Ivfk8rTLCc1tng?pwd=emws",
  105. "7367710375317520399": "https://pan.baidu.com/s/1aEaDUhSM-4VDTxn40wXm3A?pwd=6e8b",
  106. "7367316323904372772": "https://pan.baidu.com/s/1kf58ZCgI0BgCLQapMfrTbQ?pwd=cceg",
  107. "7366906746314555404": "https://pan.baidu.com/s/1MNfbPba3Nt2pTnHTfBUEBA?pwd=ew3v",
  108. "7366486018851209235": "https://pan.baidu.com/s/1QWF63ao80TT3BAMV0-QpRA?pwd=rcs5",
  109. "7366151010714157097": "https://pan.baidu.com/s/1055EkwtBxPM0Sw6L5gOCFw?pwd=1sq9",
  110. "7366102746245726248": "https://pan.baidu.com/s/1WzXSrkemz0Hm0DTNcmTpxA?pwd=y2j0",
  111. "7365004815451062312": "https://pan.baidu.com/s/1q2XYO3GraSEvdX2F3JcX4Q?pwd=glby",
  112. "7364352540936290358": "https://pan.baidu.com/s/11JDyHl97egRjDKxnH9D7rQ?pwd=mr0l",
  113. "7363525995279745035": "https://pan.baidu.com/s/1te89FR6rULnXV7g5BaRIPA?pwd=hx47",
  114. "7363532419464429619": "https://pan.baidu.com/s/1JBXBddSdLeZn-BOFYCjQrA?pwd=y1iu",
  115. "7363505120711098368": "https://pan.baidu.com/s/1iAP5OSU46CFz0vyOYGOBCA?pwd=ft2t",
  116. "7363505153716125731": "https://pan.baidu.com/s/1Lpuc4iUBWxndb1xTcRoicQ?pwd=390v",
  117. "7363505437439918121": "https://pan.baidu.com/s/1Y_RnixE05gaMptBrhC0DQw?pwd=n3ni",
  118. "7363157598629068819": "https://pan.baidu.com/s/1NPtnl5EBK7jRRgk7kSStPg?pwd=86p6",
  119. "7363157659111211027": "https://pan.baidu.com/s/1PO8ulobc-54is1QBikJSEQ?pwd=gfek",
  120. "7362021099053383714": "https://pan.baidu.com/s/19mqfaAt5zovNO1sb0e-bxw?pwd=qae9",
  121. "7361723753094610980": "https://pan.baidu.com/s/1oybfSKC4FUWGw81DH6wqXw?pwd=a83p",
  122. "7361713709670006810": "https://pan.baidu.com/s/1r0EAT_q6DKFatnbwXZfeTw?pwd=7h74",
  123. "7361659856501129279": "https://pan.baidu.com/s/1XtOabN5ZGsxG9x_CjF2Aig?pwd=ztet",
  124. "7361314021947015222": "https://pan.baidu.com/s/1Wq3RyPsSUw1PBXqPD7nHCA?pwd=hxip",
  125. "7360937011936510006": "https://pan.baidu.com/s/1WlN5HLmcaADy0jGdiCaGFQ?pwd=tiwb",
  126. "7359423244304269350": "https://pan.baidu.com/s/1_c4cXt25ky2yDOXm2kmL5A?pwd=bcrq",
  127. "7359058838047162368": "https://pan.baidu.com/s/1HkBnlRR27JBKsQheTJxmcQ?pwd=3kcd",
  128. "7358681447030390784": "https://pan.baidu.com/s/1oWMuF5itpF77lls_vSGqJA?pwd=p3wc",
  129. "7358322670871576616": "https://pan.baidu.com/s/13RET87iAbgZlj-jn5mUwUg?pwd=y9rd",
  130. "7357194974695391268": "https://pan.baidu.com/s/1cBU9PIXW99Y5W1XhvdPIpA?pwd=uxc6",
  131. "7356840659325583414": "https://pan.baidu.com/s/1znMbDDAnIRQ7PwtiznOvTQ?pwd=9nj7",
  132. "7355357328834658319": "https://pan.baidu.com/s/1uoDFjFm9iWt5eXGCYwx0Sg?pwd=9i8p",
  133. "7353386971026309183": "https://pan.baidu.com/s/1LCgvkFblrE43e4JtxSOR4Q?pwd=svb5",
  134. "7350898126372323369": "https://pan.baidu.com/s/1P6E4vYl-2x0s_qw1X5oviQ?pwd=84xz",
  135. "7350859162219184139": "https://pan.baidu.com/s/1mUHucK0x5af8G40hJbLzqw?pwd=0dh1",
  136. "7349282971213512754": "https://pan.baidu.com/s/18QgGyqjzW7aImhQ8a2_SJQ?pwd=aswx",
  137. "7348970835950043147": "https://pan.baidu.com/s/1JEL9kvkrvzcZUKwexlhPhw?pwd=gadt",
  138. "7348684759972724745": "https://pan.baidu.com/s/1sqnsG74rqE8vKVz4-mibgw?pwd=q7us",
  139. "7348649376765460531": "https://pan.baidu.com/s/18AIW_J7XHGZFbEsa4zbEZw?pwd=akgy",
  140. "7348320058776502322": "https://pan.baidu.com/s/1RImOhdsbwT-d58U8x9Cl7g?pwd=5oy1",
  141. "7348220904138227746": "https://pan.baidu.com/s/1WL1ZCM5w9opVJRHq2_tQkg?pwd=08gs",
  142. "7347939532555304972": "https://pan.baidu.com/s/1A3vmJaRPU9YFmNZje9ttDw?pwd=2vjp",
  143. "7347576656296443941": "https://pan.baidu.com/s/106MDSCSM7BCTx_1kex65gA?pwd=t1gm",
  144. "7346064108011257897": "https://pan.baidu.com/s/1NY7JuB-2KUlvtbKZqI7vew?pwd=kpt4",
  145. "7345229086283055156": "https://pan.baidu.com/s/1mkkF_bhOh3E7sZf6ymIv0g?pwd=zl3m",
  146. "7344970667663589410": "https://pan.baidu.com/s/17e5bb0dGQ183zHWkO49cmg?pwd=l193",
  147. "7343744932248600616": "https://pan.baidu.com/s/1vL1g1aGhgXMtNEah4TQFxw?pwd=ub0r",
  148. "7342692698744193063": "https://pan.baidu.com/s/1MOaSBkuHGzvv9n1GPc-B3Q?pwd=69fg",
  149. "7340706698497212455": "https://pan.baidu.com/s/1vB8aG2U3kserxWsm3bR1Zg?pwd=qszf",
  150. "7340019974860914715": "https://pan.baidu.com/s/1bykE9LVcNCePutJ4Rmz14A?pwd=dvrx",
  151. "7338982451538133026": "https://pan.baidu.com/s/10GqBT2oBHTdIrtLvm7C3Mg?pwd=203x",
  152. "7336393071648587816": "https://pan.baidu.com/s/1Zl0zxZg3dcTuGsge8pD-SA?pwd=este",
  153. "7335313319047315456": "https://pan.baidu.com/s/1QQZQlgy-WN9hXKjSe59smg?pwd=klno",
  154. "7334158528300482571": "https://pan.baidu.com/s/1DuWh9nZwec3uTAoqwLzIEA?pwd=qs0v",
  155. "7333417334876454949": "https://pan.baidu.com/s/1l5FvB35F9YPnwllSpYPvSA?pwd=ogdy",
  156. "7333416896286507044": "https://pan.baidu.com/s/1S2E0DXe1w6z5kU5r9fGGoQ?pwd=k0br",
  157. "7332303743809011739": "https://pan.baidu.com/s/1S4I4smzV8I3-jytmua1kLg?pwd=2zhv",
  158. "7331643707597864997": "https://pan.baidu.com/s/1WWMY8bWnNLSxCaD0x_Gv0Q?pwd=scm5",
  159. "7331637776204480575": "https://pan.baidu.com/s/1PAYJUrYhZ71XivTZFSxw5Q?pwd=v1n7",
  160. "7330834016368623657": "https://pan.baidu.com/s/1yB46HJtIjjffc0w8RmeRTQ?pwd=x1v3",
  161. "7330529933564919823": "https://pan.baidu.com/s/1PzKUtgetU8bVTILFYxSrNQ?pwd=ul4a",
  162. "7330518079224512550": "https://pan.baidu.com/s/1I1o9UV89oYCVmzJc5bCe1g?pwd=5nxe",
  163. "7327911477510209548": "https://pan.baidu.com/s/1ebMtvlMV2UCCvTOx7znFsA?pwd=d00o",
  164. "7326049857058177024": "https://pan.baidu.com/s/1WtKwzdeiPQz0AjKzieU_6w?pwd=prkh",
  165. "7324972262531153959": "https://pan.baidu.com/s/1qZCfNogUvYWWlkJ225qNQQ?pwd=l0ui",
  166. "7324518767126429734": "https://pan.baidu.com/s/1J7CJYI76-I-9APIq1pzE5A?pwd=ai6t",
  167. "7324518215852228644": "https://pan.baidu.com/s/1w7qG9kSfpZD1hCohnU8vUQ?pwd=0a3w",
  168. "7324510965024751650": "https://pan.baidu.com/s/1bzzIqBftk030n8ZRddnnRA?pwd=6k6e",
  169. "7320876050387353611": "https://pan.baidu.com/s/1Y6oe-upHqA72ivDp4MWBUA?pwd=04th",
  170. "7318971545959170058": "https://pan.baidu.com/s/1jEOgXAR7e5Oqd3KZ2e1zyg?pwd=wvb9",
  171. "7313727507914686476": "https://pan.baidu.com/s/1awg3uiLk5t1EJPGiUXhxyQ?pwd=ppwu",
  172. "7313751212422201379": "https://pan.baidu.com/s/1awg3uiLk5t1EJPGiUXhxyQ?pwd=ppwu",
  173. "7312337908660437004": "https://pan.baidu.com/s/1Q-6nsaWTmj3UWCdSdOQErw?pwd=4sl3",
  174. "7312292128947257383": "https://pan.baidu.com/s/1D71HmPOWkAeBmVk9ujU8dQ?pwd=ta3n",
  175. "7312294620745056267": "https://pan.baidu.com/s/1CI0fC50UWsxKLcQ4AIlUhQ?pwd=pi51",
  176. "7312295241607790643": "https://pan.baidu.com/s/1-8w4R1ypihnHw-djYQHXcg?pwd=p5h8",
  177. "7312292122370031670": "https://pan.baidu.com/s/1pZM-FzOQQrZjhgQ_Kn1nAQ?pwd=ryu0",
  178. "7312291614532599843": "https://pan.baidu.com/s/16794mteTYOn6nzu8k1gIBg?pwd=xdsg",
  179. "7312007303753957395": "https://pan.baidu.com/s/1hEyBrPTm0Rtkl1mP-1myxQ?pwd=di9v",
  180. }
  181. for _, v := range tmp {
  182. time.Sleep(time.Microsecond * 1000)
  183. param := map[string]interface{}{
  184. "appid": appId,
  185. "query_params_type": "1",
  186. "query_params_content": utils.Int64ToStr(v),
  187. "page_no": "1",
  188. "page_size": "10",
  189. }
  190. api, _ := tik_tok.TaskApi("query_task_info/", TikTokTaskToken(), zhios_third_party_utils.SerializeStr(param))
  191. detail := gjson.Get(api, "data.tasks").String()
  192. if detail == "" {
  193. fmt.Println("失败", v)
  194. continue
  195. }
  196. var tmpDetail = make([]md.TikTokTaskDetail, 0)
  197. json.Unmarshal([]byte(detail), &tmpDetail)
  198. for _, v1 := range tmpDetail {
  199. var tmpIn md.TikTokTaskDetailSecond
  200. err := copier.Copy(&tmpIn, &v1)
  201. fmt.Println(err)
  202. tmpIn.OrientedTalentRelList = utils.SerializeStr(v1.OrientedTalentRelList)
  203. tmpIn.ReferMaCaptures = utils.SerializeStr(v1.ReferMaCaptures)
  204. tmpIn.TaskTags = utils.SerializeStr(v1.TaskTags)
  205. tmpIn.ReferVideoCaptures = utils.SerializeStr(v1.ReferVideoCaptures)
  206. videoTmpStr := "bookId="
  207. if tmpIn.Appid == "tt38e94e54a7d70c4601" {
  208. videoTmpStr = "cid="
  209. } else if strings.Contains(tmpIn.StartPage, "novelid=") {
  210. videoTmpStr = "novelid="
  211. } else if strings.Contains(tmpIn.StartPage, "book_id=") {
  212. videoTmpStr = "book_id="
  213. } else if strings.Contains(tmpIn.StartPage, "video_id=") {
  214. videoTmpStr = "video_id="
  215. }
  216. ex := strings.Split(tmpIn.StartPage, videoTmpStr)
  217. if len(ex) > 1 {
  218. exSecond := strings.Split(ex[1], "&")
  219. tmpIn.VideoId = exSecond[0]
  220. }
  221. if tmpIn.VideoId == "" {
  222. fmt.Println("失败", tmpIn)
  223. continue
  224. }
  225. if tmpIn.Status != 2 {
  226. tmpIn.TaskEndTime = int(time.Now().Unix() - 10)
  227. }
  228. for _, v2 := range md.TaskAddList {
  229. if tmpIn.Appid == v2["name"] { //
  230. tmp2 := md.Cinema5bmsData{
  231. Description: "",
  232. ImageUrl: tmpIn.TaskIcon,
  233. Material: "",
  234. OnlineTime: time.Unix(int64(tmpIn.TaskStartTime), 0).Format("2006-01-02 15:04:05"),
  235. Type: v2["second_type"],
  236. Title: tmpIn.TaskName,
  237. UpdateTime: int(time.Now().Unix()),
  238. Time: tmpIn.TaskStartTime,
  239. Appid: v2["name"],
  240. Id: utils.StrToInt(tmpIn.VideoId),
  241. IsClose: 0,
  242. IsHot: 0,
  243. FirstCate: v2["type"],
  244. SecondCate: "",
  245. Platform: "",
  246. }
  247. if v2["second_type"] == "xinghe" {
  248. tmp2.Material = xinghes[utils.Int64ToStr(tmpIn.TaskId)]
  249. }
  250. uniqueId := php2go.Md5(tmp2.Appid + "_" + tmp2.Type + "_" + tmp2.FirstCate + "_" + utils.IntToStr(tmp2.Id))
  251. if tmp2.Appid == "ttbed9c86421e54c8501" {
  252. doc, _ := es.FirstDoc(md2.ZhiosNewVideo, uniqueId)
  253. if tmpIn.TaskEndTime > int(time.Now().Unix()) {
  254. tmp2.Platform = "tikTok"
  255. }
  256. if doc != nil && strings.Contains(gjson.Get(string(doc.Source), "platform").String(), "kuaishou") {
  257. if tmpIn.TaskEndTime > int(time.Now().Unix()) {
  258. tmp2.Platform = "tikTok,kuaishou"
  259. } else {
  260. tmp2.Platform = "kuaishou"
  261. }
  262. }
  263. jiang, ok := kujiangMap[tmpIn.VideoId]
  264. if ok {
  265. tmp2.Material = jiang.WebDiskUrl
  266. }
  267. } else {
  268. tmp2.Platform = "tikTok"
  269. if tmpIn.TaskEndTime < int(time.Now().Unix()) {
  270. tmp2.IsClose = 1
  271. }
  272. }
  273. if tmp2.Platform == "" {
  274. tmp2.IsClose = 1
  275. }
  276. fmt.Println(uniqueId)
  277. tmp2.Key = uniqueId
  278. commAddNew(uniqueId, tmp2)
  279. }
  280. }
  281. CommAddTaskDetail(utils.Int64ToStr(tmpIn.TaskId), tmpIn)
  282. }
  283. }
  284. }
  285. func CommAddTask(uniqueId string, taskIds string) {
  286. doc, _ := es.FirstDoc(md2.ZhiosTikTokTaskEsIndex, uniqueId)
  287. if doc == nil {
  288. var tmpData = map[string]string{
  289. "task_ids": taskIds,
  290. }
  291. createDocRet, err := es.CreateDoc(md2.ZhiosTikTokTaskEsIndex, uniqueId, tmpData)
  292. if err != nil {
  293. return
  294. }
  295. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  296. } else {
  297. source := doc.Source
  298. tmpData := make(map[string]string)
  299. json.Unmarshal(source, &tmpData)
  300. var tmpOld = make([]int64, 0)
  301. json.Unmarshal([]byte(tmpData["task_ids"]), &tmpOld)
  302. var tmp = make([]int64, 0)
  303. json.Unmarshal([]byte(taskIds), &tmp)
  304. tmp = utils.MergeArr(tmpOld, tmp)
  305. tmp = utils.UniqueArr(tmp)
  306. tmpData = map[string]string{
  307. "task_ids": utils.SerializeStr(tmp),
  308. }
  309. createDocRet, err := es.UpdateDoc(md2.ZhiosTikTokTaskEsIndex, uniqueId, tmpData)
  310. if err != nil {
  311. return
  312. }
  313. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  314. }
  315. }
  316. func CommAddTaskDetail(uniqueId string, tmp md.TikTokTaskDetailSecond) {
  317. doc, _ := es.FirstDoc(md2.ZhiosTikTokTaskDetailEsIndex, uniqueId)
  318. if doc == nil {
  319. createDocRet, err := es.CreateDoc(md2.ZhiosTikTokTaskDetailEsIndex, uniqueId, tmp)
  320. if err != nil {
  321. return
  322. }
  323. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  324. } else {
  325. createDocRet, err := es.UpdateDoc(md2.ZhiosTikTokTaskDetailEsIndex, uniqueId, tmp)
  326. if err != nil {
  327. return
  328. }
  329. fmt.Printf("CreateDoc ==> %+v \n\n", createDocRet)
  330. }
  331. }
  332. func TikTokTaskToken() string {
  333. tikTokOpenAppkey := offical.MasterListCfgGetOneData("0", "tik_tok_task_open_appkey")
  334. tikTokOpenAppSecret := offical.MasterListCfgGetOneData("0", "tik_tok_task_open_app_secret")
  335. args := map[string]string{
  336. "appkey": tikTokOpenAppkey,
  337. "appSecret": tikTokOpenAppSecret,
  338. }
  339. key := "tikTok_client_" + args["appkey"]
  340. tokeStr, err := cache.GetString(key)
  341. if cfg.Prd == false {
  342. return tokeStr
  343. }
  344. if tokeStr == "" || err != nil {
  345. token := tik_tok.GetClientToken(args)
  346. if token["tik_tok_acc_token"] != "" {
  347. tokeStr = token["tik_tok_acc_token"]
  348. cache.SetEx(key, token["tik_tok_acc_token"], utils.StrToInt(token["expires_in"]))
  349. }
  350. }
  351. return tokeStr
  352. }