eta_trial.go 3.8 KB

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