Commit 14c2778b authored by clone's avatar clone

Merge branch 'test-0814-bug' into test

# Conflicts: # application/index/service/PerformanceService.php
parents de010fbf 2c2e42a5
...@@ -271,13 +271,14 @@ class Broker extends Basic ...@@ -271,13 +271,14 @@ class Broker extends Basic
{ {
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$params = $this->params; $params = $this->params;
/*
$params['content']='跟进内容';//跟进内容 /*$params['content']='跟进内容';//跟进内容
$params['labels_id']=1;//g_labels表主键 $params['labels_id']=1;//g_labels表主键
$params['user_id']=1;//u_users ID用户表id $params['user_id']=59072;//u_users ID用户表id
$params['agent_id']=1;//agent表id-当前登录用户id $params['agent_id']=1;//agent表id-当前登录用户id
$params['type']='1';//0电话跟进 1普通跟进 $params['type']='1';//0电话跟进 1普通跟进
*/ $params['user_status']='1';//0电话跟进 1普通跟进*/
$checkResult = $this->validate($params, "BrokerValidate.verifyStatus"); $checkResult = $this->validate($params, "BrokerValidate.verifyStatus");
if (true !== $checkResult) { if (true !== $checkResult) {
...@@ -287,11 +288,18 @@ class Broker extends Basic ...@@ -287,11 +288,18 @@ class Broker extends Basic
$user_id = $params['user_id']; $user_id = $params['user_id'];
$user_status = $params['user_status']; $user_status = $params['user_status'];
$Users = new Users();
$result = $Users->getUserCityInfo($user_id);
if($result){
$params['province'] = $result[0]['province'] ? $result[0]['province'] : '上海市';
$params['city'] = $result[0]['city']? $result[0]['city'] : '上海市';
$params['disc'] = $result[0]['disc']? $result[0]['disc'] : '黄浦区';
}
//主表查询商铺详细信息 //主表查询商铺详细信息
$UPhoneFollowPp = new UPhoneFollowPp(); $UPhoneFollowPp = new UPhoneFollowPp();
$result = $UPhoneFollowPp->savePhoneFollow($params); $result = $UPhoneFollowPp->savePhoneFollow($params);
//跟进,对客户状态进行更新 0:求租;1:已租;-1:无效 //跟进,对客户状态进行更新 0:求租;1:已租;-1:无效
$Users = new Users();
$Users->update_user_status([ 'id' => $user_id, 'user_status' => $user_status ]); $Users->update_user_status([ 'id' => $user_id, 'user_status' => $user_status ]);
if ($result == 1) { if ($result == 1) {
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
namespace app\api_broker\controller; namespace app\api_broker\controller;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\model\AAgents;
use app\model\GHouses;
use app\model\GHousesFollowUp; use app\model\GHousesFollowUp;
use app\model\UPhoneFollowPp; use app\model\UPhoneFollowPp;
use think\Request; use think\Request;
...@@ -37,14 +39,14 @@ class HomePageLog extends Basic ...@@ -37,14 +39,14 @@ class HomePageLog extends Basic
public function userFollowUpList() public function userFollowUpList()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /*$params = array(
"start_time" => time(), //开始时间 "start_time" => strtotime('2016-08-14 15:47:36'), //开始时间
"end_time" => time() . " 23:59:59", //结束时间 "end_time" => strtotime('2018-08-14 15:47:36'), //结束时间
"name_or_phone" => "li",//用户姓名或电话 经纪人 "name_or_phone" => "18112347151",//用户姓名或电话 经纪人
"search_content" => "111",// 搜索跟进内容 "search_content" => "",// 搜索跟进内容
"pageNo" => 1, "pageNo" => 1,
"pageSize" => 15 "pageSize" => 15
);*/ );*/
if (empty($params['start_time']) || empty($params['end_time'])) { if (empty($params['start_time']) || empty($params['end_time'])) {
return $this->response("101", '请选择时间'); return $this->response("101", '请选择时间');
...@@ -53,7 +55,7 @@ class HomePageLog extends Basic ...@@ -53,7 +55,7 @@ class HomePageLog extends Basic
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo']; $pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize']; $pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field = "f.id,f.user_id,f.agent_id,f.type,f.content,f.create_time,f.user_status,a.name,a.img,b.store_name"; $field = "f.id,f.user_id,f.agent_id,f.type,f.content,f.create_time,f.user_status";
$where_ = []; $where_ = [];
if (!empty($params["search_content"])) { if (!empty($params["search_content"])) {
$where_["f.content"] = array( "like", "%" . trim($params['search_content']) . "%" ); $where_["f.content"] = array( "like", "%" . trim($params['search_content']) . "%" );
...@@ -63,25 +65,44 @@ class HomePageLog extends Basic ...@@ -63,25 +65,44 @@ class HomePageLog extends Basic
$end_time = date("Y-m-d H:i:s", $params["end_time"]); $end_time = date("Y-m-d H:i:s", $params["end_time"]);
$where_["f.create_time"] = array( 'between', array( $start_time, $end_time ) ); $where_["f.create_time"] = array( 'between', array( $start_time, $end_time ) );
} }
if (!empty($params["name_or_phone"])) { if (!empty($params["name_or_phone"])) {
$where_["a.name|a.phone"] = array( "like", "%" . trim($params["name_or_phone"]) . "%" ); if ((preg_match("/^1\d{10}$/", $params['name_or_phone']) != 1) or (strlen($params['name_or_phone']) < 6)) {
return $this->response("300", '手机号有误或者姓名不满两位汉字');
}
$agent_params["phone|name"] = $params["name_or_phone"];
$agent_field = "id";
$model = new AAgents();
$res_a = $model->getAgentsIdsArray($agent_field, $agent_params);
if ($res_a) {
$where_["f.agent_id"] = [ 'in', $res_a ];
}
} }
$where_["u.city"] = trim($this->city); $where_["f.city"] = trim($this->city) ? trim($this->city) : '上海市';
$join = [ $order = "f.id desc";
[ 'a_agents a', 'a.id=f.agent_id', 'left' ],
[ 'u_users u', 'u.id=f.user_id', 'left' ], $result = $this->uPhoneFollowUpModel->getSearch($pageNo, $pageSize, $order, $field, [], $where_, "");
[ 'a_store b', 'b.id=a.store_id', 'left' ],
]; foreach ($result as $key => $value) {
$order = "f.id desc"; $agent_params = [];
$result = $this->uPhoneFollowUpModel->getSearch($pageNo, $pageSize, $order, $field, $join, $where_, ""); $agent_params["a.id"] = $value['agent_id'];
//$count = $this->uPhoneFollowUpModel->getSearchCount($join, $where_); $agent_field = "a.name,a.img,b.store_name";
$model = new AAgents();
$res_a = $model->getAgentsInfo($agent_field, $agent_params);
$result[$key]['name'] = $res_a[0]['name'];
$result[$key]['img'] = $res_a[0]['img'];
$result[$key]['store_name'] = $res_a[0]['store_name'];
}
$count = $this->uPhoneFollowUpModel->getSearchCount($where_);
if (count($result) > 0) { if (count($result) > 0) {
$list["result"] = $result; $list["result"] = $result;
$list["img_path"] = AGENTHEADERIMGURL; $list["img_path"] = AGENTHEADERIMGURL;
//暂时处理 //暂时处理
$list["total"] = 0; $list["total"] = $count;
return $this->response("200", "request success", $list); return $this->response("200", "request success", $list);
} else { } else {
return $this->response("200", "request null"); return $this->response("200", "request null");
...@@ -100,15 +121,15 @@ class HomePageLog extends Basic ...@@ -100,15 +121,15 @@ class HomePageLog extends Basic
public function houseFollowUpList() public function houseFollowUpList()
{ {
$params = $this->params; $params = $this->params;
/* $params = array(
"start_time" => time(), //开始时间
"end_time" => time() . " 23:59:59", //结束时间
"name_or_phone" => "li",//用户姓名或电话
"search_content" => "111",// 搜索跟进内容
"pageNo" => 1,
"pageSize" => 15
);*/
/*$params = array(
"start_time" => strtotime('2016-08-14 11:02:36'), //开始时间
"end_time" => strtotime('2018-08-14 11:07:10'), //结束时间
"name_or_phone" => "18112347151",//用户姓名或电话
"search_content" => "1",// 搜索跟进内容
"pageNo" => 1,
"pageSize" => 15
);*/
if (empty($params['start_time']) || empty($params['end_time'])) { if (empty($params['start_time']) || empty($params['end_time'])) {
return $this->response("101", '请选择时间'); return $this->response("101", '请选择时间');
...@@ -119,38 +140,69 @@ class HomePageLog extends Basic ...@@ -119,38 +140,69 @@ class HomePageLog extends Basic
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo']; $pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize']; $pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field = "f.id,f.house_id,f.agent_id,f.follow_up_info,f.create_time,a.name,a.img,b.store_name,c.internal_title"; $field = "f.id,f.house_id,f.agent_id,f.follow_up_info,f.create_time,f.agent_name as name";
if (!empty($params["search_content"])) { if (!empty($params["search_content"])) {
$where_["f.follow_up_info"] = array( "like", "%" . trim($params['search_content']) . "%" ); $where_["f.follow_up_info"] = array( "like", "%" . trim($params['search_content']) . "%" );
} }
if (!empty($params["start_time"]) && !empty($params["end_time"])) { if (!empty($params["start_time"]) && !empty($params["end_time"])) {
$start_time = date("Y-m-d H:i:s", $params["start_time"]); $start_time = date("Y-m-d H:i:s", $params["start_time"]);
$end_time = date("Y-m-d H:i:s", $params["end_time"]); $end_time = date("Y-m-d H:i:s", $params["end_time"]);
$where_["f.create_time"] = array( 'between', array( $start_time, $end_time ) ); $where_["f.create_time"] = array( 'between', array( $start_time, $end_time ) );
} }
if (!empty($params["name_or_phone"])) {
$where_["a.phone|a.name"] = array( "like", "%" . trim($params["name_or_phone"]) . "%" );
}
if (empty($params['city'])) { if (empty($params['city'])) {
$where_["c.city"] = trim($this->city); $where_["f.city"] = trim($this->city) ? trim($this->city) : '上海市';
} else { } else {
$where_["c.city"] = $params['city']; $where_["f.city"] = $params['city'] ? $params['city'] : '上海市';
} }
if (!empty($params['disc'])) { if (!empty($params['disc'])) {
$where_["c.disc"] = $params['disc']; $where_["f.disc"] = $params['disc'];
}
if (!empty($params["province"]) && !empty($params["province"])) {
$where_["f.province"] = $params["province"];
} }
$join = [
[ 'a_agents a', 'a.id=f.agent_id', 'left' ], if (!empty($params["name_or_phone"])) {
[ 'a_store b', 'b.id=a.store_id', 'left' ], if ((preg_match("/^1\d{10}$/", $params['name_or_phone']) != 1) or (strlen($params['name_or_phone']) < 6)) {
[ 'g_houses c', 'f.house_id=c.id', 'left' ] return $this->response("300", '手机号有误或者姓名不满两位汉字');
]; }
//$agent_params["phone|name"] = array( "like", "%" . trim($params["name_or_phone"]) . "%" );
$agent_params["phone|name"] = $params["name_or_phone"];
$agent_field = "id";
$model = new AAgents();
$res_a = $model->getAgentsIdsArray($agent_field, $agent_params);
if ($res_a) {
$where_["f.agent_id"] = [ 'in', $res_a ];
}
}
$join = [];
$order = "f.id desc"; $order = "f.id desc";
$result = $this->gHouseFollowUpModel->getSearch($pageNo, $pageSize, $order, $field, $join, $where_, ""); $result = $this->gHouseFollowUpModel->getSearch($pageNo, $pageSize, $order, $field, $join, $where_, "");
$count = $this->gHouseFollowUpModel->getSearchCount($join, $where_); foreach ($result as $key => $value) {
$agent_params = [];
$agent_params["a.id"] = $value['agent_id'];
$agent_field = "a.name,a.img,b.store_name";
$model = new AAgents();
$res_a = $model->getAgentsInfo($agent_field, $agent_params);
$result[$key]['name'] = $res_a[0]['name'];
$result[$key]['img'] = $res_a[0]['img'];
$result[$key]['store_name'] = $res_a[0]['store_name'];
$house_params = [];
$house_params["id"] = $value['house_id'];
$house_field = "internal_title";
$model = new GHouses();
$res_a = $model->getHouseInfo($house_field, $house_params);
$result[$key]['internal_title'] = $res_a[0]['internal_title'];
}
$count = $this->gHouseFollowUpModel->getSearchCount($join, $where_);
if (count($result) > 0) { if (count($result) > 0) {
$list["result"] = $result; $list["result"] = $result;
$list["img_path"] = AGENTHEADERIMGURL; $list["img_path"] = AGENTHEADERIMGURL;
......
...@@ -85,7 +85,7 @@ class Performance extends Basic ...@@ -85,7 +85,7 @@ class Performance extends Basic
$house_id = $params["house_id"]; $house_id = $params["house_id"];
} }
try { try {
$result = $this->service_->personagePerformance($params["agent_id"], $params["start_time"], $params["end_time"], $result = $this->service_->personagePerformance($params["agent_id"], $params["start_time"], $params["end_time"] ." 23:59:59",
$params["is_case"], $house_id); $params["is_case"], $house_id);
return $this->response("200", "request success", $result); return $this->response("200", "request success", $result);
} catch (Exception $exception) { } catch (Exception $exception) {
...@@ -108,7 +108,7 @@ class Performance extends Basic ...@@ -108,7 +108,7 @@ class Performance extends Basic
"end_time" => "2018-06-25", "end_time" => "2018-06-25",
);*/ );*/
try { try {
$result = $this->service_->storePerformance($params["agent_id"], $params["start_time"], $params["end_time"]); $result = $this->service_->storePerformance($params["agent_id"], $params["start_time"], $params["end_time"]." 23:59:59");
return $this->response("200", "request success", $result); return $this->response("200", "request success", $result);
} catch (Exception $exception) { } catch (Exception $exception) {
return $this->response("101", "request error,msg:" . $exception); return $this->response("101", "request error,msg:" . $exception);
...@@ -164,11 +164,11 @@ class Performance extends Basic ...@@ -164,11 +164,11 @@ class Performance extends Basic
"end_time" => "2018-04-12", "end_time" => "2018-04-12",
);*/ );*/
if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"])) { if (!isset($params["agent_id"]) || !isset($params["start_time"]) || !isset($params["end_time"] )) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
try { try {
$result = $this->service_->storeSortByDistrictId($params["agent_id"], $params["is_store"], $params["start_time"], $params["end_time"]); $result = $this->service_->storeSortByDistrictId($params["agent_id"], $params["is_store"], $params["start_time"], $params["end_time"]." 23:59:59");
return $this->response("200", "request success", $result); return $this->response("200", "request success", $result);
} catch (Exception $exception) { } catch (Exception $exception) {
......
...@@ -577,6 +577,14 @@ class Shop extends Basic ...@@ -577,6 +577,14 @@ class Shop extends Basic
|| !isset($params["agent_name"]) || !isset($params["agent_phone"])) { || !isset($params["agent_name"]) || !isset($params["agent_phone"])) {
return $this->response("101", "请求参数错误"); return $this->response("101", "请求参数错误");
} }
$result = $this->gHousesModel->getHouseInfo('province,city,disc', [ 'id' => $params["house_id"]]);
if($result){
$params['province'] = $result[0]['province'] ? $result[0]['province'] : '上海市';
$params['city'] = $result[0]['city']? $result[0]['city'] : '上海市';
$params['disc'] = $result[0]['disc']? $result[0]['disc'] : '黄浦区';
}
$follow_up_model = new GHousesFollowUp(); $follow_up_model = new GHousesFollowUp();
$id = $follow_up_model->addHousesFollowUp($params); $id = $follow_up_model->addHousesFollowUp($params);
if ($id > 0) { if ($id > 0) {
......
...@@ -48,8 +48,13 @@ class CallPhoneService ...@@ -48,8 +48,13 @@ class CallPhoneService
return $result; return $result;
} }
if ((strlen($phone_a) != 11) || (strlen($phone_b) != 11)) { if (strlen($phone_a) != 11) {
$result['msg'] = '号码格式错误,请重新填写!'; $result['msg'] = '本机号码格式错误!';
return $result;
}
if (strlen($phone_b) != 11) {
$result['msg'] = '客户手机号码格式错误,请与客方沟通!';
return $result; return $result;
} }
......
...@@ -65,12 +65,12 @@ class PerformanceService ...@@ -65,12 +65,12 @@ class PerformanceService
$agent_info = $agent_info[0]; $agent_info = $agent_info[0];
} }
$where_ = []; $where_ = [];
$where_['a.create_time'] = array( 'between', array( $yesterday . " 00:00:00", $end_day . " 23:59:59" ) ); $where_['total_time'] = array( 'between', array( $yesterday, $end_day ) );
$field = "b.id as agent_id,b.store_id,b.district_id,sum(a.scale_fee) as performance_total"; $field = "agent_id,store_id,district_id,sum(performance) as performance_total";
$order = "performance_total desc"; $order = "performance_total desc";
$result = $this->bargainModel->getTotalByAgentId($field, $where_, $type, $order); $result = $this->totalModel->getTotalByAgentId($field, $where_, $type, $order);
//dump($result); //dump($result);
$arr = []; $arr = [];
$field = "a.name,a.img,b.store_name,c.district_name"; $field = "a.name,a.img,b.store_name,c.district_name";
...@@ -140,24 +140,17 @@ class PerformanceService ...@@ -140,24 +140,17 @@ class PerformanceService
$result = []; $result = [];
switch ($is_case) { switch ($is_case) {
case 1: case 1:
/* $now_date = date("Y-m-d", time()); $field = "agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,
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, 1);
/*} else {
$field = "agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,
sum(performance) as performance,sum(official_receipts) as official_receipts,sum(look_at_num) as look_at_num, sum(performance) as performance,sum(official_receipts) as official_receipts,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"; sum(march_in_num) as march_in_num , sum(paylog) as paylog , sum(bargain_sum) as bargain_sum";
$where_["agent_id"] = $agent_id; $where_["agent_id"] = $agent_id;
$where_['total_time'] = array( 'between', array( $start_time, $end_time ) ); $where_['total_time'] = array( 'between', array( $start_time, $end_time ) );
$list = $this->totalModel->personagePerformance($field, $where_); $list = $this->totalModel->personagePerformance($field, $where_);
if (count($list) > 0) { if (count($list) > 0) {
$result = $list[0]; $result = $list[0];
} }
}*/
break; break;
case 2: //案场 case 2: //案场
$house_id_arr = []; $house_id_arr = [];
...@@ -179,7 +172,7 @@ class PerformanceService ...@@ -179,7 +172,7 @@ class PerformanceService
} }
$condition['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $condition['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$condition["is_case"] = $is_case; $condition["is_case"] = $is_case;
$result = $this->nowTimeSum($condition, 2); $result = $this->nowTimeSum($condition, 2);
if (count($result) > 0 && $house_id == 0) { if (count($result) > 0 && $house_id == 0) {
$result["house_arr"] = $house_id_arr; $result["house_arr"] = $house_id_arr;
...@@ -232,7 +225,7 @@ class PerformanceService ...@@ -232,7 +225,7 @@ class PerformanceService
break; break;
} }
$result = $this->getOrderList($params, $type,$is_case); $result = $this->getOrderList($params, $type, $is_case);
if (count($result) > 0) { if (count($result) > 0) {
return $result; return $result;
} else { } else {
...@@ -241,7 +234,7 @@ class PerformanceService ...@@ -241,7 +234,7 @@ class PerformanceService
} }
public function getOrderList($params, $type,$is_case) public function getOrderList($params, $type, $is_case)
{ {
$result = []; $result = [];
//1带看 2进场 3收款 4成交报告 //1带看 2进场 3收款 4成交报告
...@@ -261,7 +254,7 @@ class PerformanceService ...@@ -261,7 +254,7 @@ class PerformanceService
break; break;
case 4: case 4:
$field = "DATE(a.create_time) as create_time ,b.house_id,b.house_title,c.user_phone,c.user_name,c.user_id,d.internal_title,d.internal_address"; $field = "DATE(a.create_time) as create_time ,b.house_id,b.house_title,c.user_phone,c.user_name,c.user_id,d.internal_title,d.internal_address";
$result = $this->bargainModel->getAddBargainOrderList($field, $params,$is_case); $result = $this->bargainModel->getAddBargainOrderList($field, $params, $is_case);
break; break;
default: default:
...@@ -335,33 +328,17 @@ class PerformanceService ...@@ -335,33 +328,17 @@ class PerformanceService
$params["district_id"] = $result[0]["district_id"]; $params["district_id"] = $result[0]["district_id"];
} }
//$list = []; $field = "sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,
//$now_date = date("Y-m-d", time());
// if ($start_time == $now_date && $end_time == $now_date) {
$verify = new VerifyService();
$agent_ids = $verify->getAgentsByAgentId($agent_id);
$where_["agent_id"] = array( "in", $agent_ids );
$where_['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$list = $this->sumDistrictPerformance($where_);
// dump($list);exit;
/* } else {
$field = "sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,
sum(performance) as performance,sum(official_receipts) as official_receipts,sum(look_at_num) as look_at_num, sum(performance) as performance,sum(official_receipts) as official_receipts,sum(look_at_num) as look_at_num,
sum(march_in_num) as march_in_num,sum(paylog) as paylog,sum(supervision_num) as supervision_num"; sum(march_in_num) as march_in_num,sum(paylog) as paylog,sum(supervision_num) as supervision_num";
$params['total_time'] = array( 'between', array( $start_time, $end_time ) ); $params['total_time'] = array( 'between', array( $start_time, $end_time ) );
$list = $this->totalModel->getTotalByAgentId($field, $params, $type, ""); $list = $this->totalModel->getTotalByAgentId($field, $params, $type, "");
// dump($list); // dump($list);
if (count($list) > 0) { if (count($list) > 0) {
$list = $list[0]; $list = $list[0];
} }
}*/
if (count($list) > 0) { if (count($list) > 0) {
return $list; return $list;
...@@ -390,63 +367,15 @@ class PerformanceService ...@@ -390,63 +367,15 @@ class PerformanceService
$verify = new VerifyService(); $verify = new VerifyService();
$agent_ids = $verify->getAgentsByAgentId($agent_id); $agent_ids = $verify->getAgentsByAgentId($agent_id);
$params["agent_id"] = array( "in", $agent_ids ); $params["agent_id"] = array( "in", $agent_ids );
$list = [];
/* $now_date = date("Y-m-d", time());
if ($start_time == $now_date && $end_time == $now_date) {*/
$param["id"] = array( "in", $agent_ids );
// 1.获取所有经纪人
$field = "id as agent_id,store_id";
$group = "";
if ($is_store == 2) {
$group = "store_id";
}
$list = $this->agentModel->getAgentsList($field, $param, $group);
//dump($list);
foreach ($list as $key => $item) {
$totalParams['create_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$totalParams['agent_id'] = $item["agent_id"];
if ($is_store == 2) {
$agent_ids = $verify->getAgentsByAgentId($item["agent_id"]);
$totalParams['agent_id'] = array( "in", $agent_ids );
}
//房源
$addHouseNum = $this->houseModel->getAddHouseNum($totalParams);
$list[$key]["add_house_num"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
//客源
$addUserNum = $this->userModel->getAddUserNum($totalParams);
$list[$key]["add_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
//进场
$addMarchInNum = $this->marchInModel->getAddMarchInNum($totalParams);
$list[$key]["march_in_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
//业绩
$performanceSum = $this->bargainModel->getAddBargainNum($totalParams, 1);//1表示业绩 2表示实收
$list[$key]["performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//实收
$receivedSum = $this->bargainModel->getAddBargainNum($totalParams, 2);//1表示业绩 2表示实收
$list[$key]["official_receipts"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
$sum = $list[$key]["add_house_num"] + $list[$key]["add_user_num"] + $list[$key]["march_in_num"] +
$list[$key]["performance"]
+ $list[$key]["official_receipts"];
if ($sum <= 0) {
unset($list[$key]);
}
}
$field = "store_id,agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,sum(march_in_num) as march_in_num,
/* } else {
$field = "store_id,agent_id,sum(add_house_num) as add_house_num,sum(add_user_num) as add_user_num,sum(march_in_num) as march_in_num,
sum(performance) as performance,sum(official_receipts) as official_receipts"; sum(performance) as performance,sum(official_receipts) as official_receipts";
$params['total_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) ); $params['total_time'] = array( 'between', array( $start_time . " 00:00:00", $end_time . " 23:59:59" ) );
$order = "total_time desc";
$list = $this->totalModel->getTotalByAgentId($field, $params, $is_store, $order);
$order = "total_time desc";
$list = $this->totalModel->getTotalByAgentId($field, $params, $is_store, $order);
}*/
if (count($list) > 0) { if (count($list) > 0) {
foreach ($list as $key => $item) { foreach ($list as $key => $item) {
...@@ -471,51 +400,6 @@ class PerformanceService ...@@ -471,51 +400,6 @@ class PerformanceService
return $list; return $list;
} }
private function sumDistrictPerformance($params)
{
$result = [];
//房源
$addHouseNum = $this->houseModel->getAddHouseNum($params);
$result["add_house_num"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;
//dump($addHouseNum);
//客源
$addUserNum = $this->userModel->getAddUserNum($params);
$result["add_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
//dump($addUserNum);
//业绩
$performanceSum = $this->bargainModel->getAddBargainNum($params, 1);//1表示业绩 2表示实收
$result["performance"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
//实收
$receivedSum = $this->bargainModel->getReceived($params);
$result["official_receipts"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;
//dump($receivedSum);
//约带看
$reportNum = $this->reportModel->getAddReportNum($params);
$result["look_at_num"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;
//dump($reportNum);
//进场
$addMarchInNum = $this->marchInModel->getAddMarchInNum($params);
$result["march_in_num"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;
//dump($addMarchInNum);
//收款
$payLogNum = $this->payLogModel->getAddPayLogNum($params);
$result["paylog"] = isset($payLogNum[0]["num"]) ? $payLogNum[0]["num"] : 0;
//dump($payLogNum);
// 监督
$result["supervision_num"] = $this->superviseModel->getSuperviseListCount($params);
return $result;
}
/** /**
* 组装请求参数 * 组装请求参数
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
<tr> <tr>
<td>商铺编号:{{d.id}}</td> <td>商铺编号:{{d.id}}</td>
<td>商铺类型:{{(d.shop_type==1)?'街铺':'商场'}}</td> <td>商铺类型:{{(d.shop_type==1)?'街铺':'商场'}}</td>
<td>是否对客户展示:{{d.is_show?'否':'是'}}</td> <td>是否对客户展示:{{(d.is_show==1)?'否':'是'}}</td>
<td>是否独家:{{d.is_exclusive_type?'是':'否'}}</td> <td>是否独家:{{(d.is_exclusive_type==1)?'是':'否'}}</td>
</tr> </tr>
<tr> <tr>
<td>{{dealPrice}}</td> <td>{{dealPrice}}</td>
...@@ -74,16 +74,16 @@ ...@@ -74,16 +74,16 @@
<tr class="tr-seat"> <tr class="tr-seat">
<td colspan="4"></td> <td colspan="4"></td>
</tr> </tr>
<tr v-if="!d.is_show"> <tr v-if="!(d.is_show==1)">
<td colspan="2">对外商铺名称:{{d.external_title}}</td> <td colspan="2">对外商铺名称:{{d.external_title}}</td>
<td colspan="2">对外商铺地址:{{d.province}}{{d.city+d.disc+d.external_address}}</td> <td colspan="2">对外商铺地址:{{d.province}}{{d.city+d.disc+d.external_address}}</td>
</tr> </tr>
<tr v-if="!d.is_show"> <tr v-if="!(d.is_show==1)">
<td colspan="2">对外项目优势:{{d.external_item_advantage}}</td> <td colspan="2">对外项目优势:{{d.external_item_advantage}}</td>
<td v-if="d.shop_type" colspan="2">对外转让费:{{(d.external_slotting_fee == '-1')?'面议':(d.external_slotting_fee+'元')}}</td> <td v-if="d.shop_type" colspan="2">对外转让费:{{(d.external_slotting_fee == '-1')?'面议':(d.external_slotting_fee+'元')}}</td>
<td v-else colspan="2"></td> <td v-else colspan="2"></td>
</tr> </tr>
<tr v-if="!d.is_show && d.cover_plan"> <tr v-if="!(d.is_show==1) && d.cover_plan">
<td colspan="4" class="oh"> <td colspan="4" class="oh">
<div class="fl">对外封面图:</div> <div class="fl">对外封面图:</div>
<div class="fl"> <div class="fl">
...@@ -132,8 +132,8 @@ ...@@ -132,8 +132,8 @@
<tr> <tr>
<td>上传时间:{{d.create_time}}</td> <td>上传时间:{{d.create_time}}</td>
<td>最后编辑时间:{{d.update_time}}</td> <td>最后编辑时间:{{d.update_time}}</td>
<td v-if="d.is_exclusive_type">独家有效期:{{d.agent_start_time+'至'+d.agent_end_time}}</td> <td v-if="(d.is_exclusive_type==1)">独家有效期:{{d.agent_start_time+'至'+d.agent_end_time}}</td>
<td v-if="d.is_exclusive_type"><!--独家方:{{d.exclusive_name}}--></td> <td v-if="(d.is_exclusive_type==1)"><!--独家方:{{d.exclusive_name}}--></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
...@@ -21,6 +21,7 @@ use app\model\OFinancialAudit; ...@@ -21,6 +21,7 @@ use app\model\OFinancialAudit;
use app\model\OPartialCommission; use app\model\OPartialCommission;
use app\model\OPayLogModel; use app\model\OPayLogModel;
use app\model\ORefundModel; use app\model\ORefundModel;
use app\task\controller\ResultsSummaryNewTask;
class Finance extends Basic class Finance extends Basic
{ {
...@@ -1433,13 +1434,30 @@ class Finance extends Basic ...@@ -1433,13 +1434,30 @@ class Finance extends Basic
if (empty($this->params['scale'])) { if (empty($this->params['scale'])) {
return $this->response(101, '分佣比例为空'); return $this->response(101, '分佣比例为空');
} }
//检查成交报告是否存在
$data = $m_bargain->getBargainPartialDetail('a.id,a.agent_id,a.create_time', ['id'=>$this->params['bargain_id']]);
if (empty($data['id'])) {
return $this->response(101, '没有成交报告信息');
}
$update['agent_id'] = $this->params['agent_id']; $update['agent_id'] = $this->params['agent_id'];
$update['scale'] = $this->params['scale']; $update['scale'] = $this->params['scale'];
$update['role'] = $this->params['role']; $update['role'] = $this->params['role'];
$update['scale_fee'] = $this->params['scale_fee']; $update['scale_fee'] = $this->params['scale_fee'];
$data = $m_bargain->updateBargainById($this->params['bargain_id'], $update); $data = $m_bargain->updateBargainById($this->params['bargain_id'], $update); //更改分佣方
//获取被修改人信息
$m_agent = new AAgents();
$agent_data = $m_agent->verifyUser('id,store_id,district_id', '',['id'=>$this->params['agent_id']]);
//更新业绩统计
$sum = new ResultsSummaryNewTask();
$date = date('Y-m-d', strtotime($data['create_time']));
$sum->updateTotalByAgentId($agent_data['id'], $agent_data['store_id'], $agent_data['district_id'], $date); //被修改的人
$sum->updateTotalByAgentId($data['agent_id'], $data['store_id'], $data['district_id'], $date);//修改为最新的分佣方
/*记录日志 start*/ /*记录日志 start*/
$bargain_data = $m_bargain->selectBargainByOrderNo('agent_id,father_id', ['id'=>$this->params['bargain_id']]); $bargain_data = $m_bargain->selectBargainByOrderNo('agent_id,father_id', ['id'=>$this->params['bargain_id']]);
......
...@@ -7,18 +7,43 @@ ...@@ -7,18 +7,43 @@
*/ */
namespace app\index\controller; namespace app\index\controller;
use app\index\extend\Basic; use app\index\extend\Basic;
class HouseFollowUp extends Basic{ use app\model\GHouses;
//在controller里新增的php文件名 use app\model\GHousesFollowUp;
public function followUpList(){
//followUpList 方法 class HouseFollowUp extends Basic
if (!$this->request->isAjax()) { {
return view('houses/HouseFollowUp'); public function followUpList()
//找到view下的 houses 文件夹下的 HouseFollowUp的html 文件 {
if (!$this->request->isAjax()) {
return view('houses/HouseFollowUp');
} }
} }
/**
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function transformFollowUp()
{
$time = time();
$m_house = new GHouses();
$m_follow = new GHousesFollowUp();
$total = $m_follow->getTotal();
$page = ceil($total / 5000);
for ($i = 1; $i <= $page; $i++) {
$data = $m_house->getList($i, 5000, 'id asc', 'id,province,city,disc');
foreach ($data as $k => $v) {
$insert['province'] = $v['province'];
$insert['city'] = $v['city'];
$insert['disc'] = $v['disc'];
$m_follow->where('house_id', $v['id'])->update($insert);
}
}
echo time() - $time . '秒';
}
} }
\ No newline at end of file
...@@ -15,6 +15,7 @@ use app\index\validate\HouseValidate; ...@@ -15,6 +15,7 @@ use app\index\validate\HouseValidate;
use app\model\AAgents; use app\model\AAgents;
use app\model\ACollectHouse; use app\model\ACollectHouse;
use app\model\GHouses; use app\model\GHouses;
use app\model\GHousesExt;
use app\model\GHousesImgs; use app\model\GHousesImgs;
use app\model\GHousesToAgents; use app\model\GHousesToAgents;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
...@@ -118,16 +119,16 @@ class Houses extends Basic ...@@ -118,16 +119,16 @@ class Houses extends Basic
$data['status'] = 200; $data['status'] = 200;
$data['msg'] = ''; $data['msg'] = '';
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$agent_where = [];
$where['a.status'] = [ '<>', 3 ]; $where['status'] = [ '<>', 3 ];
/*精选商铺--0是1否*/ /*精选商铺--0是1否*/
if ($this->params['is_carefully_chosen'] != -1) { if ($this->params['is_carefully_chosen'] != -1) {
if ($this->params['is_carefully_chosen'] == 1) { if ($this->params['is_carefully_chosen'] == 1) {
$where['a.is_carefully_chosen'] = 1; $where['is_carefully_chosen'] = 1;
$where['a.status'] = 1; $where['status'] = 1;
} else { } else {
$where['a.is_carefully_chosen'] = 0; $where['a.is_carefully_chosen'] = 0;
} }
...@@ -136,149 +137,169 @@ class Houses extends Basic ...@@ -136,149 +137,169 @@ class Houses extends Basic
/*0是1否显示在c端用户*/ /*0是1否显示在c端用户*/
if ($this->params['is_show'] != -1) { if ($this->params['is_show'] != -1) {
if ($this->params['is_show'] == 1) { if ($this->params['is_show'] == 1) {
$where['a.is_show'] = 1; $where['is_show'] = 1;
} else { } else {
$where['a.is_show'] = 0; $where['is_show'] = 0;
} }
} }
/*商铺类型(0商场,1街铺)*/ /*商铺类型(0商场,1街铺)*/
if ($this->params['shop_type'] != -1) { if ($this->params['shop_type'] != -1) {
$where['a.shop_type'] = $this->params['shop_type']; $where['shop_type'] = $this->params['shop_type'];
} }
/*所在城市*/ /*所在城市*/
if (!empty($this->params['city'])) { if (!empty($this->params['city'])) {
$where['a.city'] = $this->params['city']; $where['city'] = $this->params['city'];
} }
/*所在区*/ /*所在区*/
if (!empty($this->params['disc'])) { if (!empty($this->params['disc'])) {
$where['a.disc'] = $this->params['disc']; $where['disc'] = $this->params['disc'];
} }
/*状态 0待审批 1上架 2下架 3回收*/ /*状态 0待审批 1上架 2下架 3回收*/
if (!empty($this->params['status'])) { if (!empty($this->params['status'])) {
$where['a.status'] = $this->params['status']; $where['status'] = $this->params['status'];
} }
/*价格 -1表示营业额扣点 存分*/ /*价格 -1表示营业额扣点 存分*/
if ($this->params['rent_price'] != NULL && $this->params['rent_price'] != -1) { if ($this->params['rent_price'] != NULL && $this->params['rent_price'] != -1) {
$where['a.rent_type'] = 1; $where['rent_type'] = 1;
switch ($this->params['rent_price']) { switch ($this->params['rent_price']) {
case 1: case 1:
$where['a.rent_price'] = [ '<=', 1000000 ]; $where['rent_price'] = [ '<=', 1000000 ];
break; break;
case 2: case 2:
$where['a.rent_price'] = [ 'between', '1000000,3000000' ]; $where['rent_price'] = [ 'between', '1000000,3000000' ];
break; break;
default : default :
$where['a.rent_price'] = [ '>', '3000000' ]; $where['rent_price'] = [ '>', '3000000' ];
} }
} }
/*对内楼盘名*/ /*对内楼盘名*/
if ($this->params['internal_title'] != NULL) { if ($this->params['internal_title'] != NULL) {
$where['a.internal_title'] = [ 'LIKE', '%' . $this->params['internal_title'] . '%' ]; $where['internal_title'] = [ 'LIKE', '%' . $this->params['internal_title'] . '%' ];
} }
/*对外楼盘名*/ /*对外楼盘名*/
if ($this->params['external_title'] != NULL) { if ($this->params['external_title'] != NULL) {
$where['a.external_title'] = [ 'LIKE', '%' . $this->params['external_title'] . '%' ]; $where['external_title'] = [ 'LIKE', '%' . $this->params['external_title'] . '%' ];
} }
/*楼盘地址搜索*/ /*楼盘地址搜索*/
if ($this->params['internal_address'] != NULL) { if ($this->params['internal_address'] != NULL) {
$where['a.internal_address'] = [ 'LIKE', '%' . $this->params['internal_address'] . '%' ]; $where['internal_address'] = [ 'LIKE', '%' . $this->params['internal_address'] . '%' ];
} }
/*是否独家0否1是*/ /*是否独家0否1是*/
if ($this->params['is_exclusive_type'] != -1) { if ($this->params['is_exclusive_type'] != -1) {
$where['a.is_exclusive_type'] = $this->params['is_exclusive_type']; $where['is_exclusive_type'] = $this->params['is_exclusive_type'];
} }
/*开始时间*/ /*开始时间*/
if ($this->params['start_date'] != NULL && $this->params['end_date'] == NULL) { if ($this->params['start_date'] != NULL && $this->params['end_date'] == NULL) {
$where['a.create_time'] = [ '> time', $this->params['start_date'] . ' 00:00:00' ]; $where['create_time'] = [ '> time', $this->params['start_date'] . ' 00:00:00' ];
} }
/*结束时间*/ /*结束时间*/
if ($this->params['end_date'] != NULL && $this->params['start_date'] == NULL) { if ($this->params['end_date'] != NULL && $this->params['start_date'] == NULL) {
$where['a.create_time'] = [ '< time', $this->params['end_date'] . ' 23:59:59' ]; $where['create_time'] = [ '< time', $this->params['end_date'] . ' 23:59:59' ];
} }
/*开始结束时间*/ /*开始结束时间*/
if ($this->params['start_date'] != NULL && $this->params['end_date'] != NULL) { if ($this->params['start_date'] != NULL && $this->params['end_date'] != NULL) {
$where['a.create_time'] = [ 'between time', [ $this->params['start_date'] . ' 00:00:00', $this->params['end_date'] . ' 23:59:59' ] ]; $where['create_time'] = [ 'between time', [ $this->params['start_date'] . ' 00:00:00', $this->params['end_date'] . ' 23:59:59' ] ];
} }
/*根据库存判断是否已租*/ /*根据库存判断是否已租*/
if ($this->params['leased'] != -1) { if ($this->params['leased'] != -1) {
if ($this->params['leased'] == 0) { if ($this->params['leased'] == 0) {
$where['a.residue_num'] = 0; $where['residue_num'] = 0;
} else { } else {
$where['a.residue_num'] = [ '<>', 0 ]; $where['residue_num'] = [ '<>', 0 ];
} }
} }
/*业态*/ /*业态*/
if ($this->params['industry_type'] != NULL) { if ($this->params['industry_type'] != NULL) {
$where['a.industry_type'] = [ 'LIKE', '%' . $this->params['industry_type'] . '%' ]; $where['industry_type'] = [ 'LIKE', '%' . $this->params['industry_type'] . '%' ];
} }
$fields = 'a.id,a.shop_type,a.internal_title,a.rent_price,a.is_show,a.create_time,a.residue_num,a.rent_type, $fields = 'id,shop_type,internal_title,rent_price,is_show,create_time,residue_num,rent_type,
a.shop_area_start,a.shop_area_end,a.industry_type,d.landlord_phone,disc'; shop_area_start,shop_area_end,industry_type,disc';
/*楼盘编号*/ /*楼盘编号*/
if ($this->params['id'] != NULL) { if ($this->params['id'] != NULL) {
$where['a.id'] = $this->params['id']; $where['id'] = $this->params['id'];
} }
if ($this->params['dish_name'] != NULL) { if ($this->params['dish_name'] != NULL) {
$where['c.name'] = [ 'LIKE', '%' . $this->params['dish_name'] . '%' ]; $agent_where['b.name'] = $this->params['dish_name'];
$where['b.type'] = 2; $agent_where['a.type'] = 2;
$where['b.is_del'] = 0; $agent_where['a.is_del'] = 0;
} }
if ($this->params['dish_phone'] != NULL) { if ($this->params['dish_phone'] != NULL) {
$where['c.phone'] = [ 'LIKE', '%' . $this->params['dish_phone'] . '%' ]; $agent_where['b.phone'] = $this->params['dish_phone'];
$where['b.type'] = 2; $agent_where['a.type'] = 2;
$where['b.is_del'] = 0; $agent_where['a.is_del'] = 0;
}
if (!empty($agent_where)) {
$m_to_agent = new GHousesToAgents();
$agent_arr = $m_to_agent->getAgentsHouseField('houses_id', $agent_where);
$agent_str = implode(',', $agent_arr);
$where[] = ['EXP', "id in ({$agent_str})"];
} }
/*房东手机号搜索*/ /*房东手机号搜索*/
if ($this->params['landlord_phone'] != NULL) { if ($this->params['landlord_phone'] != NULL) {
$where['d.landlord_phone'] = [ 'LIKE', '%' . $this->params['landlord_phone'] . '%' ]; $m_house_ext = new GHousesExt();
if (strlen($this->params['landlord_phone']) != 11) {
return $this->response(101, '房东手机不足11位');
}
$house_ext_where['landlord_phone'] = ['LIKE','%'.$this->params['landlord_phone'].'%'];
$landlord_arr = $m_house_ext->getList(1,1000, '', 'house_id', $house_ext_where);
if (!empty($landlord_arr)) {
foreach ($landlord_arr as $k=>$v) {
$landlord_house_id[] = $v['house_id'];
}
$landlord_str = implode(',', $landlord_house_id);
$where[] = ['EXP', "id in ({$landlord_str})"];
}
} }
if ($this->params['city'] != NULL) { if ($this->params['city'] != NULL) {
$where['a.city'] = $this->params['city']; $where['city'] = $this->params['city'];
} }
if ($this->params['disc'] != NULL) { if ($this->params['disc'] != NULL) {
$where['a.disc'] = $this->params['disc']; $where['disc'] = $this->params['disc'];
} }
if (!empty($this->params['area'])) { if (!empty($this->params['area'])) {
switch ($this->params['area']) { switch ($this->params['area']) {
case 1: case 1:
$where['a.shop_area_start'] = ['between', [0, 30]];break; $where['shop_area_start'] = ['between', [0, 30]];break;
case 2: case 2:
$where['a.shop_area_start'] = ['between', [30, 60]];break; $where['shop_area_start'] = ['between', [30, 60]];break;
case 3: case 3:
$where['a.shop_area_start'] = ['between', [60, 100]];break; $where['shop_area_start'] = ['between', [60, 100]];break;
case 4: case 4:
$where['a.shop_area_start'] = ['between', [100, 300]];break; $where['shop_area_start'] = ['between', [100, 300]];break;
case 5: case 5:
$where['a.shop_area_start'] = ['between', [300, 500]];break; $where['shop_area_start'] = ['between', [300, 500]];break;
case 6: case 6:
$where['a.shop_area_start'] = [ '>', 500];break; $where['shop_area_start'] = [ '>', 500];break;
default : default :
$where['a.shop_area_start'] = ['>', 0]; $where['shop_area_start'] = ['>', 0];
} }
} }
$data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'a.id DESC', $fields, $where, $this->userId); $data['data']['list'] = $this->house->getHouseListDish($pageNo, $pageSize, 'id DESC', $fields, $where, $this->userId);
$data['data']['total'] = $this->house->getHouseListDishTotal($where); $data['data']['total'] = $this->house->getHouseListDishTotal($where);
$look_shop = new LookShopService(); $look_shop = new LookShopService();
......
...@@ -35,73 +35,88 @@ class Remark extends Basic ...@@ -35,73 +35,88 @@ class Remark extends Basic
$data['status'] = 200; $data['status'] = 200;
$data['msg'] = ''; $data['msg'] = '';
$where_user = $agent_where = [];
$pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo']; $pageNo = empty($this->params['pageNo']) ? 1 : $this->params['pageNo'];
$pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 15 : $this->params['pageSize'];
$u_phone_follow = new UPhoneFollowPp(); $u_phone_follow = new UPhoneFollowPp();
$last_month = date("Y-m-d", strtotime("-1 month"));
if (!empty($this->params['start_date']) && empty($this->params['end_date'])) { if (!empty($this->params['start_date']) && empty($this->params['end_date'])) {
$where['a.create_time'] = ['> time', $this->params['start_date']. ' 00:00:00']; if (strtotime($last_month) > strtotime($this->params['start_date'])) {
$where['create_time'] = ['> time', $last_month. ' 00:00:00'];
} else {
$where['create_time'] = ['> time', $this->params['start_date']. ' 00:00:00'];
}
} else {
$where['create_time'] = ['> time', $last_month. ' 00:00:00'];
} }
if (!empty($this->params['end_date']) && empty($this->params['start_date'])) { if (!empty($this->params['end_date']) && empty($this->params['start_date'])) {
$where['a.create_time'] = ['< time', $this->params['end_date']. ' 23:59:59'];; $where['create_time'] = ['< time', $this->params['end_date']. ' 23:59:59'];;
} }
if (!empty($this->params['end_date']) && !empty($this->params['start_date'])) { if (!empty($this->params['end_date']) && !empty($this->params['start_date'])) {
$where['a.create_time'] = ['between',[$this->params['start_date'].' 00:00:00',$this->params['end_date']. ' 23:59:59']]; if (strtotime($last_month) > strtotime($this->params['start_date'])) {
} $start_date = $last_month;
} else {
if (!empty($this->params['customer'])) { $start_date = $this->params['start_date'];
$where['c.user_name'] = $this->params['customer']; }
} $where['create_time'] = ['between',[$start_date.' 00:00:00',$this->params['end_date']. ' 23:59:59']];
if (!empty($this->params['phone'])) {
$where['c.user_phone'] = $this->params['phone'];
} }
if (!empty($this->params['content'])) { if (!empty($this->params['content'])) {
$where['a.content'] = ['like',"%{$this->params['content']}%"]; $where['content'] = ['LIKE',"%{$this->params['content']}%"];
} }
//跟进人名字 //跟进人名字
if (!empty($this->params['remark_name'])) { if (!empty($this->params['remark_name'])) {
$where['b.name'] = ['like', "%{$this->params['remark_name']}%"]; $agent_where['name'] = $this->params['remark_name'];
} }
//跟进人手机号 //跟进人手机号
if (!empty($this->params['remark_phone'])) { if (!empty($this->params['remark_phone'])) {
$where['b.phone'] = ['like', "%{$this->params['remark_phone']}%"]; $agent_where['phone'] = $this->params['remark_phone'];
} }
//跟进人门店 //跟进人门店
if (!empty($this->params['remark_store_id'])) { if (!empty($this->params['remark_store_id'])) {
$where['b.store_id'] = $this->params['remark_store_id']; $agent_where['store_id'] = $this->params['remark_store_id'];
} }
//跟进人部门 //跟进人部门
if (!empty($this->params['remark_district_id'])) { if (!empty($this->params['remark_district_id'])) {
$where['b.district_id'] = $this->params['remark_district_id']; $agent_where['district_id'] = $this->params['remark_district_id'];
} }
if (!empty($this->params['province'])) { if (!empty($this->params['province'])) {
$where['c.province'] = $this->params['province']; $where['province'] = $this->params['province'];
} }
if (!empty($this->params['city'])) { if (!empty($this->params['city'])) {
$where['c.city'] = $this->params['city']; $where['city'] = $this->params['city'];
} }
if (!empty($this->params['disc'])) { if (!empty($this->params['disc'])) {
$where['c.disc'] = $this->params['disc']; $where['disc'] = $this->params['disc'];
}
if (!empty($this->params['id'])) {
$where['user_id'] = $this->params['id'];
} }
$field = 'c.id,a.create_time,a.content,b.name as admin,d.name as label_name,c.user_name,c.user_phone,a.user_status,c.vip,c.agent_id'; if (!empty($where_user)) {
$data['data']['list'] = $u_phone_follow->getFollowList($pageNo, $pageSize, $order_ = 'a.id desc', $field, $where); $m_agent = new AAgents();
$agent_id_arr = $m_agent->getAgentById('id', $agent_where);
if (!empty($agent_id_arr)) {
$where['agent_id'] = ['in', $agent_id_arr];
}
}
$field = 'user_id,create_time,content,user_status,labels_id,agent_id as f_agent_id';
$data['data']['list'] = $u_phone_follow->getFollowList($pageNo, $pageSize, $order_ = 'id desc', $field, $where);
foreach ($data['data']['list'] as $k=>$v) { foreach ($data['data']['list'] as $k=>$v) {
$data['data']['list'][$k]['user_phone'] = hide_customer_phone($data['data']['list'][$k]['user_phone']); $data['data']['list'][$k]['user_phone'] = substr_replace($data['data']['list'][$k]['user_phone'],'****',3,4);
} }
$data['data']['total'] = $u_phone_follow->getFollowTotal($where); $data['data']['total'] = $u_phone_follow->getFollowTotal($where);
......
...@@ -62,13 +62,40 @@ class PerformanceService ...@@ -62,13 +62,40 @@ class PerformanceService
} }
} }
/*$where_ = [];
$where_['a.create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) ); $where_['a.create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) );
$field = "b.id as agent_id,b.store_id,b.district_id,sum(a.scale_fee) as performance_total"; $field = "b.id as agent_id,b.store_id,b.district_id,sum(a.scale_fee) as performance_total";
$order = "performance_total desc"; $order = "performance_total desc";
$result = $this->bargainModel->getTotalByAgentId($field, $where_, $type, $order); $result = $this->bargainModel->getTotalByAgentId($field, $where_, $type, $order);*/
$where_['total_time'] = array( 'between', array( $end_day, $yesterday ) );
//todo 成交报告数 bargain_sum
//todo 收款数 paylog
//todo 进场数 march_in_num
//todo 报备数 look_at_num
//todo 新增商铺数 add_house_num
//todo 新增客户数 add_user_num
//todo 团队人数 team_num
$field = "agent_id,store_id,district_id,
sum(performance) as performance_total,
sum(bargain_sum) as bargain_sum_total,
sum(paylog) as paylog_total,
sum(march_in_num) as march_in_num_total,
sum(look_at_num) as look_at_num_total,
sum(add_house_num) as add_house_num_total,
sum(add_user_num) as add_user_num_total
";
// $field = "agent_id,store_id,district_id,sum(performance) as performance_total";
$order = "performance_total desc";
//dump($where_);
$result = $this->totalModel->getTotalByAgentId($field, $where_, $type, $order);
//dump($result);
$arr = []; $arr = [];
// $total = $this->totalModel->getTotalByAgentIdCount($field, $where_, $type, $order); // $total = $this->totalModel->getTotalByAgentIdCount($field, $where_, $type, $order);
// $field = "a.name,a.img,b.store_name,c.district_name"; // $field = "a.name,a.img,b.store_name,c.district_name";
...@@ -87,41 +114,41 @@ class PerformanceService ...@@ -87,41 +114,41 @@ class PerformanceService
$value["district_name"] = $info[0]["district_name"]; $value["district_name"] = $info[0]["district_name"];
//todo 计算当日业绩 performance_total //todo 计算当日业绩 performance_total
$where_ = []; /* $where_ = [];
//$where_["district_id"] = $district_id; //$where_["district_id"] = $district_id;
$where_["agent_id"] = $value["agent_id"]; $where_["agent_id"] = $value["agent_id"];
$where_['create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) );
$obargain = new OBargainModel(); $obargain = new OBargainModel();
//dump($where_); //dump($where_);*/
//todo 计算当日成交单数 bargain_sum //todo 计算当日成交单数 bargain_sum
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收 /*$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;*/
//todo 计算当日收款数 paylog //todo 计算当日收款数 paylog
$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收 /*$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0; $value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;*/
//todo 计算当日进场数 march_in_num //todo 计算当日进场数 march_in_num
$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_); /* $addMarchInNum = $this->marchInModel->getAddMarchInNum($where_);
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0; $value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;*/
//todo 计算当日报备数 look_at_num //todo 计算当日报备数 look_at_num
$reportNum = $this->reportModel->getAddReportNum($where_); /*$reportNum = $this->reportModel->getAddReportNum($where_);
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0; $value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;*/
//todo 计算当日新增商铺数 add_house_num //todo 计算当日新增商铺数 add_house_num
$addHouseNum = $this->houseModel->getAddHouseNum($where_); /*$addHouseNum = $this->houseModel->getAddHouseNum($where_);
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0; $value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;*/
//todo 计算当日新增客户数 add_user_num //todo 计算当日新增客户数 add_user_num
$addUserNum = $this->userModel->getAddUserNum($where_); /*$addUserNum = $this->userModel->getAddUserNum($where_);
$value["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $value["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;*/
array_push($arr, $value); array_push($arr, $value);
} }
...@@ -144,7 +171,7 @@ class PerformanceService ...@@ -144,7 +171,7 @@ class PerformanceService
$value["team_num"] = $this->agentModel->getAgentsCountByStoreId($params); $value["team_num"] = $this->agentModel->getAgentsCountByStoreId($params);
//查询总监下面门店的所有经纪人 //查询总监下面门店的所有经纪人
$params = []; /*$params = [];
$params['store_id'] = $value["store_id"]; $params['store_id'] = $value["store_id"];
$params["status"] = 0; //只查询正常状态的经纪人 $params["status"] = 0; //只查询正常状态的经纪人
$agentsArr = $this->agentModel->getAgentsByStoreId($params); $agentsArr = $this->agentModel->getAgentsByStoreId($params);
...@@ -163,36 +190,36 @@ class PerformanceService ...@@ -163,36 +190,36 @@ class PerformanceService
$where_["agent_id"] = array( "in", $agentIds ); $where_["agent_id"] = array( "in", $agentIds );
$where_['create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) );
$obargain = new OBargainModel(); $obargain = new OBargainModel();
//dump($where_); //dump($where_);*/
//todo 计算当日成交单数 bargain_sum //todo 计算当日成交单数 bargain_sum
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收 /*$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;*/
//todo 计算当日收款数 paylog //todo 计算当日收款数 paylog
$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收 /*$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0; $value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;*/
//todo 计算当日进场数 march_in_num //todo 计算当日进场数 march_in_num
$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_); /*$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_);
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0; $value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;*/
//todo 计算当日报备数 look_at_num //todo 计算当日报备数 look_at_num
$reportNum = $this->reportModel->getAddReportNum($where_); /*$reportNum = $this->reportModel->getAddReportNum($where_);
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0; $value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;*/
//todo 计算当日新增商铺数 add_house_num //todo 计算当日新增商铺数 add_house_num
$addHouseNum = $this->houseModel->getAddHouseNum($where_); /*$addHouseNum = $this->houseModel->getAddHouseNum($where_);
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0; $value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;*/
//todo 计算当日新增客户数 add_user_num //todo 计算当日新增客户数 add_user_num
$addUserNum = $this->userModel->getAddUserNum($where_); /*$addUserNum = $this->userModel->getAddUserNum($where_);
$value["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $value["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;*/
//dump($value); //dump($value);
array_push($arr, $value); array_push($arr, $value);
...@@ -215,7 +242,7 @@ class PerformanceService ...@@ -215,7 +242,7 @@ class PerformanceService
$value["team_num"] = $this->agentModel->getAgentsCountByStoreId($params); $value["team_num"] = $this->agentModel->getAgentsCountByStoreId($params);
//查询总监下面门店的所有经纪人 //查询总监下面门店的所有经纪人
$params = []; /* $params = [];
$params["district_id"] = $value["district_id"]; $params["district_id"] = $value["district_id"];
$params["status"] = 0; //只查询正常状态的经纪人 $params["status"] = 0; //只查询正常状态的经纪人
$agentsArr = $this->agentModel->getAgentsByStoreId($params); $agentsArr = $this->agentModel->getAgentsByStoreId($params);
...@@ -234,36 +261,36 @@ class PerformanceService ...@@ -234,36 +261,36 @@ class PerformanceService
//$where_["district_id"] = $district_id; //$where_["district_id"] = $district_id;
$where_["agent_id"] = array( "in", $agentIds ); $where_["agent_id"] = array( "in", $agentIds );
$where_['create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) ); $where_['create_time'] = array( 'between', array( $end_day . " 00:00:00", $yesterday . " 23:59:59" ) );
$obargain = new OBargainModel(); $obargain = new OBargainModel();*/
//todo 计算当日成交单数 bargain_sum //todo 计算当日成交单数 bargain_sum
$performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收 /* $performanceSum = $obargain->getAddBargainNum($where_, 3);//1表示业绩 2表示实收
$value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $value["bargain_sum_total"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;*/
//todo 计算当日收款数 paylog //todo 计算当日收款数 paylog
$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收 /*$receivedSum = $this->bargainModel->getAddBargainNum($where_, 2);//1表示业绩 2表示实收
$value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0; $value["paylog_total"] = isset($receivedSum[0]["num"]) ? $receivedSum[0]["num"] : 0;*/
//todo 计算当日进场数 march_in_num //todo 计算当日进场数 march_in_num
$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_); /*$addMarchInNum = $this->marchInModel->getAddMarchInNum($where_);
$value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0; $value["march_in_num_total"] = isset($addMarchInNum[0]["num"]) ? $addMarchInNum[0]["num"] : 0;*/
//todo 计算当日报备数 look_at_num //todo 计算当日报备数 look_at_num
$reportNum = $this->reportModel->getAddReportNum($where_); /*$reportNum = $this->reportModel->getAddReportNum($where_);
$value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0; $value["look_at_num_total"] = isset($reportNum[0]["num"]) ? $reportNum[0]["num"] : 0;*/
//todo 计算当日新增商铺数 add_house_num //todo 计算当日新增商铺数 add_house_num
$addHouseNum = $this->houseModel->getAddHouseNum($where_); /*$addHouseNum = $this->houseModel->getAddHouseNum($where_);
$value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0; $value["add_house_num_total"] = isset($addHouseNum[0]["num"]) ? $addHouseNum[0]["num"] : 0;*/
//todo 计算当日新增客户数 add_user_num //todo 计算当日新增客户数 add_user_num
$addUserNum = $this->userModel->getAddUserNum($where_); /*$addUserNum = $this->userModel->getAddUserNum($where_);
$value["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $value["add_user_num_total"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;*/
array_push($arr, $value); array_push($arr, $value);
break; break;
} }
......
...@@ -338,10 +338,10 @@ ...@@ -338,10 +338,10 @@
<tr> <tr>
<td colspan="11"> <td colspan="11">
<form action="" method="get" id="form_search"> <form action="" method="get" id="form_search">
<!--<span class="fore-span ld-Marheight">创建时间:</span> <span class="fore-span ld-Marheight">创建时间:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="start_date" name="start_date" type="date"> <input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="start_date" name="start_date" type="date">
<span class="fore-span ld-Marheight">-</span> <span class="fore-span ld-Marheight">-</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="end_date" name="end_date" type="date">--> <input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="end_date" name="end_date" type="date">
<span class="fore-span ld-Marheight">注册时间:</span> <span class="fore-span ld-Marheight">注册时间:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="registration_start" name="registration_start" type="date"> <input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="registration_start" name="registration_start" type="date">
...@@ -446,6 +446,7 @@ ...@@ -446,6 +446,7 @@
<input class="form-control btn2 margin-top-ld input" data-rule-phoneus="false" data-rule-required="false" name="invite_agent_phone" placeholder="邀请人(经纪人)手机号" type="text" value=""> <input class="form-control btn2 margin-top-ld input" data-rule-phoneus="false" data-rule-required="false" name="invite_agent_phone" placeholder="邀请人(经纪人)手机号" type="text" value="">
<!--<div class="clear"></div>--> <!--<div class="clear"></div>-->
<!--<span class='left bottom'>(注:客方所属部门,客方所属门店与邀请人所属部门,邀请人所属门店不作为并列筛选项)</span>--> <!--<span class='left bottom'>(注:客方所属部门,客方所属门店与邀请人所属部门,邀请人所属门店不作为并列筛选项)</span>-->
<div class="clear"></div>
<span class="fore-span ld-Marheight">首次登录时间:</span> <span class="fore-span ld-Marheight">首次登录时间:</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="first_login_start" type="date"> <input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="first_login_start" type="date">
<span class="fore-span ld-Marheight">-</span> <span class="fore-span ld-Marheight">-</span>
...@@ -459,7 +460,7 @@ ...@@ -459,7 +460,7 @@
<select class="form-control btn2 ld-Marheight" id="user_area_choose"> <select class="form-control btn2 ld-Marheight" id="user_area_choose">
<option value="" selected="selected">区域筛选</option> <option value="" selected="selected">区域筛选</option>
</select> </select>
<div class="clear"></div>
<span class="btn btn-info btn3 margin-top-ld" id="search">搜索</span> <span class="btn btn-info btn3 margin-top-ld" id="search">搜索</span>
<span class="btn btn-info btn3 margin-top-ld" id="reset">重置</span> <span class="btn btn-info btn3 margin-top-ld" id="reset">重置</span>
<!--<a class="btn btn-info btn3 margin-top-ld user-favorites"> 收藏夹 </a>--> <!--<a class="btn btn-info btn3 margin-top-ld user-favorites"> 收藏夹 </a>-->
......
...@@ -18,7 +18,21 @@ ...@@ -18,7 +18,21 @@
#rank_start_day,#rank_end_day,#performance_ranking{ #rank_start_day,#rank_end_day,#performance_ranking{
font-size: 16px; font-size: 16px;
} }
/*倒序 正序 样式*/
.positive-sequence-yeji,.reverse-order-yeji{
position: relative;
margin-left: 5px;
cursor: pointer;
font-size: 20px;
}
.positive-sequence-yeji{
top: 11px;
}
.reverse-order-yeji{
top: -5px;
left: -25px;
}
</style> </style>
<div id="page-content-wrapper"> <div id="page-content-wrapper">
......
...@@ -310,8 +310,8 @@ ...@@ -310,8 +310,8 @@
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="start_date" name="start_date" type="date"> <input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="start_date" name="start_date" type="date">
<span class="fore-span ld-Marheight">-</span> <span class="fore-span ld-Marheight">-</span>
<input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="end_date" name="end_date" type="date"> <input class="form-control btn4 ld-Marheight" value="" data-rule-phoneus="false" data-rule-required="false" id="end_date" name="end_date" type="date">
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="customer_name" placeholder="客户姓名" type="text" value=""> <input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="customer_name_id" placeholder="客户编号" type="text" value="">
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="customer_phone" placeholder="客户手机号" type="tel" value=""> <!--<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="customer_phone" placeholder="客户手机号" type="tel" value="">-->
<input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="follow_content" placeholder="跟进内容" type="text" value=""> <input class="form-control btn2 ld-Marheight" data-rule-phoneus="false" data-rule-required="false" id="follow_content" placeholder="跟进内容" type="text" value="">
......
...@@ -273,7 +273,7 @@ class AAgents extends BaseModel ...@@ -273,7 +273,7 @@ class AAgents extends BaseModel
$where_["level"] = $params["level"]; $where_["level"] = $params["level"];
} }
if (isset($params['in_id'])) { if (isset($params['in_id'])) {
$where_['id'] = ['in', $params['in_id']]; $where_['id'] = [ 'in', $params['in_id'] ];
} }
$result = $this->field($field) $result = $this->field($field)
->where($where_) ->where($where_)
...@@ -352,8 +352,10 @@ class AAgents extends BaseModel ...@@ -352,8 +352,10 @@ class AAgents extends BaseModel
*/ */
public function getAgentsListByTask($pageNo = 1, $pageSize = 15, $field = "id") public function getAgentsListByTask($pageNo = 1, $pageSize = 15, $field = "id")
{ {
$params["district_id"] = array( 'not in', array( '13', '14', '15' ) );
return Db::table($this->table) return Db::table($this->table)
->field($field) ->field($field)
->where($params)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->select(); ->select();
...@@ -387,7 +389,9 @@ class AAgents extends BaseModel ...@@ -387,7 +389,9 @@ class AAgents extends BaseModel
*/ */
public function getAgentsCountByTask() public function getAgentsCountByTask()
{ {
$params["district_id"] = array( 'not in', array( '13', '14', '15' ) );
return Db::table($this->table) return Db::table($this->table)
->where($params)
->count(); ->count();
} }
...@@ -489,12 +493,13 @@ class AAgents extends BaseModel ...@@ -489,12 +493,13 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getStoreOrDistrict($params){ public function getStoreOrDistrict($params)
{
$result = Db::table($this->table) $result = Db::table($this->table)
->field("id,name,img") ->field("id,name,img")
->where($params) ->where($params)
->select(); ->select();
//echo Db::table($this->table)->getLastSql(); //echo Db::table($this->table)->getLastSql();
return $result; return $result;
} }
...@@ -776,15 +781,15 @@ class AAgents extends BaseModel ...@@ -776,15 +781,15 @@ class AAgents extends BaseModel
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '') public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '')
{ {
return $this->field($field)->alias('a') return $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left') ->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->join('g_houses_to_agents c', 'a.id=c.agents_id', 'left') ->join('g_houses_to_agents c', 'a.id=c.agents_id', 'left')
->where('c.type', 1) ->where('c.type', 1)
->where($params) ->where($params)
->group('a.id') ->group('a.id')
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->select(); ->select();
} }
/** /**
...@@ -798,7 +803,8 @@ class AAgents extends BaseModel ...@@ -798,7 +803,8 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function searchAgentShop($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') { public function searchAgentShop($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '')
{
return $this->field($field) return $this->field($field)
->alias('a') ->alias('a')
->join('a_store b', 'a.store_id = b.id', 'left') ->join('a_store b', 'a.store_id = b.id', 'left')
...@@ -818,10 +824,11 @@ class AAgents extends BaseModel ...@@ -818,10 +824,11 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentsList($field,$params,$group){ public function getAgentsList($field, $params, $group)
{
$where_ = []; $where_ = [];
if($group == "store_id"){ if ($group == "store_id") {
$where_['level'] = array("in",[20,40]); $where_['level'] = array( "in", [ 20, 40 ] );
} }
$result = Db::name($this->table) $result = Db::name($this->table)
->field($field) ->field($field)
...@@ -844,11 +851,12 @@ class AAgents extends BaseModel ...@@ -844,11 +851,12 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getUserAgent($field = '', $params = [], $house_id = 0) { public function getUserAgent($field = '', $params = [], $house_id = 0)
{
$data = $this->field($field)->alias('a') $data = $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left') ->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->join('g_houses_to_agents c', 'a.id=c.agents_id', 'left') ->join('g_houses_to_agents c', 'a.id=c.agents_id', 'left')
->join('u_users d','a.id = d.agent_id', 'left') ->join('u_users d', 'a.id = d.agent_id', 'left')
->where('c.houses_id', $house_id) ->where('c.houses_id', $house_id)
->where('c.type', 1) ->where('c.type', 1)
->where($params) ->where($params)
...@@ -866,10 +874,11 @@ class AAgents extends BaseModel ...@@ -866,10 +874,11 @@ class AAgents extends BaseModel
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentClient(string $field = '*', array $params = []) { public function getAgentClient(string $field = '*', array $params = [])
{
return $this->field($field)->alias('a') return $this->field($field)->alias('a')
->join('u_evaluate b', 'a.id = b.agents_id', 'left') ->join('u_evaluate b', 'a.id = b.agents_id', 'left')
->join('u_users c','a.id = c.agent_id', 'left') ->join('u_users c', 'a.id = c.agent_id', 'left')
->where($params) ->where($params)
->find(); ->find();
} }
...@@ -907,12 +916,12 @@ class AAgents extends BaseModel ...@@ -907,12 +916,12 @@ class AAgents extends BaseModel
if ($id) { if ($id) {
$result = $this->field('id,name as realname,create_time,img,store_id')->find($id); $result = $this->field('id,name as realname,create_time,img,store_id')->find($id);
$evaluate_grade = Db::table('u_evaluate') $evaluate_grade = Db::table('u_evaluate')
->field('sum(evaluate_grade) as evaluate_grade, count(*) as evaluate_num') ->field('sum(evaluate_grade) as evaluate_grade, count(*) as evaluate_num')
->where('agents_id', $id)->where('is_show', 0)->find(); ->where('agents_id', $id)->where('is_show', 0)->find();
$m_store = new AStore(); $m_store = new AStore();
$result['sub_shopname'] = $m_store->getStoreKeyById('store_name', ['id'=>$result['store_id']]); $result['sub_shopname'] = $m_store->getStoreKeyById('store_name', [ 'id' => $result['store_id'] ]);
if ($evaluate_grade['evaluate_grade']) { if ($evaluate_grade['evaluate_grade']) {
$grade = floor(($evaluate_grade['evaluate_grade'] / 2) / $evaluate_grade['evaluate_num']); $grade = floor(($evaluate_grade['evaluate_grade'] / 2) / $evaluate_grade['evaluate_num']);
} else { } else {
...@@ -924,9 +933,9 @@ class AAgents extends BaseModel ...@@ -924,9 +933,9 @@ class AAgents extends BaseModel
$result['watch_shop'] = Db::table('u_appoint_watch_shop') $result['watch_shop'] = Db::table('u_appoint_watch_shop')
->where('agents_id', $id)->count(); //看铺 ->where('agents_id', $id)->count(); //看铺
$result['head_portrait'] = AGENTHEADERIMGURL.$result['img']; $result['head_portrait'] = AGENTHEADERIMGURL . $result['img'];
$bargain = new OBargainModel(); $bargain = new OBargainModel();
$result['JournalAccounts'] = $bargain->ifBargainNumByOrderId([ 'agent_id' => $id ]); //成交记录 $result['JournalAccounts'] = $bargain->ifBargainNumByOrderId([ 'agent_id' => $id ]); //成交记录
$current_time = time(); $current_time = time();
...@@ -956,7 +965,8 @@ class AAgents extends BaseModel ...@@ -956,7 +965,8 @@ class AAgents extends BaseModel
* @param $data * @param $data
* @return AAgents|bool * @return AAgents|bool
*/ */
public function updateData($id, $data) { public function updateData($id, $data)
{
if ($id) { if ($id) {
$result = $this->where('id', $id)->update($data); $result = $this->where('id', $id)->update($data);
} else { } else {
...@@ -985,4 +995,36 @@ class AAgents extends BaseModel ...@@ -985,4 +995,36 @@ class AAgents extends BaseModel
//dump($this->getLastSql()); //dump($this->getLastSql());
return $result; return $result;
} }
public function getAgentsIdsArray($field, $params)
{
$params["status"] = 0;
$result = Db::table($this->table)
->field($field)
->where($params)
->select();
if($result){
$agentIds = "";
foreach ($result as $key1 => $value1) {
$agentIds .= $value1["id"] . ',';
}
$agentIds = rtrim($agentIds, ",");//经纪人ID集合
}
return $agentIds;
}
public function getAgentsInfo($field, $params)
{
$params["a.status"] = 0;
$result = Db::table($this->table)
->alias('a')
->join('a_store b', 'b.id=a.store_id', 'left' )
->field($field)
->where($params)
->select();
return $result;
}
} }
\ No newline at end of file
...@@ -92,5 +92,25 @@ class ASuperviseModel extends Model ...@@ -92,5 +92,25 @@ class ASuperviseModel extends Model
->select(); ->select();
} }
/**
* 统计监督执行数量分时间
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getAddPayLogNumGroupTimeNew($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
...@@ -272,21 +272,30 @@ class GHouses extends BaseModel ...@@ -272,21 +272,30 @@ class GHouses extends BaseModel
*/ */
public function getHouseListDish($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '') public function getHouseListDish($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '')
{ {
$data = $this->field($field)->alias('a') // $data = $this->field($field)->alias('a')
->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left') // ->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left')
->join('a_agents c', 'b.agents_id=c.id', 'left') // ->join('a_agents c', 'b.agents_id=c.id', 'left')
->join('g_houses_ext d', 'a.id=d.house_id', 'left') // ->join('g_houses_ext d', 'a.id=d.house_id', 'left')
// ->where($params)
// ->order($order_)
// ->limit($pageSize)
// ->page($pageNo)
// ->group('a.id')
// ->select();
$data = $this->field($field)
->where($params) ->where($params)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->group('a.id')
->select(); ->select();
$house_id = array();
$house_id = [];
$house_follow_up = new GHousesFollowUp(); $house_follow_up = new GHousesFollowUp();
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$house_id[$k] = $v['id']; $house_id[$k] = $v['id'];
$v->create_time = date('Y-m-d', strtotime($v->create_time)); $v->create_time = date('Y-m-d', strtotime($v->create_time));
$data[$k]['last_follow_up'] = $house_follow_up->where('house_id',$v['id'])->value('create_time'); $data[$k]['last_follow_up'] = $house_follow_up->where('house_id',$v['id'])->value('create_time');
} }
...@@ -340,14 +349,15 @@ class GHouses extends BaseModel ...@@ -340,14 +349,15 @@ class GHouses extends BaseModel
*/ */
public function getHouseListDishTotal($params = '') public function getHouseListDishTotal($params = '')
{ {
$data = $this->alias('a') // $data = $this->alias('a')
->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left') // ->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left')
->join('a_agents c', 'b.agents_id=c.id', 'left') // ->join('a_agents c', 'b.agents_id=c.id', 'left')
->join('g_houses_ext d', 'a.id=d.house_id', 'left') // ->join('g_houses_ext d', 'a.id=d.house_id', 'left')
->where($params) // ->where($params)
->group('a.id') // ->group('a.id')
->count(); // ->count();
return $data; // return $data;
return $this->where($params)->count();
} }
/** /**
...@@ -728,6 +738,27 @@ class GHouses extends BaseModel ...@@ -728,6 +738,27 @@ class GHouses extends BaseModel
->select(); ->select();
} }
/**
* 获取添加的楼盘的每天数量
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getAddHouseNumGroupTimeNew($params)
{
$field = "count(1) as num";
$where_ = [];
if (isset($params["agent_id"])) {
$where_["upload_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();
}
/** /**
* 获取新增楼盘数量 * 获取新增楼盘数量
* @param $params * @param $params
...@@ -743,6 +774,9 @@ class GHouses extends BaseModel ...@@ -743,6 +774,9 @@ class GHouses extends BaseModel
if (isset($params["create_time"])) { if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"]; $where_["create_time"] = $params["create_time"];
} }
if (isset($params['landlord_phone'])) {
$where_["landlord_phone"] = $params['landlord_phone'];
}
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->where($where_) ->where($where_)
...@@ -751,11 +785,17 @@ class GHouses extends BaseModel ...@@ -751,11 +785,17 @@ class GHouses extends BaseModel
return $result; return $result;
} }
/** /**
* 获取新增楼盘数据 * 获取新增楼盘数据
*
* @param $params * @param $params
* @param $field
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getAddHouseList($params, $field, $page_no, $page_size) public function getAddHouseList($params, $field, $page_no, $page_size)
{ {
...@@ -1112,4 +1152,34 @@ class GHouses extends BaseModel ...@@ -1112,4 +1152,34 @@ class GHouses extends BaseModel
return $result; return $result;
} }
public function getHouseIdsArray($field, $params)
{
$result = Db::table($this->table)
->field($field)
->where($params)
->select();
if($result){
$houseids = "";
foreach ($result as $key1 => $value1) {
$houseids .= $value1["id"] . ',';
}
$houseids = rtrim($houseids, ",");//经纪人ID集合
}
return $houseids;
}
public function getHouseInfo($field, $params)
{
$result = Db::table($this->table)
->field($field)
->where($params)
->select();
return $result;
}
} }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace app\model; namespace app\model;
use think\Db; use think\Db;
use think\Model;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
...@@ -12,7 +11,7 @@ use think\Model; ...@@ -12,7 +11,7 @@ use think\Model;
* Time : 下午4:31 * Time : 下午4:31
* Intro: * Intro:
*/ */
class GHousesFollowUp extends Model class GHousesFollowUp extends BaseModel
{ {
protected $table = "g_houses_follow_up"; protected $table = "g_houses_follow_up";
protected $db_; protected $db_;
...@@ -51,6 +50,19 @@ class GHousesFollowUp extends Model ...@@ -51,6 +50,19 @@ class GHousesFollowUp extends Model
$where_['landlord_name'] = $params['landlord_name']; $where_['landlord_name'] = $params['landlord_name'];
} }
if (isset($params["province"])) {
$where_["province"] = $params["province"];
}
if (isset($params["city"])) {
$where_["city"] = $params["city"];
}
if (isset($params["disc"])) {
$where_["disc"] = $params["disc"];
}
$where_["create_time"] = date("Y-m-d H:i:s", time()); $where_["create_time"] = date("Y-m-d H:i:s", time());
$where_["update_time"] = date("Y-m-d H:i:s", time()); $where_["update_time"] = date("Y-m-d H:i:s", time());
Db::startTrans(); Db::startTrans();
...@@ -68,6 +80,9 @@ class GHousesFollowUp extends Model ...@@ -68,6 +80,9 @@ class GHousesFollowUp extends Model
* @param $field * @param $field
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getShopFollowUpList($field, $params) public function getShopFollowUpList($field, $params)
{ {
...@@ -84,7 +99,6 @@ class GHousesFollowUp extends Model ...@@ -84,7 +99,6 @@ class GHousesFollowUp extends Model
} }
/** /**
* 首页商铺跟进搜索
* @param int $p * @param int $p
* @param int $pageSize * @param int $pageSize
* @param string $order_ * @param string $order_
...@@ -93,6 +107,9 @@ class GHousesFollowUp extends Model ...@@ -93,6 +107,9 @@ class GHousesFollowUp extends Model
* @param $where * @param $where
* @param $group * @param $group
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getSearch($p = 1, $pageSize = 15, $order_ = 'id desc', $field, $join, $where, $group) public function getSearch($p = 1, $pageSize = 15, $order_ = 'id desc', $field, $join, $where, $group)
{ {
...@@ -106,7 +123,7 @@ class GHousesFollowUp extends Model ...@@ -106,7 +123,7 @@ class GHousesFollowUp extends Model
->limit($pageSize) ->limit($pageSize)
->page($p) ->page($p)
->select(); ->select();
// echo $this->getLastSql(); //echo $this->getLastSql();
return $data; return $data;
} }
...@@ -126,6 +143,13 @@ class GHousesFollowUp extends Model ...@@ -126,6 +143,13 @@ class GHousesFollowUp extends Model
return $data; return $data;
} }
/**
* @param array $params
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getFollowUpByHouseId(array $params): bool public function getFollowUpByHouseId(array $params): bool
{ {
$where_ = []; $where_ = [];
......
...@@ -200,6 +200,20 @@ class GHousesToAgents extends BaseModel ...@@ -200,6 +200,20 @@ class GHousesToAgents extends BaseModel
return $result; return $result;
} }
/**
* @param $field
* @param $params
* @return array
*/
public function getAgentsHouseField($field, $params)
{
return $this->field($field)
->alias("a")
->join("a_agents b", "a.agents_id = b.id", "left")
->where($params)
->column($field);
}
/** /**
* 楼盘对应的经纪人信息 * 楼盘对应的经纪人信息
* *
...@@ -250,14 +264,15 @@ class GHousesToAgents extends BaseModel ...@@ -250,14 +264,15 @@ class GHousesToAgents extends BaseModel
* *
* @param $house_id * @param $house_id
* @param int $type * @param int $type
* @return array|\PDOStatement|string|\think\Model * @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentList($house_id, $type = 1) public function getAgentList($house_id, $type = 1, $field = 'b.id,device_id,b.name,b.phone')
{ {
return $this->field('b.id,device_id,b.name,b.phone') return $this->field($field)
->alias('a') ->alias('a')
->join('a_agents b', 'a.agents_id = b.id', 'left') ->join('a_agents b', 'a.agents_id = b.id', 'left')
->where('houses_id', $house_id) ->where('houses_id', $house_id)
......
...@@ -51,14 +51,20 @@ class GOperatingRecords extends BaseModel ...@@ -51,14 +51,20 @@ class GOperatingRecords extends BaseModel
return $result; return $result;
} }
/**
* @param $user_id
* @return array|false|\PDOStatement|string|\think\Collection
*/
public function user_history($user_id) public function user_history($user_id)
{ {
return db('g_operating_records') try {
->where('user_id',$user_id) $data = $this->field('name,remark,create_time')
->field('name,remark,create_time') ->where('user_id',$user_id)
->order('create_time', 'desc') ->order('create_time', 'desc')
->select(); ->select();
} catch (\Exception $e) {
$data = [];
}
return $data;
} }
} }
\ No newline at end of file
...@@ -626,6 +626,34 @@ class OBargainModel extends Model ...@@ -626,6 +626,34 @@ class OBargainModel extends Model
->select(); ->select();
} }
/**
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getReceivedGroupTimeNew($params)
{
$where_ = [];
$field = "sum(b.practical_fee) as num";
if (isset($params["agent_id"])) {
$where_["a.agent_id"] = $params["agent_id"];
}
if (isset($params["create_time"])) {
$where_["b.create_time"] = $params["create_time"];
}
return Db::table($this->table)
->field($field)
->alias("a")
->join("o_partial_commission b", "a.id=b.bargain_id", "right")
->where($where_)
->select();
}
/** /**
* @param $params * @param $params
* @param $type * @param $type
...@@ -655,6 +683,7 @@ class OBargainModel extends Model ...@@ -655,6 +683,7 @@ class OBargainModel extends Model
if (isset($params["agent_id"]) && $type == 3) { if (isset($params["agent_id"]) && $type == 3) {
unset($where_["agent_id"]); unset($where_["agent_id"]);
$where_["submit_agent_id"] = $params["agent_id"]; $where_["submit_agent_id"] = $params["agent_id"];
$where_["father_id"] = 0;
} }
if (isset($params["create_time"])) { if (isset($params["create_time"])) {
...@@ -668,6 +697,44 @@ class OBargainModel extends Model ...@@ -668,6 +697,44 @@ class OBargainModel extends Model
->select(); ->select();
} }
/**
* @param $params
* @param $type
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAddBargainNumGroupTimeNew($params, $type)
{
$field = "";
$where_ = [];
if ($type == 1) {
$field = "sum(scale_fee) as num";
} elseif ($type == 2) {
$field = "sum(practical_fee) as num";
} elseif ($type == 3) {
$field = "count(1) as num";
$where_["trade_type"] = 10;//产品要求统计数量必须是出租类型的180620
$where_["role"] = 3;//必须是反签方
}
if (isset($params["agent_id"])) {
$where_["agent_id"] = $params["agent_id"];
}
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
}
$data = Db::table($this->table)
->field($field)
->where($where_)
->select();
//echo $this->getLastSql();
return $data;
}
public function getAddBargainNum($params, $type) public function getAddBargainNum($params, $type)
{ {
$where_ = []; $where_ = [];
...@@ -709,7 +776,7 @@ class OBargainModel extends Model ...@@ -709,7 +776,7 @@ class OBargainModel extends Model
->join($join) ->join($join)
->where($where_) ->where($where_)
->select(); ->select();
// echo $this->getLastSql(); // echo $this->getLastSql();
return $return; return $return;
} }
...@@ -794,8 +861,8 @@ class OBargainModel extends Model ...@@ -794,8 +861,8 @@ class OBargainModel extends Model
$where_ = []; $where_ = [];
if (isset($params["agent_id"])) { if (isset($params["agent_id"])) {
$where_["c.report_agent_id"] = $params["agent_id"]; $where_["a.agent_id"] = $params["agent_id"];
$where_["a.agent_id"] = $params["agent_id"]; $where_["a.role"] = 3;
} }
if (isset($params["create_time"])) { if (isset($params["create_time"])) {
$where_["a.create_time"] = $params["create_time"]; $where_["a.create_time"] = $params["create_time"];
...@@ -1180,12 +1247,14 @@ class OBargainModel extends Model ...@@ -1180,12 +1247,14 @@ class OBargainModel extends Model
->find(); ->find();
$m_agent = new AAgents(); $m_agent = new AAgents();
$filed_agent = 'a.id,a.name,a.phone,b.store_name,c.district_name'; $filed_agent = 'a.id,a.name,a.phone,b.store_name,c.district_name,a.store_id,a.district_id';
$agent_info = $m_agent->getAgentsInfoByAgentId($filed_agent, [ 'agent_id' => $result['agent_id'] ]); $agent_info = $m_agent->getAgentsInfoByAgentId($filed_agent, [ 'agent_id' => $result['agent_id'] ]);
$result['district_name'] = $agent_info[0]['district_name']; $result['district_name'] = $agent_info[0]['district_name'];
$result['store_name'] = $agent_info[0]['store_name']; $result['store_name'] = $agent_info[0]['store_name'];
$result['name'] = $agent_info[0]['name']; $result['name'] = $agent_info[0]['name'];
$result['phone'] = $agent_info[0]['phone']; $result['phone'] = $agent_info[0]['phone'];
$result['store_id'] = $agent_info[0]['store_id'];
$result['district_id'] = $agent_info[0]['district_id'];
} catch (\Exception $ex) { } catch (\Exception $ex) {
$result = false; $result = false;
...@@ -1233,15 +1302,15 @@ class OBargainModel extends Model ...@@ -1233,15 +1302,15 @@ class OBargainModel extends Model
} }
public function performancelInfo($where, $filed, $pageSize, $pageNo)
public function performancelInfo($where,$filed,$pageSize,$pageNo){ {
$result = $this->db_ $result = $this->db_
->field($filed) ->field($filed)
->alias("Obargain") ->alias("Obargain")
->join("o_report Oreport", "Obargain.report_id = Oreport.id", "left") ->join("o_report Oreport", "Obargain.report_id = Oreport.id", "left")
->join("o_order Oorder", "Obargain.order_id = Oorder.id", "left") ->join("o_order Oorder", "Obargain.order_id = Oorder.id", "left")
->join("g_houses Houses", "Oorder.house_id = Houses.id", "left") ->join("g_houses Houses", "Oorder.house_id = Houses.id", "left")
->join("a_agents Agent", "Obargain.agent_id = Agent.id", "left") ->join("a_agents Agent", "Obargain.agent_id = Agent.id", "left")
->join('a_store Store', 'Agent.store_id = Store.id', 'left') ->join('a_store Store', 'Agent.store_id = Store.id', 'left')
->join('a_district District', 'Agent.district_id = District.id', 'left') ->join('a_district District', 'Agent.district_id = District.id', 'left')
->where($where) ->where($where)
...@@ -1253,14 +1322,15 @@ class OBargainModel extends Model ...@@ -1253,14 +1322,15 @@ class OBargainModel extends Model
return $result; return $result;
} }
public function performancelInfoTotal($where,$filed){ public function performancelInfoTotal($where, $filed)
$result = $this->db_ {
$result = $this->db_
->field($filed) ->field($filed)
->alias("Obargain") ->alias("Obargain")
->join("o_report Oreport", "Obargain.report_id = Oreport.id", "left") ->join("o_report Oreport", "Obargain.report_id = Oreport.id", "left")
->join("o_order Oorder", "Obargain.order_id = Oorder.id", "left") ->join("o_order Oorder", "Obargain.order_id = Oorder.id", "left")
->join("g_houses Houses", "Oorder.house_id = Houses.id", "left") ->join("g_houses Houses", "Oorder.house_id = Houses.id", "left")
->join("a_agents Agent", "Obargain.agent_id = Agent.id", "left") ->join("a_agents Agent", "Obargain.agent_id = Agent.id", "left")
->join('a_store Store', 'Agent.store_id = Store.id', 'left') ->join('a_store Store', 'Agent.store_id = Store.id', 'left')
->join('a_district District', 'Agent.district_id = District.id', 'left') ->join('a_district District', 'Agent.district_id = District.id', 'left')
->where($where) ->where($where)
......
...@@ -115,6 +115,27 @@ class OMarchInModel extends Model ...@@ -115,6 +115,27 @@ class OMarchInModel extends Model
->select(); ->select();
} }
/**
* 查询经纪人进场数据 todo 产品定义同一天带看同一个客户去多个铺子算一个带看,下个方法同样
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getAddMarchInNumGroupTimeNew($params)
{
$field = "count(DISTINCT report_id) 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();
}
/** /**
* 统计房源进场数据 过滤重负 * 统计房源进场数据 过滤重负
* @param $params * @param $params
......
...@@ -160,6 +160,27 @@ class OPayLogModel extends Model ...@@ -160,6 +160,27 @@ class OPayLogModel extends Model
->group("day") ->group("day")
->select(); ->select();
} }
/**
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAddPayLogNumGroupTimeNew($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();
}
/** /**
* @param $params * @param $params
......
...@@ -546,6 +546,30 @@ class OReportModel extends Model ...@@ -546,6 +546,30 @@ class OReportModel extends Model
->select(); ->select();
} }
/**
* @param $params
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAddReportNumGroupTimeNew($params)
{
$field = "count(1) as num";
$where_ = [];
if (isset($params["agent_id"])) {
$where_["report_agent_id"] = $params["agent_id"];
}
if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"];
}
$where_["status"] = 0;
return Db::table($this->table)
->field($field)
->where($where_)
->select();
}
/** /**
* @param $params * @param $params
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
......
...@@ -40,6 +40,24 @@ class TAgentTotalModel extends Model ...@@ -40,6 +40,24 @@ class TAgentTotalModel extends Model
return 0; return 0;
} }
} }
/**
* @param $params
* @return int
*/
public function saveTotal($params)
{
Db::startTrans();
try {
$this->saveAll($params);
Db::commit();
return 1;
} catch (\Exception $e) {
print_r($e);
Db::rollback();
return 0;
}
}
/** /**
* 获取最后统计的时间 * 获取最后统计的时间
......
...@@ -41,6 +41,16 @@ class UPhoneFollowPp extends BaseModel ...@@ -41,6 +41,16 @@ class UPhoneFollowPp extends BaseModel
if (isset($params["user_status"])) { if (isset($params["user_status"])) {
$arr["user_status"] = $params["user_status"]; $arr["user_status"] = $params["user_status"];
} }
if (isset($params["province"])) {
$arr["province"] = $params["province"];
}
if (isset($params["city"])) {
$arr["city"] = $params["city"];
}
if (isset($params["disc"])) {
$arr["disc"] = $params["disc"];
}
$result = $this->UPhoneFollowPp->insert($arr); $result = $this->UPhoneFollowPp->insert($arr);
return $result; return $result;
} }
...@@ -92,15 +102,13 @@ class UPhoneFollowPp extends BaseModel ...@@ -92,15 +102,13 @@ class UPhoneFollowPp extends BaseModel
} }
/** /**
* @param $join
* @param $where * @param $where
* @return int * @return int
*/ */
public function getSearchCount( $join, $where) public function getSearchCount( $where)
{ {
$r = $this $r = $this
->alias('f') ->alias('f')
->join($join)
->where($where) ->where($where)
->count(); ->count();
return $r; return $r;
...@@ -254,16 +262,43 @@ class UPhoneFollowPp extends BaseModel ...@@ -254,16 +262,43 @@ class UPhoneFollowPp extends BaseModel
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getFollowList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') { public function getFollowList($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '') {
return $this->field($field) $data = $this->field($field)
->alias('a')
->join('a_agents b','a.agent_id = b.id', 'left')
->join('u_users c','a.user_id = c.id', 'left')
->join('u_labels d','d.id = a.labels_id', 'left')
->where($params) ->where($params)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->select(); ->select();
$m_label = new ULabels();
$m_user = new Users();
$m_agent = new AAgents();
$label_data = $m_label->field('id,name')->where('type', 1)->select();
foreach ($data as $k => $v) {
if (!empty($v['f_agent_id'])) {
$data[$k]['admin'] = $m_agent->getAgentsById($v['f_agent_id'], 'name');
}
if (!empty($v['user_id'])) {
$user_data = $m_user->getUserById('user_name,user_phone,vip,agent_id', $v['user_id']);
$data[$k]['user_name'] = $user_data['user_name'];
$data[$k]['user_phone'] = $user_data['user_phone'];
$data[$k]['vip'] = $user_data['vip'];
$data[$k]['agent_id'] = $user_data['agent_id']; //客户客方
}
if (!isset($v['labels_id'])) {
continue;
}
foreach ($label_data as $k2=>$v2) {
if ($v2['id'] == $v['labels_id']) {
$data[$k]['label_name'] = $v2['name'];
}
}
}
return $data;
} }
/** /**
...@@ -274,10 +309,7 @@ class UPhoneFollowPp extends BaseModel ...@@ -274,10 +309,7 @@ class UPhoneFollowPp extends BaseModel
*/ */
public function getFollowTotal($params) public function getFollowTotal($params)
{ {
return $this->alias('a') return $this->where($params)
->join('a_agents b','a.agent_id = b.id', 'left')
->join('u_users c','a.user_id = c.id', 'left')
->where($params)
->count(); ->count();
} }
......
...@@ -494,6 +494,27 @@ class Users extends Model ...@@ -494,6 +494,27 @@ class Users extends Model
->select(); ->select();
} }
/**
* 按添加时间段分组统计
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getAddUserNumGroupTimeNew($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();
}
public function getAddUserNum($params) public function getAddUserNum($params)
{ {
$field = "count(1) as num"; $field = "count(1) as num";
...@@ -769,5 +790,17 @@ class Users extends Model ...@@ -769,5 +790,17 @@ class Users extends Model
return $return; return $return;
} }
public function getUserCityInfo($id)
{
$field='province,city,disc';
$params= [ 'id' => $id ];
$result = Db::table($this->table)
->field($field)
->where($params)
->select();
return $result;
}
} }
...@@ -280,6 +280,7 @@ Route::group('index', [ ...@@ -280,6 +280,7 @@ Route::group('index', [
'selectDistrictPerformance' => [ 'index/Performance/selectDistrictPerformance', [ 'method' => 'POST|GET' ] ], //区域业绩排行 朱伟 2018-07-31 'selectDistrictPerformance' => [ 'index/Performance/selectDistrictPerformance', [ 'method' => 'POST|GET' ] ], //区域业绩排行 朱伟 2018-07-31
'selectStorePerformance' => [ 'index/Performance/selectStorePerformance', [ 'method' => 'POST|GET' ] ], //门店业绩排行 朱伟 2018-07-31 'selectStorePerformance' => [ 'index/Performance/selectStorePerformance', [ 'method' => 'POST|GET' ] ], //门店业绩排行 朱伟 2018-07-31
'selectIndividualPerformance' => [ 'index/Performance/selectIndividualPerformance', [ 'method' => 'POST|GET' ] ], //个人业绩排行 朱伟 2018-07-31 'selectIndividualPerformance' => [ 'index/Performance/selectIndividualPerformance', [ 'method' => 'POST|GET' ] ], //个人业绩排行 朱伟 2018-07-31
'transformFollowUp' => [ 'index/HouseFollowUp/transformFollowUp', [ 'method' => 'GET' ] ], //个人业绩排行 朱伟 2018-07-31
...@@ -395,6 +396,8 @@ Route::group('task', [ ...@@ -395,6 +396,8 @@ Route::group('task', [
'totalAgentResults_new' => [ 'task/ResultsSummaryTask/totalAgentResults', [ 'method' => 'get' ] ], //业绩统计 'totalAgentResults_new' => [ 'task/ResultsSummaryTask/totalAgentResults', [ 'method' => 'get' ] ], //业绩统计
'totalAgentResults' => [ 'task/ResultsSummaryNewTask/totalAgentResults', [ 'method' => 'get' ] ], //业绩统计
'updateTotalByAgentId' => [ 'task/ResultsSummaryNewTask/updateTotalByAgentId', [ 'method' => 'get' ] ], //业绩统计
'rongBilledInformUrl' => [ 'task/PrivacyNumber/rongBilledInformUrl', [ 'method' => 'post | get' ] ],//隐私号码回调[话单通知] 'rongBilledInformUrl' => [ 'task/PrivacyNumber/rongBilledInformUrl', [ 'method' => 'post | get' ] ],//隐私号码回调[话单通知]
......
<?php
namespace app\task\controller;
use app\extra\RedisExt;
use app\model\AAgents;
use app\model\ASuperviseModel;
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.
* User : zw
* Date : 2018/3/15
* Time : 上午10:07
* Intro:
*/
class ResultsSummaryNewTask
{
private $agentsModel;
private $tAgentTotalModel;
private $houseModel;
private $userModel;
private $bargainModel;
private $reportModel;
private $marchInModel;
private $payLogModel;
private $superviseModel;
private $redis_;
function __construct()
{
$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();
$this->redis_ = RedisExt::getRedis();
$this->superviseModel = new ASuperviseModel();
}
public function totalAgentResults()
{
set_time_limit(0); // 取消脚本运行时间的超时上限
//todo 按小时统计
//todo 1.分页查询经纪人, 2遍历执行,判断一个经纪人在统计表最后一条统计数据的日期
//TODO 3.日期加一天并判断是否大于等于当前时间大于return 4.执行此日期的统计,5.当次日期小于当前日期,递归日期加一。继续统计
$total = $this->agentsModel->getAgentsCountByTask();
$pageSize = 100;
$pageTotal = ceil($total / $pageSize);
for ($pageNo = 1; $pageNo <= $pageTotal; $pageNo++) {
$resultArr = $this->agentsModel->getAgentsListByTask($pageNo, $pageSize, "id,store_id,district_id");
$this->executeTotal($resultArr, null);
unset($resultArr);
}
unset($this->agentsModel);
unset($this->tAgentTotalModel);
unset($this->houseModel);
unset($this->userModel);
unset($this->bargainModel);
unset($this->reportModel);
unset($this->marchInModel);
unset($this->payLogModel);
}
/**
* @param $agent_id
* @param $store_id
* @param $district_id
* @param $total_time 比如修改了数据如成交报告,成交报告提交时间是昨天那么这里的时间就是昨天
*/
public function updateTotalByAgentId($agent_id,$store_id,$district_id,$total_time)
{
$params[0]["id"] = $agent_id;
$params[0]["store_id"] = $store_id;
$params[0]["district_id"] = $district_id;
/* $params[0]["id"] = 5439;
$params[0]["store_id"] = 92;
$params[0]["district_id"] = 2;
$total_time = '2018-08-15';*/
$this->executeTotal($params, $total_time);
}
private function executeTotal($resultArr, $total_time)
{
$start_total_time = date("Y-m-d 00:00:00", time());
$end_total_time = date("Y-m-d H:i:s", time());
if (!empty($total_time)) {
$start_total_time = $total_time . " 00:00:00";
$end_total_time = $total_time . " 23:59:59";
} else {
$total_time = date("Y-m-d", time());
}
$insertArr = $updateArr = [];
foreach ($resultArr as $key => $value) {
$param["agent_id"] = $value["id"];
$param["is_del"] = 0;
$param["total_time"] = $total_time;
$total_time_arr = $this->tAgentTotalModel->getTotalEndTimeByAgentId("id,total_time", $param);
$id = 0;
if (count($total_time_arr) > 0) {
$id = $total_time_arr[0]["id"];
}
$agent_id = empty($value["id"]) ? 0 : $value["id"];
$district_id = empty($value["district_id"]) ? 0 : $value["district_id"];
$store_id = empty($value["store_id"]) ? 0 : $value["store_id"];
//todo 查询时间段的数据
$result = $this->selectTotal($agent_id, $district_id, $store_id, $start_total_time, $end_total_time);
if (empty($result)) continue;
if ($id > 0) {
$result["id"] = $id;
unset($result["create_time"]);
array_push($updateArr, $result);
} else {
array_push($insertArr, $result);
}
unset($result);
}
if (count($insertArr) > 0) {
$this->tAgentTotalModel->addTotal($insertArr);
}
if (count($updateArr) > 0) {
$this->tAgentTotalModel->saveTotal($updateArr);
}
}
/* public function test()
{
$params = $this->selectTotal(1, 1, 1, "2018-02-02", "2018-03-15");
$this->tAgentTotalModel->addTotal($params);
// dump($params);
}*/
private function selectTotal($agent_id, $district_id, $store_id, $start_total_time, $end_total_time)
{
//todo 如果查询出这个时间段都为0 则给此经纪人插入条最后一个日期的为空的数据
$result_arr = [];
//房源
$params["agent_id"] = $agent_id;
$params['create_time'] = array( 'between', array( $start_total_time, $end_total_time ) );
$addHouseNum = $this->houseModel->getAddHouseNumGroupTimeNew($params);
$result_arr["house_num"] = $addHouseNum[0]["num"];
//dump($addHouseNum);
//客源
$addUserNum = $this->userModel->getAddUserNumGroupTimeNew($params);
$result_arr["user_num"] = $addUserNum[0]["num"];
//dump($addUserNum);
//业绩
$performanceSum = $this->bargainModel->getAddBargainNumGroupTimeNew($params, 1);//1表示业绩 2表示实收
// dump($performanceSum);
$result_arr["performance_sum"] = $performanceSum[0]["num"];
//实收
$receivedSum = $this->bargainModel->getReceivedGroupTimeNew($params);
$result_arr["received_sum"] = $receivedSum[0]["num"];
//dump($receivedSum);
//约带看
$reportNum = $this->reportModel->getAddReportNumGroupTimeNew($params);
$result_arr["report_num"] = $reportNum[0]["num"];
//dump($reportNum);
//进场
$addMarchInNum = $this->marchInModel->getAddMarchInNumGroupTimeNew($params);
$result_arr["addMarch_in_num"] = $addMarchInNum[0]["num"];
//dump($addMarchInNum);
//收款
$payLogNum = $this->payLogModel->getAddPayLogNumGroupTimeNew($params);
$result_arr["pay_log_num"] = $payLogNum[0]["num"];
//dump($payLogNum);
// 监督
$supervision_num = $this->superviseModel->getAddPayLogNumGroupTimeNew($params);
$result_arr["supervision_num"] = $supervision_num[0]["num"];
//成交报告
$bargainSum = $this->bargainModel->getAddBargainNumGroupTimeNew($params, 3);//表示统计
$result_arr["bargain_sum"] = $bargainSum[0]["num"];
return $this->binAgentModel($agent_id, $district_id, $store_id, $result_arr, $start_total_time);
}
private function binAgentModel($agent_id, $district_id, $store_id, $result_arr, $start_total_time)
{
$params = [];
if (!empty($result_arr["house_num"]) || !empty($result_arr["user_num"]) || !empty($result_arr["performance_sum"]) ||
!empty($result_arr["received_sum"]) || !empty($result_arr["report_num"]) || !empty($result_arr["addMarch_in_num"]) ||
!empty($result_arr["pay_log_num"]) || !empty($result_arr["supervision_num"]) || !empty($result_arr["bargain_sum"])) {
$params["district_id"] = $district_id;
$params["store_id"] = $store_id;
$params["agent_id"] = $agent_id;
$params["total_time"] = $start_total_time;
$params["create_time"] = date("Y-m-d H:i:s", time());
$params["update_time"] = date("Y-m-d H:i:s", time());
$params["add_house_num"] = !empty($result_arr["house_num"]) ? $result_arr["house_num"] : 0;
$params["add_user_num"] = !empty($result_arr["user_num"]) ? $result_arr["user_num"] : 0;
$params["performance"] = !empty($result_arr["performance_sum"]) ? $result_arr["performance_sum"] : 0;
$params["official_receipts"] = !empty($result_arr["received_sum"]) ? $result_arr["received_sum"] : 0;
$params["look_at_num"] = !empty($result_arr["report_num"]) ? $result_arr["report_num"] : 0;
$params["march_in_num"] = !empty($result_arr["addMarch_in_num"]) ? $result_arr["addMarch_in_num"] : 0;
$params["paylog"] = !empty($result_arr["pay_log_num"]) ? $result_arr["pay_log_num"] : 0;
$params["supervision_num"] = !empty($result_arr["supervision_num"]) ? $result_arr["supervision_num"] : 0;
$params["bargain_sum"] = !empty($result_arr["bargain_sum"]) ? $result_arr["bargain_sum"] : 0;
}
unset($result_arr);
return $params;
}
}
\ No newline at end of file
...@@ -827,18 +827,36 @@ define(['doT', 'text!temp/remark_follow_template_tpl.html', 'ckfinder', 'ckfinde ...@@ -827,18 +827,36 @@ define(['doT', 'text!temp/remark_follow_template_tpl.html', 'ckfinder', 'ckfinde
params.remark_phone = $.trim($("#remark_phone").val()); params.remark_phone = $.trim($("#remark_phone").val());
params.remark_store_id = $.trim($("#guest_stores").val()); params.remark_store_id = $.trim($("#guest_stores").val());
params.remark_district_id = $.trim($("#district_id").val()); params.remark_district_id = $.trim($("#district_id").val());
if(params.remark_name.length == 1){
alert('跟进人姓名的搜索必须2字及2字以上');
return;
}
if($('#user_city_choose').val() == 310100){//城市 if($('#user_city_choose').val() == 310100){//城市
params.city = '上海市'; params.city = '上海市';
} }
if($('#user_city_choose').val() == 330100){ if($('#user_city_choose').val() == 330100){
params.city = '杭州市'; params.city = '杭州市';
} }
params.user_id = $.trim($("#customer_name_id").val());//区域
params.disc = $.trim($("#user_area_choose").val());//区域 params.disc = $.trim($("#user_area_choose").val());//区域
_startDateObj.val() != '' && (params.start_date = _startDateObj.val()); _startDateObj.val() != '' && (params.start_date = _startDateObj.val());
_endDateObj.val() != '' && (params.end_date = _endDateObj.val()); _endDateObj.val() != '' && (params.end_date = _endDateObj.val());
$.trim(_customerNameObj.val()) != '' && (params.customer = $.trim(_customerNameObj.val())); $.trim(_customerNameObj.val()) != '' && (params.customer = $.trim(_customerNameObj.val()));
$.trim(_customerPhoneObj.val()) != '' && (params.phone = $.trim(_customerPhoneObj.val())); $.trim(_customerPhoneObj.val()) != '' && (params.phone = $.trim(_customerPhoneObj.val()));
$.trim(_followContentObj.val()) != '' && (params.content = $.trim(_followContentObj.val())); $.trim(_followContentObj.val()) != '' && (params.content = $.trim(_followContentObj.val()));
//
var start_ = params.start_date+" 00:00:00";
date_start =new Date(Date.parse(start_.replace(/-/g, "/")));
var start_time =date_start.getTime();
var end_ = params.end_date+" 00:00:00";
date_end =new Date(Date.parse(end_.replace(/-/g, "/")));
var end_time =date_end.getTime();
var cha_time=end_time-start_time;
if(cha_time > 2678400000){
alert("跟进时间搜索控制在30天以内");
return;
}
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
......
...@@ -207,6 +207,12 @@ define(['doT', 'text!temp/followHouseUp_template_tpl.html', 'css!style/home.css' ...@@ -207,6 +207,12 @@ define(['doT', 'text!temp/followHouseUp_template_tpl.html', 'css!style/home.css'
return; return;
} }
var cha_time=params.end_time*1000-params.start_time*1000;
if(cha_time > 2764800000){
alert("跟进时间搜索控制在30天以内");
return;
}
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: '/broker/houseFollowUpList', //商铺跟进 对接接口 url: '/broker/houseFollowUpList', //商铺跟进 对接接口
......
...@@ -11,6 +11,7 @@ define(['doT', 'text!temp/real_time_performance_template_tpl.html', 'css!style/h ...@@ -11,6 +11,7 @@ define(['doT', 'text!temp/real_time_performance_template_tpl.html', 'css!style/h
store_id_Two: 0,//二级门店id store_id_Two: 0,//二级门店id
is_today_yeji:0,//默认搜索的不是今天 传参数0 is_today_yeji:0,//默认搜索的不是今天 传参数0
panfangData: null, panfangData: null,
orderList:0,
init: function() { init: function() {
//初始化dot //初始化dot
$(document.body).append(template); $(document.body).append(template);
...@@ -81,6 +82,20 @@ define(['doT', 'text!temp/real_time_performance_template_tpl.html', 'css!style/h ...@@ -81,6 +82,20 @@ define(['doT', 'text!temp/real_time_performance_template_tpl.html', 'css!style/h
realtime.is_today_yeji=0; realtime.is_today_yeji=0;
realtime.getList(1); //一级审核搜索 realtime.getList(1); //一级审核搜索
}); });
//正序
_doc.on('click', '.positive-sequence-yeji', function(e) {
e.preventDefault();
e.stopPropagation();
realtime.orderList=1;
realtime.getList(1);
});
//倒序
_doc.on('click', '.reverse-order-yeji', function(e) {
e.preventDefault();
e.stopPropagation();
realtime.orderList=0;
realtime.getList(1);
});
//搜索的重置 //搜索的重置
$("#maintable_reset").click(function() { $("#maintable_reset").click(function() {
...@@ -140,7 +155,12 @@ define(['doT', 'text!temp/real_time_performance_template_tpl.html', 'css!style/h ...@@ -140,7 +155,12 @@ define(['doT', 'text!temp/real_time_performance_template_tpl.html', 'css!style/h
var tpl=realtime.switchTpl(); var tpl=realtime.switchTpl();
console.log(tpl); console.log(tpl);
var doTtmpl = doT.template(document.getElementById(tpl).innerHTML); var doTtmpl = doT.template(document.getElementById(tpl).innerHTML);
$("#maintable_list").html(doTtmpl(data.data)); if(realtime.orderList==0){
$("#maintable_list").html(doTtmpl(data.data.list.slice(0,19)));
}
if(realtime.orderList==1){
$("#maintable_list").html(doTtmpl(data.data.list.reverse().slice(0,19)));
}
//获取统计时间 //获取统计时间
$('#rank_start_day').html(data.data.start_time); $('#rank_start_day').html(data.data.start_time);
$('#rank_end_day').html(data.data.end_time); $('#rank_end_day').html(data.data.end_time);
......
...@@ -279,11 +279,12 @@ define(['doT', 'text!temp/reportList_template_tpl.html', 'css!style/home.css', ' ...@@ -279,11 +279,12 @@ define(['doT', 'text!temp/reportList_template_tpl.html', 'css!style/home.css', '
_doc.on('click', '#maid_ok_btn', function(e){ _doc.on('click', '#maid_ok_btn', function(e){
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
if(bargain.mainTabIndex === 2){ bargain.maidConfirmOk(1);
bargain.maidConfirmOk(1); // if(bargain.mainTabIndex === 2){
}else{ // bargain.maidConfirmOk(1);
alert('财务第三级审核人员才能确认分佣!'); // }else{
} // alert('财务第三级审核人员才能确认分佣!');
// }
}); });
//详情弹出框,分佣提成里,点击保存触发的事件 //详情弹出框,分佣提成里,点击保存触发的事件
......
<!--部门业绩排行--> <!--部门业绩排行-->
<script id="realtimePerformance_list_tpl_one" type="text/template"> <script id="realtimePerformance_list_tpl_one" type="text/template">
[% if(it["list"] && it["list"].length && it["list"].length>0) { %] [% if(it && it.length && it.length>0) { %]
<tr class="maintable-tr-bar"> <tr class="maintable-tr-bar">
<th class="text-center">排名</th> <th class="text-center">排名</th>
<th class="text-center">部门</th> <th class="text-center">部门</th>
<th class="text-center">业绩(元)</th> <th class="text-center">业绩(元)<span class="glyphicon glyphicon-triangle-bottom positive-sequence-yeji"></span><span class="glyphicon glyphicon-triangle-top reverse-order-yeji"></span></th>
<th class="text-center">成交单数</th> <th class="text-center">成交单数</th>
<!--<th class="text-center">成交报告(其他)</th>-->
<th class="text-center">收款数</th> <th class="text-center">收款数</th>
<th class="text-center">进场数</th> <th class="text-center">进场数</th>
<th class="text-center">报备数</th> <th class="text-center">报备数</th>
...@@ -14,21 +13,20 @@ ...@@ -14,21 +13,20 @@
<th class="text-center">新增客户</th> <th class="text-center">新增客户</th>
<th class="text-center">团队人数</th> <th class="text-center">团队人数</th>
</tr> </tr>
[% for(var item in it["list"]){ %] [% for(var item in it){ %]
<tr data-id="[%= it['list'][item]['district_id'] %]"> <tr data-id="[%= it[item]['district_id'] %]">
<td class="text-center">[%= it["list"][item]['index_'] %]</td> <td class="text-center">[%= it[item]['index_'] %]</td>
<td class="text-center"> <td class="text-center">
<a class="store-ranking" href="#modal-store" data-toggle="modal" data-id="[%= it['list'][item]['district_id'] %]">[%= it["list"][item]['district_name']+'-'+it["list"][item]['name'] %]</a> <a class="store-ranking" href="#modal-store" data-toggle="modal" data-id="[%= it[item]['district_id'] %]">[%= it[item]['district_name']+'-'+it[item]['name'] %]</a>
</td> </td>
<td class="text-center">[%= it["list"][item]['performance_total'] %]</td> <td class="text-center">[%= it[item]['performance_total'] %]</td>
<td class="text-center">[%= it["list"][item]['bargain_sum_total'] %]</td> <td class="text-center">[%= it[item]['bargain_sum_total'] %]</td>
<!--<td class="text-center">[%= it["list"][item]['bargain_sum'] %]</td>--> <td class="text-center">[%= it[item]['paylog_total'] %]</td>
<td class="text-center">[%= it["list"][item]['paylog_total'] %]</td> <td class="text-center">[%= it[item]['march_in_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['march_in_num_total'] %]</td> <td class="text-center">[%= it[item]['look_at_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['look_at_num_total'] %]</td> <td class="text-center">[%= it[item]['add_house_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['add_house_num_total'] %]</td> <td class="text-center">[%= it[item]['add_user_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['add_user_num_total'] %]</td> <td class="text-center">[%= it[item]['team_num'] %]</td>
<td class="text-center">[%= it["list"][item]['team_num'] %]</td>
</tr> </tr>
[% } %] [% } %]
...@@ -41,13 +39,12 @@ ...@@ -41,13 +39,12 @@
<!--门店业绩排行--> <!--门店业绩排行-->
<script id="realtimePerformance_list_tpl_two" type="text/template"> <script id="realtimePerformance_list_tpl_two" type="text/template">
[% if(it["list"] && it["list"].length && it["list"].length>0) { %] [% if(it && it.length && it.length>0) { %]
<tr class="maintable-tr-bar"> <tr class="maintable-tr-bar">
<th class="text-center">排名</th> <th class="text-center">排名</th>
<td class="text-center">门店</td> <td class="text-center">门店</td>
<th class="text-center">业绩(元)</th> <th class="text-center">业绩(元)<span class="glyphicon glyphicon-triangle-bottom positive-sequence-yeji"></span><span class="glyphicon glyphicon-triangle-top reverse-order-yeji"></span></th>
<th class="text-center">成交单数</th> <th class="text-center">成交单数</th>
<!--<th class="text-center">成交报告(其他)</th>-->
<th class="text-center">收款数</th> <th class="text-center">收款数</th>
<th class="text-center">进场数</th> <th class="text-center">进场数</th>
<th class="text-center">报备数</th> <th class="text-center">报备数</th>
...@@ -55,21 +52,20 @@ ...@@ -55,21 +52,20 @@
<th class="text-center">新增客户</th> <th class="text-center">新增客户</th>
<th class="text-center">团队人数</th> <th class="text-center">团队人数</th>
</tr> </tr>
[% for(var item in it["list"]){ %] [% for(var item in it){ %]
<tr> <tr>
<td class="text-center">[%= it["list"][item]['index_'] %]</td> <td class="text-center">[%= it[item]['index_'] %]</td>
<td class="text-center"> <td class="text-center">
<a class="agent-ranking" href="#modal-agent" data-toggle="modal" data-id="[%= it['list'][item]['store_id'] %]">[%= it["list"][item]['district_name']+'-'+it["list"][item]['store_name']+'-'+it["list"][item]['name'] %]</a> <a class="agent-ranking" href="#modal-agent" data-toggle="modal" data-id="[%= it[item]['store_id'] %]">[%= it[item]['district_name']+'-'+it[item]['store_name']+'-'+it[item]['name'] %]</a>
</td> </td>
<td class="text-center">[%= it["list"][item]['performance_total'] %]</td> <td class="text-center">[%= it[item]['performance_total'] %]</td>
<td class="text-center">[%= it["list"][item]['bargain_sum_total'] %]</td> <td class="text-center">[%= it[item]['bargain_sum_total'] %]</td>
<!--<td class="text-center">[%= it["list"][item]['bargain_sum'] %]</td>--> <td class="text-center">[%= it[item]['paylog_total'] %]</td>
<td class="text-center">[%= it["list"][item]['paylog_total'] %]</td> <td class="text-center">[%= it[item]['march_in_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['march_in_num_total'] %]</td> <td class="text-center">[%= it[item]['look_at_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['look_at_num_total'] %]</td> <td class="text-center">[%= it[item]['add_house_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['add_house_num_total'] %]</td> <td class="text-center">[%= it[item]['add_user_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['add_user_num_total'] %]</td> <td class="text-center">[%= it[item]['team_num'] %]</td>
<td class="text-center">[%= it["list"][item]['team_num'] %]</td>
</tr> </tr>
[% } %] [% } %]
[% }else{ %] [% }else{ %]
...@@ -81,31 +77,29 @@ ...@@ -81,31 +77,29 @@
<!--个人业绩排行--> <!--个人业绩排行-->
<script id="realtimePerformance_list_tpl_three" type="text/template"> <script id="realtimePerformance_list_tpl_three" type="text/template">
[% if(it["list"] && it["list"].length && it["list"].length>0) { %] [% if(it && it.length && it.length>0) { %]
<tr class="maintable-tr-bar"> <tr class="maintable-tr-bar">
<th class="text-center">排名</th> <th class="text-center">排名</th>
<th class="text-center">经纪人</th> <th class="text-center">经纪人</th>
<th class="text-center">业绩(元)</th> <th class="text-center">业绩(元)<span class="glyphicon glyphicon-triangle-bottom positive-sequence-yeji"></span><span class="glyphicon glyphicon-triangle-top reverse-order-yeji"></span></th>
<th class="text-center">成交单数</th> <th class="text-center">成交单数</th>
<!--<th class="text-center">成交报告(其他)</th>-->
<th class="text-center">收款数</th> <th class="text-center">收款数</th>
<th class="text-center">进场数</th> <th class="text-center">进场数</th>
<th class="text-center">报备数</th> <th class="text-center">报备数</th>
<th class="text-center">新增商铺</th> <th class="text-center">新增商铺</th>
<th class="text-center">新增客户</th> <th class="text-center">新增客户</th>
</tr> </tr>
[% for(var item in it["list"]){ %] [% for(var item in it){ %]
<tr data-id="[%= it['list'][item]['id'] %]" data-orderid="[%= it['list'][item]['order_id'] %]"> <tr data-id="[%= it[item]['id'] %]" data-orderid="[%= it[item]['order_id'] %]">
<td class="text-center">[%= it["list"][item]['index_'] %]</td> <td class="text-center">[%= it[item]['index_'] %]</td>
<td class="text-center">[%= it["list"][item]['district_name']+'-'+it["list"][item]['store_name']+'-'+it["list"][item]['name'] %]</a></td> <td class="text-center">[%= it[item]['district_name']+'-'+it[item]['store_name']+'-'+it[item]['name'] %]</a></td>
<td class="text-center">[%= it["list"][item]['performance_total'] %]</td> <td class="text-center">[%= it[item]['performance_total'] %]</td>
<td class="text-center">[%= it["list"][item]['bargain_sum_total'] %]</td> <td class="text-center">[%= it[item]['bargain_sum_total'] %]</td>
<!--<td class="text-center">[%= it["list"][item]['bargain_sum'] %]</td>--> <td class="text-center">[%= it[item]['paylog_total'] %]</td>
<td class="text-center">[%= it["list"][item]['paylog_total'] %]</td> <td class="text-center">[%= it[item]['march_in_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['march_in_num_total'] %]</td> <td class="text-center">[%= it[item]['look_at_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['look_at_num_total'] %]</td> <td class="text-center">[%= it[item]['add_house_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['add_house_num_total'] %]</td> <td class="text-center">[%= it[item]['add_user_num_total'] %]</td>
<td class="text-center">[%= it["list"][item]['add_user_num_total'] %]</td>
</tr> </tr>
[% } %] [% } %]
[% }else{ %] [% }else{ %]
...@@ -115,6 +109,9 @@ ...@@ -115,6 +109,9 @@
[% } %] [% } %]
</script> </script>
<!--门店业绩 详情--> <!--门店业绩 详情-->
<script id="store_list_tpl" type="text/template"> <script id="store_list_tpl" type="text/template">
[% if(it["list"] && it["list"].length && it["list"].length>0) { %] [% if(it["list"] && it["list"].length && it["list"].length>0) { %]
......
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