Commit c7c5034e authored by hujun's avatar hujun

新增、解除经纪人和楼盘关系

parent efab9ff8
...@@ -12,6 +12,7 @@ namespace app\index\controller; ...@@ -12,6 +12,7 @@ namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
use app\model\AAgents; use app\model\AAgents;
use app\model\Agents; use app\model\Agents;
use app\model\GHousesToAgents;
class Broker extends Basic class Broker extends Basic
{ {
...@@ -80,4 +81,65 @@ class Broker extends Basic ...@@ -80,4 +81,65 @@ class Broker extends Basic
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['data']);
} }
/**
* 添加经纪人与楼盘关系
*
* @return \think\Response
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function AddHousesAgents() {
$data['status'] = 200;
$data['data'] = '';
$data['msg'] = '';
$params = $this->request->param();
if ($params['houses_id']) {
$hg = new GHousesToAgents();
switch ($params['type']) {
case 1:
$res = $hg->addAgents($params['phone'], $params['houses_id'], $params['type']);break;
case 2:
$res = $hg->addAgents($params['phone'], $params['houses_id'], $params['type']);break;
default :
$data['status'] = 101;
$data['msg'] = 'type is null';
}
if (!count($res) > 0) {
$data['status'] = 200;
$data['msg'] = 'Data already exists';
}
} else {
$data['status'] = 101;
$data['msg'] = 'houses_id is null';
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
/**
* 解除经纪人和楼盘关系
*
* @return \think\Response
*/
public function delTohouses() {
$data['status'] = 200;
$data['data'] = '';
$data['msg'] = '';
$params = $this->request->param();
if ($params['id']) {
$hg = new GHousesToAgents();
$hg->del($params['id']);
} else {
$data['status'] = 101;
$data['msg'] = 'id is null';
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
} }
\ No newline at end of file
<?php
namespace app\model;
use think\Model;
class GHousesToAgents extends BaseModel
{
protected $table = 'g_houses_to_agents';
protected $date = '';
public function __construct()
{
$this->date = date('Y-m-d H:i:s');
}
/**
* @param $data
* @param $houses_id
* @param $type 案场权限人:0,盘方:1,独家:2
* @return array|false|int
* @throws \Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addAgents($data, $houses_id, $type){
$agent_arr = array();
$data = array_unique($data);
foreach ($data as $k=>$v) {
$arr = explode('-',$v);
if (count($arr) == 3) {
$check = $this->where([
'houses_id' => $houses_id,
'agents_id' => $arr['0'],
'is_del' => 0 ,
'type' => $type
])->find();
if ($check) {
continue;
}
$agent_arr[$k]['agents_id'] = $arr['0'];
$agent_arr[$k]['houses_id'] = $houses_id;
$agent_arr[$k]['type'] = $type;
$agent_arr[$k]['create_time'] = $this->date;
$agent_arr[$k]['update_time'] = $this->date;
}
}
$res = $this->saveAll($agent_arr);
return $res;
}
/**
* 解除经纪人和楼盘关系
*
* @param $id
* @return bool|false|int
*/
public function del($id) {
if ($id) {
$res = $this->save(['is_del' => 1],['id'=>$id]);
} else {
$res = false;
}
return $res;
}
}
...@@ -67,6 +67,8 @@ Route::group('index', [ ...@@ -67,6 +67,8 @@ Route::group('index', [
//查询经纪人 //查询经纪人
'getBroker' => ['index/broker/getBroker',['method'=>'get']], 'getBroker' => ['index/broker/getBroker',['method'=>'get']],
'getBroker_new' => ['index/broker/getBroker_new',['method'=>'get']], 'getBroker_new' => ['index/broker/getBroker_new',['method'=>'get']],
'addHousesAgents' => ['index/broker/AddHousesAgents', ['method' => 'POST']], //新增楼盘与经纪人关系
'delTohouses' => ['index/broker/delTohouses', ['method' => 'POST']], //解除经纪人和楼盘关系
//版本管理 //版本管理
'version' => ['index/version/index',['method'=>'get']], 'version' => ['index/version/index',['method'=>'get']],
......
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