Commit 84f09094 authored by hujun's avatar hujun

暂存

parent e22891d2
......@@ -12,6 +12,7 @@ namespace app\index\controller;
use app\api_broker\service\LookShopService;
use app\api_broker\service\PushMessageService;
use app\index\extend\Basic;
use app\index\service\HouseService;
use app\index\validate\HouseValidate;
use app\model\AAgents;
use app\model\ACollectHouse;
......@@ -112,6 +113,71 @@ class Houses extends Basic
return $return;
}
/**
* 新增和编辑商铺
*
* @return \think\Response|\think\response\View
*/
public function editV2()
{
$result['code'] = 200;
$result['msg'] = $return = '';
if ($this->request->isPost()) {
$house = new HouseService();
$house_id = $house->addHouse($this->params, $this->userId);
if (!empty($this->params['sublet_id']) && $this->params['source'] == 'transfer_list') {
$m_sublet = new SubletModel();
$sublet_data['house_id'] = $house_id;
$sublet_data['status'] = 2;
$sublet_data['agents_id'] = $this->userId;
$m_sublet->editData($sublet_data, $this->params['sublet_id']);
}
//编辑商铺
} elseif ($this->params['id']) {
if ($this->request->isAjax()) {
//获取商铺详情
try {
$house = new GHouses();
$result['data'] = $house->getHouseById($this->params['id'], 0);
} catch (\Exception $e) {
$result['data'] = [];
$result['code'] = 101;
$result['msg'] = '获取商铺信息失败';
}
$return = $this->response($result['code'], $result['msg'], $result['data']);
} else {
//商铺添加页面
$return = view('edit');
}
//转铺页面跳转过来的
} elseif (isset($this->params['source']) && $this->params['source'] == 'transfer_list') {
if ($this->request->isAjax()) {
try {
$sublet = new SubletModel();
$result['data'] = $sublet->getSubletHouse($this->params['sublet_id']);
} catch (\Exception $e) {
$result['data'] = [];
$result['code'] = 101;
$result['msg'] = '获取转铺信息失败';
}
$return = $this->response($result['code'], $result['msg'], $result['data']);
} else {
//商铺添加页面
$return = view('edit');
}
} else {
//商铺添加页面
$return = view('edit');
}
return $return;
}
/**
* 楼盘列表
*
......
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/8/30
* Time: 13:13
*/
namespace app\index\service;
use app\index\validate\HouseValidate;
use app\model\AAgents;
use app\model\GHouses;
use app\model\GHousesExt;
use app\model\GHousesImgs;
use app\model\GHousesToAgents;
use app\model\GOperatingRecords;
use app\task\controller\ResultsSummaryNewTask;
class HouseService
{
protected $house;
public function __construct()
{
$this->house = new GHouses();
}
/**
* 新增或编辑商铺
*
* @param array $data
* @param int $agent_id
* @return array
*/
public function addHouse(array $data, int $agent_id) : array {
$result = [];
$validate = new HouseValidate();
$check = $validate->check($data);
if(true !== $check){
$result['status'] = 'fail';
$result['msg'] = $validate->getError();
return $result;
}
if (!empty($agent_id)) {
$result['status'] = 'fail';
$result['msg'] = '上传人id为空';
return $result;
}
$house_id = $this->house->addHouse($data, $agent_id);
if (empty($house_id)) {
$result['status'] = 'fail';
$result['msg'] = '新增或编辑商铺失败';
}
//商铺扩展字段
$houses_ext = new GHousesExt();
$houses_ext->addHouseExt($data, $house_id);
//商铺图片
$house_img = new GHousesImgs();
if ($data['id'] == '') {
$house_img->add($data, $house_id); //只记录新增图片
}
$agents = new GHousesToAgents();
//案场权限人
if (isset($data['agent_data'])) {
$agents->addHouseAgent($data['agent_data'], $house_id, 1);
}
//盘方
if (isset($data['agent_dish'])) {
$agents->addHouseAgent($data['agent_dish'], $house_id, 2);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
$m_agent = new AAgents();
$date = date('Y-m-d H:i:s');
$agent_name = [];
foreach ($data['agent_dish'] as $k=>$v) {
$agent_data = $m_agent->verifyUser('id,store_id,district_id,name', '',['id'=>$v]); //获取被修改人信息
$sum->updateTotalByAgentId($agent_data['id'], $agent_data['store_id'], $agent_data['district_id'], $date); //被修改的人
$agent_name[] = $agent_data['name'];
}
if (!empty($agent_name)) {
//记录新增盘方
$records = new GOperatingRecords();
$records->record('', 2, '新增为:' . implode(',', $agent_name), $house_id);
}
}
//独家方
if (isset($data['exclusive_ids'])) {
$agents->addHouseAgent($data['exclusive_ids'], $house_id, 3);
}
$result['data']['house_id'] = $house_id;
$result['status'] = 'successful';
$result['msg'] = '新增或编辑成功!';
return $result;
}
/**
* 删除商铺与经纪人关系
*
* @param $agent_id
* @param $house_id
* @return mixed
*/
public function updateAgentHouse($agent_id, $house_id) {
$agents = new GHousesToAgents();
$result = $agents->del($agent_id, $house_id);
if ($result) {
$data['status'] = 'successful';
$data['msg'] = '编辑成功';
} else {
$data['status'] = 'fail';
$data['msg'] = '编辑失败';
}
return $data;
}
}
\ No newline at end of file
......@@ -105,14 +105,9 @@ class AAgents extends BaseModel
return $r;
}
//删除数据
public function delUid($name, $ids)
{
$this->where($name, 'in', $ids)->delete();
}
/**通过ids批量添加数据
/**
* 通过ids批量添加数据
*
* @param $ids
* @param $data
* @return array|false|int
......
......@@ -540,6 +540,233 @@ class GHouses extends BaseModel
return $result;
}
/**
* 新增商铺
*
* @param array $data
* @param int $agent_id
* @return int|mixed|string
*/
public function addHouse(array $data, int $agent_id) {
$save_data = [];
$house_id = 0;
//楼盘名针对内部
if (isset($data['internal_title'])) {
$save_data['internal_title'] = trim($data['internal_title']);
}
//楼盘名对外
if (isset($data['external_title'])) {
$save_data['external_title'] = trim($data['external_title']);
}
//楼盘地址(对内)
if (isset($data['internal_address'])) {
$save_data['internal_address'] = trim($data['internal_address']);
}
//楼盘地址(对外)
if (isset($data['external_address'])) {
$save_data['external_address'] = trim($data['external_address']);
}
//省
if (isset($data['province'])) {
$save_data['province'] = $data['province'];
}
//市
if (isset($data['city'])) {
$save_data['city'] = $data['city'];
}
//区
if (isset($data['disc'])) {
$save_data['disc'] = $data['disc'];
}
//商圈id
if (isset($data['business_district_id'])) {
$save_data['business_district_id'] = $data['business_district_id'];
}
//商场面积
if (isset($data['market_area'])) {
$save_data['market_area'] = $data['market_area'];
}
//1.月租金 2.营业额扣点 3.每平方米租金
if (isset($data['rent_type']) && $data['rent_type'] > 0) {
$save_data['rent_type'] = $data['rent_type'];
}
//价格 -1表示营业额扣点 存分
if (isset($data['rent_price'])) {
$save_data['rent_price'] = $data['rent_price'];
}
//业态
if (isset($data['industry_type'])) {
$save_data['industry_type'] = $data['industry_type'];
}
//楼盘电话(案场经理电话)
if (isset($data['case_manager_phone'])) {
$save_data['case_manager_phone'] = $data['case_manager_phone'];
}
//状态 0待审批 1上架 2下架 3回收
if (isset($data['status'])) {
$save_data['status'] = $data['status'];
} else {
//剩余商铺为0下架
if (empty($data['residue_num']) || empty($data['total'])) {
$save_data['status'] = 2;
} else {
$save_data['status'] = 1;
}
}
//首页排序
if (isset($data['home_page_sort'])) {
$save_data['home_page_sort'] = $data['home_page_sort'];
}
//商铺类型(0商场,1街铺)
if (isset($data['shop_type'])) {
$save_data['shop_type'] = $data['shop_type'];
}
//店铺面积存米 街铺start和end面积一样
if (isset($data['shop_area_start'])) {
$save_data['shop_area_start'] = $data['shop_area_start'];
}
//店铺面积存米 街铺start和end面积一样
if (isset($data['shop_area_end']) && $data['shop_type'] == 0) {
$save_data['shop_area_end'] = $data['shop_area_end'];
} else {
$save_data['shop_area_end'] = $data['shop_area_start'];
}
//商铺标签
if (isset($data['shop_sign'])) {
$save_data['shop_sign'] = $data['shop_sign'];
}
//物业管理费 金额 存分
if (isset($data['management_fee'])) {
$save_data['management_fee'] = $data['management_fee'] * 100;
}
//进场费存分 街铺的话,则进场费 为 转让费
if (isset($data['slotting_fee'])) {
$save_data['slotting_fee'] = $data['slotting_fee'] * 100;
}
//剩余铺数
if (isset($data['residue_num'])) {
$save_data['residue_num'] = $data['residue_num'];
}
//总铺数
if (isset($data['total'])) {
$save_data['total'] = $data['total'];
}
//商铺经度
if (isset($data['longitude'])) {
$save_data['longitude'] = $data['longitude'];
}
//商铺纬度
if (isset($data['latitude'])) {
$save_data['latitude'] = $data['latitude'];
}
//0是1否显示在c端用户
if (isset($data['is_show'])) {
$save_data['is_show'] = $data['is_show'];
}
//是否可以报备,如果可以就为0否则为1
if (isset($data['is_can_records'])) {
$save_data['is_can_records'] = $data['is_can_records'];
}
//0是1否有燃气
if (isset($data['is_has_gas'])) {
$save_data['is_has_gas'] = $data['is_has_gas'];
}
//精选商铺--0否1是
if (isset($data['is_carefully_chosen'])) {
$save_data['is_carefully_chosen'] = $data['is_carefully_chosen'];
}
//是否独家0否1是
if (isset($data['is_exclusive_type'])) {
$save_data['is_exclusive_type'] = $data['is_exclusive_type'];
}
//0为执行过 1有动态记录
if (isset($data['is_execute'])) {
$save_data['is_execute'] = $data['is_execute'];
}
//楼盘资料
if (!empty($data['file_path'])) {
$save_data['file_path'] = $data['file_path'];
}
//地址的参考地标
if (!empty($data['landmark'])) {
$save_data['landmark'] = $data['landmark'];
}
//商铺省市区对应code
if (!empty($save_data['province']) && !empty($save_data['city']) && !empty($save_data['disc'])) {
$regions = new Regions();
$code_arr = $regions->getRegionsCodeByName($save_data['province'], $save_data['city'], $save_data['disc']);
$save_data['code'] = implode('##', $code_arr);
}
//案场联系人id,逗号隔开
if (!empty($data['case_id'])) {
$save_data['case_id'] = $data['case_id'];
}
//楼盘资料
if (!empty($data['code'])) {
$save_data['code'] = $data['code'];
}
//是否锁盘0否1是
if (isset($data['is_lock'])) {
$save_data['is_lock'] = $data['is_lock'];
}
if (isset($data['id'])) {
//操作人
if (isset($data['user_id'])) {
$save_data['operation_id'] = $data['user_id'];
}
$save_data['update_time'] = date('Y-m-d H:i:s');
$num = $this->where('id', $data['id'])->update($save_data);
if ($num > 0) {
$house_id =$save_data['id'];
}
} else {
$save_data['upload_id'] = $agent_id; //上传人
$save_data['create_time'] = date('Y-m-d H:i:s');
$house_id = $this->insertGetId($save_data);
}
return $house_id;
}
/**
* 商铺列表独家编辑
*
......@@ -1160,6 +1387,14 @@ class GHouses extends BaseModel
return $result;
}
/**
* @param $field
* @param $params
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseIdsArray($field, $params)
{
$result = Db::table($this->table)
......@@ -1177,6 +1412,14 @@ class GHouses extends BaseModel
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseInfo($field, $params)
{
$result = Db::table($this->table)
......
<?php
/**
* Created by PhpStorm.
* User: fuju
* User: hu jun
* Date: 2018/1/18
* Time: 17:39
*/
......@@ -22,6 +22,13 @@ class GHousesExt extends BaseModel
$this->db_ = Db::table($this->table);
}
/**
* @param $landlord_phone
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHouseId($landlord_phone)
{
$params["landlord_phone"] = array( "like", '%' . $landlord_phone . '%' );
......@@ -30,4 +37,202 @@ class GHousesExt extends BaseModel
->where($params)
->select();
}
/**
* @param $data
* @param $house_id
* @return bool
*/
public function addHouseExt($data, $house_id) {
$save_data = [];
//100字以内产品沟通过
if (empty($house_id)) {
return false;
} else {
$save_data['house_id'] = $house_id;
}
//佣金规则 100字以内产品沟通过
if (isset($data['fee_rule'])) {
$save_data['fee_rule'] = trim($data['fee_rule']);
}
//项目优势 200字以内 对内
if (isset($data['internal_item_advantage'])) {
$save_data['internal_item_advantage'] = trim($data['internal_item_advantage']);
}
//项目优势对外
if (isset($data['external_item_advantage'])) {
$save_data['external_item_advantage'] = trim($data['external_item_advantage']);
}
//微楼书
if (isset($data['tiny_brochure_url'])) {
$save_data['tiny_brochure_url'] = $data['tiny_brochure_url'];
}
//大讲堂
if (isset($data['auditorium'])) {
$save_data['auditorium'] = trim($data['auditorium']);
}
//交通
if (isset($data['traffic'])) {
$save_data['traffic'] = trim($data['traffic']);
}
//独家合同开始时间
if (isset($data['agent_start_time'])) {
$save_data['agent_start_time'] = $data['agent_start_time'];
}
//独家合同结束时间
if (isset($data['agent_end_time'])) {
$save_data['agent_end_time'] = $data['agent_end_time'];
}
//已入驻的品牌商铺
if (isset($data['enter_num'])) {
$save_data['enter_num'] = trim($data['enter_num']);
}
//营业时间 这里是文本,如早上8点到晚上8点
if (isset($data['do_business_date'])) {
$save_data['do_business_date'] = $data['do_business_date'];
}
//招商时间
if (isset($data['start_business_date'])) {
$save_data['start_business_date'] = date('Y-m-d H:i:s', strtotime($data['start_business_date']));
}
//开业时间
if (isset($data['opening_date'])) {
$save_data['opening_date'] = $data['opening_date'];
}
//签约规则
if (isset($data['sign_rule'])) {
$save_data['sign_rule'] = trim($data['sign_rule']);
}
//房东手机号
if (!empty($data['landlord_phone'])) {
$landlord_phone = [];
if (is_array($data['landlord_phone'])) {
foreach ($data['landlord_phone'] as $k => $v) {
if (!empty($v['phone'])) {
$landlord_phone[$k]['name'] = empty($v['name']) ? '房东' : $v['name'];
$landlord_phone[$k]['phone'] = $v['phone'];
}
}
} else {
//兼容之前逗号隔开的手机号
$params['landlord_phone'] = explode(',', $data['landlord_phone']);
foreach ($params['landlord_phone'] as $key => $val) {
$landlord_phone[$key]['name'] = '房东';
$landlord_phone[$key]['phone'] = trim($val);
}
}
if (isset($landlord_phone[0]['phone'])) {
$data['landlord_phone'] = json_encode($landlord_phone);
}
}
//房东备注
if (isset($data['landlord_remark'])) {
$save_data['landlord_remark'] = trim($data['landlord_remark']);
}
//年限
if (isset($data['age_limit'])) {
$save_data['age_limit'] = trim($data['age_limit']);
}
//付款规则(按月)-付款
if (isset($data['payment_month'])) {
$save_data['payment_month'] = trim($data['payment_month']);
}
//付款规则(按月)-押金
if (isset($data['deposit_month'])) {
$save_data['deposit_month'] = trim($data['deposit_month']);
}
//对外转让费:-1面议
if (isset($data['external_slotting_fee'])) {
$save_data['external_slotting_fee'] = trim($data['external_slotting_fee']);
}
//面宽
if (isset($data['area_width'])) {
$save_data['area_width'] = $data['area_width'];
}
//进深
if (isset($data['depth'])) {
$save_data['depth'] = $data['depth'];
}
//电量
if (isset($data['electric_quantity'])) {
$save_data['electric_quantity'] = $data['electric_quantity'];
}
//电压
if (isset($data['voltage'])) {
$save_data['voltage'] = $data['voltage'];
}
//烟管道: 0无1有
if (isset($data['exhaust_fume'])) {
$save_data['exhaust_fume'] = $data['exhaust_fume'];
}
//上水:0无 1有
if (isset($data['running_water'])) {
$save_data['running_water'] = $data['running_water'];
}
//下水: 0无1有
if (isset($data['downriver'])) {
$save_data['downriver'] = $data['downriver'];
}
//经营范围文字
if (isset($data['business_scope'])) {
$save_data['business_scope'] = $data['business_scope'];
}
//交付装修 0否1是
if (isset($data['decoration'])) {
$save_data['decoration'] = $data['decoration'];
}
//来源:0无,1网络,2客户介绍,3 朋友介绍,4上门挂牌,5打更新,6驻守,7其它
if (isset($data['source'])) {
$save_data['source'] = $data['source'];
}
$ext_id = $this->where('house_id', $house_id)->value('id');
if ($ext_id > 0) {
$num = $this->where('id', $ext_id)->update($save_data);
} else {
$num = $this->insert($save_data);
}
if ($num > 0) {
$result = true;
} else {
$result = false;
}
return $result;
}
}
\ No newline at end of file
......@@ -19,13 +19,12 @@ class GHousesImgs extends BaseModel
*
* @param $params
* @param $house_id
* @return array|false
* @throws \Exception
* @return array
*/
public function add($params, $house_id)
{
$count = 0;
$insert_img = array();
$insert_img = $result = [];
//1列表页封面图
if ($params['cover']) {
$insert_img[$count]['house_id'] = $house_id;
......@@ -64,7 +63,14 @@ class GHousesImgs extends BaseModel
}
}
return $this->saveAll($insert_img);
try {
$result['data'] = $this->saveAll($insert_img);
$result['status'] = 'successful';
} catch (\Exception $e) {
$result['status'] = 'fail';
$result['msg'] = $e->getMessage();
}
return $result;
}
/**
......
......@@ -144,6 +144,26 @@ class GHousesToAgents extends BaseModel
return $res;
}
/**
* 新增经纪人和楼盘关系
*
* @param $agents_id
* @param $houses_id
* @param $type
* @return int|string
*/
public function addHouseAgent($agents_id, $houses_id, $type) {
$agent_arr = [];
foreach ($agents_id as $k=>$v) {
$agent_arr[$k]['houses_id'] = $houses_id;
$agent_arr[$k]['agents_id'] = $v;
$agent_arr[$k]['type'] = $type;
}
$res = $this->insertAll($agent_arr);
return $res;
}
/**
* 解除经纪人和楼盘关系
*
......
......@@ -157,8 +157,8 @@ Route::group('index', [
//商铺
'BusinessList' => [ 'index/BusinessDistrict/getBusiness', [ 'method' => 'get' ] ], //获取商铺列表数据
'houseEdit' => [ 'index/Houses/edit', [ 'method' => 'get|post' ] ], //编辑商铺
'houseAdd' => [ 'index/Houses/edit', [ 'method' => 'get' ] ], //新增商铺
'houseEdit' => [ 'index/Houses/editV2', [ 'method' => 'get|post' ] ], //编辑商铺
'houseAdd' => [ 'index/Houses/editV2', [ 'method' => 'get' ] ], //新增商铺
'houseDel' => [ 'index/Houses/del', [ 'method' => 'post' ] ], //删除商铺
'regions' => [ 'index/BusinessDistrict/regions', [ 'method' => 'get' ] ], //获取省市区数据
'getCity' => [ 'index/BusinessDistrict/getCity', [ 'method' => '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