Commit feb0a56b authored by zw's avatar zw

Merge branch '1109-v2.9.8' of https://gitee.com/zwyjjc/tl_estate into 1109-v2.9.8

parents 6a0c43c1 aa683e01
......@@ -15,6 +15,7 @@ use app\api_broker\service\PushMessageService;
use app\index\extend\Basic;
use app\model\AAgents;
use app\model\ABindingDevice;
use app\model\AStore;
use app\model\Evaluate;
use app\model\GHousesToAgents;
use think\Session;
......@@ -748,4 +749,49 @@ class Broker extends Basic
return $this->response(101, '内部错误:'.$e->getMessage());
}
}
/**
* 经纪人职称列表
*
* @return \think\Response
*/
public function agentPositionList()
{
$msg = "";
$code = 200;
$data = [];
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where['status'] = 0;
if (!empty($this->params['position'])) {
$where['position'] = $this->params['position'];
}
if (!empty($this->params['name'])) {
$where['name'] = $this->params['name'];
}
if (!empty($this->params['phone'])) {
$where['phone'] = $this->params['phone'];
}
try {
$m_agent = new AAgents();
$m_store = new AStore();
$list = $m_agent->getList($pageNo, $pageSize, 'id desc', 'id,phone,name,position,store_id', $where);
foreach ($list as $k=>$v) {
$list[$k]['store_name'] = $m_store->getStoreKeyById('store_name', ['id'=>$v['store_id']]);
}
$data['list'] = $list;
$data['total'] = $m_agent->getTotal($where);
} catch (\Exception $e) {
$code = 101;
$msg = '内部错误:'.$e->getMessage();
}
return $this->response($code, $msg, $data);
}
}
\ No newline at end of file
{layout name="global/frame_tpl" /}
<input type="hidden" class="page-load" id="realtimePerformance" />
<input type="hidden" class="page-load" id="pkList" />
<style>
.pk-container-detail{
background-color: #fff;
margin-left: 10px;
margin-left: 8px;
width: 80%;
height: 770px;
height: 820px;
border-radius:3px ;
box-sizing: border-box;
padding: 10px;
padding: 8px;
position: relative;
}
.results-pk{
display: inline-block;
height: 32px;
padding: 6px 12px;
font-size: 14px;
line-height: 32px;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 3px;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
transition: border-color ease-in-out .15s,
}
.margain-right-10{
margin-right: 10px;
}
.pk-yeji-bang{
font-size: 18px;
color: #1C1C1C;
font-weight: 600;
}
.pk-yeji-time{
font-size: 14px ;
color: #999999;
}
.img-gold{
position: absolute;
top: 0;
right: 6px;
}
.pk-container-detail-team{
margin-top: 10px;
}
.pk-container-detail-team .team-span{
width: 70px;
height: 30px;
font-size: 11px;
color: #FF9318;
line-height: 30px;
background-color: rgba(255, 147, 24,.1);
display: inline-block;
margin-right: 15px;
text-align: center;
cursor: pointer;
}
.pk-container-detail-team .team-span-active{
width: 70px;
height: 30px;
font-size: 11px;
line-height: 30px;
display: inline-block;
margin-right: 15px;
text-align: center;
color: #FFF;
background-color: #FF9318;
cursor: pointer;
}
.pk-container-detail-team .export-pk{
width: 80px;
height: 30px;
font-size: 11px;
line-height: 30px;
display: inline-block;
text-align: center;
margin-left: 60px;
background-color: #4F66C3;
color: #fff;
}
.pk-container-detail-a{
margin: 10px 0;
}
.pk-container-detail-a .a-span{
width: 30px;
height: 30px;
font-size: 11px;
color: #FF9318;
line-height: 30px;
background-color: rgba(255, 147, 24,.1);
display: inline-block;
margin-right: 15px;
text-align: center;
cursor: pointer;
}
.pk-container-detail-a .a-span-active{
width: 30px;
height: 30px;
font-size: 11px;
color: #fff;
line-height: 30px;
background-color: rgba(255, 147, 24);
display: inline-block;
margin-right: 15px;
text-align: center;
cursor: pointer;
}
#pk_list tr:nth-child(even) {
background: #FFF;
}
#pk_list tr:nth-child(odd) {
background: #F8F8F8;
}
#pk_list td,#pk_list th{
padding: 3px;
}
</style>
<div id="page-content-wrapper">
<div class="container pk-container">
<div class="pk-container-detail">
9999
<div class="pk-container-detail-header">
<span class="margain-right-10 pk-yeji-bang">业绩PK榜</span>
<span class="margain-right-10 pk-yeji-time">(2018.11.01-2018.11.16)</span>
<select class="results-pk" id="realtime_city_choose">
<option value="">城市筛选</option>
<option value="10001">上海市</option>
<option value="10002">杭州市</option>
</select>
<img src="/resource/image/gold@1x.png" class="img-gold"/>
</div>
<div class="pk-container-detail-con">
<div class="pk-container-detail-team">
<span class="team-span team-span-pk">团队PK榜</span>
<span class="team-span-active team-span-pk">店长PK榜</span>
<span class="team-span team-span-pk">经理PK榜</span>
<span class="team-span team-span-pk">主任PK榜</span>
<span class="team-span team-span-pk">顾问PK榜</span>
<span class="team-span team-span-pk">新人PK榜</span>
<span class="export-pk">导出报表</span>
</div>
<div class="pk-container-detail-a">
<span class="a-span">A</span>
<span class="a-span">B</span>
<span class="a-span-active">C</span>
<span class="a-span">D</span>
<span class="a-span">E</span>
<span class="a-span">F</span>
<span class="a-span">G</span>
<span class="a-span">H</span>
<span class="a-span">I</span>
<span class="a-span">J</span>
</div>
<div class="pk_list_content">
<table id="pk_list" class="table">
</table>
</div>
</div>
</div>
</div>
</div>
......@@ -107,14 +107,46 @@ class AliYunSecretReport extends BaseModel
}
/**
* 返回user_id
*
* @return array
* @param $pageNo
* @param $pageSize
* @param String $field
* @param array $where
* @param String $group
* @return false|int|\PDOStatement|string|\think\Collection
*/
public function getListGroupAll($pageNo, $pageSize, String $field, Array $where, String $group) {
try {
$data = $this->field($field)
->where($where)
->group($group)
->limit($pageSize)
->page($pageNo)
->select();
} catch (\Exception $e) {
$data = 0;
}
return $data;
}
/**
* @param array $where
* @param String $group
* @return int|string
*/
public function getCallUserId() {
return $this->where('create_time', 'between', ['2018-08-28', '2018-08-31'])
->where('users_id','NOT NULL')
->group('users_id')
->column('users_id');
public function getListGroupCount(Array $where, String $group) {
try {
$data = $this->where($where)
->group($group)
->count();
} catch (\Exception $e) {
$data = 0;
}
return $data;
}
public function getListAll($field, $where) {
return $this->field($field)
->where($where)
->select();
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/3/15
* Time : 下午2:00
* Intro:
*/
class TAgentTotalCallModel extends Model
{
protected $table = "t_agent_call";
private $db_;
function __construct()
{
$this->db_ = Db::name($this->table);
}
/**
* @param $params
* @return int
*/
public function addTotal($params)
{
Db::startTrans();
try {
$this->db_->insertAll($params);
Db::commit();
return 1;
} catch (\Exception $e) {
print_r($e);
Db::rollback();
return 0;
}
}
/**
* @param $params
* @return int
*/
public function saveTotal($params)
{
Db::startTrans();
try {
foreach ($params as $k=>$v) {
$this->db_->table($this->table)->update($v);
}
Db::commit();
return 1;
} catch (\Exception $e) {
print_r($e);
Db::rollback();
return 0;
}
}
/**
* 获取最后统计的时间
*
* @param $field
* @param $param
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getTotalEndTimeByAgentId($field, $param)
{
return $this->db_
->field($field)
->where($param)
->order("total_time desc")
->find();
}
/**
* @param String $field
* @param array $where
* @return array|false|int|\PDOStatement|string|Model
*/
public function getInfo(String $field,array $where) {
try {
$data = $this->db_
->field($field)
->where($where)
->find();
} catch (\Exception $e) {
$data = 0;
}
return $data;
}
}
\ No newline at end of file
......@@ -111,6 +111,7 @@ Route::group('index', [
'getCurrentCity' => ['index/broker/getCurrentCity', ['method' => 'GET']], //获取所属城市
'settingCity' => ['index/broker/settingCity', ['method' => 'POST']], //设置所属城市
'getAgentGroupSite' => ['index/broker/getAgentGroupSite', ['method' => 'GET']], //获得经纪人站点
'agentPositionList' => ['index/broker/agentPositionList', ['method' => 'GET']], //经纪人职称列表
'batchChangDish' => ['index/houses/batchChangDish', ['method' => 'post']],//批量修改盘方
'transformLandlord' => ['index/houses/transformLandlord', ['method' => 'post']],//转换房东手机号
'lockHouse' => ['index/houses/lockHouse', ['method' => 'post']],//锁盘
......@@ -473,6 +474,8 @@ Route::group('task', [
'queryRecordFile' => ['task/PrivacyNumber/queryRecordFile', ['method' => 'get']], //下载录音
'releaseNumber' => ['task/PrivacyNumber/releaseNumber', ['method' => 'get']], //释放号码
'checkBindPhone' => ['task/PrivacyNumber/checkBindPhone', ['method' => 'get']], //检查绑定关系,去除表中不存在的绑定关系
'totalAgentCall' => ['task/PrivacyNumber/totalAgentCall', ['method' => 'get']], //统计每天经纪人拨打电话
'oldTotalAgentCall' => ['task/PrivacyNumber/oldTotalAgentCall', ['method' => 'get']], //历史数据拨打数据
'updateStatusByTime' => ['task/updateShopStatusTask/updateStatusByTime', ['method' => 'get']], //修改上下架
......
......@@ -17,6 +17,7 @@ use app\model\AAgents;
use app\model\AAgentsPhone;
use app\model\AliYunSecretReport;
use app\model\BindingPhone;
use app\model\TAgentTotalCallModel;
use think\Db;
use think\Log;
use think\Request;
......@@ -26,11 +27,13 @@ class PrivacyNumber
private $redis;
private $m_bind;
private $m_secret_report;
private $m_agent;
public function __construct()
{
$this->redis = RedisExt::getRedis();
$this->m_secret_report = new AliYunSecretReport();
$this->m_bind = new BindingPhone();
$this->m_agent = new AAgents();
}
/**
......@@ -375,4 +378,130 @@ class PrivacyNumber
$call_service = new CallPhoneService();
$call_service->defaultFollowUp();
}
/**
* 统计每天经纪人拨打电话
*
* @param $month
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function totalAgentCall($month)
{
set_time_limit(0); // 取消脚本运行时间的超时上限
$call = new TAgentTotalCallModel();
if (empty($month)) {
$yesterday = date('Y-m-d', strtotime('-1 day'));
} else {
$yesterday = $month;
}
$where['create_time'] = ['between', [$yesterday .' 00:00:00', $yesterday . ' 23:59:59']];
$where['time'] = ['>', 0];
$total = $this->m_secret_report->getListGroupCount($where, 'phone_no');
$pageSize = 50;
$pageTotal = ceil($total / $pageSize);
for ($pageNo = 1; $pageNo <= $pageTotal; $pageNo++) {
$secret_data = $this->m_secret_report->getListGroupAll($pageNo, $pageSize, 'sum(time) as time,phone_no,agents_id', $where, 'phone_no');
if (empty($secret_data[0])) {
continue;
}
foreach ($secret_data as $k=>$v) {
$tmp_data = [];
$call_where['agent_id'] = $v['agents_id'];
$call_where['total_time'] = $yesterday;
$call_where['phone'] = $v['phone_no'];
$call_data = $call->getInfo('id,time,money', $call_where);
$where_agent['agents_id'] = $v['agents_id'];
$where_agent['phone_no'] = $v['phone_no'];
$where_agent['create_time'] = $where['create_time'];
$where_agent['time'] = $where['time'];
$time_arr = $this->m_secret_report->getListAll('time', $where_agent);
$minute = 0;
foreach ($time_arr as $t_val) {
if ($t_val['time']%60 == 0){
$minute += $t_val['time']/60;
} else {
$minute += $t_val['time']/60 + 1;
}
}
$tmp_data['money'] = $minute * 0.055 + $minute * 0.04;
$tmp_data['time'] = $v['time'];
$tmp_data['phone'] = $v['phone_no'];
$tmp_data['agent_id'] = $v['agents_id'];
if (empty($call_data)) {
$tmp_data['total_time'] = $yesterday;
$insert_data[] = $this->binCallData($tmp_data);
} else {
$tmp_data['id'] = $call_data['id'];
$tmp_data['total_time'] = $yesterday;
$update_data[] = $this->binCallData($tmp_data);
}
unset($tmp_data);
}
if (!empty($insert_data)) {
$call->addTotal($insert_data);
unset($insert_data);
}
if (!empty($update_data)) {
$call->saveTotal($update_data);
unset($update_data);
}
}
return;
}
/**
* 组装数据
*
* @param $data
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
private function binCallData($data) {
if (!empty($data['agent_id'])) {
$agent_data = $this->m_agent->getAgentInfo('name,district_id,store_id,phone', $data['agent_id']);
$insert_data['district_id'] = $agent_data['district_id'];
$insert_data['store_id'] = $agent_data['store_id'];
$insert_data['agent_id'] = $data['agent_id'];
$insert_data['name'] = $agent_data['name'];
}
$insert_data['phone'] = $data['phone'];
$insert_data['total_time'] = $data['total_time'];
$insert_data['time'] = $data['time'];
$insert_data['money'] = $data['money'];
if (!empty($data['id'])) {
$insert_data['id'] = $data['id'];
}
return $insert_data;
}
/**
* 历史数据
*/
public function oldTotalAgentCall() {
// $month = ['2018-03','2018-04','2018-05','2018-06','2018-07','2018-08','2018-09','2018-10','2018-11'];
$month = ['2018-11'];
foreach ($month as $v) {
$firstday = date('Y-m-01', strtotime($v));
$lastday = date('d', strtotime("$firstday +1 month -1 day"));
for ($i=1; $i<=$lastday; $i++) {
$this->totalAgentCall($v.'-'.$i);
}
}
}
}
\ No newline at end of file
define(['doT', 'text!temp/pk_list_template_tpl.html.html', 'css!style/home.css', 'ckfinder', 'ckfinderStart', 'pagination', 'bootstrapJs'], function(doT, template) {
pkList = {
pageNo: 1,
/*第几页*/
pageSize: 25,
/*每页显示多少条*/
mainTabIndex: 0,
mainTabIndexTwo: 0,
init: function() {
//初始化dot
$(document.body).append(template);
pkList.getList(0);
pkList.event();
},
event: function() {
var _doc = $(document);
//主页面 团队 店长
_doc.on('click', '.team-span-pk', function(e){
e.preventDefault();
e.stopPropagation();
var _this = $(this);
_this.removeClass('team-span').addClass('team-span-active').siblings().removeClass('team-span-active').addClass('team-span');
pkList.mainTabIndex = _this.index();
console.log(pkList.mainTabIndex)
});
_doc.on('click', '.pk-container-detail-a>span', function(e){
e.preventDefault();
e.stopPropagation();
var _this = $(this);
_this.removeClass('a-span').addClass('a-span-active').siblings().removeClass('a-span-active').addClass('a-span');
pkList.mainTabIndexTwo = _this.index();
console.log(pkList.mainTabIndexTwo)
});
$("#export").click(function() { //导出列表
pkList.exportList();
});
},
// 导出列表
exportList: function(pageNo) {
console.log(2);
follow.pageNo = pageNo;
var params = {};
var excel_two = 1;
var user_name = $.trim($('#customer_name').val());
var start_time = $('#start_date').val();
var end_time = $('#end_date').val();
var internal_title = $('#shop_name').val();
var user_phone = $('#customer_phone').val();
var id = $('#shop_num').val() * 1;
var store_name = $('#store_name').val();
var report_phone = $('#applicant_phone').val();
var report_name = $('#applicant_name').val();
window.open('/index/getCollection?'+
'excel='+ excel_two +'&user_name=' + user_name + '&start_time=' + start_time + '&end_time=' + end_time + '&internal_title=' + internal_title + '&user_phone=' + user_phone + '&id=' + id+ '&store_name=' + store_name+ '&report_phone=' + report_phone+ '&report_name=' + report_name);
},
getList: function(pageNo) {
var params = {};
params.pageNo =pkList.pageNo;
params.pageSize =pkList.pageSize;
$.ajax({
type: 'GET',
url: '/index/evaluationList',//拜访列表
data: params,
timeout: 30000,
dataType: 'json',
beforeSend: function() {},
success: function(data) {
if(typeof data === 'object') {
if (data.code == 200) {
var doTtmpl = doT.template(document.getElementById('pk_list_tpl').innerHTML);
$("#pk_list").html(doTtmpl(data.data.list));
add_page(data.data.total,pageNo,pkList.pageSize,pkList.getList);
}else {
alert(data['msg']);
};
}else{
alert('数据错误');
};
},
error: function() {
alert('error');
},
complete: function(xhr, textStatus){
if(textStatus === 'timeout'){
alert('请求超时');
};
}
});
}
};
return pkList;
});
\ No newline at end of file
<script id="pk_list_tpl" type="text/template">
[% if(it) { %]
<tr>
<th class="text-center">排名</th>
<th class="text-center">所属门店</th>
<th class="text-center">经纪人</th>
<th class="text-center">业绩(元)</th>
</tr>
[% for(var item in it){ %]
<tr class="text-center">
<td>[%= it[item]["name"] %]</td>
<td>[%= it[item]["evaluate_content"] %]</td>
<td>[%= it[item]["phone"] %]</td>
<td>[%= it[item]["create_time"] %]</td>
</tr>
[% } %]
[% }else{ %]
<tr>
<td colspan="8" style="text-align:center;"> 暂无数据</td>
</tr>
[% } %]
</script>
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