123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- package logic
- import (
- "context"
- "fmt"
- "log"
- "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/internal/svc"
- "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
- "app.yhyue.com/moapp/jybase/common"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type GetUserInfoLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
- return &GetUserInfoLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- // 获取客户信息
- func (l *GetUserInfoLogic) GetUserInfo(in *pb.UserReq) (*pb.UserInfo, error) {
- // todo: add your logic here and delete this line
- resp := &pb.UserInfo{}
- ret, msg := SubscirbeService.GetSubscribeInfo(in)
- if msg != "" {
- l.Error(fmt.Sprintf("%+v", in), msg)
- resp.ErrorMsg = msg
- resp.ErrorCode = -1
- }
- resp.Nickname = common.ObjToString(ret["nickname"])
- resp.Headimg = common.ObjToString(ret["headimg"])
- resp.IsTourist = common.Int64All(ret["is_tourist"])
- //非游客
- if resp.IsTourist < 2 {
- resp.Phone = common.ObjToString(ret["phone"])
- resp.VipStatus = common.Int64All(ret["vipStatus"])
- resp.MemberStatus = common.Int64All(ret["memberStatus"])
- resp.EntnicheStatus = common.Int64All(ret["entnicheStatus"])
- resp.SubscribeType = common.ObjToString(ret["subscribeType"])
- items, ok := ret["items"].([]map[string]interface{})
- if !ok {
- inter_items, _ := ret["items"].([]interface{})
- items = common.ObjArrToMapArr(inter_items)
- }
- log.Println("items:", items)
- log.Println("oarea:", ret["o_area"], common.ObjToMap(ret["o_area"]))
- buyerclass, _ := ret["buyerclass"].([]interface{})
- infotype, _ := ret["infotype"].([]interface{})
- resp.Data = &pb.Subscribe{
- StartTime: common.Int64All(ret["starttime"]),
- EndTime: common.Int64All(ret["endtime"]),
- Area: l.formatM(common.ObjToMap(ret["area"])),
- Buyerclass: common.ObjArrToStringArr(buyerclass),
- Infotype: common.ObjArrToStringArr(infotype),
- Matchway: common.Int64All(ret["matchway"]),
- Projectmatch: common.Int64All(ret["projectmatch"]),
- Items: l.formatItems(items),
- }
- }
- return resp, nil
- }
- // 格式转化 map<string,list>转化
- func (l *GetUserInfoLogic) formatM(m *map[string]interface{}) map[string]*pb.List {
- retM := map[string]*pb.List{}
- if len(*m) == 0 {
- return retM
- }
- for k, v := range *m {
- s_v, ok := v.([]string)
- if !ok {
- interf, _ := v.([]interface{})
- s_v = common.ObjArrToStringArr(interf)
- }
- retM[k] = &pb.List{
- Value: s_v,
- }
- }
- return retM
- }
- func (l *GetUserInfoLogic) formatItems(m []map[string]interface{}) []*pb.Items {
- items := make([]*pb.Items, len(m))
- for k, v := range m {
- items[k] = &pb.Items{
- SItem: common.ObjToString(v["s_item"]),
- UpdateTime: common.Int64All(v["updatetime"]),
- }
- akey, _ := v["a_key"].([]map[string]interface{})
- pbKey := make([]*pb.Keys, len(akey))
- for kk, vv := range akey {
- key, ok := vv["key"].([]string)
- if !ok {
- inter_vv, _ := vv["key"].([]interface{})
- key = common.ObjArrToStringArr(inter_vv)
- }
- notkey, ok := vv["notkey"].([]string)
- if !ok {
- inter_vv, _ := vv["notkey"].([]interface{})
- notkey = common.ObjArrToStringArr(inter_vv)
- }
- pbKey[kk] = &pb.Keys{
- Key: key,
- Notkey: notkey,
- UpdateTime: common.If(vv["updatetime"] == nil, int64(0), common.Int64All(vv["updatetime"])).(int64),
- }
- }
- items[k].AKey = pbKey
- }
- return items
- }
|