Commit 133badac authored by hujun's avatar hujun

商铺编辑案场联系人修改

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