Commit e985cd85 authored by hujun's avatar hujun

添加经纪人与楼盘关系

parent c92e8a72
......@@ -24,27 +24,26 @@ class GHousesToAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addAgents($data, $houses_id, $type){
public function addAgents($agents_id, $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;
$agents_id = array_unique(explode(',',$agents_id));
foreach ($agents_id as $k=>$v) {
$check = $this->where([
'houses_id' => $houses_id,
'agents_id' => $v,
'is_del' => 0 ,
'type' => $type
])->find();
if ($check) {
continue;
}
$agent_arr[$k]['agents_id'] = $v;
$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);
......
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