Commit d0ba9898 authored by hujun's avatar hujun

修改保护期

parent 416c3996
...@@ -142,52 +142,53 @@ class RedisCacheService ...@@ -142,52 +142,53 @@ class RedisCacheService
} }
/** /**
* @param $type * @param $type 1:客户 2:经纪人 3:角色组 4:权限
* @param $id * @param $id
* @return array|bool|false|mixed|\PDOStatement|string|\think\Model * @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) { public function getRedisCache($type, $id) {
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
switch ($type) { try {
case 1: switch ($type) {
$result = $this->redis_ext->get($this->user_key . $id); case 1:
if (empty($result)) { $result = $this->redis_ext->get($this->user_key . $id);
$result = $this->userCache($id); if (empty($result)) {
} else { $result = $this->userCache($id);
$result = json_decode($result, true); } else {
} $result = json_decode($result, true);
break; }
case 2 : break;
$result = $this->redis_ext->get($this->agent_key . $id); case 2 :
if (empty($result)) { $result = $this->redis_ext->get($this->agent_key . $id);
$result = $this->agentCache($id); if (empty($result)) {
} else { $result = $this->agentCache($id);
$result = json_decode($result, true); } else {
} $result = json_decode($result, true);
break; }
case 3 : break;
$result = $this->redis_ext->get($this->group_key . $id); case 3 :
if (empty($result)) { $result = $this->redis_ext->get($this->group_key . $id);
$result = $this->groupCache($id); if (empty($result)) {
} else { $result = $this->groupCache($id);
$result = json_decode($result, true); } else {
} $result = json_decode($result, true);
break; }
case 4 : break;
$result = $this->redis_ext->get($this->rule_key. $id); case 4 :
if (empty($result)) { $result = $this->redis_ext->get($this->rule_key. $id);
$result = $this->authCache($id); if (empty($result)) {
} else { $result = $this->authCache($id);
$result = json_decode($result, true); } else {
} $result = json_decode($result, true);
break; }
default : break;
$result = false; default :
$result = false;
}
} catch (\Exception $e) {
$result = false;
} }
return $result; return $result;
} }
......
...@@ -10,6 +10,7 @@ namespace app\index\service; ...@@ -10,6 +10,7 @@ namespace app\index\service;
use app\api_broker\service\PushMessageService; use app\api_broker\service\PushMessageService;
use app\api_broker\service\RedisCacheService;
use app\api_broker\service\VipService; use app\api_broker\service\VipService;
use app\extra\RedisExt; use app\extra\RedisExt;
use app\index\validate\MemberValidate; use app\index\validate\MemberValidate;
...@@ -357,7 +358,20 @@ class UserService ...@@ -357,7 +358,20 @@ class UserService
if(!$user_id){ if(!$user_id){
return 1; 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号之后的版本可去除此处代码*/ /*先判断客户创建时间是否超过24小时 目的是兼容老数据 2018-10-20号之后的版本可去除此处代码*/
// if((time() - strtotime($res['create_time'])) < (60*60*24)){ // 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