Commit 470d06f0 authored by hujun's avatar hujun

监督执行和门店拜访

parent 8d7b4b43
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/4/24
* Time: 16:55
*/
namespace app\index\controller;
use app\index\extend\Basic;
use app\model\AgentsVisitors;
class Supervise extends Basic
{
/**
* 门店拜访
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function visitShop() {
if ($this->request->isAjax()) {
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
/*开始时间*/
if (($this->params['start_date'] != NULL) && ($this->params['end_date'] == NULL)) {
$where['created'] = ['> time', $this->params['start_date'] . ' 00:00:00'];
}
/*结束时间*/
if (($this->params['end_date'] != NULL) && ($this->params['start_date'] == NULL)) {
$where['created'] = ['< time', $this->params['end_date'] . ' 23:59:59'];
}
/*开始结束时间*/
if (($this->params['start_date'] != NULL) && ($this->params['end_date'] != NULL)) {
$where['created'] = ['between time', [$this->params['start_date'] . ' 00:00:00'], $this->params['end_date'] . ' 23:59:59'];
}
if ($this->params['store_name'] != NULL) {
$where['c.store_name'] = ['like', '%'.$this->params['store_name'].'%'];
}
if ($this->params['phone'] != NULL) {
$where['a.visitor'] = ['like', '%'.$this->params['phone'].'%'];
}
if ($this->params['visitor_name'] != NULL) {
$where['a.visitor_name'] = ['like', '%'.$this->params['visitor_name'].'%'];
}
if ($this->params['shop_name'] != NULL) {
$where['a.agentshopname'] = ['like', '%'.$this->params['shop_name'].'%'];
}
$visit = new AgentsVisitors();
$fields = 'a.id,created,a.visitor_name,a.agentshopname,a.address,c.address as shop_address,a.scene_photo,a.distance,a.remarks';
$where['visit_type'] = 0;
$data['data'] = $visit->getVisitorsList($pageNo, $pageSize, 'a.id desc', $fields, $where);
foreach ($data['data'] as $k => $v) {
$data['data'][$k]['scene_photo'] = CK_IMG_URL .'images/supervise/' . $v['scene_photo'];
$data['data'][$k]['scene_photo'] = round($v['distance']);
}
$data['total'] = $visit->getVisitorsListTotal($where);
return $this->response(200, '', $data);
} else {
return view('visitShop');
}
}
/**
* 监督执行
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function carryOut() {
if ($this->request->isAjax()) {
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
/*开始时间*/
if (($this->params['start_date'] != NULL) && ($this->params['end_date'] == NULL)) {
$where['created'] = ['> time', $this->params['start_date'] . ' 00:00:00'];
}
/*结束时间*/
if (($this->params['end_date'] != NULL) && ($this->params['start_date'] == NULL)) {
$where['created'] = ['< time', $this->params['end_date'] . ' 23:59:59'];
}
/*开始结束时间*/
if (($this->params['start_date'] != NULL) && ($this->params['end_date'] != NULL)) {
$where['created'] = ['between time', [$this->params['start_date'] . ' 00:00:00'], $this->params['end_date'] . ' 23:59:59'];
}
if ($this->params['store_name'] != NULL) {
$where['c.store_name'] = ['like', '%'.$this->params['store_name'].'%'];
}
if ($this->params['phone'] != NULL) {
$where['a.visitor'] = ['like', '%'.$this->params['phone'].'%'];
}
if ($this->params['visitor_name'] != NULL) {
$where['a.visitor_name'] = ['like', '%'.$this->params['visitor_name'].'%'];
}
if ($this->params['shop_name'] != NULL) {
$where['a.agentshopname'] = ['like', '%'.$this->params['shop_name'].'%'];
}
$visit = new AgentsVisitors();
$fields = 'a.id,created,a.visitor_name,a.visitor,c.store_name,a.address,a.scene_photo,a.remarks';
$where['visit_type'] = 1;
$data['data'] = $visit->getVisitorsList($pageNo, $pageSize, 'a.id desc', $fields, $where);
foreach ($data['data'] as $k => $v) {
$data['data'][$k]['scene_photo'] = CK_IMG_URL .'images/supervise/' . $v['scene_photo'];
}
$data['total'] = $visit->getVisitorsListTotal($where);
return $this->response(200, '', $data);
} else {
return view('carryOut');
}
}
}
\ No newline at end of file
{layout name="global/frame_tpl" /}
监督执行
\ No newline at end of file
{layout name="global/frame_tpl" /}
门店拜访
\ No newline at end of file
...@@ -34,6 +34,7 @@ class AgentsVisitors extends BaseModel ...@@ -34,6 +34,7 @@ class AgentsVisitors extends BaseModel
public function getVisitorsListTotal ($params) { public function getVisitorsListTotal ($params) {
return $this->alias('a') return $this->alias('a')
->join('a_agents b', 'a.user_id = b.id','left') ->join('a_agents b', 'a.user_id = b.id','left')
->join('a_store c','b.store_id = c.id', 'left')
->where($params) ->where($params)
->count(); ->count();
} }
......
...@@ -209,8 +209,8 @@ Route::group('index', [ ...@@ -209,8 +209,8 @@ Route::group('index', [
'agent_zhuan_aagent' => [ 'index/agent/agent_zhuan_aagent', [ 'method' => 'post|get' ] ],//经纪人 'agent_zhuan_aagent' => [ 'index/agent/agent_zhuan_aagent', [ 'method' => 'post|get' ] ],//经纪人
'shop_a_store' => [ 'index/agent/shop_a_store', [ 'method' => 'post|get' ] ],//经纪人 'shop_a_store' => [ 'index/agent/shop_a_store', [ 'method' => 'post|get' ] ],//经纪人
'getCollection' => [ 'index/Collection/getCollection', [ 'method' => 'post|get' ] ],//收款记录 'getCollection' => [ 'index/Collection/getCollection', [ 'method' => 'post|get' ] ],//收款记录
'visitShop' => [ 'index/Supervise/visitShop', [ 'method' => 'get' ] ],//门店拜访
'carryOut' => [ 'index/Supervise/carryOut', [ '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