Commit 0c28c244 authored by clone's avatar clone

1

parent 6cc8dfe3
...@@ -56,8 +56,8 @@ class OfficeRoomService ...@@ -56,8 +56,8 @@ class OfficeRoomService
$this->m_office = new OfficeGBuilding(); $this->m_office = new OfficeGBuilding();
if (CURRENT_URL == 'https://api.tonglianjituan.com/') { if (CURRENT_URL == 'https://api.tonglianjituan.com/') {
$this->internet_path = IMAGES_URL.'/resource/lib/Attachments/images/'; $this->internet_path = IMAGES_URL . '/resource/lib/Attachments/images/';
}else { } else {
$this->internet_path = 'http://pre2.tonglianjituan.com/resource/lib/Attachments/images/'; $this->internet_path = 'http://pre2.tonglianjituan.com/resource/lib/Attachments/images/';
} }
} }
...@@ -89,7 +89,7 @@ class OfficeRoomService ...@@ -89,7 +89,7 @@ class OfficeRoomService
$result['msg'] = $this->validate->getError(); $result['msg'] = $this->validate->getError();
return $result; return $result;
} }
$status = $this->m_office->getFieldOneValue('status', ['id'=>$data['building_id']]);//验证办公楼字典是否完整 $status = $this->m_office->getFieldOneValue('status', ['id' => $data['building_id']]);//验证办公楼字典是否完整
$is_alert = 0; $is_alert = 0;
if ($status != 1) { if ($status != 1) {
$is_alert = 1; $is_alert = 1;
...@@ -110,10 +110,10 @@ class OfficeRoomService ...@@ -110,10 +110,10 @@ class OfficeRoomService
$landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $id); $landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $id);
if (!empty($landlord_phone_old)) { if (!empty($landlord_phone_old)) {
$remark .= implode(',', $landlord_phone_old).','; $remark .= implode(',', $landlord_phone_old) . ',';
} }
} catch (\Exception $e) { } catch (\Exception $e) {
$result['msg'] = '房东手机号处理失败'.$e->getMessage(); $result['msg'] = '房东手机号处理失败' . $e->getMessage();
return $result; return $result;
} }
} }
...@@ -261,7 +261,7 @@ class OfficeRoomService ...@@ -261,7 +261,7 @@ class OfficeRoomService
if ($data) { if ($data) {
/*案场,盘方,独家 start*/ /*案场,盘方,独家 start*/
$agents_data = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', ['house_id'=>$data['id']]); $agents_data = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', ['house_id' => $data['id']]);
$agents_str = $exclusive_str = $dish_str = ''; $agents_str = $exclusive_str = $dish_str = '';
foreach ($agents_data as $k => $v) { foreach ($agents_data as $k => $v) {
if ($v['type'] == 1) { if ($v['type'] == 1) {
...@@ -296,7 +296,7 @@ class OfficeRoomService ...@@ -296,7 +296,7 @@ class OfficeRoomService
/*案场,盘方,独家 end*/ /*案场,盘方,独家 end*/
/*图片 start*/ /*图片 start*/
$img_data = $this->m_office_img->getListAll('id,img_type,img_name', ['house_id'=>$id]); $img_data = $this->m_office_img->getListAll('id,img_type,img_name', ['house_id' => $id]);
if ($app == 0) { if ($app == 0) {
foreach ($img_data as $k => $v) { foreach ($img_data as $k => $v) {
...@@ -346,11 +346,11 @@ class OfficeRoomService ...@@ -346,11 +346,11 @@ class OfficeRoomService
$data['title'] = ''; $data['title'] = '';
$data['landlord_phone_array'] = $data['building_data'] = []; $data['landlord_phone_array'] = $data['building_data'] = [];
} else { } else {
$data['title'] = $office->getFieldOneValue('title', ['id'=>$data['building_id']]); $data['title'] = $office->getFieldOneValue('title', ['id' => $data['building_id']]);
$data['landlord_phone_array'] = $m_landlord->getAllList('id,name,phone', ['house_id'=>$data['id']]); $data['landlord_phone_array'] = $m_landlord->getAllList('id,name,phone', ['house_id' => $data['id']]);
$building_service = new OfficeService(); $building_service = new OfficeService();
$building_data = $building_service->BuildingSearch(1, 100, ['id'=>$data['building_id']]); $building_data = $building_service->BuildingSearch(1, 100, ['id' => $data['building_id']]);
if ($building_data['status'] != 'fail') { if ($building_data['status'] != 'fail') {
$data['building_data'] = $building_data['data'][0]; $data['building_data'] = $building_data['data'][0];
} else { } else {
...@@ -358,22 +358,22 @@ class OfficeRoomService ...@@ -358,22 +358,22 @@ class OfficeRoomService
} }
} }
$data['landlord_phone_array'] = $this->landlord_phone->getAllList('id,name,phone', ['house_id'=>$id]); //房东手机号 $data['landlord_phone_array'] = $this->landlord_phone->getAllList('id,name,phone', ['house_id' => $id]); //房东手机号
if ($data['price_total'] > 0) { if ($data['price_total'] > 0) {
$data['price_total'] = $data['price_total']/100; $data['price_total'] = $data['price_total'] / 100;
} }
if ($data['price'] > 0) { if ($data['price'] > 0) {
$data['price'] = $data['price']/100; $data['price'] = $data['price'] / 100;
} }
if ($data['slotting_fee'] > 0) { if ($data['slotting_fee'] > 0) {
$data['slotting_fee'] = $data['slotting_fee']/100; $data['slotting_fee'] = $data['slotting_fee'] / 100;
} }
if ($data['management_fee'] > 0) { if ($data['management_fee'] > 0) {
$data['management_fee'] = $data['management_fee']/100; $data['management_fee'] = $data['management_fee'] / 100;
} }
} }
$result['data'] = $data; $result['data'] = $data;
...@@ -513,7 +513,7 @@ class OfficeRoomService ...@@ -513,7 +513,7 @@ class OfficeRoomService
} }
} }
$result['status'] = 'successful'; $result['status'] = 'successful';
}catch (\Exception $e) { } catch (\Exception $e) {
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = $e->getMessage(); $result['msg'] = $e->getMessage();
} }
...@@ -532,21 +532,22 @@ class OfficeRoomService ...@@ -532,21 +532,22 @@ class OfficeRoomService
* User HuJun * User HuJun
* Date 19-5-30 下午9:01 * Date 19-5-30 下午9:01
*/ */
public function delAgentHouse($type, $house_id, $id_edit = 1) { public function delAgentHouse($type, $house_id, $id_edit = 1)
{
if (empty($type) || empty($house_id)) { if (empty($type) || empty($house_id)) {
return false; return false;
} }
$id = $this->m_office_room->getTotal(['id'=>$house_id,'is_exclusive_type'=>1]); $id = $this->m_office_room->getTotal(['id' => $house_id, 'is_exclusive_type' => 1]);
if (empty($id)) { if (empty($id)) {
return false; return false;
} }
$where['house_id'] = $house_id; $where['house_id'] = $house_id;
$where['type'] = $type; $where['type'] = $type;
$is_ok = $this->agent_room->updateData(['is_del'=>1], $where); $is_ok = $this->agent_room->updateData(['is_del' => 1], $where);
if ($id_edit && $type == 3) { if ($id_edit && $type == 3) {
$this->m_office_room->editData(['is_exclusive_type'=>0], $house_id); $this->m_office_room->editData(['is_exclusive_type' => 0], $house_id);
} }
return $is_ok; return $is_ok;
} }
...@@ -561,23 +562,24 @@ class OfficeRoomService ...@@ -561,23 +562,24 @@ class OfficeRoomService
* @throws \think\Exception * @throws \think\Exception
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function landlordPhoneEditV2(array $data, $house_id) { public function landlordPhoneEditV2(array $data, $house_id)
{
$update_data = $insert_data = $new_phone = $del_phone = $edit_phone = []; $update_data = $insert_data = $new_phone = $del_phone = $edit_phone = [];
$key = 0; $key = 0;
$old_landlord = $this->landlord_phone->getColumn('id,phone', ['house_id'=>$house_id]); $old_landlord = $this->landlord_phone->getColumn('id,phone', ['house_id' => $house_id]);
if (empty($old_landlord)) { if (empty($old_landlord)) {
//新增 //新增
foreach ($data as $k=>$v) { foreach ($data as $k => $v) {
$insert_data[$k]['name'] = $v['name']; $insert_data[$k]['name'] = $v['name'];
$insert_data[$k]['phone'] = $v['phone']; $insert_data[$k]['phone'] = $v['phone'];
$insert_data[$k]['house_id'] = $house_id; $insert_data[$k]['house_id'] = $house_id;
$edit_phone[] = '新增房东手机号:'. substr_replace($v['phone'], '****', 3, 4); $edit_phone[] = '新增房东手机号:' . substr_replace($v['phone'], '****', 3, 4);
} }
} else { } else {
//新增与编辑 //新增与编辑
foreach ($data as $k=>$v) { foreach ($data as $k => $v) {
if ($v['id']) { if ($v['id']) {
$phone = $old_landlord[$v['id']]; $phone = $old_landlord[$v['id']];
...@@ -586,7 +588,7 @@ class OfficeRoomService ...@@ -586,7 +588,7 @@ class OfficeRoomService
$update_data[$key]['name'] = $v['name']; $update_data[$key]['name'] = $v['name'];
if ($phone != $v['phone']) { if ($phone != $v['phone']) {
$update_data[$k]['phone'] = $v['phone']; $update_data[$k]['phone'] = $v['phone'];
$edit_phone[] = '房东手机号由【'.substr_replace($phone, '****', 3, 4) . '】修改为【' . substr_replace($v['phone'], '****', 3, 4).'】'; $edit_phone[] = '房东手机号由【' . substr_replace($phone, '****', 3, 4) . '】修改为【' . substr_replace($v['phone'], '****', 3, 4) . '】';
$new_phone[] = $phone; $new_phone[] = $phone;
} }
} }
...@@ -602,12 +604,12 @@ class OfficeRoomService ...@@ -602,12 +604,12 @@ class OfficeRoomService
$key++; $key++;
} }
foreach ($old_landlord as $k2=>$v2) { foreach ($old_landlord as $k2 => $v2) {
if (!in_array($v2, $new_phone)) { if (!in_array($v2, $new_phone)) {
$update_data[$key]['id'] = $k2; $update_data[$key]['id'] = $k2;
$update_data[$key]['is_del'] = 1; $update_data[$key]['is_del'] = 1;
$key++; $key++;
$edit_phone[] = '删除房东手机号:'.substr_replace($v2, '****', 3, 4) ; $edit_phone[] = '删除房东手机号:' . substr_replace($v2, '****', 3, 4);
} }
} }
} }
...@@ -628,7 +630,8 @@ class OfficeRoomService ...@@ -628,7 +630,8 @@ class OfficeRoomService
* @return array * @return array
* http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=867 * http://showdoc.tonglianjituan.com/index.php?s=/1&page_id=867
*/ */
public function getOfficeRoomInfo($id,$agent_id){ public function getOfficeRoomInfo($id, $agent_id)
{
$field = 'a.id,a.building_id,b.title,b.province,b.city,b.disc,b.floor_total,a.price_total,a.price,a.station_start,b.type,a.station_end,a.area,a.floor,a.floor_tag, $field = 'a.id,a.building_id,b.title,b.province,b.city,b.disc,b.floor_total,a.price_total,a.price,a.station_start,b.type,a.station_end,a.area,a.floor,a.floor_tag,
a.is_register,a.age_limit_start,a.age_limit_end,a.rent_free,a.management_fee,a.slotting_fee,a.carport,a.enter_date, a.is_register,a.age_limit_start,a.age_limit_end,a.rent_free,a.management_fee,a.slotting_fee,a.carport,a.enter_date,
...@@ -636,9 +639,9 @@ class OfficeRoomService ...@@ -636,9 +639,9 @@ class OfficeRoomService
a.fee_rule,a.update_time,b.address,a.is_exclusive_type,a.agent_start_time,a.agent_end_time,c.name as business_name, a.fee_rule,a.update_time,b.address,a.is_exclusive_type,a.agent_start_time,a.agent_end_time,c.name as business_name,
a.shop_sign,b.longitude,b.latitude,b.intro,a.is_rent,a.room_number,a.is_show,a.mansion'; a.shop_sign,b.longitude,b.latitude,b.intro,a.is_rent,a.room_number,a.is_show,a.mansion';
$result = $this->m_office_room->getOfficeRoomInfo($field,['a.id'=>$id]); $result = $this->m_office_room->getOfficeRoomInfo($field, ['a.id' => $id]);
if (!$result) { if (!$result) {
return ['status'=>101,'msg'=>'此房源不存在','data'=>'']; return ['status' => 101, 'msg' => '此房源不存在', 'data' => ''];
} }
$result['price'] = $result['price'] * 0.01; $result['price'] = $result['price'] * 0.01;
...@@ -647,13 +650,13 @@ class OfficeRoomService ...@@ -647,13 +650,13 @@ class OfficeRoomService
$result['management_fee'] = $result['management_fee'] * 0.01; $result['management_fee'] = $result['management_fee'] * 0.01;
//轮播图 //轮播图
$result['carousel_image'] = $this->getCarouselImage($result['id'],2); $result['carousel_image'] = $this->getCarouselImage($result['id'], 2);
//上传人 //上传人
$result['upload_info'] = $this->getUploadInfo($result['operation_id']); $result['upload_info'] = $this->getUploadInfo($result['operation_id']);
//独家方 //独家方
$result['exclusive_info'] = $this->getExclusiveInfo($result['id'],3); $result['exclusive_info'] = $this->getExclusiveInfo($result['id'], 3);
//盘方 //盘方
$result['room_relegation_info'] = $this->getExclusiveInfo($result['id'],2); $result['room_relegation_info'] = $this->getExclusiveInfo($result['id'], 2);
//房东 //房东
$result['landlord_info'] = $this->getLandlordInfo($result['id']); $result['landlord_info'] = $this->getLandlordInfo($result['id']);
//房源数 //房源数
...@@ -665,31 +668,32 @@ class OfficeRoomService ...@@ -665,31 +668,32 @@ class OfficeRoomService
//楼盘图 //楼盘图
$result['building_image'] = $this->getBuildingImage($result['building_id']); $result['building_image'] = $this->getBuildingImage($result['building_id']);
//是否被收藏 //是否被收藏
$result['is_collect'] = $this->isCollect($result['id'],$agent_id); $result['is_collect'] = $this->isCollect($result['id'], $agent_id);
//是否可编辑 //是否可编辑
$result['is_can_edit'] = $this->isCanEdit($result['id'],$agent_id); $result['is_can_edit'] = $this->isCanEdit($result['id'], $agent_id);
return ['status'=>200,'msg'=>'success','data'=>$result]; return ['status' => 200, 'msg' => 'success', 'data' => $result];
} }
//是否可编辑 //是否可编辑
public function isCanEdit($id,$agent_id){ public function isCanEdit($id, $agent_id)
{
$params['house_id'] = $id; $params['house_id'] = $id;
$params['agent_id'] = $agent_id; $params['agent_id'] = $agent_id;
$params['type'] = 2; $params['type'] = 2;
$house = $this->agent_room->isCanEdit('agent_id', $params); $house = $this->agent_room->isCanEdit('agent_id', $params);
if($house){ if ($house) {
return 0; return 0;
}else{ } else {
return 1; return 1;
} }
} }
//是否被收藏 //是否被收藏
private function isCollect($house_id,$agent_id){ private function isCollect($house_id, $agent_id)
{
$m_collect_room = new OfficeACollectHouse(); $m_collect_room = new OfficeACollectHouse();
//是否被收藏 //是否被收藏
$is_collect = 2; $is_collect = 2;
...@@ -707,7 +711,8 @@ class OfficeRoomService ...@@ -707,7 +711,8 @@ class OfficeRoomService
} }
//参考均价 //参考均价
public function referenceAveragePrice($id){ public function referenceAveragePrice($id)
{
$field = 'MIN(price) as num'; $field = 'MIN(price) as num';
$where['building_id'] = $id; $where['building_id'] = $id;
$where['status'] = 1; $where['status'] = 1;
...@@ -717,50 +722,55 @@ class OfficeRoomService ...@@ -717,50 +722,55 @@ class OfficeRoomService
} }
//字段最低值 //字段最低值
public function MinField($id, $field = ''){ public function MinField($id, $field = '')
{
$where['building_id'] = $id; $where['building_id'] = $id;
$field_string = "min({$field}) as min"; $field_string = "min({$field}) as min";
return $this->m_office_room->getFieldOneValue($field_string, $where); return $this->m_office_room->getFieldOneValue($field_string, $where);
} }
//楼盘图 //楼盘图
public function getBuildingImage($id){ public function getBuildingImage($id)
{
$where['img_status'] = 0; $where['img_status'] = 0;
$where['house_id'] = $id; $where['house_id'] = $id;
$where['img_type'] = 0; $where['img_type'] = 0;
$house_img_data = $this->m_office_img->getListAll('id,img_name', $where); $house_img_data = $this->m_office_img->getListAll('id,img_name', $where);
if($house_img_data){ if ($house_img_data) {
foreach ($house_img_data as $k=>$v) { foreach ($house_img_data as $k => $v) {
$house_img_data[$k]['image_path'] = $this->internet_path.$v['img_name']; $house_img_data[$k]['image_path'] = $this->internet_path . $v['img_name'];
} }
} }
return $house_img_data; return $house_img_data;
} }
//轮播图 //轮播图
public function getCarouselImage($id,$img_type=2){ public function getCarouselImage($id, $img_type = 2)
{
$where['img_type'] = $img_type; $where['img_type'] = $img_type;
$where['img_status'] = 0; $where['img_status'] = 0;
$where['house_id'] = $id; $where['house_id'] = $id;
$house_img_data = $this->m_office_img->getListAll('id,img_name', $where); $house_img_data = $this->m_office_img->getListAll('id,img_name', $where);
if($house_img_data){ if ($house_img_data) {
foreach ($house_img_data as $k=>$v) { foreach ($house_img_data as $k => $v) {
$house_img_data[$k]['image_path'] = $this->internet_path.$v['img_name']; $house_img_data[$k]['image_path'] = $this->internet_path . $v['img_name'];
} }
} }
return $house_img_data?$house_img_data:[]; return $house_img_data ? $house_img_data : [];
} }
//交通信息 //交通信息
public function getTrafficInfo($id){ public function getTrafficInfo($id)
{
$field = 'b.line_name_simple,b.name,a.distance'; $field = 'b.line_name_simple,b.name,a.distance';
$res = $this->m_building_stations->getTrafficInfo($field, ['a.building_id'=>$id]); $res = $this->m_building_stations->getTrafficInfo($field, ['a.building_id' => $id]);
$res_str = "{$res['line_name_simple']}{$res['name']}地铁站出站{$res['distance']}米"; $res_str = "{$res['line_name_simple']}{$res['name']}地铁站出站{$res['distance']}米";
return $res_str; return $res_str;
} }
//房源数 //房源数
public function getRoomNum($building_id){ public function getRoomNum($building_id)
{
$params['building_id'] = $building_id; $params['building_id'] = $building_id;
// $params['id'] = array('neq',$id); // $params['id'] = array('neq',$id);
$params['is_rent'] = 0; $params['is_rent'] = 0;
...@@ -770,24 +780,26 @@ class OfficeRoomService ...@@ -770,24 +780,26 @@ class OfficeRoomService
} }
//获取上传人信息 //获取上传人信息
public function getUploadInfo($agent_id){ public function getUploadInfo($agent_id)
{
$agent = []; $agent = [];
$res = $this->redis_service->getRedisCache(2, $agent_id); $res = $this->redis_service->getRedisCache(2, $agent_id);
if($res){ if ($res) {
$agent['name'] = $res['name']; $agent['name'] = $res['name'];
$agent['phone'] = $res['phone']; $agent['phone'] = $res['phone'];
} }
return $agent?$agent:null; return $agent ? $agent : null;
} }
//获取独家方 //获取独家方
public function getExclusiveInfo($house_id,$type=3){ public function getExclusiveInfo($house_id, $type = 3)
{
$exclusive_info = []; $exclusive_info = [];
$params['house_id'] = $house_id; $params['house_id'] = $house_id;
$params['type'] = $type; $params['type'] = $type;
$params['is_del'] = 0; $params['is_del'] = 0;
$res = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', $params); $res = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', $params);
if($res){ if ($res) {
$exclusive_info['name'] = $res[0]['name']; $exclusive_info['name'] = $res[0]['name'];
$exclusive_info['phone'] = $res[0]['phone']; $exclusive_info['phone'] = $res[0]['phone'];
} }
...@@ -796,12 +808,13 @@ class OfficeRoomService ...@@ -796,12 +808,13 @@ class OfficeRoomService
//房东 //房东
public function getLandlordInfo($house_id){ public function getLandlordInfo($house_id)
{
$m_landlord = new OfficeGLandlordPhone(); $m_landlord = new OfficeGLandlordPhone();
$res = $m_landlord->getAllList('id,name,phone', ['house_id'=>$house_id]);; $res = $m_landlord->getAllList('id,name,phone', ['house_id' => $house_id]);;
if($res){ if ($res) {
foreach ($res as $k=>$v) { foreach ($res as $k => $v) {
$res[$k]['phone'] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $v["phone"]); $res[$k]['phone'] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $v["phone"]);
} }
} }
...@@ -817,7 +830,8 @@ class OfficeRoomService ...@@ -817,7 +830,8 @@ class OfficeRoomService
* User HuJun * User HuJun
* Date 19-6-3 上午10:31 * Date 19-6-3 上午10:31
*/ */
public function getRoomList($params, $is_total = 0) { public function getRoomList($params, $is_total = 0)
{
$page_no = empty($params['pageNo']) ? 1 : $params['pageNo']; $page_no = empty($params['pageNo']) ? 1 : $params['pageNo'];
$page_size = empty($params['pageSize']) ? 15 : $params['pageSize']; $page_size = empty($params['pageSize']) ? 15 : $params['pageSize'];
$result['status'] = 'fail'; $result['status'] = 'fail';
...@@ -862,16 +876,16 @@ class OfficeRoomService ...@@ -862,16 +876,16 @@ class OfficeRoomService
$result['msg'] = '房东手机不足11位'; $result['msg'] = '房东手机不足11位';
return $result; return $result;
} }
$landlord_where['phone'] = ['LIKE','%'.$params['landlord_phone'].'%']; $landlord_where['phone'] = ['LIKE', '%' . $params['landlord_phone'] . '%'];
$landlord_where['is_del'] = 0; $landlord_where['is_del'] = 0;
$landlord_arr = $this->landlord_phone->getList(1,1000, '', 'house_id', $landlord_where); $landlord_arr = $this->landlord_phone->getList(1, 1000, '', 'house_id', $landlord_where);
if (empty($landlord_arr)) { if (empty($landlord_arr)) {
$result['status'] = 'successful'; $result['status'] = 'successful';
return $result; return $result;
} else { } else {
$landlord_house_id = []; $landlord_house_id = [];
foreach ($landlord_arr as $k=>$v) { foreach ($landlord_arr as $k => $v) {
$landlord_house_id[] = $v['house_id']; $landlord_house_id[] = $v['house_id'];
} }
$landlord_str = implode(',', $landlord_house_id); $landlord_str = implode(',', $landlord_house_id);
...@@ -884,12 +898,12 @@ class OfficeRoomService ...@@ -884,12 +898,12 @@ class OfficeRoomService
$room_data = $this->m_office_room->getRoomAgent($page_no, $page_size, $field, $where); $room_data = $this->m_office_room->getRoomAgent($page_no, $page_size, $field, $where);
$m_business = new GBusinessDistrict(); $m_business = new GBusinessDistrict();
foreach ($room_data as $k=>$v) { foreach ($room_data as $k => $v) {
$room_data[$k]['business_name'] = $m_business->getValue(['id'=>$v['business_district_id']], 'name'); $room_data[$k]['business_name'] = $m_business->getValue(['id' => $v['business_district_id']], 'name');
$room_data[$k]['price_total'] = $room_data[$k]['price_total']/100; $room_data[$k]['price_total'] = $room_data[$k]['price_total'] / 100;
$room_data[$k]['price'] = $room_data[$k]['price']/100; $room_data[$k]['price'] = $room_data[$k]['price'] / 100;
$dish_name = $this->agent_room->getAgentsByRoomColumn('b.name', ['a.house_id'=>$v['id'],'a.type'=>2]); $dish_name = $this->agent_room->getAgentsByRoomColumn('b.name', ['a.house_id' => $v['id'], 'a.type' => 2]);
if (empty($dish_name)) { if (empty($dish_name)) {
$room_data[$k]['dish_name'] = ''; $room_data[$k]['dish_name'] = '';
} else { } else {
...@@ -902,7 +916,7 @@ class OfficeRoomService ...@@ -902,7 +916,7 @@ class OfficeRoomService
} }
$result['data'] = $room_data; $result['data'] = $room_data;
$result['status'] = 'successful'; $result['status'] = 'successful';
}catch (\Exception $e) { } catch (\Exception $e) {
$result['msg'] = $e->getMessage(); $result['msg'] = $e->getMessage();
} }
...@@ -917,7 +931,8 @@ class OfficeRoomService ...@@ -917,7 +931,8 @@ class OfficeRoomService
* User HuJun * User HuJun
* Date 19-6-2 下午4:21 * Date 19-6-2 下午4:21
*/ */
private function buildParams($params) { private function buildParams($params)
{
$where = []; $where = [];
/*所在区*/ /*所在区*/
if (isset($params['disc'])) { if (isset($params['disc'])) {
...@@ -963,32 +978,32 @@ class OfficeRoomService ...@@ -963,32 +978,32 @@ class OfficeRoomService
/*租金总价*/ /*租金总价*/
if (isset($params['price_total_start'])) { if (isset($params['price_total_start'])) {
$where['a.price_total'] = $params['price_total_start']*100; $where['a.price_total'] = $params['price_total_start'] * 100;
} }
/*租金总价*/ /*租金总价*/
if (isset($params['price_total_end'])) { if (isset($params['price_total_end'])) {
$where['a.price_total'] = $params['price_total_end']*100; $where['a.price_total'] = $params['price_total_end'] * 100;
} }
/*租金总价*/ /*租金总价*/
if (isset($params['price_total_end']) && isset($params['price_total_start'])) { if (isset($params['price_total_end']) && isset($params['price_total_start'])) {
$where['a.price_total'] = ['between', [$params['price_total_start']*100, $params['price_total_end']*100]]; $where['a.price_total'] = ['between', [$params['price_total_start'] * 100, $params['price_total_end'] * 100]];
} }
/*租金单价*/ /*租金单价*/
if (isset($params['price_start'])) { if (isset($params['price_start'])) {
$where['a.price'] = $params['price_start']*100; $where['a.price'] = $params['price_start'] * 100;
} }
/*租金单价*/ /*租金单价*/
if (isset($params['price_end'])) { if (isset($params['price_end'])) {
$where['a.price'] = $params['price_end']*100; $where['a.price'] = $params['price_end'] * 100;
} }
/*租金单价*/ /*租金单价*/
if (isset($params['price_end']) && isset($params['price_start'])) { if (isset($params['price_end']) && isset($params['price_start'])) {
$where['a.price'] = ['between', [$params['price_start']*100, $params['price_end']*100]]; $where['a.price'] = ['between', [$params['price_start'] * 100, $params['price_end'] * 100]];
} }
/*可容纳工位*/ /*可容纳工位*/
...@@ -1003,8 +1018,8 @@ class OfficeRoomService ...@@ -1003,8 +1018,8 @@ class OfficeRoomService
/*可容纳工位*/ /*可容纳工位*/
if (isset($params['station_end']) && isset($params['station_start'])) { if (isset($params['station_end']) && isset($params['station_start'])) {
$where['a.station_start'] = ['between', [$params['station_start'],$params['station_end']]]; $where['a.station_start'] = ['between', [$params['station_start'], $params['station_end']]];
$where['a.station_end'] = ['between', [$params['station_start'],$params['station_end']]]; $where['a.station_end'] = ['between', [$params['station_start'], $params['station_end']]];
} }
//编号 //编号
...@@ -1014,7 +1029,7 @@ class OfficeRoomService ...@@ -1014,7 +1029,7 @@ class OfficeRoomService
//地址 //地址
if (isset($params['address'])) { if (isset($params['address'])) {
$where['b.address'] = ['like', '%'.$params['address'].'%']; $where['b.address'] = ['like', '%' . $params['address'] . '%'];
} }
//是否独家0否1是 //是否独家0否1是
...@@ -1139,31 +1154,32 @@ class OfficeRoomService ...@@ -1139,31 +1154,32 @@ class OfficeRoomService
* @param $agentId * @param $agentId
* @return array * @return array
*/ */
public function getMyBuildingRoom($status,$pageNo, $pageSize, $agentId){ public function getMyBuildingRoom($status, $pageNo, $pageSize, $agentId)
{
$field = "a.id,a.building_id,a.area,a.price_total,a.price,a.station_start,a.station_end, $field = "a.id,a.building_id,a.area,a.price_total,a.price,a.station_start,a.station_end,
a.decoration,b.disc,b.title,d.name as business_name,a.status"; a.decoration,b.disc,b.title,d.name as business_name,a.status";
$params["a.status"] = $status; $params["a.status"] = $status;
$params["c.agent_id"] = $agentId; $params["c.agent_id"] = $agentId;
$params["c.type"] = 2; $params["c.type"] = 2;
$params["c.is_del"] = 0; $params["c.is_del"] = 0;
$res = $this->m_office_room->getMyBuildingRoom($field, $params,$pageSize,$pageNo); $res = $this->m_office_room->getMyBuildingRoom($field, $params, $pageSize, $pageNo);
if (!$res) { if (!$res) {
return ['status'=>200,'msg'=>'此房源不存在','data'=>[]]; return ['status' => 200, 'msg' => '此房源不存在', 'data' => []];
} }
foreach ($res as $k=>$v) { foreach ($res as $k => $v) {
$tmp['id'] = $v['id']; $tmp['id'] = $v['id'];
$tmp['status'] = $v['status']; $tmp['status'] = $v['status'];
$tmp['price'] = $this->MinField($v['building_id'], 'price'); $tmp['price'] = $this->MinField($v['building_id'], 'price');
$tmp['price'] = empty($tmp['price']) ? 0:$tmp['price']/100; $tmp['price'] = empty($tmp['price']) ? 0 : $tmp['price'] / 100;
$tmp['price_total'] = $this->MinField($v['building_id'], 'price_total'); $tmp['price_total'] = $this->MinField($v['building_id'], 'price_total');
$tmp['price_total'] = empty($tmp['price_total']) ? 0:$tmp['price_total']/100; $tmp['price_total'] = empty($tmp['price_total']) ? 0 : $tmp['price_total'] / 100;
$tmp['shop_sign'] = $this->getBuildingSign($v['id']); $tmp['shop_sign'] = $this->getBuildingSign($v['id']);
$area = $this->MinField($v['building_id'], 'area'); $area = $this->MinField($v['building_id'], 'area');
$tmp['title'] = $v['disc'].' '.$v['business_name']. ' '.$v['title']. ' '.$area.'㎡'; $tmp['title'] = $v['disc'] . ' ' . $v['business_name'] . ' ' . $v['title'] . ' ' . $area . '㎡';
$result_data[] = $tmp; $result_data[] = $tmp;
} }
return ['status'=>200,'msg'=>'success','data'=>$result_data]; return ['status' => 200, 'msg' => 'success', 'data' => $result_data];
} }
/** /**
...@@ -1188,7 +1204,7 @@ class OfficeRoomService ...@@ -1188,7 +1204,7 @@ class OfficeRoomService
} }
if (isset($params['title'])) { if (isset($params['title'])) {
$where['b.title'] = ['LIKE', '%'.$params['title'].'%']; //楼盘名 $where['b.title'] = ['LIKE', '%' . $params['title'] . '%']; //楼盘名
} }
if (isset($params['id'])) { if (isset($params['id'])) {
...@@ -1216,15 +1232,15 @@ class OfficeRoomService ...@@ -1216,15 +1232,15 @@ class OfficeRoomService
} }
if (isset($params['price_start'])) { if (isset($params['price_start'])) {
$where['a.price'] = $params['price_start']*100;//租金单价 $where['a.price'] = $params['price_start'] * 100;//租金单价
} }
if (isset($params['price_end'])) { if (isset($params['price_end'])) {
$where['a.price'] = $params['price_end']*100;//租金单价 $where['a.price'] = $params['price_end'] * 100;//租金单价
} }
if (isset($params['price_start']) && isset($params['price_end'])) { if (isset($params['price_start']) && isset($params['price_end'])) {
$where['a.price'] = ['between', [$params['price_start']*100, $params['price_end']*100]]; //租金单价 $where['a.price'] = ['between', [$params['price_start'] * 100, $params['price_end'] * 100]]; //租金单价
} }
if (isset($params['is_exclusive_type'])) { if (isset($params['is_exclusive_type'])) {
...@@ -1245,13 +1261,19 @@ class OfficeRoomService ...@@ -1245,13 +1261,19 @@ class OfficeRoomService
} }
if (isset($params['shop_sign'])) { if (isset($params['shop_sign'])) {
$where['a.shop_sign'] = ['like', '%'.$params['shop_sign'].'%']; //商铺标签 $where['a.shop_sign'] = ['like', '%' . $params['shop_sign'] . '%']; //商铺标签
} }
if (isset($params['is_carefully_chosen'])) { if (isset($params['is_carefully_chosen'])) {
$where['a.is_carefully_chosen'] = $params['is_carefully_chosen']; //精选商铺--0否1是 $where['a.is_carefully_chosen'] = $params['is_carefully_chosen']; //精选商铺--0否1是
$order = 'a.home_page_sort desc'; $order = 'a.home_page_sort desc';
} }
if(isset($params['stations_ids'])){
$ids = $this->getBuildingByStations($params['stations_ids']);
if($ids){
$where['b.id'] = array("in",$ids); //地铁
}
}
$field = 'a.id,b.disc,b.title,b.address,c.name as business_name,a.building_id,a.price,a.price_total,b.status,a.is_rent'; $field = 'a.id,b.disc,b.title,b.address,c.name as business_name,a.building_id,a.price,a.price_total,b.status,a.is_rent';
try { try {
...@@ -1263,15 +1285,15 @@ class OfficeRoomService ...@@ -1263,15 +1285,15 @@ class OfficeRoomService
} }
$result_data = []; $result_data = [];
foreach ($data as $k=>$v) { foreach ($data as $k => $v) {
$tmp['id'] = $v['id']; $tmp['id'] = $v['id'];
$tmp['price'] = empty($v['price']) ? 0:$v['price']/100; $tmp['price'] = empty($v['price']) ? 0 : $v['price'] / 100;
$tmp['price_total'] = empty($v['price_total']) ? 0:$v['price_total']/100; $tmp['price_total'] = empty($v['price_total']) ? 0 : $v['price_total'] / 100;
$tmp['shop_sign'] = $this->getBuildingSign($v['building_id']); $tmp['shop_sign'] = $this->getBuildingSign($v['building_id']);
$tmp['status'] = $v['status']; $tmp['status'] = $v['status'];
$tmp['is_rent'] = $v['is_rent']; $tmp['is_rent'] = $v['is_rent'];
$area = $this->MinField($v['building_id'], 'area'); $area = $this->MinField($v['building_id'], 'area');
$tmp['title'] = $v['disc'].' '.$v['business_name']. ' '.$v['title']. ' '.$area.'㎡'; $tmp['title'] = $v['disc'] . ' ' . $v['business_name'] . ' ' . $v['title'] . ' ' . $area . '㎡';
$result_data[] = $tmp; $result_data[] = $tmp;
} }
$result['status'] = 'successful'; $result['status'] = 'successful';
...@@ -1279,22 +1301,46 @@ class OfficeRoomService ...@@ -1279,22 +1301,46 @@ class OfficeRoomService
return $result; return $result;
} }
/**
* 根据地铁id获取字典id
* @param $stations_str
* @return string
*/
private function getBuildingByStations($stations_str)
{
$buildingStationsModel = new OfficeGBuildingStations();
$field = "building_id,stations_id";
$params["stations_id"] = array("in", $stations_str);
$buildingArr = $buildingStationsModel->getBuilderByStations($field, $params);
$ids = "";
if (count($buildingArr) > 0) {
foreach ($buildingArr as $item) {
$ids .= $item["id"] . ",";
}
$ids = rtrim($ids, ",");
}
return $ids;
}
/** /**
* 标签处理 * 标签处理
* *
* @param $id * @param $id
* @return string * @return string
*/ */
private function getBuildingSign($id){ private function getBuildingSign($id)
{
$field = 'shop_sign'; $field = 'shop_sign';
$where['building_id'] = $id; $where['building_id'] = $id;
$where['status'] = 1; $where['status'] = 1;
$res = $this->m_office_room->getRoom($field, $where); $res = $this->m_office_room->getRoom($field, $where);
if(!$res) if (!$res)
return ''; return '';
$shop_sign_old = ''; $shop_sign_old = '';
foreach ($res as $k=>$v) { foreach ($res as $k => $v) {
$shop_sign_old.=','.$v['shop_sign']; $shop_sign_old .= ',' . $v['shop_sign'];
} }
$ex_shop_sign_old = explode(',', trim($shop_sign_old, ",")); $ex_shop_sign_old = explode(',', trim($shop_sign_old, ","));
$ex_shop_sign_old = array_unique($ex_shop_sign_old);//数组去重 $ex_shop_sign_old = array_unique($ex_shop_sign_old);//数组去重
...@@ -1308,7 +1354,8 @@ class OfficeRoomService ...@@ -1308,7 +1354,8 @@ class OfficeRoomService
* @param $data * @param $data
* @return mixed * @return mixed
*/ */
public function delRoom($data) { public function delRoom($data)
{
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = ''; $result['msg'] = '';
$result['data'] = []; $result['data'] = [];
...@@ -1319,13 +1366,13 @@ class OfficeRoomService ...@@ -1319,13 +1366,13 @@ class OfficeRoomService
return $result; return $result;
} }
$house_id = $this->m_office_room->getFieldOneValue('id', ['id'=>$data['id'],'status'=>['<>', 3]]); $house_id = $this->m_office_room->getFieldOneValue('id', ['id' => $data['id'], 'status' => ['<>', 3]]);
if (empty($house_id)) { if (empty($house_id)) {
$result['msg'] = '没有该商铺'; $result['msg'] = '没有该商铺';
return $result; return $result;
} }
$is_ok = $this->m_office_room->editData(['status'=>3], $data['id']); $is_ok = $this->m_office_room->editData(['status' => 3], $data['id']);
if ($is_ok) { if ($is_ok) {
//删除商铺对应的收藏商铺也要删除(改状态值)delCollectHouse //删除商铺对应的收藏商铺也要删除(改状态值)delCollectHouse
$collect_house = new OfficeACollectHouse(); $collect_house = new OfficeACollectHouse();
...@@ -1353,7 +1400,7 @@ class OfficeRoomService ...@@ -1353,7 +1400,7 @@ class OfficeRoomService
$result['msg'] = ''; $result['msg'] = '';
$result['data'] = []; $result['data'] = [];
$data = $this->m_office_room->getFindData('id,is_exclusive_type,agent_start_time,agent_end_time', ['id'=>$room_id]); $data = $this->m_office_room->getFindData('id,is_exclusive_type,agent_start_time,agent_end_time', ['id' => $room_id]);
if (empty($data['id'])) { if (empty($data['id'])) {
$result['msg'] = '没有该房源'; $result['msg'] = '没有该房源';
...@@ -1365,7 +1412,7 @@ class OfficeRoomService ...@@ -1365,7 +1412,7 @@ class OfficeRoomService
$result_data['agent_start_time'] = $data['agent_start_time']; $result_data['agent_start_time'] = $data['agent_start_time'];
$result_data['agent_end_time'] = $data['agent_end_time']; $result_data['agent_end_time'] = $data['agent_end_time'];
$agent_data = $this->agent_room->getAgentsByRoomId('b.id,b.name,b.phone', ['a.house_id'=>$room_id, 'a.type'=>3]); $agent_data = $this->agent_room->getAgentsByRoomId('b.id,b.name,b.phone', ['a.house_id' => $room_id, 'a.type' => 3]);
if ($agent_data[0]) { if ($agent_data[0]) {
$result_data['name'] = $agent_data[0]['name'] . '-' . $agent_data[0]['phone']; $result_data['name'] = $agent_data[0]['name'] . '-' . $agent_data[0]['phone'];
...@@ -1373,7 +1420,7 @@ class OfficeRoomService ...@@ -1373,7 +1420,7 @@ class OfficeRoomService
$result_data['name'] = ''; $result_data['name'] = '';
} }
$room_img = $this->m_office_img->getListAll('img_name',['house_id'=>$room_id,'img_type'=>4]); $room_img = $this->m_office_img->getListAll('img_name', ['house_id' => $room_id, 'img_type' => 4]);
if ($room_img) { if ($room_img) {
$result_data['exclusive_img'] = $room_img; $result_data['exclusive_img'] = $room_img;
} else { } else {
...@@ -1384,8 +1431,8 @@ class OfficeRoomService ...@@ -1384,8 +1431,8 @@ class OfficeRoomService
$house_file_where['status'] = 0; $house_file_where['status'] = 0;
$exclusive_file = $this->m_house_file->getHouseFileAll('id,file_name', $house_file_where); $exclusive_file = $this->m_house_file->getHouseFileAll('id,file_name', $house_file_where);
if ($exclusive_file) { if ($exclusive_file) {
foreach ($exclusive_file as $k=>$v) { foreach ($exclusive_file as $k => $v) {
$exclusive_file[$k]['file_name'] = '/static/exclusive_file/'.$v['file_name']; $exclusive_file[$k]['file_name'] = '/static/exclusive_file/' . $v['file_name'];
} }
$result_data['exclusive_file'] = $exclusive_file; $result_data['exclusive_file'] = $exclusive_file;
} else { } else {
...@@ -1403,13 +1450,14 @@ class OfficeRoomService ...@@ -1403,13 +1450,14 @@ class OfficeRoomService
* @param $house_id * @param $house_id
* @return array|int|string * @return array|int|string
*/ */
public function exclusiveFile($data, $house_id) { public function exclusiveFile($data, $house_id)
{
$result = []; $result = [];
//新增附件 //新增附件
if (!empty($data['exclusive_file'])) { if (!empty($data['exclusive_file'])) {
$exclusive_file_arr = explode(',', $data['exclusive_file']); $exclusive_file_arr = explode(',', $data['exclusive_file']);
$save_data = []; $save_data = [];
foreach ($exclusive_file_arr as $k=>$v) { foreach ($exclusive_file_arr as $k => $v) {
$save_data[$k]['file_name'] = $v; $save_data[$k]['file_name'] = $v;
$save_data[$k]['house_id'] = $house_id; $save_data[$k]['house_id'] = $house_id;
$save_data[$k]['type'] = 0; $save_data[$k]['type'] = 0;
...@@ -1422,8 +1470,8 @@ class OfficeRoomService ...@@ -1422,8 +1470,8 @@ class OfficeRoomService
//伪删除附件 //伪删除附件
if (!empty($data['del_file_id'])) { if (!empty($data['del_file_id'])) {
$file_id_arr = explode(',', $data['del_file_id']); $file_id_arr = explode(',', $data['del_file_id']);
foreach ($file_id_arr as $k=>$v) { foreach ($file_id_arr as $k => $v) {
$result[] =$this->m_house_file->where('id', $v)->update(['status'=>1]); $result[] = $this->m_house_file->where('id', $v)->update(['status' => 1]);
} }
} }
...@@ -1436,7 +1484,8 @@ class OfficeRoomService ...@@ -1436,7 +1484,8 @@ class OfficeRoomService
* @param $data * @param $data
* @return mixed * @return mixed
*/ */
public function isShow($data) { public function isShow($data)
{
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = ''; $result['msg'] = '';
$result['data'] = []; $result['data'] = [];
...@@ -1446,13 +1495,13 @@ class OfficeRoomService ...@@ -1446,13 +1495,13 @@ class OfficeRoomService
return $result; return $result;
} }
try { try {
$house_data = $this->m_office_room->getFindData('id,is_show', ['id'=>$data['id']]); $house_data = $this->m_office_room->getFindData('id,is_show', ['id' => $data['id']]);
if (empty($house_data['id'])) { if (empty($house_data['id'])) {
$result['msg'] = '没有该房源'; $result['msg'] = '没有该房源';
return $result; return $result;
} else { } else {
if ($house_data['is_show'] != $data['is_show']) { if ($house_data['is_show'] != $data['is_show']) {
$this->m_office_room->editData(['is_show'=> $data['is_show']], $data['id']); $this->m_office_room->editData(['is_show' => $data['is_show']], $data['id']);
$result['status'] = 'successful'; $result['status'] = 'successful';
} }
} }
...@@ -1471,7 +1520,8 @@ class OfficeRoomService ...@@ -1471,7 +1520,8 @@ class OfficeRoomService
* @throws \think\Exception * @throws \think\Exception
* @throws \think\exception\PDOException * @throws \think\exception\PDOException
*/ */
public function downStatus(int $building_id, int $status) { public function downStatus(int $building_id, int $status)
{
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = ''; $result['msg'] = '';
$result['data'] = []; $result['data'] = [];
...@@ -1482,7 +1532,7 @@ class OfficeRoomService ...@@ -1482,7 +1532,7 @@ class OfficeRoomService
} }
$where['building_id'] = $building_id; $where['building_id'] = $building_id;
$where['status'] = ['<>', 3]; $where['status'] = ['<>', 3];
$num = $this->m_office_room->updateData(['status'=>$status], $where); $num = $this->m_office_room->updateData(['status' => $status], $where);
if ($num > 0) { if ($num > 0) {
$result['status'] = 'successful'; $result['status'] = 'successful';
$result['msg'] = '修改成功'; $result['msg'] = '修改成功';
...@@ -1498,7 +1548,8 @@ class OfficeRoomService ...@@ -1498,7 +1548,8 @@ class OfficeRoomService
* @param $params * @param $params
* @return mixed * @return mixed
*/ */
public function checkRepetition($params) { public function checkRepetition($params)
{
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = ''; $result['msg'] = '';
$result['data'] = []; $result['data'] = [];
...@@ -1520,15 +1571,15 @@ class OfficeRoomService ...@@ -1520,15 +1571,15 @@ class OfficeRoomService
if ($list) { if ($list) {
$data = []; $data = [];
foreach ($list as $k=>$v) { foreach ($list as $k => $v) {
$data[$k]['id'] = $v['id']; $data[$k]['id'] = $v['id'];
$data[$k]['address'] = $v['mansion'].'-'.$v['floor'].'-'.$v['room_number']; $data[$k]['address'] = $v['mansion'] . '-' . $v['floor'] . '-' . $v['room_number'];
} }
$result['data'] = $data; $result['data'] = $data;
} }
$result['status'] = 'successful'; $result['status'] = 'successful';
} catch (\Exception $e) { } catch (\Exception $e) {
$result['msg'] = "内部错误:".$e->getMessage(); $result['msg'] = "内部错误:" . $e->getMessage();
} }
return $result; return $result;
} }
......
...@@ -61,6 +61,14 @@ class OfficeGBuildingStations extends BaseModel ...@@ -61,6 +61,14 @@ class OfficeGBuildingStations extends BaseModel
->select(); ->select();
} }
public function getBuilderByStations($field, $where){
$where['a.is_del'] = 0;
return $this->db_
->field($field)
->where($where)
->select();
}
/** /**
* @param $data * @param $data
* @param $where * @param $where
......
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