@@ -222,6 +222,7 @@ class MarketController extends MarketBaseController
// 更新缓存
$userInfo = Member::getInfo(['id' => $agentId]);
session('agentInfo', $userInfo);
+ session('userInfo', null);
showJson(1005, 2043);
} catch (\Exception $exception) {
@@ -16,18 +16,17 @@ class MemberController extends BaseController
public function __construct()
{
parent::__construct();
- $openid = session('openid');
- if(empty($this->userInfo) && $openid){
- $this->userInfo = Member::getInfo(['openid'=> $openid,'user_type'=> 2]);
- }
-
- $userStatus = isset($this->userInfo['user_status']) ? intval($this->userInfo['user_status']) : 0;
- $agentType = isset($this->userInfo['agent_type']) ? intval($this->userInfo['agent_type']) : 0;
- $agentStatus = isset($this->userInfo['agent_status']) ? intval($this->userInfo['agent_status']) : 0;
$needRegProfile = isset($this->userInfo['is_reg_profile'])? $this->userInfo['is_reg_profile'] : 0;
+ $userStatus = isset($this->userInfo['user_status']) ? intval($this->userInfo['user_status']) : 0;
+
+ $openid = session('openid');
+ $agentInfo = Member::checkAgentInfo($this->userId? $this->userId: $openid);
+ $agentType = isset($agentInfo['agent_type']) ? intval($agentInfo['agent_type']) : 0;
+ $agentStatus = isset($agentInfo['agent_status']) ? intval($agentInfo['agent_status']) : 0;
var_dump(session('openid'));
var_dump($this->userInfo);
+ var_dump($agentInfo);
exit;
if($agentType == 1 && $agentStatus != 3 && $needRegProfile != 1){
$url = url('/weixin/market/index', '', '', true);
@@ -347,6 +347,30 @@ class Member extends Model
}
/**
+ * 验证获取代理用户信息
+ * @param $account
+ * @return array|bool
+ * @throws \think\db\exception\DataNotFoundException
+ * @throws \think\db\exception\ModelNotFoundException
+ * @throws \think\exception\DbException
+ */
+ public static function checkAgentInfo($account){
+ $cacheKey = "caches:agents:check_{$account}";
+ $info = PRedis::get($cacheKey);
+ if($info){
+ return $info;
+ }
+ $field = 'id,openid,user_nickname,user_type,agent_type,agent_status,avatar,user_login,collect_expire,user_status,real_name,redheart,is_reg_profile,mobile,balance,user_status,is_heart,vip_auth,vip_expire,is_follow,freezing_choose';
+ $info = self::where(['openid|id'=> $account, 'user_type'=> 2])->field($field)->order('user_status desc,id desc')->find();
+ $info = $info ? $info->toArray() : [];
+ PRedis::set($cacheKey, $info,5);
+ /**
* 充值记录
* @param $params
* @param int $pageSize