浏览代码

只统计94之后数据

sunhao 5 年之前
父节点
当前提交
5c0b63de67
共有 2 个文件被更改,包括 8 次插入7 次删除
  1. 4 3
      app/Console/Commands/DayGrandTotal.php
  2. 4 4
      app/Http/Controllers/Api/TemplateController.php

+ 4 - 3
app/Console/Commands/DayGrandTotal.php

@@ -25,6 +25,7 @@ class DayGrandTotal extends Command {
25 25
 
26 26
     
27 27
     public function dayGrandTotal(){
28
+        $_start = '2019-09-04';
28 29
         $_end = date('Y-m-d');
29 30
         $data = array();
30 31
         $idate = date('Y-m-d', strtotime('-1 day'));
@@ -36,9 +37,9 @@ class DayGrandTotal extends Command {
36 37
         }
37 38
         $data['idate'] = $idate;
38 39
         //总投入
39
-        $data['throw_cost'] = CustTotal::where('is_del',0)->where('dtime','<',$_end)->sum('total_cost');
40
+        $data['throw_cost'] = CustTotal::where('is_del',0)->where('dtime','<',$_end)->where('dtime','>=',$_start)->sum('total_cost');
40 41
         //订单信息
41
-        $order = Order::select(DB::raw('sum(cost) as goods_cost, sum(freight_cost) as freight_cost, sum(aftersale_fee) as aftersale_cost, count(1) as order_count, sum(receivedAmount) as order_amount, count(distinct(receiverMobile)) as cust_count, sum(refund_price) as refund_fee'))->where('is_del',0)->where('createTime','<',$_end)->where('cost', '>', 0)->first();
42
+        $order = Order::select(DB::raw('sum(cost) as goods_cost, sum(freight_cost) as freight_cost, sum(aftersale_fee) as aftersale_cost, count(1) as order_count, sum(receivedAmount) as order_amount, count(distinct(receiverMobile)) as cust_count, sum(refund_price) as refund_fee'))->where('is_del',0)->where('createTime','<',$_end)->where('createTime','>=',$_start)->where('cost', '>', 0)->first();
42 43
         $data['goods_cost'] = $order->goods_cost;
43 44
         $data['freight_cost'] = $order->freight_cost;
44 45
         $data['aftersale_cost'] = $order->aftersale_cost;
@@ -47,7 +48,7 @@ class DayGrandTotal extends Command {
47 48
         $data['order_amount'] = $order->order_amount;
48 49
         $data['cust_count'] = $order->cust_count;
49 50
         //加粉
50
-        $data['fan_count'] = CustDetail::where('is_del',0)->where('dtime','<',$_end)->sum('fan_add');    
51
+        $data['fan_count'] = CustDetail::where('is_del',0)->where('dtime','<',$_end)->where('dtime','>=',$_start)->sum('fan_add');    
51 52
         //毛利 = 总销售额-总商品成本-总运费-总售后
52 53
         $data['profit'] = $order->order_amount - $order->goods_cost - $order->freight_cost - $order->aftersale_cost - $data['throw_cost'] + $order->refund_fee;
53 54
    

+ 4 - 4
app/Http/Controllers/Api/TemplateController.php

@@ -124,14 +124,14 @@ class TemplateController extends Controller {
124 124
         }
125 125
         $stime = date('Y-m-d', strtotime('-'.$days.' day'));
126 126
         $data = array();
127
-       
127
+        $_start = '2019-09-04';
128 128
         //今日数据实时计算
129 129
         $idate = date('Y-m-d');
130 130
         $data['idate'] = $idate;
131 131
         //总投入
132
-        $data['throw_cost'] = CustTotal::where('is_del',0)->sum('total_cost');
132
+        $data['throw_cost'] = CustTotal::where('is_del',0)->where('dtime','>=',$_start)->sum('total_cost');
133 133
         //订单信息
134
-        $order = Order::select(DB::raw('sum(cost) as goods_cost, sum(freight_cost) as freight_cost, sum(aftersale_fee) as aftersale_cost, count(1) as order_count, sum(receivedAmount) as order_amount, count(distinct(receiverMobile)) as cust_count, sum(refund_price) as refund_fee'))->where('is_del',0)->where('cost', '>', 0)->first();
134
+        $order = Order::select(DB::raw('sum(cost) as goods_cost, sum(freight_cost) as freight_cost, sum(aftersale_fee) as aftersale_cost, count(1) as order_count, sum(receivedAmount) as order_amount, count(distinct(receiverMobile)) as cust_count, sum(refund_price) as refund_fee'))->where('createTime','>=',$_start)->where('is_del',0)->where('cost', '>', 0)->first();
135 135
         $data['goods_cost'] = $order->goods_cost;
136 136
         $data['freight_cost'] = $order->freight_cost;
137 137
         $data['aftersale_cost'] = $order->aftersale_cost;
@@ -140,7 +140,7 @@ class TemplateController extends Controller {
140 140
         $data['order_amount'] = $order->order_amount;
141 141
         $data['cust_count'] = $order->cust_count;
142 142
         //加粉
143
-        $data['fan_count'] = CustDetail::where('is_del',0)->sum('fan_add');    
143
+        $data['fan_count'] = CustDetail::where('is_del',0)->where('dtime','>=',$_start)->sum('fan_add');    
144 144
         //毛利 = 总销售额-总商品成本-总运费-总售后
145 145
         $data['profit'] = $order->order_amount - $order->goods_cost - $order->freight_cost - $order->aftersale_cost - $data['throw_cost'] + $order->refund_fee;
146 146