Commit bb3923bb authored by hujun's avatar hujun

门店添加编辑,获取城市列表

parent 08ca4cd0
...@@ -121,4 +121,18 @@ class BusinessDistrict extends Basic ...@@ -121,4 +121,18 @@ class BusinessDistrict extends Basic
$data = $regions->getRegions($params['code'], $params['parent_code'], $params['type']); $data = $regions->getRegions($params['code'], $params['parent_code'], $params['type']);
return $this->response(200, '', $data); return $this->response(200, '', $data);
} }
/**
* 获取所有的城市
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getCity() {
$region = new Regions();
$city = $region->where('type',2)->select();
return $this->response(200, '', $city);
}
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/2/2
* Time: 10:32
*/
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AStore;
class Store extends Basic
{
/**
* @return \think\response\View
*/
public function index() {
$result['code'] = 200;
$result['msg'] = '';
if ($this->request->isAjax()) {
} else {
//总监列表
$return = view('index');
}
return $return;
}
/**
* 添加门店
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function addStore() {
$district = new AStore();
if ($this->params['agents_id'] || $this->params['id']) {
$this->data = $district->addStoreAgents($this->params, $this->params['agents_id']);
} else {
$this->code = 101;
$this->msg = 'agents_id or id is null';
}
return $this->response($this->code, $this->msg, $this->data);
}
/**
* 通过id获取门店信息
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getStoreById() {
$district = new AStore();
if ($this->params['id']) {
$this->data = $district->getStoreById($this->params['id']);
} else {
$this->code = 101;
$this->msg = 'id is null';
}
return $this->response($this->code, $this->msg, $this->data);
}
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
...@@ -29,7 +29,10 @@ class ADistrict extends BaseModel ...@@ -29,7 +29,10 @@ class ADistrict extends BaseModel
if ($this->id) { if ($this->id) {
$agents = new AAgents(); $agents = new AAgents();
$agents_edit = $agents->save(['district_id' => $this->id],['id'=>$agents_id]); $agents_data['district_id'] = $this->id;
$agents_data['level'] = 30;
$agents_edit = $agents->editData($agents_data, $agents_id,'id');
if ($agents_edit) { if ($agents_edit) {
$resutlt = $this->id; $resutlt = $this->id;
$this->commit(); $this->commit();
......
<?php
/**
* Created by PhpStorm.
* User: hu jun
* Date: 2018/2/2
* Time: 14:28
*/
namespace app\model;
class AStore extends BaseModel
{
/**
* 添加门店,绑定店长关系
*
* @param $data
* @param $agents_id
* @return bool|mixed
* @throws \Exception
* @throws \think\exception\PDOException3
*/
public function addStoreAgents($data, $agents_id) {
$regions = new Regions();
$code_arr = $regions->getRegionsCodeByName($data['province'], $data['city'], $data['district']);
$store_data['province'] = $data['province'];
$store_data['city'] = $data['city'];
$store_data['district'] = $data['district'];
$store_data['address'] = $data['address'];
$store_data['longitude'] = $data['longitude'];
$store_data['latitude'] = $data['latitude'];
$store_data['store_name'] = $data['store_name'];
$store_data['scale'] = $data['scale'];
$store_data['district_id'] = $data['district_id'];
$store_data['code'] = implode('##',$code_arr);
$agents = new AAgents();
if ($data['id'] == '') {
$store_data['create_time'] = date('Y-m-d H:i:s');
$this->save($store_data);
$agents_data['store_id'] = $this->id;
$agents_data['level'] = 20;
$agents->editData($agents_data, $agents_id,'id');
} else {
$this->save($store_data, ['id'=>$data['id']]);
$resutlt = $agents_id;
$store_agents_id = $agents->where([
'store_id' =>$data['id'],
'level' => 20
])->value('id');
if ($store_agents_id != $agents_id) {
$update_agents[0]['id'] = $store_agents_id;
$update_agents[0]['level'] = 10;
$update_agents[1]['id'] = $agents_id;
$update_agents[1]['level'] =20;
$agents->saveAll($update_agents);
}
}
return $resutlt;
}
/**
* 通过id获取门店信息
*
* @param $id
* @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getStoreById($id) {
$data = $this->where('id',$id)->where('status',0)->find();
$agents = new AAgents();
$agents_name = $agents->field('id,name,phone')->where('store_id',$data['id'])->where('level',20)->find();
$data['agents_id'] = $agents_name['id'];
$data['agents_name'] = $agents_name['name'].'-'.$agents_name['phone'];
return $data;
}
}
\ No newline at end of file
...@@ -48,6 +48,7 @@ class JournalAccounts extends Model ...@@ -48,6 +48,7 @@ class JournalAccounts extends Model
$result = $this->db->field($field)->alias('j') $result = $this->db->field($field)->alias('j')
->join('applies a','j.apply_id = a.id','LEFT') ->join('applies a','j.apply_id = a.id','LEFT')
->where('a.agent_id', $agent_id) ->where('a.agent_id', $agent_id)
->where($params)
->group('j.apply_id') ->group('j.apply_id')
->limit($pageSize) ->limit($pageSize)
->order($order_) ->order($order_)
......
...@@ -48,19 +48,24 @@ class Regions extends Model ...@@ -48,19 +48,24 @@ class Regions extends Model
public function getRegionsCodeByName($province, $city = '', $disc = '') { public function getRegionsCodeByName($province, $city = '', $disc = '') {
if ($province) { if ($province) {
$result['province_code'] = $this->where('parentCode',100000) $result['province_code'] = $this->where('parentCode',100000)
->where('name','LIKE',$province.'%')->value('code'); ->where('fullName','LIKE',$province.'%')->value('code');
if ($result['province_code'] && $city) { if ($result['province_code'] && $city) {
$result['city_code'] = $this->where('parentCode',$result['province_code']) $result['city_code'] = $this->where('parentCode',$result['province_code'])
->where('name','LIKE',$city.'%')->value('code'); ->where('fullName','LIKE',$city.'%')->value('code');
if ($disc) { if ($disc) {
$result['disc_code'] = $this->where('parentCode',$result['city_code']) $result['disc_code'] = $this->where('parentCode',$result['city_code'])
->where('name','LIKE',$disc.'%')->value('code'); ->where('fullName','LIKE',$disc.'%')->value('code');
} }
} }
} }
return $result; return $result;
} }
public function getCity() {
$city = $this->where('type',2)->select();
return $city;
}
} }
...@@ -6,5 +6,46 @@ use think\Model; ...@@ -6,5 +6,46 @@ use think\Model;
class Remarks extends Model class Remarks extends Model
{ {
// /**
* 成交记录列表
*
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @param string $agent_id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getJournalHouseInfo($pageNo = 1, $pageSize = 15, $order_ = 'j.id desc', $field, $params) {
$data = $this->field($field)->alias('a')
->join('houseinfos b','houseinfos b ON a.house_id = b.id','LEFT')
->where($params)
->group('j.apply_id')
->limit($pageSize)
->order($order_)
->page($pageNo)
->select();
//查找商铺或街铺的名字和图片
foreach ($data as $key => $value) {
$data[$key] = Db::table('journalaccounts')
->field('singntime')->where('apply_id',$value['apply_id'])->find();
$data[$key]['singntime'] = date('Y-m-d',strtotime($value['singntime']));
$img = Db::table('houseimgs')->field('imagename')
->where('house_id', $value['house_id'])->where('imgtype',1)->find();
if ($img['imagename']) {
$data[$key]['img'] = ADMIN_URL_TL.'/houseImg/'.$img['imagename'];
} else {
$data[$key]['img'] = ADMIN_URL_TL.'/resource/image/pzz_.jpg';
}
}
return $data;
}
} }
...@@ -118,6 +118,7 @@ Route::group('index', [ ...@@ -118,6 +118,7 @@ Route::group('index', [
'houseEdit' => ['index/Houses/edit', ['method' => 'get|post']], //编辑商铺 'houseEdit' => ['index/Houses/edit', ['method' => 'get|post']], //编辑商铺
'houseDel' => ['index/Houses/del', ['method' => 'post']], //删除商铺 'houseDel' => ['index/Houses/del', ['method' => 'post']], //删除商铺
'regions' => ['index/BusinessDistrict/regions', ['method' => 'get']], //获取省市区数据 'regions' => ['index/BusinessDistrict/regions', ['method' => 'get']], //获取省市区数据
'getCity' => ['index/BusinessDistrict/getCity', ['method' => 'get']], //获取所有的城市
'getHouseList' => ['index/houses/getHouseList', ['method' => 'get']], //楼盘列表 'getHouseList' => ['index/houses/getHouseList', ['method' => 'get']], //楼盘列表
'carefullyChosen' => ['index/houses/carefullyChosen', ['method' => 'post']], //设置精选楼盘 'carefullyChosen' => ['index/houses/carefullyChosen', ['method' => 'post']], //设置精选楼盘
'editExclusive' => ['index/houses/editExclusive', ['method' => 'post']], //添加和编辑楼盘独家 'editExclusive' => ['index/houses/editExclusive', ['method' => 'post']], //添加和编辑楼盘独家
...@@ -126,9 +127,10 @@ Route::group('index', [ ...@@ -126,9 +127,10 @@ Route::group('index', [
'getDistrictList' => ['index/district/getDistrictList',['method'=>'get']], //总监列表 'getDistrictList' => ['index/district/getDistrictList',['method'=>'get']], //总监列表
'districtList' => ['index/district/districtList',['method'=>'get']], //总监列表 'districtList' => ['index/district/districtList',['method'=>'get']], //总监列表
'adddistrict' => ['index/district/addDistrict',['method'=>'post']], //添加部门,绑定总监关系 'adddistrict' => ['index/district/addDistrict',['method'=>'post']], //添加部门,绑定总监关系
'getDistrictListByName' => ['index/district/getDistrictListByName',['method'=>'get']], //查询部门
'storeList' => ['index/Store/index',['method'=>'get']], //门店列表 'storeList' => ['index/Store/index',['method'=>'get']], //门店列表
'addStore' => ['index/Store/addStore',['method'=>'get']], //添加门店 'addStore' => ['index/Store/addStore',['method'=>'get|post']], //添加门店
'getDistrictListByName' => ['index/broker/getDistrictListByName',['method'=>'get']], //添加门店 'getStoreById' => ['index/Store/getStoreById',['method'=>'get']], //通过id获得门店信息
]); ]);
......
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