Commit a24b427c authored by hujun's avatar hujun

all

parent b1dba3b5
......@@ -9,9 +9,15 @@
namespace app\index\service;
use app\api_broker\service\PushMessageService;
use app\index\validate\OfficeBuildingRoomValidate;
use app\model\AAgents;
use app\model\OfficeGBuildingImg;
use app\model\OfficeGLandlordPhone;
use app\model\OfficeGOperatingRecord;
use app\model\OfficeGRoom;
use app\model\OfficeGRoomToAgent;
use app\task\controller\ResultsSummaryNewTask;
class OfficeRoomService
{
......@@ -19,25 +25,33 @@ class OfficeRoomService
private $m_office_room;
private $m_office_img;
private $m_building_stations;
private $push;
private $agent;
private $agent_room;
public function __construct()
{
$this->validate = new OfficeBuildingRoomValidate();
$this->m_office_room = new OfficeGRoom();
$this->m_office_img = new OfficeGBuildingImg();
$this->push = new PushMessageService();
$this->agent = new AAgents();
$this->agent_room = new OfficeGRoomToAgent();
}
/**
* 新增或编辑楼盘
*
* @param array $data
* @param int $agent_id 上传人id
* @param int $agent_id 上传人id
* @param int $site_id
* @return mixed
*/
public function edit(array $data, int $agent_id = 0) {
public function edit(array $data, int $agent_id, $site_id)
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$result['msg'] = '';
$result['data'] = [];
if (isset($data['id'])) {
$scene = 'edit';
......@@ -54,28 +68,116 @@ class OfficeRoomService
$id = $this->m_office_room->addRoom($data, $agent_id);
if ($id > 0) {
$remark = '';
/*房东手机号处理 start*/
if (!empty($landlord_phone_new)) {
$landlord_phone_old = $this->landlordPhoneEditV2($landlord_phone_new, $data['id']);
if (!empty($landlord_phone_old)) {
$remark .= implode(',', $landlord_phone_old).',';
}
}
/*房东手机号处理 end*/
/*楼盘与经纪人关系处理 start*/
//案场权限人
if (!empty($data['agent_data'])) {
$result_agent_data = $this->releaseRelationshipV2($data['agent_data'], $id, 1, $agent_id, $data['internal_title'], $site_id);
if ($result_agent_data['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑案场权限人失败,' . $result_agent_data['msg'];
return $result;
}
}
//盘方
if (!empty($data['agent_dish'])) {
$result_agent_dish = $this->releaseRelationshipV2($data['agent_dish'], $id, 2, $agent_id, $data['internal_title'], $site_id);
if ($result_agent_dish['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑盘方失败,' . $result_agent_dish['msg'];
return $result;
}
}
//独家方
if (empty($data['exclusive_ids'])) {
$this->delAgentHouse(3, $data['id'], 0);
unset($data['exclusive_ids']);
} else {
$result_exclusive_ids = $this->releaseRelationshipV2($data['exclusive_ids'], $id, 3, $agent_id, $data['internal_title'], $site_id);
if ($result_exclusive_ids['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑独家方失败,' . $result_exclusive_ids['msg'];
return $result;
}
}
/*楼盘与经纪人关系处理 end*/
/*图片处理 start*/
if (!empty($data['cover'])) {
$data['cover'] = json_decode($data['cover'], true);
foreach ($data['cover'] as $k=>$v) {
foreach ($data['cover'] as $k => $v) {
$data['cover'][$k] = stripslashes($v);
}
}
if (!empty($data['slide_show'])) {
$data['slide_show'] = json_decode($data['slide_show'], true);
foreach ($data['slide_show'] as $k=>$v) {
foreach ($data['slide_show'] as $k => $v) {
$data['slide_show'][$k] = stripslashes($v);
}
}
if (!empty($data['exclusive_img'])) {
$data['exclusive_img'] = json_decode($data['exclusive_img'], true);
foreach ($data['exclusive_img'] as $k=>$v) {
foreach ($data['exclusive_img'] as $k => $v) {
$data['exclusive_img'][$k] = stripslashes($v);
}
}
if (!empty($data['cover'])) {
$image_result = $this->m_office_img->edit($data['cover'], $id, 1);
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑主图图片失败,' . $image_result['msg'];
return $result;
}
}
if (!empty($data['slide_show'])) {
$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'];
return $result;
}
}
if (!empty($data['plan'])) {
$image_result = $this->m_office_img->edit($data['plan'], $id, 3);
if ($image_result['status'] == 'fail') {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑楼盘图片失败,' . $image_result['msg'];
return $result;
}
}
if (!empty($data['exclusive_img'])) {
$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'];
return $result;
}
}
/*图片处理 end*/
$result['status'] = 'successful';
if (!empty($remark)) {
$m_operating = new OfficeGOperatingRecord();
$m_operating->record($agent_id, 2, $remark, $data['id']);
}
} else {
$result['msg'] = '新增或编辑失败!';
}
......@@ -92,9 +194,9 @@ class OfficeRoomService
public function getOfficeRoomDetail(int $id, $app = 0)
{
$result['status'] = 'fail';
$result['msg'] = '';
$result['msg'] = '';
$check_data['id'] = $id;
$data['slide_show'] = $data['plan'] = $data['exclusive_img'] = [];
$data['slide_show'] = $data['plan'] = $data['exclusive_img'] = [];
$check = $this->validate->scene('detail')->check($check_data);
if (false === $check) {
......@@ -104,15 +206,15 @@ 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]);
$data = $this->m_office->getFindData($field, ['id' => $id]);
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', ['building_id' => $id, 'img_type' => 0]);
if ($app == 0) {
foreach ($img_data as $k => $v) {
$data['building_images'][$k]['img_name'] = $v['img_name'];
$data['building_images'][$k]['id'] = $v['id'];
$data['building_images'][$k]['id'] = $v['id'];
}
} else {
$file_url = [];
......@@ -132,10 +234,10 @@ class OfficeRoomService
// }
$field_stations = 'a.id,b.line_name,name,distance,b.id as stations_id';
$data['building_stations'] = $this->m_building_stations->getListAll($field_stations, ['a.building_id'=>$id]);
$data['building_stations'] = $this->m_building_stations->getListAll($field_stations, ['a.building_id' => $id]);
}
$result['data'] = $data;
$result['data'] = $data;
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['msg'] = $e->getMessage();
......@@ -182,4 +284,220 @@ class OfficeRoomService
return $data;
}
/**
* 处理楼盘与经纪人关系
*
* @param $agent_id_string
* @param $house_id
* @param $type
* @param $operation_id
* @param $house_title
* @param $site_id
* @return mixed
*/
public function releaseRelationshipV2($agent_id_string, $house_id, $type, $operation_id, $house_title, $site_id)
{
if (empty($agent_id_string)) {
$result['status'] = 'fail';
$result['msg'] = '经纪人id字符串为空';
return $result;
}
try {
$records = new OfficeGOperatingRecord();
$save_data = $del_agent_name = $del_agent_id = [];
$agent_id_arr = array_unique(explode(',', $agent_id_string));
$agent_room_where['a.is_del'] = 0;
$agent_room_where['a.houses_id'] = $house_id;
$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);
foreach ($agent_data_old as $k=>$v) {
if (in_array($v['agents_id'], $agent_id_arr)) {
$key = array_search($v['agents_id'], $agent_id_arr);
if ($key !== false) {
unset($agent_id_arr[$key]);
}
} else {
$save_data['is_del'] = 1;
$this->agent_room->updateData($save_data, ['id'=>$v['id']]);
$del_agent_name[] = $v['name'];
$del_agent_id[] = $v['agents_id'];
}
}
foreach ($agent_id_arr as $kay=>$val) {
if ((int)$val > 0) {
$add_agent_data[$kay]['agent_id'] = $val;
$add_agent_data[$kay]['room_id'] = $house_id;
$add_agent_data[$kay]['type'] = $type;
}
}
if (isset($add_agent_data)) {
$this->agent_room->insertAll($add_agent_data);
}
if ($type == 2) {
$sum = new ResultsSummaryNewTask();
//记录
$remark = '';
if ($del_agent_name) {
$remark .= '删除盘方:' . implode(',', $del_agent_name) . ',';
}
if ($agent_id_arr) {
$agent_name = $this->agent->getAgentsByWhereColumn(['id' => ['in', $agent_id_arr]], 'name');
$remark .= '新增盘方:' . implode(',', $agent_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);
$date = date('Y-m-d');
foreach ($agent_id_arr as $v3) {
$agent_data = $this->agent->verifyUser('id,store_id,district_id,name', '', ['id' => $v3]); //新增人信息
$sum->updateTotalByAgentId($agent_data['id'], $agent_data['store_id'], $agent_data['district_id'], $date, $site_id);
}
foreach ($del_agent_id as $v4) {
$agent_data = $this->agent->verifyUser('id,store_id,district_id,name', '', ['id' => $v4]); //被删除人信息
$sum->updateTotalByAgentId($agent_data['id'], $agent_data['store_id'], $agent_data['district_id'], $date, $site_id);
}
}
if (!empty($remark)) {
$records->record($operation_id, 2, $remark, $house_id);
}
}
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['status'] = 'fail';
$result['msg'] = '经纪人id字符串为空';
}
return $result;
}
/**
* 删除经纪人与楼盘关系
*
* @param $type
* @param $room_id
* @param int $id_edit
* @return bool|int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
* User HuJun
* Date 19-5-30 下午9:01
*/
public function delAgentHouse($type, $room_id, $id_edit = 1) {
if (empty($type) || empty($house_id)) {
return false;
}
$id = $this->m_office_room->getTotal(['id'=>$room_id,'is_exclusive_type'=>1]);
if (empty($id)) {
return false;
}
$where['room_id'] = $room_id;
$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], $room_id);
}
return $is_ok;
}
/**
* 房东手机号处理
*
* @param array $data
* @param $house_id
* @return array 删除的手机号
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function landlordPhoneEditV2(array $data, $house_id) {
$m_landlord = new OfficeGLandlordPhone();
$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]);
if (empty($old_landlord)) {
//新增
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);
}
} else {
//新增与编辑
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'];
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 {
//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 {
$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']];
}
}
$new_phone[] = $v['phone'];
$key++;
}
foreach ($old_landlord as $k2=>$v2) {
if (!in_array($v2, $new_phone)) {
$update_data[$key]['id'] = $k2;
$update_data[$key]['status'] = 1;
$key++;
$edit_phone[] = '删除房东手机号:'.substr_replace($v2, '****', 3, 4) ;
}
}
}
if ($update_data) {
$m_landlord->updateData($update_data);
}
if ($insert_data) {
$m_landlord->insertData($insert_data);
}
return $edit_phone;
}
}
\ No newline at end of file
......@@ -15,51 +15,89 @@ class OfficeBuildingRoomValidate extends Validate
{
protected $rule = [
'id' => 'require|between: 1,99999999999',
'upload_id' => 'require|between: 1,99999999999',
'title' => 'require|length:1,125',
'address' => 'require|length:1,125',
'province' => 'require|length:1,60',
'city' => 'require|length:1,60',
'disc' => 'require|length:1,60',
'type' => 'require',
'status' => 'require|in:[0,1,2]',
'floor_total' => 'require|between:0,9999999999',
'longitude' => 'require|min:1',
'latitude' => 'require|min:1',
'business_district_id' => 'require|between: 1,99999999999',
'intro'=>'require|length:1,255'
'floor' => 'require|between: 1,99999',
'room_number' => 'require|length:1,50',
'is_rent' => 'require|in:0,1',
'is_exclusive_type' => 'require|in:0,1',
'price_total' => 'require|between: 1,99999999',
'price' => 'require|between: 1,99999999',
'slotting_fee' => 'require|between: 1,99999999',
'management_fee' => 'require|between: 1,99999999',
'station_start' => 'require|between: 1,99999',
'station_end' => 'require|between: 1,99999',
'area' => 'require|between: 1,99999',
'floor_tag' => 'require|in:1,2,3',
'enter_time' => 'require',
'payment_month' => 'require|between:1,12',
'deposit_month' => 'require|between:1,12',
'age_limit_start' => 'require|between:1,12',
'age_limit_end' => 'require|between:1,12',
'is_partition' => 'is_partition|in:0,1',
'carport' => 'require|length:1,255',
'rent_free' => 'require|length:-1,99',
'source' => 'require|in:0,1,2,3,4,5,6,7',
'is_show' => 'require|in:0,1',
'decoration' => 'require|in:1,2,3,4',
'shop_sign' => 'require|length:1,255',
];
protected $message = [
'title.require' => '对内楼盘名为必填',
'title.length' => '名称字数在1至125个字',
'address.require' => '楼盘地址为必填',
'address.length' => '地址要在1至255个字',
'province.require' => '省份为必填',
'province.length' => '省份要在1至60个字',
'city.require' => '市为必填',
'city.length' => '对内地址要在1至60个字',
'disc.require' => '区为必填',
'disc.length' => '对内地址要在1至60个字',
'longitude.require' => '无法获取楼盘坐标,请重新修改地址',
'longitude.min' => '楼盘坐标参数错误',
'latitude.require' => '无法获取楼盘坐标,请重新修改地址',
'latitude.min' => '楼盘坐标参数错误',
'business_district_id.require' => '楼盘必选',
'business_district_id.between' => '楼盘参数错误',
'id.require' => '楼盘id必传',
'id.between' => '楼盘id错误',
'upload_id.require' => '上传人id必传',
'upload_id.between' => '上传人id错误',
'intro.require'=>'楼盘简介必填',
'intro.length'=>'楼盘简介要做1至255个字'
'floor.require' => '所在楼层必填',
'floor.between' => '所在楼层参数错误',
'room_number.require' => '门牌号为必填',
'room_number.length' => '门牌号要在1至50个字',
'is_rent.require'=>'房源状态必选',
'is_rent.in'=>'房源状态参数错误',
'is_exclusive_type.require'=>'是否独家必选',
'is_exclusive_type.in'=>'是否独家参数错误',
'price_total.require'=>'租金总价必填',
'price_total.between'=>'租金总价必填',
'price.require'=>'租金单价必填',
'price.between'=>'租金单价参数错误',
'slotting_fee.require'=>'转让费必填',
'slotting_fee.between'=>'转让费参数错误',
'management_fee.require'=>'物业管理费必填',
'management_fee.between'=>'物业管理费参数错误',
'station_start.require'=>'可容纳工位开始必填',
'station_start.between'=>'可容纳工位开始参数错误',
'station_end.require'=>'可容纳工位结束必填',
'station_end.between'=>'可容纳工位结束参数错误',
'area.require'=>'可面积必填',
'area.between'=>'面积参数错误',
'floor_tag.require'=>'所属楼层必填',
'floor_tag.in'=>'所属楼层参数错误',
'enter_time.require'=>'入住时间必填',
'payment_month.require'=>'付款规则开始必填',
'payment_month.between'=>'付款规则开始参数错误',
'deposit_month.require'=>'付款规则结束必填',
'deposit_month.between'=>'付款规则结束参数错误',
'age_limit_start.require'=>'签约年限开始必填',
'age_limit_start.between'=>'签约年限开始参数错误',
'age_limit_end.require'=>'签约年限结束必填',
'age_limit_end.between'=>'签约年限结束参数错误',
'is_partition.require'=>'是否可分割必填',
'is_partition.in'=>'是否可分割参数错误',
'carport.require' => '车位请况为必填',
'carport.length' => '车位请况要在1至255个字',
'rent_free.require' => '免租时间为必填',
'rent_free.length' => '免租时间要在1至99个字',
'source.require' => '来源为必填',
'source.length' => '来源参数错误',
'is_show.require'=>'是否对客户展示必填',
'is_show.between'=>'是否对客户展示参数错误',
'decoration.require'=>'交付装修必填',
'decoration.between'=>'交付装修参数错误',
'shop_sign.require' => '商铺标签为必填',
'shop_sign.length' => '商铺标签参数错误',
];
protected $scene = [
'add' => ['title','address','province','city','disc','type','floor_total','longitude','latitude',
'business_district_id','upload_id','intro'],
'edit' => ['id','title','address','province','city','disc','type','floor_total','longitude','latitude',
'business_district_id','intro'],
'add' => ['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','is_show','decoration','shop_sign'],
'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','is_show','decoration','shop_sign'],
'detail' => ['id']
];
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ class OfficeBuildingValidate extends Validate
'city' => 'require|length:1,60',
'disc' => 'require|length:1,60',
'type' => 'require',
'status' => 'require|in:[0,1,2]',
'status' => 'require|in:0,1,2',
'floor_total' => 'require|between:0,9999999999',
'longitude' => 'require|min:1',
'latitude' => 'require|min:1',
......
<?php
namespace app\model;
use think\Db;
class OfficeGLandlordPhone extends BaseModel
{
protected $table = 'office_g_landlord_phone';
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* @param $name
* @param $room_id
* @param $phone
* @param $id
* @return bool|int
* User HuJun
* Date 19-5-30 下午9:04
*/
public function add($name, $room_id, $phone, $id = 0)
{
$save_data = [];
if (empty($name)) {
return false;
}
if (empty($room_id)) {
return false;
}
if (empty($phone)) {
return false;
}
$save_data['name'] = $name;
$save_data['room_id'] = $room_id;
$save_data['phone'] = $phone;
if ($id) {
$save_data['create_time'] = date('Y-m-d H:i:s');
$id = $this->insertGetId($save_data);
} else {
try {
$save_data['update_time'] = date('Y-m-d H:i:s');
$this->where('id', $id)->update($save_data);
$id = $id;
} catch (\Exception $e) {
$id = 0;
}
}
return (int)$id;
}
/**
* @param $data
* @param $where
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
* User HuJun
* Date 19-5-30 下午8:49
*/
public function updateData($data, $where)
{
return $this->db_->where($where)->update($data);
}
/**
* @param $data
* @return int|string
*/
public function insertData($data){
return $this->db_->insertAll($data);
}
/**
* @param $field
* @param $where
* @return array
*/
public function getColumn($field, $where) {
return $this->db_->where($where)
->column($field);
}
}
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/1/20
* Time: 17:52
*/
namespace app\model;
use think\Request;
use think\Session;
class OfficeGOperatingRecord extends BaseModel
{
/**
* 日志
*
* @param int $agents_id
* @param string $type
* @param string $remark
* @param string $room_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)
{
$result = false;
$agents_id = $agents_id ? $agents_id : Session::get('userId');
if ($agents_id > 0) {
$request = Request::instance();
$name = Session::get('userName');
if (empty($name)) {
$name = db('a_agents')->where('id', $agents_id)->value('name');
}
$data = [
'agents_id' => $agents_id,
'name' => $name,
'url' => $request->url(),
'ip' => $request->ip(),
'remark' => $remark,
'room_id' => $room_id,
'user_id' => $user_id,
'type' => $type,
'create_time' => date('Y-m-d H:i:s'),
];
$result = $this->isUpdate(false)->data($data)->save();
}
return $result;
}
/**
* @param $param
* @return array|false|\PDOStatement|string|\think\Collection
* User HuJun
* Date 19-5-30 下午8:44
*/
public function user_history($param)
{
if (empty($param['user_id'])) {
return [];
}
try {
$data = $this->field('name,remark,create_time,user_id')
->where($param)
->order('create_time', 'desc')
->select();
} catch (\Exception $e) {
$data = [];
}
return $data;
}
/**
* @param $pageNo
* @param $pageSize
* @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-30 下午8:44
*/
public function getRecordsList($pageNo, $pageSize, $field, $params)
{
$order = "OperatingRecords.create_time desc";
return $this->field($field)
->alias('OperatingRecords')
->where($params)
->limit($pageSize)
->page($pageNo)
->order($order)
->select();
}
/**
* @param $field
* @param $params
* @return int|string
* User HuJun
* Date 19-5-30 下午8:44
*/
public function getRecordsListTotal($field, $params)
{
return $this->field($field)
->alias('OperatingRecords')
->where($params)
->count();
}
}
\ No newline at end of file
......@@ -168,7 +168,6 @@ class OfficeGRoom extends BaseModel
$save_data['shop_sign'] = $data['shop_sign'];
}
if (empty($data['id'])) {
$save_data['operation_id'] = $agent_id; //上传人
$save_data['create_time'] = date('Y-m-d H:i:s');
......
<?php
namespace app\model;
use think\Db;
class OfficeGRoomToAgent extends BaseModel
{
protected $table = 'office_g_room_to_agent';
private $db_;
public function __construct($data = [])
{
parent::__construct($data);
$this->db_ = Db::name($this->table);
}
/**
* 新增和编辑办公楼与经纪人关系
*
* @param array $data
* @return int|mixed|string
*/
public function add(array $data)
{
$save_data = [];
if (isset($data['agent_id'])) {
$save_data['agent_id'] = (int)$data['agent_id'];
}
if (isset($data['room_id'])) {
$save_data['room_id'] = (int)$data['room_id'];
}
if (isset($data['room_id'])) {
$save_data['room_id'] = (int)$data['room_id'];
}
if (empty($data['id'])) {
$save_data['create_time'] = date('Y-m-d H:i:s');
$room_id = $this->insertGetId($save_data);
} else {
try {
$save_data['update_time'] = date('Y-m-d H:i:s');
$this->where('id', $data['id'])->update($save_data);
$room_id = $data['id'];
} catch (\Exception $e) {
$room_id = 0;
}
}
return (int)$room_id;
}
/**
* @param $data
* @param $where
* @return int|string
* @throws \think\Exception
* @throws \think\exception\PDOException
* User HuJun
* Date 19-5-30 下午8:49
*/
public function updateData($data, $where)
{
return $this->db_->where($where)->update($data);
}
/**
* @param $data
* @return int|string
*/
public function insertData($data){
return $this->db_->insertAll($data);
}
}
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