Commit d875c191 authored by clone's avatar clone Committed by hujun

业绩排行

parent 54d577d4
......@@ -37,9 +37,9 @@ class Performance extends Basic
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
/* $params = array(
"agent_id" => 10013,
"type" => 1, //1表示个人业绩排行 2门店 3区域
/* $params = array(
"agent_id" => 80,
"type" => 3, //1表示个人业绩排行 2门店 3区域
"end_day" => "",
"start_day" =>""
);*/
......@@ -47,7 +47,7 @@ class Performance extends Basic
return $this->response("101", "请求参数错误");
}
//默认排序一周
$end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", strtotime("-1 day"));
$end_day = !empty($params["end_day"]) ? $params["end_day"] : date("Y-m-d", time());
$start_day = !empty($params["start_day"]) ? $params["start_day"] : date("Y-m-d", strtotime("-7 day"));
$list = $this->service_->totalAgent($params["agent_id"], $params["type"], $end_day, $start_day);
//dump($list);
......
......@@ -91,9 +91,11 @@ class PerformanceService
if ($value["store_id"] == $agent_info["store_id"] || $key < 5) {
$value["index_"] = $key + 1;
$value["is_my"] = $agent_info["store_id"];
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"] ]);
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"] ,""]);
$store_name = $this->agentModel->getStoreOrDistrict(["store_id"=>$value["store_id"],"level"=>20]);
$name = count($store_name) > 0 ? $store_name[0]["name"] : "---";
if (count($info) > 0) {
$value["name"] = $info[0]["name"];
$value["name"] = $name;
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$value["district_name"] = $info[0]["district_name"];
......@@ -105,8 +107,10 @@ class PerformanceService
$value["index_"] = $key + 1;
$value["is_my"] = $agent_info["district_id"];
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"] ]);
$district_name = $this->agentModel->getStoreOrDistrict(["store_id"=>$value["store_id"],"level"=>["in","30,40"]]);
$name = count($district_name) > 0 ? $district_name[0]["name"] : "---";
if (count($info) > 0) {
$value["name"] = $info[0]["name"];
$value["name"] = $name;
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$value["district_name"] = $info[0]["district_name"];
......
......@@ -444,6 +444,15 @@ class AAgents extends BaseModel
}
public function getStoreOrDistrict($params){
$result = Db::table($this->table)
->field("id,name")
->where($params)
->select();
//echo Db::table($this->table)->getLastSql();
return $result;
}
public function searchAgentsByKeyword($field, $params)
{
......
......@@ -87,7 +87,7 @@ class TAgentTotalModel extends Model
->group($group_)
->order($order)
->select();
//echo $this->db_->getLastSql();
// echo $this->db_->getLastSql();
return $result;
}
......
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