From 34099e12921afc2508672fbd93b5cc4b15e11690 Mon Sep 17 00:00:00 2001 From: lin fan Date: Mon, 4 Nov 2024 17:27:34 +0800 Subject: [PATCH] 1 --- api/controllers/wxapp/licheb/Score.php | 92 ++++++++------------------ 1 file changed, 27 insertions(+), 65 deletions(-) diff --git a/api/controllers/wxapp/licheb/Score.php b/api/controllers/wxapp/licheb/Score.php index 43030603..dc4ac5dd 100644 --- a/api/controllers/wxapp/licheb/Score.php +++ b/api/controllers/wxapp/licheb/Score.php @@ -216,11 +216,11 @@ class Score extends Wxapp $s_stime = strtotime($s_time); $s_etime = strtotime($e_time); $indicator = [ - ['name' => '拓客能力', 'max' => 100], - ['name' => '跟进能力', 'max' => 1], - ['name' => '邀约能力', 'max' => 100], - ['name' => '成交能力', 'max' => 100], - ['name' => '交付能力', 'max' => 1] + ['name' => '拓客能力', 'max' => 10], + ['name' => '跟进能力', 'max' => 10], + ['name' => '邀约能力', 'max' => 10], + ['name' => '成交能力', 'max' => 10], + ['name' => '交付能力', 'max' => 10] ]; $series_value = []; foreach ($indicator as $key => $value) { @@ -228,11 +228,13 @@ class Score extends Wxapp case 0: $where = [ 'status>=' => 0, - "biz_id in (biz_id in (select id from lc_biz where province_id =$province_id))" => null, + 'of_id' => 3, 'c_time >=' => $s_stime, 'c_time <=' => $s_etime, ]; - $max = $this->customers_model->count($where); + $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); @@ -241,41 +243,16 @@ class Score extends Wxapp $where = [ 'status>=' => 0, "biz_id in (select id from lc_biz where province_id =$province_id)" => null, - 'c_time >=' => strtotime($s_time), - 'c_time <=' => strtotime($e_time), "id in (select DISTINCT customer_id from lc_receiver_customer_oplogs where c_time>={$s_stime} and c_time>={$s_etime})" => null ]; - $province_gj = $this->customers_model->count($where); + $max = $this->customers_model->count($where); $where = [ 'status>=' => 0, - 'province_id' => $province_id, - 'c_time >=' => strtotime($s_time), - 'c_time <=' => strtotime($e_time), "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 ]; - $biz_gj = $this->customers_model->count($where); - $where = [ - 'status>=' => 0, - "biz_id in (select id from lc_biz where province_id =$province_id)" => null, - 'c_time >=' => strtotime($s_time), - 'c_time <=' => strtotime($e_time), - "status in (0,1)" => null - ]; - $province_total = $this->customers_model->count($where); - $where = [ - 'status>=' => 0, - 'c_time >=' => strtotime($s_time), - 'c_time <=' => strtotime($e_time), - "status in (0,1)" => null, - 'biz_id' => $this->biz_id - ]; - $biz_total = $this->customers_model->count($where); - $province_total && $max = $province_gj / $province_total; - $value = 0; - if ($biz_total) { - $value = $biz_gj / $biz_total; - } + $value = $this->customers_model->count($where); + $max && $indicator[$key]['max'] = $max; break; case 2: $where = [ @@ -284,7 +261,9 @@ class Score extends Wxapp 'dt_time >=' => $s_time, 'dt_time <=' => $e_time, ]; - $max = $this->customers_model->count($where); + $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); @@ -292,47 +271,30 @@ class Score extends Wxapp case 3: $where = [ 'status>=' => 0, - "biz_id in (select id from lc_biz where province_id =$province_id)" => null, 'c_time >=' => $s_stime, 'c_time <=' => $s_etime, ]; - $max = $this->customers_model->count($where); + $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; - $sub_sql = "select id from lc_receiver_customers where province_id={$province_id} and biz_id={$this->biz_id} and c_time>={$s_stime} and c_time>={$s_etime}"; - $where = [ - 'status>=' => 0, - "biz_id" => $this->biz_id, - 'c_time >=' => strtotime($s_time), - 'c_time <=' => strtotime($e_time), - "customer_id in ($sub_sql)" => null - ]; + $where["biz_id"] = $this->biz_id; $value = $this->orders_model->count($where); break; case 4: - $sub_sql = "select id from lc_receiver_customers where province_id={$province_id} and c_time>={$s_stime} and c_time>={$s_etime}"; $where = [ 'status>=' => 0, - 'c_time >=' => strtotime($s_time), - 'c_time <=' => strtotime($e_time), - "customer_id in ($sub_sql)" => null + 'over_time >=' => $s_time, + 'over_time <=' => $e_time, ]; - $province_order = $this->orders_model->count($where); - $where['status'] = 3; - $province_jf = $this->orders_model->count($where); - $sub_sql = "select id from lc_receiver_customers where biz_id={$this->biz_id} and province_id={$province_id} and c_time>={$s_stime} and c_time>={$s_etime}"; - $where = [ - 'status>=' => 0, - 'c_time >=' => strtotime($s_time), - 'c_time <=' => strtotime($e_time), - "customer_id in ($sub_sql)" => null - ]; - $biz_order = $this->orders_model->count($where); - $where['status'] = 3; - $biz_jf = $this->orders_model->count($where); - $province_order && $max = $province_jf / $province_order; + $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; - $value = $biz_order ? $biz_jf / $biz_order : 0; + $where['biz_id'] = $this->biz_id; + $value = $this->orders_model->count($where); default: + break; } $series_value[] = $value; }