mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: statistics
This commit is contained in:
parent
d9bd54cbc5
commit
76f4a1764b
@ -117,6 +117,8 @@ class V2boardStatistics extends Command
|
|||||||
$statisticalService->setStartAt($startAt);
|
$statisticalService->setStartAt($startAt);
|
||||||
$statisticalService->setEndAt($endAt);
|
$statisticalService->setEndAt($endAt);
|
||||||
$data = $statisticalService->generateStatData();
|
$data = $statisticalService->generateStatData();
|
||||||
|
$data['record_at'] = $startAt;
|
||||||
|
$data['record_type'] = 'd';
|
||||||
$statistic = Stat::where('record_at', $startAt)
|
$statistic = Stat::where('record_at', $startAt)
|
||||||
->where('record_type', 'd')
|
->where('record_type', 'd')
|
||||||
->first();
|
->first();
|
||||||
|
@ -36,6 +36,11 @@ class StatController extends Controller
|
|||||||
->get()
|
->get()
|
||||||
->makeHidden(['record_at', 'created_at', 'updated_at', 'id', 'record_type'])
|
->makeHidden(['record_at', 'created_at', 'updated_at', 'id', 'record_type'])
|
||||||
->toArray();
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
$statisticalService = new StatisticalService();
|
||||||
|
$stats = array_merge($stats ?? [], [$statisticalService->generateStatData()]);
|
||||||
|
|
||||||
$stats = array_reduce($stats, function($carry, $item) {
|
$stats = array_reduce($stats, function($carry, $item) {
|
||||||
foreach($item as $key => $value) {
|
foreach($item as $key => $value) {
|
||||||
if(isset($carry[$key]) && $carry[$key]) {
|
if(isset($carry[$key]) && $carry[$key]) {
|
||||||
@ -46,17 +51,12 @@ class StatController extends Controller
|
|||||||
}
|
}
|
||||||
return $carry;
|
return $carry;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'data' => $stats
|
'data' => $stats
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$statisticalService = new StatisticalService();
|
|
||||||
return [
|
|
||||||
'data' => $statisticalService->generateStatData()
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOverride(Request $request)
|
public function getOverride(Request $request)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
@ -106,12 +106,12 @@ class StatController extends Controller
|
|||||||
$result[] = [
|
$result[] = [
|
||||||
'type' => '收款金额',
|
'type' => '收款金额',
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'value' => $statistic['order_total'] / 100
|
'value' => $statistic['paid_total'] / 100
|
||||||
];
|
];
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'type' => '收款笔数',
|
'type' => '收款笔数',
|
||||||
'date' => $date,
|
'date' => $date,
|
||||||
'value' => $statistic['order_count']
|
'value' => $statistic['paid_count']
|
||||||
];
|
];
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'type' => '佣金金额(已发放)',
|
'type' => '佣金金额(已发放)',
|
||||||
|
@ -52,11 +52,7 @@ class StatisticalService {
|
|||||||
$startAt = strtotime(date('Y-m-d'));
|
$startAt = strtotime(date('Y-m-d'));
|
||||||
$endAt = strtotime('+1 day', $startAt);
|
$endAt = strtotime('+1 day', $startAt);
|
||||||
}
|
}
|
||||||
$data = [
|
$data = [];
|
||||||
'record_type' => 'd',
|
|
||||||
'paid_rate' => 0,
|
|
||||||
'record_at' => $startAt
|
|
||||||
];
|
|
||||||
$data['order_count'] = Order::where('created_at', '>=', $startAt)
|
$data['order_count'] = Order::where('created_at', '>=', $startAt)
|
||||||
->where('created_at', '<', $endAt)
|
->where('created_at', '<', $endAt)
|
||||||
->count();
|
->count();
|
||||||
|
@ -687,13 +687,13 @@ ALTER TABLE `v2_plan`
|
|||||||
ALTER TABLE `v2_stat_order`
|
ALTER TABLE `v2_stat_order`
|
||||||
CHANGE `record_at` `record_at` int(11) NOT NULL AFTER `id`,
|
CHANGE `record_at` `record_at` int(11) NOT NULL AFTER `id`,
|
||||||
CHANGE `record_type` `record_type` char(1) COLLATE 'utf8_general_ci' NOT NULL AFTER `record_at`,
|
CHANGE `record_type` `record_type` char(1) COLLATE 'utf8_general_ci' NOT NULL AFTER `record_at`,
|
||||||
CHANGE `order_count` `order_count` int(11) NOT NULL COMMENT '订单数量' AFTER `record_type`,
|
CHANGE `order_count` `paid_count` int(11) NOT NULL COMMENT '订单数量' AFTER `record_type`,
|
||||||
CHANGE `order_amount` `order_total` int(11) NOT NULL COMMENT '订单合计' AFTER `order_count`,
|
CHANGE `order_amount` `paid_total` int(11) NOT NULL COMMENT '订单合计' AFTER `paid_count`,
|
||||||
CHANGE `commission_count` `commission_count` int(11) NOT NULL AFTER `order_total`,
|
CHANGE `commission_count` `commission_count` int(11) NOT NULL AFTER `paid_total`,
|
||||||
CHANGE `commission_amount` `commission_total` int(11) NOT NULL COMMENT '佣金合计' AFTER `commission_count`,
|
CHANGE `commission_amount` `commission_total` int(11) NOT NULL COMMENT '佣金合计' AFTER `commission_count`,
|
||||||
ADD `paid_count` int(11) NOT NULL AFTER `commission_total`,
|
ADD `order_count` int(11) NOT NULL AFTER `record_type`,
|
||||||
ADD `paid_total` int(11) NOT NULL AFTER `paid_count`,
|
ADD `order_total` int(11) NOT NULL AFTER `order_count`,
|
||||||
ADD `register_count` int(11) NOT NULL AFTER `paid_total`,
|
ADD `register_count` int(11) NOT NULL AFTER `order_total`,
|
||||||
ADD `invite_count` int(11) NOT NULL AFTER `register_count`,
|
ADD `invite_count` int(11) NOT NULL AFTER `register_count`,
|
||||||
ADD `transfer_used_total` varchar(32) NOT NULL AFTER `invite_count`,
|
ADD `transfer_used_total` varchar(32) NOT NULL AFTER `invite_count`,
|
||||||
RENAME TO `v2_stat`;
|
RENAME TO `v2_stat`;
|
||||||
|
Loading…
Reference in New Issue
Block a user