eta_trial.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package eta_trial
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type EtaTrial struct {
  8. EtaTrialId int `orm:"column(eta_trial_id);pk" description:"eta试用客户id"`
  9. UserName string `description:"客户名称"`
  10. CompanyName string `description:"客户公司姓名"`
  11. Position string `description:"职位"`
  12. Password string `json:"-"`
  13. Account string `json:"-"`
  14. Mobile string `description:"手机号"`
  15. Enabled int `description:"1:有效,0:禁用"`
  16. ActiveTime int `description:"累计活跃时长"`
  17. LastLoginTime time.Time `description:"最后一次登陆时间"`
  18. SellerId int `description:"销售id"`
  19. Seller string `description:"销售员名称"`
  20. CreateTime time.Time
  21. ModifyTime time.Time
  22. LastLoginDuration int `description:"最后一次登录时长"`
  23. }
  24. // Update 更新用户基础信息
  25. func (item *EtaTrial) Update(cols []string) (err error) {
  26. o := orm.NewOrm()
  27. _, err = o.Update(item, cols...)
  28. return
  29. }
  30. func GetETATrialList(condition, sortStr string, pars []interface{}, startSize, pageSize int) (items []*ETATrialListRespItem, err error) {
  31. sql := `SELECT * FROM eta_trial WHERE 1=1 `
  32. if sortStr == "" {
  33. sortStr = "ORDER BY create_time DESC "
  34. }
  35. if condition != "" {
  36. sql += condition
  37. }
  38. sql += sortStr + ` LIMIT ?,? `
  39. o := orm.NewOrm()
  40. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  41. return
  42. }
  43. func GetETATrialListCount(condition string, pars []interface{}) (count int, err error) {
  44. sql := `SELECT COUNT(1) AS count FROM eta_trial WHERE 1 = 1 `
  45. o := orm.NewOrm()
  46. if condition != "" {
  47. sql += condition
  48. }
  49. err = o.Raw(sql, pars).QueryRow(&count)
  50. return
  51. }
  52. type ETATrialListRespItem struct {
  53. EtaTrialId int `orm:"column(eta_trial_id);pk" description:"eta试用客户id"`
  54. UserName string `description:"客户名称"`
  55. CompanyName string `description:"客户公司姓名"`
  56. Position string `description:"职位"`
  57. Mobile string `description:"手机号"`
  58. ActiveTime string `description:"累计活跃时长"`
  59. LastLoginTime string `description:"最后一次登陆时间"`
  60. SellerId int `description:"销售id"`
  61. Seller string `description:"销售员名称"`
  62. InterestModule string `description:"感兴趣模块"`
  63. Expiration int `description:"账号到期时长"`
  64. Enabled int `description:"1:有效,0:禁用"`
  65. IndexNum int `description:"累计添加指标"`
  66. ChartNum int `description:"累计添加图表"`
  67. LoginNum int `description:"累计登录次数"`
  68. Password string
  69. Account string
  70. CreateTime string
  71. ModifyTime string
  72. LastLoginDuration string `description:"最后一次登录时长"`
  73. }
  74. type ETATrialListRespList struct {
  75. List []*ETATrialListRespItem
  76. Paging *paging.PagingItem
  77. ApprovalNum int
  78. }
  79. type ETATrialAddItem struct {
  80. UserName string `description:"客户名称"`
  81. CompanyName string `description:"客户公司姓名"`
  82. Position string `description:"职位"`
  83. Mobile string `description:"手机号"`
  84. }
  85. type ETATrialAddReq struct {
  86. List []ETATrialAddItem
  87. }
  88. func GetETATrialByMobile(mobile string) (item *EtaTrial, err error) {
  89. sql := `SELECT * FROM eta_trial WHERE mobile = ? `
  90. o := orm.NewOrm()
  91. err = o.Raw(sql, mobile).QueryRow(&item)
  92. return
  93. }
  94. // 新增客户
  95. func AddETATrial(item *EtaTrial) (lastId int64, err error) {
  96. o := orm.NewOrm()
  97. lastId, err = o.Insert(item)
  98. return
  99. }
  100. func GetETATrialByAccount(account string) (items []*EtaTrial, err error) {
  101. sql := `SELECT * FROM eta_trial WHERE account LIKE '%` + account + `%' `
  102. o := orm.NewOrm()
  103. _, err = o.Raw(sql).QueryRows(&items)
  104. return
  105. }
  106. func UpdateETATrialEnable(mobile string) (err error) {
  107. o := orm.NewOrm()
  108. sql := `UPDATE eta_trial SET enabled=1,modify_time=NOW()
  109. WHERE mobile=? `
  110. _, err = o.Raw(sql, mobile).Exec()
  111. return
  112. }