Commit d0ba9898 authored by hujun's avatar hujun

修改保护期

parent 416c3996
......@@ -142,52 +142,53 @@ class RedisCacheService
}
/**
* @param $type
* @param $type 1:客户 2:经纪人 3:角色组 4:权限
* @param $id
* @return array|bool|false|mixed|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getRedisCache($type, $id) {
if (empty($id)) {
return false;
}
switch ($type) {
case 1:
$result = $this->redis_ext->get($this->user_key . $id);
if (empty($result)) {
$result = $this->userCache($id);
} else {
$result = json_decode($result, true);
}
break;
case 2 :
$result = $this->redis_ext->get($this->agent_key . $id);
if (empty($result)) {
$result = $this->agentCache($id);
} else {
$result = json_decode($result, true);
}
break;
case 3 :
$result = $this->redis_ext->get($this->group_key . $id);
if (empty($result)) {
$result = $this->groupCache($id);
} else {
$result = json_decode($result, true);
}
break;
case 4 :
$result = $this->redis_ext->get($this->rule_key. $id);
if (empty($result)) {
$result = $this->authCache($id);
} else {
$result = json_decode($result, true);
}
break;
default :
$result = false;
try {
switch ($type) {
case 1:
$result = $this->redis_ext->get($this->user_key . $id);
if (empty($result)) {
$result = $this->userCache($id);
} else {
$result = json_decode($result, true);
}
break;
case 2 :
$result = $this->redis_ext->get($this->agent_key . $id);
if (empty($result)) {
$result = $this->agentCache($id);
} else {
$result = json_decode($result, true);
}
break;
case 3 :
$result = $this->redis_ext->get($this->group_key . $id);
if (empty($result)) {
$result = $this->groupCache($id);
} else {
$result = json_decode($result, true);
}
break;
case 4 :
$result = $this->redis_ext->get($this->rule_key. $id);
if (empty($result)) {
$result = $this->authCache($id);
} else {
$result = json_decode($result, true);
}
break;
default :
$result = false;
}
} catch (\Exception $e) {
$result = false;
}
return $result;
}
......
......@@ -10,6 +10,7 @@ namespace app\index\service;
use app\api_broker\service\PushMessageService;
use app\api_broker\service\RedisCacheService;
use app\api_broker\service\VipService;
use app\extra\RedisExt;
use app\index\validate\MemberValidate;
......@@ -357,7 +358,20 @@ class UserService
if(!$user_id){
return 1;
}
$res = $this->user->selectUser($user_id, "id,protect_time,create_time");
$redis_cache = new RedisCacheService();
$user_data = $redis_cache->getRedisCache(1, $user_id);
if (empty($user_data)) {
$res = $this->user->selectUser($user_id, "id,protect_time,create_time");
} else {
if ($user_data['status'] == 0 || $user_data['status'] == -1) {
$res['protect_time'] = $user_data['protect_time'];
}
}
if (empty($res['protect_time'])) {
return 1;//过保护期
}
/*先判断客户创建时间是否超过24小时 目的是兼容老数据 2018-10-20号之后的版本可去除此处代码*/
// if((time() - strtotime($res['create_time'])) < (60*60*24)){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment