Commit 2375e057 authored by hujun's avatar hujun

门店拜访

parent a176bb48
...@@ -11,6 +11,7 @@ namespace app\api_broker\controller; ...@@ -11,6 +11,7 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\model\AAgents; use app\model\AAgents;
use app\model\AgentsVisitors;
use app\model\SSupervision; use app\model\SSupervision;
class Supervise extends Basic class Supervise extends Basic
...@@ -21,18 +22,29 @@ class Supervise extends Basic ...@@ -21,18 +22,29 @@ class Supervise extends Basic
* @return \think\Response * @return \think\Response
*/ */
public function add() { public function add() {
$supervision = new SSupervision();
if (empty($this->params['id'])) { if (empty($this->params['id'])) {
return $this->response(101, 'Id is null'); return $this->response(101, 'Id is null');
} }
$supervision = new AgentsVisitors();
$data['id'] = ''; $data['id'] = '';
$data['content'] = $this->params['content']; $data['user_id'] = $this->agentId;
$data['usertable'] = $this->params['usertable'];
$data['visitor'] = $this->agentPhone;
$data['visitor_name'] = $this->agentName;
$data['agentshopname'] = $this->params['agentshopname'];
$data['leader_name'] = $this->params['leader_name'];
$data['leader_phone'] = $this->params['leader_phone'];
$data['address'] = $this->params['address'];
$data['remarks'] = $this->params['remarks'];
$data['longitude'] = $this->params['longitude']; $data['longitude'] = $this->params['longitude'];
$data['latitude'] = $this->params['latitude']; $data['latitude'] = $this->params['latitude'];
$data['address'] = $this->params['address']; $data['distance'] = $this->params['distance'];
$data['agent_id'] = $this->params['agent_id']; $data['shop_id'] = $this->params['shop_id'];
$data['district_id'] = $this->params['district_id']; $data['modified'] = date('Y-m-d H:i:s');
$data['store_id'] = $this->params['store_id'];
$supervision->editData($data, $this->params['id']); $supervision->editData($data, $this->params['id']);
return $this->response(200, '', ['id'=>$this->params['id']]); return $this->response(200, '', ['id'=>$this->params['id']]);
} }
...@@ -53,8 +65,10 @@ class Supervise extends Basic ...@@ -53,8 +65,10 @@ class Supervise extends Basic
$info = $file->validate(['size'=>1024000,'ext'=>'jpg,png'])->move($path); $info = $file->validate(['size'=>1024000,'ext'=>'jpg,png'])->move($path);
if($info){ if($info){
$img_path = $info->getSaveName(); //生成的图片路径 $img_path = $info->getSaveName(); //生成的图片路径
$data['img_url'] = $img_path; $data['scene_photo'] = $img_path;
$supervision = new SSupervision(); $data['created'] = date('Y-m-d H:i:s');
$data['visit_type'] = empty($this->params['visit_type']) ? 0:1; //拜访类型(0代表门店拜访、1代表监督执行)
$supervision = new AgentsVisitors();
$supervision->editData($data); $supervision->editData($data);
$data['status'] = 200; $data['status'] = 200;
$data['msg'] = '上传成功'; $data['msg'] = '上传成功';
...@@ -86,7 +100,7 @@ class Supervise extends Basic ...@@ -86,7 +100,7 @@ class Supervise extends Basic
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$verify = new AAgents(); $verify = new AAgents();
$agent_data = $verify->getAgentInfo('level,store_id,district_id', $this->params['agent_id']); $agent_data = $verify->getAgentInfo('level,store_id,district_id', $this->agentId);
switch ($agent_data['level']) { switch ($agent_data['level']) {
case 20 : case 20 :
...@@ -96,22 +110,80 @@ class Supervise extends Basic ...@@ -96,22 +110,80 @@ class Supervise extends Basic
case 40 : case 40 :
$where = 'a.store_id = '.$agent_data['store_id'] . ' or a.district_id = '.$agent_data['district_id'];break; $where = 'a.store_id = '.$agent_data['store_id'] . ' or a.district_id = '.$agent_data['district_id'];break;
default : default :
$where = 'agent_id = '.$this->params['agent_id']; $where = 'user_id = '.$this->params['agent_id'];
} }
$supervision = new SSupervision(); //拜访类型(0代表门店拜访、1代表监督执行)
$fields = 'longitude,latitude,address,content,img_url,b.name,a.create_time'; if (empty($this->params['visit_type'])) {
$where .= ' AND visit_type = 0';
$fields = 'longitude,latitude,address,a.remarks,scene_photo,b.name,a.created,b.phone,a.leader_name,agentshopname';
} else {
$where .= ' AND visit_type = 1';
$fields = 'longitude,latitude,address,a.remarks,scene_photo,b.name,a.created';
}
if (empty($where)) { if (empty($where)) {
return $this->response(101, 'Params is error'); return $this->response(101, 'Params is error');
} }
$data['list'] = $supervision->getSupervisionList($pageNo, $pageSize, 'a.id desc', $fields, $where); $supervision = new AgentsVisitors();
$data['list'] = $supervision->getVisitorsList($pageNo, $pageSize, 'a.id desc', $fields, $where);
foreach ($data['list'] as $k=>$v) { foreach ($data['list'] as $k=>$v) {
$data['list'][$k]['img_url'] = CK_IMG_URL .'images/supervise/' . $v['img_url']; $data['list'][$k]['scene_photo'] = CK_IMG_URL .'images/supervise/' . $v['scene_photo'];
} }
$data['total'] = $supervision->getSupervisionListTotal($where); $data['total'] = $supervision->getVisitorsListTotal($where);
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 searchInfo() {
$data['status'] = 200;
$data['data'] = '';
$data['msg'] = '';
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$where = 'a.status <> 2';
if ($this->params['search']) {
$where .= ' AND (concat(phone,name) like "%'.$this->params['search'].'%" or store_name like "%'.$this->params['search'].'%")';
}
if ($this->params['level']) {
$where .= ' AND level in ('.$this->params['level'].')';
}
if ($where) {
$agent = new AAgents();
$field = 'a.id,a.name,a.phone,a.level,b.store_name,b.province,b.city,b.district,b.address,b.longitude,b.latitude';
$data['data'] = $agent->searchAgentShop($pageNo, $pageSize, 'id DESC', $field, $where);
foreach ($data['data'] as $k=>$v) {
switch ($v['level']) {
case 10 :
$data['data'][$k]['level_name'] = '业务员';break;
case 20 :
$data['data'][$k]['level_name'] = '店长';break;
case 30 :
$data['data'][$k]['level_name'] = '总监';break;
case 40 :
$data['data'][$k]['level_name'] = '总监';break;
default :
$data['data'][$k]['level_name'] = "";
}
}
} else {
$data['msg'] = '没有经纪人信息';
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
} }
\ No newline at end of file
...@@ -43,6 +43,7 @@ class Basic extends Controller ...@@ -43,6 +43,7 @@ class Basic extends Controller
'broker/getRegions', 'broker/getRegions',
'broker/getAddress', 'broker/getAddress',
'broker/getBroker', 'broker/getBroker',
'broker/searchAgentShop',
); );
/** /**
......
...@@ -743,4 +743,26 @@ class AAgents extends BaseModel ...@@ -743,4 +743,26 @@ class AAgents extends BaseModel
return $data; return $data;
} }
/**
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchAgentShop($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field)
->alias('a')
->join('a_store b', 'a.store_id = b.id', 'left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
} }
\ No newline at end of file
...@@ -2,9 +2,38 @@ ...@@ -2,9 +2,38 @@
namespace app\model; namespace app\model;
use think\Model;
class AgentsVisitors extends Model class AgentsVisitors extends BaseModel
{ {
// /**
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param string $field
* @param string $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getVisitorsList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field)->alias('a')
->join('a_agents b', 'a.user_id = b.id','left')
->where($params)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
}
/**
* @param $params
* @return int|string
*/
public function getVisitorsListTotal ($params) {
return $this->alias('a')
->join('a_agents b', 'a.user_id = b.id','left')
->where($params)
->count();
}
} }
...@@ -390,8 +390,9 @@ Route::group('broker', [ ...@@ -390,8 +390,9 @@ Route::group('broker', [
'weekWorkImg' => ['api_broker/Statement/weekWorkImg', ['method' => 'post']], //生成周报和日报图片 'weekWorkImg' => ['api_broker/Statement/weekWorkImg', ['method' => 'post']], //生成周报和日报图片
'setReportContent' => ['api_broker/Statement/setReportContent', ['method' => 'get|post']], //保存日报周报四个字段 'setReportContent' => ['api_broker/Statement/setReportContent', ['method' => 'get|post']], //保存日报周报四个字段
'getWeekOrDay' => ['api_broker/Statement/getWeekOrDay', ['method' => 'get']], //获取日报或者周报 'getWeekOrDay' => ['api_broker/Statement/getWeekOrDay', ['method' => 'get']], //获取日报或者周报
'uploadSuperviseFile' => ['api_broker/Supervise/uploadSuperviseFile', ['method' => 'post']], //监督执行上传图片 'uploadSuperviseFile' => ['api_broker/Supervise/uploadSuperviseFile', ['method' => 'post']], //监督执行和门店拜访上传图片
'add_supervise' => ['api_broker/Supervise/add', ['method' => 'post']], //监督执行 'searchAgentShop' => ['api_broker/Supervise/searchInfo', ['method' => 'get']], //拜访门店查询
'add_supervise' => ['api_broker/Supervise/add', ['method' => 'post']], //添加监督执行和门店拜访
'addBargain' => ['api_broker/OrderLog/addBargain', [ 'method' => 'post' ] ], //新增成交报告佣金(分佣提成) 'addBargain' => ['api_broker/OrderLog/addBargain', [ 'method' => 'post' ] ], //新增成交报告佣金(分佣提成)
'getSupervise' => ['api_broker/Supervise/getSupervise', [ 'method' => 'get' ] ], //监督执行列表 'getSupervise' => ['api_broker/Supervise/getSupervise', [ 'method' => 'get' ] ], //监督执行列表
'sendSms' => ['api_broker/broker/sendSms', [ 'method' => 'post' ] ], //发送短信 'sendSms' => ['api_broker/broker/sendSms', [ 'method' => 'post' ] ], //发送短信
......
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