Commit 69afad96 authored by hujun's avatar hujun

新增楼盘

parent 7a1641bf
...@@ -9,93 +9,77 @@ ...@@ -9,93 +9,77 @@
namespace app\api_broker\controller; namespace app\api_broker\controller;
use app\index\extend\Basic; use app\api_broker\extend\Basic;
use app\index\service\OfficeRoomService; use app\index\service\OfficeRoomService;
use think\Request;
class OfficeRoom extends Basic class OfficeRoom extends Basic
{ {
private $service; private $service;
public function __construct(?Request $request = null) public function __construct()
{ {
parent::__construct($request); parent::__construct();
$this->service = new OfficeRoomService(); $this->service = new OfficeRoomService();
} }
/** /**
* 新增楼盘 * 删除图片
* *
* @return \think\Response|\think\response\View * @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function add() public function delHouseFile()
{ {
if (!$this->request->isAjax()) { $msg = '';
return view('office/add');
}
$code = 200; $code = 200;
$result['status'] = $msg = ''; $result = $this->service->delHouseFile($this->params['id'], $this->params['house_id'], 2);
if ($this->request->isPost()) {
$msg = '新增成功';
$result = $this->service->edit($this->params, $this->userId);
}
if ($result['status'] == 'fail') { if ($result['status'] == 'fail') {
$code = 101; $code = 101;
$msg = $result['msg']; $msg = '删除失败';
} }
return $this->response($code, $msg); return $this->response($code, $msg);
} }
/** /**
* 编辑楼盘 * 新增和编辑商铺
* *
* @return \think\Response|\think\response\View * @return \think\Response
*/ */
public function edit() { public function edit()
if (!$this->request->isAjax()) { {
return view('office/add'); $result['code'] = 200;
} $result['msg'] = '';
$result_data = [];
if (empty($this->params['id'])) {
return $this->response(101, '参数错误');
}
$code = 200;
$msg = '';
if ($this->request->isPost()) { if ($this->request->isPost()) {
$result = $this->service->edit($this->params); $data = $this->service->edit($this->params, $this->agentId, $this->siteId);
} else {
$result = $this->service->getOfficeDetail($this->params['id'], 0);
}
if ($result['status'] == 'fail') { if ($data['status'] == 'successful') {
$code = 101; $result_data['room_id'] = $data['data']['room_id'];
$msg = $result['msg']; $result_data['title'] = $data['data']['title'];
$result['msg'] = '新增或编辑成功';
} else {
$result['code'] = 101;
$result['msg'] = $data['msg'];
}
} else {
if (empty($this->params['id'])) {
$result['code'] = 101;
$result['msg'] = 'Id is null';
} else {
//获取商铺详情
$data = $this->service->getOfficeRoomDetail($this->params['id']);
if ($data['status'] == 'successful') {
$result_data = $data['data'];
} else {
$result['msg'] = $data['msg'];
$result['code'] = 101;
}
}
} }
return $this->response($code, $msg, []);
}
/** return $this->response($result['code'], $result['msg'], $result_data);
* 删除图片
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function delHouseFile()
{
$msg = '';
$code = 200;
$result = $this->service->delHouseFile($this->params['id'], $this->params['building_id'], 2);
if ($result['status'] == 'fail') {
$code = 101;
$msg = '删除失败';
}
return $this->response($code, $msg);
} }
} }
\ No newline at end of file
...@@ -12,7 +12,7 @@ namespace app\index\service; ...@@ -12,7 +12,7 @@ namespace app\index\service;
use app\api_broker\service\PushMessageService; use app\api_broker\service\PushMessageService;
use app\index\validate\OfficeBuildingRoomValidate; use app\index\validate\OfficeBuildingRoomValidate;
use app\model\AAgents; use app\model\AAgents;
use app\model\OfficeGBuildingImg; use app\model\OfficeGImg;
use app\model\OfficeGLandlordPhone; use app\model\OfficeGLandlordPhone;
use app\model\OfficeGOperatingRecord; use app\model\OfficeGOperatingRecord;
use app\model\OfficeGRoom; use app\model\OfficeGRoom;
...@@ -33,7 +33,7 @@ class OfficeRoomService ...@@ -33,7 +33,7 @@ class OfficeRoomService
{ {
$this->validate = new OfficeBuildingRoomValidate(); $this->validate = new OfficeBuildingRoomValidate();
$this->m_office_room = new OfficeGRoom(); $this->m_office_room = new OfficeGRoom();
$this->m_office_img = new OfficeGBuildingImg(); $this->m_office_img = new OfficeGImg();
$this->push = new PushMessageService(); $this->push = new PushMessageService();
$this->agent = new AAgents(); $this->agent = new AAgents();
$this->agent_room = new OfficeGRoomToAgent(); $this->agent_room = new OfficeGRoomToAgent();
...@@ -173,11 +173,15 @@ class OfficeRoomService ...@@ -173,11 +173,15 @@ class OfficeRoomService
} }
/*图片处理 end*/ /*图片处理 end*/
$result['status'] = 'successful';
if (!empty($remark)) { if (!empty($remark)) {
$m_operating = new OfficeGOperatingRecord(); $m_operating = new OfficeGOperatingRecord();
$m_operating->record($agent_id, 2, $remark, $data['id']); $m_operating->record($agent_id, 2, $remark, $data['id']);
} }
$result['status'] = 'successful';
$result['data']['house_id'] = $id;
$result['data']['title'] = $data['title'];
} else { } else {
$result['msg'] = '新增或编辑失败!'; $result['msg'] = '新增或编辑失败!';
} }
...@@ -259,7 +263,7 @@ class OfficeRoomService ...@@ -259,7 +263,7 @@ class OfficeRoomService
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function delHouseFile($id, $building_id, $img_status) public function delHouseFile($id, $house_id, $img_status)
{ {
$data['status'] = 'fail'; $data['status'] = 'fail';
$data['msg'] = ''; $data['msg'] = '';
...@@ -269,7 +273,7 @@ class OfficeRoomService ...@@ -269,7 +273,7 @@ class OfficeRoomService
return $data; return $data;
} }
$where['building_id'] = $id; $where['house_id'] = $id;
$where['id'] = $id; $where['id'] = $id;
$where['img_status'] = $img_status; $where['img_status'] = $img_status;
$id = $this->m_office_img->getFindData('id', $where); $id = $this->m_office_img->getFindData('id', $where);
...@@ -300,46 +304,45 @@ class OfficeRoomService ...@@ -300,46 +304,45 @@ class OfficeRoomService
{ {
if (empty($agent_id_string)) { if (empty($agent_id_string)) {
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = '经纪人id字符串为空'; $result['msg'] = '经纪人id字符串为空';
return $result; return $result;
} }
try { try {
$records = new OfficeGOperatingRecord(); $records = new OfficeGOperatingRecord();
$count = 0;
$save_data = $del_agent_name = $del_agent_id = []; $save_data = $del_agent_name = $del_agent_id = [];
$agent_id_arr = array_unique(explode(',', $agent_id_string)); $agent_id_arr = array_unique(explode(',', $agent_id_string));
$agent_room_where['a.is_del'] = 0; $agent_house_where['a.house_id'] = $house_id;
$agent_room_where['a.houses_id'] = $house_id; $agent_house_where['a.type'] = $type;
$agent_room_where['a.type'] = $type;
$agent_data_old = $this->agent_room->getAgentsByHouseId('a.id,a.agents_id,a.houses_id,b.name', $agent_room_where); $agent_data_old = $this->agent_room->getAgentsByRoomId('a.id,a.agent_id,a.house_id,b.name', $agent_house_where);
foreach ($agent_data_old as $k=>$v) { foreach ($agent_data_old as $v) {
if (in_array($v['agents_id'], $agent_id_arr)) { if (in_array($v['agent_id'], $agent_id_arr)) {
$key = array_search($v['agents_id'], $agent_id_arr); $key = array_search($v['agent_id'], $agent_id_arr);
if ($key !== false) { if ($key !== false) {
unset($agent_id_arr[$key]); unset($agent_id_arr[$key]);
} }
} else { } else {
$save_data['is_del'] = 1; $save_data[$count]['id'] = $v['id'];
$this->agent_room->updateData($save_data, ['id'=>$v['id']]); $save_data[$count]['is_del'] = 1;
$count++;
$del_agent_name[] = $v['name']; $del_agent_name[] = $v['name'];
$del_agent_id[] = $v['agents_id']; $del_agent_id[] = $v['agent_id'];
} }
} }
foreach ($agent_id_arr as $kay=>$val) { foreach ($agent_id_arr as $val) {
if ((int)$val > 0) { if ((int)$val > 0) {
$add_agent_data[$kay]['agent_id'] = $val; $save_data[$count]['agent_id'] = $val;
$add_agent_data[$kay]['room_id'] = $house_id; $save_data[$count]['house_id'] = $house_id;
$add_agent_data[$kay]['type'] = $type; $save_data[$count]['type'] = $type;
$count++;
} }
} }
$this->agent_room->updateDataAll($save_data);
if (isset($add_agent_data)) {
$this->agent_room->insertAll($add_agent_data);
}
if ($type == 2) { if ($type == 2) {
$sum = new ResultsSummaryNewTask(); $sum = new ResultsSummaryNewTask();
...@@ -355,7 +358,7 @@ class OfficeRoomService ...@@ -355,7 +358,7 @@ class OfficeRoomService
//推送记录 //推送记录
$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); $data['message'] = '你的【' . $house_title . '】楼盘,盘方被【' . $operation_name . '】修改为:' . implode(',', $agent_name);
$this->push->record(3, $house_id, $del_agent_id, $operation_id, $data); $this->push->record(3, $house_id, $del_agent_id, $operation_id, $data);
$date = date('Y-m-d'); $date = date('Y-m-d');
...@@ -371,13 +374,13 @@ class OfficeRoomService ...@@ -371,13 +374,13 @@ class OfficeRoomService
} }
if (!empty($remark)) { if (!empty($remark)) {
$records->record($operation_id, 2, $remark, $house_id); $records->record($operation_id, 1, $remark, $house_id);
} }
} }
$result['status'] = 'successful'; $result['status'] = 'successful';
} catch (\Exception $e) { }catch (\Exception $e) {
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = '经纪人id字符串为空'; $result['msg'] = '经纪人id字符串为空';
} }
return $result; return $result;
} }
...@@ -386,7 +389,7 @@ class OfficeRoomService ...@@ -386,7 +389,7 @@ class OfficeRoomService
* 删除经纪人与楼盘关系 * 删除经纪人与楼盘关系
* *
* @param $type * @param $type
* @param $room_id * @param $house_id
* @param int $id_edit * @param int $id_edit
* @return bool|int|string * @return bool|int|string
* @throws \think\Exception * @throws \think\Exception
...@@ -394,21 +397,21 @@ class OfficeRoomService ...@@ -394,21 +397,21 @@ class OfficeRoomService
* User HuJun * User HuJun
* Date 19-5-30 下午9:01 * Date 19-5-30 下午9:01
*/ */
public function delAgentHouse($type, $room_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'=>$room_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['room_id'] = $room_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], $room_id); $this->m_office_room->editData(['is_exclusive_type'=>0], $house_id);
} }
return $is_ok; return $is_ok;
} }
...@@ -492,7 +495,7 @@ class OfficeRoomService ...@@ -492,7 +495,7 @@ class OfficeRoomService
} }
if ($update_data) { if ($update_data) {
$m_landlord->updateData($update_data); $m_landlord->updateDataAll($update_data);
} }
if ($insert_data) { if ($insert_data) {
......
...@@ -11,7 +11,7 @@ namespace app\index\service; ...@@ -11,7 +11,7 @@ namespace app\index\service;
use app\index\validate\OfficeBuildingValidate; use app\index\validate\OfficeBuildingValidate;
use app\model\OfficeGBuilding; use app\model\OfficeGBuilding;
use app\model\OfficeGBuildingImg; use app\model\OfficeGImg;
use app\model\OfficeGBuildingStations; use app\model\OfficeGBuildingStations;
class OfficeService class OfficeService
...@@ -25,7 +25,7 @@ class OfficeService ...@@ -25,7 +25,7 @@ class OfficeService
{ {
$this->validate = new OfficeBuildingValidate(); $this->validate = new OfficeBuildingValidate();
$this->m_office = new OfficeGBuilding(); $this->m_office = new OfficeGBuilding();
$this->m_office_img = new OfficeGBuildingImg(); $this->m_office_img = new OfficeGImg();
$this->m_building_stations = new OfficeGBuildingStations(); $this->m_building_stations = new OfficeGBuildingStations();
} }
...@@ -128,7 +128,7 @@ class OfficeService ...@@ -128,7 +128,7 @@ class OfficeService
if ($result) { if ($result) {
$img_data = $this->m_office_img->getListAll('id,img_type,img_name', ['building_id'=>$id, 'img_type'=>0]); $img_data = $this->m_office_img->getListAll('id,img_type,img_name', ['house_id'=>$id, 'img_type'=>0]);
if ($app == 0) { if ($app == 0) {
foreach ($img_data as $k => $v) { foreach ($img_data as $k => $v) {
$data['building_images'][$k]['img_name'] = $v['img_name']; $data['building_images'][$k]['img_name'] = $v['img_name'];
...@@ -187,7 +187,7 @@ class OfficeService ...@@ -187,7 +187,7 @@ class OfficeService
return $data; return $data;
} }
$where['building_id'] = $id; $where['house_id'] = $building_id;
$where['id'] = $id; $where['id'] = $id;
$where['img_status'] = $img_status; $where['img_status'] = $img_status;
$id = $this->m_office_img->getFindData('id', $where); $id = $this->m_office_img->getFindData('id', $where);
......
...@@ -32,7 +32,7 @@ class OfficeBuildingRoomValidate extends Validate ...@@ -32,7 +32,7 @@ class OfficeBuildingRoomValidate extends Validate
'deposit_month' => 'require|between:1,12', 'deposit_month' => 'require|between:1,12',
'age_limit_start' => 'require|between:1,12', 'age_limit_start' => 'require|between:1,12',
'age_limit_end' => 'require|between:1,12', 'age_limit_end' => 'require|between:1,12',
'is_partition' => 'is_partition|in:0,1', 'is_partition' => 'require|in:0,1',
'carport' => 'require|length:1,255', 'carport' => 'require|length:1,255',
'rent_free' => 'require|length:-1,99', 'rent_free' => 'require|length:-1,99',
'source' => 'require|in:0,1,2,3,4,5,6,7', 'source' => 'require|in:0,1,2,3,4,5,6,7',
......
...@@ -6,9 +6,9 @@ namespace app\model; ...@@ -6,9 +6,9 @@ namespace app\model;
use think\Db; use think\Db;
class OfficeGBuildingImg extends BaseModel class OfficeGImg extends BaseModel
{ {
protected $table = 'office_g_building_img'; protected $table = 'office_g_img';
private $db_; private $db_;
public function __construct($data = []) public function __construct($data = [])
...@@ -27,8 +27,8 @@ class OfficeGBuildingImg extends BaseModel ...@@ -27,8 +27,8 @@ class OfficeGBuildingImg extends BaseModel
{ {
$save_data = []; $save_data = [];
//楼盘名称 //楼盘名称
if (isset($data['building_id'])) { if (isset($data['house_id'])) {
$save_data['building_id'] = $data['building_id']; $save_data['house_id'] = $data['house_id'];
} }
//图片类型:1列表页封面图,2详情页轮播图,3楼层平面图,4独家合同,5,删除 //图片类型:1列表页封面图,2详情页轮播图,3楼层平面图,4独家合同,5,删除
...@@ -113,7 +113,7 @@ class OfficeGBuildingImg extends BaseModel ...@@ -113,7 +113,7 @@ class OfficeGBuildingImg extends BaseModel
$image_arr = array_unique($image_arr); $image_arr = array_unique($image_arr);
//编辑图片 //编辑图片
$where['img_status'] = 0; $where['img_status'] = 0;
$where['building_id'] = $house_id; $where['house_id'] = $house_id;
$where['img_type'] = $type; $where['img_type'] = $type;
$house_img_data = $this->getListAll('id,img_name', $where); $house_img_data = $this->getListAll('id,img_name', $where);
$house_img_edit = []; $house_img_edit = [];
...@@ -133,7 +133,7 @@ class OfficeGBuildingImg extends BaseModel ...@@ -133,7 +133,7 @@ class OfficeGBuildingImg extends BaseModel
$house_img_add[$k2]['img_status'] = 0; $house_img_add[$k2]['img_status'] = 0;
$house_img_add[$k2]['img_name'] = $v2; $house_img_add[$k2]['img_name'] = $v2;
$house_img_add[$k2]['img_type'] = $type; $house_img_add[$k2]['img_type'] = $type;
$house_img_add[$k2]['building_id'] = $house_id; $house_img_add[$k2]['house_id'] = $house_id;
} }
if (isset($house_img_add)) { if (isset($house_img_add)) {
......
...@@ -75,6 +75,42 @@ class OfficeGLandlordPhone extends BaseModel ...@@ -75,6 +75,42 @@ class OfficeGLandlordPhone extends BaseModel
return $this->db_->where($where)->update($data); return $this->db_->where($where)->update($data);
} }
/**
* @param $data
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
* User HuJun
* Date 19-5-31 上午10:41
*/
public function updateDataAll($data)
{
$num = 0;
foreach ($data as $k=>$v) {
if (empty($v['name'])) {
continue;
}
if (empty($v['phone'])) {
continue;
}
if (empty($v['room_id'])) {
continue;
}
if (isset($v['id'])) {
$save_data['id'] = $v['id'];
}
$save_data['name'] = $v['name'];
$save_data['phone'] = $v['phone'];
$save_data['room_id'] = $v['room_id'];
$num += $this->db_->update($data);
}
return $num;
}
/** /**
* @param $data * @param $data
* @return int|string * @return int|string
......
...@@ -184,4 +184,21 @@ class OfficeGRoom extends BaseModel ...@@ -184,4 +184,21 @@ class OfficeGRoom extends BaseModel
return (int)$room_id; return (int)$room_id;
} }
/**
* @param $field
* @param $where
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* User HuJun
* Date 19-5-31 上午11:13
*/
public function getFindData($field, $where)
{
return $this->field($field)
->where($where)
->find();
}
} }
...@@ -76,4 +76,60 @@ class OfficeGRoomToAgent extends BaseModel ...@@ -76,4 +76,60 @@ class OfficeGRoomToAgent extends BaseModel
public function insertData($data){ public function insertData($data){
return $this->db_->insertAll($data); return $this->db_->insertAll($data);
} }
/**
* @param $data
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
* User HuJun
* Date 19-5-31 上午10:41
*/
public function updateDataAll($data)
{
$num = 0;
foreach ($data as $k=>$v) {
if (empty($v['type'])) {
continue;
}
if (empty($v['agent_id'])) {
continue;
}
if (empty($v['room_id'])) {
continue;
}
if (isset($v['id'])) {
$save_data['id'] = $v['id'];
}
$save_data['name'] = $v['name'];
$save_data['phone'] = $v['phone'];
$save_data['room_id'] = $v['room_id'];
$num += $this->db_->update($data);
}
return $num;
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* User HuJun
* Date 19-5-31 上午10:49
*/
public function getAgentsByRoomId($field, $params)
{
$params['a.is_del'] = 0;
return $this->field($field)
->alias("a")
->join("a_agents b", "a.agents_id = b.id", "left")
->where($params)
->select();
}
} }
...@@ -938,10 +938,6 @@ Route::group('search', [ ...@@ -938,10 +938,6 @@ Route::group('search', [
Route::group('office', [ Route::group('office', [
'houseAdd' => ['api_broker/OfficeManage/add', ['method' => 'GET|POST']],//楼盘字典新增
'houseEdit' => ['api_broker/OfficeManage/edit', ['method' => 'GET|POST']],//楼盘字典编辑
'delHouseFile' => ['api_broker/OfficeManage/delHouseFile', ['method' => 'POST']],//删除楼盘图片
'marchIn' => ['api_broker/OfficeOrderLog/marchIn', ['method' => 'get|post']], 'marchIn' => ['api_broker/OfficeOrderLog/marchIn', ['method' => 'get|post']],
'marchInV2' => ['api_broker/OfficeOrderLog/marchInV2', ['method' => 'get|post']], 'marchInV2' => ['api_broker/OfficeOrderLog/marchInV2', ['method' => 'get|post']],
'getBeforeBillInfo' => ['api_broker/OfficeOrderLog/getBeforeBillInfo', ['method' => 'get|post']], 'getBeforeBillInfo' => ['api_broker/OfficeOrderLog/getBeforeBillInfo', ['method' => 'get|post']],
...@@ -967,6 +963,7 @@ Route::group('office', [ ...@@ -967,6 +963,7 @@ Route::group('office', [
'getCommission' => ['api_broker/OfficeOrderLog/getCommission', ['method' => 'GET|POST']], 'getCommission' => ['api_broker/OfficeOrderLog/getCommission', ['method' => 'GET|POST']],
'isShowAdjustment' => ['api_broker/OfficeOrderLog/isShowAdjustment', ['method' => 'GET|POST']], 'isShowAdjustment' => ['api_broker/OfficeOrderLog/isShowAdjustment', ['method' => 'GET|POST']],
'addBargain' => ['api_broker/OfficeOrderLog/addBargain', ['method' => 'post']], //新增成交报告佣金(分佣提成) 'addBargain' => ['api_broker/OfficeOrderLog/addBargain', ['method' => 'post']], //新增成交报告佣金(分佣提成)
'houseEdit' => ['api_broker/OfficeRoom/edit', ['method' => 'POST']],//楼盘字典新增和编辑
]); ]);
Route::group('office_index', [ Route::group('office_index', [
......
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