Commit 86b4ff2d authored by hujun's avatar hujun

转铺上架

parent 2928e4d5
......@@ -24,7 +24,7 @@ class Houses extends Basic
protected $house;
protected $code = 200;
protected $data = '';
protected $msg = '';
protected $msg = '';
public function __construct(Request $request = null)
{
......@@ -42,25 +42,36 @@ class Houses extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function edit() {
public function edit()
{
$result['code'] = 200;
$result['msg'] = '';
$result['msg'] = '';
if ($this->request->isPost()) {
$house_id = $this->house->add($this->params, $this->userId); //添加或编辑商铺
if (!empty($this->params['sublet_id']) && $this->params['source'] == 'transfer_list') {
$m_sublet = new SubletModel();
$sublet_data['house_id'] = $house_id;
$sublet_data['status'] = 2;
$sublet_data['agents_id'] = $this->userId;
$m_sublet->editData($sublet_data, $this->params['sublet_id']);
}
if ($house_id) {
$return = $this->response($result['code'], $result['msg'],['id',$house_id]);
$return = $this->response($result['code'], $result['msg'], [ 'id', $house_id ]);
} else {
$return = $this->response(101, 'add houses is error');
}
//编辑商铺
} elseif ($this->params['id']){
} elseif ($this->params['id']) {
if ($this->request->isAjax()) {
//获取商铺详情
$house = new GHouses();
$result['data'] = $house->getHouseById($this->params['id'], 0);
$return = $this->response($result['code'], $result['msg'], $result['data']);
//获取商铺详情
$house = new GHouses();
$result['data'] = $house->getHouseById($this->params['id'], 0);
$return = $this->response($result['code'], $result['msg'], $result['data']);
} else {
//商铺添加页面
$return = view('edit');
......@@ -69,9 +80,9 @@ class Houses extends Basic
//转铺页面跳转过来的
} elseif (isset($this->params['source']) && $this->params['source'] == 'transfer_list') {
if ($this->request->isAjax()) {
$sublet = new SubletModel();
$sublet = new SubletModel();
$result['data'] = $sublet->getSubletHouse($this->params['sublet_id']);
$return = $this->response($result['code'], $result['msg'], $result['data']);
$return = $this->response($result['code'], $result['msg'], $result['data']);
} else {
//商铺添加页面
$return = view('edit');
......@@ -91,12 +102,13 @@ class Houses extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseList() {
public function getHouseList()
{
if ($this->request->isAjax()) {
$data['status'] = 200;
$data['msg'] = '';
$data['msg'] = '';
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
/*精选商铺--0是1否*/
......@@ -134,19 +146,19 @@ class Houses extends Basic
$where['rent_type'] = 1;
switch ($this->params['rent_price']) {
case 1:
$where['rent_price'] = ['<=', 1000000];
$where['rent_price'] = [ '<=', 1000000 ];
break;
case 2:
$where['rent_price'] = ['between', '1000000,3000000'];
$where['rent_price'] = [ 'between', '1000000,3000000' ];
break;
default :
$where['rent_price'] = ['>', '3000000'];
$where['rent_price'] = [ '>', '3000000' ];
}
}
/*对内楼盘名*/
if ($this->params['internal_title'] != NULL) {
$where['internal_title'] = ['LIKE', '%'.$this->params['internal_title'] . '%'];
$where['internal_title'] = [ 'LIKE', '%' . $this->params['internal_title'] . '%' ];
}
/*是否独家0否1是*/
......@@ -156,17 +168,17 @@ class Houses extends Basic
/*开始时间*/
if ($this->params['start_date'] != NULL && $this->params['end_date'] == NULL) {
$where['a.create_time'] = ['> time', $this->params['start_date'] . ' 00:00:00'];
$where['a.create_time'] = [ '> time', $this->params['start_date'] . ' 00:00:00' ];
}
/*结束时间*/
if ($this->params['end_date'] != NULL && $this->params['start_date'] == NULL) {
$where['a.create_time'] = ['< time', $this->params['end_date'] . ' 23:59:59'];
$where['a.create_time'] = [ '< time', $this->params['end_date'] . ' 23:59:59' ];
}
/*开始结束时间*/
if ($this->params['start_date'] != NULL && $this->params['end_date'] != NULL) {
$where['a.create_time'] = ['between time', [$this->params['start_date'] . ' 00:00:00', $this->params['end_date'] . ' 23:59:59']];
$where['a.create_time'] = [ 'between time', [ $this->params['start_date'] . ' 00:00:00', $this->params['end_date'] . ' 23:59:59' ] ];
}
/*根据库存判断是否已租*/
......@@ -174,13 +186,13 @@ class Houses extends Basic
if ($this->params['leased'] == 0) {
$where['residue_num'] = 0;
} else {
$where['residue_num'] = ['<>', 0];
$where['residue_num'] = [ '<>', 0 ];
}
}
/*业态*/
if ($this->params['industry_type'] != NULL) {
$where['industry_type'] = ['LIKE', '%'.$this->params['industry_type'] . '%'];
$where['industry_type'] = [ 'LIKE', '%' . $this->params['industry_type'] . '%' ];
}
$fields = 'a.id,a.shop_type,a.internal_title,a.rent_price,a.is_show,a.create_time,a.residue_num,a.rent_type';
......@@ -190,8 +202,8 @@ class Houses extends Basic
if (!empty($this->params['id'])) {
$where['id'] = $this->params['id'];
}
$where['status'] = ['<>', 3];
$data['data']['list'] = $this->house->getHouseList($pageNo, $pageSize, 'id DESC', $fields, $where, $this->userId);
$where['status'] = [ '<>', 3 ];
$data['data']['list'] = $this->house->getHouseList($pageNo, $pageSize, 'id DESC', $fields, $where, $this->userId);
$data['data']['total'] = $this->house->getHouseListTotal($where);
} else {
//盘方人搜索
......@@ -199,11 +211,11 @@ class Houses extends Basic
if ($this->params['id'] != NULL) {
$where['a.id'] = $this->params['id'];
}
$where['a.status'] = ['<>', 3];
$where['c.name'] = ['LIKE', '%'.$this->params['dish'] . '%'];
$where['b.type'] = ['=', 2];
$where['b.is_del'] = 0;
$data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where, $this->userId);
$where['a.status'] = [ '<>', 3 ];
$where['c.name'] = [ 'LIKE', '%' . $this->params['dish'] . '%' ];
$where['b.type'] = [ '=', 2 ];
$where['b.is_del'] = 0;
$data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where, $this->userId);
$data['data']['total'] = $this->house->getHouseListDishTotal($where);
}
return $this->response($data['status'], $data['msg'], $data['data']);
......@@ -217,13 +229,14 @@ class Houses extends Basic
*
* @return \think\Response
*/
public function del() {
public function del()
{
$data['status'] = 200;
$data['msg'] = '';
$data['data'] = '';
if ($this->params['id']) {
$this->house->isUpdate(true)->save(['status'=>3],['id'=>$this->params['id']]);
$this->house->isUpdate(true)->save([ 'status' => 3 ], [ 'id' => $this->params['id'] ]);
$data['msg'] = 'successfully deleted';
} else {
$data['status'] = 101;
......@@ -238,10 +251,11 @@ class Houses extends Basic
*
* @return \think\Response
*/
public function carefullyChosen() {
public function carefullyChosen()
{
if ($this->params['houses_id'] != NULL && $this->params['is_carefully_chosen'] != NULL) {
$data['is_carefully_chosen'] = $this->params['is_carefully_chosen'];
$this->data = $this->house->editData($data,$this->params['houses_id'],'id');
$this->data = $this->house->editData($data, $this->params['houses_id'], 'id');
} else {
$this->code = 101;
$this->msg = 'houses_id or is_carefully_chosen is null';
......@@ -259,9 +273,10 @@ class Houses extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function editExclusive() {
public function editExclusive()
{
if ($this->params['houses_id']) {
$this->data = $this->house->exclusive($this->params,$this->params['houses_id']);
$this->data = $this->house->exclusive($this->params, $this->params['houses_id']);
} else {
$this->code = 101;
$this->msg = 'houses_id is null';
......@@ -278,7 +293,8 @@ class Houses extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getExclusive() {
public function getExclusive()
{
if ($this->params['houses_id']) {
$this->data = $this->house->getExclusive($this->params['houses_id']);
} else {
......@@ -300,13 +316,13 @@ class Houses extends Basic
public function getRecords()
{
if ($this->params['houses_id']) {
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$field = 'id,name,remark,create_time';
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$field = 'id,name,remark,create_time';
$params['houses_id'] = $this->params['houses_id'];
$params['type'] = 2;
$agents = new AAgents();
$this->data = $agents->getRecords($pageNo, $pageSize,'id DESC', $field, $params);
$agents = new AAgents();
$this->data = $agents->getRecords($pageNo, $pageSize, 'id DESC', $field, $params);
} else {
$this->code = 101;
$this->msg = 'houses_id is null';
......@@ -325,7 +341,8 @@ class Houses extends Basic
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function batchChangDish() {
public function batchChangDish()
{
if (empty($this->params['old_agents_id']) || empty($this->params['agents_id'])) {
return $this->response(101, '盘方信息错误');
......@@ -336,21 +353,21 @@ class Houses extends Basic
$agent->lock(true);
$where['type'] = 2;
$where['b.id'] = $this->params['old_agents_id'];
$agent_house = $agent->getHouseAgent('a.id', $where);
$agent_house = $agent->getHouseAgent('a.id', $where);
$agent_data_arr = [];
if (count($agent_house) > 0) {
$agent_data_arr = [];
foreach ($agent_house as $k=>$v) {
$agent_data_arr[$k]['id'] = $v['id'];
foreach ($agent_house as $k => $v) {
$agent_data_arr[$k]['id'] = $v['id'];
$agent_data_arr[$k]['agents_id'] = $this->params['agents_id'];
}
}
$total = $agent->updateUserAll($agent_data_arr);
$agent->commit();
return $this->response(200, '', ['total'=>count($total)]);
return $this->response(200, '', [ 'total' => count($total) ]);
}
/**
......
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