Commit d1405102 authored by hujun's avatar hujun

独家方修改商铺

parent 013ec70a
...@@ -40,13 +40,15 @@ class Broker extends Basic{ ...@@ -40,13 +40,15 @@ class Broker extends Basic{
$fields = 'a.id,name,phone,COUNT(b.id) evaluate,sum(evaluate_grade) as evaluate_grade,a.img'; $fields = 'a.id,name,phone,COUNT(b.id) evaluate,sum(evaluate_grade) as evaluate_grade,a.img';
$agent_client = 0;
if (!empty($this->userId) && ($this->params['source'] != 'B-APP')) { if (!empty($this->userId) && ($this->params['source'] != 'B-APP')) {
$agent_client = $agents->getAgentClient($fields, ['c.id'=>$this->userId]); $agent_client = $agents->getAgentClient($fields, ['c.id'=>$this->userId]);
} }
$list = $agents->getUser($pageNo, $pageSize, 'evaluate desc', $fields, '', $params['house_id']); $list = $agents->getUser($pageNo, $pageSize, 'evaluate desc', $fields, '', $params['house_id']);
if (!empty($agent_client)) { if (!empty($agent_client['id'])) {
array_unshift($list, $agent_client); array_unshift($list, $agent_client);
} }
......
...@@ -286,15 +286,11 @@ class Shop extends Basic ...@@ -286,15 +286,11 @@ class Shop extends Basic
$result['data'] = []; $result['data'] = [];
if ($this->request->isPost()) { if ($this->request->isPost()) {
$this->gHousesModel->startTrans(); $house_id = $this->gHousesModel->app_add($this->params, $this->agentId); //添加或编辑商铺
$this->params['userId'] = $this->agentId;
$house_id = $this->gHousesModel->app_add($this->params); //添加或编辑商铺
if ($house_id) { if ($house_id) {
$this->gHousesModel->commit();
$result['data']['house_id'] = $house_id['house_id']; $result['data']['house_id'] = $house_id['house_id'];
$result['data']['internal_title'] = $this->params['internal_title']; $result['data']['internal_title'] = $this->params['internal_title'];
} else { } else {
$this->gHousesModel->rollback();
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = 'Add houses failure'; $data['msg'] = 'Add houses failure';
} }
......
...@@ -35,25 +35,25 @@ class Houses extends Basic ...@@ -35,25 +35,25 @@ class Houses extends Basic
/** /**
* 新增和编辑商铺 * 新增和编辑商铺
* *
* @return \think\response\View * @return \think\Response|\think\response\View
* @throws \Exception * @throws \Exception
* @throws \think\exception\PDOException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function edit() { public function edit() {
$result['code'] = 200; $result['code'] = 200;
$result['msg'] = ''; $result['msg'] = '';
if ($this->request->isPost()) { if ($this->request->isPost()) {
$this->house->startTrans(); $house_id = $this->house->add($this->params, $this->userId); //添加或编辑商铺
$this->params['userId'] = $this->userId;
$house_id = $this->house->add($this->params); //添加或编辑商铺
if ($house_id) { if ($house_id) {
$this->house->commit();
$return = $this->response($result['code'], $result['msg'],['id',$house_id]); $return = $this->response($result['code'], $result['msg'],['id',$house_id]);
} else { } else {
$this->house->rollback();
$return = $this->response(101, 'add houses is error'); $return = $this->response(101, 'add houses is error');
} }
//编辑商铺
} elseif ($this->params['id']){ } elseif ($this->params['id']){
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
//获取商铺详情 //获取商铺详情
...@@ -64,6 +64,8 @@ class Houses extends Basic ...@@ -64,6 +64,8 @@ class Houses extends Basic
//商铺添加页面 //商铺添加页面
$return = view('edit'); $return = view('edit');
} }
//转铺页面跳转过来的
} elseif (isset($this->params['source']) && $this->params['source'] == 'transfer_list') { } elseif (isset($this->params['source']) && $this->params['source'] == 'transfer_list') {
if ($this->request->isAjax()) { if ($this->request->isAjax()) {
$sublet = new SubletModel(); $sublet = new SubletModel();
...@@ -96,8 +98,6 @@ class Houses extends Basic ...@@ -96,8 +98,6 @@ class Houses extends Basic
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$fields = '';
/*精选商铺--0是1否*/ /*精选商铺--0是1否*/
if ($this->params['is_carefully_chosen'] != NULL) { if ($this->params['is_carefully_chosen'] != NULL) {
$where['is_carefully_chosen'] = $this->params['is_carefully_chosen']; $where['is_carefully_chosen'] = $this->params['is_carefully_chosen'];
...@@ -181,8 +181,9 @@ class Houses extends Basic ...@@ -181,8 +181,9 @@ class Houses extends Basic
$where['industry_type'] = ['LIKE', '%'.$this->params['industry_type'] . '%']; $where['industry_type'] = ['LIKE', '%'.$this->params['industry_type'] . '%'];
} }
$fields = 'a.id,a.shop_type,a.internal_title,a.rent_price,a.is_show,a.create_time,a.residue_num';
//案场权限人搜索 //案场权限人搜索
if (empty($params['dish'])) { if (empty($this->params['dish'])) {
/*楼盘编号*/ /*楼盘编号*/
if (!empty($params['id'])) { if (!empty($params['id'])) {
$where['id'] = $params['id']; $where['id'] = $params['id'];
...@@ -193,12 +194,13 @@ class Houses extends Basic ...@@ -193,12 +194,13 @@ class Houses extends Basic
} else { } else {
//盘方人搜索 //盘方人搜索
/*楼盘编号*/ /*楼盘编号*/
if ($params['id'] != NULL) { if ($this->params['id'] != NULL) {
$where['a.id'] = $params['id']; $where['a.id'] = $this->params['id'];
} }
$where['a.status'] = ['<>', 3]; $where['a.status'] = ['<>', 3];
$where['c.name'] = ['LIKE', $params['dish'] . '%']; $where['c.name'] = ['LIKE', '%'.$this->params['dish'] . '%'];
$where['b.type'] = ['=', 1]; $where['b.type'] = ['=', 2];
$data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where, $this->userId); $data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where, $this->userId);
$data['data']['total'] = $this->house->getHouseListDishTotal($where); $data['data']['total'] = $this->house->getHouseListDishTotal($where);
} }
......
...@@ -81,7 +81,7 @@ class Login extends Basic ...@@ -81,7 +81,7 @@ class Login extends Basic
} else { } else {
$where_rule['id'] = ['in', $list['rules']]; $where_rule['id'] = ['in', $list['rules']];
//查询后台菜单 //查询后台菜单
$nav = $this->authRule->getRule('', $list['rules']); $nav = $this->authRule->getRule('', $where_rule);
} }
$menu_data = []; $menu_data = [];
...@@ -89,8 +89,6 @@ class Login extends Basic ...@@ -89,8 +89,6 @@ class Login extends Basic
foreach ($nav as $k=>$v) { foreach ($nav as $k=>$v) {
if ($v['is_menu'] == 1) { if ($v['is_menu'] == 1) {
$menu_data[$k]['id'] = $v['id']; $menu_data[$k]['id'] = $v['id'];
// $menu_data[$k]['name_all'] = $v['name'];
// $v['name'] = explode('/',$v['name']);
$menu_data[$k]['name'] = $v['name']; $menu_data[$k]['name'] = $v['name'];
$menu_data[$k]['title'] = $v['title']; $menu_data[$k]['title'] = $v['title'];
$menu_data[$k]['pid'] = $v['pid']; $menu_data[$k]['pid'] = $v['pid'];
......
...@@ -10,10 +10,9 @@ namespace app\index\extend; ...@@ -10,10 +10,9 @@ namespace app\index\extend;
* 基类 * 基类
*/ */
use app\model\AAgents; use app\model\AAgents;
use app\model\AuthGroup; use app\model\GHousesToAgents;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
use think\Controller; use think\Controller;
use think\Db;
use think\Request; use think\Request;
use think\Response; use think\Response;
use think\Session; use think\Session;
...@@ -113,23 +112,20 @@ class Basic extends Controller ...@@ -113,23 +112,20 @@ class Basic extends Controller
} }
} }
$exclude_auth = [ $agents = new AAgents();
'index/addHousesAgents', $is_auth = $agents->agentsAuth($auth_id, $this->userId);
'index/addHousesAgentsDish', $is_auth = empty($is_auth['id']) ? 0:1;
'index/addHousesAgentsExclusive',
'index/houseEdit',
];
$is_auth = 1;
if (in_array($requestPath, $exclude_auth)) {
if (empty($this->params['upload_id']) || ($this->params['upload_id'] != $this->userId)) {
$is_auth = 0;
}
}
//处理盘方编辑商铺
if ($is_auth == 0) { if ($is_auth == 0) {
$agents = new AAgents(); if ($requestPath == 'index/houseEdit' && isset($this->params['id'])) {
$is_auth = $agents->agentsAuth($auth_id, $this->userId); $agent = new GHousesToAgents();
$is_auth = empty($is_auth['id']) ? 0:1; $where['houses_id'] = $this->params['id'];
$where['type'] = 2;
$where['agents_id'] = $this->userId;
$is_ = $agent->getTotal($where);
$is_auth = $is_ > 0 ? 1:0;
}
} }
if (empty($is_auth) && $this->userId != 1) { if (empty($is_auth) && $this->userId != 1) {
...@@ -157,6 +153,7 @@ class Basic extends Controller ...@@ -157,6 +153,7 @@ class Basic extends Controller
if ((time() - $this->lastLoginTime) > 7200) { if ((time() - $this->lastLoginTime) > 7200) {
$this->redirect('/index/login'); $this->redirect('/index/login');
} }
return ; return ;
} }
......
...@@ -180,4 +180,18 @@ class AuthRule extends BaseModel ...@@ -180,4 +180,18 @@ class AuthRule extends BaseModel
->where($where) ->where($where)
->select(); ->select();
} }
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAuthRule($field, $where) {
return $this->field($field)
->where($where)
->find();
}
} }
\ No newline at end of file
...@@ -160,7 +160,8 @@ class GHouses extends BaseModel ...@@ -160,7 +160,8 @@ class GHouses extends BaseModel
*/ */
public function getHouseList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '') public function getHouseList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '')
{ {
$data = $this->field($field) $data = $this->field($field)
->alias('a')
->where($params) ->where($params)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
...@@ -177,31 +178,41 @@ class GHouses extends BaseModel ...@@ -177,31 +178,41 @@ class GHouses extends BaseModel
$result = $data; $result = $data;
} else { } else {
$house_id = array_unique($house_id); $house_id = array_unique($house_id);
/*案场权限人和盘方*/
//获取案场权限人和盘方
$house_agents = Db::table('g_houses_to_agents')->alias('a') $house_agents = Db::table('g_houses_to_agents')->alias('a')
->field('a.houses_id,b.id,b.name,b.phone,a.type') ->field('a.houses_id,b.id,b.name,b.phone,a.agents_id')
->join('a_agents b', 'a.agents_id=b.id', 'left') ->join('a_agents b', 'a.agents_id=b.id', 'left')
->where('a.houses_id', 'IN', implode(',', $house_id)) ->where('a.houses_id', 'IN', implode(',', $house_id))
->where('a.is_del', 0) ->where('a.is_del', 0)
->where('a.type',2) ->where('a.type',2)
->select(); ->select();
foreach ($data as $k => $v) { $house_id_arr = [];
if ($v['upload_id'] == $agents_id) { foreach ($data as $k => $v) {
$data[$k]['auth_edit_house'] = 1;
} else {
$data[$k]['auth_edit_house'] = 0;
}
$result[$k] = $v->toArray(); $result[$k] = $v->toArray();
$dish_name = ''; $dish_name = '';
$result[$k]['dish_name'] = ''; $result[$k]['dish_name'] = '';
$result[$k]['auth_edit_house'] = 1;
foreach ($house_agents as $k2 => $v2) { foreach ($house_agents as $k2 => $v2) {
if ($v['id'] == $v2['houses_id']) { if ($v['id'] == $v2['houses_id']) {
$dish_name .= $v2['name'] . ','; $dish_name .= $v2['name'] . ',';
$result[$k]['dish_name'] = rtrim($dish_name, ','); $result[$k]['dish_name'] = rtrim($dish_name, ',');
if ($v2['agents_id'] == $agents_id) {
$house_id_arr[] = $v['id']; //存储盘方自己的商铺
}
} }
} }
//盘方对自己的商铺有编辑权限
if (in_array($v['id'], $house_id_arr)) {
$result[$k]['auth_edit_house'] = 1;
} else {
$result[$k]['auth_edit_house'] = 0;
}
} }
} }
...@@ -234,11 +245,6 @@ class GHouses extends BaseModel ...@@ -234,11 +245,6 @@ class GHouses extends BaseModel
->select(); ->select();
$house_id = array(); $house_id = array();
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
if ($v['upload_id'] == $agents_id) {
$data[$k]['auth_edit_house'] = 1;
} else {
$data[$k]['auth_edit_house'] = 0;
}
$house_id[$k] = $v['id']; $house_id[$k] = $v['id'];
} }
...@@ -248,31 +254,36 @@ class GHouses extends BaseModel ...@@ -248,31 +254,36 @@ class GHouses extends BaseModel
} else { } else {
/*案场权限人和盘方*/ /*案场权限人和盘方*/
$house_agents = Db::table('g_houses_to_agents')->alias('a') $house_agents = Db::table('g_houses_to_agents')->alias('a')
->field('a.houses_id,b.id,b.name,b.phone,a.type') ->field('a.houses_id,b.id,b.name,b.phone,a.agents_id')
->join('a_agents b', 'a.agents_id=b.id', 'left') ->join('a_agents b', 'a.agents_id=b.id', 'left')
->where('a.houses_id', 'IN', implode(',', $house_id)) ->where('a.houses_id', 'IN', implode(',', $house_id))
->where('a.is_del', 0) ->where('a.is_del', 0)
->where('a.type',2)
->select(); ->select();
$house_id_arr = [];
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
if ($v['upload_id'] == $agents_id) {
$data[$k]['auth_edit_house'] = 1;
} else {
$data[$k]['auth_edit_house'] = 0;
}
$result[$k] = $v->toArray(); $result[$k] = $v->toArray();
$dish_name = ''; $dish_name = '';
$result[$k]['dish_name'] = ''; $result[$k]['dish_name'] = '';
foreach ($house_agents as $k2 => $v2) { foreach ($house_agents as $k2 => $v2) {
if ($v->id == $v2['houses_id']) { if ($v['id'] == $v2['houses_id']) {
if ($v2['type'] == 2) { $dish_name .= $v2['name'] . ',';
$dish_name .= $v2['name'] . ','; $result[$k]['dish_name'] = rtrim($dish_name, ',');
$result[$k]['dish_name'] = rtrim($dish_name, ',');
} else { if ($v2['agents_id'] == $agents_id) {
$result[$k]['dish_name'] = ''; $house_id_arr[] = $v['id']; //存储盘方自己的商铺
} }
} }
} }
//盘方对自己的商铺有编辑权限
if (in_array($v['id'], $house_id_arr)) {
$result[$k]['auth_edit_house'] = 1;
} else {
$result[$k]['auth_edit_house'] = 0;
}
} }
} }
return $result; return $result;
...@@ -297,15 +308,18 @@ class GHouses extends BaseModel ...@@ -297,15 +308,18 @@ class GHouses extends BaseModel
/** /**
* 添加和编辑商铺 * 添加和编辑商铺
* *
* @param $params * @param array $params
* @param int $agent_id
* @return mixed * @return mixed
* @throws \Exception * @throws \Exception
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/ */
public function add($params) public function add(array $params,int $agent_id)
{ {
$this->startTrans();
$case = new ACase(); $case = new ACase();
$case_id = $case->addCase($params['phone']); $case_id = $case->addCase($params['phone']);
$params['case_id'] = $case_id; $params['case_id'] = $case_id;
...@@ -334,9 +348,12 @@ class GHouses extends BaseModel ...@@ -334,9 +348,12 @@ class GHouses extends BaseModel
$sublet = new SubletModel(); $sublet = new SubletModel();
$sublet->editData(['status'=>2], $params['sublet_id']); //转铺表更新状态 $sublet->editData(['status'=>2], $params['sublet_id']); //转铺表更新状态
} }
$params['upload_id'] = $params['userId']; $params['upload_id'] = $agent_id;
$this->allowField(true)->save($params); $this->allowField(true)->save($params);
$house_id = $this->id; $house_id = $this->id;
$params['agent_data'] = empty($params['agent_data']) ? $agent_id : $params['agent_data'] . ','.$agent_id; //默认案场
$params['agent_dish'] = empty($params['agent_dish']) ? $agent_id : $params['agent_dish'] . ','.$agent_id; //默认盘方
} else { } else {
$params['operation_id'] = $params['userId']; $params['operation_id'] = $params['userId'];
$this->allowField(true)->isUpdate(true)->save($params, [ 'id' => $params['id'] ]); $this->allowField(true)->isUpdate(true)->save($params, [ 'id' => $params['id'] ]);
...@@ -382,6 +399,13 @@ class GHouses extends BaseModel ...@@ -382,6 +399,13 @@ class GHouses extends BaseModel
if (isset($params['exclusive_ids'])) { if (isset($params['exclusive_ids'])) {
$agents->addAgents($params['exclusive_ids'], $house_id, 3); $agents->addAgents($params['exclusive_ids'], $house_id, 3);
} }
if ($house_id != NULL) {
$this->commit();
} else {
$this->rollback();
}
return $house_id; return $house_id;
} }
...@@ -758,8 +782,9 @@ class GHouses extends BaseModel ...@@ -758,8 +782,9 @@ class GHouses extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function app_add($params) public function app_add($params, $agent_id)
{ {
$this->startTrans();
if (isset($params['phone'])) { if (isset($params['phone'])) {
$case = new ACase(); $case = new ACase();
$case_id = $case->addCase($params['phone']); $case_id = $case->addCase($params['phone']);
...@@ -785,7 +810,10 @@ class GHouses extends BaseModel ...@@ -785,7 +810,10 @@ class GHouses extends BaseModel
//新增或编辑 //新增或编辑
if (empty($params['id'])) { if (empty($params['id'])) {
$params['upload_id'] = $params['userId']; $params['agent_data'] = empty($params['agent_data']) ? $agent_id : $params['agent_data'] . ','.$agent_id; //默认案场
$params['agent_dish'] = empty($params['agent_dish']) ? $agent_id : $params['agent_dish'] . ','.$agent_id; //默认胖盘方
$params['upload_id'] = $agent_id;
$this->allowField(true)->save($params); $this->allowField(true)->save($params);
$house_id = $this->id; $house_id = $this->id;
$result['house_id'] = $this->id; $result['house_id'] = $this->id;
...@@ -834,6 +862,12 @@ class GHouses extends BaseModel ...@@ -834,6 +862,12 @@ class GHouses extends BaseModel
$agents->addAgents($params['exclusive_ids'], $house_id, 3); $agents->addAgents($params['exclusive_ids'], $house_id, 3);
} }
if ($result['house_id'] != NULL) {
$this->commit();
} else {
$this->rollback();
}
return $result; return $result;
} }
} }
...@@ -36,13 +36,12 @@ ...@@ -36,13 +36,12 @@
[% } %] [% } %]
</td> </td>
<td> <td>
[% if(it[item]["dish_name"] != "") { %]
[%= it[item]['dish_name'] %]
[% } %]
[% if(check_auth('index/addHousesAgentsDish')) { %] [% if(check_auth('index/addHousesAgentsDish')) { %]
[% if(it[item]["dish_name"] == "") { %] <a data-toggle="modal" data-id='[%= it[item]["id"] %]' href="#modal-anch" class="btn1 btn-danger add_applies">修改</a>
<a data-toggle="modal" data-id='[%= it[item]["id"] %]' href="#modal-anch" class="btn1 btn-danger add_applies">修改</a>
[% }else{ %]
[%= it[item]['dish_name'] %]
<a data-toggle="modal" data-id='[%= it[item]["id"] %]' href="#modal-anch" class="btn1 btn-danger add_applies">修改</a>
[% } %]
[% } %] [% } %]
</td> </td>
<td> <td>
......
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