Commit 1e68107a authored by hujun's avatar hujun

商铺删除

parent 56652c23
...@@ -111,6 +111,9 @@ class BusinessDistrict extends Basic ...@@ -111,6 +111,9 @@ class BusinessDistrict extends Basic
* 获取省市区数据 * 获取省市区数据
* *
* @return \think\Response * @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function regions() { public function regions() {
$code = $this->request->get('code'); $code = $this->request->get('code');
......
...@@ -13,10 +13,19 @@ use app\index\extend\Basic; ...@@ -13,10 +13,19 @@ 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 think\Request;
class Houses extends Basic class Houses extends Basic
{ {
protected $house;
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->house = new GHouses();
}
public function index() { public function index() {
return view('index'); return view('index');
} }
...@@ -39,14 +48,14 @@ class Houses extends Basic ...@@ -39,14 +48,14 @@ class Houses extends Basic
$params['update_time'] = $date; $params['update_time'] = $date;
} }
$house = new GHouses();
$house->startTrans(); $this->house->startTrans();
//新增或编辑 //新增或编辑
if ($params['id'] == '') { if ($params['id'] == '') {
$house_id = $house->allowField(true)->save($params); $house_id = $this->house->allowField(true)->save($params);
} else { } else {
$house_id = $house->allowField(true)->isUpdate(true)->save($params, ['id' => $params['id']]); $house_id = $this->house->allowField(true)->isUpdate(true)->save($params, ['id' => $params['id']]);
} }
$params['house_id'] = $house_id; $params['house_id'] = $house_id;
$house_ext = new GHousesExt(); $house_ext = new GHousesExt();
...@@ -72,10 +81,10 @@ class Houses extends Basic ...@@ -72,10 +81,10 @@ class Houses extends Basic
} }
/***保存图片 hujun 2018.1.19 end***/ /***保存图片 hujun 2018.1.19 end***/
if ($house_id) { if ($house_id) {
$house->commit(); $this->house->commit();
$return = $this->response($result['code'], $result['msg']); $return = $this->response($result['code'], $result['msg']);
} else { } else {
$house->rollback(); $this->house->rollback();
$return = $this->response(101, $result['msg']); $return = $this->response(101, $result['msg']);
} }
} elseif ($params['id']){ } elseif ($params['id']){
...@@ -107,7 +116,6 @@ class Houses extends Basic ...@@ -107,7 +116,6 @@ class Houses extends Basic
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo']; $pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize']; $pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$house = new GHouses();
$fields = ''; $fields = '';
/*精选商铺--0是1否*/ /*精选商铺--0是1否*/
...@@ -186,14 +194,19 @@ class Houses extends Basic ...@@ -186,14 +194,19 @@ class Houses extends Basic
} }
} }
/*业态*/
if ($params['industry_type'] != NULL) {
$where['industry_type'] = ['LIKE',$params['industry_type'].'%'];
}
if (empty($params['dish'])) { if (empty($params['dish'])) {
/*楼盘编号*/ /*楼盘编号*/
if ($params['id'] != NULL) { if ($params['id'] != NULL) {
$where['id'] = $params['id']; $where['id'] = $params['id'];
} }
$where['status'] = ['<>',2]; $where['status'] = ['<>',2];
$data['data']['list'] = $house->getHouseList($pageNo, $pageSize, 'id DESC', $fields, $where); $data['data']['list'] = $this->house->getHouseList($pageNo, $pageSize, 'id DESC', $fields, $where);
$data['data']['total'] = $house->getTotal($where); $data['data']['total'] = $this->house->getTotal($where);
} else { } else {
/*楼盘编号*/ /*楼盘编号*/
if ($params['id'] != NULL) { if ($params['id'] != NULL) {
...@@ -201,14 +214,30 @@ class Houses extends Basic ...@@ -201,14 +214,30 @@ class Houses extends Basic
} }
$where['a.status'] = ['<>',2]; $where['a.status'] = ['<>',2];
$where['c.name'] = ['LIKE',$params['dish'].'%']; $where['c.name'] = ['LIKE',$params['dish'].'%'];
$data['data']['list'] = $house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where); $data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where);
$data['data']['total'] = $house->getHouseListDishTotal($where); $data['data']['total'] = $this->house->getHouseListDishTotal($where);
} }
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['data']);
} }
/**
* 伪删除商铺
*
* @return \think\Response
*/
public function del() { public function del() {
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
if ($params['id']) {
$this->house->isUpdate(true)->save(['status'=>3],['id'=>$params['id']]);
$data['msg'] = 'successfully deleted';
} else {
$data['status'] = 101;
$data['msg'] = 'id is null';
}
return $this->response($data['status'], $data['msg'], $data['data']);
} }
} }
\ No newline at end of file
...@@ -84,10 +84,9 @@ Route::group('index', [ ...@@ -84,10 +84,9 @@ Route::group('index', [
'BusinessList' => ['index/BusinessDistrict/getBusiness', ['method' => 'get']], //获取商铺列表数据 'BusinessList' => ['index/BusinessDistrict/getBusiness', ['method' => 'get']], //获取商铺列表数据
'houseList' => ['index/Houses/index', ['method' => 'get']], //商铺列表 'houseList' => ['index/Houses/index', ['method' => 'get']], //商铺列表
'houseEdit' => ['index/Houses/edit', ['method' => 'get|post']], //编辑商铺 'houseEdit' => ['index/Houses/edit', ['method' => 'get|post']], //编辑商铺
'houseDel' => ['index/Houses/del', ['method' => 'get']], //删除商铺 'houseDel' => ['index/Houses/del', ['method' => 'post']], //删除商铺
'regions' => ['index/BusinessDistrict/regions', ['method' => 'get']], //获取省市区数据 'regions' => ['index/BusinessDistrict/regions', ['method' => 'get']], //获取省市区数据
'getHouseList' => ['index/houses/getHouseList', ['method' => 'get']], 'getHouseList' => ['index/houses/getHouseList', ['method' => 'get']], //楼盘列表
'regions' => ['index/BusinessDistrict/regions', ['method' => 'get']], //删除商铺
]); ]);
......
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