userinfologic.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jybase/common"
  4. "app.yhyue.com/moapp/jybase/redis"
  5. "context"
  6. "fmt"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. IC "jyBXSubscribe/rpc/init"
  9. "jyBXSubscribe/rpc/internal/svc"
  10. "jyBXSubscribe/rpc/type/bxsubscribe"
  11. "jyBXSubscribe/rpc/util"
  12. )
  13. type UserInfoLogic struct {
  14. ctx context.Context
  15. svcCtx *svc.ServiceContext
  16. logx.Logger
  17. }
  18. func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoLogic {
  19. return &UserInfoLogic{
  20. ctx: ctx,
  21. svcCtx: svcCtx,
  22. Logger: logx.WithContext(ctx),
  23. }
  24. }
  25. // 用户推送信息查看
  26. func (l *UserInfoLogic) UserInfo(in *bxsubscribe.GetUserInfoReq) (*bxsubscribe.GetUserInfoResq, error) {
  27. // todo: add your logic here and delete this line
  28. userInfo := &map[string]interface{}{}
  29. s_email := ""
  30. s_m_openid := ""
  31. userInfo, _ = IC.Mgo.FindById(util.USER, in.MgoUserId, `{"o_pushset":1,"s_m_openid":1}`)
  32. if userInfo != nil && len(*userInfo) > 0 {
  33. pushSet := common.ObjToMap((*userInfo)["o_pushset"])
  34. s_email = common.InterfaceToStr((*pushSet)["s_email"])
  35. s_m_openid = common.InterfaceToStr((*userInfo)["s_m_openid"])
  36. }
  37. if in.PositionType == 1 {
  38. userInfo, _ = IC.Mgo.FindOne(util.ENTUSER, map[string]interface{}{"i_entid": in.EntId, "i_userid": in.EntUserId})
  39. if userInfo != nil && len(*userInfo) > 0 {
  40. pushSet := common.ObjToMap((*userInfo)["o_pushset"])
  41. s_email = common.InterfaceToStr((*pushSet)["s_email"])
  42. }
  43. }
  44. ShowWx := false
  45. if s_m_openid != "" {
  46. //微信是否关注处理
  47. subscribeList := &[]map[string]interface{}{}
  48. subscribeList, _ = IC.Mgo.Find(util.SUBSCRIBE, map[string]interface{}{"s_m_openid": s_m_openid}, `{"l_date":-1}`, `{"s_event":1"}`, true, -1, -1)
  49. if subscribeList != nil && len(*subscribeList) > 0 {
  50. s_event := common.InterfaceToStr((*subscribeList)[0]["s_event"])
  51. if s_event == "subscribe" {
  52. ShowWx = true
  53. }
  54. }
  55. }
  56. //用户二维码生成处理
  57. data := map[string]string{
  58. "userId": in.MgoUserId,
  59. "source": util.ServiceMap[in.ServiceType],
  60. }
  61. redis.Put("other", "Bind_"+common.InterfaceToStr(in.BaseUserId), data, -1)
  62. return &bxsubscribe.GetUserInfoResq{
  63. Data: &bxsubscribe.GetUserInfo{
  64. Mail: s_email,
  65. ShowWx: ShowWx,
  66. ImgUrl: fmt.Sprintf("/jyapp/getERCode/Bind_%v", in.BaseUserId), //二维码地址
  67. },
  68. }, nil
  69. }