Commit 3e82d5a2 authored by hujun's avatar hujun

楼盘详情

parent d86c91cf
...@@ -13,6 +13,7 @@ use app\index\extend\Basic; ...@@ -13,6 +13,7 @@ use app\index\extend\Basic;
use app\model\GHouses; use app\model\GHouses;
use app\model\GHousesExt; use app\model\GHousesExt;
use app\model\GHousesImgs; use app\model\GHousesImgs;
use app\model\HouseInfos;
class Houses extends Basic class Houses extends Basic
...@@ -22,7 +23,7 @@ class Houses extends Basic ...@@ -22,7 +23,7 @@ class Houses extends Basic
} }
/** /**
* 新增商铺 * 新增和编辑商铺
* *
* @return \think\response\View * @return \think\response\View
* @throws \Exception * @throws \Exception
...@@ -31,8 +32,8 @@ class Houses extends Basic ...@@ -31,8 +32,8 @@ class Houses extends Basic
public function edit() { public function edit() {
$result['code'] = 200; $result['code'] = 200;
$result['msg'] = ''; $result['msg'] = '';
if ($this->request->isPost()) {
$params = $this->request->param(); $params = $this->request->param();
if ($this->request->isPost()) {
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
if ($params['id']) { if ($params['id']) {
...@@ -71,28 +72,46 @@ class Houses extends Basic ...@@ -71,28 +72,46 @@ class Houses extends Basic
$house_img->edit($params, $house_id); $house_img->edit($params, $house_id);
} }
/***保存图片 hujun 2018.1.19 end***/ /***保存图片 hujun 2018.1.19 end***/
if ($house->id) { if ($house_id) {
$house->commit(); $house->commit();
$return = $this->response($result['code'], $result['msg']); $return = $this->response($result['code'], $result['msg']);
} else { } else {
$house->rollback(); $house->rollback();
$return = $this->response(101, $result['msg']); $return = $this->response(101, $result['msg']);
} }
} elseif ($this->request->param('id')){ } elseif ($params['id']){
//获取商铺详情 //获取商铺详情
$house = new GHouses(); $house = new GHouses();
$result['data'] = $house->find(); $result['data'] = $house->getHouseById($params['id']);
$return = $this->response($result['code'], $result['msg'], $result['data']); $return = $this->response($result['code'], $result['msg'], $result['data']);
} else { } else {
//商铺添加页面 //商铺添加页面
$return = view('edit'); $return = view('edit');
} }
return $return; return $return;
} }
/**
* 获取商铺列表
*
* @return \think\Response
*/
public function getHouse() {
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$house = new GHouses();
$where = 'status <> 3';
$data['list'] = $house->getHouseInfoList($pageNo, $pageSize, 'id DESC', '*', $where);
// $data['total'] = $house->($where);
return $this->response($data['status'], $data['msg'], $data['data']);
}
public function del() { public function del() {
} }
......
...@@ -7,4 +7,40 @@ namespace app\model; ...@@ -7,4 +7,40 @@ namespace app\model;
class GHouses extends BaseModel class GHouses extends BaseModel
{ {
protected $table = 'g_houses'; protected $table = 'g_houses';
/**
* 通过id获取商铺详情
*
* @param $id
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseById($id) {
$fields = 'a.*,b.fee_rule,internal_item_advantage,external_item_advantage,tiny_brochure_url,auditorium,traffic,
enter_num,do_business_date,start_business_date,singn_rule,landlord_phone';
$data = $this->alias('a')->field($fields)
->join('g_houses_ext b','a.id = b.house_id', 'left')
->where('a.id',$id)
->find();
$data = $data->toArray();
$img = new GHousesImgs();
$img_data = $img->field('id,img_type,img_name')
->where('img_status = 0 AND house_id = '.$id)
->select();
foreach ($img_data as $k=>$v) {
switch ($v->img_type) {
case 1 :
$data['cover'] = $v;break;
case 2 :
$data['slide_show'][$k] = $v;break;
default :
$data['plan'][$k] = $v;
}
}
return $data;
}
} }
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