|
@@ -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
|
}
|