Browse Source

财务退补报表区别付款方式

sunhao 5 years ago
parent
commit
0c592a07ed

+ 62 - 16
app/Http/Controllers/Admin/StatisticsController.php

@@ -1791,9 +1791,20 @@ class StatisticsController extends Controller
1791 1791
             $refund_info = Order::select(DB::raw('count(1) as refund_count, sum(refund_price) as refund_price'))->where(function($query) use($team, $ctime){
1792 1792
                 $query->where('team_id', $team);
1793 1793
                 $query->where('refund_time', '=', $ctime);
1794
-            })->where('is_del', 0)->where('refund_time', '>', '')->first();
1794
+            })->where('is_del', 0)->where('refund_time', '>', '')->where('is_refund', 1)->first();
1795 1795
             $v['refund_count'] = $refund_info->refund_count;
1796 1796
             $v['refund_price'] = $refund_info->refund_price;
1797
+            //wx退补
1798
+            $wx_refund_info = Order::select(DB::raw('count(1) as refund_count, sum(refund_price) as refund_price'))->where('refund_type', 1)->where(function($query) use($team, $ctime){
1799
+                $query->where('team_id', $team);
1800
+                $query->where('refund_time', '=', $ctime);
1801
+            })->where('is_del', 0)->where('refund_time', '>', '')->where('is_refund', 1)->first();
1802
+            $v['wx_refund_count'] = $wx_refund_info->refund_count;
1803
+            $v['wx_refund_price'] = $wx_refund_info->refund_price;
1804
+            //付款码退补
1805
+            $v['zfm_refund_count'] = $v['refund_count'] - $v['wx_refund_count'];
1806
+            $v['zfm_refund_price'] = $v['refund_price'] - $v['wx_refund_price'];
1807
+
1797 1808
             #发货
1798 1809
             $send_info = Order::select(DB::raw('count(1) as send_count, sum(cost) as cost, sum(freight_cost) as freight_cost'))->where(function($query) use($team, $ctime){
1799 1810
                 $query->where('team_id', $team);
@@ -1803,8 +1814,12 @@ class StatisticsController extends Controller
1803 1814
             $v['cost'] = $send_info->cost;
1804 1815
             $v['freight_cost'] = $send_info->freight_cost;
1805 1816
 
1806
-            $v['true_amount'] = $v['receivedAmount'] + $v['refund_price'] - $v['aftersale_fee'];
1807
-            $v['zfm_money'] = $v['receivedAmount'] - $v['wx_money'];
1817
+            $v['zfm_money'] = $v['receivedAmount'] - $v['wx_money'];           
1818
+            $v['wx_true_amount'] = $v['wx_money'] + $v['wx_refund_price'] - $v['aftersale_fee'];
1819
+            $v['zfm_true_amount'] = $v['zfm_money'] + $v['zfm_refund_price'];
1820
+
1821
+            #毛利
1822
+            $v['profit'] = $v['wx_true_amount'] + $v['zfm_true_amount'] - $v['cost'] - $v['freight_cost'];
1808 1823
         }
1809 1824
 
1810 1825
         $teamList = DB::table('teams')->select('id', 'name')->get();
@@ -1884,25 +1899,40 @@ class StatisticsController extends Controller
1884 1899
             $refund_info = Order::select(DB::raw('count(1) as refund_count, sum(refund_price) as refund_price'))->where(function($query) use($team, $ctime){
1885 1900
                 $query->where('team_id', $team);
1886 1901
                 $query->where('refund_time', '=', $ctime);
1887
-            })->where('is_del', 0)->where('refund_time', '>', '')->first();
1902
+            })->where('is_del', 0)->where('refund_time', '>', '')->where('is_refund', 1)->first();
1888 1903
             $v['refund_count'] = $refund_info->refund_count;
1889 1904
             $v['refund_price'] = $refund_info->refund_price;
