Browse Source

区分支付方式金额

sunhao 5 years ago
parent
commit
e361279776

+ 13 - 6
app/Http/Controllers/Admin/StatisticsController.php

1784
 
1784
 
1785
         $teams = DB::table('teams')->lists('name', 'id');
1785
         $teams = DB::table('teams')->lists('name', 'id');
1786
         if($aftersale == 1){
1786
         if($aftersale == 1){
1787
-            $result = Order::select(DB::raw('left(aftersale_time, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1787
+            $result = Order::select(DB::raw('left(aftersale_time, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost, sum(if(payment_type=1,receivedAmount,null)) as wx_money'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1788
                 if($team_id) $query->where('team_id', $team_id);
1788
                 if($team_id) $query->where('team_id', $team_id);
1789
                 if($stime) $query->where('aftersale_time', '>=', $stime);
1789
                 if($stime) $query->where('aftersale_time', '>=', $stime);
1790
                 if($etime) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1790
                 if($etime) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1791
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1791
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1792
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->offset($offset)->limit($pageSize)->get();
1792
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->offset($offset)->limit($pageSize)->get();
1793
         }else{
1793
         }else{
1794
-            $result = Order::select(DB::raw('left(createTime, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1794
+            $result = Order::select(DB::raw('left(createTime, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost, sum(if(payment_type=1,receivedAmount,null)) as wx_money'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1795
                 if($team_id) $query->where('team_id', $team_id);
1795
                 if($team_id) $query->where('team_id', $team_id);
1796
                 if($stime) $query->where('createTime', '>=', $stime);
1796
                 if($stime) $query->where('createTime', '>=', $stime);
1797
                 if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
1797
                 if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
1802
         foreach($result as $k=>&$v){
1802
         foreach($result as $k=>&$v){
1803
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
1803
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
1804
             $v['true_amount'] = $v['receivedAmount'] - $v['refund_price'] - $v['aftersale_fee'];
1804
             $v['true_amount'] = $v['receivedAmount'] - $v['refund_price'] - $v['aftersale_fee'];
1805
+            $v['zfm_money'] = $v['receivedAmount'] - $v['wx_money'];
1805
         }
1806
         }
1806
 
1807
 
1807
         $teamList = DB::table('teams')->select('id', 'name')->get();
1808
         $teamList = DB::table('teams')->select('id', 'name')->get();
1869
        
1870
        
1870
         $teams = DB::table('teams')->lists('name', 'id');
1871
         $teams = DB::table('teams')->lists('name', 'id');
1871
         if($aftersale == 1){
1872
         if($aftersale == 1){
1872
-            $result = Order::select(DB::raw('left(aftersale_time, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1873
+            $result = Order::select(DB::raw('left(aftersale_time, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost, sum(if(payment_type=1,receivedAmount,null)) as wx_money'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1873
                 if($team_id) $query->where('team_id', $team_id);
1874
                 if($team_id) $query->where('team_id', $team_id);
1874
                 if($stime) $query->where('aftersale_time', '>=', $stime);
1875
                 if($stime) $query->where('aftersale_time', '>=', $stime);
1875
                 if($etime) $query->where('aftersale_time', '<=', $etime.' 23:59:59');
1876
                 if($etime) $query->where('aftersale_time', '<=', $etime.' 23:59:59');
1876
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1877
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1877
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->get();
1878
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->get();
1878
         }else{
1879
         }else{
1879
-            $result = Order::select(DB::raw('left(createTime, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1880
+            $result = Order::select(DB::raw('left(createTime, 10) as ctime, team_id, count(1) as order_count, sum(receivedAmount) as receivedAmount, sum(aftersale_fee) as aftersale_fee, sum(refund_price) as refund_price, sum(cost) as cost, sum(freight_cost) as freight_cost, sum(if(payment_type=1,receivedAmount,null)) as wx_money'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
1880
                 if($team_id) $query->where('team_id', $team_id);
1881
                 if($team_id) $query->where('team_id', $team_id);
1881
                 if($stime) $query->where('createTime', '>=', $stime);
1882
                 if($stime) $query->where('createTime', '>=', $stime);
1882
                 if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
1883
                 if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
1887
         foreach($result as $k=>&$v){
1888
         foreach($result as $k=>&$v){
1888
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
1889
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
1889
             $v['true_amount'] = $v['receivedAmount'] - $v['refund_price'] - $v['aftersale_fee'];
1890
             $v['true_amount'] = $v['receivedAmount'] - $v['refund_price'] - $v['aftersale_fee'];
1891
+            $v['zfm_money'] = $v['receivedAmount'] - $v['wx_money'];
1890
         }
1892
         }
1891
 
1893
 
1892
-        $indexKey = ['team_name','ctime','order_count','receivedAmount','aftersale_fee','refund_price','true_amount','cost','freight_cost'];
1893
-        $title = ['团队', '时间', '总单数', '成交金额', '售后', '退补差价', '实际金额', '供应商成本', '物流成本'];
1894
+        if($aftersale==0){
1895
+            $indexKey = ['team_name','ctime','order_count','receivedAmount','wx_money','zfm_money','aftersale_fee','refund_price','true_amount','cost','freight_cost'];
1896
+            $title = ['团队', '时间', '总单数', '成交金额', '微信支付金额','付款码支付金额', '售后', '退补差价', '实际金额', '供应商成本', '物流成本'];
1897
+        }else{
1898
+            $indexKey = ['team_name','ctime','order_count','receivedAmount','aftersale_fee','refund_price','true_amount','cost','freight_cost'];
1899
+            $title = ['团队', '时间', '总单数', '成交金额', '售后', '退补差价', '实际金额', '供应商成本', '物流成本'];
1900
+        }
1894
         $filename = $aftersale==0 ? 'dingdanhuizong_'.date('Y-m-d_H').'.xlsx' : 'shouhouhuizong_'.date('Y-m-d_H').'.xlsx';
1901
         $filename = $aftersale==0 ? 'dingdanhuizong_'.date('Y-m-d_H').'.xlsx' : 'shouhouhuizong_'.date('Y-m-d_H').'.xlsx';
1895
         return Order::export_excel($result, $filename, $indexKey, $title);
1902
         return Order::export_excel($result, $filename, $indexKey, $title);
1896
 
1903
 

+ 8 - 0
resources/views/statistics/teamFinanceTotal.blade.php

30
                     <th width="5%">时间</th>
30
                     <th width="5%">时间</th>
31
                     <th width="5%">总单数</th>
31
                     <th width="5%">总单数</th>
32
                     <th width="5%">成交金额</th>
32
                     <th width="5%">成交金额</th>
33
+                    @if($aftersale==0)
34
+                    <th width="5%">微信支付金额</th>
35
+                    <th width="5%">付款码支付金额</th>
36
+                    @endif
33
                     <th width="5%">售后</th>
37
                     <th width="5%">售后</th>
34
                     <th width="5%">退补差价</th>
38
                     <th width="5%">退补差价</th>
35
                     <th width="5%">实际金额</th>
39
                     <th width="5%">实际金额</th>
45
                             <td>{{$a['ctime']}}</td>
49
                             <td>{{$a['ctime']}}</td>
46
                             <td>{{$a['order_count']}}</td>
50
                             <td>{{$a['order_count']}}</td>
47
                             <td>{{$a['receivedAmount']}}</td>
51
                             <td>{{$a['receivedAmount']}}</td>
52
+                            @if($aftersale==0)
53
+                            <td>{{$a['wx_money']}}</td>
54
+                            <td>{{$a['zfm_money']}}</td>
55
+                            @endif
48
                             <td>{{$a['aftersale_fee']}}</td>
56
                             <td>{{$a['aftersale_fee']}}</td>
49
                             <td>{{$a['refund_price']}}</td>
57
                             <td>{{$a['refund_price']}}</td>
50
                             <td>{{$a['true_amount']}}</td>
58
                             <td>{{$a['true_amount']}}</td>