wangchuanjin 2 years ago
parent
commit
0343e5f0c5
2 changed files with 71 additions and 1 deletions
  1. 55 1
      common/src/qfw/util/jy/bigVipPower.go
  2. 16 0
      common/src/qfw/util/jy/userCenter.go

+ 55 - 1
common/src/qfw/util/jy/bigVipPower.go

@@ -13,6 +13,7 @@ import (
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/middleground"
 	"bp.jydev.jianyu360.cn/BaseService/powerCheckCenter/rpc/pb"
+	userCenterBp "bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
 )
 
 // 大会员状态redis缓存
@@ -88,6 +89,7 @@ const (
 	RedisMenuKeyWX            = "jy_workdesktopmenu_10000_WX_%s"  //剑鱼appid:10000
 	RedisMenuKeyAPP           = "jy_workdesktopmenu_10000_APP_%s" //剑鱼appid:10000
 	UserPowerRedisKey         = "jy_userpowerredis_10000_%d_%s"   //工作桌面 用户功能缓存(类似bigmember_power_3_%s)
+	PowerCheckKey             = "user_power_info_%s"              //权益校验中台缓存
 )
 
 // 初始化大会员权益
@@ -126,7 +128,14 @@ func ClearBigVipUserPower(userId string) bool {
 	redisMenuKeyWX := fmt.Sprintf(RedisMenuKeyWX, userId)
 	redisMenuKeyAPP := fmt.Sprintf(RedisMenuKeyAPP, userId)
 	userPowerRedisKey := fmt.Sprintf(UserPowerRedisKey, time.Now().Day(), userId)
-	return redis.Del(BaseInfoCacheDb, cacheKey) && redis.Del(BaseInfoCacheDb, baseInfoCacheKey) && redis.Del(BaseInfoCacheDb, redisMenuKeyPC) && redis.Del(BaseInfoCacheDb, redisMenuKeyWX) && redis.Del(BaseInfoCacheDb, redisMenuKeyAPP) && redis.Del(BaseInfoCacheDb, userPowerRedisKey)
+	powerCheckKey := fmt.Sprintf(PowerCheckKey, userId)
+	return redis.Del(BaseInfoCacheDb, cacheKey) &&
+		redis.Del(BaseInfoCacheDb, baseInfoCacheKey) &&
+		redis.Del(BaseInfoCacheDb, redisMenuKeyPC) &&
+		redis.Del(BaseInfoCacheDb, redisMenuKeyWX) &&
+		redis.Del(BaseInfoCacheDb, redisMenuKeyAPP) &&
+		redis.Del(BaseInfoCacheDb, userPowerRedisKey) &&
+		redis.Del(BaseInfoCacheDb, powerCheckKey)
 }
 
 // 获取商机管理个人基本信息
@@ -261,3 +270,48 @@ func (this *BigVipBaseMsg) GetUseId() string {
 	}
 	return this.Uid
 }
+
+//根据userid获取用户基本信息
+func GetInfoForBaseUser(mgo m.MongodbSim, userid string) *userCenterBp.UserIdReq {
+	if userid == "" {
+		return nil
+	}
+	data, ok := mgo.FindById("user", userid, `{"base_user_id":1,"s_m_openid":1,"a_m_openid":1,"s_m_phone":1,"s_phone":1,"s_nickname":1,"s_jyname":1,"s_headimageurl":1,"s_headimage":1,"s_company":1,"s_password":1,"s_unionid":1}`)
+	if ok && data != nil && len(*data) > 0 {
+		userinfo := &userCenterBp.UserIdReq{
+			Appid: "10000",
+			Id:    qutil.Int64All((*data)["base_user_id"]),
+		}
+		if s_openid := qutil.ObjToString((*data)["s_m_openid"]); s_openid != "" {
+			userinfo.SOpenid = s_openid
+		}
+		if a_openid := qutil.ObjToString((*data)["a_m_openid"]); a_openid != "" {
+			userinfo.AOpenid = a_openid
+		}
+		phone := qutil.ObjToString((*data)["s_phone"])
+		if phone == "" {
+			phone = qutil.ObjToString((*data)["s_m_phone"])
+		}
+		if phone != "" {
+			userinfo.Phone = phone
+		}
+		nickname := qutil.ObjToString((*data)["s_nickname"])
+		if nickname == "" {
+			nickname = qutil.ObjToString((*data)["s_jyname"])
+		}
+		if nickname != "" {
+			userinfo.Nickname = nickname
+		}
+		if unionid := qutil.ObjToString((*data)["s_unionid"]); unionid != "" {
+			userinfo.Unionid = unionid
+		}
+		if password := qutil.ObjToString((*data)["s_password"]); password != "" {
+			userinfo.Password = password
+		}
+		if headimg := qutil.ObjToString((*data)["s_headimageurl"]); headimg != "" {
+			userinfo.Headimg = headimg
+		}
+		return userinfo
+	}
+	return nil
+}

+ 16 - 0
common/src/qfw/util/jy/userCenter.go

@@ -23,3 +23,19 @@ func AddUser(mgo mongodb.MongodbSim, userid string, req pb.UserAddReq, middlegro
 	}
 	return false
 }
+
+//修改base-user相关参数
+func UpdateUser(mgo mongodb.MongodbSim, userid string, req pb.UserIdReq, middleground middleground.Middleground) bool {
+	if resp := middleground.UserCenter.UserUpdate(req); resp != nil {
+		return resp.Data.Status == 1
+	}
+	return false
+}
+
+//删除base-user
+func DelUser(mgo mongodb.MongodbSim, userid string, req pb.UserIdReq, middleground middleground.Middleground) bool {
+	if resp := middleground.UserCenter.UserDel(req); resp != nil {
+		return resp.Data.Status == 1
+	}
+	return false
+}