123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type YbUserCollection struct {
- CollectionId uint `orm:"column(collection_id);pk"`
- CollectionType uint8 `orm:"column(collection_type)"`
- UserId uint `orm:"column(user_id)"`
- CompanyId uint `orm:"column(company_id)"`
- CompanyStatus string `orm:"column(company_status)"`
- CompanyName string `orm:"column(company_name)"`
- RealName string `orm:"column(real_name)"`
- PrimaryId uint `orm:"column(primary_id)"`
- ExtendId uint `orm:"column(extend_id)"`
- State uint8 `orm:"column(state)"`
- SourceAgent uint8 `orm:"column(source_agent)"`
- SellerId int `orm:"column(seller_id)"`
- Title string `orm:"column(title)"`
- PublishTime time.Time `orm:"column(publish_time)"`
- CreateTime time.Time `orm:"column(create_time)"`
- ModifyTime time.Time `orm:"column(modify_time)"`
- }
- func (l *YbUserCollection) TableName() string {
- return "yb_user_collection"
- }
- type SellerCollectCount struct {
- Num int `json:"num"`
- SellerId int `json:"seller_id"`
- }
- type SellerCollectCountListItem struct {
- Num int
- UserId int
- RealName string
- CompanyId int
- CompanyStatus string
- CompanyName string
- }
- func GetSellerCollectCountByCompanyStatus(companyStatus string, startDate, endDate time.Time) (list []*SellerCollectCount, err error) {
- o := orm.NewOrm()
- pars := make([]interface{}, 0)
- sql := `SELECT COUNT(*) AS num, seller_id FROM yb_user_collection WHERE company_status =? AND state=1 and create_time >= ? and create_time <= ? GROUP BY seller_id`
- pars = append(pars, companyStatus, startDate, endDate)
- _, err = o.Raw(sql, pars).QueryRows(&list)
- return
- }
- type SellerCollectUserLogReq struct {
- PageSize int `description:"每页数据条数"`
- CurrentIndex int `description:"当前页页码,从1开始"`
- SortParam string `description:"排序字段参数,用来排序的字段, 枚举值:'viewTotal':总阅读次数 、 'viewTime':阅读时间 、 'roadShowTotal':累计路演次数 、'expireDay':到期时间 、 'createTime':创建时间 、 'formalTime': 转正时间 、 'freezeTime':冻结时间 、'lossTime':流失时间" 、'deadline':距离未完成的任务的截止日期的天数、'ybUserLog': 按照用户的点击量`
- SortType string `description:"如何排序,是正序还是倒序,枚举值:asc 正序,desc 倒叙 "`
- SellerIds string `description:"销售ID, 用','拼接 "`
- CompanyStatus string `description:"客户状态"`
- StartDate string `description:"起始时间"`
- EndDate string `description:"截止时间"`
- }
- const (
- CollectionTypeReport = 1
- CollectionTypeVideo = 2
- CollectionTypeRoadVideo = 3
- )
- func GetSellerUserCollectCountByCompanyStatus(companyStatus string, startDate, endDate time.Time, sellerIds string, startSize, pageSize int, orderStr string) (list []*SellerCollectCountListItem, total int64, err error) {
- o := orm.NewOrm()
- pars := make([]interface{}, 0)
- sql := `SELECT COUNT(*) AS num, user_id, real_name, company_id, company_status, company_name FROM yb_user_collection WHERE company_status =? AND state=1 and create_time >= ? and create_time <= ? and seller_id in `+sellerIds+` GROUP BY user_id, company_id`
- pars = append(pars, companyStatus, startDate, endDate)
- totalSQL := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSQL, pars).QueryRow(&total)
- if err != nil {
- return
- }
- if orderStr != "" {
- sql += orderStr
- }
- sql += ` LIMIT ?,?`
- pars = append(pars, startSize, pageSize)
- _, err = o.Raw(sql, pars).QueryRows(&list)
- return
- }
- type CollectListReq struct {
- PageSize int `description:"每页数据条数"`
- CurrentIndex int `description:"当前页页码,从1开始"`
- SellerIds string `description:"销售ID, 用','拼接 "`
- UserId int `description:"联系人id"`
- CompanyStatus string `description:"客户状态"`
- StartDate string `description:"起始时间"`
- EndDate string `description:"截止时间"`
- CollectionType string `description:"收藏类型:1-研报; 2-视频社区; 3-微路演视频"`
- }
- func GetYbUserCollectionByCondition(condition string, pars []interface{}, startSize, pageSize int) (list []*YbUserCollection, total int64, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM yb_user_collection WHERE state=1 `
- if condition != "" {
- sql += condition
- }
- totalSQL := `SELECT COUNT(1) total FROM (` + sql + `) z `
- err = o.Raw(totalSQL, pars).QueryRow(&total)
- if err != nil {
- return
- }
- sql += ` order by create_time desc, collection_id desc LIMIT ?,?`
- pars = append(pars, startSize, pageSize)
- _, err = o.Raw(sql, pars).QueryRows(&list)
- return
- }
|