Commit a61c63be authored by zhuwei's avatar zhuwei

业绩日报周报重写

parent 4948c360
......@@ -4,6 +4,7 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\StatementService;
use app\model\AAgents;
use app\model\RAgentNote;
use app\model\RAgentReport;
use think\Exception;
......@@ -37,11 +38,17 @@ class Statement extends Basic
header('Access-Control-Allow-Origin:*');
$params = $this->params;
Log::write($params, 'zhuwei'); //记录日志
/*$params = array(
"agent_id" => 3742,//5739 总监 5740店长
"time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()),
);*/
$params = array (
'agent_id' => '5739',
'time_start' => '2018-11-23',
'time_end' => '2018-11-23',
);
if (!isset($params["agent_id"]) || !isset($params["time_start"]) || !isset($params["time_end"])) {
return $this->response("101", "请求参数错误");
......@@ -208,20 +215,52 @@ class Statement extends Basic
header('Access-Control-Allow-Origin:*');
$params = $this->params;
/*$params = array(
"agent_id" => 3742,//5739 总监 5740店长
"time_start" => date("Y-m-d", time()),
"time_end" => date("Y-m-d", time()),
"agent_id" => 5739,//5739 总监 5740店长
"day_or_week" => 0,//0 日报 1 周报
);*/
if (!isset($params["agent_id"]) || !isset($params["time_start"]) || !isset($params["time_end"])) {
return $this->response("101", "请求参数错误");
}
$day_or_week = $params["time_start"] == $params["time_end"] ? 'day' : 'week';
$time_end = $params["time_end"] . " 23:59:59";
$result = $this->service_->selectStatementByAgentId($params["agent_id"], $params["time_start"], $time_end,$day_or_week);
#当前登录人角色 0经纪人 1店长 2总监
$field = "id,store_id,district_id,level,name,phone,sex,status";
$agentModel = new AAgents();
$agent_result = $agentModel->getAgentById($field, [ "agent_id" => $params["agent_id"] ]);
if(!$agent_result){
return $this->response("200", "request is null");
}
$store_id = $agent_result[0]["store_id"];
$district_id = $agent_result[0]["district_id"];
if ($agent_result[0]["level"] == 10) {
//todo 业务员 Clerk
$agent_level = 0;
$result = $this->service_->selectStatementForClerk($params["agent_id"], $agent_level, $store_id,$district_id);
} elseif ($agent_result[0]["level"] == 20) {
//todo 1店长
$agent_level = 1;
if($params["day_or_week"] == 0 ){
//todo 日报
}else{
//todo 周报
}
} else {
//todo 2总监
$agent_level = 2;
if($params["day_or_week"] == 0 ){
//todo 日报
}else{
//todo 周报
}
}
if (count($result) > 0) {
if ($result) {
return $this->response("200", "request success", $result);
} else {
return $this->response("200", "request is null");
......
......@@ -706,6 +706,10 @@ Route::group('broker', [
'getVolume' => [ 'api_broker/SpreadUser/getVolume', [ 'method' => 'get' ] ],
'getHouseAddress' => [ 'api_broker/shop/getHouseAddress', [ 'method' => 'get' ] ] //搜索商铺地址
//业绩日报周报重写
'dayStatement' => ['api_broker/Statement/dayStatement', ['method' => 'get|post']],
]);
//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