Commit ab12e9fa authored by zw's avatar zw

pk

parent 01ad11e9
......@@ -45,4 +45,24 @@ class RankingList extends Basic{
$export->exportTables('PK明细表', $result, 6, 'PK明细表', $title);
return '';
}
public function selectPkSortByTime()
{
$params = $this->params;
/* $params = array(
"site_id" => 10001
);*/
if (!isset($params["site_id"])) {
return $this->response("101", "请求参数错误");
}
$start_day = date('Y-m-01 00:00:00', strtotime('-1 month'));
$end_day = date("Y-m-d 23:59:59", strtotime(-date('d') . 'day'));
$list = $this->service_->totalAgent( $start_day, $end_day,$params["site_id"]);
if (count($list) > 0) {
return $this->response("200", "request success", $list);
}
return $this->response("200", "request null");
}
}
\ No newline at end of file
......@@ -116,4 +116,23 @@ class RankingListService
}
public function totalAgent( $yesterday, $end_day,$site_id)
{
$totalModel = new TAgentTotalModel();
$where_ = [];
$where_['b.site_id'] = $site_id;
$where_['a.total_time'] = array( 'between', array( $yesterday, $end_day ) );
$field = "a.agent_id,b.name,c.store_name,sum(a.performance) as performance_total";
$order = "performance_total desc";
$data["agent_sort"] = $totalModel->getTotalByPk($field, $where_, 1, $order);
$data["store_sort"] = $totalModel->getTotalByPk($field, $where_, 2, $order);
return $data;
}
}
\ No newline at end of file
......@@ -40,6 +40,7 @@ class TAgentTotalModel extends Model
return 0;
}
}
/**
* @param $params
* @return int
......@@ -48,7 +49,7 @@ class TAgentTotalModel extends Model
{
Db::startTrans();
try {
foreach ($params as $k=>$v) {
foreach ($params as $k => $v) {
$this->db_->table($this->table)->update($v);
}
// $this->saveAll($params);
......@@ -87,7 +88,7 @@ class TAgentTotalModel extends Model
* @param string $order
* @return false|\PDOStatement|string|\think\Collection
*/
public function getTotalByAgentId($field ,$params, $type ,$order = "")
public function getTotalByAgentId($field, $params, $type, $order = "")
{
$group_ = "";
switch ($type) {
......@@ -113,6 +114,33 @@ class TAgentTotalModel extends Model
}
public function getTotalByPk($field, $params, $type, $order = "", $limit = 5)
{
$group_ = "";
switch ($type) {
case 1:
$group_ = "a.agent_id";
break;
case 2:
$group_ = "a.store_id";
break;
default:
return null;
}
$result = $this->db_
->field($field)
->alias("a")
->join("a_agents b","a.agent_id=b.id","left")
->join("a_store c","a.store_id=c.id","left")
->where($params)
->group($group_)
->order($order)
->select();
//echo $this->db_->getLastSql();
return $result;
}
/**
* 获取分组统计数据-加入站点
* @param $field
......@@ -121,7 +149,7 @@ class TAgentTotalModel extends Model
* @param string $order
* @return false|\PDOStatement|string|\think\Collection
*/
public function getTotalByAgentIdSite($field ,$params, $type ,$order = "")
public function getTotalByAgentIdSite($field, $params, $type, $order = "")
{
$group_ = "";
switch ($type) {
......@@ -149,7 +177,7 @@ class TAgentTotalModel extends Model
}
public function getTotalByAgentIdPage($pageNo,$pageSize,$field ,$params, $type ,$order = "")
public function getTotalByAgentIdPage($pageNo, $pageSize, $field, $params, $type, $order = "")
{
$group_ = "";
switch ($type) {
......@@ -177,7 +205,7 @@ class TAgentTotalModel extends Model
}
public function getTotalByAgentIdCount($field ,$params, $type ,$order = "")
public function getTotalByAgentIdCount($field, $params, $type, $order = "")
{
$group_ = "";
switch ($type) {
......@@ -204,8 +232,6 @@ class TAgentTotalModel extends Model
}
/**
* 统计时间端经纪人业绩
* @param $field
......@@ -221,7 +247,6 @@ class TAgentTotalModel extends Model
}
/**
* 获取分组统计数据-pc后台业绩用
* @param $field
......@@ -230,7 +255,7 @@ class TAgentTotalModel extends Model
* @param string $order
* @return false|\PDOStatement|string|\think\Collection
*/
public function getTotalByAgentIdForPcPerformance($field ,$params, $type ,$order = "",$pageSize,$pageNo)
public function getTotalByAgentIdForPcPerformance($field, $params, $type, $order = "", $pageSize, $pageNo)
{
$group_ = "";
switch ($type) {
......@@ -260,7 +285,7 @@ class TAgentTotalModel extends Model
}
public function getTotalByAgentIdForPcPerformanceTotal($field ,$params, $type ,$order = "")
public function getTotalByAgentIdForPcPerformanceTotal($field, $params, $type, $order = "")
{
$group_ = "";
switch ($type) {
......@@ -287,7 +312,7 @@ class TAgentTotalModel extends Model
}
public function getTotalByAgentIdForPcPerformanceSum($field ,$params, $type ,$order = "")
public function getTotalByAgentIdForPcPerformanceSum($field, $params, $type, $order = "")
{
$group_ = "";
switch ($type) {
......@@ -313,15 +338,4 @@ class TAgentTotalModel extends Model
return $result;
}
public function getSortPerformance($field ,$params){
$data = $this->db_
->field($field)
->where($params)
->group("agent_id")
->order("performance desc")
->select();
//echo $this->getLastSql();
return $data;
}
}
\ No newline at end of file
......@@ -360,6 +360,7 @@ Route::group('index', [
'getRandKingList' => ['index/RankingList/getRandKingList', ['method' => 'GET|POST']], //设置角色站点
'exportReport' => ['index/RankingList/exportReport', ['method' => 'GET|POST']],
'selectPkSortByTime' => ['index/RankingList/selectPkSortByTime', ['method' => 'GET|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