Commit 51e52250 authored by hujun's avatar hujun

是否精选

parent bf004a68
......@@ -17,6 +17,9 @@ use app\model\OfficeACollectHouse;
class OfficeRoom extends Basic
{
private $service;
private $code = 200;
private $msg = '';
private $data = [];
public function __construct()
{
......@@ -31,36 +34,32 @@ class OfficeRoom extends Basic
*/
public function edit()
{
$result['code'] = 200;
$result['msg'] = '';
$result_data = [];
if ($this->request->isPost()) {
$data = $this->service->edit($this->params, $this->userId, $this->siteId);
if ($data['status'] == 'successful') {
$result_data['house_id'] = $data['data']['house_id'];
$result['msg'] = '新增或编辑成功';
$this->data['house_id'] = $data['data']['house_id'];
$this->msg = '新增或编辑成功';
} else {
$result['code'] = 101;
$result['msg'] = $data['msg'];
$this->code = 101;
$this->msg = $data['msg'];
}
} else {
if (empty($this->params['id'])) {
$result['code'] = 101;
$result['msg'] = 'Id is null';
$this->code = 101;
$this->msg = 'Id is null';
} else {
//获取商铺详情
$data = $this->service->getOfficeRoomDetail($this->params['id']);
if ($data['status'] == 'successful') {
$result_data = $data['data'];
$this->data = $data['data'];
} else {
$result['msg'] = $data['msg'];
$result['code'] = 101;
$this->msg = $data['msg'];
$this->code = 101;
}
}
}
return $this->response($result['code'], $result['msg'], $result_data);
return $this->response($this->code, $this->msg, $this->data);
}
......@@ -74,22 +73,19 @@ class OfficeRoom extends Basic
*/
public function getBuildingSearch()
{
$msg = '';
$data = [];
$code = 200;
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$building_service = new OfficeService();
$result = $building_service->BuildingSearch($pageNo, $pageSize, $this->params);
if ($result['status'] == 'fail') {
$code = 101;
$msg = $result['msg'];
$this->code = 101;
$this->msg = $result['msg'];
} else {
$data = $result['data'];
$this->data = $result['data'];
}
return $this->response($code, $msg, $data);
return $this->response($this->code, $this->msg, $this->data);
}
......@@ -100,20 +96,16 @@ class OfficeRoom extends Basic
*/
public function getBuildingDetail()
{
$msg = '';
$data = [];
$code = 200;
$building_service = new OfficeService();
$result = $building_service->getOfficeDetail($this->params['id']);
if ($result['status'] == 'fail') {
$code = 101;
$msg = $result['msg'];
$this->code = 101;
$this->msg = $result['msg'];
} else {
$data = $result['data'];
$this->data = $result['data'];
}
return $this->response($code, $msg, $data);
return $this->response($this->code, $this->msg, $this->data);
}
/**
......@@ -126,11 +118,7 @@ class OfficeRoom extends Basic
if (!$this->request->isAjax()) {
return view('office/officeBuildingList');
}
$code = 200;
$data = [];
$msg = '';
$result = $this->service->getRoomList($this->params, 1);
if ($result['status'] == 'successful') {
$m_collect = new OfficeACollectHouse();
foreach ($result['data'] as $k=>$v) {
......@@ -138,15 +126,15 @@ class OfficeRoom extends Basic
$where['house_id'] = $v['id'];
$where['status'] = 1;
$is_collect = $m_collect->getFieldOneValue('id', $where);
$result['data'][$k]['is_collect'] = $is_collect ? $is_collect : 0;
$result['data'][$k]['is_collect'] = $is_collect ? 1 : 2;
}
$data['list'] = $result['data'];
$data['total'] = $result['total'];
$this->data['list'] = $result['data'];
$this->data['total'] = $result['total'];
} else {
$code = 101;
$msg = $result['msg'];
$this->code = 101;
$this->msg = $result['msg'];
}
return $this->response($code, $msg, $data);
return $this->response($this->code, $this->msg, $this->data);
}
/**
......@@ -156,18 +144,17 @@ class OfficeRoom extends Basic
*/
public function getRecords()
{
$data = [];
$this->params['type'] = 1;
$result = $this->service->getRecords($this->params);
if ($result['status'] == 'successful') {
$data = $result['data'];
$code = 200;
$msg = '';
$this->data = $result['data'];
$this->code = 200;
$this->msg = '';
} else {
$code = 101;
$msg = $result['msg'];
$this->code = 101;
$this->msg = $result['msg'];
}
return $this->response($code, $msg, $data);
return $this->response($this->code, $this->msg, $this->data);
}
/**
......@@ -177,17 +164,31 @@ class OfficeRoom extends Basic
*/
public function batchChangDish()
{
$code = 200;
$msg = '';
$data = [];
$result = $this->service->batchChangDish($this->params['old_agents_id'], $this->params['agents_id'], $this->userId);
if ($result['status'] == 'successful') {
$data = $result['data'];
$this->data = $result['data'];
} else {
$code = 101;
$msg = $result['msg'];
$this->code = 101;
$this->msg = $result['msg'];
}
return $this->response($code, $msg, $data);
return $this->response($this->code, $this->msg, $this->data);
}
/**
* 是否精选商铺
*
* @return \think\Response
*/
public function carefullyChosen()
{
$data['id'] = $this->params['houses_id'];
$data['is_carefully_chosen'] = $this->params['is_carefully_chosen'];
$result = $this->service->edit($data, $this->userId, $this->siteId, 'is_carefully_chosen');
if ($result['status'] == 'fail') {
$this->code = 101;
$this->msg = $result['msg'];
}
return $this->response($this->code, $this->msg, $this->data);
}
}
\ No newline at end of file
......@@ -63,37 +63,44 @@ class OfficeRoomService
* @param array $data
* @param int $agent_id 上传人id
* @param int $site_id
* @param string $scene
* @return mixed
*/
public function edit(array $data, int $agent_id, $site_id)
public function edit(array $data, int $agent_id, $site_id, $scene = '')
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
if (isset($data['id'])) {
$scene = 'edit';
} else {
$scene = 'add';
if (empty($scene)) {
if (isset($data['id'])) {
$scene = 'edit';
} else {
$scene = 'add';
}
}
$check = $this->validate->scene($scene)->check($data);
if (false === $check) {
$result['msg'] = $this->validate->getError();
return $result;
}
$id = $this->m_office_room->addRoom($data, $agent_id);
if ($id > 0) {
$remark = '';
/*房东手机号处理 start*/
if (!empty($data['landlord_phone'])) {
$landlord_phone_new = json_decode($data['landlord_phone'], true);
$landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $id);
try {
$landlord_phone_new = json_decode($data['landlord_phone'], true);
$landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $id);
if (!empty($landlord_phone_old)) {
$remark .= implode(',', $landlord_phone_old).',';
if (!empty($landlord_phone_old)) {
$remark .= implode(',', $landlord_phone_old).',';
}
} catch (\Exception $e) {
$result['msg'] = '房东手机号处理失败'.$e->getMessage();
return $result;
}
}
/*房东手机号处理 end*/
......@@ -121,8 +128,13 @@ class OfficeRoomService
//独家方
if (empty($data['exclusive_ids'])) {
$this->delAgentHouse(3, $id, 0);
unset($data['exclusive_ids']);
try {
$this->delAgentHouse(3, $id, 0);
unset($data['exclusive_ids']);
} catch (\Exception $e) {
}
} else {
$result_exclusive_ids = $this->releaseRelationshipV2($data['exclusive_ids'], $id, 3, $agent_id, $data['title'], $site_id);
if ($result_exclusive_ids['status'] == 'fail') {
......@@ -878,6 +890,7 @@ class OfficeRoomService
}
if ($is_total) {
$result['total'] = $this->m_office_room->getRoomAgentTotal($where);
$result['total'] = $result['total'] ? $result['total'] : 0;
}
$result['data'] = $room_data;
$result['status'] = 'successful';
......
......@@ -41,7 +41,8 @@ class OfficeBuildingRoomValidate extends Validate
'decoration' => 'require|in:1,2,3,4',
'shop_sign' => 'require|length:1,255',
'landlord_phone'=>'require',
'agent_dish'=>'require'
'agent_dish'=>'require',
'is_carefully_chosen'=>'require|in:0,1'
];
protected $message = [
......@@ -95,7 +96,9 @@ class OfficeBuildingRoomValidate extends Validate
'landlord_phone.require' => '房东手机号必填',
'agent_dish.require' => '盘方必填',
'building_id.require'=>'办公楼必选',
'building_id.between'=>'办公楼参数错误'
'building_id.between'=>'办公楼参数错误',
'is_carefully_chosen.require'=>'是否精选参数必选提交',
'is_carefully_chosen.in'=>'是否精选参数错误'
];
protected $scene = [
......@@ -105,6 +108,7 @@ class OfficeBuildingRoomValidate extends Validate
'edit' => ['id','floor','room_number','is_rent','is_exclusive_type','price_total','price','slotting_fee','management_fee',
'station_start','station_end','area','floor_tag','enter_time','payment_month','deposit_month','age_limit_start',
'age_limit_end','is_partition','carport','rent_free','source','decoration','shop_sign'],
'detail' => ['id']
'detail' => ['id'],
'is_carefully_chosen'=>['id','is_carefully_chosen']
];
}
\ No newline at end of file
......@@ -193,6 +193,11 @@ class OfficeGRoom extends BaseModel
$save_data['landlord_remark'] = $data['landlord_remark'];
}
//精选商铺--0否1是
if (isset($data['is_carefully_chosen'])) {
$save_data['is_carefully_chosen'] = $data['is_carefully_chosen'];
}
if (empty($data['id'])) {
$save_data['operation_id'] = $agent_id; //上传人
$save_data['create_time'] = date('Y-m-d H:i:s');
......
......@@ -1014,7 +1014,7 @@ Route::group('office_index', [
'houseDictionaryAdd' => ['index/OfficeManage/add', ['method' => 'GET|POST']],//楼盘字典新增
'houseDictionaryEdit' => ['index/OfficeManage/edit', ['method' => 'GET|POST']],//楼盘字典编辑
'delHouseFile' => ['index/OfficeManage/delHouseFile', ['method' => 'POST']],//删除房源图片
'delBuildingFile' => ['index/OfficeBuilding/delBuildingFile', ['method' => 'POST']],//删除楼盘图片
'delBuildingFile' => ['index/OfficeManage/delBuildingFile', ['method' => 'POST']],//删除楼盘图片
'getBuildingSearch' => ['index/OfficeRoom/getBuildingSearch', ['method' => 'GET']],//搜索楼盘
'getBuildingDetail' => ['index/OfficeRoom/getBuildingDetail', ['method' => 'GET']],//楼盘详情
'getBuildingList' => ['index/OfficeManage/getBuildingList', ['method' => 'GET']],//楼盘列表
......@@ -1031,6 +1031,7 @@ Route::group('office_index', [
'adjustment' => ['index/OfficePayLog/adjustment', ['method' => 'get']],//导出收款记录
'getCollectionDetail' => ['index/OfficePayLog/getCollectionDetail', ['method' => 'get']],//收款详情
'getAdjustmentDetail' => ['index/OfficePayLog/getAdjustmentDetail', ['method' => 'get']],//调整收款详情
'carefullyChosen' => ['index/OfficeRoom/carefullyChosen', ['method' => 'POST|get']],//设置精选楼盘
]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment