Commit 0300a070 authored by hujun's avatar hujun

修改

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