users.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import "rdluck_tools/orm"
  3. type HongzeUsers struct {
  4. RealName string
  5. CompanyName string
  6. Mobile string
  7. IsRegister string
  8. UserType string
  9. }
  10. func GetHongzeUsers() (items []*HongzeUsers, err error) {
  11. sql := `select wu.real_name,c.company_name,left(wu.mobile, 11) as mobile ,if(wu.open_id is null,'否','是') as is_register,if(c.type in (1),'是','否') as user_type
  12. from wx_user wu
  13. inner join company c on c.company_id = wu.company_id
  14. where c.company_id <> 1 and c.company_id <> 16
  15. and c.type in (1)
  16. order by company_name desc `
  17. _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
  18. return
  19. }
  20. type WxUser struct {
  21. UserId int64
  22. Mobile string
  23. Email string
  24. CompanyId int
  25. ExpiredIn int64
  26. OpenId string
  27. }
  28. func GetWxUserByUserId(userId int) (item *WxUser, err error) {
  29. sql := `SELECT * FROM wx_user WHERE user_id=? `
  30. err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
  31. return
  32. }
  33. func GetWxUserByMobile(mobile string) (item *WxUser, err error) {
  34. sql := `SELECT * FROM wx_user WHERE mobile=? `
  35. err = orm.NewOrm().Raw(sql, mobile).QueryRow(&item)
  36. return
  37. }