1905
+            //wx退补
1906
+            $wx_refund_info = Order::select(DB::raw('count(1) as refund_count, sum(refund_price) as refund_price'))->where('refund_type', 1)->where(function($query) use($team, $ctime){
1907
+                $query->where('team_id', $team);
1908
+                $query->where('refund_time', '=', $ctime);
1909
+            })->where('is_del', 0)->where('refund_time', '>', '')->where('is_refund', 1)->first();
1910
+            $v['wx_refund_count'] = $wx_refund_info->refund_count;
1911
+            $v['wx_refund_price'] = $wx_refund_info->refund_price;
1912
+            //付款码退补
1913
+            $v['zfm_refund_count'] = $v['refund_count'] - $v['wx_refund_count'];
1914
+            $v['zfm_refund_price'] = $v['refund_price'] - $v['wx_refund_price'];
1915
+
1890 1916
             #发货
1891 1917
             $send_info = Order::select(DB::raw('count(1) as send_count, sum(cost) as cost, sum(freight_cost) as freight_cost'))->where(function($query) use($team, $ctime){
1892 1918
                 $query->where('team_id', $team);
1893 1919
                 $query->where('send_time', '=', $ctime);
1894
-            })->where('is_del', 0)->where('logistics_id','>','')->first();
1920
+            })->where('is_del', 0)->where('logistics_id', '>', '')->first();
1895 1921
             $v['send_count'] = $send_info->send_count;
1896 1922
             $v['cost'] = $send_info->cost;
1897 1923
             $v['freight_cost'] = $send_info->freight_cost;
1898 1924
 
1899
-            $v['true_amount'] = $v['receivedAmount'] + $v['refund_price'] - $v['aftersale_fee'];
1900
-            $v['zfm_money'] = $v['receivedAmount'] - $v['wx_money'];
1925
+            $v['zfm_money'] = $v['receivedAmount'] - $v['wx_money'];           
1926
+            $v['wx_true_amount'] = $v['wx_money'] + $v['wx_refund_price'] - $v['aftersale_fee'];
1927
+            $v['zfm_true_amount'] = $v['zfm_money'] + $v['zfm_refund_price'];
1928
+
1929
+            #毛利
1930
+            $v['profit'] = $v['wx_true_amount'] + $v['zfm_true_amount'] - $v['cost'] - $v['freight_cost'];
1901 1931
         }
1902 1932
 
1903 1933
 
1904
-        $indexKey = ['team_name','ctime','order_count','receivedAmount','wx_money','zfm_money','aftersale_count','aftersale_fee','refund_count','refund_price','true_amount', 'send_count', 'cost', 'freight_cost'];
1905
-        $title = ['团队', '时间', '总单数', '成交金额', '微信支付金额','付款码支付金额', '售后单数', '售后金额', '退补单数', '退补差价', '实际金额', '发货单数', '货品成本', '物流成本'];
1934
+        $indexKey = ['team_name','ctime','order_count','receivedAmount','wx_money','zfm_money','aftersale_count','aftersale_fee','wx_refund_count','wx_refund_price','wx_true_amount','zfm_refund_count','zfm_refund_price','zfm_true_amount', 'send_count', 'cost', 'freight_cost', 'profit'];
1935
+        $title = ['团队', '时间', '总单数', '成交金额', '微信支付金额','付款码支付金额', '售后单数', '售后金额', '微信退补单数', '微信退补差价', '微信实际金额', '付款码退补单数', '付款码退补差价', '付款码实际金额', '发货单数', '货品成本', '物流成本', '毛利'];
1906 1936
         
1907 1937
         $filename = 'dingdanhuizong_'.date('Y-m-d_H').'.xlsx';
1908 1938
         return Order::export_excel($result, $filename, $indexKey, $title);
@@ -1994,7 +2024,7 @@ class StatisticsController extends Controller
1994 2024
             if($stime) $query->where('refund_time', '>=', $stime);
1995 2025
             if($etime) $query->where('refund_time', '<=', $etime);
1996 2026
 
