Commit ab5718fc authored by zhuwei's avatar zhuwei

业绩汇总判断请求来源

parent 48f0b235
......@@ -41,7 +41,8 @@ class Performance extends Basic
"agent_id" => 80,
"type" => 3, //1表示个人业绩排行 2门店 3区域
"end_day" => "",
"start_day" =>""
"start_day" =>"",
'request_source_type'=>""
);*/
if (!isset($params["agent_id"]) || !isset($params["type"])) {
return $this->response("101", "请求参数错误");
......@@ -51,9 +52,10 @@ class Performance extends Basic
//$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-d", strtotime("-7 day"));
$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-01", time());
$request_source_type = !empty($params["request_source_type"]) ? $params["request_source_type"] : 0 ;//请求来源默认0:App 1:PC后台
$list = $this->service_->totalAgent($params["agent_id"], $params["type"], $end_day, $start_day);
$list = $this->service_->totalAgent($params["agent_id"], $params["type"], $end_day, $start_day,$request_source_type);
//dump($list);
if (count($list) > 0) {
$result["list"] = $list;
......
......@@ -62,7 +62,7 @@ class PerformanceService
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function totalAgent($agent_id, $type, $yesterday, $end_day)
public function totalAgent($agent_id, $type, $yesterday, $end_day,$request_source_type)
{
$agent_info = $this->getStoreAndDistrict($agent_id);
......@@ -90,10 +90,13 @@ class PerformanceService
//dump($result);
$arr = [];
$field = "a.name,a.img,b.store_name,c.district_name";
//dump($result);
$ranking_num = $request_source_type == 0 ? 5 : 100 ;//App显示前5 PC后台显示前100
foreach ($result as $key => $value) {
switch ($type) {
case 1:
if ($value["agent_id"] == $agent_info["id"] || $key < 5) {
if ($value["agent_id"] == $agent_info["id"] || $key < $ranking_num) {
$value["index_"] = $key + 1;
$value["is_my"] = $agent_info["id"];
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"] ]);
......@@ -111,7 +114,7 @@ class PerformanceService
}
break;
case 2:
if ($value["store_id"] == $agent_info["store_id"] || $key < 5) {
if ($value["store_id"] == $agent_info["store_id"] || $key < $ranking_num) {
$value["index_"] = $key + 1;
$value["is_my"] = $agent_info["store_id"];
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"], "" ]);
......
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