修复项目任务列表新建时间戳
修复区域销售品类报表错误
This commit is contained in:
@@ -13,7 +13,6 @@ use Gdoo\Index\Controllers\DefaultController;
|
||||
class ReportController extends DefaultController
|
||||
{
|
||||
public $permission = [
|
||||
'citydata',
|
||||
'clientdata'
|
||||
];
|
||||
|
||||
@@ -1060,84 +1059,6 @@ class ReportController extends DefaultController
|
||||
));
|
||||
}
|
||||
|
||||
// 单区域数据分析
|
||||
public function citydata()
|
||||
{
|
||||
// 获得销售员登录名
|
||||
$year = Request::get('year');
|
||||
$circle_id = Request::get('circle_id');
|
||||
|
||||
$rows = $model = DB::table('order_data as i')
|
||||
->leftJoin('order_type as t', 't.id', '=', 'i.type')
|
||||
->leftJoin('order as o', 'o.id', '=', 'i.order_id')
|
||||
->leftJoin('user as c', 'c.id', '=', 'o.client_id')
|
||||
->leftJoin('client', 'client.user_id', '=', 'c.id')
|
||||
->leftJoin('region as r', 'r.id', '=', 'c.city_id')
|
||||
->leftJoin('product as p', 'p.id', '=', 'i.product_id')
|
||||
->where('i.deleted', 0)
|
||||
->where('o.pay_time', '>', 0)
|
||||
->where('client.circle_id', $circle_id)
|
||||
->whereRaw('FROM_UNIXTIME(o.pay_time,"%Y")=?', [$year])
|
||||
->where('t.type', 1)
|
||||
->groupBy('p.category_id')
|
||||
->groupBy('o.client_id')
|
||||
//->groupBy('r.id')
|
||||
->groupBy('month')
|
||||
->orderBy('month', 'ASC')
|
||||
->selectRaw('c.city_id,client.circle_id,o.client_id,c.nickname company_name,r.name city_name,c.salesman_id,p.category_id,i.product_id,SUM(i.fact_amount * i.price) money,FROM_UNIXTIME(o.pay_time,"%Y") year,FROM_UNIXTIME(o.pay_time,"%c") month');
|
||||
$rows = $model->get();
|
||||
|
||||
if ($rows->count()) {
|
||||
$single = array();
|
||||
foreach ($rows as $v) {
|
||||
if ($v['circle_id'] > 0) {
|
||||
//循环产品
|
||||
$single['money'][$v['month']][$v['category_en']] += $v['money'];
|
||||
$single['cat'][$v['month']] += $v['money'];
|
||||
$single['category'][$v['category_en']] = $v['category'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//促销计算
|
||||
$_promotions = DB::table('promotion as p')
|
||||
->leftJoin('user as c', 'c.id', '=', 'p.customer_id')
|
||||
->leftJoin('client', 'client.user_id', '=', 'c.id')
|
||||
->leftJoin('region as r', 'r.id', '=', 'c.city_id')
|
||||
->where('p.deleted_by', 0)
|
||||
->where('client.circle_id', $circle_id)
|
||||
->whereRaw("DATE_FORMAT(p.data_30, '%Y')=?", [$year])
|
||||
->groupBy('p.customer_id')
|
||||
//->groupBy('r.id')
|
||||
->groupBy('month')
|
||||
->selectRaw('r.id,c.salesman_id,client.circle_id,p.customer_id, DATE_FORMAT(p.end_at, "%c") as month, SUM(p.data_amount) as bd_sum, p.type_id')
|
||||
->get();
|
||||
|
||||
if ($_promotions->count()) {
|
||||
foreach ($_promotions as $v) {
|
||||
if ($v['circle_id']) {
|
||||
//促销分类金额
|
||||
$promotions['month'][$v['month']][$v['type_id']] += $v['bd_sum'];
|
||||
$promotions['month1'][$v['month']] += $v['bd_sum'];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($_promotions);
|
||||
|
||||
$circle = DB::table('customer_circle')->where('id', $circle_id)->first();
|
||||
|
||||
return $this->display(array(
|
||||
'single' => $single,
|
||||
'year' => $year,
|
||||
'categorys' => $categorys,
|
||||
'promotions'=> $promotions,
|
||||
'select' => $selects,
|
||||
'query' => $query,
|
||||
'assess' => $assess,
|
||||
'circle' => $circle,
|
||||
));
|
||||
}
|
||||
|
||||
// 单品客户数据分析
|
||||
public function client()
|
||||
{
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
<a class="btn btn-default btn-sm" onclick="LocalTableExport('report_export', '地区品类销售');"><i class="fa fa-mail-forward"></i> 导出</a>
|
||||
</div>
|
||||
|
||||
@if(Auth::user()->role->code != 'c001')
|
||||
@include('report/select')
|
||||
@endif
|
||||
@include('report/select')
|
||||
|
||||
<button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i> 筛选</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -17,51 +16,68 @@
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered" id="report_export">
|
||||
<tr>
|
||||
<th style="white-space:nowrap">
|
||||
销售组
|
||||
</th>
|
||||
|
||||
@foreach($categorys as $k => $v)
|
||||
@if($v['parent_id'] == 226)
|
||||
<th nowrap="true">{{$v['name']}}</th>
|
||||
@endif
|
||||
@endforeach
|
||||
<th style="white-space:nowrap">销售区域</th>
|
||||
|
||||
<th style="white-space:nowrap"></th>
|
||||
|
||||
@if(count($categorys))
|
||||
@foreach($categorys as $k => $v)
|
||||
@if($v['parent_id'] == 226)
|
||||
<th nowrap="nowrap">{{$v['name']}}</th>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
<th>总销售额</th>
|
||||
<th>促销费比</th>
|
||||
<th>促销金额</th>
|
||||
<!--
|
||||
<th>消费促销</th>
|
||||
<th>渠道促销</th>
|
||||
<th>经销促销</th>
|
||||
-->
|
||||
</tr>
|
||||
|
||||
@if(count($now_year_single['money']))
|
||||
@foreach($now_year_single['money'] as $key => $value)
|
||||
|
||||
<tr>
|
||||
|
||||
<td rowspan="3" align="center" style="white-space:nowrap;vertical-align:middle;">
|
||||
{{$regions[$key]}}
|
||||
<a class="option" href="{{url('citydata')}}?circle_id={{$key}}&year={{$now_year}}">
|
||||
[月销]
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td align="center" style="vertical-align:middle;color:#999;">销售金额(元)</td>
|
||||
|
||||
@if(count($categorys))
|
||||
@foreach($categorys as $k => $v)
|
||||
@if($v['parent_id'] == 226)
|
||||
<td align="right">
|
||||
{{(int)$value[$k]}}
|
||||
{{number_format($value[$k], 2)}}
|
||||
</td>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
<td style="vertical-align:middle;" align="right">{{$now_year_single['totalcost'][$key]}}</td>
|
||||
<td style="vertical-align:middle;" align="right">
|
||||
{{number_format($now_year_single['totalcost'][$key], 2)}}
|
||||
</td>
|
||||
|
||||
<td rowspan="3" style="vertical-align:middle;" align="center">
|
||||
@if($promotions['all'][$key])
|
||||
{{:$c = ($promotions['all'][$key]/$now_year_single['totalcost'][$key])}}
|
||||
{{number_format($c*100, 2)}}%
|
||||
{{number_format($c * 100, 2)}}%
|
||||
@else
|
||||
0.00%
|
||||
@endif
|
||||
</td>
|
||||
|
||||
<td rowspan="3" style="vertical-align:middle;" align="right">
|
||||
{{$promotions['all'][$key] > 0 ? $promotions['all'][$key] : 0}}
|
||||
</td>
|
||||
|
||||
<!--
|
||||
{{:$ps = $promotions[$key]}}
|
||||
<td rowspan="3" style="vertical-align:middle;" align="right">
|
||||
{{$ps[1] > 0 ? $ps[1] : 0}}
|
||||
@@ -72,24 +88,30 @@
|
||||
<td rowspan="3" style="vertical-align:middle;" align="right">
|
||||
{{$ps[3] > 0 ? $ps[3] : 0}}
|
||||
</td>
|
||||
-->
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
@foreach($categorys as $category_id => $category)
|
||||
@if($category['parent_id'] == 226)
|
||||
<td align="right" title="去年同期增长率" nowrap="true">
|
||||
<?php $scale = $oldscale[$key][$category_id]; ?>
|
||||
@if($scale == 0)
|
||||
去年无
|
||||
@elseif($scale > 0)
|
||||
<span style="color:green">{{number_format($scale * 100, 2)}}%</span>
|
||||
@else
|
||||
<span style="color:red">{{number_format($scale * 100, 2)}}%</span>
|
||||
<td align="center" style="vertical-align:middle;color:#999;">去年同期增长率</td>
|
||||
|
||||
@if(count($categorys))
|
||||
@foreach($categorys as $category_id => $category)
|
||||
@if($category['parent_id'] == 226)
|
||||
<td align="right" title="去年同期增长率" nowrap="nowrap">
|
||||
<?php $scale = $oldscale[$key][$category_id]; ?>
|
||||
@if($scale == 0)
|
||||
去年无
|
||||
@elseif($scale > 0)
|
||||
<span style="color:green">{{number_format($scale * 100, 2)}}%</span>
|
||||
@else
|
||||
<span style="color:red">{{number_format($scale * 100, 2)}}%</span>
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
@endforeach
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
<?php
|
||||
$_year = $now_year_single['totalcost'][$key] - $old_year_single['totalcost'][$key];
|
||||
@@ -110,22 +132,24 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<td align="center" style="vertical-align:middle;color:#999;">占区域该品类百分比</td>
|
||||
@if(count($categorys))
|
||||
@foreach($categorys as $k => $v)
|
||||
@if($v['parent_id'] == 226)
|
||||
<td align="right" title="占区域该品类百分比">
|
||||
@if($value[$v['id']] > 0)
|
||||
{{number_format(($value[$v['id']] / $now_year_single['cat'][$v['id']]) * 100, 2)}}%
|
||||
{{number_format(($value[$v['id']] / $now_year_single[cat][$v['id']]) * 100, 2)}}%
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
<td style="vertical-align:middle;" align="right"></td>
|
||||
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
<div class="panel">
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td><div class='title'>{{$year}}年 ({{$circle['name']}}) 客户圈月份销售分析</div></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<th>月份</th>
|
||||
|
||||
@if(count($categorys)) @foreach($categorys as $k => $v)
|
||||
<th>{{$k}}</th>
|
||||
@endforeach @endif
|
||||
|
||||
<th>总销售额</th>
|
||||
<th>促销费比</th>
|
||||
|
||||
<th>消费促销</th>
|
||||
<th>渠道促销</th>
|
||||
<th>经销促销</th>
|
||||
|
||||
@if(count($single['money'])) @foreach($single['money'] as $key => $value)
|
||||
<tr>
|
||||
<td rowspan="2" width="40" align="center" style="vertical-align:middle;color:#66CC00;font-weight:bold;background:#FFFFE9">{{$key}}月</td>
|
||||
|
||||
@if(count($categorys)) @foreach($categorys as $k => $v)
|
||||
<td align="right">
|
||||
{{$value[$v] > 0 ? $value[$v] : 0}}
|
||||
</td>
|
||||
@endforeach @endif
|
||||
|
||||
|
||||
<td rowspan="2" align="right" style="vertical-align:middle;color:#666;background:#FFFFE9">{{$single['cat'][$key]}}</td>
|
||||
|
||||
<td rowspan="2" style="vertical-align:middle;" align="right">
|
||||
@if($single['cat'][$key])
|
||||
{{:$c = ($promotions['month1'][$key]/$single['cat'][$key])}}
|
||||
{{number_format($c*100, 2)}}%
|
||||
@else
|
||||
0.00%
|
||||
@endif
|
||||
</td>
|
||||
|
||||
|
||||
{{:$promotion = $promotions['month'][$key]}}
|
||||
<td rowspan="2" style="vertical-align:middle;" align="right">
|
||||
{{$promotion[1] > 0 ? $promotion[1] : 0}}
|
||||
</td>
|
||||
<td rowspan="2" style="vertical-align:middle;" align="right">
|
||||
{{$promotion[2] > 0 ? $promotion[2] : 0}}
|
||||
</td>
|
||||
<td rowspan="2" style="vertical-align:middle;" align="right">
|
||||
{{$promotion[3] > 0 ? $promotion[3] : 0}}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@if(count($categorys)) @foreach($categorys as $k => $v)
|
||||
<td align="right">
|
||||
{{:$pl = $value[$v]/$single['cat'][$key]}}
|
||||
{{$_pl = number_format($pl*100, 2)}}%
|
||||
</td>
|
||||
@endforeach @endif
|
||||
</tr>
|
||||
|
||||
@endforeach @endif
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user