company_interaction_num.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxCompanyInteractionNum struct {
  7. Id int `orm:"column(id);pk"`
  8. CompanyId int `description:"用户ID"`
  9. ArticleHistoryNum int `description:"文章浏览数量"`
  10. ArticleCountNum int `description:"文章收藏数量"`
  11. ChartCountNum int `description:"图表收藏"`
  12. IndustryFllowNum int `description:"产业关注数量"`
  13. DepartmentFollowNum int `description:"作者关注数量"`
  14. KeyWordNum int `description:"关键词搜索次数"`
  15. ActivityOnLineNum int `description:"线上活动报名次数"`
  16. ActivityOfficeNum int `description:"线下活动报名次数"`
  17. ActivityNum int `description:"活动报名次数"`
  18. TripNum int `description:"专项产业调研数量"`
  19. RoadshowVideoNum int `description:"产业视频播放量"`
  20. ActivityVideoNum int `description:"活动视频播放量"`
  21. ActivityVoiceNum int `description:"活动音频播放量"`
  22. RoadshowNum int `description:"路演播放总数量"`
  23. TagNum int `description:"标签点击次数"`
  24. YanxuanSpecialNum int `description:"研选专栏阅读数量"`
  25. YanxuanSpecialCollectNum int `description:"研选专栏收藏数量"`
  26. YanxuanSpecialFollowNum int `description:"研选专栏作者关注数量"`
  27. CreateTime time.Time `description:"创建时间"`
  28. ModifyTime time.Time `description:"更新时间"`
  29. }
  30. // 添加
  31. func AddCygxCompanyInteractionNum(item *CygxCompanyInteractionNum) (lastId int64, err error) {
  32. o := orm.NewOrm()
  33. lastId, err = o.Insert(item)
  34. return
  35. }
  36. // 修改
  37. func UpdateCygxCompanyInteractionNum(item *CygxCompanyInteractionNum) (err error) {
  38. updateParams := make(map[string]interface{})
  39. updateParams["CompanyId"] = item.CompanyId
  40. updateParams["ArticleHistoryNum"] = item.ArticleHistoryNum
  41. updateParams["ArticleCountNum"] = item.ArticleCountNum
  42. updateParams["ChartCountNum"] = item.ChartCountNum
  43. updateParams["IndustryFllowNum"] = item.IndustryFllowNum
  44. updateParams["DepartmentFollowNum"] = item.DepartmentFollowNum
  45. updateParams["KeyWordNum"] = item.KeyWordNum
  46. updateParams["ActivityOnLineNum"] = item.ActivityOnLineNum
  47. updateParams["ActivityOfficeNum"] = item.ActivityOfficeNum
  48. updateParams["ActivityNum"] = item.ActivityNum
  49. updateParams["TripNum"] = item.TripNum
  50. updateParams["RoadshowVideoNum"] = item.RoadshowVideoNum
  51. updateParams["ActivityVideoNum"] = item.ActivityVideoNum
  52. updateParams["ActivityVoiceNum"] = item.ActivityVoiceNum
  53. updateParams["RoadshowNum"] = item.RoadshowNum
  54. updateParams["TagNum"] = item.TagNum
  55. updateParams["CreateTime"] = time.Now()
  56. updateParams["ModifyTime"] = time.Now()
  57. whereParam := map[string]interface{}{"company_id": item.CompanyId}
  58. err = UpdateByExpr(CygxCompanyInteractionNum{}, whereParam, updateParams)
  59. return
  60. }
  61. // 获取列表
  62. func GetCygxCompanyInteractionNumList() (items []*CygxCompanyInteractionNum, err error) {
  63. o := orm.NewOrm()
  64. sql := `SELECT * FROM cygx_company_interaction_num `
  65. _, err = o.Raw(sql).QueryRows(&items)
  66. return
  67. }
  68. // 批量添加企业互动信息
  69. func AddCygxCompanyInteractionNumList(items []*CygxCompanyInteractionNum) (lastId int64, err error) {
  70. o := orm.NewOrm()
  71. _, err = o.InsertMulti(len(items), items)
  72. return
  73. }
  74. // UpdateActivitySignupDetailMulti 批量修改
  75. func UpdateCygxCompanyInteractionNumMulti(items []*CygxCompanyInteractionNum) (err error) {
  76. o := orm.NewOrm()
  77. p, err := o.Raw(` UPDATE cygx_company_interaction_num SET
  78. article_history_num = ?,
  79. article_count_num = ?,
  80. industry_fllow_num = ?,
  81. department_follow_num = ?,
  82. key_word_num = ?,
  83. activity_num = ?,
  84. chart_count_num = ?,
  85. trip_num = ?,
  86. roadshow_video_num = ?,
  87. activity_video_num = ?,
  88. activity_voice_num = ?,
  89. roadshow_num = ?,
  90. tag_num = ?
  91. WHERE company_id = ? `).Prepare()
  92. if err != nil {
  93. return
  94. }
  95. defer func() {
  96. _ = p.Close() // 别忘记关闭 statement
  97. }()
  98. for _, v := range items {
  99. _, err = p.Exec(
  100. v.ArticleHistoryNum,
  101. v.ArticleCountNum,
  102. v.ChartCountNum,
  103. v.IndustryFllowNum,
  104. v.DepartmentFollowNum,
  105. v.KeyWordNum,
  106. v.ActivityNum,
  107. v.TripNum,
  108. v.RoadshowVideoNum,
  109. v.ActivityVideoNum,
  110. v.ActivityVoiceNum,
  111. v.RoadshowNum,
  112. v.TagNum,
  113. v.CompanyId)
  114. if err != nil {
  115. return
  116. }
  117. }
  118. return
  119. }
  120. // 企业互动量
  121. type CompanyInteractionNumReq struct {
  122. CompanyId int `description:"用户ID"`
  123. InteractionNum int `description:"互动总量"`
  124. InteractionNumSeller int `description:"销售可以查看的互动总量"`
  125. }
  126. // UpdateCompanyInteractionNumMulti 批量修改客户互动量
  127. func UpdateCompanyInteractionNumMulti(items []*CompanyInteractionNumReq) (err error) {
  128. o := orm.NewOrmUsingDB("weekly_report")
  129. p, err := o.Raw(` UPDATE company SET interaction_num = ? , interaction_num_seller = ? WHERE company_id=? `).Prepare()
  130. if err != nil {
  131. return
  132. }
  133. defer func() {
  134. _ = p.Close() // 别忘记关闭 statement
  135. }()
  136. for _, v := range items {
  137. _, err = p.Exec(
  138. v.InteractionNum,
  139. v.InteractionNumSeller,
  140. v.CompanyId)
  141. if err != nil {
  142. return
  143. }
  144. }
  145. return
  146. }