Commit f3980a4b authored by hujun's avatar hujun

house_exclusive

parent d86ee67d
......@@ -1027,24 +1027,29 @@ class Shop extends Basic
/**
* 商铺列表添加和编辑独家
*
* @return \think\Response
*/
public function editExclusive()
{
// $res = $this->gHousesModel->exclusive($this->params, $this->params['houses_id'], $this->agentId, $this->siteId);
if (empty($this->params['id'])) {
if (empty($this->params['id']) || empty($this->params['exclusive_ids'])) {
return $this->response(101, '参数错误');
}
$code = 200;
$msg = "";
$house = new HouseService();
if ($this->params['is_exclusive_type'] == 1) {
$house = new HouseService();
$result = $house->addHouse($this->params, $this->agentId, 1, 0, 'exclusive');
if ($result['status'] == 'fail') {
$code = 101;
$msg = $result['msg'];
}
} else {
$this->gHousesModel->editData(['is_exclusive_type'=>0], $this->params['id']);
$result = $house->delAgentHouse(3, $this->params['id'], $this->params['exclusive_ids']);
if (!$result) {
$code = 101;
$msg = '解除独家关系失败';
}
}
return $this->response($code, $msg);
......
......@@ -528,10 +528,6 @@ class Houses extends Basic
* 商铺列表添加和编辑独家
*
* @return \think\Response
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function editExclusive()
{
......@@ -539,7 +535,24 @@ class Houses extends Basic
return $this->response(101, '参数错误');
}
$this->data = $this->house->exclusive($this->params, $this->params['houses_id'], $this->userId, $this->siteId);
$house = new HouseService();
if ($this->params['is_exclusive_type'] == 1) {
$data = $this->params;
$data['id'] = $this->params['houses_id'];
unset($data['houses_id']);
$house = new HouseService();
$this->data = $house->addHouse($data, $this->userId, 0, $this->siteId, 'exclusive');
if ($this->data['status'] == 'fail') {
$this->code = 101;
$this->msg = $this->data['msg'];
}
} else {
$result = $house->delAgentHouse(3, $this->params['houses_id'], $this->params['exclusive_id']);
if (!$result) {
$this->code = 101;
$this->msg = '解除独家关系失败';
}
}
return $this->response($this->code, $this->msg, $this->data);
}
......
......@@ -935,4 +935,32 @@ class HouseService
return ;
}
/**
* 删除经纪人与楼盘关系
*
* @param $type
* @param $house_id
* @param $agent_id
* @return GHousesToAgents|bool
*/
public function delAgentHouse($type, $house_id, $agent_id) {
if (empty($type) || empty($house_id) || empty($agent_id)) {
return false;
}
$id = $this->m_house->getTotal(['id'=>$house_id]);
if (empty($id)) {
return false;
}
$where['houses_id'] = $house_id;
$where['agents_id'] = $agent_id;
$where['type'] = $type;
$is_ok = $this->agent_house->updateData($where, ['is_del'=>1]);
if ($type == 3) {
$this->m_house->editData(['is_exclusive_type'=>0], $house_id);
}
return $is_ok;
}
}
\ No newline at end of file
......@@ -573,4 +573,13 @@ class GHousesToAgents extends BaseModel
$result = $this->where($where_)->count();
return $result;
}
/**
* @param $where
* @param $data
* @return GHousesToAgents
*/
public function updateData($where, $data) {
return $this->where($where)->update($data);
}
}
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