|
@@ -4586,6 +4586,15 @@ class StatisticsController extends Controller
|
4586
|
4586
|
//毛利 = 总销售额-总商品成本-总运费-总售后
|
4587
|
4587
|
$data['profit'] = $order->order_amount - $order->goods_cost - $order->freight_cost - $order->aftersale_cost - $data['throw_cost'] + $order->refund_fee;
|
4588
|
4588
|
$data['roi'] = $data['throw_cost']>0? round($order->order_amount / $data['throw_cost'], 4) * 100 .'%' : '';
|
|
4589
|
+ //总新粉单数
|
|
4590
|
+ $new_order = Order::select(DB::raw('count(1) as order_count'))->leftJoin('customers as cu','cu.phone', '=', 'order.receiverMobile')->whereRaw('left(order.createTime, 10) = cu.fanTime')->where('order.is_del', 0)->where('order.createTime','>=',$_start)->first();
|
|
4591
|
+ $data['new_order_count'] = $new_order->order_count;
|
|
4592
|
+ //总老粉单数
|
|
4593
|
+ $data['old_order_count'] = $data['order_count'] - $data['new_order_count'];
|
|
4594
|
+ //总复购订单
|
|
4595
|
+ $data['fugou_order_count'] = $data['order_count'] - $data['cust_count'];
|
|
4596
|
+ //总复购率
|
|
4597
|
+ $data['fugou_rate'] = $data['cust_count']>0 ? round($data['fugou_order_count'] / $data['cust_count'], 4) : '';
|
4589
|
4598
|
}else{
|
4590
|
4599
|
$offset = ($page-1) * $pageSize - 1;
|
4591
|
4600
|
}
|
|
@@ -4596,6 +4605,7 @@ class StatisticsController extends Controller
|
4596
|
4605
|
$result = json_decode(json_encode($result), true);
|
4597
|
4606
|
foreach($result as $k=>&$v){
|
4598
|
4607
|
$v['roi'] = $v['throw_cost']>0 ? round($v['order_amount'] / $v['throw_cost'], 4) * 100 .'%' : '';
|
|
4608
|
+ $v['fugou_rate'] = $v['cust_count']>0 ? round($v['fugou_order_count'] / $v['cust_count'], 4) : '';
|
4599
|
4609
|
}
|
4600
|
4610
|
if($page == 1){
|
4601
|
4611
|
$result = array_merge([$data], $result);
|
|
@@ -4641,11 +4651,21 @@ class StatisticsController extends Controller
|
4641
|
4651
|
//毛利 = 总销售额-总商品成本-总运费-总售后
|
4642
|
4652
|
$data['profit'] = $order->order_amount - $order->goods_cost - $order->freight_cost - $order->aftersale_cost - $data['throw_cost'] + $order->refund_fee;
|
4643
|
4653
|
$data['roi'] = $data['throw_cost']>0? round($order->order_amount / $data['throw_cost'], 4) * 100 .'%' : '';
|
4644
|
|
-
|
|
4654
|
+ //总新粉单数
|
|
4655
|
+ $new_order = Order::select(DB::raw('count(1) as order_count'))->leftJoin('customers as cu','cu.phone', '=', 'order.receiverMobile')->whereRaw('left(order.createTime, 10) = cu.fanTime')->where('order.is_del', 0)->where('order.createTime','>=',$_start)->first();
|
|
4656
|
+ $data['new_order_count'] = $new_order->order_count;
|
|
4657
|
+ //总老粉单数
|
|
4658
|
+ $data['old_order_count'] = $data['order_count'] - $data['new_order_count'];
|
|
4659
|
+ //总复购订单
|
|
4660
|
+ $data['fugou_order_count'] = $data['order_count'] - $data['cust_count'];
|
|
4661
|
+ //总复购率
|
|
4662
|
+ $data['fugou_rate'] = $data['cust_count']>0 ? round($data['fugou_order_count'] / $data['cust_count'], 4) : '';
|
|
4663
|
+
|
4645
|
4664
|
$result = DB::table('day_grand_total')->orderBy('idate', 'desc')->get();
|
4646
|
4665
|
$result = json_decode(json_encode($result), true);
|
4647
|
4666
|
foreach($result as $k=>&$v){
|
4648
|
4667
|
$v['roi'] = $v['throw_cost']>0 ? round($v['order_amount'] / $v['throw_cost'], 4) * 100 .'%' : '';
|
|
4668
|
+ $v['fugou_rate'] = $v['cust_count']>0 ? round($v['fugou_order_count'] / $v['cust_count'], 4) : '';
|
4649
|
4669
|
}
|
4650
|
4670
|
$result = array_merge([$data], $result);
|
4651
|
4671
|
|