Commit a79c9c5e authored by zhuwei's avatar zhuwei

运营数据

parent f1ccf2f8
...@@ -82,8 +82,7 @@ class User extends Basic ...@@ -82,8 +82,7 @@ class User extends Basic
"pageSize" => 15, "pageSize" => 15,
"status" => 0, "status" => 0,
);*/ );*/
$field = "id as user_id,sex,user_name,city,user_phone,user_status,agent_id,create_time,industry_type,price_demand, $field = "id as user_id,sex,user_name,city,user_phone,user_status,agent_id,create_time,industry_type,price_demand,area_demand,vip,user_label";
area_demand,vip,source,source_intro";
$conditions = []; $conditions = [];
...@@ -157,7 +156,7 @@ class User extends Basic ...@@ -157,7 +156,7 @@ class User extends Basic
foreach ($userList as $k => $v) { foreach ($userList as $k => $v) {
/*判断是否纯房东 0:否 1:是 start*/ /*判断是否纯房东 0:否 1:是 start*/
$is_single_homeowner = 0; $is_single_homeowner = 0;
if ($v['source'] == 41) { if ($v['user_label'] == 2) {
//source 41纯房东 //source 41纯房东
$is_single_homeowner = 1; $is_single_homeowner = 1;
} }
......
<?php <?php
namespace app\index\controller; namespace app\index\controller;
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: zhuwei * User: zhuwei
...@@ -26,9 +28,9 @@ class OperationData extends Basic ...@@ -26,9 +28,9 @@ class OperationData extends Basic
public function __construct($request = null) public function __construct($request = null)
{ {
parent::__construct($request); parent::__construct($request);
$this->gHousesModel = new GHouses(); $this->gHousesModel = new GHouses();
$this->userModel = new Users(); $this->userModel = new Users();
$this->marchInModel = new OMarchInModel(); $this->marchInModel = new OMarchInModel();
} }
...@@ -36,18 +38,19 @@ class OperationData extends Basic ...@@ -36,18 +38,19 @@ class OperationData extends Basic
* 发起微聊用户数 * 发起微聊用户数
* @return \think\Response * @return \think\Response
*/ */
public function chatUserNum(){ public function chatUserNum()
{
$params = $this->params; $params = $this->params;
$where['create_time'] = ['between', [$params['create_time_start']. ' 00:00:00', $params['create_time_end'] . ' 23:59:59']]; $where['create_time'] = [ 'between', [ $params['create_time_start'] . ' 00:00:00', $params['create_time_end'] . ' 23:59:59' ] ];
// 发起微聊用户数 // 发起微聊用户数
$chatRelationModel = new ChatRelation(); $chatRelationModel = new ChatRelation();
$where['from_id'] = ['LIKE','%user_%']; $where['from_id'] = [ 'LIKE', '%user_%' ];
$group = ''; $group = '';
$res = $chatRelationModel->getChatUserNumOperation($where,$group); $res = $chatRelationModel->getChatUserNumOperation($where, $group);
$result["chat_user_all_num"] = $res; $result["chat_user_all_num"] = $res;
$group = 'from_id'; $group = 'from_id';
$res = $chatRelationModel->getChatUserNumOperation($where,$group); $res = $chatRelationModel->getChatUserNumOperation($where, $group);
$result["chat_user_num"] = $res; $result["chat_user_num"] = $res;
return $this->response(200, 'success', $result); return $this->response(200, 'success', $result);
} }
...@@ -55,16 +58,10 @@ class OperationData extends Basic ...@@ -55,16 +58,10 @@ class OperationData extends Basic
* 客户来电数 * 客户来电数
* @return \think\Response * @return \think\Response
*/ */
public function userPhoneNum(){ public function userPhoneNum()
{
$params = $this->params; $params = $this->params;
$where['create_time'] = [ 'between', [ $params['create_time_start'] . ' 00:00:00', $params['create_time_end'] . ' 23:59:59' ] ];
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where['create_time'] = ['between', [$params['create_time_start']. ' 00:00:00', $params['create_time_end'] . ' 23:59:59']];
//todo 客户来电数
// 先查新所有部门 // 先查新所有部门
$district_list = $this->getDistrict(); $district_list = $this->getDistrict();
...@@ -72,49 +69,46 @@ class OperationData extends Basic ...@@ -72,49 +69,46 @@ class OperationData extends Basic
$result_["id"] = $v['id']; $result_["id"] = $v['id'];
$result_["district_name"] = $v['district_name']; $result_["district_name"] = $v['district_name'];
// 商场进场数 // 客户来电数
$agentIds = $this->getAgentIDsByDistrictId($v['id']); $params = [];
// // dump($agentIds); $params["district_id"] = $v['id'];
// $where["a.reception_id"] = array( "in", $agentIds ); $params["status"] = 0; //只查询正常状态的经纪人
// $res = $this->getFollowUpNum($where,0); $field = "sum(call_number) as call_number_total";
// // dump($res); $agentModel = new AAgents();
$result_["user_phone_num"] = 0; $res = $agentModel->getUserPhoneNum($field, $params);
$result_["user_phone_num"] = isset($res[0]["call_number_total"]) ? $res[0]["call_number_total"] : 0;;
$result[]=$result_; $result[] = $result_;
} }
return $this->response(200, 'success', $result); return $this->response(200, 'success', $result);
} }
/** /**
* 新增-注册-登录用户数 * 新增-注册-登录用户数
* @return \think\Response * @return \think\Response
*/ */
public function loginNum(){ public function loginNum()
{
$params = $this->params; $params = $this->params;
$between = ['between', [$params['create_time_start']. ' 00:00:00', $params['create_time_end'] . ' 23:59:59']]; $between = [ 'between', [ $params['create_time_start'] . ' 00:00:00', $params['create_time_end'] . ' 23:59:59' ] ];
$where['create_time'] = $between; $where['create_time'] = $between;
// 新增客户数 // 新增客户数
$addUserNum = $this->userModel->getAddUserNumForOperation($where); $addUserNum = $this->userModel->getAddUserNumForOperation($where);
$result["add_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $result["add_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
// 注册客户数 // 注册客户数
$where = []; $where = [];
$where['create_time'] = $between; $where['create_time'] = $between;
$where['registration_time'] = array('exp','is not null'); $where['registration_time'] = array( 'exp', 'is not null' );
$addUserNum = $this->userModel->getAddUserNumForOperation($where); $addUserNum = $this->userModel->getAddUserNumForOperation($where);
$result["create_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $result["create_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
// 登录客户数 // 登录客户数
$where = []; $where = [];
$where['create_time'] = $between; $where['create_time'] = $between;
$where['last_login_time'] = array('exp','is not null'); $where['last_login_time'] = array( 'exp', 'is not null' );
$addUserNum = $this->userModel->getAddUserNumForOperation($where); $addUserNum = $this->userModel->getAddUserNumForOperation($where);
$result["login_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0; $result["login_user_num"] = isset($addUserNum[0]["num"]) ? $addUserNum[0]["num"] : 0;
return $this->response(200, 'success', $result); return $this->response(200, 'success', $result);
} }
...@@ -124,21 +118,22 @@ class OperationData extends Basic ...@@ -124,21 +118,22 @@ class OperationData extends Basic
* 商铺总量-待租数 * 商铺总量-待租数
* @return \think\Response * @return \think\Response
*/ */
public function houseNum(){ public function houseNum()
{
$params = $this->params; $params = $this->params;
if (!empty($params['create_time_start']) && !empty($params['create_time_end'])) { if (!empty($params['create_time_start']) && !empty($params['create_time_end'])) {
$where['create_time'] = ['between', [$params['create_time_start']. ' 00:00:00', $params['create_time_end'] . ' 23:59:59']]; $where['create_time'] = [ 'between', [ $params['create_time_start'] . ' 00:00:00', $params['create_time_end'] . ' 23:59:59' ] ];
} }
// 商铺总量 // 商铺总量
$house_res = $this->gHousesModel->getHouseNum($where); $house_res = $this->gHousesModel->getHouseNum($where);
$result["house_num"] = $house_res; $result["house_num"] = $house_res;
// 待租商铺数量 // 待租商铺数量
$where['residue_num'] = array('neq',0); $where['residue_num'] = array( 'neq', 0 );
$where['total'] = array('neq',0); $where['total'] = array( 'neq', 0 );
$house_res = $this->gHousesModel->getHouseNum($where); $house_res = $this->gHousesModel->getHouseNum($where);
$result["have_not_rent_num"] = $house_res; $result["have_not_rent_num"] = $house_res;
return $this->response(200, 'success', $result); return $this->response(200, 'success', $result);
...@@ -148,9 +143,10 @@ class OperationData extends Basic ...@@ -148,9 +143,10 @@ class OperationData extends Basic
* 各部门商场街铺进场数-商场街铺成交数 * 各部门商场街铺进场数-商场街铺成交数
* @return \think\Response * @return \think\Response
*/ */
public function houseBargainNum(){ public function houseBargainNum()
{
$params = $this->params; $params = $this->params;
$where['a.create_time'] = ['between', [$params['create_time_start']. ' 00:00:00', $params['create_time_end'] . ' 23:59:59']]; $where['a.create_time'] = [ 'between', [ $params['create_time_start'] . ' 00:00:00', $params['create_time_end'] . ' 23:59:59' ] ];
// 先查新所有部门 // 先查新所有部门
$district_list = $this->getDistrict(); $district_list = $this->getDistrict();
...@@ -160,73 +156,76 @@ class OperationData extends Basic ...@@ -160,73 +156,76 @@ class OperationData extends Basic
$result_["district_name"] = $v['district_name']; $result_["district_name"] = $v['district_name'];
// 商场进场数 // 商场进场数
$agentIds = $this->getAgentIDsByDistrictId($v['id']); $agentIds = $this->getAgentIDsByDistrictId($v['id']);
// dump($agentIds);
$where["a.reception_id"] = array( "in", $agentIds ); $where["a.reception_id"] = array( "in", $agentIds );
$res = $this->getFollowUpNum($where,0); $res = $this->getFollowUpNum($where, 0);
// dump($res);
$result_["indoor_shop_look_at_num"] = $res; $result_["indoor_shop_look_at_num"] = $res;
// 街铺进场数 // 街铺进场数
$res = $this->getFollowUpNum($where,1); $res = $this->getFollowUpNum($where, 1);
$result_["outdoor_shop_look_at_num"] = $res; $result_["outdoor_shop_look_at_num"] = $res;
// 商场成交数 // 商场成交数
$obargain = new OBargainModel(); $obargain = new OBargainModel();
$where_['a.create_time'] = $where['a.create_time']; $where_['a.create_time'] = $where['a.create_time'];
$where_['a.agent_id'] = array( "in", $agentIds ); $where_['a.agent_id'] = array( "in", $agentIds );
// dump($where_); $performanceSum = $obargain->getAddBargainNumOperation($where_, 0);
// exit;
$performanceSum = $obargain->getAddBargainNumOperation($where_, 0);
$result_["indoor_shop_bargain_num"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result_["indoor_shop_bargain_num"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
// 街铺成交数 // 街铺成交数
$performanceSum = $obargain->getAddBargainNumOperation($where_, 1); $performanceSum = $obargain->getAddBargainNumOperation($where_, 1);
$result_["outdoor_shop_bargain_num"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0; $result_["outdoor_shop_bargain_num"] = isset($performanceSum[0]["num"]) ? $performanceSum[0]["num"] : 0;
$result[]=$result_; $result[] = $result_;
} }
return $this->response(200, 'success', $result); return $this->response(200, 'success', $result);
} }
/** /**
* 获取部门列表 * 获取部门列表
* @return \think\Response * @return \think\Response
*/ */
public function getDistrict(){ public function getDistrict()
{
$params = []; $params = [];
$params['status'] = 0; $params['status'] = 0;
$field = 'id,district_name'; $field = 'id,district_name';
$district_model = new ADistrict(); $district_model = new ADistrict();
$result = $district_model->getDistrict($params,$field); $result = $district_model->getDistrict($params, $field);
return $result; return $result;
} }
/** /**
* 获取进场数 * 获取进场数
* @return \think\Response * @return \think\Response
*/ */
public function getFollowUpNum($params,$type){ public function getFollowUpNum($params, $type)
{
//shop_type '商铺类型(0商场,1街铺)' //shop_type '商铺类型(0商场,1街铺)'
$params['c.shop_type'] = $type == 0 ? 0: 1; $params['c.shop_type'] = $type == 0 ? 0 : 1;
// dump($params); $addMarchInNum = $this->marchInModel->getMarchInNumOperation($params);
$addMarchInNum = $this->marchInModel->getMarchInNumOperation($params);
return $addMarchInNum; return $addMarchInNum;
} }
public function getAgentIDsByDistrictId($district_id){ /**
* 查询区域的所有经纪人id
* @param $district_id
* @return string
*/
public function getAgentIDsByDistrictId($district_id)
{
//查询总监下面门店的所有经纪人 //查询总监下面门店的所有经纪人
$params=[]; $params = [];
$params["district_id"] = $district_id; $params["district_id"] = $district_id;
$params["status"] = 0; //只查询正常状态的经纪人 $params["status"] = 0; //只查询正常状态的经纪人
$agentModel = new AAgents(); $agentModel = new AAgents();
$agentsArr = $agentModel->getAgentsByStoreId($params); $agentsArr = $agentModel->getAgentsByStoreId($params);
$agent_total = count($agentsArr); $agent_total = count($agentsArr);
if ($agent_total > 0) { if ($agent_total > 0) {
$agentIds = ""; $agentIds = "";
...@@ -237,7 +236,6 @@ class OperationData extends Basic ...@@ -237,7 +236,6 @@ class OperationData extends Basic
}//查询总监下面门店的所有经纪人 end }//查询总监下面门店的所有经纪人 end
return $agentIds; return $agentIds;
} }
......
...@@ -1187,7 +1187,23 @@ class AAgents extends BaseModel ...@@ -1187,7 +1187,23 @@ class AAgents extends BaseModel
return $result; return $result;
} }
/**
* 客户来电数
* @param $field
* @param $params
* @return false|\PDOStatement|string|\think\Collection
*/
public function getUserPhoneNum($field ,$params)
{
$result = Db::table($this->table)
->field($field)
->where($params)
->group('district_id')
->select();
//echo $this->getLastSql();
return $result;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment