sunhao 5 years ago
parent
commit
d68556a3a5
1 changed files with 11 additions and 4 deletions
  1. 11 4
      app/Http/Controllers/Admin/StatisticsController.php

+ 11 - 4
app/Http/Controllers/Admin/StatisticsController.php

@@ -4382,14 +4382,18 @@ class StatisticsController extends Controller
4382 4382
             $result[$k]['click_rate'] = $result[$k]['pv_count']>0 && $result[$k]['long_count']>0 ? round( $result[$k]['long_count'] / $result[$k]['pv_count'], 4 ) * 100 . '%' : '';
4383 4383
             $result[$k]['change_rate'] = $result[$k]['long_count']>0 && $result[$k]['fan_add']>0 ? round( $result[$k]['fan_add'] / $result[$k]['long_count'], 4 ) * 100 . '%' : '';
4384 4384
             //下单数据统计
4385
-            $order = Order::select(DB::raw('count(1) as order_count,sum(receivedAmount) as order_amount'))->where('admin_id', $admin_id)->first();
4385
+            $order = Order::select(DB::raw('count(1) as order_count,sum(receivedAmount) as order_amount'))->where('admin_id', $admin_id)->where('is_del', 0)->first();
4386 4386
             $result[$k]['order_count'] = $order->order_count;
4387 4387
             $result[$k]['order_amount'] = $order->order_amount;
4388 4388
             //下单用户数
4389 4389
             $customer_count = DB::table('customers')->where('admin_id', $admin_id)->count();
4390 4390
             $customer_fugou_count = DB::table('customers')->where('is_fugou', 1)->where('admin_id', $admin_id)->count();
4391
+
4392
+            //复购单
4393
+            $fugou_count = Order::where('is_fugou', 1)->where('admin_id', $admin_id)->where('is_del', 0)->count();
4394
+            $no_fugou_count = $order->order_count - $fugou_count;
4391 4395
             //复购率
4392
-            $fugou_rate = $customer_count>0 ? round( $customer_fugou_count / $customer_count, 4 ) * 100 . '%' : '';
4396
+            $fugou_rate = $no_fugou_count>0 ? round( $fugou_count / $no_fugou_count, 4 ) * 100 . '%' : '';
4393 4397
 
4394 4398
             $result[$k]['customer_count'] = $customer_count;
4395 4399
             $result[$k]['customer_fugou_count'] = $customer_fugou_count;
@@ -4469,14 +4473,17 @@ class StatisticsController extends Controller
4469 4473
             $result[$k]['click_rate'] = $result[$k]['pv_count']>0 && $result[$k]['long_count']>0 ? round( $result[$k]['long_count'] / $result[$k]['pv_count'], 4 ) * 100 . '%' : '';
4470 4474
             $result[$k]['change_rate'] = $result[$k]['long_count']>0 && $result[$k]['fan_add']>0 ? round( $result[$k]['fan_add'] / $result[$k]['long_count'], 4 ) * 100 . '%' : '';
4471 4475
             //下单数据统计
4472
-            $order = Order::select(DB::raw('count(1) as order_count,sum(receivedAmount) as order_amount'))->where('admin_id', $admin_id)->first();
4476
+            $order = Order::select(DB::raw('count(1) as order_count,sum(receivedAmount) as order_amount'))->where('is_del', 0)->where('admin_id', $admin_id)->first();
4473 4477
             $result[$k]['order_count'] = $order->order_count;
4474 4478
             $result[$k]['order_amount'] = $order->order_amount;
4475 4479
             //下单用户数
4476 4480
             $customer_count = DB::table('customers')->where('admin_id', $admin_id)->count();
4477 4481
             $customer_fugou_count = DB::table('customers')->where('is_fugou', 1)->where('admin_id', $admin_id)->count();
4482
+            //复购单
4483
+            $fugou_count = Order::where('is_fugou', 1)->where('admin_id', $admin_id)->where('is_del', 0)->count();
4484
+            $no_fugou_count = $order->order_count - $fugou_count;
4478 4485
             //复购率
4479
-            $fugou_rate = $customer_count>0 ? round( $customer_fugou_count / $customer_count, 4 ) * 100 . '%' : '';
4486
+            $fugou_rate = $no_fugou_count>0 ? round( $fugou_count / $no_fugou_count, 4 ) * 100 . '%' : '';
4480 4487
 
4481 4488
             $result[$k]['customer_count'] = $customer_count;
4482 4489
             $result[$k]['customer_fugou_count'] = $customer_fugou_count;