|
@@ -309,7 +309,7 @@ class StatisticsController extends Controller
|
309
|
309
|
//当日加粉
|
310
|
310
|
$phones = DB::table('customers')->where('fanTime', $v['dtime'])->lists('phone');
|
311
|
311
|
#当日加粉订单总计:
|
312
|
|
- $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count, sum(cost) as order_cost'))->whereIn('receiverMobile', $phones)->where('createTime','<',$end_time)->where('is_del', 0)->where(function($query) use($team_id){
|
|
312
|
+ $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('createTime','<',$end_time)->where('is_del', 0)->where(function($query) use($team_id){
|
313
|
313
|
if($team_id>0) $query->where('team_id', $team_id);
|
314
|
314
|
})->first();
|
315
|
315
|
#当日新粉成单:
|
|
@@ -339,8 +339,10 @@ class StatisticsController extends Controller
|
339
|
339
|
$v['fugou_order_amount'] = $fugou->order_amount;
|
340
|
340
|
#货品成本
|
341
|
341
|
$v['order_cost'] = $order->order_cost;
|
|
342
|
+ //加物流成本
|
|
343
|
+ $v['freight_cost'] = $order->freight_cost;
|
342
|
344
|
#毛利
|
343
|
|
- $v['profit'] = $v['order_amount'] - $v['order_cost'] - $v['total_cost'];
|
|
345
|
+ $v['profit'] = $v['order_amount'] - $v['order_cost'] - $v['total_cost'] - $v['freight_cost'];
|
344
|
346
|
//综合成单率 综合成单率=订单数/微信好友数
|
345
|
347
|
$v['order_rate'] = $custDetail->wx_fan_add>0 ? round($order->order_count/$custDetail->wx_fan_add, 4) * 100 .'%' : '';
|
346
|
348
|
//新粉成单率
|
|
@@ -351,7 +353,7 @@ class StatisticsController extends Controller
|
351
|
353
|
|
352
|
354
|
//加roi
|
353
|
355
|
$v['total_roi'] = $v['total_cost']>0 ? round($v['order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
|
354
|
|
- $v['new_roi'] = $v['total_cost']>0 ? round($v['new_order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
|
|
356
|
+ $v['new_roi'] = $v['total_cost']>0 ? round($v['new_order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
|
355
|
357
|
|
356
|
358
|
}
|
357
|
359
|
|