banner_history.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxBannerHistory struct {
  7. Id int `orm:"column(id);pk"`
  8. TimeLineId int
  9. UserId int
  10. CreateTime time.Time
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. ModifyTime time.Time `description:"修改时间"`
  16. RealName string `description:"用户实际名称"`
  17. SellerName string `description:"所属销售"`
  18. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  19. }
  20. // 列表
  21. func GetCygxBannerHistoryList(condition string, pars []interface{}) (items []*CygxBannerHistory, err error) {
  22. o := orm.NewOrmUsingDB("hz_cygx")
  23. sql := `SELECT * FROM cygx_banner_history as art WHERE 1= 1 `
  24. if condition != "" {
  25. sql += condition
  26. }
  27. _, err = o.Raw(sql, pars).QueryRows(&items)
  28. return
  29. }
  30. // 获取数量
  31. func GetCygxBannerHistoryCount(condition string, pars []interface{}) (count int, err error) {
  32. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_banner_history as art WHERE 1= 1 `
  33. if condition != "" {
  34. sqlCount += condition
  35. }
  36. o := orm.NewOrmUsingDB("hz_cygx")
  37. err = o.Raw(sqlCount, pars).QueryRow(&count)
  38. return
  39. }
  40. // 获取数量
  41. func GetCygxBannerHistoryCountUv(bannerId int) (count int, err error) {
  42. sqlCount := ` SELECT
  43. count(*) AS uv
  44. FROM
  45. ( SELECT count(*) FROM cygx_banner_history WHERE 1 = 1 AND banner_id = ? GROUP BY user_id ) b `
  46. o := orm.NewOrmUsingDB("hz_cygx")
  47. err = o.Raw(sqlCount, bannerId).QueryRow(&count)
  48. return
  49. }
  50. // 获取数量
  51. func GetCygxBannerHistoryCountPv(bannerId int) (count int, err error) {
  52. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_banner_history as art WHERE 1= 1 AND banner_id = ? `
  53. o := orm.NewOrmUsingDB("hz_cygx")
  54. err = o.Raw(sqlCount, bannerId).QueryRow(&count)
  55. return
  56. }