From 06adaa2124ed43918db63e472c8ce82ac889a35c Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Sat, 31 Jul 2021 02:21:49 +0900 Subject: [PATCH] update: fix order statistics --- app/Console/Commands/V2boardStatistics.php | 4 ++-- app/Services/OrderService.php | 1 + database/install.sql | 3 ++- database/update.sql | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/V2boardStatistics.php b/app/Console/Commands/V2boardStatistics.php index 9be5ece5..6a25b439 100644 --- a/app/Console/Commands/V2boardStatistics.php +++ b/app/Console/Commands/V2boardStatistics.php @@ -50,8 +50,8 @@ class V2boardStatistics extends Command { $endAt = strtotime(date('Y-m-d')); $startAt = strtotime('-1 day', $endAt); - $builder = Order::where('created_at', '>=', $startAt) - ->where('created_at', '<', $endAt) + $builder = Order::where('paid_at', '>=', $startAt) + ->where('paid_at', '<', $endAt) ->whereNotIn('status', [0, 2]); $orderCount = $builder->count(); $orderAmount = $builder->sum('total_amount'); diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 99ede9ee..e5fd0ff7 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -239,6 +239,7 @@ class OrderService return true; } $order->status = 1; + $order->paid_at = time(); $order->callback_no = $callbackNo; return $order->save(); } diff --git a/database/install.sql b/database/install.sql index e53b2985..3aab50ce 100644 --- a/database/install.sql +++ b/database/install.sql @@ -110,6 +110,7 @@ CREATE TABLE `v2_order` ( `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0待支付1开通中2已取消3已完成4已折抵', `commission_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0待确认1发放中2有效3无效', `commission_balance` int(11) NOT NULL DEFAULT '0', + `paid_at` int(11) DEFAULT NULL, `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, PRIMARY KEY (`id`) @@ -348,4 +349,4 @@ CREATE TABLE `v2_user` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- 2021-07-13 13:50:52 +-- 2021-07-30 17:19:01 diff --git a/database/update.sql b/database/update.sql index c987a7bd..9f35b429 100644 --- a/database/update.sql +++ b/database/update.sql @@ -425,3 +425,6 @@ DROP INDEX `email_deleted_at`; ALTER TABLE `v2_user` ADD `commission_type` tinyint NOT NULL DEFAULT '0' COMMENT '0: system 1: cycle 2: onetime' AFTER `discount`; + +ALTER TABLE `v2_order` + ADD `paid_at` int(11) NULL AFTER `commission_balance`;