Commit e985cd85 authored by hujun's avatar hujun

添加经纪人与楼盘关系

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