user.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type UserDetail struct {
  7. Headimgurl string `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
  8. Mobile string `description:"手机号码"`
  9. UserId int `description:"用户ID"`
  10. Email string `description:"邮箱"`
  11. NickName string `description:"用户昵称"`
  12. RealName string `description:"用户实际名称"`
  13. CompanyName string `description:"公司名称"`
  14. PermissionName string `description:"拥有权限分类,多个用英文逗号分隔"`
  15. HasPermission int `description:"1:无该行业权限,不存在权益客户下,2:潜在客户,未提交过申请,3:潜在客户,已提交过申请"`
  16. SellerMobile string `description:"销售手机号"`
  17. SellerName string `description:"销售名称"`
  18. Note string `json:"-" description:"申请提交时,公司名称"`
  19. CountryCode string `description:"区号"`
  20. OutboundMobile string `description:"外呼手机号"`
  21. OutboundCountryCode string `description:"外呼手机号区号"`
  22. }
  23. type UserPermission struct {
  24. CompanyName string `description:"公司名称"`
  25. ChartPermissionName string `description:"权限"`
  26. }
  27. type LoginReq struct {
  28. LoginType int `description:"登录方式:1:微信手机,2:邮箱,3:自定义手机登录"`
  29. Mobile string `description:"手机号"`
  30. Email string `description:"邮箱"`
  31. VCode string `description:"验证码"`
  32. CountryCode string `description:"区号"`
  33. }
  34. type LoginResp struct {
  35. UserId int `description:"用户id"`
  36. Authorization string `description:"Token"`
  37. Headimgurl string `description:"用户头像"`
  38. Mobile string `description:"手机号"`
  39. Email string `description:"邮箱"`
  40. CompanyName string `description:"客户名称"`
  41. Status string `description:"状态"`
  42. EndDate string `description:"到期日期"`
  43. ProductName string `description:"客户类型名称"`
  44. }
  45. type CheckStatusResp struct {
  46. IsBind bool `description:"true:需要绑定手机号或邮箱,false:不需要绑定手机号或邮箱"`
  47. IsAuth bool `description:"true:需要授权,false:不需要授权"`
  48. PermissionName string `description:"拥有权限分类,多个用英文逗号分隔"`
  49. }
  50. type ApplyTryReq struct {
  51. BusinessCardUrl string `description:"名片地址"`
  52. RealName string `description:"姓名"`
  53. CompanyName string `description:"公司名称"`
  54. ApplyMethod int `description:"1:已付费客户申请试用,2:非客户申请试用,3:非客户申请试用(ficc下,不需要进行数据校验)"`
  55. }
  56. type CountryCode struct {
  57. IsNeedAddCountryCode bool `description:"是否需要填写区号:需要填写,false:不需要填写"`
  58. }
  59. type OutboundMobile struct {
  60. IsNeedAddOutboundMobile bool `description:"是否需要填写外呼手机号:需要填写,false:不需要填写"`
  61. }
  62. type CountryCodeItem struct {
  63. CountryCode string `description:"区号"`
  64. }
  65. // 修改外呼手机号
  66. type OutboundMobileItem struct {
  67. OutboundMobile string `description:"外呼手机号"`
  68. OutboundCountryCode string `description:"外呼手机号区号"`
  69. ActivityId int `description:"活动ID"`
  70. }
  71. type UserWhiteList struct {
  72. Mobile string `description:"手机号码"`
  73. RealName string `description:"用户实际名称"`
  74. CompanyName string `description:"公司名称"`
  75. Permission string `description:"拥有权限分类,多个用英文逗号分隔"`
  76. CountryCode string `description:"区号"`
  77. SellerName string `description:"销售姓名"`
  78. CreatedTime time.Time
  79. Status string `description:"客户状态'试用','永续','冻结','流失','正式','潜在'"`
  80. }
  81. type UserWhiteListRep struct {
  82. List []*UserWhiteList
  83. }
  84. type UserDetailByUserLogin struct {
  85. Headimgurl string `description:"头像"`
  86. Mobile string `description:"手机号码"`
  87. RealName string `description:"用户实际名称"`
  88. CompanyName string `description:"公司名称"`
  89. Permission string `description:"拥有权限分类,多个用英文逗号分隔"`
  90. HasPermission int `description:"1:有该行业权限,正常展示,2:无权限,非潜在客户,3:未在小程序授权用户信息 等"`
  91. Token string `description:"Token"`
  92. }
  93. func GetCompanyPermission(companyId int) (permission string, err error) {
  94. sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_name ORDER BY b.sort ASC SEPARATOR ',') AS permission
  95. FROM company_report_permission AS a
  96. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  97. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  98. WHERE a.company_id=?
  99. AND c.is_suspend=0
  100. AND b.cygx_auth=1
  101. AND c.status IN('正式','试用','永续')
  102. AND a.status IN('正式','试用','永续') `
  103. o := orm.NewOrm()
  104. err = o.Raw(sql, companyId).QueryRow(&permission)
  105. return
  106. }
  107. func GetCompanyPermissionId(companyId int) (permissionId string, err error) {
  108. sql := ` SELECT GROUP_CONCAT(DISTINCT b.chart_permission_id ORDER BY b.sort ASC SEPARATOR ',') AS permissionId
  109. FROM company_report_permission AS a
  110. INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
  111. INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
  112. WHERE a.company_id=?
  113. AND c.is_suspend=0
  114. AND b.cygx_auth=1
  115. AND c.status IN('正式','试用','永续')
  116. AND a.status IN('正式','试用','永续') `
  117. o := orm.NewOrm()
  118. err = o.Raw(sql, companyId).QueryRow(&permissionId)
  119. return
  120. }
  121. func UserSubscribe(subscribeType, userId int) (err error) {
  122. o := orm.NewOrm()
  123. sql := `UPDATE wx_user SET cygx_subscribe=?,cygx_subscribe_time=NOW() WHERE user_id = ? `
  124. _, err = o.Raw(sql, subscribeType, userId).Exec()
  125. return
  126. }
  127. func CygxUserSubscribe(subscribeType int, unionid string) (err error) {
  128. o := orm.NewOrmUsingDB("hz_cygx")
  129. sql := `UPDATE cygx_user_record SET subscribe=?,subscribe_time=NOW() WHERE union_id = ? `
  130. _, err = o.Raw(sql, subscribeType, unionid).Exec()
  131. return
  132. }