Commit 0c28c244 authored by clone's avatar clone

1

parent 6cc8dfe3
......@@ -43,21 +43,21 @@ class OfficeRoomService
public function __construct()
{
$this->validate = new OfficeBuildingRoomValidate();
$this->m_office_room = new OfficeGRoom();
$this->m_office_img = new OfficeGImg();
$this->push = new PushMessageService();
$this->agent = new AAgents();
$this->agent_room = new OfficeGRoomToAgent();
$this->landlord_phone = new OfficeGLandlordPhone();
$this->validate = new OfficeBuildingRoomValidate();
$this->m_office_room = new OfficeGRoom();
$this->m_office_img = new OfficeGImg();
$this->push = new PushMessageService();
$this->agent = new AAgents();
$this->agent_room = new OfficeGRoomToAgent();
$this->landlord_phone = new OfficeGLandlordPhone();
$this->m_building_stations = new OfficeGBuildingStations();
$this->redis_service = new RedisCacheService();
$this->m_house_file = new OfficeGHouseFile();
$this->m_office = new OfficeGBuilding();
$this->redis_service = new RedisCacheService();
$this->m_house_file = new OfficeGHouseFile();
$this->m_office = new OfficeGBuilding();
if (CURRENT_URL == 'https://api.tonglianjituan.com/') {
$this->internet_path = IMAGES_URL.'/resource/lib/Attachments/images/';
}else {
$this->internet_path = IMAGES_URL . '/resource/lib/Attachments/images/';
} else {
$this->internet_path = 'http://pre2.tonglianjituan.com/resource/lib/Attachments/images/';
}
}
......@@ -74,8 +74,8 @@ class OfficeRoomService
public function edit(array $data, int $agent_id, $site_id, $scene = '')
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$result['msg'] = '';
$result['data'] = [];
if (empty($scene)) {
if (isset($data['id'])) {
......@@ -89,10 +89,10 @@ class OfficeRoomService
$result['msg'] = $this->validate->getError();
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;
if ($status != 1) {
$is_alert = 1;
$is_alert = 1;
$data['status'] = 2;
}
......@@ -110,10 +110,10 @@ class OfficeRoomService
$landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $id);
if (!empty($landlord_phone_old)) {
$remark .= implode(',', $landlord_phone_old).',';
$remark .= implode(',', $landlord_phone_old) . ',';
}
} catch (\Exception $e) {
$result['msg'] = '房东手机号处理失败'.$e->getMessage();
$result['msg'] = '房东手机号处理失败' . $e->getMessage();
return $result;
}
}
......@@ -125,7 +125,7 @@ class OfficeRoomService
$result_agent_data = $this->releaseRelationshipV2($data['agent_data'], $id, 1, $agent_id, $data['title'], $site_id);
if ($result_agent_data['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑案场权限人失败,' . $result_agent_data['msg'];
$result['msg'] = '新增或编辑案场权限人失败,' . $result_agent_data['msg'];
return $result;
}
}
......@@ -135,7 +135,7 @@ class OfficeRoomService
$result_agent_dish = $this->releaseRelationshipV2($data['agent_dish'], $id, 2, $agent_id, $data['title'], $site_id);
if ($result_agent_dish['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑盘方失败,' . $result_agent_dish['msg'];
$result['msg'] = '新增或编辑盘方失败,' . $result_agent_dish['msg'];
return $result;
}
}
......@@ -153,7 +153,7 @@ class OfficeRoomService
$result_exclusive_ids = $this->releaseRelationshipV2($data['exclusive_ids'], $id, 3, $agent_id, $data['title'], $site_id);
if ($result_exclusive_ids['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑独家方失败,' . $result_exclusive_ids['msg'];
$result['msg'] = '新增或编辑独家方失败,' . $result_exclusive_ids['msg'];
return $result;
}
}
......@@ -185,7 +185,7 @@ class OfficeRoomService
$image_result = $this->m_office_img->edit($data['cover'], $id, 1);
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑主图图片失败,' . $image_result['msg'];
$result['msg'] = '新增或编辑主图图片失败,' . $image_result['msg'];
return $result;
}
}
......@@ -194,7 +194,7 @@ class OfficeRoomService
$image_result = $this->m_office_img->edit($data['slide_show'], $id, 2);
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑轮播图片失败,' . $image_result['msg'];
$result['msg'] = '新增或编辑轮播图片失败,' . $image_result['msg'];
return $result;
}
}
......@@ -203,7 +203,7 @@ class OfficeRoomService
$image_result = $this->m_office_img->edit($data['plan'], $id, 3);
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑楼盘图片失败,' . $image_result['msg'];
$result['msg'] = '新增或编辑楼盘图片失败,' . $image_result['msg'];
return $result;
}
}
......@@ -212,7 +212,7 @@ class OfficeRoomService
$image_result = $this->m_office_img->edit($data['exclusive_img'], $id, 4);
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑独家图片失败,' . $image_result['msg'];
$result['msg'] = '新增或编辑独家图片失败,' . $image_result['msg'];
return $result;
}
}
......@@ -223,7 +223,7 @@ class OfficeRoomService
$m_operating = new OfficeGOperatingRecord();
$m_operating->record($agent_id, 2, $remark, $id);
}
$result['status'] = 'successful';
$result['status'] = 'successful';
$result['data']['house_id'] = $id;
$result['data']['is_alert'] = $is_alert;
} else {
......@@ -241,9 +241,9 @@ class OfficeRoomService
*/
public function getOfficeRoomDetail(int $id, $app = 0)
{
$result['status'] = 'fail';
$result['msg'] = '';
$check_data['id'] = $id;
$result['status'] = 'fail';
$result['msg'] = '';
$check_data['id'] = $id;
$data['slide_show'] = $data['plan'] = $data['exclusive_img'] = [];
$check = $this->validate->scene('detail')->check($check_data);
......@@ -257,12 +257,12 @@ class OfficeRoomService
$field .= 'management_fee,station_start,station_end,area,floor,room_number,floor_tag,enter_date,';
$field .= 'payment_month,deposit_month,age_limit_start,age_limit_end,is_register,is_partition,carport,decoration,';
$field .= 'rent_free,shop_sign,fee_rule,agent_start_time,agent_end_time,landlord_remark,mansion';
$data = $this->m_office_room->getFindData($field, ['id' => $id]);
$data = $this->m_office_room->getFindData($field, ['id' => $id]);
if ($data) {
/*案场,盘方,独家 start*/
$agents_data = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', ['house_id'=>$data['id']]);
$agents_str = $exclusive_str = $dish_str = '';
$agents_data = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', ['house_id' => $data['id']]);
$agents_str = $exclusive_str = $dish_str = '';
foreach ($agents_data as $k => $v) {
if ($v['type'] == 1) {
$agents_str .= $v['id'] . ',';
......@@ -296,7 +296,7 @@ class OfficeRoomService
/*案场,盘方,独家 end*/
/*图片 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) {
foreach ($img_data as $k => $v) {
......@@ -320,7 +320,7 @@ class OfficeRoomService
} else {
$file_url = [];
foreach ($img_data as $k => $v) {
$img_url = 'resource/lib/Attachments/images/' . $v['img_name'];
$img_url = 'resource/lib/Attachments/images/' . $v['img_name'];
$file_url['file_name'] = $img_url;
$file_url['save_path'] = $v['img_name'];
switch ($v['img_type']) {
......@@ -340,17 +340,17 @@ class OfficeRoomService
}
/*图片 end*/
$office = new OfficeGBuilding();
$m_landlord = new OfficeGLandlordPhone();
$office = new OfficeGBuilding();
$m_landlord = new OfficeGLandlordPhone();
if (empty($data['building_id'])) {
$data['title'] = '';
$data['title'] = '';
$data['landlord_phone_array'] = $data['building_data'] = [];
} else {
$data['title'] = $office->getFieldOneValue('title', ['id'=>$data['building_id']]);
$data['landlord_phone_array'] = $m_landlord->getAllList('id,name,phone', ['house_id'=>$data['id']]);
$data['title'] = $office->getFieldOneValue('title', ['id' => $data['building_id']]);
$data['landlord_phone_array'] = $m_landlord->getAllList('id,name,phone', ['house_id' => $data['id']]);
$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') {
$data['building_data'] = $building_data['data'][0];
} else {
......@@ -358,28 +358,28 @@ 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) {
$data['price_total'] = $data['price_total']/100;
$data['price_total'] = $data['price_total'] / 100;
}
if ($data['price'] > 0) {
$data['price'] = $data['price']/100;
$data['price'] = $data['price'] / 100;
}
if ($data['slotting_fee'] > 0) {
$data['slotting_fee'] = $data['slotting_fee']/100;
$data['slotting_fee'] = $data['slotting_fee'] / 100;
}
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;
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['msg'] = $e->getMessage();
$result['msg'] = $e->getMessage();
$result['status'] = 'fail';
}
......@@ -403,7 +403,7 @@ class OfficeRoomService
public function delHouseFile($id = 0, $house_id, $save_path = '')
{
$data['status'] = 'fail';
$data['msg'] = '';
$data['msg'] = '';
if (empty($id)) {
$where['house_id'] = $house_id;
$where['img_name'] = $save_path;
......@@ -418,7 +418,7 @@ class OfficeRoomService
} else {
$this->m_office_img->editData(['img_status' => 1], $id['id'], 'id');
$data['status'] = 200;
$data['msg'] = '删除成功';
$data['msg'] = '删除成功';
}
return $data;
......@@ -444,13 +444,13 @@ class OfficeRoomService
}
try {
$records = new OfficeGOperatingRecord();
$count = 0;
$save_data = $del_agent_name = $del_agent_id = [];
$records = new OfficeGOperatingRecord();
$count = 0;
$save_data = $del_agent_name = $del_agent_id = [];
$agent_id_arr = array_unique(explode(',', $agent_id_string));
$agent_house_where['a.house_id'] = $house_id;
$agent_house_where['a.type'] = $type;
$agent_house_where['a.type'] = $type;
$agent_data_old = $this->agent_room->getAgentsByRoomId('a.id,a.agent_id,a.house_id,b.name', $agent_house_where);
......@@ -461,11 +461,11 @@ class OfficeRoomService
unset($agent_id_arr[$key]);
}
} else {
$save_data[$count]['id'] = $v['id'];
$save_data[$count]['id'] = $v['id'];
$save_data[$count]['is_del'] = 1;
$count++;
$del_agent_name[] = $v['name'];
$del_agent_id[] = $v['agent_id'];
$del_agent_id[] = $v['agent_id'];
}
}
......@@ -473,7 +473,7 @@ class OfficeRoomService
if ((int)$val > 0) {
$save_data[$count]['agent_id'] = $val;
$save_data[$count]['house_id'] = $house_id;
$save_data[$count]['type'] = $type;
$save_data[$count]['type'] = $type;
$count++;
}
}
......@@ -489,10 +489,10 @@ class OfficeRoomService
if ($agent_id_arr) {
$agent_name = $this->agent->getAgentsByWhereColumn(['id' => ['in', $agent_id_arr]], 'name');
$remark .= '新增盘方:' . implode(',', $agent_name);
$remark .= '新增盘方:' . implode(',', $agent_name);
//推送记录
$operation_name = $this->agent->getAgentsById($operation_id, 'name');
$operation_name = $this->agent->getAgentsById($operation_id, 'name');
$data['message'] = '你的【' . $house_title . '】楼盘,盘方被【' . $operation_name . '】修改为:' . implode(',', $agent_name);
$this->push->record(3, $house_id, $del_agent_id, $operation_id, $data);
......@@ -513,7 +513,7 @@ class OfficeRoomService
}
}
$result['status'] = 'successful';
}catch (\Exception $e) {
} catch (\Exception $e) {
$result['status'] = 'fail';
$result['msg'] = $e->getMessage();
}
......@@ -532,21 +532,22 @@ class OfficeRoomService
* User HuJun
* 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)) {
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)) {
return false;
}
$where['house_id'] = $house_id;
$where['type'] = $type;
$is_ok = $this->agent_room->updateData(['is_del'=>1], $where);
$where['type'] = $type;
$is_ok = $this->agent_room->updateData(['is_del' => 1], $where);
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;
}
......@@ -561,53 +562,54 @@ class OfficeRoomService
* @throws \think\Exception
* @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 = [];
$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)) {
//新增
foreach ($data as $k=>$v) {
$insert_data[$k]['name'] = $v['name'];
$insert_data[$k]['phone'] = $v['phone'];
foreach ($data as $k => $v) {
$insert_data[$k]['name'] = $v['name'];
$insert_data[$k]['phone'] = $v['phone'];
$insert_data[$k]['house_id'] = $house_id;
$edit_phone[] = '新增房东手机号:'. substr_replace($v['phone'], '****', 3, 4);
$edit_phone[] = '新增房东手机号:' . substr_replace($v['phone'], '****', 3, 4);
}
} else {
//新增与编辑
foreach ($data as $k=>$v) {
foreach ($data as $k => $v) {
if ($v['id']) {
$phone = $old_landlord[$v['id']];
if (!empty($phone)) {
$update_data[$key]['id'] = $v['id'];
$update_data[$key]['name'] = $v['name'];
$update_data[$key]['id'] = $v['id'];
$update_data[$key]['name'] = $v['name'];
if ($phone != $v['phone']) {
$update_data[$k]['phone'] = $v['phone'];
$edit_phone[] = '房东手机号由【'.substr_replace($phone, '****', 3, 4) . '】修改为【' . substr_replace($v['phone'], '****', 3, 4).'】';
$new_phone[] = $phone;
$edit_phone[] = '房东手机号由【' . substr_replace($phone, '****', 3, 4) . '】修改为【' . substr_replace($v['phone'], '****', 3, 4) . '】';
$new_phone[] = $phone;
}
}
} else {
if (!in_array($v['phone'], $old_landlord)) {
$insert_data[$key]['phone'] = $v['phone'];
$insert_data[$key]['phone'] = $v['phone'];
$insert_data[$key]['house_id'] = $house_id;
$insert_data[$key]['name'] = $v['name'];
$new_phone[] = $old_landlord[$v['id']];
$insert_data[$key]['name'] = $v['name'];
$new_phone[] = $old_landlord[$v['id']];
}
}
$new_phone[] = $v['phone'];
$key++;
}
foreach ($old_landlord as $k2=>$v2) {
foreach ($old_landlord as $k2 => $v2) {
if (!in_array($v2, $new_phone)) {
$update_data[$key]['id'] = $k2;
$update_data[$key]['id'] = $k2;
$update_data[$key]['is_del'] = 1;
$key++;
$edit_phone[] = '删除房东手机号:'.substr_replace($v2, '****', 3, 4) ;
$edit_phone[] = '删除房东手机号:' . substr_replace($v2, '****', 3, 4);
}
}
}
......@@ -628,7 +630,8 @@ class OfficeRoomService
* @return array
* 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,
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,24 +639,24 @@ 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.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) {
return ['status'=>101,'msg'=>'此房源不存在','data'=>''];
return ['status' => 101, 'msg' => '此房源不存在', 'data' => ''];
}
$result['price'] = $result['price'] * 0.01;
$result['price_total'] = $result['price_total'] * 0.01;
$result['slotting_fee'] = $result['slotting_fee'] * 0.01;
$result['price'] = $result['price'] * 0.01;
$result['price_total'] = $result['price_total'] * 0.01;
$result['slotting_fee'] = $result['slotting_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['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']);
//房源数
......@@ -665,31 +668,32 @@ class OfficeRoomService
//楼盘图
$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['agent_id'] = $agent_id;
$params['type'] = 2;
$house = $this->agent_room->isCanEdit('agent_id', $params);
$params['type'] = 2;
$house = $this->agent_room->isCanEdit('agent_id', $params);
if($house){
if ($house) {
return 0;
}else{
} else {
return 1;
}
}
//是否被收藏
private function isCollect($house_id,$agent_id){
private function isCollect($house_id, $agent_id)
{
$m_collect_room = new OfficeACollectHouse();
//是否被收藏
$is_collect = 2;
......@@ -707,88 +711,96 @@ class OfficeRoomService
}
//参考均价
public function referenceAveragePrice($id){
$field = 'MIN(price) as num';
$where['building_id'] = $id;
$where['status'] = 1;
$res = $this->m_office_room->getRoom($field, $where);
public function referenceAveragePrice($id)
{
$field = 'MIN(price) as num';
$where['building_id'] = $id;
$where['status'] = 1;
$res = $this->m_office_room->getRoom($field, $where);
$reference_average_price = isset($res[0]["num"]) ? $res[0]["num"] * 0.01 : 0;
return $reference_average_price;
}
//字段最低值
public function MinField($id, $field = ''){
public function MinField($id, $field = '')
{
$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);
}
//楼盘图
public function getBuildingImage($id){
public function getBuildingImage($id)
{
$where['img_status'] = 0;
$where['house_id'] = $id;
$where['img_type'] = 0;
$house_img_data = $this->m_office_img->getListAll('id,img_name', $where);
if($house_img_data){
foreach ($house_img_data as $k=>$v) {
$house_img_data[$k]['image_path'] = $this->internet_path.$v['img_name'];
$where['house_id'] = $id;
$where['img_type'] = 0;
$house_img_data = $this->m_office_img->getListAll('id,img_name', $where);
if ($house_img_data) {
foreach ($house_img_data as $k => $v) {
$house_img_data[$k]['image_path'] = $this->internet_path . $v['img_name'];
}
}
return $house_img_data;
}
//轮播图
public function getCarouselImage($id,$img_type=2){
$where['img_type'] = $img_type;
public function getCarouselImage($id, $img_type = 2)
{
$where['img_type'] = $img_type;
$where['img_status'] = 0;
$where['house_id'] = $id;
$house_img_data = $this->m_office_img->getListAll('id,img_name', $where);
if($house_img_data){
foreach ($house_img_data as $k=>$v) {
$house_img_data[$k]['image_path'] = $this->internet_path.$v['img_name'];
$where['house_id'] = $id;
$house_img_data = $this->m_office_img->getListAll('id,img_name', $where);
if ($house_img_data) {
foreach ($house_img_data as $k => $v) {
$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){
$field = 'b.line_name_simple,b.name,a.distance';
$res = $this->m_building_stations->getTrafficInfo($field, ['a.building_id'=>$id]);
public function getTrafficInfo($id)
{
$field = 'b.line_name_simple,b.name,a.distance';
$res = $this->m_building_stations->getTrafficInfo($field, ['a.building_id' => $id]);
$res_str = "{$res['line_name_simple']}{$res['name']}地铁站出站{$res['distance']}米";
return $res_str;
}
//房源数
public function getRoomNum($building_id){
public function getRoomNum($building_id)
{
$params['building_id'] = $building_id;
// $params['id'] = array('neq',$id);
$params['is_rent'] = 0;
$params['status'] = 1;
$res = $this->m_office_room->getRoomNum($params);
$params['status'] = 1;
$res = $this->m_office_room->getRoomNum($params);
return $res;
}
//获取上传人信息
public function getUploadInfo($agent_id){
public function getUploadInfo($agent_id)
{
$agent = [];
$res = $this->redis_service->getRedisCache(2, $agent_id);
if($res){
$agent['name'] = $res['name'];
$res = $this->redis_service->getRedisCache(2, $agent_id);
if ($res) {
$agent['name'] = $res['name'];
$agent['phone'] = $res['phone'];
}
return $agent?$agent:null;
return $agent ? $agent : null;
}
//获取独家方
public function getExclusiveInfo($house_id,$type=3){
$exclusive_info = [];
public function getExclusiveInfo($house_id, $type = 3)
{
$exclusive_info = [];
$params['house_id'] = $house_id;
$params['type'] = $type;
$params['is_del'] = 0;
$res = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', $params);
if($res){
$exclusive_info['name'] = $res[0]['name'];
$params['type'] = $type;
$params['is_del'] = 0;
$res = $this->agent_room->getAgentsByRoomId('b.id,name,a.type,b.phone', $params);
if ($res) {
$exclusive_info['name'] = $res[0]['name'];
$exclusive_info['phone'] = $res[0]['phone'];
}
return $exclusive_info ? $exclusive_info : null;
......@@ -796,12 +808,13 @@ class OfficeRoomService
//房东
public function getLandlordInfo($house_id){
$m_landlord = new OfficeGLandlordPhone();
public function getLandlordInfo($house_id)
{
$m_landlord = new OfficeGLandlordPhone();
$res = $m_landlord->getAllList('id,name,phone', ['house_id'=>$house_id]);;
if($res){
foreach ($res as $k=>$v) {
$res = $m_landlord->getAllList('id,name,phone', ['house_id' => $house_id]);;
if ($res) {
foreach ($res as $k => $v) {
$res[$k]['phone'] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $v["phone"]);
}
}
......@@ -817,7 +830,8 @@ class OfficeRoomService
* User HuJun
* 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_size = empty($params['pageSize']) ? 15 : $params['pageSize'];
$result['status'] = 'fail';
......@@ -828,15 +842,15 @@ class OfficeRoomService
/*盘方 start*/
if ($params['dish_id'] != NULL) {
$agent_where['a.agent_id'] = $params['dish_id'];
$agent_where['a.agent_id'] = $params['dish_id'];
}
if ($params['dish_store_id'] != NULL) {
$agent_where['b.store_id'] = $params['dish_store_id'];
$agent_where['b.store_id'] = $params['dish_store_id'];
}
if ($params['dish_district_id'] != NULL) {
$agent_where['b.district_id'] = $params['dish_district_id'];
$agent_where['b.district_id'] = $params['dish_district_id'];
}
try {
......@@ -844,14 +858,14 @@ class OfficeRoomService
if (!empty($agent_where)) {
$agent_where['a.type'] = 2;
$agent_where['a.is_del'] = 0;
$agent_arr = $this->agent_room->getAgentsByRoomColumn('house_id', $agent_where);
$agent_arr = $this->agent_room->getAgentsByRoomColumn('house_id', $agent_where);
if (empty($agent_arr)) {
$result['status'] = 'successful';
return $result;
} else {
$agent_str = implode(',', $agent_arr);
$where[] = ['EXP', "a.id in ({$agent_str})"];
$where[] = ['EXP', "a.id in ({$agent_str})"];
}
}
/*盘方 end*/
......@@ -862,34 +876,34 @@ class OfficeRoomService
$result['msg'] = '房东手机不足11位';
return $result;
}
$landlord_where['phone'] = ['LIKE','%'.$params['landlord_phone'].'%'];
$landlord_where['phone'] = ['LIKE', '%' . $params['landlord_phone'] . '%'];
$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)) {
$result['status'] = 'successful';
return $result;
} else {
$landlord_house_id = [];
foreach ($landlord_arr as $k=>$v) {
foreach ($landlord_arr as $k => $v) {
$landlord_house_id[] = $v['house_id'];
}
$landlord_str = implode(',', $landlord_house_id);
$where[] = ['EXP', "a.id in ({$landlord_str})"];
$where[] = ['EXP', "a.id in ({$landlord_str})"];
}
}
/*房东手机号搜索 end*/
$field = 'a.id,b.type,b.disc,b.business_district_id,b.title,a.price_total,a.area,a.station_start,a.station_end,';
$field .= 'a.status,a.is_rent,a.is_show,a.create_time,a.floor_tag,a.price,a.building_id,a.is_carefully_chosen';
$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();
foreach ($room_data as $k=>$v) {
$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'] = $room_data[$k]['price']/100;
foreach ($room_data as $k => $v) {
$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'] = $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)) {
$room_data[$k]['dish_name'] = '';
} else {
......@@ -900,10 +914,10 @@ class OfficeRoomService
$result['total'] = $this->m_office_room->getRoomAgentTotal($where);
$result['total'] = $result['total'] ? $result['total'] : 0;
}
$result['data'] = $room_data;
$result['data'] = $room_data;
$result['status'] = 'successful';
}catch (\Exception $e) {
$result['msg'] = $e->getMessage();
} catch (\Exception $e) {
$result['msg'] = $e->getMessage();
}
return $result;
......@@ -917,7 +931,8 @@ class OfficeRoomService
* User HuJun
* Date 19-6-2 下午4:21
*/
private function buildParams($params) {
private function buildParams($params)
{
$where = [];
/*所在区*/
if (isset($params['disc'])) {
......@@ -963,32 +978,32 @@ class OfficeRoomService
/*租金总价*/
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'])) {
$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'])) {
$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'])) {
$where['a.price'] = $params['price_start']*100;
$where['a.price'] = $params['price_start'] * 100;
}
/*租金单价*/
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'])) {
$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
/*可容纳工位*/
if (isset($params['station_end']) && isset($params['station_start'])) {
$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_start'] = ['between', [$params['station_start'], $params['station_end']]];
$where['a.station_end'] = ['between', [$params['station_start'], $params['station_end']]];
}
//编号
......@@ -1014,7 +1029,7 @@ class OfficeRoomService
//地址
if (isset($params['address'])) {
$where['b.address'] = ['like', '%'.$params['address'].'%'];
$where['b.address'] = ['like', '%' . $params['address'] . '%'];
}
//是否独家0否1是
......@@ -1063,16 +1078,16 @@ class OfficeRoomService
$result['msg'] = '参数错误';
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field = 'id,name,remark,create_time';
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field = 'id,name,remark,create_time';
$where['house_id'] = $params['houses_id'];
if (isset($params['type'])) {
$where['type'] = $params['type'];
}
try {
$agents = new OfficeGOperatingRecord();
$result['data'] = $agents->getList($pageNo, $pageSize, 'id DESC', $field, $where);
$agents = new OfficeGOperatingRecord();
$result['data'] = $agents->getList($pageNo, $pageSize, 'id DESC', $field, $where);
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['msg'] = $e->getMessage();
......@@ -1091,9 +1106,9 @@ class OfficeRoomService
*/
public function batchChangDish($old_agents_id, $agents_id, $operation_id)
{
$result['data'] = [];
$result['data'] = [];
$result['status'] = 'fail';
$result['msg'] = '盘方信息错误';
$result['msg'] = '盘方信息错误';
if (empty($old_agents_id) || empty($agents_id)) {
return $result;
}
......@@ -1106,7 +1121,7 @@ class OfficeRoomService
if ($agent_house) {
$agent_data_arr = [];
foreach ($agent_house as $k => $v) {
$agent_data_arr[$k]['id'] = $v['id'];
$agent_data_arr[$k]['id'] = $v['id'];
$agent_data_arr[$k]['agent_id'] = $agents_id;
}
}
......@@ -1117,10 +1132,10 @@ class OfficeRoomService
$m_operating = new OfficeGOperatingRecord();
foreach ($agent_house as $k => $v) {
$agent_data = $this->redis_service->getRedisCache(2, $agents_id);
$remark = '批量修改盘方方为' . $agent_data['name'] . '-' . $agent_data['phone'];
$remark = '批量修改盘方方为' . $agent_data['name'] . '-' . $agent_data['phone'];
$m_operating->record($operation_id, 2, $remark, $v['houses_id'], $v['id']);
}
$result['msg'] = '修改' . $total . '条记录';
$result['msg'] = '修改' . $total . '条记录';
$result['status'] = 'successful';
} else {
$result['msg'] = '无修改内容';
......@@ -1139,31 +1154,32 @@ class OfficeRoomService
* @param $agentId
* @return array
*/
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,
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,
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.type"] = 2;
$params["c.is_del"] = 0;
$res = $this->m_office_room->getMyBuildingRoom($field, $params,$pageSize,$pageNo);
$params["c.type"] = 2;
$params["c.is_del"] = 0;
$res = $this->m_office_room->getMyBuildingRoom($field, $params, $pageSize, $pageNo);
if (!$res) {
return ['status'=>200,'msg'=>'此房源不存在','data'=>[]];
}
foreach ($res as $k=>$v) {
$tmp['id'] = $v['id'];
$tmp['status'] = $v['status'];
$tmp['price'] = $this->MinField($v['building_id'], 'price');
$tmp['price'] = empty($tmp['price']) ? 0:$tmp['price']/100;
$tmp['price_total'] = $this->MinField($v['building_id'], 'price_total');
$tmp['price_total'] = empty($tmp['price_total']) ? 0:$tmp['price_total']/100;
$tmp['shop_sign'] = $this->getBuildingSign($v['id']);
$area = $this->MinField($v['building_id'], 'area');
$tmp['title'] = $v['disc'].' '.$v['business_name']. ' '.$v['title']. ' '.$area.'㎡';
$result_data[] = $tmp;
}
return ['status'=>200,'msg'=>'success','data'=>$result_data];
return ['status' => 200, 'msg' => '此房源不存在', 'data' => []];
}
foreach ($res as $k => $v) {
$tmp['id'] = $v['id'];
$tmp['status'] = $v['status'];
$tmp['price'] = $this->MinField($v['building_id'], 'price');
$tmp['price'] = empty($tmp['price']) ? 0 : $tmp['price'] / 100;
$tmp['price_total'] = $this->MinField($v['building_id'], 'price_total');
$tmp['price_total'] = empty($tmp['price_total']) ? 0 : $tmp['price_total'] / 100;
$tmp['shop_sign'] = $this->getBuildingSign($v['id']);
$area = $this->MinField($v['building_id'], 'area');
$tmp['title'] = $v['disc'] . ' ' . $v['business_name'] . ' ' . $v['title'] . ' ' . $area . '㎡';
$result_data[] = $tmp;
}
return ['status' => 200, 'msg' => 'success', 'data' => $result_data];
}
/**
......@@ -1174,13 +1190,13 @@ class OfficeRoomService
*/
public function getRoomBuildingList($params)
{
$page_no = empty($params['pageNo']) ? 1 : $params['pageNo'];
$page_size = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where = [];
$order = 'a.id desc';
$page_no = empty($params['pageNo']) ? 1 : $params['pageNo'];
$page_size = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where = [];
$order = 'a.id desc';
if (isset($params['city'])) {
$where['b.city'] = $params['city']; //市
$where['b.city'] = $params['city']; //市
}
if (isset($params['disc'])) {
......@@ -1188,7 +1204,7 @@ class OfficeRoomService
}
if (isset($params['title'])) {
$where['b.title'] = ['LIKE', '%'.$params['title'].'%']; //楼盘名
$where['b.title'] = ['LIKE', '%' . $params['title'] . '%']; //楼盘名
}
if (isset($params['id'])) {
......@@ -1216,15 +1232,15 @@ class OfficeRoomService
}
if (isset($params['price_start'])) {
$where['a.price'] = $params['price_start']*100;//租金单价
$where['a.price'] = $params['price_start'] * 100;//租金单价
}
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'])) {
$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'])) {
......@@ -1233,7 +1249,7 @@ class OfficeRoomService
if (isset($params['agent_start_time']) && $params['agent_end_time']) {
$where['a.agent_start_time'] = ['>', $params['agent_start_time']]; //独家合同开始时间
$where['a.agent_end_time'] = ['<', $params['agent_end_time']]; //独家合同结束时间
$where['a.agent_end_time'] = ['<', $params['agent_end_time']]; //独家合同结束时间
}
if (isset($params['is_rent'])) {
......@@ -1245,12 +1261,18 @@ class OfficeRoomService
}
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'])) {
$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';
......@@ -1258,47 +1280,71 @@ class OfficeRoomService
$data = $this->m_office_room->getRoomBuilding($page_no, $page_size, $order, $field, $where);
} catch (\Exception $e) {
$result['status'] = 'fail';
$result['msg'] = $e->getMessage();
$result['msg'] = $e->getMessage();
return $result;
}
$result_data = [];
foreach ($data as $k=>$v) {
$tmp['id'] = $v['id'];
$tmp['price'] = empty($v['price']) ? 0:$v['price']/100;
$tmp['price_total'] = empty($v['price_total']) ? 0:$v['price_total']/100;
$tmp['shop_sign'] = $this->getBuildingSign($v['building_id']);
$tmp['status'] = $v['status'];
$tmp['is_rent'] = $v['is_rent'];
$area = $this->MinField($v['building_id'], 'area');
$tmp['title'] = $v['disc'].' '.$v['business_name']. ' '.$v['title']. ' '.$area.'㎡';
$result_data[] = $tmp;
foreach ($data as $k => $v) {
$tmp['id'] = $v['id'];
$tmp['price'] = empty($v['price']) ? 0 : $v['price'] / 100;
$tmp['price_total'] = empty($v['price_total']) ? 0 : $v['price_total'] / 100;
$tmp['shop_sign'] = $this->getBuildingSign($v['building_id']);
$tmp['status'] = $v['status'];
$tmp['is_rent'] = $v['is_rent'];
$area = $this->MinField($v['building_id'], 'area');
$tmp['title'] = $v['disc'] . ' ' . $v['business_name'] . ' ' . $v['title'] . ' ' . $area . '㎡';
$result_data[] = $tmp;
}
$result['status'] = 'successful';
$result['data'] = $result_data;
$result['data'] = $result_data;
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
* @return string
*/
private function getBuildingSign($id){
$field = 'shop_sign';
private function getBuildingSign($id)
{
$field = 'shop_sign';
$where['building_id'] = $id;
$where['status'] = 1;
$res = $this->m_office_room->getRoom($field, $where);
if(!$res)
$where['status'] = 1;
$res = $this->m_office_room->getRoom($field, $where);
if (!$res)
return '';
$shop_sign_old = '';
foreach ($res as $k=>$v) {
$shop_sign_old.=','.$v['shop_sign'];
foreach ($res as $k => $v) {
$shop_sign_old .= ',' . $v['shop_sign'];
}
$ex_shop_sign_old = explode(',', trim($shop_sign_old, ","));
$ex_shop_sign_old = array_unique($ex_shop_sign_old);//数组去重
$shop_sign = implode(",", $ex_shop_sign_old);
$shop_sign = implode(",", $ex_shop_sign_old);
return $shop_sign;
}
......@@ -1308,10 +1354,11 @@ class OfficeRoomService
* @param $data
* @return mixed
*/
public function delRoom($data) {
public function delRoom($data)
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$result['msg'] = '';
$result['data'] = [];
$check = $this->validate->scene('del')->check($data);
if (false === $check) {
......@@ -1319,19 +1366,19 @@ class OfficeRoomService
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)) {
$result['msg'] = '没有该商铺';
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) {
//删除商铺对应的收藏商铺也要删除(改状态值)delCollectHouse
$collect_house = new OfficeACollectHouse();
$collect_house->delCollectHouse($data['id']);
$result['status'] = 'successful';
$result['msg'] = '操作成功';
$result['msg'] = '操作成功';
} else {
$result['msg'] = '操作失败';
}
......@@ -1350,48 +1397,48 @@ class OfficeRoomService
public function getExclusive($room_id)
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$result['msg'] = '';
$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'])) {
$result['msg'] = '没有该房源';
return $result;
}
if (empty($data['id'])) {
$result['msg'] = '没有该房源';
return $result;
}
$result_data['id'] = $data['id'];
$result_data['id'] = $data['id'];
$result_data['is_exclusive_type'] = $data['is_exclusive_type'];
$result_data['agent_start_time'] = $data['agent_start_time'];
$result_data['agent_end_time'] = $data['agent_end_time'];
$result_data['agent_start_time'] = $data['agent_start_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]) {
$result_data['name'] = $agent_data[0]['name'] . '-' . $agent_data[0]['phone'];
} else {
$result_data['name'] = '';
}
if ($agent_data[0]) {
$result_data['name'] = $agent_data[0]['name'] . '-' . $agent_data[0]['phone'];
} else {
$result_data['name'] = '';
}
$room_img = $this->m_office_img->getListAll('img_name',['house_id'=>$room_id,'img_type'=>4]);
if ($room_img) {
$result_data['exclusive_img'] = $room_img;
} else {
$result_data['exclusive_img'] = [];
}
$room_img = $this->m_office_img->getListAll('img_name', ['house_id' => $room_id, 'img_type' => 4]);
if ($room_img) {
$result_data['exclusive_img'] = $room_img;
} else {
$result_data['exclusive_img'] = [];
}
$house_file_where['house_id'] = $room_id;
$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) {
foreach ($exclusive_file as $k=>$v) {
$exclusive_file[$k]['file_name'] = '/static/exclusive_file/'.$v['file_name'];
foreach ($exclusive_file as $k => $v) {
$exclusive_file[$k]['file_name'] = '/static/exclusive_file/' . $v['file_name'];
}
$result_data['exclusive_file'] = $exclusive_file;
} else {
$result_data['exclusive_file'] = [];
}
$result['data'] = $result_data;
$result['data'] = $result_data;
$result['status'] = 'successful';
return $result;
}
......@@ -1403,17 +1450,18 @@ class OfficeRoomService
* @param $house_id
* @return array|int|string
*/
public function exclusiveFile($data, $house_id) {
public function exclusiveFile($data, $house_id)
{
$result = [];
//新增附件
if (!empty($data['exclusive_file'])) {
$exclusive_file_arr = explode(',', $data['exclusive_file']);
$save_data = [];
foreach ($exclusive_file_arr as $k=>$v) {
$save_data = [];
foreach ($exclusive_file_arr as $k => $v) {
$save_data[$k]['file_name'] = $v;
$save_data[$k]['house_id'] = $house_id;
$save_data[$k]['type'] = 0;
$save_data[$k]['status'] = 0;
$save_data[$k]['type'] = 0;
$save_data[$k]['status'] = 0;
}
$result = $this->m_house_file->insertAll($save_data);
......@@ -1422,8 +1470,8 @@ class OfficeRoomService
//伪删除附件
if (!empty($data['del_file_id'])) {
$file_id_arr = explode(',', $data['del_file_id']);
foreach ($file_id_arr as $k=>$v) {
$result[] =$this->m_house_file->where('id', $v)->update(['status'=>1]);
foreach ($file_id_arr as $k => $v) {
$result[] = $this->m_house_file->where('id', $v)->update(['status' => 1]);
}
}
......@@ -1436,23 +1484,24 @@ class OfficeRoomService
* @param $data
* @return mixed
*/
public function isShow($data) {
public function isShow($data)
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$check = $this->validate->scene('show')->check($data);
$result['msg'] = '';
$result['data'] = [];
$check = $this->validate->scene('show')->check($data);
if (false === $check) {
$result['msg'] = $this->validate->getError();
return $result;
}
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'])) {
$result['msg'] = '没有该房源';
return $result;
} else {
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';
}
}
......@@ -1466,26 +1515,27 @@ class OfficeRoomService
* 修改上下架
*
* @param int $building_id
* @param int $status //状态 1上架 2下架 3回收
* @param int $status //状态 1上架 2下架 3回收
* @return mixed
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function downStatus(int $building_id, int $status) {
public function downStatus(int $building_id, int $status)
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$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);
$where['status'] = ['<>', 3];
$num = $this->m_office_room->updateData(['status' => $status], $where);
if ($num > 0) {
$result['status'] = 'successful';
$result['msg'] = '修改成功';
$result['msg'] = '修改成功';
} else {
$result['msg'] = '修改失败';
}
......@@ -1498,11 +1548,12 @@ class OfficeRoomService
* @param $params
* @return mixed
*/
public function checkRepetition($params) {
public function checkRepetition($params)
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$check = $this->validate->scene('checkRepetition')->check($params);
$result['msg'] = '';
$result['data'] = [];
$check = $this->validate->scene('checkRepetition')->check($params);
if (false === $check) {
$result['msg'] = $this->validate->getError();
return $result;
......@@ -1512,23 +1563,23 @@ class OfficeRoomService
$page_size = empty($params['pageSize']) ? 15 : $params['pageSize'];
try {
$field = 'a.id,a.floor,a.room_number,a.mansion';
$where['b.city'] = $params['city'];
$where['a.floor'] = $params['floor'];
$field = 'a.id,a.floor,a.room_number,a.mansion';
$where['b.city'] = $params['city'];
$where['a.floor'] = $params['floor'];
$where['a.mansion'] = $params['mansion'];
$list = $this->m_office_room->getRoomBuildingListLimit($page_no, $page_size, $field, $where);
$list = $this->m_office_room->getRoomBuildingListLimit($page_no, $page_size, $field, $where);
if ($list) {
$data = [];
foreach ($list as $k=>$v) {
$data[$k]['id'] = $v['id'];
$data[$k]['address'] = $v['mansion'].'-'.$v['floor'].'-'.$v['room_number'];
foreach ($list as $k => $v) {
$data[$k]['id'] = $v['id'];
$data[$k]['address'] = $v['mansion'] . '-' . $v['floor'] . '-' . $v['room_number'];
}
$result['data'] = $data;
}
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['msg'] = "内部错误:".$e->getMessage();
$result['msg'] = "内部错误:" . $e->getMessage();
}
return $result;
}
......
......@@ -61,6 +61,14 @@ class OfficeGBuildingStations extends BaseModel
->select();
}
public function getBuilderByStations($field, $where){
$where['a.is_del'] = 0;
return $this->db_
->field($field)
->where($where)
->select();
}
/**
* @param $data
* @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