Commit fea349bc authored by clone's avatar clone

修改

parent 2aab4e53
......@@ -29,13 +29,13 @@ class FollowUp extends Basic
*/
public function report()
{
/* $params = $this->params;
$params = $this->params;
if (!isset($params['report_agent_id']) || !isset($params['report_store_id']) || !isset($params['user_id']) ||
!isset($params['house_ids']) || !isset($params['vehicle']) ) {
return $this->response("101", "请求参数错误");
}*/
}
$params = array(
/* $params = array(
"report_agent_id" => 1,
"report_store_id" => 1,
"user_id" => 1,
......@@ -43,7 +43,7 @@ class FollowUp extends Basic
"vehicle" => 10,
"intro" => "123123123",
"to_see_time" => date("Y-m-d H:i:s", time()),
);
);*/
$result = $this->followUpModel->addFollowUp($params);
if($result["code"] == 200){
return $this->response("200", "request success", ["id",$result["msg"]]);
......
<?php
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\PerformanceService;
use think\Request;
......@@ -11,10 +13,12 @@ use think\Request;
* Time : 下午2:06
* Intro: 业绩模块
*/
class Performance extends Basic{
class Performance extends Basic
{
private $service_;
function __construct(Request $request = null)
{
parent::__construct($request);
......@@ -28,28 +32,46 @@ class Performance extends Basic{
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function selectPerformanceByTime(){
public function selectPerformanceByTime()
{
$params = $this->params;
/* $params = array(
"agent_id" => 1,
"type" => 1, //1表示个人业绩排行 2门店 3区域
);*/
if(!isset($params["agent_id"]) || !isset($params["type"])){
return $this->response("101","请求参数错误");
/* $params = array(
"agent_id" => 1,
"type" => 1, //1表示个人业绩排行 2门店 3区域
);*/
if (!isset($params["agent_id"]) || !isset($params["type"])) {
return $this->response("101", "请求参数错误");
}
$yesterday = date("Y-m-d", strtotime("-1 day"));
$end_day = date("Y-m-d", strtotime("-7 day"));
$list = $this->service_->totalAgent($params["agent_id"],$params["type"],$yesterday,$end_day);
$list = $this->service_->totalAgent($params["agent_id"], $params["type"], $yesterday, $end_day);
//dump($list);
if(count($list) > 0){
$result["list"] = $list;
if (count($list) > 0) {
$result["list"] = $list;
$result["start_time"] = $yesterday;
$result["end_time"] = $end_day;
return $this->response("200","request success",$result);
$result["end_time"] = $end_day;
return $this->response("200", "request success", $result);
}
}
public function agentPerformanceBySearch()
{
$params = $this->params;
$params = array(
"agent_id" => 1,
"start_time" => "2018-03-23",
"end_time" => "2018-03-23",
"is_case" => 1,//1经纪人 2案场
);
if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"])) {
return $this->response("101", "请求参数错误");
}
$result = $this->service_->personagePerformance($params["agent_id"], $params["start_time"], $params["end_time"], $params["is_case"]);
return $this->response("200", "request success", $result);
}
}
......@@ -386,22 +386,4 @@ class OrderLogService
}
/**
* 根据手机号和用户名搜索经纪人
* @param $keyWord
* @return false|\PDOStatement|string|\think\Collection
*/
/* public function searchAgents($agent_id, $keyWord)
{
$params["a.phone|a.name|b."] = array( "like", "%$keyWord%" );
//$field = "id,store_id,auth_group_id,district_id,level,name,phone";
$filed = "a.id,a.create_time,b.user_phone,b.user_name,b.user_id,d.id as house_id,d.internal_title,d.internal_address";
$agentModel = new AAgents();
return $agentModel->searchAgentsByKeyword($field, $params);
}*/
}
\ No newline at end of file
......@@ -3,7 +3,13 @@
namespace app\api_broker\service;
use app\model\AAgents;
use app\model\GHouses;
use app\model\OBargainModel;
use app\model\OMarchInModel;
use app\model\OPayLogModel;
use app\model\OReportModel;
use app\model\TAgentTotalModel;
use app\model\Users;
/**
* Created by PhpStorm.
......@@ -16,11 +22,27 @@ class PerformanceService
{
private $totalModel;
private $agentModel;
private $agentsModel;
private $tAgentTotalModel;
private $houseModel;
private $userModel;
private $bargainModel;
private $reportModel;
private $marchInModel;
private $payLogModel;
public function __construct()
{
$this->totalModel = new TAgentTotalModel();
$this->agentModel = new AAgents();
$this->totalModel = new TAgentTotalModel();
$this->agentModel = new AAgents();
$this->agentsModel = new AAgents();
$this->tAgentTotalModel = new TAgentTotalModel();
$this->houseModel = new GHouses();
$this->userModel = new Users();
$this->bargainModel = new OBargainModel();
$this->reportModel = new OReportModel();
$this->marchInModel = new OMarchInModel();
$this->payLogModel = new OPayLogModel();
}
......@@ -41,11 +63,11 @@ class PerformanceService
$where_ = [];
$where_['total_time'] = array( 'between', array( $end_day, $yesterday, ) );
$where_['total_time'] = array( 'between', array( $end_day, $yesterday ) );
$result = $this->totalModel->getTotalByAgentId($where_, $type);
//dump($result);
$arr = [];
$arr = [];
$field = "a.name,a.img,b.store_name,c.district_name";
foreach ($result as $key => $value) {
switch ($type) {
......@@ -53,11 +75,11 @@ class PerformanceService
if ($value["agent_id"] == $agent_info["id"] || $key < 5) {
$value["index_"] = $key + 1;
$value["is_my"] = $agent_info["id"];
$info = $this->agentModel->getAgentsInfoByAgentId($field,["agent_id"=>$value["agent_id"]]);
if(count($info) > 0){
$value["name"] = $info[0]["name"];
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"] ]);
if (count($info) > 0) {
$value["name"] = $info[0]["name"];
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$value["district_name"] = $info[0]["district_name"];
}
array_push($arr, $value);
......@@ -67,11 +89,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"]]);
if(count($info) > 0){
$value["name"] = $info[0]["name"];
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"] ]);
if (count($info) > 0) {
$value["name"] = $info[0]["name"];
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$value["district_name"] = $info[0]["district_name"];
}
array_push($arr, $value);
......@@ -80,11 +102,11 @@ class PerformanceService
case 3:
$value["index_"] = $key + 1;
$value["is_my"] = $agent_info["district_id"];
$info = $this->agentModel->getAgentsInfoByAgentId($field,["agent_id"=>$value["agent_id"]]);
if(count($info) > 0){
$value["name"] = $info[0]["name"];
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$info = $this->agentModel->getAgentsInfoByAgentId($field, [ "agent_id" => $value["agent_id"] ]);
if (count($info) > 0) {
$value["name"] = $info[0]["name"];
$value["img"] = AGENTHEADERIMGURL . $info[0]["img"];
$value["store_name"] = $info[0]["store_name"];
$value["district_name"] = $info[0]["district_name"];
}
array_push($arr, $value);
......@@ -105,7 +127,6 @@ class PerformanceService
*/
public function getStoreAndDistrict($agent_id)
{
$params["agent_id"] = $agent_id;
$agent_info = $this->agentModel->getAgentById("id,store_id,district_id,level", $params);
if (count($agent_info) > 0) {
......@@ -115,4 +136,63 @@ class PerformanceService
}
public function personagePerformance($agent_id, $start_time, $end_time, $is_case)
{
$field = "agent_id,sum(look_at_num) as look_at_num,sum(march_in_num) as march_in_num , sum(paylog) as paylog ,
sum(bargain_sum) as bargain_sum";
$result = [];
if($is_case == 2 ){ //案场
$vService = new VerifyService();
$house_id_arr = $vService->getAgentsByAgentId($agent_id);
}
$now_date = date("Y-m-d", time());
if ($start_time == $now_date && $end_time == $now_date) {
$params["agent_id"] = $agent_id;
$params['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$result = $this->nowTimeSum($params);
} else {
$where_["agent_id"] = $agent_id;
$where_['total_time'] = array( 'between', array( $start_time, $end_time ) );
$list = $this->totalModel->personagePerformance($field, $where_);
if (count($list) > 0) {
$result = $list[0];
}
}
if (count($result) > 0) {
return $result;
} else {
return null;
}
}
/**
* @param $params
* @return array
*/
private function nowTimeSum($params)
{
$result = [];
$reportNum = $this->reportModel->getAddReportNum($params);
if (count($reportNum) > 0) {
$result["look_at_num"] = $reportNum[0]["num"];
}
$addMarchInNum = $this->marchInModel->getAddMarchInNum($params);
if (count($addMarchInNum) > 0) {
$result["march_in_num"] = $addMarchInNum[0]["num"];
}
$payLogNum = $this->payLogModel->getAddPayLogNum($params);
if (count($payLogNum) > 0) {
$result["paylog"] = $payLogNum[0]["num"];
}
$bargainSum = $this->bargainModel->getAddBargainNum($params);//表示统计
if (count($bargainSum) > 0) {
$result["bargain_sum"] = $bargainSum[0]["num"];
}
return $result;
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
namespace app\api_broker\service;
use app\model\AAgents;
use app\model\GHousesToAgents;
/**
* Created by PhpStorm.
......@@ -20,6 +21,11 @@ class VerifyService
$this->agentModel = new AAgents();
}
/**
* 经纪人身份验证
* @param $agent_id
* @return null|string
*/
public function getAgentsByAgentId($agent_id)
{
$params["id"] = $agent_id;
......@@ -38,7 +44,7 @@ class VerifyService
break;
}
$ids = "";
if(count($arr_list) > 0){
if (count($arr_list) > 0) {
foreach ($arr_list as $item) {
$ids .= $item["id"] . ",";
}
......@@ -49,4 +55,19 @@ class VerifyService
}
return null;
}
public function getCaseHouseIdByAgentId($agent_id)
{
$houseToAgentModel = new GHousesToAgents();
$params["agents_id"] = $agent_id;
$params["type"] = 1; //案场权限人
$params["is_del"] = 0;
$house_arr = $houseToAgentModel->getHouseByAgentId("houses_id", $params);
if (count($house_arr) > 0) {
return $house_arr;
}
return null;
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
namespace app\model;
use Think\Db;
use think\Model;
class GHousesToAgents extends BaseModel
......@@ -138,6 +139,18 @@ class GHousesToAgents extends BaseModel
->select();
}
/**
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getHouseByAgentId($field,$params){
return Db::name($this->table)
->field($field)
->where($params)
->select();
}
/**
* 楼盘对应的经纪人信息
*
......
......@@ -309,7 +309,6 @@ class OBargainModel extends Model
$field = "count(1) as num,DATE(create_time) as day";
}
$where_["status"] = 11; //审核成功
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
......@@ -324,4 +323,21 @@ class OBargainModel extends Model
->group("day")
->select();
}
public function getAddBargainNum($params){
$where_ = [];
$field = "count(1) as num";
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
->field($field)
->where($where_)
->select();
}
}
\ No newline at end of file
......@@ -96,4 +96,19 @@ class OMarchInModel extends Model
->select();
}
public function getAddMarchInNum($params){
$field = "count(1) as num";
$where_ = [];
if(isset($params["agent_id"])){
$where_["reception_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
->field($field)
->where($where_)
->select();
}
}
\ No newline at end of file
......@@ -93,4 +93,19 @@ class OPayLogModel extends Model
->group("day")
->select();
}
public function getAddPayLogNum($params){
$field = "count(1) as num";
$where_ = [];
if(isset($params["agent_id"])){
$where_["agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["create_time"] = $params["create_time"];
}
return Db::table($this->table)
->field($field)
->where($where_)
->select();
}
}
\ No newline at end of file
......@@ -153,4 +153,26 @@ class OReportModel extends Model
->group("day")
->select();
}
public function getAddReportNum($params){
$field = "count(1) as num";
$where_ = [];
if(isset($params["agent_id"])){
$where_["a.report_agent_id"] = $params["agent_id"];
}
if(isset($params["create_time"])){
$where_["a.create_time"] = $params["create_time"];
}
if(isset($params["house_ids"])){
$where_["b.house_id"] = array("in",$params["house_ids"]);
}
$where_["a.status"] = 0;
return Db::table($this->table)
->field($field)
->alias("a")
->join("o_order b","a.order_id = b.id","left")
->where($where_)
->select();
}
}
\ No newline at end of file
<?php
namespace app\model;
use think\Db;
use think\Model;
......@@ -10,8 +12,8 @@ use think\Model;
* Time : 下午2:00
* Intro:
*/
class TAgentTotalModel extends Model{
class TAgentTotalModel extends Model
{
protected $table = "t_agent_total";
private $db_;
......@@ -24,7 +26,8 @@ class TAgentTotalModel extends Model{
* @param $params
* @return int
*/
public function addTotal($params){
public function addTotal($params)
{
Db::startTrans();
try {
$this->db_->insertAll($params);
......@@ -44,7 +47,8 @@ class TAgentTotalModel extends Model{
* @param $param
* @return false|\PDOStatement|string|\think\Collection
*/
public function getTotalEndTimeByAgentId($field,$param){
public function getTotalEndTimeByAgentId($field, $param)
{
return $this->db_
->field($field)
->where($param)
......@@ -53,9 +57,16 @@ class TAgentTotalModel extends Model{
->select();
}
public function getTotalByAgentId($params , $type){
/**
* 获取分组统计数据
* @param $params
* @param $type
* @return false|\PDOStatement|string|\think\Collection
*/
public function getTotalByAgentId($params, $type)
{
$group_ = "agent_id";
switch ($type){
switch ($type) {
case 1:
$group_ = "agent_id";
break;
......@@ -66,7 +77,7 @@ class TAgentTotalModel extends Model{
$group_ = "district_id";
break;
}
$result = $this->db_
$result = $this->db_
->field("agent_id,store_id,district_id,sum(performance) as performance_total")
->where($params)
->group($group_)
......@@ -76,4 +87,18 @@ class TAgentTotalModel extends Model{
return $result;
}
/**
* 统计时间端经纪人业绩
* @param $field
* @param $param
* @return false|\PDOStatement|string|\think\Collection
*/
public function personagePerformance($field, $param)
{
return $this->db_
->field($field)
->where($param)
->select();
}
}
\ No newline at end of file
......@@ -361,10 +361,14 @@ Route::group('broker', [
'selectPerformanceByTime' => ['api_broker/Performance/selectPerformanceByTime', ['method' => 'get']],
'agentPerformanceBySearch' => ['api_broker/Performance/agentPerformanceBySearch', ['method' => 'get']],
'weekWorkImg' => ['api_broker/Statement/weekWorkImg', ['method' => 'post']], //生成周报和日报图片
'setReportContent' => ['api_broker/Statement/setReportContent', ['method' => 'get|post']], //保存日报周报四个字段
'getWeekOrDay' => ['api_broker/Statement/getWeekOrDay', ['method' => 'get']], //获取日报或者周报
]);
//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