Commit 93df3da8 authored by hujun's avatar hujun

修改状态

parent 78193d7a
...@@ -1460,4 +1460,34 @@ class OfficeRoomService ...@@ -1460,4 +1460,34 @@ class OfficeRoomService
} }
return $result; return $result;
} }
/**
* 修改上下架
*
* @param int $building_id
* @param int $status //状态 1上架 2下架 3回收
* @return mixed
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function downStatus(int $building_id, int $status) {
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
if (empty($building_id) || empty($status)) {
$result['msg'] = '参数错误';
return $result;
}
$where['building_id'] = $building_id;
$where['status'] = ['<>', 3];
$num = $this->m_office_room->updateData(['status'=>$status], $where);
if ($num > 0) {
$result['status'] = 'successful';
$result['msg'] = '修改成功';
} else {
$result['msg'] = '修改失败';
}
return $result;
}
} }
\ No newline at end of file
...@@ -64,7 +64,7 @@ class OfficeService ...@@ -64,7 +64,7 @@ class OfficeService
$result['msg'] = $this->validate->getError(); $result['msg'] = $this->validate->getError();
return $result; return $result;
} }
$data['status'] = 1;
$id = $this->m_office->addOffice($data, $agent_id); $id = $this->m_office->addOffice($data, $agent_id);
if ($id > 0) { if ($id > 0) {
...@@ -112,6 +112,7 @@ class OfficeService ...@@ -112,6 +112,7 @@ class OfficeService
$this->m_office_img->edit($data['building_images'], $id, 0); $this->m_office_img->edit($data['building_images'], $id, 0);
} }
$this->service_room->downStatus($id, 1);
$result['status'] = 'successful'; $result['status'] = 'successful';
} else { } else {
$result['msg'] = '新增或编辑失败!'; $result['msg'] = '新增或编辑失败!';
......
...@@ -27,7 +27,9 @@ class OfficeBuildingValidate extends Validate ...@@ -27,7 +27,9 @@ class OfficeBuildingValidate extends Validate
'longitude' => 'require|min:1', 'longitude' => 'require|min:1',
'latitude' => 'require|min:1', 'latitude' => 'require|min:1',
'business_district_id' => 'require|between: 1,99999999999', 'business_district_id' => 'require|between: 1,99999999999',
'intro'=>'require|length:1,255' 'intro'=>'require|length:1,255',
'add_building_stations'=>'require|min:5',
'building_images'=>'require'
]; ];
protected $message = [ protected $message = [
...@@ -55,14 +57,17 @@ class OfficeBuildingValidate extends Validate ...@@ -55,14 +57,17 @@ class OfficeBuildingValidate extends Validate
'intro.length'=>'楼盘简介要做1至255个字', 'intro.length'=>'楼盘简介要做1至255个字',
'floor_total.require'=>'总层数不能为空', 'floor_total.require'=>'总层数不能为空',
'floor_total.between'=>'总层数参数错误', 'floor_total.between'=>'总层数参数错误',
'type.require'=>'类型不为空' 'type.require'=>'类型不为空',
'add_building_stations.require'=>'地铁必选',
'add_building_stations.min'=>'地铁参数错误',
'building_images.require'=>'楼盘图片必传',
]; ];
protected $scene = [ protected $scene = [
'add' => ['title','address','province','city','disc','type','floor_total','longitude','latitude', 'add' => ['title','address','province','city','disc','type','floor_total','longitude','latitude',
'business_district_id','upload_id','intro'], 'business_district_id','upload_id','intro','building_images','add_building_stations'],
'edit' => ['id','title','address','province','city','disc','type','floor_total','longitude','latitude', 'edit' => ['id','title','address','province','city','disc','type','floor_total','longitude','latitude',
'business_district_id','intro'], 'business_district_id','intro','building_images','add_building_stations'],
'detail' => ['id'] 'detail' => ['id']
]; ];
} }
\ No newline at end of file
...@@ -469,4 +469,14 @@ class OfficeGRoom extends BaseModel ...@@ -469,4 +469,14 @@ class OfficeGRoom extends BaseModel
return $result; return $result;
} }
/**
* @param $data
* @param $where
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function updateData($data, $where) {
return $this->db_->where($where)->update($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