Commit 3eb736bc authored by zhuwei's avatar zhuwei

业绩修改

parent 7b751f43
......@@ -60,26 +60,28 @@ class PerformanceService
$where_ = [];
if($father_id){
if($type == 1){
$where_['store_id'] = $father_id;
$where_['a.store_id'] = $father_id;
}elseif($type == 2){
$where_['district_id'] = $father_id;
$where_['a.district_id'] = $father_id;
}
}
if (!empty($params['site_id'])) {
$where_['d.site_id'] = $params['site_id'];
}
//区域搜索条件
if (!empty($params['district_id'])) {
$where_['district_id'] = $params['district_id'];
$where_['a.district_id'] = $params['district_id'];
}
//部门搜索条件
if (!empty($params['store_id'])) {
$where_['store_id'] = $params['store_id'];
$where_['a.store_id'] = $params['store_id'];
}
//经纪人搜索条件
if (!empty($params['agent_id'])) {
$where_['agent_id'] = $params['agent_id'];
$where_['a.agent_id'] = $params['agent_id'];
}
$where_['total_time'] = array( 'between', array( $end_day, $yesterday ) );
$where_['a.total_time'] = array( 'between', array( $end_day, $yesterday ) );
/* 成交报告数 bargain_sum
收款数 paylog
......@@ -89,14 +91,14 @@ class PerformanceService
新增客户数 add_user_num
团队人数 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 = "a.agent_id,a.store_id,a.district_id,
sum(a.performance) as performance_total,
sum(a.bargain_sum) as bargain_sum_total,
sum(a.paylog) as paylog_total,
sum(a.march_in_num) as march_in_num_total,
sum(a.look_at_num) as look_at_num_total,
sum(a.add_house_num) as add_house_num_total,
sum(a.add_user_num) as add_user_num_total
";
//排序规则
......@@ -325,26 +327,35 @@ class PerformanceService
$where_ = [];
if($father_id){
if($type == 1){
$where_['store_id'] = $father_id;
$where_['a.store_id'] = $father_id;
}elseif($type == 2){
$where_['district_id'] = $father_id;
$where_['a.district_id'] = $father_id;
}
}
if (!empty($params['district_id'])) {
$where_['a.district_id'] = $params['district_id'];
}
if (!empty($params['site_id'])) {
$where_['d.site_id'] = $params['site_id'];
}
//区域搜索条件
if (!empty($params['district_id'])) {
$where_['district_id'] = $params['district_id'];
$where_['a.district_id'] = $params['district_id'];
}
//部门搜索条件
if (!empty($params['store_id'])) {
$where_['store_id'] = $params['store_id'];
$where_['a.store_id'] = $params['store_id'];
}
//经纪人搜索条件
if (!empty($params['agent_id'])) {
$where_['agent_id'] = $params['agent_id'];
$where_['a.agent_id'] = $params['agent_id'];
}
$where_['total_time'] = array( 'between', array( $end_day, $yesterday ) );
$where_['a.total_time'] = array( 'between', array( $end_day, $yesterday ) );
/* 成交报告数 bargain_sum
收款数 paylog
......@@ -354,18 +365,18 @@ class PerformanceService
新增客户数 add_user_num
团队人数 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 = "a.agent_id,a.store_id,a.district_id,
sum(a.performance) as performance_total,
sum(a.bargain_sum) as bargain_sum_total,
sum(a.paylog) as paylog_total,
sum(a.march_in_num) as march_in_num_total,
sum(a.look_at_num) as look_at_num_total,
sum(a.add_house_num) as add_house_num_total,
sum(a.add_user_num) as add_user_num_total
";
$order = "performance_total desc";
$result = $this->totalModel->getTotalByAgentId($field, $where_, $type, $order);
$result = $this->totalModel->getTotalByAgentIdSite($field, $where_, $type, $order);
$arr = [];
$field = "a.name,a.img,b.store_name,c.district_name";
......
......@@ -227,18 +227,20 @@ class TAgentTotalModel extends Model
$group_ = "";
switch ($type) {
case 1:
$group_ = "agent_id";
$group_ = "a.agent_id";
break;
case 2:
$group_ = "store_id";
$group_ = "a.store_id";
break;
case 3:
$group_ = "district_id";
$group_ = "a.district_id";
break;
}
$result = $this->db_
->field($field)
->alias('a')
->join('a_district d', 'a.district_id = d.id', 'left')
->where($params)
->group($group_)
->order($order)
......
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