Commit 1a6e4c25 authored by hujun's avatar hujun

centerV2

parent 223ed239
......@@ -78,4 +78,61 @@ class MyCenterService{
}
return $result;
}
/**
* 我的个人中心
*
* @param $agent_id
* @return false|mixed|null|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function centerV2($agent_id){
$field = "a.id,a.store_id,a.auth_group_id,a.district_id,a.level,a.name,a.phone,a.sex,a.img,a.status,b.store_name,
c.district_name,a.position";
$params["agent_id"] = $agent_id;
$result = $this->agentModel->getAgentsInfoByAgentId($field,$params);
if(count($result) <= 0){
return null;
}
$result = $result[0];
$level_name = self::USER_LEVEL_FIST;
if($result["level"] == 20){
$level_name = self::USER_LEVEL_SECOND;
}elseif ($result["level"] == 30 || $result["level"] == 40 ){
$level_name = self::USER_LEVEL_THIRD;
}
$result["level_name"] = $level_name;
$result["sign"] = $result["district_name"].$result["store_name"];
if(!empty($result["img"])){
$result["img"] = AGENTHEADERIMGURL . $result["img"];
}
//todo 需要计算暂时没做。
//$result["money_total"] = 1000;
$result['show_daily'] = $result['show_cost_list'] = 0;
if (!empty($result['auth_group_id'])) {
$redis = new RedisCacheService();
$auth_group = $redis->getRedisCache(3, $result['auth_group_id']);
$result['auth_group_name'] = empty($auth_group['title']) ? '':$auth_group['title'];
$is_ok = $redis->checkRule($redis['id'], 'index/dailyDetailsFinance');
if (!$is_ok) {
$result['show_daily'] = 1; //财务日报
}
$is_ok = $redis->checkRule($redis['id'], 'broker/costListDistrict');
if (!$is_ok) {
$result['show_cost_list'] = 1; //显示费用申请
}
}
return $result;
}
}
\ No newline at end of file
......@@ -394,4 +394,49 @@ class RedisCacheService
$hash_key = $agent_id . '-' . $user_id.'-'.$site_id;
return $this->redis_ext->hDel($user_key, $hash_key);
}
/**
* 是否具有权限
*
* @param int $id
* @param string $name
* @return int 是否可以查看 0:可查看 1:不可查看
*/
public function checkRule(int $id, string $name)
{
if ($id == 1) {
return 0;
}
try {
$agent_data = $this->getRedisCache(2, $id);
if (empty($agent_data)) {
return 0;
}
$group_data = $this->getRedisCache(3, $agent_data['auth_group_id']);
if (empty($group_data)) {
return 0;
}
$rules = $group_data['rules'];
$rule_data = $this->authCache($name);
if (empty($rule_data)) {
return 0;
}
$auth_rule_id = $rule_data['id'];
} catch (\Exception $e) {
return -1;
}
$rules_arr = explode(',', $rules);
$result = 1;
if (in_array($auth_rule_id, $rules_arr)) {
$result = 0;
}
return $result;
}
}
\ No newline at end of file
......@@ -857,6 +857,7 @@ Route::group('broker', [
'center' => ['api_broker/MyCenter/center', ['method' => 'get|post']],
'centerV2' => ['api_broker/MyCenter/centerV2', ['method' => 'get|post']],
// 'houseEdit' => [ 'api_broker/shop/edit', [ 'method' => 'get|post' ] ], //编辑商铺
// 'houseEditV2' => [ 'api_broker/shop/editV2', [ 'method' => 'get|post' ] ], //编辑商铺
'houseEditV2' => ['api_broker/shop/edit', ['method' => 'get|post']], //编辑商铺
......
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