init12.8.go 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. package services
  2. import (
  3. "fmt"
  4. "hongze/hongze_cygx/models"
  5. "hongze/hongze_cygx/utils"
  6. )
  7. func init11() {
  8. var condition string
  9. var pars []interface{}
  10. list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
  11. if tmpErr != nil {
  12. fmt.Println(tmpErr)
  13. return
  14. }
  15. for _, v := range list {
  16. fmt.Println(v.UserId)
  17. UdpateYanxuanSpecialauthorArticleNum(v.UserId)
  18. }
  19. }
  20. func init8882228() {
  21. var condition string
  22. var pars []interface{}
  23. list, tmpErr := models.GetYanxuanSpecialList(0, condition, pars, 0, 99999)
  24. fmt.Println(len(list))
  25. fmt.Println(tmpErr)
  26. for _, v := range list {
  27. fmt.Println(v.Id)
  28. EsAddYanxuanSpecial(v.Id)
  29. }
  30. }
  31. func init77() {
  32. var condition string
  33. var pars []interface{}
  34. //condition = " AND is_del = 0 AND company_id > 1 AND article_id IN (SELECT article_id FROM cygx_article) "
  35. //total, err := models.GetCygxArticleHistoryRecordAllCountBycondition(condition, pars)
  36. //
  37. //if err != nil {
  38. // fmt.Println(err)
  39. // return
  40. //}
  41. //for i := 0; i <= total/2000; i++ {
  42. // allList, err := models.GetCygxArticleHistoryRecordAllList(condition, pars, 2000*i, 2000)
  43. // if err != nil {
  44. // fmt.Println("GetCygxArticleHistoryRecordByCompanyListNew Err:", err.Error())
  45. //
  46. // }
  47. // var items []*models.CygxArticleAndYanxuanRecord
  48. // fmt.Println(len(allList))
  49. // for _, v := range allList {
  50. // item := new(models.CygxArticleAndYanxuanRecord)
  51. // item.SourceId = v.ArticleId
  52. // item.Source = utils.CYGX_OBJ_ARTICLE
  53. // item.UserId = v.UserId
  54. // item.RealName = v.RealName
  55. // item.Mobile = v.Mobile
  56. // item.Email = v.Email
  57. // item.CompanyId = v.CompanyId
  58. // item.CompanyName = v.CompanyName
  59. // item.CompanyId = v.CompanyId
  60. // item.CreateTime = v.CreateTime
  61. // item.ModifyTime = v.ModifyTime
  62. // item.StopTime = v.StopTime
  63. //
  64. // if v.Source == "CELUE" {
  65. // item.RegisterPlatform = 3
  66. // } else if v.Source == "WEB" {
  67. // item.RegisterPlatform = 2
  68. // } else {
  69. // item.RegisterPlatform = 1
  70. // }
  71. //
  72. // items = append(items, item)
  73. // }
  74. //
  75. // err = models.AddCygxArticleAndYanxuanRecordMulti(items)
  76. // if err != nil {
  77. // fmt.Println(err)
  78. // }
  79. //
  80. //}
  81. condition = " AND yanxuan_special_id IN (SELECT id FROM cygx_yanxuan_special ) "
  82. list, err := models.GetCygxYanxuanSpecialRecordRespList(condition, pars, 0, 99999)
  83. if err != nil {
  84. fmt.Println("GetCygxArticleHistoryRecordByCompanyListNew Err:", err.Error())
  85. }
  86. var items []*models.CygxArticleAndYanxuanRecord
  87. fmt.Println(len(list))
  88. for _, v := range list {
  89. item := new(models.CygxArticleAndYanxuanRecord)
  90. item.SourceId = v.YanxuanSpecialId
  91. item.Source = utils.CYGX_OBJ_YANXUANSPECIAL
  92. item.UserId = v.UserId
  93. item.RealName = v.RealName
  94. item.Mobile = v.Mobile
  95. item.Email = v.Email
  96. item.CompanyId = v.CompanyId
  97. item.CompanyName = v.CompanyName
  98. item.CompanyId = v.CompanyId
  99. item.CreateTime = v.CreateTime
  100. item.ModifyTime = v.ModifyTime
  101. item.StopTime = v.StopTime
  102. item.RegisterPlatform = v.RegisterPlatform
  103. items = append(items, item)
  104. }
  105. fmt.Println(len(items))
  106. //return
  107. err = models.AddCygxArticleAndYanxuanRecordMulti(items)
  108. if err != nil {
  109. fmt.Println(err)
  110. }
  111. }
  112. // 更新文章收藏数量
  113. func initcc() {
  114. var condition string
  115. var pars []interface{}
  116. list, e := models.GetYanxuanSpecialListBycondition(condition, pars, 0, 9999)
  117. if e != nil && e.Error() != utils.ErrNoRow() {
  118. fmt.Println(e)
  119. return
  120. }
  121. for _, v := range list {
  122. fmt.Println(v.Id)
  123. UdpateYanxuanSpecialCollect(v.Id)
  124. }
  125. }
  126. // 更新作者粉丝数量
  127. func initFansNum() {
  128. var condition string
  129. var pars []interface{}
  130. list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
  131. if tmpErr != nil {
  132. fmt.Println(tmpErr)
  133. return
  134. }
  135. for _, v := range list {
  136. fmt.Println(v.UserId)
  137. UdpateYanxuanSpecialFansNum(v.UserId)
  138. }
  139. }
  140. // 专栏Pv
  141. func initPv() {
  142. var condition string
  143. var pars []interface{}
  144. list, tmpErr := models.GetYanxuanSpecialList(0, condition, pars, 0, 99999)
  145. fmt.Println(len(list))
  146. fmt.Println(tmpErr)
  147. for _, v := range list {
  148. condition = ""
  149. pars = make([]interface{}, 0)
  150. condition = " AND company_id != 16 AND user_id > 0 AND yanxuan_special_id = ? "
  151. pars = append(pars, v.Id)
  152. totalYanxuanSpecial, err := models.GetCygxYanxuanSpecialRecordCount(condition, pars)
  153. if err != nil {
  154. fmt.Println(err)
  155. return
  156. }
  157. totalYanxuanSpecialUv, err := models.GetCygxYanxuanSpecialRecordCountGroup(condition, pars)
  158. if err != nil {
  159. fmt.Println(err)
  160. return
  161. }
  162. fmt.Println(totalYanxuanSpecial, "____", totalYanxuanSpecialUv)
  163. err = models.UpdateYanxuanSpecialPvNUm(totalYanxuanSpecial, v.Id)
  164. if err != nil {
  165. fmt.Println(err)
  166. return
  167. }
  168. err = models.UpdateYanxuanSpecialUvUm(totalYanxuanSpecialUv, v.Id)
  169. if err != nil {
  170. fmt.Println(err)
  171. return
  172. }
  173. }
  174. }
  175. // 作者Pv
  176. func inituser() {
  177. var condition string
  178. var pars []interface{}
  179. list, tmpErr := models.GetYanxuanSpecialAuthorList(condition, pars, 0, 9999)
  180. fmt.Println(len(list))
  181. fmt.Println(tmpErr)
  182. for _, v := range list {
  183. condition = ""
  184. pars = make([]interface{}, 0)
  185. condition = " AND company_id != 16 AND user_id > 0 AND yanxuan_special_id IN ( SELECT id FROM cygx_yanxuan_special WHERE user_id = ? ) "
  186. pars = append(pars, v.UserId)
  187. totalYanxuanSpecial, err := models.GetCygxYanxuanSpecialRecordCount(condition, pars)
  188. if err != nil {
  189. fmt.Println(err)
  190. return
  191. }
  192. totalYanxuanSpecialUv, err := models.GetCygxYanxuanSpecialRecordCountGroup(condition, pars)
  193. if err != nil {
  194. fmt.Println(err)
  195. return
  196. }
  197. fmt.Println(totalYanxuanSpecial, "____", totalYanxuanSpecialUv)
  198. err = models.UpdateYanxuanSpecialauthorPvNUm(totalYanxuanSpecial, v.UserId)
  199. if err != nil {
  200. fmt.Println(err)
  201. return
  202. }
  203. err = models.UpdateYanxuanSpecialauthorUvUm(totalYanxuanSpecialUv, v.UserId)
  204. if err != nil {
  205. fmt.Println(err)
  206. return
  207. }
  208. }
  209. }
  210. func initbug111() {
  211. var condition string
  212. var pars []interface{}
  213. condition = " AND company_id = 5593 AND mobile != '' GROUP BY mobile ORDER BY mobile DESC LIMIT 0,5000 "
  214. signUpDetailList, err := models.GetSignupDetailList(condition, pars)
  215. if err != nil && err.Error() != utils.ErrNoRow() {
  216. fmt.Println(err)
  217. return
  218. }
  219. var mobiles []string
  220. for _, v := range signUpDetailList {
  221. mobiles = append(mobiles, v.Mobile)
  222. }
  223. listUser, e := models.GetWxUserByMobiles(mobiles)
  224. if e != nil {
  225. fmt.Println(e)
  226. return
  227. }
  228. mapMobile := make(map[string]int)
  229. var itemsUpdate []*models.CygxActivitySignupDetail
  230. for _, v := range listUser {
  231. if v.Mobile == "" {
  232. continue
  233. }
  234. mapMobile[v.Mobile] = v.UserId
  235. var itemDetail = new(models.CygxActivitySignupDetail)
  236. itemDetail.Mobile = v.Mobile
  237. itemDetail.UserId = v.UserId
  238. itemsUpdate = append(itemsUpdate, itemDetail)
  239. }
  240. fmt.Println(len(itemsUpdate))
  241. err = models.UpdateActivitySignupDetailMultiUserId(itemsUpdate)
  242. if err != nil {
  243. fmt.Println(err)
  244. return
  245. }
  246. }