Commit d1405102 authored by hujun's avatar hujun

独家方修改商铺

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