|
@@ -1703,18 +1703,24 @@ class StatisticsController extends Controller
|
1703
|
1703
|
}
|
1704
|
1704
|
|
1705
|
1705
|
$teams = DB::table('teams')->lists('name', 'id');
|
1706
|
|
- $result = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'aftersale_fee', 'refund_price', 'cost', 'freight_cost', 'payment_type')->where(function($query) use($team_id, $stime, $etime, $aftersale){
|
|
1706
|
+ $resultQuery = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'aftersale_fee', 'refund_price', 'cost', 'freight_cost', 'payment_type', 'aftersale_time')->where(function($query) use($team_id, $stime, $etime, $aftersale){
|
1707
|
1707
|
if($team_id) $query->where('team_id', $team_id);
|
1708
|
1708
|
if($stime) $query->where('createTime', '>=', $stime);
|
1709
|
1709
|
if($etime) $query->where('createTime', '<=', $etime. ' 23:59:59');
|
1710
|
1710
|
if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
1711
|
|
- })->where('is_del', 0)->orderBy('team_id', 'asc')->orderBy('createTime','desc')->offset($offset)->limit($pageSize)->get();
|
|
1711
|
+ })->where('is_del', 0)->orderBy('team_id', 'asc');
|
|
1712
|
+ if($aftersale == 1){
|
|
1713
|
+ $result = $resultQuery->orderBy('aftersale_time','desc')->offset($offset)->limit($pageSize)->get();
|
|
1714
|
+ }else{
|
|
1715
|
+ $result = $resultQuery->orderBy('createTime','desc')->offset($offset)->limit($pageSize)->get();
|
|
1716
|
+ }
|
1712
|
1717
|
$result = json_decode(json_encode($result), true);
|
1713
|
1718
|
$payArr = [1=>'微信支付', 2=>'付款码支付'];
|
1714
|
1719
|
foreach($result as $k=>&$v){
|
1715
|
1720
|
$v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';;
|
1716
|
1721
|
$v['true_amount'] = $v['receivedAmount'] - $v['refund_price'] - $v['aftersale_fee'];
|
1717
|
1722
|
$v['payment_type'] = $payArr[$v['payment_type']];
|
|
1723
|
+ $v['ctime'] = $aftersale == 1 ? $v['aftersale_time'] : $v['createTime'];
|
1718
|
1724
|
}
|
1719
|
1725
|
|
1720
|
1726
|
$teamList = DB::table('teams')->select('id', 'name')->get();
|
|
@@ -1749,7 +1755,12 @@ class StatisticsController extends Controller
|
1749
|
1755
|
}
|
1750
|
1756
|
$offset = ($page-1) * $pageSize;
|
1751
|
1757
|
|
1752
|
|
- $count = Order::select(DB::raw('left(createTime, 10) as ctime, team_id'))->where(function($query) use($team_id, $stime, $etime, $aftersale){
|
|
1758
|
+ if($aftersale == 1){
|
|
1759
|
+ $countQuery = Order::select(DB::raw('left(aftersale_time, 10) as ctime, team_id'));
|
|
1760
|
+ }else{
|
|
1761
|
+ $countQuery = Order::select(DB::raw('left(createTime, 10) as ctime, team_id'));
|
|
1762
|
+ }
|
|
1763
|
+ $count = $countQuery->where(function($query) use($team_id, $stime, $etime, $aftersale){
|
1753
|
1764
|
if($team_id) $query->where('team_id', $team_id);
|
1754
|
1765
|
if($stime) $query->where('createTime', '>=', $stime);
|
1755
|
1766
|
if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
|
|
@@ -1766,12 +1777,21 @@ class StatisticsController extends Controller
|
1766
|
1777
|
}
|
1767
|
1778
|
|
1768
|
1779
|
$teams = DB::table('teams')->lists('name', 'id');
|
1769
|
|
- $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){
|
1770
|
|
- if($team_id) $query->where('team_id', $team_id);
|
1771
|
|
- if($stime) $query->where('createTime', '>=', $stime);
|
1772
|
|
- if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
|
1773
|
|
- if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
1774
|
|
- })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('createTime','desc')->offset($offset)->limit($pageSize)->get();
|
|
1780
|
+ if($aftersale == 1){
|
|
1781
|
+ $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){
|
|
1782
|
+ if($team_id) $query->where('team_id', $team_id);
|
|
1783
|
+ if($stime) $query->where('createTime', '>=', $stime);
|
|
1784
|
+ if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
|
|
1785
|
+ if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
|
1786
|
+ })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->offset($offset)->limit($pageSize)->get();
|
|
1787
|
+ }else{
|
|
1788
|
+ $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){
|
|
1789
|
+ if($team_id) $query->where('team_id', $team_id);
|
|
1790
|
+ if($stime) $query->where('createTime', '>=', $stime);
|
|
1791
|
+ if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
|
|
1792
|
+ if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
|
1793
|
+ })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('createTime','desc')->offset($offset)->limit($pageSize)->get();
|
|
1794
|
+ }
|
1775
|
1795
|
$result = json_decode(json_encode($result), true);
|
1776
|
1796
|
foreach($result as $k=>&$v){
|
1777
|
1797
|
$v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
|
|
@@ -1804,12 +1824,17 @@ class StatisticsController extends Controller
|
1804
|
1824
|
$aftersale = $request->input('aftersale');
|
1805
|
1825
|
|
1806
|
1826
|
$teams = DB::table('teams')->lists('name', 'id');
|
1807
|
|
- $result = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'aftersale_fee', 'refund_price', 'cost', 'freight_cost', 'payment_type')->where(function($query) use($team_id, $stime, $etime, $aftersale){
|
|
1827
|
+ $resultQuery = Order::select('team_id', 'createTime', 'id', 'receivedAmount', 'aftersale_fee', 'refund_price', 'cost', 'freight_cost', 'payment_type', 'aftersale_time')->where(function($query) use($team_id, $stime, $etime, $aftersale){
|
1808
|
1828
|
if($team_id) $query->where('team_id', $team_id);
|
1809
|
1829
|
if($stime) $query->where('createTime', '>=', $stime);
|
1810
|
1830
|
if($etime) $query->where('createTime', '<=', $etime. ' 23:59:59');
|
1811
|
1831
|
if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
1812
|
|
- })->where('is_del', 0)->orderBy('team_id', 'asc')->orderBy('createTime','desc')->get();
|
|
1832
|
+ })->where('is_del', 0)->orderBy('team_id', 'asc');
|
|
1833
|
+ if($aftersale == 1){
|
|
1834
|
+ $result = $resultQuery->orderBy('aftersale_time','desc')->get();
|
|
1835
|
+ }else{
|
|
1836
|
+ $result = $resultQuery->orderBy('createTime','desc')->get();
|
|
1837
|
+ }
|
1813
|
1838
|
$result = json_decode(json_encode($result), true);
|
1814
|
1839
|
$payArr = [1=>'微信支付', 2=>'付款码支付'];
|
1815
|
1840
|
foreach($result as $k=>&$v){
|
|
@@ -1818,7 +1843,8 @@ class StatisticsController extends Controller
|
1818
|
1843
|
$v['payment_type'] = $payArr[$v['payment_type']];
|
1819
|
1844
|
}
|
1820
|
1845
|
|
1821
|
|
- $indexKey = ['team_name','createTime','id','receivedAmount','aftersale_fee','refund_price','true_amount','cost','freight_cost', 'payment_type'];
|
|
1846
|
+ if($aftersale == 0) $indexKey = ['team_name','createTime','id','receivedAmount','aftersale_fee','refund_price','true_amount','cost','freight_cost', 'payment_type'];
|
|
1847
|
+ if($aftersale == 1) $indexKey = ['team_name','aftersale_time','id','receivedAmount','aftersale_fee','refund_price','true_amount','cost','freight_cost', 'payment_type'];
|
1822
|
1848
|
$title = ['团队', '时间', '订单编号', '成交金额', '售后', '退补差价', '实际金额', '供应商成本', '物流成本', '支付方式'];
|
1823
|
1849
|
$filename = 'teamFinanceList_'.date('Y-m-d_H').'.xlsx';
|
1824
|
1850
|
return Order::export_excel($result, $filename, $indexKey, $title);
|
|
@@ -1834,12 +1860,21 @@ class StatisticsController extends Controller
|
1834
|
1860
|
$aftersale = $request->input('aftersale');
|
1835
|
1861
|
|
1836
|
1862
|
$teams = DB::table('teams')->lists('name', 'id');
|
1837
|
|
- $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){
|
1838
|
|
- if($team_id) $query->where('team_id', $team_id);
|
1839
|
|
- if($stime) $query->where('createTime', '>=', $stime);
|
1840
|
|
- if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
|
1841
|
|
- if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
1842
|
|
- })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('createTime','desc')->get();
|
|
1863
|
+ if($aftersale == 1){
|
|
1864
|
+ $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){
|
|
1865
|
+ if($team_id) $query->where('team_id', $team_id);
|
|
1866
|
+ if($stime) $query->where('createTime', '>=', $stime);
|
|
1867
|
+ if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
|
|
1868
|
+ if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
|
1869
|
+ })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->get();
|
|
1870
|
+ }else{
|
|
1871
|
+ $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){
|
|
1872
|
+ if($team_id) $query->where('team_id', $team_id);
|
|
1873
|
+ if($stime) $query->where('createTime', '>=', $stime);
|
|
1874
|
+ if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
|
|
1875
|
+ if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
|
|
1876
|
+ })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('createTime','desc')->get();
|
|
1877
|
+ }
|
1843
|
1878
|
$result = json_decode(json_encode($result), true);
|
1844
|
1879
|
foreach($result as $k=>&$v){
|
1845
|
1880
|
$v['team_name'] = $v['team_id']>0 ? $teams[$v['team_id']] : '';
|