Commit f05e8411 authored by zw's avatar zw

日报周报

parent b66b2dd5
...@@ -28,13 +28,12 @@ class Statement extends Basic ...@@ -28,13 +28,12 @@ class Statement extends Basic
public function dayStatement() public function dayStatement()
{ {
$params = $this->params; $params = $this->params;
$params = array( /* $params = array(
"agent_id" => 1, "agent_id" => 1,
//"type" => 1, // 1.日报 2.周报
"time_start" => date("Y-m-d", time()), "time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()) . " 23:59:59", "time_end" => date("Y-m-d", time()) . " 23:59:59",
); );*/
if (!isset($params["agent_id"]) || !isset($params["type"])) { if (!isset($params["agent_id"]) || !isset($params["time_start"]) || !isset($params["time_end"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
try { try {
......
...@@ -19,6 +19,10 @@ class StatementService { ...@@ -19,6 +19,10 @@ class StatementService {
private $userModel; private $userModel;
private $followUpModel; private $followUpModel;
const USER_LEVEL_FIST = 0; //经纪人
const USER_LEVEL_SECOND = 1; //店长
const USER_LEVEL_THIRD = 2; //总监
function __construct() function __construct()
{ {
$this->agentModel = new AAgents(); $this->agentModel = new AAgents();
...@@ -46,12 +50,12 @@ class StatementService { ...@@ -46,12 +50,12 @@ class StatementService {
return null; return null;
} }
$user_type = 0; //经纪人权限,0经纪人 1店长 2总监 $user_type = self::USER_LEVEL_FIST; //经纪人权限,0经纪人 1店长 2总监
if($agent_result[0]["level"] == 20){ if($agent_result[0]["level"] == 20){
$user_type = 1; $user_type = self::USER_LEVEL_SECOND;
}elseif ($agent_result[0]["level"] == 30 || $agent_result[0]["level"] == 40 ){ }elseif ($agent_result[0]["level"] == 30 || $agent_result[0]["level"] == 40 ){
$user_type = 2; $user_type = self::USER_LEVEL_THIRD;
} }
$store_id = $agent_result[0]["store_id"]; $store_id = $agent_result[0]["store_id"];
$district_id = $agent_result[0]["district_id"]; $district_id = $agent_result[0]["district_id"];
...@@ -63,6 +67,7 @@ class StatementService { ...@@ -63,6 +67,7 @@ class StatementService {
} }
private function selectStatement($conditions,$user_type,$store_id,$district_id){ private function selectStatement($conditions,$user_type,$store_id,$district_id){
$result = $params = []; $result = $params = [];
switch ($user_type){ switch ($user_type){
case 0: case 0:
...@@ -79,9 +84,12 @@ class StatementService { ...@@ -79,9 +84,12 @@ class StatementService {
break; break;
} }
$agent_total = 1; //进到这里的经纪人肯定都存在所以默认此经纪人数量为1
if(!empty($params)){ if(!empty($params)){
$agentsArr = $this->agentModel->getAgentsByStoreId($params); $agentsArr = $this->agentModel->getAgentsByStoreId($params);
if(count($agentsArr) > 0){ $agent_total = count($agentsArr);
if($agent_total > 0){
$agentIds = ""; $agentIds = "";
foreach ($agentsArr as $key => $value){ foreach ($agentsArr as $key => $value){
$agentIds .= $value["id"] . ","; $agentIds .= $value["id"] . ",";
...@@ -91,6 +99,7 @@ class StatementService { ...@@ -91,6 +99,7 @@ class StatementService {
} }
} }
$result["agent_total"] = $agent_total;
$result["house_num"] = $this->houseModel->getAddHouseNumByAgentId($conditions); $result["house_num"] = $this->houseModel->getAddHouseNumByAgentId($conditions);
$result["user_num"] = $this->userModel->getAddUserNumByAgentId($conditions); $result["user_num"] = $this->userModel->getAddUserNumByAgentId($conditions);
$result["follow_up_num"] = $this->followUpModel->getAddFollowUpNumByAgentId($conditions); $result["follow_up_num"] = $this->followUpModel->getAddFollowUpNumByAgentId($conditions);
......
...@@ -335,9 +335,11 @@ class AAgents extends BaseModel ...@@ -335,9 +335,11 @@ class AAgents extends BaseModel
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
*/ */
public function getAgentsByStoreId($params){ public function getAgentsByStoreId($params){
return Db::table($this->table) $result = Db::table($this->table)
->field("id") ->field("id")
->where($params) ->where($params)
->select(); ->select();
echo Db::table($this->table)->getLastSql();
return $result;
} }
} }
\ No newline at end of file
...@@ -298,6 +298,12 @@ Route::group('broker', [ ...@@ -298,6 +298,12 @@ Route::group('broker', [
'getAgentsByPhone' => ['api_broker/broker/getAgentsByPhone', [ 'method' => 'get' ] ], 'getAgentsByPhone' => ['api_broker/broker/getAgentsByPhone', [ 'method' => 'get' ] ],
'agentsPhone' => ['api_broker/CellPhone/agentsPhone', [ 'method' => 'get|post' ] ], //获取经纪人拨打界面手机号 'agentsPhone' => ['api_broker/CellPhone/agentsPhone', [ 'method' => 'get|post' ] ], //获取经纪人拨打界面手机号
'dayStatement' => ['api_broker/Statement/dayStatement', [ 'method' => 'get|post' ] ],
]); ]);
//Route::miss('api/index/miss');//处理错误的url //Route::miss('api/index/miss');//处理错误的url
\ No newline at end of file
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