Commit bd0b3a05 authored by clone's avatar clone

业绩模块

parent 9addc727
...@@ -99,11 +99,11 @@ class Performance extends Basic ...@@ -99,11 +99,11 @@ class Performance extends Basic
public function storePerformanceBySearch() public function storePerformanceBySearch()
{ {
$params = $this->params; $params = $this->params;
$params = array( /* $params = array(
"agent_id" => 1, "agent_id" => 1,
"start_time" => "2018-03-23", "start_time" => "2018-03-10",
"end_time" => "2018-03-23", "end_time" => "2018-03-23",
); );*/
try { try {
$result = $this->service_->storePerformance($params["agent_id"], $params["start_time"], $params["end_time"]); $result = $this->service_->storePerformance($params["agent_id"], $params["start_time"], $params["end_time"]);
...@@ -120,14 +120,14 @@ class Performance extends Basic ...@@ -120,14 +120,14 @@ class Performance extends Basic
public function orderNoList() public function orderNoList()
{ {
$params = $this->params; $params = $this->params;
$params = array( /* $params = array(
"agent_id" => 1, "agent_id" => 1,
"start_time" => "2018-03-23", "start_time" => "2018-03-13",
"end_time" => "2018-03-23", "end_time" => "2018-03-26",
"is_case" => 2,//1经纪人 2案场 "is_case" => 2,//1经纪人 2案场
"house_id" => 0, "house_id" => 0,
"type" => 2 // 1带看 2进场 3收款 4成交报告 "type" => 1 // 1带看 2进场 3收款 4成交报告
); );*/
if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"]) || !isset($params["type"])) { if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"]) || !isset($params["type"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
...@@ -146,6 +146,10 @@ class Performance extends Basic ...@@ -146,6 +146,10 @@ class Performance extends Basic
} }
} }
/**
* 门店或者经纪人业绩排行
* @return \think\Response
*/
public function storeOrAgentSort(){ public function storeOrAgentSort(){
$params = $this->params; $params = $this->params;
$params = array( $params = array(
......
...@@ -343,7 +343,6 @@ class PerformanceService ...@@ -343,7 +343,6 @@ class PerformanceService
{ {
$result = $this->agentModel->searchAgentsByKeyword("id,store_id,district_id,level", [ "id" => $agent_id ]); $result = $this->agentModel->searchAgentsByKeyword("id,store_id,district_id,level", [ "id" => $agent_id ]);
dump($result);
if (count($result) <= 0) { if (count($result) <= 0) {
return null; return null;
} }
...@@ -351,12 +350,7 @@ class PerformanceService ...@@ -351,12 +350,7 @@ class PerformanceService
$field = "store_id,agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,sum(march_in_num) as march_in_num, $field = "store_id,agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,sum(march_in_num) as march_in_num,
sum(performance) as performance,sum(official_receipts) as official_receipts"; sum(performance) as performance,sum(official_receipts) as official_receipts";
/* $where_["agent_id"] = $agent_id;
$where_['total_time'] = array( 'between', array( $start_time, $end_time ) );
$list = $this->totalModel->personagePerformance($field, $where_);*/
$type = 0; $type = 0;
if ($result[0]["level"] == 20) { if ($result[0]["level"] == 20) {
$type = 1; $type = 1;
$params["store_id"] = $result[0]["store_id"]; $params["store_id"] = $result[0]["store_id"];
...@@ -367,11 +361,23 @@ class PerformanceService ...@@ -367,11 +361,23 @@ class PerformanceService
$params['total_time'] = array( 'between', array( $start_time, $end_time ) ); $params['total_time'] = array( 'between', array( $start_time, $end_time ) );
$field = "agent_id,store_id,district_id,sum(performance) as performance_total"; $order = "total_time desc";
$order = "total_time desc"; $list = $this->totalModel->getTotalByAgentId($field, $params, $type, $order);
$result = $this->totalModel->getTotalByAgentId($field, $params, $type, $order); if (count($list) > 0) {
dump($result); foreach ($list as $key => $item) {
$fields = "a.name,b.store_name";
$where_["a.store_id"] = $item["store_id"];
$info = $this->agentModel->getStoreOrAgentInfo($fields, $where_);
if (count($info) > 0) {
$list[$key]["store_name"] = $info[0]["store_name"];
$list[$key]["name"] = $info[0]["name"];
}else{
$list[$key]["store_name"] = "";
$list[$key]["name"] = "";
}
}
}
return $list;
} }
private function sumDistrictPerformance($params) private function sumDistrictPerformance($params)
......
...@@ -205,6 +205,7 @@ class AppChat extends Basic ...@@ -205,6 +205,7 @@ class AppChat extends Basic
*/ */
public function uploadImg() public function uploadImg()
{ {
header('Access-Control-Allow-Origin:*');
$file = request()->file('image'); $file = request()->file('image');
$data = []; $data = [];
if ($file) { if ($file) {
......
...@@ -454,7 +454,17 @@ class AAgents extends BaseModel ...@@ -454,7 +454,17 @@ class AAgents extends BaseModel
->find(); ->find();
} }
/** public function getStoreOrAgentInfo($field ,$params){
$result = Db::table($this->table)
->field($field)
->alias("a")
->join("a_store b","a.store_id = b.id","left")
->where($params)
->where('a.level',['=',20],['=',40],'or')
->select();
return $result;
}
/**
* 根据id获取经纪人信息 * 根据id获取经纪人信息
* *
* @param $field * @param $field
......
...@@ -92,6 +92,9 @@ class TAgentTotalModel extends Model ...@@ -92,6 +92,9 @@ class TAgentTotalModel extends Model
} }
/** /**
* 统计时间端经纪人业绩 * 统计时间端经纪人业绩
* @param $field * @param $field
......
...@@ -363,6 +363,7 @@ Route::group('broker', [ ...@@ -363,6 +363,7 @@ Route::group('broker', [
'selectPerformanceByTime' => ['api_broker/Performance/selectPerformanceByTime', ['method' => 'get']], 'selectPerformanceByTime' => ['api_broker/Performance/selectPerformanceByTime', ['method' => 'get']],
'agentPerformanceBySearch' => ['api_broker/Performance/agentPerformanceBySearch', ['method' => 'get']], 'agentPerformanceBySearch' => ['api_broker/Performance/agentPerformanceBySearch', ['method' => 'get']],
'orderNoList' => ['api_broker/Performance/orderNoList', ['method' => 'get']], 'orderNoList' => ['api_broker/Performance/orderNoList', ['method' => 'get']],
'storePerformanceBySearch' => ['api_broker/Performance/storePerformanceBySearch', ['method' => 'get']],
'storeOrAgentSort' => ['api_broker/Performance/storeOrAgentSort', ['method' => 'get']], 'storeOrAgentSort' => ['api_broker/Performance/storeOrAgentSort', ['method' => 'get']],
'weekWorkImg' => ['api_broker/Statement/weekWorkImg', ['method' => 'post']], //生成周报和日报图片 'weekWorkImg' => ['api_broker/Statement/weekWorkImg', ['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