Commit 133badac authored by hujun's avatar hujun

商铺编辑案场联系人修改

parent dcdc6ee9
......@@ -4,6 +4,7 @@ namespace app\model;
use think\Db;
use think\Session;
class GHouses extends BaseModel
{
......@@ -19,62 +20,72 @@ class GHouses extends BaseModel
* @throws \think\exception\DbException
*/
public function getHouseById($id) {
$data = array();
$fields = 'a.*,b.*';
$select_data = $this->alias('a')->field($fields)
->join('g_houses_ext b','a.id = b.house_id', 'left')
->where('a.id',$id)
->where('a.status','<>',3)
->find();
$data = $select_data->getData();
/*案场,盘方,独家 start*/
$houseAgents = new GHousesToAgents();
$agents_data = $houseAgents->getHousesAgents($id);
$agents_str = '';
$exclusive_str = '';
$dish_str = '';
foreach ($agents_data as $k => $v) {
if ($v['type'] == 1) {
$agents_str .= $v['id'].',';
$data['agents_name'][$k] = $v['id'].'-'.$v['name'].'-'.$v['phone'];
} elseif ($v['type'] == 2) {
$dish_str .= $v['id'].',';
$data['dish_name'][$k] = $v['id'].'-'.$v['name'].'-'.$v['phone'];
} elseif ($v['type'] == 3) {
$exclusive_str .= $v['id'].',';
$data['exclusive_name'][$k] = $v['id'].'-'.$v['name'].'-'.$v['phone'];
if ($select_data) {
$data = $select_data->getData();
/*案场,盘方,独家 start*/
$houseAgents = new GHousesToAgents();
$agents_data = $houseAgents->getHousesAgents($id);
$agents_str = '';
$exclusive_str = '';
$dish_str = '';
foreach ($agents_data as $k => $v) {
if ($v['type'] == 1) {
$agents_str .= $v['id'] . ',';
$data['agents_name'][$k] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
} elseif ($v['type'] == 2) {
$dish_str .= $v['id'] . ',';
$data['dish_name'][$k] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
} elseif ($v['type'] == 3) {
$exclusive_str .= $v['id'] . ',';
$data['exclusive_name'][$k] = $v['id'] . '-' . $v['name'] . '-' . $v['phone'];
}
}
}
$data['agent_data'] = rtrim($agents_str,',');
$data['agent_dish'] = rtrim($dish_str,',');
$data['exclusive_ids'] = rtrim($exclusive_str,',');
/*案场,盘方,独家 end*/
/*案场联系人 start*/
$case = new ACase();
$data['phone'] = $case->where('id','in',$data['case_id'])
->where('status',0)->column('name,phone');
/*案场联系人 end*/
/*图片 start*/
$img = new GHousesImgs();
$img_data = $img->field('id,img_type,img_name')
->where('img_status = 0 AND house_id = '.$id)
->select();
$area = explode('##',$data['code']);
$data['province_code'] = $area['0'];
$data['city_code'] = $area['1'];
$data['disc_code'] = $area['2'];
foreach ($img_data as $k=>$v) {
switch ($v->img_type) {
case 1 :
$data['cover'] = $v->img_name;break;
case 2 :
$data['slide_show'][$k] = $v->img_name;break;
case 3 :
$data['plan'][$k] = $v->img_name;break;
default :
$data['exclusive_img'][$k] = $v->img_name;
$data['agent_data'] = rtrim($agents_str, ',');
$data['agent_dish'] = rtrim($dish_str, ',');
$data['exclusive_ids'] = rtrim($exclusive_str, ',');
/*案场,盘方,独家 end*/
/*案场联系人 start*/
$case = new ACase();
$data['phone'] = $case->field('id,name,phone')->where('id', 'in', $data['case_id'])
->where('status', 0)->select();
/*案场联系人 end*/
/*图片 start*/
$img = new GHousesImgs();
$img_data = $img->field('id,img_type,img_name')
->where('img_status = 0 AND house_id = ' . $id)
->select();
$area = explode('##', $data['code']);
$data['province_code'] = $area['0'];
$data['city_code'] = $area['1'];
$data['disc_code'] = $area['2'];
foreach ($img_data as $k => $v) {
switch ($v->img_type) {
case 1 :
$data['cover'] = $v->img_name;
break;
case 2 :
$data['slide_show'][$k] = $v->img_name;
break;
case 3 :
$data['plan'][$k] = $v->img_name;
break;
default :
$data['exclusive_img'][$k] = $v->img_name;
}
}
/*图片 start*/
}
/*图片 start*/
return $data;
}
......@@ -239,9 +250,11 @@ class GHouses extends BaseModel
//新增或编辑
if ($params['id'] == '') {
$params['upload_id'] = Session::get('userId');
$this->allowField(true)->save($params);
$house_id = $this->id;
} else {
$params['operation_id'] = Session::get('userId');
$this->allowField(true)->isUpdate(true)->save($params, ['id' => $params['id']]);
$house_id = $this->id;
}
......
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