|
|
|
|
@ -208,13 +208,20 @@ class StatisticsController extends CommonController
|
|
|
|
|
$checkout = $model_checkout->sum("total");
|
|
|
|
|
$refund = $model_refund->sum("money");
|
|
|
|
|
$payment_methods = (new Recharge())->payment_methods;
|
|
|
|
|
$payment_online_methods = (new Recharge())->payment_online_methods;
|
|
|
|
|
|
|
|
|
|
$recharge_by_payment = $model_recharge->select("payment", "paid_at", "money", "order_id")->addSelect(DB::raw("sum(`money`) as total"))->groupBy("payment")->get()->keyBy("payment")->toArray();
|
|
|
|
|
$recharge = [];
|
|
|
|
|
$recharge["total"] = collect($recharge_by_payment)->sum("total");
|
|
|
|
|
$recharge["total_online"] = collect($recharge_by_payment)->filter(function($item) use ($payment_online_methods) {
|
|
|
|
|
return in_array($item["payment"], array_keys($payment_online_methods));
|
|
|
|
|
})->sum("total");
|
|
|
|
|
|
|
|
|
|
foreach ($payment_methods as $k => $v) {
|
|
|
|
|
$val = isset($recharge_by_payment[$k]) ? $recharge_by_payment[$k]["total"] : 0;
|
|
|
|
|
$recharge[$k] = $val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response()->json(compact("checkout", "refund", "recharge", "payment_methods"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|