|
|
|
|
@ -551,11 +551,16 @@ class StatisticsController extends CommonController
|
|
|
|
|
$total['order_total'] = $total['shouxufei'] = $total['zengshishui'] = $total['shijishouru'] = $total['guanlifei'] = 0;
|
|
|
|
|
$area = [];
|
|
|
|
|
foreach ($areaList as $item) {
|
|
|
|
|
$beds = Bed::where('area_id', $item->id)->where('project_id', $project_id)->get();
|
|
|
|
|
// 订单总数
|
|
|
|
|
$orders = Orders::where('project_id', $project_id)
|
|
|
|
|
// ->where('created_at', 'like', '%' . $month . '%')
|
|
|
|
|
->whereIn('bed_id', $beds->pluck('id'))
|
|
|
|
|
->get();
|
|
|
|
|
$orderTotal = Balance::where('created_at', 'like', '%' . $month . '%')
|
|
|
|
|
->whereHas("order", function ($query) use ($project_id) {
|
|
|
|
|
$query->where("project_id", $project_id);
|
|
|
|
|
})->sum("money");
|
|
|
|
|
->where('belongs_type', 'App\Models\Recharge')
|
|
|
|
|
->where('order_id', $orders->pluck('id'))
|
|
|
|
|
->sum("money");
|
|
|
|
|
$item->order_total = $orderTotal;
|
|
|
|
|
$item->shouxufei = round($orderTotal * 0.006, 2);
|
|
|
|
|
$item->zengshishui = round($orderTotal * 0.06, 2);
|
|
|
|
|
@ -573,13 +578,17 @@ class StatisticsController extends CommonController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取所有订单数据
|
|
|
|
|
$beds = Bed::whereIn('area_id', $areaList->pluck('id'))->where('project_id', $project_id)->get();
|
|
|
|
|
// 订单总数
|
|
|
|
|
$allOrderTotal = Orders::where('project_id', $project_id)
|
|
|
|
|
->where('created_at', 'like', '%' . $month . '%')
|
|
|
|
|
->whereIn('bed_id', $beds->pluck('id'))
|
|
|
|
|
->get();
|
|
|
|
|
$refund['order_total'] = Refund::where('created_at', 'like', '%' . $month . '%')->whereIn('order_id', $allOrderTotal->pluck('id'))->sum('money');
|
|
|
|
|
// $beds = Bed::whereIn('area_id', $areaList->pluck('id'))->where('project_id', $project_id)->get();
|
|
|
|
|
// // 订单总数
|
|
|
|
|
// $allOrderTotal = Orders::where('project_id', $project_id)
|
|
|
|
|
// ->where('created_at', 'like', '%' . $month . '%')
|
|
|
|
|
// ->whereIn('bed_id', $beds->pluck('id'))
|
|
|
|
|
// ->get();
|
|
|
|
|
$refund['order_total'] = Balance::where('created_at', 'like', '%' . $month . '%')
|
|
|
|
|
->where('belongs_type', 'App\Models\Refund')
|
|
|
|
|
->whereHas("order", function ($query) use ($project_id) {
|
|
|
|
|
$query->where("project_id", $project_id);
|
|
|
|
|
})->sum("money");
|
|
|
|
|
$refund['shijishouru'] = $refund['order_total'];
|
|
|
|
|
$refund['guanlifei'] = round($refund['order_total'] * 0.06, 2);
|
|
|
|
|
// 总计
|
|
|
|
|
|