product_interior_history.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxProductInteriorHistory struct {
  7. Id int `orm:"column(id);pk"`
  8. ProductInteriorId 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. }
  19. // 添加历史信息
  20. func AddCygxProductInteriorHistory(item *CygxProductInteriorHistory) (lastId int64, err error) {
  21. o := orm.NewOrm()
  22. item.ModifyTime = time.Now()
  23. lastId, err = o.Insert(item)
  24. return
  25. }
  26. type ListProductInteriorPvUvResp struct {
  27. ProductInteriorId int `description:"文章ID"`
  28. Pv int `description:"pv"`
  29. Uv int `description:"pv"`
  30. }
  31. // 列表
  32. func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*ListProductInteriorPvUvResp, err error) {
  33. o := orm.NewOrm()
  34. sql := `SELECT
  35. COUNT( 1 ) AS pv,
  36. product_interior_id
  37. FROM
  38. cygx_product_interior_history WHERE 1 = 1 `
  39. if condition != "" {
  40. sql += condition
  41. }
  42. sql += ` GROUP BY product_interior_id `
  43. _, err = o.Raw(sql, pars).QueryRows(&items)
  44. return
  45. }
  46. type ListProductInteriorPvResp struct {
  47. ProductInteriorId int `description:"文章ID"`
  48. Pv int `description:"pv"`
  49. }
  50. // 列表
  51. func GetCygxProductInteriorHistoryListPv(condition string, pars []interface{}) (items []*ListProductInteriorPvResp, err error) {
  52. o := orm.NewOrm()
  53. sql := `SELECT product_interior_id ,COUNT(*) as pv FROM cygx_product_interior_history WHERE 1= 1 `
  54. if condition != "" {
  55. sql += condition
  56. }
  57. sql += " GROUP BY product_interior_id "
  58. _, err = o.Raw(sql, pars).QueryRows(&items)
  59. return
  60. }
  61. type ListProductInteriorResp struct {
  62. ProductInteriorId int `description:"文章ID"`
  63. Title string `description:"标题"`
  64. UserId int `description:"用户ID"`
  65. Mobile string `description:"手机号"`
  66. Email string `description:"邮箱"`
  67. CompanyId int `description:"公司id"`
  68. CompanyName string `description:"公司名称"`
  69. RealName string `description:"用户实际名称"`
  70. CreateTime string `description:"创建时间"`
  71. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  72. RecordId int `description:"日志ID"`
  73. }
  74. // 列表
  75. func GetCygxProductInteriorHistoryListData(condition string, pars []interface{}) (items []*ListProductInteriorResp, err error) {
  76. o := orm.NewOrm()
  77. sql := `SELECT
  78. a.product_interior_id,
  79. a.title,
  80. b.user_id,
  81. b.id as record_id,
  82. b.real_name,
  83. b.mobile,
  84. b.email,
  85. b.company_id,
  86. b.company_name,
  87. b.create_time
  88. FROM
  89. cygx_product_interior AS a
  90. INNER JOIN cygx_product_interior_history AS b ON a.product_interior_id = b.product_interior_id WHERE 1= 1 `
  91. if condition != "" {
  92. sql += condition
  93. }
  94. _, err = o.Raw(sql, pars).QueryRows(&items)
  95. return
  96. }