77
This commit is contained in:
@@ -10,7 +10,7 @@ defined('BASEPATH') or exit('No direct script access allowed');
|
||||
class Customer extends HD_Controller
|
||||
{
|
||||
private $searchTpAry = array('mobile' => '客户手机号', 'cid' => '客户编号');
|
||||
private $searchTimeAry = array('c_time' => '创建时间', 'p_time' => '派单时间', 'cont_time' => '最后联系时间', 'dt_time' => '首次到店时间', 'order_time' => '下定时间', 'def_time' => '战败时间');
|
||||
private $searchTimeAry = array('p_time' => '派单/建档时间', 'cont_time' => '最后联系时间', 'dt_time' => '首次到店时间', 'order_time' => '下定时间', 'def_time' => '战败时间','c_time' => '创建时间', );
|
||||
|
||||
protected $log_dir;
|
||||
|
||||
@@ -52,7 +52,7 @@ class Customer extends HD_Controller
|
||||
//$wxqyAry = $this->customers_model->wxqyAry();
|
||||
$wxgrAry = $this->customers_model->wxgrAry();
|
||||
if ($count) {
|
||||
$fileds = 'id,cid,name,mobile,cf_title,cont_time,admin_id,status,biz_id,level,of_id,of2_id,wxgr,c_time,county_id';
|
||||
$fileds = 'id,cid,name,mobile,cf_title,p_time,cont_time,admin_id,status,biz_id,level,of_id,of2_id,wxgr,c_time,county_id';
|
||||
$rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds);
|
||||
//获取车管家
|
||||
$admin_id_arr = array_unique(array_column($rows, 'admin_id'));
|
||||
@@ -110,6 +110,7 @@ class Customer extends HD_Controller
|
||||
'biz_poi' => $area ? "{$area['province_name']}-{$area['city_name']}-{$area['county_name']}" : '',
|
||||
'biz_name' => isset($biz_rows[$val['biz_id']]) ? $biz_rows[$val['biz_id']][0]['biz_name'] : '',
|
||||
'c_time' => $val['c_time'] != '0' ? date('Y-m-d H:i:s', $val['c_time']) : '',
|
||||
'p_time' => $val['p_time'],
|
||||
'cont_time' => $val['cont_time'] != '0000-00-00 00:00:00' ? $val['cont_time'] : '',
|
||||
);
|
||||
}
|
||||
@@ -606,12 +607,14 @@ class Customer extends HD_Controller
|
||||
'of_title' => $of_title,
|
||||
'wx_name' => $this->customers_model->wxgrAry($row['wxgr']),
|
||||
'c_time' => date('Y-m-d H:i:s', $row['c_time']),
|
||||
'p_time' => $row['p_time'],
|
||||
'status' => $row['status'],
|
||||
'tag' => $tag,
|
||||
'tag_defeat' => $tag_defeat,
|
||||
'tag_intention' => $tag_intention,
|
||||
'poi' => $poi,
|
||||
'biz' => $row_biz['biz_name']
|
||||
'biz' => $row_biz['biz_name'],
|
||||
'time_name' => $row['clue_id'] ? '派单时间' : '建档时间',
|
||||
);
|
||||
|
||||
//到店信息
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="table-td"><span class="mr5">留资时间:</span>{{info.c_time}}</td>
|
||||
<td class="table-td"><span class="mr5">{{info.time_name}}:</span>{{info.p_time}}</td>
|
||||
<td class="table-td"><span class="mr5">微信好友:</span>{{info.wx_name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -219,7 +219,7 @@
|
||||
<th width="6%"><span>车管家</span></th>
|
||||
<th width="6%"><span>个微</span></th>
|
||||
<th width="6%"><span>状态</span></th>
|
||||
<th width="15%"><span>创建时间</span></th>
|
||||
<th width="15%"><span>派单/建档时间</span></th>
|
||||
<th width="15%"><span>最后联系时间</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -236,7 +236,7 @@
|
||||
<td style="vertical-align: middle;">{{v.admin_name}}</td>
|
||||
<td style="vertical-align: middle;">{{v.wxgr_name}}</td>
|
||||
<td style="vertical-align: middle;">{{v.status_name}}</td>
|
||||
<td style="vertical-align: middle;">{{v.c_time}}</td>
|
||||
<td style="vertical-align: middle;">{{v.p_time}}</td>
|
||||
<td style="vertical-align: middle;">{{v.cont_time}}</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
@@ -209,31 +209,6 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="am-form-group clearfix">
|
||||
<p class="am-text-default mb10 ml30 pt15 pb10">
|
||||
行驶证:
|
||||
</p>
|
||||
<ul id="viewer-car_img" class="photopic-list ml30 clearfix">
|
||||
<li style="position:relative;" v-if="info.img_data.car_img">
|
||||
<div style="position:absolute;top:5px;right:0;padding:0 8px 2px 8px;line-height:22px; background-color:rgba(0,0,0,.5);font-size:14px;color:#fff;"
|
||||
onclick="del_img('data','car_img','')">x
|
||||
</div>
|
||||
<a target="_blank" class="pic">
|
||||
<img alt="行驶证" onclick="showViewer('viewer-car_img')"
|
||||
:src="info.img_data.car_img"/>
|
||||
</a>
|
||||
</li>
|
||||
<li v-else>
|
||||
<a href="javascript:void(0);" class="pic" data-file="1" data-type="jpg,png,gif,png,jpeg"
|
||||
data-uptype="qiniu" data-field="car_img" data-mark="compalbum">
|
||||
<input type="hidden" class="car_img" name="car_img" data-type="1" value=""
|
||||
onchange="upImg('car_img',this)">
|
||||
<div></div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group clearfix">
|
||||
<div class="">
|
||||
<p class="am-text-default mb10 ml30 pt15 pb10">
|
||||
@@ -282,6 +257,30 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group clearfix">
|
||||
<p class="am-text-default mb10 ml30 pt15 pb10">
|
||||
行驶证:
|
||||
</p>
|
||||
<ul id="viewer-car_img" class="photopic-list ml30 clearfix">
|
||||
<li style="position:relative;" v-if="info.img_data.car_img">
|
||||
<div style="position:absolute;top:5px;right:0;padding:0 8px 2px 8px;line-height:22px; background-color:rgba(0,0,0,.5);font-size:14px;color:#fff;"
|
||||
onclick="del_img('data','car_img','')">x
|
||||
</div>
|
||||
<a target="_blank" class="pic">
|
||||
<img alt="行驶证" onclick="showViewer('viewer-car_img')"
|
||||
:src="info.img_data.car_img"/>
|
||||
</a>
|
||||
</li>
|
||||
<li v-else>
|
||||
<a href="javascript:void(0);" class="pic" data-file="1" data-type="jpg,png,gif,png,jpeg"
|
||||
data-uptype="qiniu" data-field="car_img" data-mark="compalbum">
|
||||
<input type="hidden" class="car_img" name="car_img" data-type="1" value=""
|
||||
onchange="upImg('car_img',this)">
|
||||
<div></div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="am-form-group clearfix">
|
||||
<div class="">
|
||||
<p class="am-text-default mb10 ml30 pt15 pb10">
|
||||
|
||||
@@ -92,7 +92,7 @@ class City extends Wxapp
|
||||
}
|
||||
$children[] = ['city_id' => $item2['city_id'], 'name' => $item2['city_name']];
|
||||
}
|
||||
$lists[] = ['name' => $rows[0]['province_name'], 'propvince_id' => $item, 'children' => $children];
|
||||
$lists[] = ['name' => $rows[0]['province_name'], 'province_id' => $item, 'children' => $children];
|
||||
}
|
||||
$data = [
|
||||
'area_list' => $lists,
|
||||
|
||||
@@ -49,7 +49,7 @@ class Series extends Wxapp{
|
||||
$page = $this->input_param('page');
|
||||
$size = $this->input_param('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
!$size && $size = 100;
|
||||
|
||||
$where = [
|
||||
'status' => 1
|
||||
@@ -69,7 +69,7 @@ class Series extends Wxapp{
|
||||
$size = $this->input_param('size');
|
||||
$series_id = $this->input_param('series_id');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
!$size && $size = 100;
|
||||
|
||||
$where = [
|
||||
'status' => 1
|
||||
|
||||
@@ -0,0 +1,776 @@
|
||||
<?php
|
||||
defined('WXAPP_APP') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Notes:店铺操作
|
||||
* Created on: 2021/12/15 16:43
|
||||
* Created by: dengbw
|
||||
*/
|
||||
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
|
||||
class Biz extends Wxapp
|
||||
{
|
||||
private $biz_id;
|
||||
|
||||
function __construct($inputs, $app_key)
|
||||
{
|
||||
parent::__construct($inputs, $app_key);
|
||||
|
||||
$this->login_white = array();//登录白名单
|
||||
$this->check_status = array();//用户状态校验
|
||||
$this->check_mobile = array();//需要手机号
|
||||
$this->check_headimg = array();//授权微信信息
|
||||
|
||||
$this->load->model('receiver/order/receiver_orders_model', 'orders_model');
|
||||
$this->load->model('receiver/receiver_customers_model', 'customers_model');
|
||||
$this->load->model('receiver/receiver_customer_sign_model','customer_sign_model');
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'app_user_model');
|
||||
|
||||
$this->biz_id = $this->get_biz_id();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:门店数据
|
||||
* Created on: 2022/8/10 14:37
|
||||
* Created by: dengbw
|
||||
* @return array
|
||||
*/
|
||||
protected function get_stats()
|
||||
{
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
|
||||
//客户
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id" => $this->biz_id
|
||||
];
|
||||
$customers = $this->customers_model->count($c_where);
|
||||
|
||||
//进店
|
||||
$s_where = [
|
||||
"c_time>=" => $c_time['s_time'],
|
||||
"c_time<=" => $c_time['e_time'],
|
||||
"status" => 1,
|
||||
"biz_id" => $this->biz_id
|
||||
];
|
||||
$sign = $this->customer_sign_model->count($s_where);
|
||||
|
||||
//个微
|
||||
$wxgrs = $this->customers_model->count(['biz_id' => $this->biz_id, 'status>=' => 0, 'p_time>=' => $o_time['s_time'], 'p_time<=' => $o_time['e_time'], 'wxgr' => 1]);
|
||||
//成交
|
||||
$orders = $this->orders_model->count(['biz_id' => $this->biz_id, 'status>=' => 0, 'order_time>=' => $o_time['s_time'], 'order_time<=' => $o_time['e_time']]);
|
||||
|
||||
$data['tabs'] = [['title' => '所有客户', 'value_1' => $customers, 'url' => '/pages/storeData/customerData/index?type=0'],
|
||||
['title' => '到店客户', 'value_1' => $sign, 'url' => '/pages/storeData/customerData/index?type=1'],
|
||||
['title' => '添加个微', 'value_1' => $wxgrs, 'url' => '/pages/storeData/customerData/index?type=2'],
|
||||
['title' => '所有订单', 'value_1' => $orders, 'url' => '/pages/storeData/customerData/index?type=3'],
|
||||
];
|
||||
|
||||
$orders_per = $customers ? $orders / $customers : 0;
|
||||
$intos_per = $customers ? $sign / $customers : 0;
|
||||
$orders_per = number_format_com($orders_per * 100, 1, '');
|
||||
$intos_per = number_format_com($intos_per * 100, 1, '');
|
||||
$data['funnel'] = ['title' => '线索转化',
|
||||
'expected_data' => [['name' => "订单({$orders_per}%)", 'value' => 33.3], ['name' => "到店({$intos_per}%)", 'value' => 66.7], ['name' => '客户(100%)', 'value' => 100]]
|
||||
, 'actual_data' => [['name' => '订单', 'value' => $orders], ['name' => '到店', 'value' => $sign], ['name' => '客户', 'value' => $customers]]];
|
||||
$data['title'] = '数据看板';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:客户/订单走势图
|
||||
* Created on: 2022/8/12 10:56
|
||||
* Created by: dengbw
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_stats_days()
|
||||
{
|
||||
$days = intval($this->input_param('days'));
|
||||
!$days && $days = 7;
|
||||
$customers = $orders = $xAxis = [];
|
||||
for ($i = ($days - 1); $i >= 0; $i--) {
|
||||
$s_time = date('Y-m-d', strtotime("-{$i} day"));
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($s_time)))];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $s_time . ' 23:59:59'];
|
||||
$xAxis[] = $days > 7 ? date('d', strtotime($s_time)) : date('n-d', strtotime($s_time));
|
||||
$customers[] = $this->customers_model->count(['biz_id' => $this->biz_id, 'status>=' => 0, 'p_time>=' => $o_time['s_time'], 'p_time<=' => $o_time['e_time']]);;
|
||||
$orders[] = $this->orders_model->count(['biz_id' => $this->biz_id, 'status>=' => 0, 'order_time>=' => $o_time['s_time'], 'order_time<=' => $o_time['e_time']]);
|
||||
}
|
||||
$title = $days == 7 ? "近一周" : "近{$days}日";
|
||||
$data = ['title' => "{$title}走势", 'legend_data' => ["客户", "订单"], 'xAxis' => $xAxis,
|
||||
'series' => [['name' => "客户", 'type' => 'line', 'smooth' => true, 'data' => $customers]
|
||||
, ['name' => "订单", 'type' => 'line', 'smooth' => true, 'data' => $orders]]];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:客户数据
|
||||
* Created on: 2022/8/11 16:09
|
||||
* Created by: dengbw
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_stats_customer()
|
||||
{
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$type = intval($this->input_param('type'));
|
||||
|
||||
$c_time = [
|
||||
's_time' => strtotime($s_time),
|
||||
'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))
|
||||
];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
$pie1_level = $pie1_offline = $users = $users_customer = [];
|
||||
$bottom2 = $bottom1 = '';
|
||||
|
||||
$sdata_level = $this->customers_model->get_sdata('level');
|
||||
foreach ($sdata_level as $v) {
|
||||
if($type == 1){
|
||||
$title = '到店客户';
|
||||
$where = [
|
||||
"a.c_time>=" => $c_time['s_time'],
|
||||
"a.c_time<=" => $c_time['e_time'],
|
||||
"a.status" => 1,
|
||||
"b.level" => $v,
|
||||
"b.biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->customer_sign_model->db->select('a.id')
|
||||
->from('lc_receiver_customer_sign as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}elseif($type == 2){
|
||||
$title = '添加微信';
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'level' => $v,
|
||||
'wxgr' => 1,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}elseif($type == 3){
|
||||
$title = '所有订单';
|
||||
$where = [
|
||||
'a.order_time>=' => $o_time['s_time'],
|
||||
'a.order_time<=' => $o_time['e_time'],
|
||||
"a.status >=" => 0,
|
||||
"b.level" => $v,
|
||||
"a.biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->orders_model->db->select('a.id')
|
||||
->from('lc_receiver_orders as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}else{
|
||||
$title = '所有客户';
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'level' => $v,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}
|
||||
if($value){
|
||||
$pie1_level[] = ['name' => $v, 'value' => $value];
|
||||
$bottom1 += $value;
|
||||
}
|
||||
}
|
||||
|
||||
$offlineSources = $this->customers_model->offlineSources();
|
||||
foreach ($offlineSources as $k => $v) {
|
||||
$id = count($v["list"]) > 0 ? $k : 0;
|
||||
|
||||
if($type == 1){
|
||||
//到店
|
||||
$where = [
|
||||
"a.c_time>=" => $c_time['s_time'],
|
||||
"a.c_time<=" => $c_time['e_time'],
|
||||
"a.status" => 1,
|
||||
"b.of_id" => $k,
|
||||
"b.biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->customer_sign_model->db->select('a.id')
|
||||
->from('lc_receiver_customer_sign as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}elseif($type == 2){
|
||||
//个微
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'of_id' => $k,
|
||||
'wxgr' => 1,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}elseif($type == 3){
|
||||
//订单
|
||||
$where = [
|
||||
'a.order_time>=' => $o_time['s_time'],
|
||||
'a.order_time<=' => $o_time['e_time'],
|
||||
"a.status >=" => 0,
|
||||
"b.of_id" => $k,
|
||||
"b.biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->orders_model->db->select('a.id')
|
||||
->from('lc_receiver_orders as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}else{
|
||||
//所有
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'of_id' => $k,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id" => $this->biz_id,
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}
|
||||
|
||||
$value && $pie1_offline[] = ['id' => $id, 'name' => $v['name'], 'value' => $value];
|
||||
}
|
||||
|
||||
$res_user = $this->app_user_model->select(['status' => 1, 'biz_id' => $this->biz_id], 'id desc', 0, 0, 'id,uname');
|
||||
foreach ($res_user as $k => $v) {
|
||||
$users[] = $v['uname'];
|
||||
|
||||
if($type == 1){
|
||||
//进店
|
||||
$where = [
|
||||
"a.c_time>=" => $c_time['s_time'],
|
||||
"a.c_time<=" => $c_time['e_time'],
|
||||
"a.status" => 1,
|
||||
"b.admin_id" => $v['id'],
|
||||
];
|
||||
$value = $this->customer_sign_model->db->select('a.id')
|
||||
->from('lc_receiver_customer_sign as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}elseif($type == 2){
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'admin_id' => $v['id'],
|
||||
'wxgr' => 1,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value = $this->customers_model->count($where);
|
||||
}elseif($type == 3){
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'admin_id' => $v['id'],
|
||||
'order_time>=' => $o_time['s_time'],
|
||||
'order_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value = $this->orders_model->count($where);
|
||||
}else{
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'admin_id' => $v['id'],
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value = $this->customers_model->count($where);
|
||||
}
|
||||
|
||||
$users_customer[] = $value;
|
||||
$bottom2 += $value;
|
||||
}
|
||||
$data['pie1'] = ['title' => '客户来源', 'series_data_1' => $pie1_level, 'series_data_2' => $pie1_offline, 'bottom' => "合计: {$bottom1}"];
|
||||
$data['bar'] = ['title' => '归属顾问', 'xAxis_data' => $users, 'series_data' => $users_customer,'bottom' => "合计: {$bottom2}"];
|
||||
$data['title'] = $title;
|
||||
|
||||
return $data;
|
||||
}
|
||||
//客户数据
|
||||
protected function get_stats_customer_pid()
|
||||
{
|
||||
$id = $this->input_param('id');
|
||||
$type = $this->input_param('type');
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))];
|
||||
$pie_offline = [];
|
||||
$where = ['biz_id' => $this->biz_id, 'status>=' => 0, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time']];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
|
||||
$offlineSources = $this->customers_model->offlineSources($id, 0);
|
||||
|
||||
foreach ($offlineSources["list"] as $k => $v) {
|
||||
$title = $offlineSources['name'];
|
||||
if($type==1){
|
||||
$where = [
|
||||
"a.c_time>=" => $c_time['s_time'],
|
||||
"a.c_time<=" => $c_time['e_time'],
|
||||
"a.status" => 1,
|
||||
'b.of_id'=> $id,
|
||||
'b.of2_id' => $k,
|
||||
"b.biz_id" => $this->biz_id,
|
||||
];
|
||||
$value_1 = $this->customer_sign_model->db->select('a.id')
|
||||
->from('lc_receiver_customer_sign as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
$value_1 && $pie_offline[] = ['id' => $id,'name' => $v, 'value' => $value_1];
|
||||
}else if($type==2){
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
"biz_id" => $this->biz_id,
|
||||
'wxgr' => 1,
|
||||
'of_id' => $id,
|
||||
'of2_id' => $k,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value_1 = $this->customers_model->count($where);
|
||||
$value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1];
|
||||
}else if($type==3){
|
||||
$where = [
|
||||
'a.order_time>=' => $o_time['s_time'],
|
||||
'a.order_time<=' => $o_time['e_time'],
|
||||
"a.status >=" => 0,
|
||||
'b.of_id' => $id,
|
||||
'b.of2_id' => $k,
|
||||
"b.biz_id" => $this->biz_id,
|
||||
];
|
||||
$value_1 = $this->orders_model->db->select('a.id')
|
||||
->from('lc_receiver_orders as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
|
||||
$value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1];
|
||||
}else{
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id" => $this->biz_id,
|
||||
];
|
||||
$value_1 = $this->customers_model->count(array_merge($where, ['of_id'=>$id,'of2_id' => $k]));
|
||||
$value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1];
|
||||
}
|
||||
|
||||
$bottom += $value_1;
|
||||
}
|
||||
|
||||
return ['title' => $title, 'series_data' => $pie_offline, 'bottom' => "合计: {$bottom}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:企微数据
|
||||
* Created on: 2022/8/11 15:40
|
||||
* Created by: dengbw
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_stats_wxqy()
|
||||
{
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))];
|
||||
$bar1_xAxis_data = $bar1_series_data = $bar2_xAxis_data = $bar2_series_data = [];
|
||||
$res_user = $this->app_user_model->select(['status' => 1, 'biz_id' => $this->biz_id], 'id desc', 0, 0, 'id,uname,userid');
|
||||
foreach ($res_user as $k => $v) {
|
||||
$bar1_xAxis_data[] = $v['uname'];
|
||||
$wxqys_add = 0;
|
||||
if ($v['userid']) {
|
||||
$wxqys_add = $this->mdWechatqyLog->count(["userid" => $v['userid'], 'change_type' => 'add_external_contact'
|
||||
, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time']]);
|
||||
}
|
||||
$bar1_series_data[] = $wxqys_add;
|
||||
$bar2_xAxis_data[] = $v['uname'];
|
||||
$bar2_series_data[] = $this->customers_model->count(['admin_id' => $v['id'], 'biz_id' => $this->biz_id, 'status>=' => 0
|
||||
, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time'], 'wxqy' => 1]);
|
||||
}
|
||||
$data['bar1'] = ['title' => '企微添加好友', 'xAxis_data' => $bar1_xAxis_data, 'series_data' => $bar1_series_data];
|
||||
$data['bar2'] = ['title' => '企微添加点亮', 'xAxis_data' => $bar2_xAxis_data, 'series_data' => $bar2_series_data];
|
||||
$data['title'] = '添加微信';
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:订单数据
|
||||
* Created on: 2022/8/11 15:40
|
||||
* Created by: dengbw
|
||||
* @return mixed
|
||||
*/
|
||||
protected function get_stats_order()
|
||||
{
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
$pie1_series_data = $users = $users_customer = $users_order = [];
|
||||
$pie1_bottom = 0;
|
||||
$offlineSources = $this->customers_model->offlineSources();
|
||||
foreach ($offlineSources as $k => $v) {
|
||||
$id = count($v["list"])>0 ? $k : 0;
|
||||
$value = $this->orders_model->db->select('a.id')
|
||||
->from('lc_receiver_orders as a')
|
||||
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
|
||||
->where(['b.biz_id' => $this->biz_id, 'a.status>=' => 0, 'a.order_time>=' => $o_time['s_time'], 'a.order_time<=' => $o_time['e_time']
|
||||
, 'b.of_id' => $k])
|
||||
->count_all_results();
|
||||
if ($value) {
|
||||
$pie1_series_data[] = ['id'=> $id, 'name' => $v['name'], 'value' => $value];
|
||||
$pie1_bottom += $value;
|
||||
}
|
||||
}
|
||||
$pie1_bottom = $pie1_bottom ? "订单数 $pie1_bottom" : '';
|
||||
$res_user = $this->app_user_model->select(['status' => 1, 'biz_id' => $this->biz_id], 'id desc', 0, 0, 'id,uname');
|
||||
foreach ($res_user as $k => $v) {
|
||||
$users[] = $v['uname'];
|
||||
$users_customer[] = $this->customers_model->count(['admin_id' => $v['id'], 'biz_id' => $this->biz_id, 'status>=' => 0
|
||||
, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time']]);
|
||||
$users_order[] = $this->orders_model->count(['admin_id' => $v['id'], 'biz_id' => $this->biz_id, 'status>=' => 0
|
||||
, 'order_time>=' => $o_time['s_time'], 'order_time<=' => $o_time['e_time']]);
|
||||
}
|
||||
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
|
||||
$series_data = $series_data_1 = $series_data_2 = [];
|
||||
$where_o = ['biz_id' => $this->biz_id, 'status>=' => 0, 'order_time>=' => $o_time['s_time'], 'order_time<=' => $o_time['e_time']];
|
||||
$where_r = ['biz_id' => $this->biz_id, 'status' => 2, 'refund_time>=' => $o_time['s_time'], 'refund_time<=' => $o_time['e_time']];
|
||||
//成交
|
||||
$orders = $this->orders_model->count($where_o);
|
||||
$res_o = $this->orders_model->select($where_o, 'id desc', 0, 0, 'distinct(brand_id) as brand_id');
|
||||
if ($res_o) {
|
||||
$str_ids = implode(",", array_unique(array_column($res_o, 'brand_id')));
|
||||
$map_brand = $this->mdAutoBrand->map('id', 'name', ["id in({$str_ids})" => null]);
|
||||
foreach ($res_o as $k => $v) {
|
||||
$name = $map_brand[$v['brand_id']] ? $map_brand[$v['brand_id']] : '-';
|
||||
$value = 0;
|
||||
if ($v['brand_id']) {
|
||||
$value = $this->orders_model->count(array_merge($where_o, ['brand_id' => $v['brand_id']]));
|
||||
}
|
||||
$brand_id = $v['brand_id'];
|
||||
$value && $series_data_1[] = ['id' => $brand_id,'name' => $name, 'value' => $value];
|
||||
}
|
||||
}
|
||||
//退定
|
||||
$refunds = $this->orders_model->count($where_r);
|
||||
$pie2_bottom = '';
|
||||
$orders_refunds = $orders + $refunds;
|
||||
if ($orders) {
|
||||
$series_data[] = ['name' => '成交', 'value' => $orders];
|
||||
$orders_per = number_format_com($orders / $orders_refunds * 100, 1, '');
|
||||
$pie2_bottom = "成交数 {$orders}({$orders_per}%)";
|
||||
}
|
||||
if ($refunds) {
|
||||
$series_data[] = ['name' => '退定', 'value' => $refunds];
|
||||
$refunds_per = number_format_com($refunds / $orders_refunds * 100, 1, '');
|
||||
$pie2_bottom = $pie2_bottom ? $pie2_bottom . " 退定数 {$refunds}({$refunds_per}%)" : "退定数 {$refunds}({$refunds_per}%)";
|
||||
}
|
||||
$data['pie1'] = ['title' => '订单来源', 'bottom' => $pie1_bottom, 'series_data' => $pie1_series_data];
|
||||
$data['pie2'] = ['title' => '品牌分布', 'bottom' => $pie2_bottom, 'series_data' => $series_data, 'series_data_1' => $series_data_1, 'series_data_2' => $series_data_2];
|
||||
$data['bar'] = ['title' => '顾问成交情况', 'xAxis_data' => $users
|
||||
, 'series' => [['name' => '客户数', 'type' => 'bar', 'data' => $users_customer], ['name' => '订单数', 'type' => 'bar', 'data' => $users_order]]];
|
||||
$data['title'] = '订单数据';
|
||||
return $data;
|
||||
}
|
||||
|
||||
//订单数据
|
||||
protected function get_stats_order_series(){
|
||||
$id = $this->input_param('id');
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
|
||||
$series_data_1 = [];
|
||||
$where_o = ['biz_id' => $this->biz_id, 'status>=' => 0, 'order_time>=' => $o_time['s_time'], 'order_time<=' => $o_time['e_time'],'brand_id'=>$id];
|
||||
//成交
|
||||
$res_o = $this->orders_model->select($where_o, 'id desc', 0, 0, 'distinct(s_id) as s_id');
|
||||
if ($res_o) {
|
||||
$str_ids = implode(",", array_unique(array_column($res_o, 's_id')));
|
||||
$map_series = $this->mdAutoSeries->map('id', 'name', ["id in({$str_ids})" => null]);
|
||||
foreach ($res_o as $k => $v) {
|
||||
$name = $map_series[$v['s_id']] ? $map_series[$v['s_id']] : '-';
|
||||
$value = 0;
|
||||
if ($v['s_id']) {
|
||||
$value = $this->orders_model->count(array_merge($where_o, ['s_id' => $v['s_id']]));
|
||||
}
|
||||
$value && $series_data_1[] = ['name' => $name, 'value' => $value];
|
||||
}
|
||||
}
|
||||
return ['title' => '品牌分布', 'series_data' => $series_data_1];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:店铺概况_tab
|
||||
* Created on: 2022/1/5 15:13
|
||||
* Created by: dengbw
|
||||
* @return array
|
||||
*/
|
||||
protected function get_situation_tabs()
|
||||
{
|
||||
return [['id' => 1, 'name' => '基础信息'], ['id' => 2, 'name' => '售卖情况']];
|
||||
}
|
||||
|
||||
protected function get_situation()
|
||||
{
|
||||
$this->load->model("biz/biz_brand_model", 'mdBizBrand');
|
||||
$this->load->model("biz/biz_base_model", 'mdBizBase');
|
||||
$this->load->model("biz/biz_sell_model", 'mdBizSell');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$this->load->model('area_model');
|
||||
$this->load->model('sys/sys_street_model', 'mdStreet');
|
||||
$tabs_id = intval($this->input_param('tabs_id'));
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
$re_biz = $this->mdBiz->get(['id' => $biz_id, 'status' => 1]);
|
||||
if (!$re_biz) {
|
||||
throw new Hd_exception('店铺不存在!', API_CODE_FAIL);
|
||||
}
|
||||
$info = [];
|
||||
if ($tabs_id == 2) {//售卖情况
|
||||
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
|
||||
$jsondata = $re_biz['jsondata'] ? json_decode($re_biz['jsondata'], true) : [];
|
||||
$y_month = date('Y-m', strtotime("-1 month"));//上个月
|
||||
$re_sell = $this->mdBizSell->get(['biz_id' => $biz_id, 'y_month' => $y_month]);
|
||||
$fields = $this->mdBizSell->get_fields();
|
||||
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$biz_id],'','','','brand_id');
|
||||
foreach ($fields as $key => $value) {
|
||||
if ($key == 'y_month') {
|
||||
$fields[$key]['value'] = $y_month;
|
||||
} else if ($key == 'cooperation_car' && $b_biz_rows) {
|
||||
$auto_brands = implode(',', array_column($b_biz_rows,'brand_id'));
|
||||
$res_ab = $this->mdAutoBrand->select(["id in({$auto_brands})" => null], 'id desc', 0, 0, 'name');
|
||||
$res_ab && $fields[$key]['value'] = array_column($res_ab, 'name');
|
||||
} else if ($key == 'sales') {
|
||||
$last_month_s = date("Y-m-01", strtotime("-1 month"));//上1个月1日
|
||||
$last_month_e = date("Y-m-d", strtotime("$last_month_s +1 month -1 day")); //上1个月最后一天
|
||||
$where = ['biz_id' => $biz_id, 'status<>' => -1, 'brand_id<>' => 3, 'biz_id<>' => 1];
|
||||
$orders = $this->orders_model->count(array_merge($where, ['c_time >=' => strtotime($last_month_s . ' 00:00:00')
|
||||
, 'c_time <=' => strtotime($last_month_e . ' 23:59:59')]));
|
||||
$fields[$key]['value'] = $orders;
|
||||
} else {
|
||||
$re_sell[$key] && $fields[$key]['value'] = $re_sell[$key];
|
||||
}
|
||||
$setValue = $fields[$key];
|
||||
$setValue['field'] = $key;
|
||||
$info[] = $setValue;
|
||||
}
|
||||
} else {//基础信息
|
||||
$re_base = $this->mdBizBase->get(['biz_id' => $biz_id]);
|
||||
$fields = $this->mdBizBase->get_fields();
|
||||
unset($fields['company']); # 230220close
|
||||
foreach ($fields as $key => $value) {
|
||||
$list = '';
|
||||
if ($key == 'county_id') {//县区
|
||||
$result = $this->area_model->get(['county_id' => $re_biz['county_id']]);
|
||||
$result['county_name'] && $fields[$key]['value'] = $result['county_name'];
|
||||
} else if ($key == 'street_id' && $re_biz['county_id']) {//乡镇
|
||||
$list[] = $value['list'];
|
||||
$result = $this->area(['type' => $key, 'id' => $re_biz['county_id']]);
|
||||
foreach ($result as $key2 => $value2) {
|
||||
$list[] = $value2;
|
||||
}
|
||||
$fields[$key]['list'] = $list;
|
||||
$re_biz['street_id'] && $fields[$key]['value'] = $re_biz['street_id'];
|
||||
} else if ($key == 'company' && $re_biz['brand_id']) {//公司名称
|
||||
$result = $this->mdBizBrand->get(['id' => $re_biz['brand_id']]);
|
||||
$result['brand_name'] && $fields[$key]['value'] = $result['brand_name'];
|
||||
} else if ($key == 'type') {//类型
|
||||
$fields[$key]['value'] = $this->mdBiz->type_ary($re_biz['type']);
|
||||
} else if ($key == 'level') {//级别
|
||||
$fields[$key]['value'] = $this->level($biz_id);
|
||||
} else if ($key == 'address' && $re_biz['address']) {//位置
|
||||
$fields[$key]['value'] = $re_biz['address'];
|
||||
} else if ($key == 'lead') {//负责人
|
||||
$list[] = $value['list'];
|
||||
$result = $this->app_user_model->select(['biz_id' => $biz_id], 'id DESC', 0, 0, 'id,uname as name');
|
||||
foreach ($result as $key2 => $value2) {
|
||||
$list[] = $value2;
|
||||
}
|
||||
$fields[$key]['list'] = $list;
|
||||
$re_base[$key] && $fields[$key]['value'] = $re_base[$key];
|
||||
} else if ($key == 'imgs') {//负责人
|
||||
$imgs = $re_base[$key] ? json_decode($re_base[$key], true) : [];
|
||||
foreach ($fields[$key]['list'] as $key2 => $value2) {
|
||||
$setValue = $value2;
|
||||
if ($imgs[$value2['id']]) {
|
||||
$setValue['value'] = $imgs[$value2['id']];
|
||||
$setValue['src'] = build_qiniu_image_url($setValue['value']);
|
||||
} else {
|
||||
$setValue['value'] = '';
|
||||
$setValue['src'] = '';
|
||||
}
|
||||
$list[] = $setValue;
|
||||
}
|
||||
$fields[$key]['list'] = $list;
|
||||
} else if ($re_base && $re_base[$key]) {//有字段赋值
|
||||
$fields[$key]['value'] = $re_base[$key];
|
||||
}
|
||||
$setValue = $fields[$key];
|
||||
$setValue['field'] = $key;
|
||||
$info[] = $setValue;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
protected function get_street()
|
||||
{
|
||||
$this->load->model('area_model');
|
||||
$this->load->model('sys/sys_street_model', 'mdStreet');
|
||||
$id = intval($this->input->get('id'));
|
||||
$list[] = ['id' => 0, 'name' => '选择乡镇'];
|
||||
if (!$id) {
|
||||
return $list;
|
||||
}
|
||||
$result = $this->area(['type' => 'street', 'id' => $id]);
|
||||
foreach ($result as $key => $value) {
|
||||
$list[] = $value;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function area($params)
|
||||
{
|
||||
$result = [];
|
||||
if ($params['id']) {
|
||||
if ($params['type'] == 'county_id' || $params['type'] == 'county') {
|
||||
$result = $this->area_model->county($params['id'], 1);
|
||||
} else if ($params['type'] == 'street_id' || $params['type'] == 'street') {
|
||||
$result = $this->mdStreet->select(['county_id' => $params['id']], 'id ASC', 0, 0, 'street_id as id,street_name as name');
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function post_situation()
|
||||
{
|
||||
$this->load->model("biz/biz_base_model", 'mdBizBase');
|
||||
$this->load->model("biz/biz_sell_model", 'mdBizSell');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$tabs_id = intval($this->input_param('tabs_id'));
|
||||
$info = $this->input_param('info');
|
||||
if (!$tabs_id || !$info) {
|
||||
throw new Exception('参数错误', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
|
||||
if ($tabs_id == 2) {//售卖情况
|
||||
$date = [];
|
||||
foreach ($info as $key => $value) {
|
||||
if ($value['field'] == 'sale_cars' || $value['field'] == 'clues_channel') {
|
||||
} else if ($value['field'] == 'cooperation_car') {
|
||||
$date[$value['field']] = $value['value'] ? implode(',', $value['value']) : '';
|
||||
} else {
|
||||
$date[$value['field']] = $value['value'];
|
||||
}
|
||||
}
|
||||
$y_month = date('Y-m', strtotime("-1 month"));//上个月
|
||||
$re_sell = $this->mdBizSell->get(['biz_id' => $biz_id, 'y_month' => $y_month]);
|
||||
if (!$re_sell) {//新增
|
||||
$date['biz_id'] = $biz_id;
|
||||
$date['y_month'] = $y_month;
|
||||
$date['status'] = 1;
|
||||
$date['c_time'] = time();
|
||||
$this->mdBizSell->add($date);
|
||||
} else {//更新
|
||||
$this->mdBizSell->update($date, ['id' => $re_sell['id']]);
|
||||
}
|
||||
} else {//基础信息
|
||||
$date = $biz = [];
|
||||
foreach ($info as $key => $value) {
|
||||
if ($value['field'] == 'company' || $value['field'] == 'level' || $value['field'] == 'type' || $value['field'] == 'county_id') {
|
||||
} else if ($value['field'] == 'address' || $value['field'] == 'street_id') {//更新门店信息
|
||||
$biz[$value['field']] = $value['value'];
|
||||
} else if ($value['field'] == 'imgs') {
|
||||
$imgs = [];
|
||||
foreach ($value['list'] as $key2 => $value2) {
|
||||
$imgs[$value2['id']] = $value2['value'];
|
||||
}
|
||||
$date[$value['field']] = json_encode($imgs, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$date[$value['field']] = $value['value'];
|
||||
}
|
||||
}
|
||||
$re_base = $this->mdBizBase->get(['biz_id' => $biz_id]);
|
||||
if (!$re_base) {//新增
|
||||
$date['biz_id'] = $biz_id;
|
||||
$date['status'] = 1;
|
||||
$date['c_time'] = time();
|
||||
$this->mdBizBase->add($date);
|
||||
} else {//更新
|
||||
$this->mdBizBase->update($date, ['id' => $re_base['id']]);
|
||||
}
|
||||
$this->mdBiz->update($biz, ['id' => $biz_id]);//更新门店信息
|
||||
}
|
||||
throw new Exception('保存成功', API_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
private function level($biz_id = 0)
|
||||
{
|
||||
$str = '';
|
||||
if ($biz_id) {
|
||||
$where = ['biz_id' => $biz_id, 'status<>' => -1, 'brand_id<>' => 3, 'biz_id<>' => 1];
|
||||
$last_month_s = date("Y-m-01", strtotime("-1 month"));//上1个月1日
|
||||
$last_month_e = date("Y-m-d", strtotime("$last_month_s +1 month -1 day")); //上1个月最后一天
|
||||
$orders = $this->orders_model->count(array_merge($where, ['c_time >=' => strtotime($last_month_s . ' 00:00:00')
|
||||
, 'c_time <=' => strtotime($last_month_e . ' 23:59:59')]));
|
||||
if ($orders >= 12) {
|
||||
$str = 'A1';
|
||||
} else if ($orders >= 9) {
|
||||
$str = 'A2';
|
||||
} else if ($orders >= 6) {
|
||||
$str = 'A3';
|
||||
} else if ($orders >= 5) {
|
||||
$str = 'B1';
|
||||
} else if ($orders >= 4) {
|
||||
$str = 'B2';
|
||||
} else if ($orders >= 3) {
|
||||
$str = 'B3';
|
||||
} else {
|
||||
$month_s = date("Y-m-01", strtotime("-3 month")); //上3个月1日
|
||||
$month_e = date("Y-m-d", strtotime("$month_s +1 month -1 day")); //上3个月最后一天
|
||||
$orders = $this->orders_model->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00')
|
||||
, 'c_time <=' => strtotime($month_e . ' 23:59:59')]));
|
||||
if ($orders && $orders <= 8) {
|
||||
$str = 'C1';
|
||||
} else {
|
||||
$month_s = date("Y-m-d", strtotime("$last_month_s -15 day"));//45天前
|
||||
$month_e = $last_month_e; //上个月最后一天
|
||||
$orders = $this->orders_model->count(array_merge($where, ['c_time >=' => strtotime($month_s . ' 00:00:00')
|
||||
, 'c_time <=' => strtotime($month_e . ' 23:59:59')]));
|
||||
if ($orders == 1) {
|
||||
$str = 'C2';
|
||||
} else if ($orders == 0) {
|
||||
$this->load->model('items/items_model', 'mdItems');
|
||||
$count_items = $this->mdItems->count(['status<>' => 0, 'biz_id' => $biz_id, 'brand_id<>' => 3, 'biz_id<>' => 1]);
|
||||
!$count_items && $str = 'C3';//门店有样车未开单
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -222,6 +222,9 @@ class Cusorder extends Wxapp
|
||||
}
|
||||
$res = $this->orders_model->update(['status' => $status], ['id' => $id]);
|
||||
if ($res) {
|
||||
if($status == -1){
|
||||
throw new Exception('操作成功', API_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
//记日志
|
||||
$uid = $this->session['uid'];
|
||||
@@ -375,7 +378,11 @@ class Cusorder extends Wxapp
|
||||
$where['biz_id'] = $this->biz_id;
|
||||
}
|
||||
if ($keyword) {
|
||||
$where['name'] = $keyword;
|
||||
if (is_numeric($keyword)) {
|
||||
$where["mobile like '%{$keyword}%'"] =null;
|
||||
} else {
|
||||
$where["name like '%{$keyword}%'"] =null;
|
||||
}
|
||||
}
|
||||
if ($status == 11) { //进行中
|
||||
$where['status<'] = 3;
|
||||
|
||||
@@ -58,7 +58,7 @@ class Customers extends Wxapp
|
||||
if ($this->get_biz('type') != 5) {
|
||||
$other_data['客户来源'] = $this->get_cfTitle($row);
|
||||
}
|
||||
$other_data['建卡时间'] = date('Y-m-d', $row['c_time']);
|
||||
$other_data['建档时间'] = date('Y-m-d', $row['c_time']);
|
||||
$row['cont_time'] != '0000-00-00 00:00:00' && $other_data['最近联系'] = date('Y-m-d', strtotime($row['cont_time']));
|
||||
if ($this->session['group_id'] == 1) {
|
||||
$where_visit = ['c_id' => $id, 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']];
|
||||
@@ -73,7 +73,7 @@ class Customers extends Wxapp
|
||||
'id' => $row['id'],
|
||||
'cid' => $row['cid'],
|
||||
'name' => $row['name'],
|
||||
'mobile' => $this->get_mobile(['mobile' => $row['mobile'], 'of_id' => $row['of_id'], 'of2_id' => $row['of2_id']]),
|
||||
'mobile' => $this->get_mobile(['mobile' => $row['mobile'], 'clue_id' => $row['clue_id']]),
|
||||
'complete_mobile' => $row['mobile'],
|
||||
'tip' => $tip,
|
||||
'is_top' => $row['is_top'],
|
||||
@@ -113,7 +113,7 @@ class Customers extends Wxapp
|
||||
$of_title = $row['of_id'] ? $this->get_cfTitle($row) : '';
|
||||
$data['baseinfo'] = [
|
||||
'name' => ['value' => $row['name'], 'cn' => '客户姓名'],
|
||||
'mobile' => ['value' => $this->get_mobile(['mobile' => $row['mobile'], 'of_id' => $row['of_id'], 'of2_id' => $row['of2_id']]), 'cn' => '客户电话'],
|
||||
'mobile' => ['value' => $this->get_mobile(['mobile' => $row['mobile'], 'clue_id' => $row['clue_id']]), 'cn' => '客户电话'],
|
||||
// 'c_brand' => $row['c_brand'],
|
||||
'of_id' => ['value' => $of_title, 'of_id' => intval($row['of_id']), 'of2_id' => intval($row['of2_id']), 'cn' => '客户来源', 'edit_status' => $edit_status],
|
||||
'buy_time' => ['value' => $row['buy_time'], 'cn' => '预计购车时间'],
|
||||
@@ -922,7 +922,7 @@ class Customers extends Wxapp
|
||||
if ($param['biz_type'] != 5) {
|
||||
$other_data['客户来源'] = $this->get_cfTitle($val);
|
||||
}
|
||||
$other_data['建卡时间'] = date('Y-m-d', $val['c_time']);
|
||||
$other_data['建档时间'] = date('Y-m-d', $val['c_time']);
|
||||
$val['cont_time'] != '0000-00-00 00:00:00' && $other_data['最近联系'] = date('Y-m-d', strtotime($val['cont_time']));
|
||||
if ($param['group_id'] == 1) {
|
||||
$where_visit = ['c_id' => $val['id'], 'biz_id' => $this->biz_id, 'sales_id' => $this->session['uid']];
|
||||
@@ -943,7 +943,7 @@ class Customers extends Wxapp
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
|
||||
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'clue_id' => $val['clue_id']]),
|
||||
'complete_mobile' => $val['mobile'],
|
||||
'is_top' => $val['is_top'],
|
||||
'other_data' => $other_data,
|
||||
@@ -1260,7 +1260,7 @@ class Customers extends Wxapp
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['name'],
|
||||
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'of_id' => $val['of_id'], 'of2_id' => $val['of2_id']]),
|
||||
'mobile' => $this->get_mobile(['mobile' => $val['mobile'], 'clue_id' => $val['clue_id']]),
|
||||
'reason' => $reason,
|
||||
];
|
||||
}
|
||||
@@ -1355,8 +1355,10 @@ class Customers extends Wxapp
|
||||
$mobile = $params['mobile'];
|
||||
if (!$mobile) {
|
||||
return '';
|
||||
} else {
|
||||
} elseif ($params['clue_id']){
|
||||
return mobile_asterisk($mobile);
|
||||
}else {
|
||||
return $mobile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -146,7 +146,6 @@ class Sign extends Wxapp
|
||||
$biz = $this->biz_model->get(['id' => $biz_id]);
|
||||
$biz_user = $this->app_user_model->get(['id' => $biz_uid]);
|
||||
$sign_data['sid'] = create_customer_no($biz['city_id']);
|
||||
$sign_data['biz_id'] = $biz_id;
|
||||
//计算距离
|
||||
$distance = get_distance($lat, $lng, $biz['lat'], $biz['lng']);
|
||||
$biz['lat'] && $sign_data['biz_lat'] = $biz['lat'];
|
||||
|
||||
@@ -21,8 +21,7 @@ class Statistics extends Wxapp{
|
||||
$this->load->model("biz/biz_model");
|
||||
$this->load->model('receiver/receiver_customers_model','customers_model');
|
||||
$this->load->model('receiver/order/receiver_orders_model','orders_model');
|
||||
$this->load->model('receiver/order/receiver_customer_sign_model','customer_sign_model');
|
||||
//$this->load->library('receiver/stats_entity');
|
||||
$this->load->model('receiver/receiver_customer_sign_model','customer_sign_model');
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
@@ -645,75 +644,69 @@ class Statistics extends Wxapp{
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
|
||||
$biz_where = array('province_id' => $province_id, 'status' => 1);
|
||||
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
|
||||
$city_id && $biz_where['city_id'] = $city_id;
|
||||
$bizs = $this->biz_model->select($biz_where);
|
||||
if($bizs){
|
||||
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
|
||||
}
|
||||
|
||||
//门店数
|
||||
$biz_count = count($bizs);
|
||||
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
|
||||
|
||||
//客户
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
'biz_id in ('.$biz_id_arr.')' => null,
|
||||
"biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$customers = $this->customers_model->count($c_where);
|
||||
|
||||
//进店
|
||||
$s_where = [
|
||||
'c_time>=' => $c_time['s_time'],
|
||||
'c_time<=' => $c_time['e_time'],
|
||||
'status' => 1,
|
||||
"c_time>=" => $c_time['s_time'],
|
||||
"c_time<=" => $c_time['e_time'],
|
||||
"status" => 1,
|
||||
"biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$intos = $this->customer_sign_model-count($s_where);
|
||||
$sign = $this->customer_sign_model->count($s_where);
|
||||
|
||||
//个微
|
||||
$g_where = [
|
||||
'status>=' => 0,
|
||||
'wxgr' => 1,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$wxgr = $this->customers_model->count($g_where);
|
||||
|
||||
//成交
|
||||
$where = [
|
||||
$o_where = [
|
||||
'status>=' => 0,
|
||||
'order_time>=' => $o_time['s_time'],
|
||||
'order_time<=' => $o_time['e_time'],
|
||||
"customer_id in (
|
||||
select id from lc_receiver_customers where status>=0 and cs_biz_id!=-1 and
|
||||
biz_id in (select id from lc_biz where city_id={$city_id} and status=1)
|
||||
)" => null
|
||||
];
|
||||
$orders = $this->orders_model->count($where);
|
||||
$where = [
|
||||
'a.status>=' => 0,
|
||||
'a.bill_time>=' => $o_time['s_time'],
|
||||
'a.bill_time<=' => $o_time['e_time'],
|
||||
'a.status<>' => 2,
|
||||
'b.pid_status' => 3,
|
||||
'b.status in (1,2)' => null,
|
||||
"a.customer_id in (
|
||||
select id from lc_receiver_customers where status>=0 and cs_biz_id!=-1 and
|
||||
biz_id in (select id from lc_biz where city_id={$city_id} and status=1)
|
||||
)" => null
|
||||
"biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$orders = $this->orders_model->count($o_where);
|
||||
|
||||
$data['tabs'] = [
|
||||
['title' => '门店', 'value_1' => $biz_count, 'url' => '/pages/dataAnalysis/detail/index?type=3'],
|
||||
['title' => '客户', 'value_1' => $customers, 'url' => '/pages/dataAnalysis/detail/index?type=0'],
|
||||
['title' => '到店', 'value_1' => $intos, 'url' => '/pages/dataAnalysis/detail/index?type=1'],
|
||||
['title' => '订单', 'value_1' => $orders, 'url' => '/pages/dataAnalysis/detail/index?type=2'],
|
||||
['title' => '所有客户', 'value_1' => $customers, 'url' => '/pages/dataAnalysis/detail/index?type=0'],
|
||||
['title' => '到店客户', 'value_1' => $sign, 'url' => '/pages/dataAnalysis/detail/index?type=1'],
|
||||
['title' => '添加微信', 'value_1' => $wxgr, 'url' => '/pages/dataAnalysis/detail/index?type=2'],
|
||||
['title' => '所有订单', 'value_1' => $orders, 'url' => '/pages/dataAnalysis/detail/index?type=3'],
|
||||
];
|
||||
$orders_per = number_format_com($orders / $customers * 100, 1, '');
|
||||
$intos_per = number_format_com($intos / $customers * 100, 1, '');
|
||||
$orders_per = $customers ? $orders / $customers : 0;
|
||||
$intos_per = $customers ? $sign / $customers : 0;
|
||||
$orders_per = number_format_com($orders_per * 100, 1, '');
|
||||
$intos_per = number_format_com($intos_per * 100, 1, '');
|
||||
$data['funnel'] = [
|
||||
'title' => '转化漏斗',
|
||||
'expected_data' => [
|
||||
['name' => "成交数({$orders_per}%)", 'value' => 33.3],
|
||||
['name' => "到店数({$intos_per}%)", 'value' => 66.7],
|
||||
['name' => '客户数100%', 'value' => 100]
|
||||
['name' => "订单({$orders_per}%)", 'value' => 33.3],
|
||||
['name' => "到店({$intos_per}%)", 'value' => 66.7],
|
||||
['name' => '客户(100%)', 'value' => 100]
|
||||
],
|
||||
'actual_data' => [
|
||||
['name' => '成交数', 'value' => $orders],
|
||||
['name' => '到店数', 'value' => $intos],
|
||||
['name' => '客户量', 'value' => $customers]
|
||||
['name' => '订单', 'value' => $orders],
|
||||
['name' => '到店', 'value' => $sign],
|
||||
['name' => '客户', 'value' => $customers]
|
||||
]
|
||||
];
|
||||
$data['title'] = '数据看板';
|
||||
@@ -732,30 +725,32 @@ class Statistics extends Wxapp{
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($s_time)))];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $s_time . ' 23:59:59'];
|
||||
$xAxis[] = $days > 7 ? date('d', strtotime($s_time)) : date('n-d', strtotime($s_time));
|
||||
$where = [
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'c_time>=' => $c_time['s_time'],
|
||||
'c_time<=' => $c_time['e_time'],
|
||||
"biz_id in (select id from lc_biz where province_id={$province_id} and status=1)" => null
|
||||
];
|
||||
$customers[] = $this->customers_model->count($where);
|
||||
$where = [
|
||||
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
|
||||
$city_id && $biz_where['city_id'] = $city_id;
|
||||
$bizs = $this->biz_model->select($biz_where);
|
||||
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
|
||||
$c_where["biz_id in ({$biz_id_arr})"] = null;
|
||||
$customers[] = $this->customers_model->count($c_where);
|
||||
$o_where = [
|
||||
'status>=' => 0,
|
||||
'order_time>=' => $o_time['s_time'],
|
||||
'order_time<=' => $o_time['e_time'],
|
||||
"customer_id in (
|
||||
select id from lc_receiver_customers where status>=0 and biz_id in (select id from lc_biz where province_id={$province_id} and status=1)
|
||||
)" => null
|
||||
"biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$orders[] = $this->orders_model->count($where);
|
||||
$orders[] = $this->orders_model->count($o_where);
|
||||
}
|
||||
$title = $days == 7 ? "近一周" : "近{$days}日";
|
||||
$data = [
|
||||
'title' => "{$title}走势图", 'legend_data' => ["客户数", "订单数"],
|
||||
'title' => "{$title}走势", 'legend_data' => ["客户", "订单"],
|
||||
'xAxis' => $xAxis,
|
||||
'series' => [
|
||||
['name' => "客户数", 'type' => 'line', 'smooth' => true, 'data' => $customers],
|
||||
['name' => "订单数", 'type' => 'line', 'smooth' => true, 'data' => $orders]
|
||||
['name' => "客户", 'type' => 'line', 'smooth' => true, 'data' => $customers],
|
||||
['name' => "订单", 'type' => 'line', 'smooth' => true, 'data' => $orders]
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
@@ -765,17 +760,274 @@ class Statistics extends Wxapp{
|
||||
{
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
$province_id = intval($this->input_param('province_id'));
|
||||
$city_id = intval($this->input_param('city_id'));
|
||||
$type = intval($this->input_param('type'));
|
||||
switch ($type){
|
||||
case 1: //到店客户
|
||||
return $this->stats_entity->customers($s_time,$e_time,$city_id,$type);
|
||||
case 2: //订单数
|
||||
return $this->stats_entity->orders($s_time,$e_time,$city_id);;
|
||||
case 3: //开票数
|
||||
return $this->stats_entity->orders($s_time,$e_time,$city_id,$type);
|
||||
default: //全部客户
|
||||
return $this->stats_entity->customers($s_time,$e_time,$city_id);
|
||||
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$c_time = [
|
||||
's_time' => strtotime($s_time),
|
||||
'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))
|
||||
];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
$pie1_level = $pie1_offline = $biz_customer = [];
|
||||
$bottom2 = $bottom1 = '';
|
||||
|
||||
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
|
||||
$city_id && $biz_where['city_id'] = $city_id;
|
||||
$bizs = $this->biz_model->select($biz_where);
|
||||
if($bizs){
|
||||
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
|
||||
|
||||
$sdata_level = $this->customers_model->get_sdata('level');
|
||||
foreach ($sdata_level as $v) {
|
||||
if($type == 1){
|
||||
$title = '到店客户';
|
||||
$where = [
|
||||
"a.c_time>=" => $c_time['s_time'],
|
||||
"a.c_time<=" => $c_time['e_time'],
|
||||
"a.status" => 1,
|
||||
"b.level" => $v,
|
||||
"b.biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$value = $this->customer_sign_model->db->select('a.id')
|
||||
->from('lc_receiver_customer_sign as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}elseif($type == 2){
|
||||
$title = '添加微信';
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'level' => $v,
|
||||
'wxgr' => 1,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id in ({$biz_id_arr})" => null
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}elseif($type == 3){
|
||||
$title = '所有订单';
|
||||
$where = [
|
||||
'a.order_time>=' => $o_time['s_time'],
|
||||
'a.order_time<=' => $o_time['e_time'],
|
||||
"a.status >=" => 0,
|
||||
"b.level" => $v,
|
||||
"b.biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$value = $this->orders_model->db->select('a.id')
|
||||
->from('lc_receiver_orders as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}else{
|
||||
$title = '所有客户';
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'level' => $v,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id in ({$biz_id_arr})" => null
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}
|
||||
if($value){
|
||||
$pie1_level[] = ['name' => $v, 'value' => $value];
|
||||
$bottom1 += $value;
|
||||
}
|
||||
}
|
||||
|
||||
$offlineSources = $this->customers_model->offlineSources();
|
||||
foreach ($offlineSources as $k => $v) {
|
||||
$id = count($v["list"]) > 0 ? $k : 0;
|
||||
|
||||
if($type == 1){
|
||||
//到店
|
||||
$where = [
|
||||
"a.c_time>=" => $c_time['s_time'],
|
||||
"a.c_time<=" => $c_time['e_time'],
|
||||
"a.status" => 1,
|
||||
"b.of_id" => $k,
|
||||
"b.biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$value = $this->customer_sign_model->db->select('a.id')
|
||||
->from('lc_receiver_customer_sign as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}elseif($type == 2){
|
||||
//个微
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'of_id' => $k,
|
||||
'wxgr' => 1,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id in ({$biz_id_arr})" => null
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}elseif($type == 3){
|
||||
//订单
|
||||
$where = [
|
||||
'a.order_time>=' => $o_time['s_time'],
|
||||
'a.order_time<=' => $o_time['e_time'],
|
||||
"a.status >=" => 0,
|
||||
"b.of_id" => $k,
|
||||
"b.biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$value = $this->orders_model->db->select('a.id')
|
||||
->from('lc_receiver_orders as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
}else{
|
||||
//所有
|
||||
$c_where = [
|
||||
'status>=' => 0,
|
||||
'of_id' => $k,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id in ({$biz_id_arr})" => null
|
||||
];
|
||||
$value = $this->customers_model->count($c_where);
|
||||
}
|
||||
|
||||
$value && $pie1_offline[] = ['id' => $id,'name' => $v['name'], 'value' => $value];
|
||||
}
|
||||
|
||||
//门店归属
|
||||
foreach ($bizs as $k => $v) {
|
||||
$biz_arr[] = str_replace('车卖场', '', $v['biz_name']);
|
||||
if($type == 1){
|
||||
//进店
|
||||
$s_where = [
|
||||
"c_time>=" => $c_time['s_time'],
|
||||
"c_time<=" => $c_time['e_time'],
|
||||
"status" => 1,
|
||||
"biz_id" => $v['id'],
|
||||
];
|
||||
$value = $this->customer_sign_model->count($s_where);
|
||||
}elseif($type == 2){
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'biz_id' => $v['id'],
|
||||
'wxgr' => 1,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value = $this->customers_model->count($where);
|
||||
}elseif($type == 3){
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'biz_id' => $v['id'],
|
||||
'order_time>=' => $o_time['s_time'],
|
||||
'order_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value = $this->orders_model->count($where);
|
||||
}else{
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'biz_id' => $v['id'],
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value = $this->customers_model->count($where);
|
||||
}
|
||||
$biz_customer[] = $value;
|
||||
$bottom2 += $value;
|
||||
}
|
||||
}
|
||||
|
||||
$data['pie1'] = ['title' => '客户来源', 'series_data_1' => $pie1_level, 'series_data_2' => $pie1_offline,'bottom' => "合计: {$bottom1}"];
|
||||
$data['bar'] = ['title' => '归属门店', 'xAxis_data' => $biz_arr, 'series_data' => $biz_customer,'bottom' => "合计: {$bottom2}"];
|
||||
$data['title'] = $title;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function get_stats_customer_pid()
|
||||
{
|
||||
$id = $this->input_param('id');
|
||||
$type = $this->input_param('type');
|
||||
$s_time = $this->input_param('s_time');
|
||||
$e_time = $this->input_param('e_time');
|
||||
$province_id = intval($this->input_param('province_id'));
|
||||
$city_id = intval($this->input_param('city_id'));
|
||||
|
||||
!$s_time && $s_time = date('Y-m-d');
|
||||
!$e_time && $e_time = date('Y-m-d');
|
||||
$c_time = ['s_time' => strtotime($s_time), 'e_time' => strtotime(date('Y-m-d 23:59:59', strtotime($e_time)))];
|
||||
$pie_offline = [];
|
||||
$o_time = ['s_time' => $s_time . ' 00:00:00', 'e_time' => $e_time . ' 23:59:59'];
|
||||
|
||||
$biz_where = array('province_id' => $province_id, 'status' => 1, 'type' => 0);
|
||||
$city_id && $biz_where['city_id'] = $city_id;
|
||||
$bizs = $this->biz_model->select($biz_where);
|
||||
if($bizs){
|
||||
$biz_id_arr = implode(',', array_unique(array_column($bizs, 'id')));
|
||||
$offlineSources = $this->customers_model->offlineSources($id, 0);
|
||||
|
||||
foreach ($offlineSources["list"] as $k => $v) {
|
||||
$title = $offlineSources['name'];
|
||||
if($type==1){
|
||||
$where = [
|
||||
"a.c_time>=" => $c_time['s_time'],
|
||||
"a.c_time<=" => $c_time['e_time'],
|
||||
"a.status" => 1,
|
||||
'b.of_id'=> $id,
|
||||
'b.of2_id' => $k,
|
||||
"b.biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$value_1 = $this->customer_sign_model->db->select('a.id')
|
||||
->from('lc_receiver_customer_sign as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
$value_1 && $pie_offline[] = ['id' => $id,'name' => $v, 'value' => $value_1];
|
||||
}else if($type==2){
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
"biz_id in ({$biz_id_arr})" => null,
|
||||
'wxgr' => 1,
|
||||
'of_id' => $id,
|
||||
'of2_id' => $k,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
];
|
||||
$value_1 = $this->customers_model->count($where);
|
||||
$value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1];
|
||||
}else if($type==3){
|
||||
$where = [
|
||||
'a.order_time>=' => $o_time['s_time'],
|
||||
'a.order_time<=' => $o_time['e_time'],
|
||||
"a.status >=" => 0,
|
||||
'b.of_id' => $id,
|
||||
'b.of2_id' => $k,
|
||||
"b.biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$value_1 = $this->orders_model->db->select('a.id')
|
||||
->from('lc_receiver_orders as a')
|
||||
->join('lc_receiver_customers as b', "a.customer_id=b.id", 'left')
|
||||
->where($where)
|
||||
->count_all_results();
|
||||
|
||||
$value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1];
|
||||
}else{
|
||||
$where = [
|
||||
'status>=' => 0,
|
||||
'p_time>=' => $o_time['s_time'],
|
||||
'p_time<=' => $o_time['e_time'],
|
||||
"biz_id in ({$biz_id_arr})" => null,
|
||||
];
|
||||
$value_1 = $this->customers_model->count(array_merge($where, ['of_id'=>$id,'of2_id' => $k]));
|
||||
$value_1 && $pie_offline[] = ['name' => $v, 'value' => $value_1];
|
||||
}
|
||||
|
||||
$bottom += $value_1;
|
||||
}
|
||||
}
|
||||
|
||||
return ['title' => $title, 'series_data' => $pie_offline, 'bottom' => "合计: {$bottom}"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,16 +333,16 @@ class User extends Wxapp
|
||||
$fq_total = $this->orders_model->count($where);
|
||||
$where = [
|
||||
'status' => 1,
|
||||
'brand_id>' => 0, 'biz_id' => $biz_id, 'status!=' => 2,
|
||||
'biz_id' => $biz_id,
|
||||
];
|
||||
$group_id == 1 && $where['sale_id'] = $uid;
|
||||
$kp_total = $this->orders_model->count($where);;
|
||||
$kp_total = $this->orders_model->count($where);
|
||||
$where = [
|
||||
'status' => 2,
|
||||
'biz_id' => $biz_id,
|
||||
];
|
||||
$group_id == 1 && $where['sale_id'] = $uid;
|
||||
$ck_total = $this->orders_model->count($where);;
|
||||
$ck_total = $this->orders_model->count($where);
|
||||
$deallist = [
|
||||
['title' => '签约下定 ', 'icon' => 'icon-banfenqi', 'total' => $fq_total, 'page' => '/pages/order/filterList/index2?type=0&title=签约下定'],
|
||||
['title' => '发票开具', 'icon' => 'icon-kaipiao1', 'total' => $kp_total, 'page' => '/pages/order/filterList/index2?type=1&title=发票开具'],
|
||||
@@ -497,11 +497,27 @@ class User extends Wxapp
|
||||
$o_where['status'] = 1;
|
||||
$bizs = $this->biz_model->select($o_where, 'id desc', '', '', $fileds);
|
||||
}
|
||||
|
||||
if ($bizs) {
|
||||
foreach ($bizs as $key => $val) {
|
||||
|
||||
$where = ['status' => 0, 'biz_id' => $val['id']];
|
||||
$fq_total = $this->orders_model->count($where);
|
||||
|
||||
$where = ['status' => 1, 'biz_id' => $val['id']];
|
||||
$kp_total = $this->orders_model->count($where);
|
||||
|
||||
$where = ['status' => 2, 'biz_id' => $val['id'],];
|
||||
$ck_total = $this->orders_model->count($where);
|
||||
|
||||
$lists[] = [
|
||||
'id' => $val['id'],
|
||||
'name' => $val['biz_name'],
|
||||
'orders' => array(
|
||||
array('name' => '签约下定 '.$fq_total, 'bg_color' => $fq_total ? '#fff' : '#999'),
|
||||
array('name' => '发票开具 '.$kp_total, 'bg_color' => $kp_total ? '#fff' : '#999'),
|
||||
array('name' => '车辆交付 '.$ck_total, 'bg_color' => $ck_total ? '#fff' : '#999'),
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class Receiver_customers_model extends HD_Model
|
||||
return $this->offlineSources($id);
|
||||
}
|
||||
|
||||
public function offlineSources($id = 0)
|
||||
public function offlineSources($id = 0, $title = 1)
|
||||
{
|
||||
$this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model');
|
||||
$arr = [];
|
||||
@@ -94,7 +94,12 @@ class Receiver_customers_model extends HD_Model
|
||||
if ($row) {
|
||||
$rows = $this->clues_cfrom_model->select(['pid' => $id], '', 0, 0, 'id,title');
|
||||
foreach ($rows as $item) {
|
||||
$lists[$item['id']] = $item['title'];
|
||||
if($title){
|
||||
$lists[$item['id']] = $item['title'];
|
||||
}else{
|
||||
$tmp = explode('-', $item['title']);
|
||||
$lists[$item['id']] = $tmp[1] ? $tmp[1] : $tmp[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
$arr['name'] = $row['title'];
|
||||
|
||||
Reference in New Issue
Block a user