Browse Source

售后时间搜索

sunhao 5 years ago
parent
commit
f6a605f40d
1 changed files with 20 additions and 12 deletions
  1. 20 12
      app/Http/Controllers/Admin/StatisticsController.php

+ 20 - 12
app/Http/Controllers/Admin/StatisticsController.php

@@ -1690,8 +1690,10 @@ class StatisticsController extends Controller
1690 1690
 
1691 1691
         $count = Order::where(function($query) use($team_id, $stime, $etime, $aftersale){
1692 1692
             if($team_id) $query->where('team_id', $team_id);
1693
-            if($stime) $query->where('createTime', '>=', $stime);
1694
-            if($etime) $query->where('createTime', '<=', $etime. ' 23:59:59');
1693
+            if($stime && $aftersale == 0) $query->where('createTime', '>=', $stime);
1694
+            if($etime && $aftersale == 0) $query->where('createTime', '<=', $etime. ' 23:59:59');
1695
+            if($stime && $aftersale == 1) $query->where('aftersale_time', '>=', $stime);
1696
+            if($etime && $aftersale == 1) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1695 1697
             if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1696 1698
         })->where('is_del', 0)->count();
1697 1699
         if ($count > 1) {
@@ -1705,8 +1707,10 @@ class StatisticsController extends Controller
1705 1707
         $teams = DB::table('teams')->lists('name', 'id');
1706 1708
         $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 1709
             if($team_id) $query->where('team_id', $team_id);
1708
-            if($stime) $query->where('createTime', '>=', $stime);
1709
-            if($etime) $query->where('createTime', '<=', $etime. ' 23:59:59');
1710
+            if($stime && $aftersale == 0) $query->where('createTime', '>=', $stime);
1711
+            if($etime && $aftersale == 0) $query->where('createTime', '<=', $etime. ' 23:59:59');
1712
+            if($stime && $aftersale == 1) $query->where('aftersale_time', '>=', $stime);
1713
+            if($etime && $aftersale == 1) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1710 1714
             if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1711 1715
         })->where('is_del', 0)->orderBy('team_id', 'asc');
1712 1716
         if($aftersale == 1){
@@ -1762,8 +1766,10 @@ class StatisticsController extends Controller
1762 1766
         }
1763 1767
         $count = $countQuery->where(function($query) use($team_id, $stime, $etime, $aftersale){
1764 1768
             if($team_id) $query->where('team_id', $team_id);
1765
-            if($stime) $query->where('createTime', '>=', $stime);
1766
-            if($etime) $query->where('createTime', '<=', $etime.' 23:59:59');
1769
+            if($stime && $aftersale == 0) $query->where('createTime', '>=', $stime);
1770
+            if($etime && $aftersale == 0) $query->where('createTime', '<=', $etime. ' 23:59:59');
1771
+            if($stime && $aftersale == 1) $query->where('aftersale_time', '>=', $stime);
1772
+            if($etime && $aftersale == 1) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1767 1773
             if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1768 1774
         })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->get();
1769 1775
         $count = count($count);
@@ -1780,8 +1786,8 @@ class StatisticsController extends Controller
1780 1786
         if($aftersale == 1){
1781 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){
1782 1788
                 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');
1789
+                if($stime) $query->where('aftersale_time', '>=', $stime);
1790
+                if($etime) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1785 1791
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1786 1792
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->offset($offset)->limit($pageSize)->get();
1787 1793
         }else{
@@ -1826,8 +1832,10 @@ class StatisticsController extends Controller
1826 1832
         $teams = DB::table('teams')->lists('name', 'id');
1827 1833
         $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){
1828 1834
             if($team_id) $query->where('team_id', $team_id);
1829
-            if($stime) $query->where('createTime', '>=', $stime);
1830
-            if($etime) $query->where('createTime', '<=', $etime. ' 23:59:59');
1835
+            if($stime && $aftersale == 0) $query->where('createTime', '>=', $stime);
1836
+            if($etime && $aftersale == 0) $query->where('createTime', '<=', $etime. ' 23:59:59');
1837
+            if($stime && $aftersale == 1) $query->where('aftersale_time', '>=', $stime);
1838
+            if($etime && $aftersale == 1) $query->where('aftersale_time', '<=', $etime. ' 23:59:59');
1831 1839
             if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1832 1840
         })->where('is_del', 0)->orderBy('team_id', 'asc');
1833 1841
         if($aftersale == 1){
@@ -1863,8 +1871,8 @@ class StatisticsController extends Controller
1863 1871
         if($aftersale == 1){
1864 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){
1865 1873
                 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');
1874
+                if($stime) $query->where('aftersale_time', '>=', $stime);
1875
+                if($etime) $query->where('aftersale_time', '<=', $etime.' 23:59:59');
1868 1876
                 if($aftersale == 1) $query->where('aftersale_fee', '>', 0);
1869 1877
             })->where('is_del', 0)->groupBy('team_id')->groupBy('ctime')->orderBy('team_id', 'asc')->orderBy('aftersale_time','desc')->get();
1870 1878
         }else{