1997
-        })->where('is_del', 0)->where('refund_time', '>', '')->count();
2027
+        })->where('is_del', 0)->where('refund_time', '>', '')->where('is_refund', 1)->count();
1998 2028
         if ($count > 1) {
1999 2029
             // 总页数
2000 2030
             $pages = ceil($count/$pageSize);
@@ -2004,11 +2034,11 @@ class StatisticsController extends Controller
2004 2034
         }
2005 2035
 
2006 2036
         $teams = DB::table('teams')->lists('name', 'id');
2007
-        $resultQuery = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'refund_price', 'payment_type', 'refund_time')->where(function($query) use($team_id, $stime, $etime){
2037
+        $resultQuery = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'refund_price', 'payment_type', 'refund_time', 'refund_note', 'refund_type')->where(function($query) use($team_id, $stime, $etime){
2008 2038
             if($team_id) $query->where('team_id', $team_id);
2009 2039
             if($stime ) $query->where('refund_time', '>=', $stime);
2010 2040
             if($etime ) $query->where('refund_time', '<=', $etime);
2011
-        })->where('is_del', 0)->where('refund_time', '>', '');
2041
+        })->where('is_del', 0)->where('refund_time', '>', '')->where('is_refund', 1);
2012 2042
 
2013 2043
         $result = $resultQuery->orderBy('refund_time','desc')->offset($offset)->limit($pageSize)->get();
2014 2044
         
@@ -2018,6 +2048,14 @@ class StatisticsController extends Controller
2018 2048
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';;            
2019 2049
             $v['payment_type'] = $payArr[$v['payment_type']];
2020 2050
             $v['ctime'] = $v['refund_time'];
2051
+            //退补支付方式
2052
+            if($v['refund_type'] == 1){
2053
+                $v['refund_type'] = '微信支付';
2054
+            }elseif($v['refund_type'] == 2){
2055
+                $v['refund_type'] = '付款码支付';
2056
+            }else{
2057
+                $v['refund_type'] = '';
2058
+            }   
2021 2059
         }
2022 2060
 
2023 2061
         $teamList = DB::table('teams')->select('id', 'name')->get();
@@ -2138,11 +2176,11 @@ class StatisticsController extends Controller
2138 2176
         $etime = $request->input('etime');
2139 2177
 
2140 2178
         $teams = DB::table('teams')->lists('name', 'id');
2141
-        $resultQuery = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'refund_price', 'payment_type', 'refund_time')->where(function($query) use($team_id, $stime, $etime){
2179
+        $resultQuery = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'refund_price', 'payment_type', 'refund_time', 'refund_note', 'refund_type')->where(function($query) use($team_id, $stime, $etime){
2142 2180
             if($team_id) $query->where('team_id', $team_id);
2143 2181
             if($stime ) $query->where('refund_time', '>=', $stime);
2144 2182
             if($etime ) $query->where('refund_time', '<=', $etime);
2145
-        })->where('is_del', 0)->where('refund_time', '>', '');
2183
+        })->where('is_del', 0)->where('refund_time', '>', '')->where('is_refund', 1);
2146 2184
 
2147 2185
         $result = $resultQuery->orderBy('refund_time','desc')->get();
2148 2186
         
@@ -2152,10 +2190,18 @@ class StatisticsController extends Controller
2152 2190
             $v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';;            
2153 2191
             $v['payment_type'] = $payArr[$v['payment_type']];
2154 2192
             $v['ctime'] = $v['refund_time'];
2193
+            //退补支付方式
2194
+            if($v['refund_type'] == 1){
2195
+                $v['refund_type'] = '微信支付';
2196
+            }elseif($v['refund_type'] == 2){
2197
+                $v['refund_type'] = '付款码支付';
2198
+            }else{
2199
+                $v['refund_type'] = '';
2200
+            } 
2155 2201
         }
2156 2202
 
