12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- package logic
- import (
- "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/redis"
- "context"
- "fmt"
- "github.com/zeromicro/go-zero/core/logx"
- IC "jyBXSubscribe/rpc/init"
- "jyBXSubscribe/rpc/internal/svc"
- "jyBXSubscribe/rpc/type/bxsubscribe"
- "jyBXSubscribe/rpc/util"
- )
- type UserInfoLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoLogic {
- return &UserInfoLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 用户推送信息查看
- func (l *UserInfoLogic) UserInfo(in *bxsubscribe.GetUserInfoReq) (*bxsubscribe.GetUserInfoResq, error) {
- // todo: add your logic here and delete this line
- userInfo := &map[string]interface{}{}
- s_email := ""
- s_m_openid := ""
- userInfo, _ = IC.Mgo.FindById(util.USER, in.UserId, `{"o_pushset":1,"s_m_openid":1}`)
- if userInfo != nil && len(*userInfo) > 0 {
- pushSet := common.ObjToMap((*userInfo)["o_pushset"])
- s_email = common.InterfaceToStr((*pushSet)["s_email"])
- s_m_openid = common.InterfaceToStr((*userInfo)["s_m_openid"])
- }
- if in.PositionType == 1 {
- userInfo, _ = IC.Mgo.FindOne(util.ENTUSER, map[string]interface{}{"i_entid": in.EntId, "i_userid": in.EntUserId})
- if userInfo != nil && len(*userInfo) > 0 {
- pushSet := common.ObjToMap((*userInfo)["o_pushset"])
- s_email = common.InterfaceToStr((*pushSet)["s_email"])
- }
- }
- ShowWx := false
- if s_m_openid != "" {
- //微信是否关注处理
- subscribeList := &[]map[string]interface{}{}
- subscribeList, _ = IC.Mgo.Find(util.SUBSCRIBE, map[string]interface{}{"s_m_openid": s_m_openid}, `{"l_date":-1}`, `{"s_event":1"}`, true, -1, -1)
- if subscribeList != nil && len(*subscribeList) > 0 {
- s_event := common.InterfaceToStr((*subscribeList)[0]["s_event"])
- if s_event == "subscribe" {
- ShowWx = true
- }
- }
- }
- //用户二维码生成处理
- data := map[string]string{
- "userId": in.UserId,
- "source": util.ServiceMap[in.ServiceType],
- }
- redis.Put("other", "Bind_"+common.InterfaceToStr(in.BaseUserId), data, -1)
- return &bxsubscribe.GetUserInfoResq{
- Data: &bxsubscribe.GetUserInfo{
- Mail: s_email,
- ShowWx: ShowWx,
- ImgUrl: fmt.Sprintf("/publicapply/getERCode/Bind_%v", in.BaseUserId), //二维码地址
- },
- }, nil
- }
|