Browse Source

区分支付方式金额

sunhao 5 years ago
parent
commit
e361279776

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

@@ -1784,14 +1784,14 @@ class StatisticsController extends Controller
1784 1784
 
1785 1785
         $teams = DB::table('teams')->lists('name', 'id');
1786 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 1788
                 if($team_id) $query->where('team_id', $team_id);
1789 1789
                 if($stime) $query->where('aftersale_time', '>=', $stime);
1790 1790
                 if($etime) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1791 1791
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1792 1792
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->offset($offset)->limit($pageSize)->get();
1793 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 1795
                 if($team_id) $query->where('team_id', $team_id);
1796 1796
                 if($stime) $query->where('createTime', '>=', $stime);
1797 1797
                 if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
@@ -1802,6 +1802,7 @@ class StatisticsController extends Controller
1802 1802
         foreach($result as $k=>&$v){
1803 1803
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
1804 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 1808
         $teamList = DB::table('teams')->select('id', 'name')->get();
@@ -1869,14 +1870,14 @@ class StatisticsController extends Controller
1869 1870
        
1870 1871
         $teams = DB::table('teams')->lists('name', 'id');
1871 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 1874
                 if($team_id) $query->where('team_id', $team_id);
1874 1875
                 if($stime) $query->where('aftersale_time', '>=', $stime);
1875 1876
                 if($etime) $query->where('aftersale_time', '<=', $etime.' 23:59:59');
1876 1877
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1877 1878
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->get();
1878 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 1881
                 if($team_id) $query->where('team_id', $team_id);
1881 1882
                 if($stime) $query->where('createTime', '>=', $stime);
1882 1883
                 if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
@@ -1887,10 +1888,16 @@ class StatisticsController extends Controller
1887 1888
         foreach($result as $k=>&$v){
1888 1889
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
1889 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 1901
         $filename = $aftersale==0 ? 'dingdanhuizong_'.date('Y-m-d_H').'.xlsx' : 'shouhouhuizong_'.date('Y-m-d_H').'.xlsx';
1895 1902
         return Order::export_excel($result, $filename, $indexKey, $title);
1896 1903
 

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

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