2157
-        $indexKey = ['team_name','ctime','id','receivedAmount','refund_price', 'payment_type'];      
2158
-        $title = ['团队', '退补时间', '订单编号', '成交金额','退补差价', '支付方式'];
2203
+        $indexKey = ['team_name','ctime','id','receivedAmount', 'payment_type','refund_price', 'refund_type'];      
2204
+        $title = ['团队', '退补时间', '订单编号', '成交金额', '支付方式', '退补差价', '退补支付方式'];
2159 2205
         $filename = 'tuibumingxi_'.date('Y-m-d_H').'.xlsx';
2160 2206
         return Order::export_excel($result, $filename, $indexKey, $title);
2161 2207
     } 

+ 6 - 6
resources/views/statistics/refundFinanceList.blade.php

@@ -30,9 +30,9 @@
30 30
                     <th width="5%">退补时间</th>
31 31
                     <th width="5%">订单编号</th>
32 32
                     <th width="5%">成交金额</th>                
33
-                    <th width="5%">退补金额</th>                
34
-                                              
35
-                    <th width="5%">支付方式</th>                                                
33
+                    <th width="5%">支付方式</th>                
34
+                    <th width="5%">退补金额</th>                                                             
35
+                    <th width="5%">退补支付方式</th>                                                
36 36
                 </tr>
37 37
                 </thead>
38 38
                 <tbody>
@@ -42,10 +42,10 @@
42 42
                             <td>{{$a['team_name']}}</td>                            
43 43
                             <td>{{$a['ctime']}}</td>
44 44
                             <td>{{$a['id']}}</td>
45
-                            <td>{{$a['receivedAmount']}}</td>                      
45
+                            <td>{{$a['receivedAmount']}}</td>  
46
+                            <td>{{$a['payment_type']}}</td>                    
46 47
                             <td>{{$a['refund_price']}}</td>                      
47
-
48
-                            <td>{{$a['payment_type']}}</td>
48
+                            <td>{{$a['refund_type']}}</td>
49 49
 
50 50
                         </tr>
51 51
                     @endforeach

+ 14 - 6
resources/views/statistics/teamFinanceTotal.blade.php

@@ -34,12 +34,16 @@
34 34
                     <th width="5%">付款码支付金额</th>
35 35
                     <th width="5%">售后单数</th>
36 36
                     <th width="5%">售后金额</th>
37
-                    <th width="5%">退补单数</th>
38
-                    <th width="5%">退补差价</th>
39
-                    <th width="5%">实际金额</th>
37
+                    <th width="5%">微信退补单数</th>
38
+                    <th width="5%">微信退补差价</th>
39
+                    <th width="5%">微信实际金额</th>
40
+                    <th width="5%">付款码退补单数</th>
41
+                    <th width="5%">付款码退补差价</th>
42
+                    <th width="5%">付款码实际金额</th>
40 43
                     <th width="5%">发货单数</th>
41 44
                     <th width="5%">货品成本</th>
42 45
                     <th width="5%">物流成本</th>
46
+                    <th width="5%">毛利</th>
43 47
                                              
44 48
                 </tr>
45 49
                 </thead>
@@ -55,12 +59,16 @@
55 59
                             <td>{{$a['zfm_money']}}</td>
56 60
                             <td>{{$a['aftersale_count']}}</td>
57 61
                             <td>{{$a['aftersale_fee']}}</td>
58
-                            <td>{{$a['refund_count']}}</td>
59
-                            <td>{{$a['refund_price']}}</td>
60
-                            <td>{{$a['true_amount']}}</td>
62
+                            <td>{{$a['wx_refund_count']}}</td>
63
+                            <td>{{$a['wx_refund_price']}}</td>
64
+                            <td>{{$a['wx_true_amount']}}</td>
65
+                            <td>{{$a['zfm_refund_count']}}</td>
66
+                            <td>{{$a['zfm_refund_price']}}</td>
67
+                            <td>{{$a['zfm_true_amount']}}</td>
61 68
                             <td>{{$a['send_count']}}</td>
62 69
                             <td>{{$a['cost']}}</td>
63 70
                             <td>{{$a['freight_cost']}}</td>
71
+                            <td>{{$a['profit']}}</td>
64 72
 
65 73
                         </tr>
66 74
                     @endforeach