1
This commit is contained in:
@@ -200,8 +200,6 @@ class Score extends Wxapp
|
||||
|
||||
public function get_radar()
|
||||
{
|
||||
$biz = (new Biz_model())->get(['id' => $this->biz_id]);
|
||||
$province_id = $biz['province_id'];
|
||||
$day_type = $this->input_param('day_type'); // 默认0昨天 1本月 2上月
|
||||
if($day_type==2){
|
||||
$s_time = date('Y-m-01 00:00:00', strtotime('last month'));
|
||||
@@ -213,96 +211,84 @@ class Score extends Wxapp
|
||||
$s_time = date('Y-m-d 00:00:00',strtotime("-1 day"));
|
||||
$e_time = date('Y-m-d 23:59:59',strtotime("-1 day"));
|
||||
}
|
||||
$s_stime = strtotime($s_time);
|
||||
$s_etime = strtotime($e_time);
|
||||
$indicator = [
|
||||
['name' => '拓客能力', 'max' => 100],
|
||||
['name' => '跟进能力', 'max' => 100],
|
||||
['name' => '邀约能力', 'max' => 100],
|
||||
['name' => '成交能力', 'max' => 100],
|
||||
['name' => '交付能力', 'max' => 100]
|
||||
];
|
||||
|
||||
$ts_s_time = strtotime($s_time);
|
||||
$ts_e_time = strtotime($e_time);
|
||||
|
||||
$biz = (new Biz_model())->get(['id' => $this->biz_id]);
|
||||
$province_id = $biz['province_id'];
|
||||
$bizs = (new Biz_model())->select(['province_id' => $province_id, 'status' => 1]);
|
||||
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
|
||||
|
||||
$names = [ '拓客能力', '跟进能力', '邀约能力', '成交能力', '交付能力'];
|
||||
$series_value = [];
|
||||
foreach ($indicator as $key => $value) {
|
||||
switch ($key) {
|
||||
case 0:
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'of_id' => 3,
|
||||
'c_time >=' => $s_stime,
|
||||
'c_time <=' => $s_etime,
|
||||
];
|
||||
$where_max = $where;
|
||||
$where_max["biz_id in (select id from lc_biz where province_id =$province_id)"] = null;
|
||||
$max = $this->customers_model->count($where_max);
|
||||
$max && $indicator[$key]['max'] = $max;
|
||||
$where['biz_id'] = $this->biz_id;
|
||||
$value = $this->customers_model->count($where) * 1.2;
|
||||
!$value && $value = $max*0.1;
|
||||
break;
|
||||
case 1://跟进能力
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
"biz_id in (select id from lc_biz where province_id =$province_id)" => null,
|
||||
"id in (select DISTINCT customer_id from lc_receiver_customer_oplogs where c_time>={$s_stime} and c_time>={$s_etime})" => null
|
||||
];
|
||||
$max = $this->customers_model->count($where);
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
"id in (select DISTINCT customer_id from lc_receiver_customer_oplogs where c_time>={$s_stime} and c_time>={$s_etime})" => null,
|
||||
"biz_id" => $this->biz_id
|
||||
];
|
||||
$value = $this->customers_model->count($where) * 1.2;
|
||||
$max && $indicator[$key]['max'] = $max;
|
||||
!$value && $value = $max*0.1;
|
||||
break;
|
||||
case 2:
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
"biz_id in (select id from lc_biz where province_id =$province_id)" => null,
|
||||
'dt_time >=' => $s_time,
|
||||
'dt_time <=' => $e_time,
|
||||
];
|
||||
$where_max = $where;
|
||||
$where_max["biz_id in (select id from lc_biz where province_id =$province_id)"] = null;
|
||||
$max = $this->customers_model->count($where_max);
|
||||
$max && $indicator[$key]['max'] = $max;
|
||||
$where["biz_id"] = $this->biz_id;
|
||||
$value = $this->customers_model->count($where) * 1.2;
|
||||
!$value && $value = $max*0.1;
|
||||
break;
|
||||
case 3:
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'c_time >=' => $s_stime,
|
||||
'c_time <=' => $s_etime,
|
||||
];
|
||||
$where_max = $where;
|
||||
$where_max["biz_id in (select id from lc_biz where province_id =$province_id)"] = null;
|
||||
$max = $this->orders_model->count($where_max);
|
||||
$max && $indicator[$key]['max'] = $max;
|
||||
$where["biz_id"] = $this->biz_id;
|
||||
$value = $this->orders_model->count($where) * 1.2;
|
||||
!$value && $value = $max*0.1;
|
||||
break;
|
||||
case 4:
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'over_time >=' => $s_time,
|
||||
'over_time <=' => $e_time,
|
||||
];
|
||||
$where_max = $where;
|
||||
$where_max["biz_id in (select id from lc_biz where province_id =$province_id)"] = null;
|
||||
$max = $this->orders_model->count($where_max);
|
||||
$max && $indicator[$key]['max'] = $max;
|
||||
$where['biz_id'] = $this->biz_id;
|
||||
$value = $this->orders_model->count($where) * 1.2;
|
||||
!$value && $value = $max*0.1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$series_value[] = $value;
|
||||
$max_total = 0;
|
||||
$indicator = [];
|
||||
|
||||
//拓客能力
|
||||
$where_max = $where = [
|
||||
'status>=' => 0,
|
||||
'of_id' => 3,
|
||||
'c_time >=' => $ts_s_time,
|
||||
'c_time <=' => $ts_e_time,
|
||||
];
|
||||
$where_max["biz_id in ($biz_id_arr)"] = null;
|
||||
$max = $this->customers_model->count($where_max);
|
||||
$where['biz_id'] = $this->biz_id;
|
||||
$series_value[] = $this->customers_model->count($where);
|
||||
$max_total = $max_total + $max;
|
||||
|
||||
//跟进能力
|
||||
$where_max = $where = [
|
||||
'status>=' => 0,
|
||||
"id in (select DISTINCT customer_id from lc_receiver_customer_oplogs where c_time>={$ts_s_time} and c_time>={$ts_e_time}) and cf_platform like 'wxapp'" => null
|
||||
];
|
||||
$where_max["biz_id in ($biz_id_arr)"] = null;
|
||||
$max = $this->customers_model->count($where_max);
|
||||
$where['biz_id'] = $this->biz_id;
|
||||
$series_value[] = $this->customers_model->count($where);
|
||||
$max_total = $max_total + $max;
|
||||
|
||||
//邀约能力
|
||||
$where_max = $where = [
|
||||
'status>=' => 0,
|
||||
'dt_time >=' => $s_time,
|
||||
'dt_time <=' => $e_time,
|
||||
];
|
||||
$where_max["biz_id in ($biz_id_arr)"] = null;
|
||||
$max = $this->customers_model->count($where_max);
|
||||
$where['biz_id'] = $this->biz_id;
|
||||
$series_value[] = $this->customers_model->count($where);
|
||||
$max_total = $max_total + $max;
|
||||
|
||||
//成交能力
|
||||
$where_max = $where = [
|
||||
'status>=' => 0,
|
||||
'order_time >=' => $s_time,
|
||||
'order_time <=' => $e_time,
|
||||
];
|
||||
$where_max["biz_id in ($biz_id_arr)"] = null;
|
||||
$max = $this->orders_model->count($where_max);
|
||||
$where["biz_id"] = $this->biz_id;
|
||||
$series_value[] = $this->orders_model->count($where);
|
||||
$max_total = $max_total + $max;
|
||||
|
||||
//交付能力
|
||||
$where_max = $where = [
|
||||
'status>=' => 0,
|
||||
'over_time >=' => $s_time,
|
||||
'over_time <=' => $e_time,
|
||||
];
|
||||
$where_max["biz_id in ($biz_id_arr)"] = null;
|
||||
$max = $this->orders_model->count($where_max);
|
||||
$where["biz_id"] = $this->biz_id;
|
||||
$series_value[] = $this->orders_model->count($where);
|
||||
$max_total = $max_total + $max;
|
||||
|
||||
foreach ($names as $value) {
|
||||
$indicator[] = array('name' => $value, 'max' => $max_total/5);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'indicator' => $indicator,
|
||||
'series_value' => $series_value
|
||||
|
||||
Reference in New Issue
Block a user