Commit 5873a063 authored by clone's avatar clone

业绩监督执行列表

parent 5057c0e6
......@@ -388,4 +388,39 @@ class Performance extends Basic
return $this->response("200", "success", $result["date"]);
}
}
/**
* 获取时间段进场数据
* @return \think\Response
*/
public function superviseList()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
$params = array(
"agent_id" => 78,
"start_time" => "2018-06-12",
"end_time" => "2018-06-20",
"page_no" => 1,
"page_size" => 15
);
$checkResult = $this->validate($params, "PerformanceValidate.verifyOther");
if (true !== $checkResult) {
return $this->response("101", $checkResult);
}
//默认排序一周
$end_day = !empty($params["end_time"]) ? $params["end_time"] : date("Y-m-d", strtotime("-1 day"));
$start_day = !empty($params["start_time"]) ? $params["start_time"] : date("Y-m-d", strtotime("-7 day"));
$page_no = empty($params['page_no']) ? 1 : $params['page_no'];
$page_size = empty($params['page_size']) ? 15 : $params['page_size'];
$result = $this->service_->superviseList($params["agent_id"], $start_day, $end_day, $page_no, $page_size);
if ($result["code"] == 101) {
return $this->response("101", $result["date"]);
} else {
return $this->response("200", "success", $result["date"]);
}
}
}
......@@ -31,7 +31,8 @@ class Supervise extends Basic
*
* @return \think\Response
*/
public function add() {
public function add()
{
if (empty($this->params['id'])) {
return $this->response(101, 'Id is null');
......@@ -39,24 +40,24 @@ class Supervise extends Basic
$supervision = new AgentsVisitors();
$data['id'] = '';
$data['user_id'] = $this->agentId;
$data['usertable'] = empty($this->params['usertable'])? "" : $this->params['usertable'];
$data['visitor'] = $this->agentPhone;
$data['visitor_name'] = $this->agentName;
$data['id'] = '';
$data['user_id'] = $this->agentId;
$data['usertable'] = empty($this->params['usertable']) ? "" : $this->params['usertable'];
$data['visitor'] = $this->agentPhone;
$data['visitor_name'] = $this->agentName;
$data['agentshopname'] = empty($this->params['agentshopname']) ? '' : $this->params['agentshopname'];
$data['leader_name'] = empty($this->params['leader_name']) ? '': $this->params['leader_name'];
$data['leader_phone'] = empty($this->params['leader_phone']) ? '' : $this->params['leader_phone'];
$data['address'] = $this->params['address'];
$data['remarks'] = $this->params['remarks'];
$data['longitude'] = $this->params['longitude'];
$data['latitude'] = $this->params['latitude'];
$data['distance'] = empty($this->params['distance']) ? '' : $this->params['distance'];
$data['shop_id'] = $this->params['shop_id'];
$data['modified'] = date('Y-m-d H:i:s');
$data['leader_name'] = empty($this->params['leader_name']) ? '' : $this->params['leader_name'];
$data['leader_phone'] = empty($this->params['leader_phone']) ? '' : $this->params['leader_phone'];
$data['address'] = $this->params['address'];
$data['remarks'] = $this->params['remarks'];
$data['longitude'] = $this->params['longitude'];
$data['latitude'] = $this->params['latitude'];
$data['distance'] = empty($this->params['distance']) ? '' : $this->params['distance'];
$data['shop_id'] = $this->params['shop_id'];
$data['modified'] = date('Y-m-d H:i:s');
$supervision->editData($data, $this->params['id']);
return $this->response(200, '', ['id'=>$this->params['id']]);
return $this->response(200, '', [ 'id' => $this->params['id'] ]);
}
/**
......@@ -64,29 +65,30 @@ class Supervise extends Basic
*
* @return \think\Response
*/
public function uploadSuperviseFile() {
public function uploadSuperviseFile()
{
$data['status'] = 101;
$data['msg'] = '';
$data['data'] = '';
$file = $this->request->file('file');
if($file){
$path = ROOT_PATH . 'public' . DS . 'resource'. DS . 'lib'. DS .'Attachments'. DS .'images'.DS.'supervise';
$info = $file->validate(['size'=>1024000,'ext'=>'jpg,png'])->move($path);
if($info){
$img_path = $info->getSaveName(); //生成的图片路径
if ($file) {
$path = ROOT_PATH . 'public' . DS . 'resource' . DS . 'lib' . DS . 'Attachments' . DS . 'images' . DS . 'supervise';
$info = $file->validate([ 'size' => 1024000, 'ext' => 'jpg,png' ])->move($path);
if ($info) {
$img_path = $info->getSaveName(); //生成的图片路径
$data['scene_photo'] = $img_path;
$data['created'] = date('Y-m-d H:i:s');
$data['visit_type'] = empty($this->params['visit_type']) ? 0:1; //拜访类型(0代表门店拜访、1代表监督执行)
$supervision = new AgentsVisitors();
$data['visit_type'] = empty($this->params['visit_type']) ? 0 : 1; //拜访类型(0代表门店拜访、1代表监督执行)
$supervision = new AgentsVisitors();
$supervision->editData($data);
$data['status'] = 200;
$data['msg'] = '上传成功';
$data['data'] = [
'file_name' => CK_IMG_URL .'images/supervise/' . $img_path,
'file_name' => CK_IMG_URL . 'images/supervise/' . $img_path,
'id' => $supervision->id
];
}else{
} else {
// 上传失败获取错误信息
$data['msg'] = $file->getError();
}
......@@ -105,25 +107,26 @@ class Supervise extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getSupervise() {
public function getSupervise()
{
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$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->agentId);
if ($agent_data['level'] == 10) {
$where = 'a.user_id = '.$this->params['agent_id'];
$where = 'a.user_id = ' . $this->params['agent_id'];
} else {
$where = 'b.store_id = '.$agent_data['store_id'];
$where = 'b.store_id = ' . $agent_data['store_id'];
}
//拜访类型(0代表门店拜访、1代表监督执行)
if (empty($this->params['visit_type'])) {
$where .= ' AND visit_type = 0';
$where .= ' AND visit_type = 0';
$fields = 'a.longitude,a.latitude,c.province,c.city,c.district,c.address as agent_address,a.address,a.remarks,scene_photo,b.name,a.created,leader_name,leader_phone,b.phone,agentshopname';
} else {
$where .= ' AND visit_type = 1';
$where .= ' AND visit_type = 1';
$fields = 'a.longitude,a.latitude,a.address,a.remarks,scene_photo,b.name,a.created';
}
......@@ -133,15 +136,15 @@ class Supervise extends Basic
$supervision = new AgentsVisitors();
$data['list'] = $supervision->getVisitorsList($pageNo, $pageSize, 'a.id desc', $fields, $where);
$data['list'] = $supervision->getVisitorsList($pageNo, $pageSize, 'a.id desc', $fields, $where);
if (empty($this->params['visit_type'])) {
foreach ($data['list'] as $k => $v) {
$data['list'][$k]['agent_address'] = $data['list'][$k]['province'].$data['list'][$k]['city'].$data['list'][$k]['district'].$data['list'][$k]['agent_address'];
$data['list'][$k]['agent_address'] = $data['list'][$k]['province'] . $data['list'][$k]['city'] . $data['list'][$k]['district'] . $data['list'][$k]['agent_address'];
}
}
foreach ($data['list'] as $k=>$v) {
$data['list'][$k]['scene_photo'] = CK_IMG_URL .'images/supervise/' . $v['scene_photo'];
foreach ($data['list'] as $k => $v) {
$data['list'][$k]['scene_photo'] = CK_IMG_URL . 'images/supervise/' . $v['scene_photo'];
}
$data['total'] = $supervision->getVisitorsListTotal($where);
return $this->response(200, '', $data);
......@@ -155,27 +158,28 @@ class Supervise extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchInfo() {
public function searchInfo()
{
$data['status'] = 200;
$data['data'] = '';
$data['msg'] = '';
$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'].'%")';
$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'].')';
$where .= ' AND level in (' . $this->params['level'] . ')';
} else {
$where .= ' AND level in (20,40)';
}
if ($where) {
$agent = new AAgents();
$field = 'a.id,b.store_name,a.name,a.phone,b.province,b.city,b.district,b.address,b.longitude,b.latitude,a.store_id';
$field = 'a.id,b.store_name,a.name,a.phone,b.province,b.city,b.district,b.address,b.longitude,b.latitude,a.store_id';
$data['data'] = $agent->searchAgentShop($pageNo, $pageSize, 'id DESC', $field, $where);
} else {
......@@ -196,7 +200,7 @@ class Supervise extends Basic
$file = request()->file('image');
$data = [];
if ($file) {
$path = './resource' . DS . 'lib' . DS . 'Attachments'. DS . 'images'. DS . 'supervise';
$path = './resource' . DS . 'lib' . DS . 'Attachments' . DS . 'images' . DS . 'supervise';
$info = $file->validate([ 'size' => 10240000, 'ext' => 'jpg,png' ])//限制100m
->move($path);
if ($info) {
......@@ -207,7 +211,7 @@ class Supervise extends Basic
$data = [
'name' => $img_path,
'path' => CK_IMG_URL .'images/supervise/' . $img_path
'path' => CK_IMG_URL . 'images/supervise/' . $img_path
];
} else {
// 上传失败获取错误信息
......@@ -226,7 +230,8 @@ class Supervise extends Basic
* Date: 2018/6/20
* Time: 13:10:33
*/
public function addSupervise(){
public function addSupervise()
{
$params = $this->params;
/*
......@@ -238,13 +243,19 @@ class Supervise extends Basic
*/
if (!isset($params['agent_id']) || !isset($params['agent_name']) || !isset($params['remark']) || !isset($params['img'])) {
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
return $this->response("300", "参数不全");
}
$res = $this->aSuperviseModel->saveSupervise(['agent_id' => $params['agent_id'],'agent_name' => $params['agent_name'],'remark' => $params['remark'],'img' => $params['img'],'address' => $params['address']]);
//dump($UPhoneFollowPp->id);exit;
$insert["agent_id"] = $params['agent_id'];
$insert["agent_name"] = $params['agent_name'];
$insert["remark"] = $params['remark'];
$insert["img"] = $params['img'];
$insert["address"] = $params['address'];
$res = $this->aSuperviseModel->saveSupervise($insert);
if ($res) {
return $this->response("200", "success!",$res);
return $this->response("200", "success!", $res);
} else {
return $this->response("101", "失败!");
}
......@@ -257,7 +268,8 @@ class Supervise extends Basic
* Date: 2018/6/15
* Time: 13:10:33
*/
public function superviseList(){
public function superviseList()
{
$result = '';
......@@ -273,38 +285,38 @@ class Supervise extends Basic
//搜索条件 start
//1.上传时间
if (!empty($params['create_time_start']) && !empty($params['create_time_end'])) {
$where['a.create_time'] = ['between time', [$params['create_time_start']. ' 00:00:00', $params['create_time_end'] . ' 23:59:59']];
$where['a.create_time'] = [ 'between time', [ $params['create_time_start'] . ' 00:00:00', $params['create_time_end'] . ' 23:59:59' ] ];
}
//2.部门
if (!empty($params['district_id'])) {
$where['b.district_id'] = $params['district_id'];
$where['b.district_id'] = $params['district_id'];
}
//3.门店名称
if (!empty($params['store_id'])) {
$where['b.store_id'] = $params['store_id'];
$where['b.store_id'] = $params['store_id'];
}
//4.提交人手机号
if (!empty($params['phone'])) {
$where['b.phone'] = ['LIKE','%'.$params['phone'].'%'];
$where['b.phone'] = [ 'LIKE', '%' . $params['phone'] . '%' ];
}
//5.跟进内容
if (!empty($params['remark'])) {
$where['a.remark'] = ['LIKE','%'.$params['remark'].'%'];
$where['a.remark'] = [ 'LIKE', '%' . $params['remark'] . '%' ];
}
//搜索条件 end
$fields_evaluate = 'a.create_time,a.agent_name,a.address,a.img as supervise_img,a.remark,b.name,b.phone,c.store_name';
$data['list'] = $this->aSuperviseModel->findSuperviseList($pageNo, $pageSize, 'a.id desc', $fields_evaluate, $where);
$data['total'] = $this->aSuperviseModel->findSuperviseListCount($fields_evaluate, $where);
foreach ($data['list'] as $k=>$v) {
$data['list'][$k]['supervise_img'] = CK_IMG_URL .'images/supervise/' . $v['supervise_img'];
$data['list'] = $this->aSuperviseModel->findSuperviseList($pageNo, $pageSize, 'a.id desc', $fields_evaluate, $where);
$data['total'] = $this->aSuperviseModel->findSuperviseListCount($fields_evaluate, $where);
foreach ($data['list'] as $k => $v) {
$data['list'][$k]['supervise_img'] = CK_IMG_URL . 'images/supervise/' . $v['supervise_img'];
}
//var_dump($result);
//return $result;
......
......@@ -3,6 +3,7 @@
namespace app\api_broker\service;
use app\model\AAgents;
use app\model\ASuperviseModel;
use app\model\GHouses;
use app\model\GHousesImgs;
use app\model\OBargainModel;
......@@ -32,6 +33,7 @@ class PerformanceService
private $marchInModel;
private $payLogModel;
private $gHousesImgModel;
private $superviseModel;
public function __construct()
{
......@@ -46,6 +48,7 @@ class PerformanceService
$this->marchInModel = new OMarchInModel();
$this->payLogModel = new OPayLogModel();
$this->gHousesImgModel = new GHousesImgs();
$this->superviseModel = new ASuperviseModel();
}
......@@ -613,13 +616,14 @@ class PerformanceService
$params = $this->getAgentId($agent_id, 2, $start_time, $end_time);
if (!$params)
return [ "code" => 101, "date" => "传入的参数错误" ];
$field = "a.id,a.user_name,a.user_phone,a.predict_see_time,b.house_title";
$field = "a.id,a.user_name,a.user_phone,a.predict_see_time,b.house_title";
$reportList = $this->reportModel->getAddReportList($params, $field, $page_no, $page_size);
foreach ($reportList as $key => $val) {
$reportList[$key]["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $val["user_phone"]);
}
return [ "code" => 200, "date" => $reportList ];
}
/**
* 获取进场数据
* @param $agent_id
......@@ -635,14 +639,15 @@ class PerformanceService
$params = $this->getAgentId($agent_id, 2, $start_time, $end_time);
if (!$params)
return [ "code" => 101, "date" => "传入的参数错误" ];
$field = "a.id,c.user_name,c.user_phone,c.predict_see_time,b.house_title";
$addMarchInList = $this->marchInModel->getAddMarchInList($params, $field, $page_no, $page_size);
$field = "a.id,c.user_name,c.user_phone,c.predict_see_time,b.house_title";
$addMarchInList = $this->marchInModel->getAddMarchInList($params, $field, $page_no, $page_size);
//获取图片信息
foreach ($addMarchInList as $key => $val) {
$addMarchInList[$key]["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $val["user_phone"]);
}
return [ "code" => 200, "date" => $addMarchInList ];
}
/**
* 获取收款数据
* @param $agent_id
......@@ -658,14 +663,15 @@ class PerformanceService
$params = $this->getAgentId($agent_id, 2, $start_time, $end_time);
if (!$params)
return [ "code" => 101, "date" => "传入的参数错误" ];
$field = "a.id,c.user_name,c.user_phone,c.predict_see_time,b.house_title";
$payLogList = $this->payLogModel->getAddPayLogList($params, $field, $page_no, $page_size);
$field = "a.id,c.user_name,c.user_phone,c.predict_see_time,b.house_title";
$payLogList = $this->payLogModel->getAddPayLogList($params, $field, $page_no, $page_size);
//获取图片信息
foreach ($payLogList as $key => $val) {
$payLogList[$key]["user_phone"] = preg_replace('/(\d{3})\d{4}(\d{4})/', '$1****$2', $val["user_phone"]);
}
return [ "code" => 200, "date" => $payLogList ];
}
/**
* 获取业绩数据
* @param $type
......@@ -676,15 +682,40 @@ class PerformanceService
* @param $page_size
* @return array|false|\PDOStatement|string|\think\Collection
*/
public function performanceList($type,$agent_id, $start_time, $end_time, $page_no, $page_size)
public function performanceList($type, $agent_id, $start_time, $end_time, $page_no, $page_size)
{
$params = $this->getAgentId($agent_id, $type, $start_time, $end_time);
if (!$params)
return [ "code" => 101, "date" => "传入的参数错误" ];
$field = "a.id,b.name,c.store_name,d.district_name,a.scale_fee,a.create_time";
$performanceList = $this->bargainModel->getAddBargainList($params, $field, $page_no, $page_size);
$field = "a.id,b.name,c.store_name,d.district_name,a.scale_fee,a.create_time";
$performanceList = $this->bargainModel->getAddBargainList($params, $field, $page_no, $page_size);
return [ "code" => 200, "date" => $performanceList ];
}
/**
* 获取监督执行记录
* @param $agent_id
* @param $start_time
* @param $end_time
* @param $page_no
* @param $page_size
* @return array
*/
public function superviseList($agent_id, $start_time, $end_time, $page_no, $page_size)
{
$params = $this->getAgentId($agent_id, 2, $start_time, $end_time);
if (!$params)
return [ "code" => 101, "date" => "传入的参数错误" ];
$field = "a.id,a.agent_id,a.agent_name,a.remark,a.img,a.address,a.create_time";
$where_["a.agent_id"] = $params["agent_id"];
$where_["a.create_time"] = $params["create_time"];
$superviseList = $this->superviseModel->findSuperviseList($page_no, $page_size, 'id desc', $field, $where_);
foreach ($superviseList as $k => $v) {
$superviseList[$k]['img'] = CK_IMG_URL . 'images/supervise/' . $v['img'];
}
return [ "code" => 200, "date" => $superviseList ];
}
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ class UWxInfo extends Model
* 新增微信拉取用户信息
* @param $params
* @return int|string
* @throws Exception
* @throws Exception xx
*/
public function addWxInfo(array $params): int
{
......
......@@ -468,6 +468,7 @@ Route::group('broker', [
'marchInList' => [ 'api_broker/Performance/marchInList', [ 'method' => 'POST|GET' ] ], //进场list
'paylogList' => [ 'api_broker/Performance/paylogList', [ 'method' => 'POST|GET' ] ], //收款list
'performanceList' => [ 'api_broker/Performance/performanceList', [ 'method' => 'POST|GET' ] ], //业绩list
'superviseList' => [ 'api_broker/Performance/superviseList', [ 'method' => 'POST|GET' ] ], //监督执行list
//user
'returnSearchCondition' => [ 'api_broker/User/returnSearchCondition', [ '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