Commit 0300a070 authored by hujun's avatar hujun

修改

parent bb241087
...@@ -56,8 +56,7 @@ class OfficeRoom extends Basic ...@@ -56,8 +56,7 @@ class OfficeRoom extends Basic
$data = $this->service->edit($this->params, $this->agentId, $this->siteId); $data = $this->service->edit($this->params, $this->agentId, $this->siteId);
if ($data['status'] == 'successful') { if ($data['status'] == 'successful') {
$result_data['room_id'] = $data['data']['room_id']; $result_data['house_id'] = $data['data']['house_id'];
$result_data['title'] = $data['data']['title'];
$result['msg'] = '新增或编辑成功'; $result['msg'] = '新增或编辑成功';
} else { } else {
$result['code'] = 101; $result['code'] = 101;
......
...@@ -17,9 +17,9 @@ class OfficeManage extends Basic ...@@ -17,9 +17,9 @@ class OfficeManage extends Basic
{ {
private $service; private $service;
public function __construct(?Request $request = null) public function __construct()
{ {
parent::__construct($request); parent::__construct();
$this->service = new OfficeService(); $this->service = new OfficeService();
} }
...@@ -90,7 +90,7 @@ class OfficeManage extends Basic ...@@ -90,7 +90,7 @@ class OfficeManage extends Basic
{ {
$msg = ''; $msg = '';
$code = 200; $code = 200;
$result = $this->service->delHouseFile($this->params['id'], $this->params['building_id'], 2); $result = $this->service->delHouseFile($this->params['id'], $this->params['house_id'], $this->params['type']);
if ($result['status'] == 'fail') { if ($result['status'] == 'fail') {
$code = 101; $code = 101;
$msg = '删除失败'; $msg = '删除失败';
......
<?php
/**
* Created by PhpStorm.
* User: HuJun
* Date: 2019/5/30
* Time: 10:11
*/
namespace app\index\controller;
use app\api_broker\extend\Basic;
use app\index\service\OfficeRoomService;
class OfficeRoom extends Basic
{
private $service;
public function __construct()
{
parent::__construct();
$this->service = new OfficeRoomService();
}
/**
* 新增和编辑商铺
*
* @return \think\Response
*/
public function edit()
{
$result['code'] = 200;
$result['msg'] = '';
$result_data = [];
if ($this->request->isPost()) {
$data = $this->service->edit($this->params, $this->agentId, $this->siteId);
if ($data['status'] == 'successful') {
$result_data['house_id'] = $data['data']['house_id'];
$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($result['code'], $result['msg'], $result_data);
}
}
\ No newline at end of file
...@@ -70,7 +70,8 @@ class OfficeRoomService ...@@ -70,7 +70,8 @@ class OfficeRoomService
if ($id > 0) { if ($id > 0) {
$remark = ''; $remark = '';
/*房东手机号处理 start*/ /*房东手机号处理 start*/
if (!empty($landlord_phone_new)) { if (!empty($data['landlord_phone'])) {
$landlord_phone_new = json_decode($data['landlord_phone'], true);
$landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $data['id']); $landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $data['id']);
if (!empty($landlord_phone_old)) { if (!empty($landlord_phone_old)) {
...@@ -181,7 +182,6 @@ class OfficeRoomService ...@@ -181,7 +182,6 @@ class OfficeRoomService
$result['status'] = 'successful'; $result['status'] = 'successful';
$result['data']['house_id'] = $id; $result['data']['house_id'] = $id;
$result['data']['title'] = $data['title'];
} else { } else {
$result['msg'] = '新增或编辑失败!'; $result['msg'] = '新增或编辑失败!';
} }
...@@ -209,8 +209,8 @@ class OfficeRoomService ...@@ -209,8 +209,8 @@ class OfficeRoomService
} }
try { try {
$field = 'id,title,address,province,city,disc,business_district_id,type,floor_total,longitude,latitude,intro'; $field = 'id,building_id,is_show,province,city,disc,business_district_id,type,floor_total,longitude,latitude,intro';
$data = $this->m_office->getFindData($field, ['id' => $id]); $data = $this->m_office_room->getFindData($field, ['id' => $id]);
if ($result) { if ($result) {
...@@ -256,7 +256,7 @@ class OfficeRoomService ...@@ -256,7 +256,7 @@ class OfficeRoomService
* 删除图片 * 删除图片
* *
* @param $id * @param $id
* @param $building_id * @param $house_id
* @param $img_status * @param $img_status
* @return mixed * @return mixed
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
...@@ -273,7 +273,7 @@ class OfficeRoomService ...@@ -273,7 +273,7 @@ class OfficeRoomService
return $data; return $data;
} }
$where['house_id'] = $id; $where['house_id'] = $house_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);
...@@ -380,7 +380,7 @@ class OfficeRoomService ...@@ -380,7 +380,7 @@ class OfficeRoomService
$result['status'] = 'successful'; $result['status'] = 'successful';
}catch (\Exception $e) { }catch (\Exception $e) {
$result['status'] = 'fail'; $result['status'] = 'fail';
$result['msg'] = '经纪人id字符串为空'; $result['msg'] = $e->getMessage();
} }
return $result; return $result;
} }
...@@ -431,7 +431,7 @@ class OfficeRoomService ...@@ -431,7 +431,7 @@ class OfficeRoomService
$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 = $m_landlord->getColumn('id,phone', ['house_id'=>$house_id, 'status'=>0]); $old_landlord = $m_landlord->getColumn('id,phone', ['house_id'=>$house_id]);
if (empty($old_landlord)) { if (empty($old_landlord)) {
//新增 //新增
...@@ -457,23 +457,7 @@ class OfficeRoomService ...@@ -457,23 +457,7 @@ class OfficeRoomService
} }
} }
} else { } else {
//v3.2.1 之后去除update_data if (!in_array($v['phone'], $old_landlord)) {
$id = array_search($v['phone'], $old_landlord);
if ($id) {
$update_data[$key]['id'] = $id;
$update_data[$key]['phone'] = $v['phone'];
$update_data[$key]['house_id'] = $house_id;
$update_data[$key]['name'] = $v['name'];
$phone = $old_landlord[$v['id']];
if (!empty($phone)) {
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;
}
}
} else {
$insert_data[$key]['phone'] = $v['phone']; $insert_data[$key]['phone'] = $v['phone'];
$insert_data[$key]['house_id'] = $house_id; $insert_data[$key]['house_id'] = $house_id;
$insert_data[$key]['name'] = $v['name']; $insert_data[$key]['name'] = $v['name'];
...@@ -487,7 +471,7 @@ class OfficeRoomService ...@@ -487,7 +471,7 @@ class OfficeRoomService
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]['status'] = 1; $update_data[$key]['is_del'] = 1;
$key++; $key++;
$edit_phone[] = '删除房东手机号:'.substr_replace($v2, '****', 3, 4) ; $edit_phone[] = '删除房东手机号:'.substr_replace($v2, '****', 3, 4) ;
} }
......
...@@ -170,24 +170,34 @@ class OfficeService ...@@ -170,24 +170,34 @@ class OfficeService
* 删除图片 * 删除图片
* *
* @param $id * @param $id
* @param $building_id * @param $house_id
* @param $img_status * @param $img_status
* @return mixed * @return mixed
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @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'] = '';
if (empty($id) || empty($building_id)) { if (empty($id) || empty($house_id)) {
$data['msg'] = '参数错误'; $data['msg'] = '参数错误';
return $data; return $data;
} }
$where['house_id'] = $building_id; if (empty($house_id)) {
$data['msg'] = '参数错误';
return $data;
}
if (empty($img_status)) {
$data['msg'] = '参数错误';
return $data;
}
$where['house_id'] = $house_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);
......
...@@ -39,6 +39,8 @@ class OfficeBuildingRoomValidate extends Validate ...@@ -39,6 +39,8 @@ class OfficeBuildingRoomValidate extends Validate
'is_show' => 'require|in:0,1', 'is_show' => 'require|in:0,1',
'decoration' => 'require|in:1,2,3,4', 'decoration' => 'require|in:1,2,3,4',
'shop_sign' => 'require|length:1,255', 'shop_sign' => 'require|length:1,255',
'landlord_phone'=>'require',
'agent_dish'=>'require'
]; ];
protected $message = [ protected $message = [
...@@ -89,6 +91,8 @@ class OfficeBuildingRoomValidate extends Validate ...@@ -89,6 +91,8 @@ class OfficeBuildingRoomValidate extends Validate
'decoration.between'=>'交付装修参数错误', 'decoration.between'=>'交付装修参数错误',
'shop_sign.require' => '商铺标签为必填', 'shop_sign.require' => '商铺标签为必填',
'shop_sign.length' => '商铺标签参数错误', 'shop_sign.length' => '商铺标签参数错误',
'landlord_phone.require' => '房东手机号必填',
'agent_dish.require' => '盘方必填',
]; ];
protected $scene = [ protected $scene = [
......
...@@ -85,28 +85,36 @@ class OfficeGLandlordPhone extends BaseModel ...@@ -85,28 +85,36 @@ class OfficeGLandlordPhone extends BaseModel
*/ */
public function updateDataAll($data) public function updateDataAll($data)
{ {
$num = 0; $num = 0;
foreach ($data as $k=>$v) { foreach ($data as $k=>$v) {
if (empty($v['name'])) { if (empty($v['id'])) {
continue; continue;
} }
if (empty($v['phone'])) { if (isset($v['id'])) {
continue; $save_data['id'] = $v['id'];
} }
if (empty($v['room_id'])) { if (isset($v['name'])) {
continue; $save_data['name'] = $v['name'];
} }
if (isset($v['id'])) { if (isset($v['phone'])) {
$save_data['id'] = $v['id']; $save_data['phone'] = $v['phone'];
}
if (isset($v['house_id'])) {
$save_data['house_id'] = $v['house_id'];
} }
$save_data['name'] = $v['name']; if (isset($v['is_del'])) {
$save_data['phone'] = $v['phone']; $save_data['is_del'] = $v['is_del'];
$save_data['room_id'] = $v['room_id']; }
$num += $this->db_->update($data);
if (isset($save_data)) {
$num += $this->db_->update($save_data);
}
} }
return $num; return $num;
} }
...@@ -125,6 +133,7 @@ class OfficeGLandlordPhone extends BaseModel ...@@ -125,6 +133,7 @@ class OfficeGLandlordPhone extends BaseModel
* @return array * @return array
*/ */
public function getColumn($field, $where) { public function getColumn($field, $where) {
$where['is_del'] = 0;
return $this->db_->where($where) return $this->db_->where($where)
->column($field); ->column($field);
} }
......
...@@ -17,19 +17,19 @@ class OfficeGOperatingRecord extends BaseModel ...@@ -17,19 +17,19 @@ class OfficeGOperatingRecord extends BaseModel
/** /**
* 日志 * 日志
* *
* @param int $agents_id * @param int agent_id
* @param string $type * @param string $type
* @param string $remark * @param string $remark
* @param string $room_id * @param string $house_id
* @param int $user_id * @param int $user_id
* @return bool|false|int * @return bool|false|int
* User HuJun * User HuJun
* Date 19-5-30 下午8:44 * Date 19-5-30 下午8:44
*/ */
public function record($agents_id = 0, $type = '', $remark = '', $room_id = '', $user_id = 0) public function record($agent_id = 0, $type = '', $remark = '', $house_id = '', $user_id = 0)
{ {
$result = false; $result = false;
$agents_id = $agents_id ? $agents_id : Session::get('userId'); $agents_id = $agent_id ? $agent_id : Session::get('userId');
if ($agents_id > 0) { if ($agents_id > 0) {
$request = Request::instance(); $request = Request::instance();
$name = Session::get('userName'); $name = Session::get('userName');
...@@ -38,12 +38,12 @@ class OfficeGOperatingRecord extends BaseModel ...@@ -38,12 +38,12 @@ class OfficeGOperatingRecord extends BaseModel
} }
$data = [ $data = [
'agents_id' => $agents_id, 'agent_id' => $agent_id,
'name' => $name, 'name' => $name,
'url' => $request->url(), 'url' => $request->url(),
'ip' => $request->ip(), 'ip' => $request->ip(),
'remark' => $remark, 'remark' => $remark,
'room_id' => $room_id, 'house_id' => $house_id,
'user_id' => $user_id, 'user_id' => $user_id,
'type' => $type, 'type' => $type,
'create_time' => date('Y-m-d H:i:s'), 'create_time' => date('Y-m-d H:i:s'),
......
...@@ -89,26 +89,30 @@ class OfficeGRoomToAgent extends BaseModel ...@@ -89,26 +89,30 @@ class OfficeGRoomToAgent extends BaseModel
{ {
$num = 0; $num = 0;
foreach ($data as $k=>$v) { foreach ($data as $k=>$v) {
if (empty($v['type'])) { if (isset($v['agent_id'])) {
continue; $save_data['agent_id'] = $v['agent_id'];
} }
if (empty($v['agent_id'])) { if (isset($v['house_id'])) {
continue; $save_data['house_id'] = $v['house_id'];
} }
if (empty($v['room_id'])) { if (isset($v['type'])) {
continue; $save_data['type'] = $v['type'];
} }
if (isset($v['id'])) { if (isset($v['is_del'])) {
$save_data['id'] = $v['id']; $save_data['is_del'] = $v['is_del'];
} }
$save_data['name'] = $v['name']; if (isset($save_data)) {
$save_data['phone'] = $v['phone']; if (isset($v['id'])) {
$save_data['room_id'] = $v['room_id']; $save_data['id'] = $v['id'];
$num += $this->db_->update($data); $num += $this->db_->update($save_data);
} else {
$num += $this->db_->insert($save_data);
}
}
} }
return $num; return $num;
} }
...@@ -128,7 +132,7 @@ class OfficeGRoomToAgent extends BaseModel ...@@ -128,7 +132,7 @@ class OfficeGRoomToAgent extends BaseModel
$params['a.is_del'] = 0; $params['a.is_del'] = 0;
return $this->field($field) return $this->field($field)
->alias("a") ->alias("a")
->join("a_agents b", "a.agents_id = b.id", "left") ->join("a_agents b", "a.agent_id = b.id", "left")
->where($params) ->where($params)
->select(); ->select();
} }
......
...@@ -963,12 +963,15 @@ Route::group('office', [ ...@@ -963,12 +963,15 @@ 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']],//楼盘字典新增和编辑 'houseEdit' => ['api_broker/OfficeRoom/edit', ['method' => 'POST']],//楼盘字典新增和编辑
'delHouseFile' => ['index/OfficeRoom/delHouseFile', ['method' => 'POST']],//删除楼盘图片
]); ]);
Route::group('office_index', [ Route::group('office_index', [
'houseAdd' => ['index/OfficeManage/add', ['method' => 'GET|POST']],//楼盘字典新增 'houseDictionaryAdd' => ['index/OfficeManage/add', ['method' => 'GET|POST']],//楼盘字典新增
'houseEdit' => ['index/OfficeManage/edit', ['method' => 'GET|POST']],//楼盘字典编辑 'houseDictionaryEdit' => ['index/OfficeManage/edit', ['method' => 'GET|POST']],//楼盘字典编辑
'delHouseFile' => ['index/OfficeManage/delHouseFile', ['method' => 'POST']],//删除楼盘图片 'delHouseFile' => ['index/OfficeManage/delHouseFile', ['method' => 'POST']],//删除楼盘图片
'delHouseFile' => ['index/OfficeManage/delHouseFile', ['method' => 'POST']],//删除楼盘图片
]); ]);
//Route::miss('api/index/miss');//处理错误的url //Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
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