order_818
This commit is contained in:
@@ -16,10 +16,159 @@ class order extends HD_Controller
|
||||
//首页信息
|
||||
public function index()
|
||||
{
|
||||
return $this->get_dashboards();
|
||||
return $this->get_dfmc();
|
||||
}
|
||||
|
||||
public function get_dashboards()
|
||||
/**
|
||||
* Notes:哪吒
|
||||
* Created on: 2022/8/17 14:19
|
||||
* Created by: dengbw
|
||||
*/
|
||||
public function get_hozonauto()
|
||||
{
|
||||
$this->load->model('biz/biz_model', 'mdBiz');
|
||||
$brand_id = 4;//品牌id
|
||||
$params = $this->input->get();
|
||||
!$params['type'] && $params['type'] = 1;
|
||||
$start_date = date('Y-m', strtotime("-2 month"));//取最近3个月
|
||||
$end_date = date('Y-m');
|
||||
if ($params['time']) {
|
||||
$time = explode(' ~ ', $params['time']);
|
||||
$time[0] && $start_date = $time[0];
|
||||
$time[1] && $end_date = $time[1];
|
||||
} else {
|
||||
$params['time'] = $start_date . ' ~ ' . $end_date;
|
||||
}
|
||||
$date_months = $this->dateMonths($start_date, $end_date);
|
||||
rsort($date_months);
|
||||
$days = [];
|
||||
foreach ($date_months as $k => $v) {
|
||||
$month = date('n', strtotime($v . '-01'));
|
||||
$days[$v] = ['month' => $month, 'num' => 0];
|
||||
}
|
||||
$bizs = [1 => ['biz_name' => '宁德哪吒品牌店', 'ids' => '70', 'rowspan' => 1], 2 => ['biz_name' => '宁德哪吒代理店', 'city_id' => '350900']
|
||||
, 3 => ['biz_name' => '厦门哪吒订单中心', 'city_id' => '350200'], 4 => ['biz_name' => '泉州哪吒代理店', 'city_id' => '350500']];
|
||||
foreach ($bizs as $k => $v) {
|
||||
$str_ids = $v['ids'] ? $v['ids'] : '';
|
||||
if (!$str_ids) {
|
||||
$res = $this->mdBiz->select(['status' => 1, 'type' => 3, 'city_id' => $v['city_id']], 'id desc', 0, 0, 'id');
|
||||
if ($res) {
|
||||
$str_ids = implode(',', array_unique(array_column($res, 'id')));
|
||||
$str_ids = $str_ids ? $str_ids : '-1';
|
||||
}
|
||||
}
|
||||
$list = [];
|
||||
foreach ($days as $k2 => $v2) {
|
||||
$order_time = $this->getTime($k2);
|
||||
$c_time = $this->getTime($k2, 1);
|
||||
if ($params['type'] == 2) {
|
||||
$num = $this->mdOrders->count(["biz_id in({$str_ids})" => null, 'brand_id' => $brand_id,
|
||||
'status>=' => 0, 'order_time>=' => $order_time['s_time'], 'order_time<=' => $order_time['e_time']]);
|
||||
} else {
|
||||
$num = $this->mdOrders->db->select('a.id')
|
||||
->from('lc_receiver_orders_v2 as a')
|
||||
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
|
||||
->where(["a.biz_id in({$str_ids})" => null, 'a.brand_id' => $brand_id, 'a.status>=' => 0, 'a.order_time>=' => $order_time['s_time']
|
||||
, 'a.order_time<=' => $order_time['e_time'], 'b.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']])
|
||||
->count_all_results();
|
||||
}
|
||||
$list[$k2] = $num;
|
||||
$days[$k2]['num'] = $v2['num'] + $num;
|
||||
}
|
||||
$v['list'] = $list;
|
||||
$v['ids'] = $str_ids;
|
||||
$bizs[$k] = $v;
|
||||
}
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$offlineSources_count = count($offlineSources);
|
||||
//过程数据
|
||||
$process_cus = $process_into = $process_ord = [];
|
||||
foreach ($bizs as $k => $v) {
|
||||
$list_cus = $cus_sum = $list_into = $ord_into = $into_sum = $list_ord = $ord_sum = [];
|
||||
foreach ($offlineSources as $k2 => $v2) {
|
||||
$stats_per_cus = $stats_cus = $stats_per_into = $stats_into = $stats_per_ord = $stats_ord = [];
|
||||
foreach ($days as $k3 => $v3) {
|
||||
$order_time = $this->getTime($k3);
|
||||
$c_time = $this->getTime($k3, 1);
|
||||
//线索数
|
||||
$num_cus = 0;
|
||||
if ($k2 != 1) {//不包括自然到店
|
||||
$num_cus = $this->mdCustomers->count(["biz_id in({$v['ids']})" => null, 'of_id' => $k2, 'status>=' => 0, 'c_time>=' => $c_time['s_time'], 'c_time<=' => $c_time['e_time']]);
|
||||
$cus_sum[$k3] += $num_cus;
|
||||
$stats_cus[] = $num_cus;
|
||||
$stats_per_cus[$k3] = $num_cus;
|
||||
}
|
||||
//进店数
|
||||
if ($params['type'] == 2) {
|
||||
$num_into = $this->mdUsersLog->db->select('a.id')
|
||||
->from('lc_receiver_customer_oplogs as a')
|
||||
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
|
||||
->where(['a.type' => 4, 'a.log' => '客户到店', 'a.c_time>=' => $c_time['s_time'], 'a.c_time<=' => $c_time['e_time'],
|
||||
'b.status>=' => 0, "b.biz_id in({$v['ids']})" => null, 'b.of_id' => $k2])
|
||||
->count_all_results();
|
||||
} else {
|
||||
$num_into = $this->mdUsersLog->db->select('a.id')
|
||||
->from('lc_receiver_customer_oplogs as a')
|
||||
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
|
||||
->where(['a.type' => 4, 'a.log' => '客户到店', 'a.c_time>=' => $c_time['s_time'], 'a.c_time<=' => $c_time['e_time'],
|
||||
'b.status>=' => 0, "b.biz_id in({$v['ids']})" => null, 'b.of_id' => $k2, 'b.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']])
|
||||
->count_all_results();
|
||||
}
|
||||
$into_sum[$k3] += $num_into;
|
||||
$stats_into[] = $num_into;
|
||||
$num_into_per = '';
|
||||
if ($k2 != 1) {//转化率=进店数/客户数
|
||||
$num_into_per = $this->getPercentage(['num' => $num_into, 'sum' => $num_cus]);
|
||||
}
|
||||
$stats_per_into[$k3] = $num_into_per;
|
||||
//成交数
|
||||
if ($params['type'] == 2) {
|
||||
$num_ord = $this->mdOrders->db->select('a.id')
|
||||
->from('lc_receiver_orders_v2 as a')
|
||||
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
|
||||
->where(["a.biz_id in({$v['ids']})" => null, 'a.brand_id' => $brand_id, 'a.status>=' => 0, 'a.order_time>=' => $order_time['s_time']
|
||||
, 'a.order_time<=' => $order_time['e_time'], 'b.of_id' => $k2])
|
||||
->count_all_results();
|
||||
} else {
|
||||
$num_ord = $this->mdOrders->db->select('a.id')
|
||||
->from('lc_receiver_orders_v2 as a')
|
||||
->join('lc_receiver_customers as b', "b.id=a.customer_id", 'left')
|
||||
->where(["a.biz_id in({$v['ids']})" => null, 'a.brand_id' => $brand_id, 'a.status>=' => 0, 'a.order_time>=' => $order_time['s_time'], 'a.order_time<=' => $order_time['e_time']
|
||||
, 'b.of_id' => $k2, 'b.c_time>=' => $c_time['s_time'], 'b.c_time<=' => $c_time['e_time']])
|
||||
->count_all_results();
|
||||
}
|
||||
$ord_sum[$k3] += $num_ord;
|
||||
$stats_ord[] = $num_ord;
|
||||
//转化率=订单数/进店数
|
||||
$stats_per_ord[$k3] = $this->getPercentage(['num' => $num_ord, 'sum' => $num_into]);
|
||||
}
|
||||
if ($k2 != 1) {//不包括自然到店
|
||||
$list_cus[] = ['name' => $v2['name'], 'stats_per' => $stats_per_cus, 'stats' => $stats_cus];
|
||||
}
|
||||
$list_into[] = ['name' => $v2['name'], 'stats_per' => $stats_per_into, 'stats' => $stats_into];
|
||||
$list_ord[] = ['name' => $v2['name'], 'stats_per' => $stats_per_ord, 'stats' => $stats_ord];
|
||||
}
|
||||
$process_cus[] = ['biz_name' => $v['biz_name'], 'num_sum' => $cus_sum, 'list' => $list_cus];
|
||||
$process_into[] = ['biz_name' => $v['biz_name'], 'num_sum' => $into_sum, 'list' => $list_into];
|
||||
$process_ord[] = ['biz_name' => $v['biz_name'], 'num_sum' => $ord_sum, 'list' => $list_ord];
|
||||
}
|
||||
$process = ['customers' => $process_cus, 'into_shop' => $process_into, 'orders' => $process_ord];
|
||||
$this->data['info'] = ['days' => $days, 'bizs' => $bizs, 'bizs_count' => count($bizs), 'days_count' => count($days)
|
||||
, 'brands_count' => 1, 'offlineSources_count' => $offlineSources_count, 'process' => $process,
|
||||
'type_ary' => [1 => '月销售模型(当月线索)', 2 => '月销售模型']];
|
||||
$this->data['params'] = $params;
|
||||
$this->data['_title'] = '哪吒';
|
||||
return $this->show_view('stats/order/hozonauto', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notes:东风品牌店群
|
||||
* Created on: 2022/8/17 14:17
|
||||
* Created by: dengbw
|
||||
* @return bool|void
|
||||
*/
|
||||
public function get_dfmc()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
!$params['type'] && $params['type'] = 1;
|
||||
@@ -35,8 +184,6 @@ class order extends HD_Controller
|
||||
$date_months = $this->dateMonths($start_date, $end_date);
|
||||
rsort($date_months);
|
||||
$days = [];
|
||||
// $days = ['2022-07' => ['month' => 7, 'num' => 0], '2022-06' => ['month' => 6, 'num' => 0],
|
||||
// '2022-05' => ['month' => 5, 'num' => 0], '2022-04' => ['month' => 4, 'num' => 0]];
|
||||
foreach ($date_months as $k => $v) {
|
||||
$month = date('n', strtotime($v . '-01'));
|
||||
$days[$v] = ['month' => $month, 'num' => 0];
|
||||
@@ -216,7 +363,7 @@ class order extends HD_Controller
|
||||
, 'customers_stats' => $customers_stats, 'process' => $process, 'type_ary' => [1 => '月销售模型(当月线索)', 2 => '月销售模型']];
|
||||
$this->data['params'] = $params;
|
||||
$this->data['_title'] = '东风品牌店群';
|
||||
return $this->show_view('stats/order/dashboards', true);
|
||||
return $this->show_view('stats/order/dfmc', true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="17" class="td-middle">线索数</td>
|
||||
<td rowspan="<?= $info['offlineSources_count'] * $info['bizs_count'] + 2 ?>" class="td-middle">线索数</td>
|
||||
<td colspan="2" rowspan="2"></td>
|
||||
<td colspan="<?= $info['days_count'] ?>">转化率</td>
|
||||
<td colspan="<?= $info['days_count'] ?>">数据</td>
|
||||
@@ -201,7 +201,7 @@
|
||||
<tr>
|
||||
<td colspan="<?= $info['days_count'] + 1 ?>">合计</td>
|
||||
<? foreach ($v['num_sum'] as $v5) { ?>
|
||||
<td><?= $v5 ?></td>
|
||||
<td><strong><?= $v5 ?></strong></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? } ?>
|
||||
@@ -229,7 +229,7 @@
|
||||
<tr>
|
||||
<td colspan="<?= $info['days_count'] + 1 ?>">合计</td>
|
||||
<? foreach ($v['num_sum'] as $v5) { ?>
|
||||
<td><?= $v5 ?></td>
|
||||
<td><strong><?= $v5 ?></strong></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? } ?>
|
||||
@@ -257,7 +257,7 @@
|
||||
<tr>
|
||||
<td colspan="<?= $info['days_count'] + 1 ?>">合计</td>
|
||||
<? foreach ($v['num_sum'] as $v5) { ?>
|
||||
<td><?= $v5 ?></td>
|
||||
<td><strong><?= $v5 ?></strong></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? } ?>
|
||||
@@ -0,0 +1,184 @@
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="/stats/order/get_hozonauto">
|
||||
<input name="type" value="<?= $params['type'] ?>" type="hidden">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">统计月份:</label>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w300">
|
||||
<input id="id-time" name="time" type="text" value="<?= $params['time'] ?>"
|
||||
placeholder="统计月份范围" autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<? foreach ($info['type_ary'] as $key => $val) { ?>
|
||||
<li role="presentation"
|
||||
class="<?= $params['type'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);"
|
||||
data-open="/stats/order/get_hozonauto?type=<?= $key ?>&time=<?= $params['time'] ?>">
|
||||
<?= $val ?>
|
||||
</a>
|
||||
</li>
|
||||
<? } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="coms-table-bd">
|
||||
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="<?= $info['days_count'] + 3 ?>" width="50%" style="text-align: left;">目标完成情况</th>
|
||||
<? foreach ($info['days'] as $v) { ?>
|
||||
<th width="10%"><?= $v['month'] ?>月完成</th>
|
||||
<? } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="<?= $info['days_count'] + 3 ?>" align="left"><strong>本期的完成情况(订单台数)</strong></td>
|
||||
<? foreach ($info['days'] as $v) { ?>
|
||||
<td><strong><?= $v['num'] ?></strong></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? foreach ($info['bizs'] as $v) { ?>
|
||||
<tr>
|
||||
<? if ($v['rowspan'] == 1) { ?>
|
||||
<td rowspan="<?= $info['bizs_count'] ?>" class="td-middle">渠道</td>
|
||||
<? } ?>
|
||||
<td colspan="<?= $info['days_count'] + 2 ?>"><?= $v['biz_name'] ?></td>
|
||||
<? foreach ($v['list'] as $v2) { ?>
|
||||
<td><?= $v2 ?></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<table class="am-table am-table-bordered" style="margin-top: 10px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="<?= $info['days_count'] * 2 + 3 ?>">过程数据</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td rowspan="<?= $info['offlineSources_count'] * $info['bizs_count'] + 2 ?>" class="td-middle">线索数</td>
|
||||
<td colspan="2" rowspan="2"></td>
|
||||
<td colspan="<?= $info['days_count'] ?>">转化率</td>
|
||||
<td colspan="<?= $info['days_count'] ?>">数据</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<? foreach ($info['days'] as $v) { ?>
|
||||
<td><?= $v['month'] ?>月</td>
|
||||
<? } ?>
|
||||
<? foreach ($info['days'] as $v) { ?>
|
||||
<td><?= $v['month'] ?>月</td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
|
||||
<? foreach ($info['process']['customers'] as $v) { ?>
|
||||
<tr>
|
||||
<td rowspan="<?= $info['offlineSources_count'] ?>" class="td-middle"><?= $v['biz_name'] ?></td>
|
||||
<? foreach ($v['list'] as $k2 => $v2) { ?>
|
||||
<?= $k2 != 0 ? '<tr>' : '' ?>
|
||||
<td align="left"><?= $v2['name'] ?></td>
|
||||
<? foreach ($v2['stats_per'] as $k3 => $v3) { ?>
|
||||
<td><strong><?= number_format_com($v3 / $v['num_sum'][$k3] * 100, 2, '') . "%" ?></strong>
|
||||
</td>
|
||||
<? } ?>
|
||||
<? foreach ($v2['stats'] as $v4) { ?>
|
||||
<td><?= $v4 ?></td>
|
||||
<? } ?>
|
||||
<?= $k2 != 0 ? '</tr>' : '' ?>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="<?= $info['days_count'] + 1 ?>">合计</td>
|
||||
<? foreach ($v['num_sum'] as $v5) { ?>
|
||||
<td><strong><?= $v5 ?></strong></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
||||
<? foreach ($info['process']['into_shop'] as $k => $v) { ?>
|
||||
<tr>
|
||||
<? if ($k == 0) { ?>
|
||||
<td rowspan="<?= ($info['offlineSources_count'] + 1) * $info['bizs_count'] ?>"
|
||||
class="td-middle">进店数
|
||||
</td>
|
||||
<? } ?>
|
||||
<td rowspan="<?= $info['offlineSources_count'] + 1 ?>" class="td-middle"><?= $v['biz_name'] ?></td>
|
||||
<? foreach ($v['list'] as $k2 => $v2) { ?>
|
||||
<?= $k2 != 0 ? '<tr>' : '' ?>
|
||||
<td align="left"><?= $v2['name'] ?></td>
|
||||
<? foreach ($v2['stats_per'] as $k3 => $v3) { ?>
|
||||
<td><strong><?= $v3 ?></strong></td>
|
||||
<? } ?>
|
||||
<? foreach ($v2['stats'] as $v4) { ?>
|
||||
<td><?= $v4 ?></td>
|
||||
<? } ?>
|
||||
<?= $k2 != 0 ? '</tr>' : '' ?>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="<?= $info['days_count'] + 1 ?>">合计</td>
|
||||
<? foreach ($v['num_sum'] as $v5) { ?>
|
||||
<td><strong><?= $v5 ?></strong></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
||||
<? foreach ($info['process']['orders'] as $k => $v) { ?>
|
||||
<tr>
|
||||
<? if ($k == 0) { ?>
|
||||
<td rowspan="<?= ($info['offlineSources_count'] + 1) * $info['bizs_count'] ?>"
|
||||
class="td-middle">成交数
|
||||
</td>
|
||||
<? } ?>
|
||||
<td rowspan="<?= $info['offlineSources_count'] + 1 ?>" class="td-middle"><?= $v['biz_name'] ?></td>
|
||||
<? foreach ($v['list'] as $k2 => $v2) { ?>
|
||||
<?= $k2 != 0 ? '<tr>' : '' ?>
|
||||
<td align="left"><?= $v2['name'] ?></td>
|
||||
<? foreach ($v2['stats_per'] as $k3 => $v3) { ?>
|
||||
<td><strong><?= $v3 ?></strong></td>
|
||||
<? } ?>
|
||||
<? foreach ($v2['stats'] as $v4) { ?>
|
||||
<td><?= $v4 ?></td>
|
||||
<? } ?>
|
||||
<?= $k2 != 0 ? '</tr>' : '' ?>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="<?= $info['days_count'] + 1 ?>">合计</td>
|
||||
<? foreach ($v['num_sum'] as $v5) { ?>
|
||||
<td><strong><?= $v5 ?></strong></td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
<? } ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require(['laydate', 'autocomplete'], function (laydate) {
|
||||
laydate.render({
|
||||
elem: '#id-time', range: '~', format: 'yyyy-MM', type: 'month',
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.td-middle {
|
||||
vertical-align: middle !important;
|
||||
}
|
||||
</style>
|
||||
@@ -569,6 +569,7 @@ class Customers extends Wxapp
|
||||
$s_visit_time = $this->input_param('s_visit_time');//回访开始时间
|
||||
$e_visit_time = $this->input_param('e_visit_time');//回访结束时间
|
||||
$status_tp = intval($this->input_param('status_tp')); //状态类型
|
||||
$admin_ids = $this->input_param('admin_ids');//多选销售人员
|
||||
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 10;
|
||||
@@ -603,7 +604,7 @@ class Customers extends Wxapp
|
||||
$where["admin_id"] = $uid;
|
||||
}
|
||||
if ($group_id == 4 && $this->biz_id != 1) {
|
||||
$where['brand_id!='] = 3; //渠道经理过滤
|
||||
$where['brand_id<>'] = 3; //渠道经理过滤
|
||||
}
|
||||
if ($s_time && $e_time) {
|
||||
$where['c_time >='] = strtotime($s_time);
|
||||
@@ -626,6 +627,9 @@ class Customers extends Wxapp
|
||||
}
|
||||
$unuse && $where['admin_id'] = 0;
|
||||
$admin_id && $where['admin_id'] = $admin_id;
|
||||
if ($admin_ids) {
|
||||
$where["admin_id in ({$admin_ids})"] = null;
|
||||
}
|
||||
$id && $where['id'] = $id;
|
||||
strlen($istop) && $where['is_top'] = $istop;
|
||||
strlen($if_driver) && $where['if_driver'] = 1;
|
||||
|
||||
Reference in New Issue
Block a user