free_viewer.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package models
  2. import "github.com/rdlucklib/rdluck_tools/orm"
  3. type FreeViewerDetails struct {
  4. UserId int
  5. RealName string
  6. Mobile string
  7. Note string
  8. CreatedTime string
  9. MaxCreatedTime string
  10. Email string
  11. }
  12. func GetFreeViewerDetails(startTime, endTime string) (items []*FreeViewerDetails, err error) {
  13. sql := `select u.user_id,u.real_name,u.mobile,u.note,u.created_time,max(uvh.created_time) as max_created_time,u.email
  14. from wx_user u
  15. LEFT JOIN user_view_history uvh on u.user_id = uvh.user_id
  16. INNER JOIN user_record AS c ON u.user_id=c.user_id
  17. where u.company_id = 1
  18. and u.is_deal=0
  19. and u.apply_method<>2
  20. and u.mobile is not null
  21. AND u.mobile<>''
  22. and u.created_time > ?
  23. and u.created_time <= ?
  24. AND c.create_platform<>4
  25. AND u.is_deal = 0
  26. group by u.user_id`
  27. _, err = orm.NewOrm().Raw(sql, startTime, endTime).QueryRows(&items)
  28. return
  29. }
  30. // DealWxUser 处理用户标记状态
  31. func DealWxUser(userId int) (err error) {
  32. sql := `update wx_user set is_deal = 1 where user_id=?`
  33. _, err = orm.NewOrm().Raw(sql, userId).Exec()
  34. return
  35. }