mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: add statis api
This commit is contained in:
parent
76f4a1764b
commit
9db5d3d483
@ -50,7 +50,7 @@ class CheckCommission extends Command
|
|||||||
if ((int)config('v2board.commission_auto_check_enable', 1)) {
|
if ((int)config('v2board.commission_auto_check_enable', 1)) {
|
||||||
Order::where('commission_status', 0)
|
Order::where('commission_status', 0)
|
||||||
->where('invite_user_id', '!=', NULL)
|
->where('invite_user_id', '!=', NULL)
|
||||||
->whereNotIn('status', [0, 2])
|
->where('status', 3)
|
||||||
->where('updated_at', '<=', strtotime('-3 day', time()))
|
->where('updated_at', '<=', strtotime('-3 day', time()))
|
||||||
->update([
|
->update([
|
||||||
'commission_status' => 1
|
'commission_status' => 1
|
||||||
|
@ -57,6 +57,22 @@ class StatController extends Controller
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStatRecord(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'type' => 'required|in:order_total,commission_total,register_count',
|
||||||
|
'start_at' => '',
|
||||||
|
'end_at'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$statisticalService = new StatisticalService();
|
||||||
|
$statisticalService->setStartAt($request->input('start_at'));
|
||||||
|
$statisticalService->setEndAt($request->input('end_at'));
|
||||||
|
return [
|
||||||
|
'data' => $statisticalService->getStatRecord($request->input('type'))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function getOverride(Request $request)
|
public function getOverride(Request $request)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -175,4 +175,36 @@ class StatisticalService {
|
|||||||
{
|
{
|
||||||
Cache::forget("stat_server_{$this->startAt}");
|
Cache::forget("stat_server_{$this->startAt}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStatRecord($type)
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case "order_total": {
|
||||||
|
return Stat::select([
|
||||||
|
'*',
|
||||||
|
DB::raw('order_total / 100 as order_total')
|
||||||
|
])
|
||||||
|
->where('record_at', '>=', $this->startAt)
|
||||||
|
->where('record_at', '<', $this->endAt)
|
||||||
|
->orderBy('record_at', 'ASC')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
case "commission_total": {
|
||||||
|
return Stat::select([
|
||||||
|
'*',
|
||||||
|
DB::raw('commission_total / 100 as commission_total')
|
||||||
|
])
|
||||||
|
->where('record_at', '>=', $this->startAt)
|
||||||
|
->where('record_at', '<', $this->endAt)
|
||||||
|
->orderBy('record_at', 'ASC')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
case "register_count": {
|
||||||
|
return Stat::where('record_at', '>=', $this->startAt)
|
||||||
|
->where('record_at', '<', $this->endAt)
|
||||||
|
->orderBy('record_at', 'ASC')
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user