后台增加门店日报

This commit is contained in:
lcc
2025-01-08 08:03:32 +08:00
parent 6fbde3c97b
commit c202e34091
5 changed files with 505 additions and 137 deletions
+216 -131
View File
@@ -1,6 +1,6 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
defined('BASEPATH') or exit('No direct script access allowed');
class Report extends HD_Controller
{
@@ -9,19 +9,49 @@ class Report extends HD_Controller
parent::__construct();
$this->load->model("biz/biz_model");
$this->load->model('receiver/receiver_score_log_model');
$this->load->model('receiver/receiver_score_day_model');
$this->load->model('receiver/receiver_score_avg_day_model');
$this->load->model('app/licheb/app_licheb_users_model');
$this->load->model('receiver/receiver_customers_model');
$this->load->model('receiver/order/receiver_orders_model');
$this->load->model('receiver/order/receiver_order_datas_model');
$this->load->model("biz/biz_report_day_model");
// $this->load->model('receiver/receiver_score_log_model');
// $this->load->model('receiver/receiver_score_day_model');
// $this->load->model('receiver/receiver_score_avg_day_model');
// $this->load->model('app/licheb/app_licheb_users_model');
// $this->load->model('receiver/receiver_customers_model');
// $this->load->model('receiver/order/receiver_orders_model');
// $this->load->model('receiver/order/receiver_order_datas_model');
}
//首页信息
public function index()
{
//return $this->lists();
$params = $this->input->get();
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
$lists = array();
$where = ["status<>-1" => null];
if ($params['day']) {
$where['day'] = $params['day'];
}
if ($params['biz_id']) {
$where['biz_id'] = $params['biz_id'];
}
$count = $this->biz_report_day_model->count($where);
$biz_where = ['status' => 1, 'type' => 0, 'province_id' => 350000];
$biz_lists = $this->biz_model->select($biz_where, '', 0, 0, 'id,biz_name');
$map_biz_lists = array_column($biz_lists, null, 'id');
if ($count) {
$res = $this->biz_report_day_model->select($where, "id desc", $params['page'], $params['size']);
foreach ($res as $value) {
$setValue = $value;
$biz = $map_biz_lists[$value['biz_id']];
$setValue['biz_name'] = $biz['biz_name'];
$lists[] = $setValue;
}
}
//获取所有
$this->data['biz_lists'] = $biz_lists;
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['_title'] = '门店日报';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
return $this->show_view('receiver/report/lists', true);
}
@@ -44,24 +74,26 @@ class Report extends HD_Controller
}
//编辑单条数据
public function edit(){
public function edit()
{
}
//删除单条数据
public function del(){
public function del()
{
}
//批量操作(默认修改状态)
public function batch(){
public function batch()
{
}
//导出数据列表
public function export()
{
$day = $this->input->get('day');
$params = $this->input->get();
$day = $params['day'];
!$day && $day = date('Y-m-d', strtotime('yesterday'));
$month = date('m', strtotime($day));
$indexs = [
'biz_name' => '车卖场',
@@ -88,124 +120,177 @@ class Report extends HD_Controller
"order_finish" => "本月订单信息完整数",
'score_month' => '本月运营分',
];
$where = array(
'status' => 1,
'type' => 0,
'province_id' => 350000
);
$bizs = $this->biz_model->select($where, '', 0, 0, 'id, biz_name');
if($bizs){
foreach ($bizs as $v){
//开工率
$sales = $this->app_licheb_users_model->count(array('group_id in (1,2)' => null, 'biz_id' => $v['id'], 'status' => 1));
$works = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 0, 'sub_type' => 0, 'score >' => 0));
//今日新增线索数
$cust_new = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'DATE(p_time)' => $day));
//本月线索总数
$cust_month = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'MONTH(p_time)' => $month));
//今日新增跟进数
$cust_visit = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0));
//本月跟进客户数
$cust_visit_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//今日订单新增数
$order_new = $this->receiver_orders_model->count(array('DATE(order_time)' => $day, 'biz_id' => $v['id'], 'status >=' => 0));
//本月订单总数
$order_month = $this->receiver_orders_model->select(array('MONTH(order_time)' => $month, 'biz_id' => $v['id'], 'status >=' => 0), '', 0, 0, 'id');
//本月订单信息完整数
if($order_month){
$oids = implode(',', array_unique(array_column($order_month, 'id')));
$where = array(
"o_id in ({$oids})" => null,
"((cardida != '' AND cardidb != '') OR (business_licence != ''))" => null,
"pay_img <>" => '',
"contract_img <>" => '',
"bill_img <>" => '',
"car_img <>" => '',
"insurance_img <>" => '',
"business_img <>" => '',
);
$order_finish = $this->receiver_order_datas_model->count($where);
}else{
$order_finish = 0;
}
//今日线索逾期数
$cust_delay = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0));
//本月线索逾期数
$cust_delay_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0));
//今日订单未达T+1
$order_wrong = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//本月订单未达T+1
$order_wrong_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//今日开票早与订单时间数
$order_early = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 1, 'target_id >' => 0), 'target_id');
//今日未及时分配数
$cust_push = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id');
//本月未及时分配数
$cust_push_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id');
//今日战败申请未处理数
$cust_defeat = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id');
//本月战败申请未处理数
$cust_defeat_moth = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id');
//本月交付总数
$order_over = $this->receiver_orders_model->count(array('MONTH(over_time)' => $month, 'biz_id' => $v['id'], 'status >' => 0));
//今日运营分
$score = $this->receiver_score_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1));
//本月运营分
$score_month = $this->receiver_score_avg_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'uid' => 0));
$data[] = array(
'biz_name' => $v['biz_name'],
'sales' => $sales,
'work_per' => number_format($works/$sales, 2) * 100 .'%',
'cust_new' => $cust_new,
'cust_push' => $cust_push,
'cust_visit' => $cust_visit,
'cust_delay' => $cust_delay,
'cust_defeat' => $cust_defeat,
'order_new' => $order_new,
'order_wrong' => $order_wrong,
'order_early' => $order_early,
'score' => round($score['score']),
'cust_month' => $cust_month,
'cust_push_month' => $cust_push_month,
'cust_visit_month' => $cust_visit_month,
'cust_delay_month' => $cust_delay_month,
'cust_defeat_month' => $cust_defeat_moth,
'order_month' => count($order_month),
'order_wrong_month' => $order_wrong_month,
'order_over' => $order_over,
'order_finish' => $order_finish,
'score_month' => round($score_month['score']),
);
}
$lists = [];
$where = ["status<>-1" => null];
if ($params['day']) {
$where['day'] = $params['day'];
}
if ($params['biz_id']) {
$where['biz_id'] = $params['biz_id'];
}
$res = $this->biz_report_day_model->select($where, "id desc", $params['page'], $params['size']);
$map_biz_lists = $this->biz_model->get_map_by_ids(array_column($res, 'biz_id'), 'id,biz_name');
foreach ($res as $value) {
$setValue = $value;
$biz = $map_biz_lists[$value['biz_id']][0];
$setValue['biz_name'] = $biz['biz_name'];
$lists[] = $setValue;
}
$fileName = '车卖场日报';
array_unshift($data, $indexs);
array_unshift($lists, $indexs);
$this->load->library('excel');
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
$this->excel->out_csv($lists, $indexs, $fileName . "_" . date('YmdHis'));
}
//导出数据列表
// public function export()
// {
// $day = $this->input->get('day');
// !$day && $day = date('Y-m-d', strtotime('yesterday'));
// $month = date('m', strtotime($day));
//
// $indexs = [
// 'biz_name' => '车卖场',
// 'sales' => '顾问数(含店长)',
// 'work_per' => '今日开工率',
// 'cust_new' => '今日新增线索数',
// "cust_push" => "今日未及时分配数",
// 'cust_visit' => '今日新增跟进数',
// "cust_delay" => "今日线索逾期数",
// "cust_defeat" => "今日战败申请未处理数",
// 'order_new' => '今日订单新增数',
// "order_wrong" => "今日订单未达T+1",
// "order_early" => "今日开票早与订单时间数",
// 'score' => '今日运营分',
//
// 'cust_month' => '本月线索总数',
// "cust_push_month" => "本月未及时分配总数",
// 'cust_visit_month' => '本月跟进客户数',
// "cust_delay_month" => "本月线索逾期数",
// "cust_defeat_month" => "本月战败申请未处理数",
// 'order_month' => '本月订单总数',
// "order_wrong_month" => "本月订单未达T+1",
// 'order_over' => "本月交付总数",
// "order_finish" => "本月订单信息完整数",
// 'score_month' => '本月运营分',
// ];
//
// $where = array(
// 'status' => 1,
// 'type' => 0,
// 'province_id' => 350000
// );
// $bizs = $this->biz_model->select($where, '', 0, 0, 'id, biz_name');
// if($bizs){
// foreach ($bizs as $v){
// //开工率
// $sales = $this->app_licheb_users_model->count(array('group_id in (1,2)' => null, 'biz_id' => $v['id'], 'status' => 1));
// $works = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 0, 'sub_type' => 0, 'score >' => 0));
//
// //今日新增线索数
// $cust_new = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'DATE(p_time)' => $day));
//
// //本月线索总数
// $cust_month = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'MONTH(p_time)' => $month));
//
// //今日新增跟进数
// $cust_visit = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0));
//
// //本月跟进客户数
// $cust_visit_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//
// //今日订单新增数
// $order_new = $this->receiver_orders_model->count(array('DATE(order_time)' => $day, 'biz_id' => $v['id'], 'status >=' => 0));
//
// //本月订单总数
// $order_month = $this->receiver_orders_model->select(array('MONTH(order_time)' => $month, 'biz_id' => $v['id'], 'status >=' => 0), '', 0, 0, 'id');
//
//
// //本月订单信息完整数
// if($order_month){
// $oids = implode(',', array_unique(array_column($order_month, 'id')));
//
// $where = array(
// "o_id in ({$oids})" => null,
// "((cardida != '' AND cardidb != '') OR (business_licence != ''))" => null,
// "pay_img <>" => '',
// "contract_img <>" => '',
// "bill_img <>" => '',
// "car_img <>" => '',
// "insurance_img <>" => '',
// "business_img <>" => '',
// );
// $order_finish = $this->receiver_order_datas_model->count($where);
// }else{
// $order_finish = 0;
// }
//
// //今日线索逾期数
// $cust_delay = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0));
//
// //本月线索逾期数
// $cust_delay_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0));
//
// //今日订单未达T+1
// $order_wrong = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//
// //本月订单未达T+1
// $order_wrong_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//
// //今日开票早与订单时间数
// $order_early = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 1, 'target_id >' => 0), 'target_id');
//
// //今日未及时分配数
// $cust_push = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id');
//
// //本月未及时分配数
// $cust_push_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id');
//
// //今日战败申请未处理数
// $cust_defeat = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id');
//
// //本月战败申请未处理数
// $cust_defeat_moth = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id');
//
// //本月交付总数
// $order_over = $this->receiver_orders_model->count(array('MONTH(over_time)' => $month, 'biz_id' => $v['id'], 'status >' => 0));
//
// //今日运营分
// $score = $this->receiver_score_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1));
//
// //本月运营分
// $score_month = $this->receiver_score_avg_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'uid' => 0));
//
// $data[] = array(
// 'biz_name' => $v['biz_name'],
// 'sales' => $sales,
// 'work_per' => number_format($works/$sales, 2) * 100 .'%',
// 'cust_new' => $cust_new,
// 'cust_push' => $cust_push,
// 'cust_visit' => $cust_visit,
// 'cust_delay' => $cust_delay,
// 'cust_defeat' => $cust_defeat,
// 'order_new' => $order_new,
// 'order_wrong' => $order_wrong,
// 'order_early' => $order_early,
// 'score' => round($score['score']),
//
// 'cust_month' => $cust_month,
// 'cust_push_month' => $cust_push_month,
// 'cust_visit_month' => $cust_visit_month,
// 'cust_delay_month' => $cust_delay_month,
// 'cust_defeat_month' => $cust_defeat_moth,
// 'order_month' => count($order_month),
// 'order_wrong_month' => $order_wrong_month,
// 'order_over' => $order_over,
// 'order_finish' => $order_finish,
// 'score_month' => round($score_month['score']),
// );
// }
// }
//
// $fileName = '车卖场日报';
// array_unshift($data, $indexs);
// $this->load->library('excel');
// $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
// }
}
+98 -6
View File
@@ -1,12 +1,25 @@
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;margin-bottom: 20px;">
</div>
<div class="coms-table-wrap mt10">
<div class="coms-table-wrap mt10" id="vue-app">
<form class="form-search coms-table-hd clearfix no-border" onsubmit="return false" action="/receiver/report">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w100">门店:</label>
<div class="am-form-group fl">
<div class="am-para-inline">
<select class="selectpicker" name="biz_id" data-live-search="true">
<option value="0">所有品牌</option>
<? foreach ($biz_lists as $item) { ?>
<option value="<?= $item['id'] ?>" <?= $item['id'] == $params['biz_id'] ? 'selected' : '' ?>><?= $item['biz_name'] ?></option>
<? } ?>
</select>
</div>
</div>
</div>
<div class="am-form-group fl" style="margin-bottom: 0px;">
<label class="am-para-label w100">日期:</label>
<div class="am-form-group fl">
<div class="am-para-inline w100">
<div class="am-para-inline">
<input id="id-day" name="day" type="text" value="<?= $params['day'] ?>"
placeholder="选择日期" autocomplete="off"/>
</div>
@@ -14,6 +27,10 @@
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday">昨日</a>
</div>
</div>
<div class="am-form-group fl ml10">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索
</button>
</div>
<div class="am-form-group fl ml10">
<button type="button" onclick="export_out()" class="am-btn am-btn-success am-btn-sm w100">导出
</button>
@@ -21,24 +38,99 @@
</div>
</div>
</form>
<div class="coms-table-bd" id="vue-show">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="10%"><span>车卖场</span></th>
<th><span>日期</span></th>
<th><span>顾问数(含店长)</span></th>
<th><span>今日开工率</span></th>
<th><span>今日新增线索数</span></th>
<th><span>今日未及时分配数</span></th>
<th><span>今日新增跟进数</span></th>
<th><span>今日线索逾期数</span></th>
<th><span>今日战败申请未处理数</span></th>
<th><span>今日订单新增数</span></th>
<th><span>今日订单未达T+1</span></th>
<th><span>今日开票早与订单时间数</span></th>
<th><span>今日运营分</span></th>
<!--
// 'cust_month' => '本月线索总数',
// "cust_push_month" => "本月未及时分配总数",
// 'cust_visit_month' => '本月跟进客户数',
// "cust_delay_month" => "本月线索逾期数",
// "cust_defeat_month" => "本月战败申请未处理数",
// 'order_month' => '本月订单总数',
// "order_wrong_month" => "本月订单未达T+1",
// 'order_over' => "本月交付总数",
// "order_finish" => "本月订单信息完整数",
// 'score_month' => '本月运营分',-->
</tr>
</thead>
<tbody>
<?php if ($lists) {
foreach ($lists as $v) { ?>
<tr>
<td><?= $v['biz_name'] ?></td>
<td><?= $v['day'] ?></td>
<td><?= $v['sales'] ?></td>
<td><?= intval($v['work_per']) ?>%</td>
<td><?= $v['cust_new'] ?></td>
<td><?= $v['cust_push'] ?></td>
<td><?= $v['cust_visit'] ?></td>
<td><?= $v['cust_delay'] ?></td>
<td><?= $v['cust_defeat'] ?></td>
<td><?= $v['order_new'] ?></td>
<td><?= $v['order_wrong'] ?></td>
<td><?= $v['order_early'] ?></td>
<td><?= $v['score'] ?></td>
</tr>
<?php }
} ?>
</tbody>
</table>
</div>
<div class="coms-table-ft clearfix">
<div class="hander am-form">
</div>
<div class="coms-pagination fr mr20">
<?php page_view($pager) ?>
</div>
</div>
</div>
<script>
require(['laydate', 'autocomplete'], function (laydate) {
var vue_obj;
$(function () {
vue_obj = new Vue({
el: '#vue-app',
data: {
optionsList: [],
},
mounted: function () {
},
methods: {},
watch: {}
});
<?php page_script($pager) ?>
});
require(['laydate', 'bootstrap-select'], function (laydate) {
laydate.render({
elem: '#id-day'
});
$('.id-day-btn').click(function () {
var type = $(this).data('date'), date = '', nowDate = new Date();
var date = (new Date(nowDate.getTime() - 86400000)).Format('yyyy-MM-dd');
$('#id-day').val(date);
});
$('.selectpicker').selectpicker();
});
function export_out () {
function export_out() {
var href = $.menu.parseUri(window.location.href);
var day = $('#id-day').val();
href = href.replace("report?", "report/export?day=" + day+ "&");
href = href.replace("report?", "report/export?day=" + day + "&");
window.location.href = href;
}
</script>
+2
View File
@@ -38,6 +38,8 @@ class Plan extends CI_Controller
$plan[] = array('url' => base_url(array('plan', 'score', 'mergeAvgUser')), 'interval' => 1); //合并本月个人分数日志
$plan[] = array('url' => base_url(array('plan', 'score', 'mergeAvgBiz')), 'interval' => 1); //合并本月门店分数日志
$plan[] = array('url' => base_url(array('plan', 'report', 'index')), 'interval' => 20); //门店日报
$this->plan = $plan;
}
+176
View File
@@ -0,0 +1,176 @@
<?php
/**
* 报表数据
*/
class Report extends HD_Controller
{
private $log_dir = 'biz_report';
public function __construct()
{
parent::__construct();
$this->load->model("biz/biz_model");
$this->load->model("biz/biz_report_day_model");
$this->load->model('receiver/receiver_score_log_model');
$this->load->model('receiver/receiver_score_day_model');
$this->load->model('receiver/receiver_score_avg_day_model');
$this->load->model('app/licheb/app_licheb_users_model');
$this->load->model('receiver/receiver_customers_model');
$this->load->model('receiver/order/receiver_orders_model');
$this->load->model('receiver/order/receiver_order_datas_model');
}
//报表统计
public function index()
{
$day = $this->input->get('day');
!$day && $day = date('Y-m-d', strtotime('yesterday'));
$month = date('m', strtotime($day));
$getPage = $this->input->get('page');
$size = $this->input->get('size');
$t_limit = $this->input->get('time_limit');
$h = date('H');
if (!$t_limit && $h > 5) {
echo '当前时间段不可执行';
exit;
}
$redis = &load_cache('redis');
$pageCacheKey = "BIZ_REPORT_DAY";
if ($getPage) {
$page = $getPage;
} else {
$page = $redis->get($pageCacheKey) ?: 1;
}
!$size && $size = 20;
$where = array(
'status' => 1,
'type' => 0,
'province_id' => 350000
);
$bizs = $this->biz_model->select($where, '', $page, $size, 'id, biz_name');
if ($bizs) {
foreach ($bizs as $v) {
//开工率
$sales = $this->app_licheb_users_model->count(array('group_id in (1,2)' => null, 'biz_id' => $v['id'], 'status' => 1));
$works = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 0, 'sub_type' => 0, 'score >' => 0));
//今日新增线索数
$cust_new = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'DATE(p_time)' => $day));
//本月线索总数
$cust_month = $this->receiver_customers_model->count(array('biz_id' => $v['id'], 'MONTH(p_time)' => $month));
//今日新增跟进数
$cust_visit = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0));
//本月跟进客户数
$cust_visit_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 1, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//今日订单新增数
$order_new = $this->receiver_orders_model->count(array('DATE(order_time)' => $day, 'biz_id' => $v['id'], 'status >=' => 0));
//本月订单总数
$order_month = $this->receiver_orders_model->select(array('MONTH(order_time)' => $month, 'biz_id' => $v['id'], 'status >=' => 0), '', 0, 0, 'id');
//本月订单信息完整数
if ($order_month) {
$oids = implode(',', array_unique(array_column($order_month, 'id')));
$where = array(
"o_id in ({$oids})" => null,
"((cardida != '' AND cardidb != '') OR (business_licence != ''))" => null,
"pay_img <>" => '',
"contract_img <>" => '',
"bill_img <>" => '',
"car_img <>" => '',
"insurance_img <>" => '',
"business_img <>" => '',
);
$order_finish = $this->receiver_order_datas_model->count($where);
} else {
$order_finish = 0;
}
//今日线索逾期数
$cust_delay = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0));
//本月线索逾期数
$cust_delay_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 3, 'target_id >' => 0));
//今日订单未达T+1
$order_wrong = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//本月订单未达T+1
$order_wrong_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 2, 'target_id >' => 0), 'target_id');
//今日开票早与订单时间数
$order_early = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 1, 'target_id >' => 0), 'target_id');
//今日未及时分配数
$cust_push = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id');
//本月未及时分配数
$cust_push_month = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 4, 'target_id >' => 0), 'target_id');
//今日战败申请未处理数
$cust_defeat = $this->receiver_score_log_model->count(array('day' => $day, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id');
//本月战败申请未处理数
$cust_defeat_moth = $this->receiver_score_log_model->count(array('MONTH(day)' => $month, 'biz_id' => $v['id'], 'type' => 3, 'sub_type' => 5, 'target_id >' => 0), 'target_id');
//本月交付总数
$order_over = $this->receiver_orders_model->count(array('MONTH(over_time)' => $month, 'biz_id' => $v['id'], 'status >' => 0));
//今日运营分
$score = $this->receiver_score_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'type' => 1));
//本月运营分
$score_month = $this->receiver_score_avg_day_model->get(array('day' => $day, 'biz_id' => $v['id'], 'uid' => 0));
$data = [
'sales' => $sales,
'work_per' => number_format($works / $sales, 2) * 100,
'cust_new' => $cust_new,
'cust_push' => $cust_push,
'cust_visit' => $cust_visit,
'cust_delay' => $cust_delay,
'cust_defeat' => $cust_defeat,
'order_new' => $order_new,
'order_wrong' => $order_wrong,
'order_early' => $order_early,
'score' => round($score['score']),
'cust_month' => $cust_month,
'cust_push_month' => $cust_push_month,
'cust_visit_month' => $cust_visit_month,
'cust_delay_month' => $cust_delay_month,
'cust_defeat_month' => $cust_defeat_moth,
'order_month' => count($order_month),
'order_wrong_month' => $order_wrong_month,
'order_over' => $order_over,
'order_finish' => $order_finish,
'score_month' => round($score_month['score']),
'day' => $day,
];
$row = $this->biz_report_day_model->get(['biz_id' => $v['id'], 'day' => $day]);
if ($row) {
$this->biz_report_day_model->update($data, ['id' => $row['id']]);
} else {
$data['biz_id'] = $v['id'];
$data['c_time'] = time();
$this->biz_report_day_model->add($data);
}
}
debug_log("[info]# 当前执行页数" . $page, __FUNCTION__, $this->log_dir);
$page++;
$redis->save($pageCacheKey, $page, 60 * 60);
} else {
$msg = '执行完成';
echo $msg;
debug_log("[info]# " . $msg, __FUNCTION__, $this->log_dir);
}
}
}
@@ -0,0 +1,13 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Biz_report_day_model extends HD_Model
{
private $table_name = 'lc_biz_report_day';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}