user.go 6.3 KB

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