sunhao 5 vuotta sitten
vanhempi
commit
55c349573d
1 muutettua tiedostoa jossa 5 lisäystä ja 2 poistoa
  1. 5 2
      app/Http/Controllers/Admin/StatisticsController.php

+ 5 - 2
app/Http/Controllers/Admin/StatisticsController.php

@@ -570,6 +570,7 @@ class StatisticsController extends Controller
570 570
             if($etime) $query->where('dtime', '<=', $etime);
571 571
         })->where('is_del',0)->groupBy('dtime')->orderBy('dtime', 'desc')->offset($offset)->limit($pageSize)->get();
572 572
         $result = json_decode(json_encode($result),true);
573
+        $end_time = date('Y-m-d');
573 574
         foreach($result as $k=>&$v){
574 575
             #进粉成本
575 576
             $v['cost_fan'] = $v['total_fan_add']>0? round($v['total_cost'] / $v['total_fan_add'], 2) : '';
@@ -594,9 +595,10 @@ class StatisticsController extends Controller
594 595
              //当日加粉
595 596
             $phones = DB::table('customers')->where('fanTime', $v['dtime'])->lists('phone');
596 597
             #当日加粉订单总计:
598
+            #截止昨天           
597 599
             $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count, sum(cost) as order_cost, sum(freight_cost) as freight_cost'))->whereIn('receiverMobile', $phones)->where('is_del', 0)->where(function($query) use($team_id){
598 600
                 if($team_id>0) $query->where('team_id', $team_id);
599
-            })->first();
601
+            })->where('createTime','<',$end_time)->first();
600 602
             #当日新粉成单:            
601 603
             $new_order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $v['dtime'])->where('createTime','<', $v['dtime'].' 23:59:59')->where('is_del', 0)->whereIn('receiverMobile', $phones)->where(function($query) use($team_id){
602 604
                 if($team_id>0) $query->where('team_id', $team_id);
@@ -650,6 +652,7 @@ class StatisticsController extends Controller
650 652
             if($etime) $query->where('dtime', '<=', $etime);
651 653
         })->where('is_del',0)->groupBy('dtime')->orderBy('dtime', 'desc')->get();
652 654
         $result = json_decode(json_encode($result),true);
655
+        $end_time = date('Y-m-d');
653 656
         foreach($result as $k=>&$v){
654 657
             #进粉成本
655 658
             $v['cost_fan'] = $v['total_fan_add']>0? round($v['total_cost'] / $v['total_fan_add'], 2) : '';
@@ -667,7 +670,7 @@ class StatisticsController extends Controller
667 670
             #当日订单数、销售额
668 671
             $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $v['dtime'])->where('createTime','<', $v['dtime'].' 23:59:59')->where('is_del', 0)->where(function($query) use($team_id){
669 672
                 if($team_id>0) $query->where('team_id', $team_id);
670
-            })->first();
673
+            })->where('createTime','<',$end_time)->first();
671 674
             $v['order_count'] = $order->order_count;
672 675
             $v['order_amount'] = $order->order_amount;
673 676