From 508961c4fb1621e150fad8c7bbace2867946a537 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Jan 2020 13:57:30 +0800 Subject: [PATCH] update --- app/Console/Commands/V2boardCache.php | 23 ------------------- app/Http/Controllers/Admin/MailController.php | 2 +- app/Http/Controllers/Admin/StatController.php | 10 +++++--- app/Http/Controllers/AppController.php | 4 ++-- .../Controllers/Passport/CommController.php | 23 ++++++++----------- 5 files changed, 20 insertions(+), 42 deletions(-) diff --git a/app/Console/Commands/V2boardCache.php b/app/Console/Commands/V2boardCache.php index 1227fd80..79a1d216 100644 --- a/app/Console/Commands/V2boardCache.php +++ b/app/Console/Commands/V2boardCache.php @@ -43,28 +43,5 @@ class V2boardCache extends Command */ public function handle() { - $this->setMonthIncome(); - $this->setMonthRegisterTotal(); - } - - private function setMonthIncome() - { - Cache::put( - 'month_income', - Order::where('created_at', '>=', strtotime(date('Y-m-1'))) - ->where('created_at', '<', time()) - ->where('status', '3') - ->sum('total_amount') - ); - } - - private function setMonthRegisterTotal() - { - Cache::put( - 'month_register_total', - User::where('created_at', '>=', strtotime(date('Y-m-1'))) - ->where('created_at', '<', time()) - ->count() - ); } } diff --git a/app/Http/Controllers/Admin/MailController.php b/app/Http/Controllers/Admin/MailController.php index 1ffdcca3..02185a6e 100644 --- a/app/Http/Controllers/Admin/MailController.php +++ b/app/Http/Controllers/Admin/MailController.php @@ -32,7 +32,7 @@ class MailController extends Controller 'url' => config('v2board.app_url'), 'content' => $request->input('content') ] - ]); + ])->onQueue('other_mail'); } return response([ diff --git a/app/Http/Controllers/Admin/StatController.php b/app/Http/Controllers/Admin/StatController.php index 30181087..d3110fa7 100644 --- a/app/Http/Controllers/Admin/StatController.php +++ b/app/Http/Controllers/Admin/StatController.php @@ -18,15 +18,19 @@ class StatController extends Controller { return response([ 'data' => [ - 'month_income' => Cache::get('month_income'), - 'month_register_total' => Cache::get('month_register_total'), + 'month_income' => Order::where('created_at', '>=', strtotime(date('Y-m-1'))) + ->where('created_at', '<', time()) + ->where('status', '3') + ->sum('total_amount'), + 'month_register_total' => User::where('created_at', '>=', strtotime(date('Y-m-1'))) + ->where('created_at', '<', time()) + ->count(), 'ticket_pendding_total' => Ticket::where('status', 0) ->count(), 'commission_pendding_total' => Order::where('commission_status', 0) ->where('invite_user_id', '!=', NULL) ->where('status', 3) ->count(), - ] ]); } diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index a60a6b3d..99e97f51 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -12,7 +12,7 @@ use App\Utils\Helper; class AppController extends Controller { - CONST CLIENT_CONFIG = '{"policy":{"levels":{"0":{"uplinkOnly":0}}},"dns":{"servers":["114.114.114.114","8.8.8.8"]},"outboundDetour":[{"protocol":"freedom","tag":"direct","settings":{}}],"inbound":{"listen":"0.0.0.0","port":31211,"protocol":"socks","settings":{"auth":"noauth","udp":true,"ip":"127.0.0.1"}},"inboundDetour":[{"listen":"0.0.0.0","allocate":{"strategy":"always","refresh":5,"concurrency":3},"port":31210,"protocol":"http","tag":"httpDetour","domainOverride":["http","tls"],"streamSettings":{},"settings":{"timeout":0}}],"routing":{"strategy":"rules","settings":{"domainStrategy":"IPIfNonMatch","rules":[{"type":"field","ip":["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.2.0/24","192.168.0.0/16","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","::1/128","fc00::/7","fe80::/10"],"outboundTag":"direct"},{"type":"field","ip":["geoip:cn"],"outboundTag":"direct"}]}},"outbound":{"tag":"proxy","sendThrough":"0.0.0.0","mux":{"enabled":false,"concurrency":8},"protocol":"vmess","settings":{"vnext":[{"address":"server","port":443,"users":[{"id":"uuid","alterId":2,"security":"auto","level":0}],"remark":"remark"}]},"streamSettings":{"network":"tcp","tcpSettings":{"header":{"type":"none"}},"security":"none","tlsSettings":{"allowInsecure":true,"allowInsecureCiphers":true},"kcpSettings":{"header":{"type":"none"},"mtu":1350,"congestion":false,"tti":20,"uplinkCapacity":5,"writeBufferSize":1,"readBufferSize":1,"downlinkCapacity":20},"wsSettings":{"path":"","headers":{"Host":"server.cc"}}}}}'; + CONST CLIENT_CONFIG = '{"policy":{"levels":{"0":{"uplinkOnly":0}}},"dns":{"servers":["114.114.114.114","8.8.8.8"]},"outboundDetour":[{"protocol":"freedom","tag":"direct","settings":{}}],"inbound":{"listen":"0.0.0.0","port":31211,"protocol":"socks","settings":{"auth":"noauth","udp":true,"ip":"127.0.0.1"}},"inboundDetour":[{"listen":"0.0.0.0","allocate":{"strategy":"always","refresh":5,"concurrency":3},"port":31210,"protocol":"http","tag":"httpDetour","domainOverride":["http","tls"],"streamSettings":{},"settings":{"timeout":0}}],"routing":{"strategy":"rules","settings":{"domainStrategy":"IPIfNonMatch","rules":[{"type":"field","ip":["geoip:cn"],"outboundTag":"direct"},{"type":"field","ip":["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.2.0/24","192.168.0.0/16","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","::1/128","fc00::/7","fe80::/10"],"outboundTag":"direct"}]}},"outbound":{"tag":"proxy","sendThrough":"0.0.0.0","mux":{"enabled":false,"concurrency":8},"protocol":"vmess","settings":{"vnext":[{"address":"server","port":443,"users":[{"id":"uuid","alterId":2,"security":"auto","level":0}],"remark":"remark"}]},"streamSettings":{"network":"tcp","tcpSettings":{"header":{"type":"none"}},"security":"none","tlsSettings":{"allowInsecure":true,"allowInsecureCiphers":true},"kcpSettings":{"header":{"type":"none"},"mtu":1350,"congestion":false,"tti":20,"uplinkCapacity":5,"writeBufferSize":1,"readBufferSize":1,"downlinkCapacity":20},"wsSettings":{"path":"","headers":{"Host":"server.cc"}}}}}'; CONST SOCKS_PORT = 10010; CONST HTTP_PORT = 10011; @@ -100,7 +100,7 @@ class AppController extends Controller } } if ($request->input('is_global')) { - $json->routing->settings->rules[5]->outboundTag = 'proxy'; + $json->routing->settings->rules[0]->outboundTag = 'proxy'; } if ($server->tls) { $json->outbound->streamSettings->security = "tls"; diff --git a/app/Http/Controllers/Passport/CommController.php b/app/Http/Controllers/Passport/CommController.php index 46a0208a..2135f8a8 100644 --- a/app/Http/Controllers/Passport/CommController.php +++ b/app/Http/Controllers/Passport/CommController.php @@ -9,6 +9,7 @@ use Illuminate\Http\Exceptions\HttpResponseException; use Illuminate\Support\Facades\Mail; use App\Utils\Helper; use Illuminate\Support\Facades\Cache; +use App\Jobs\SendEmail; class CommController extends Controller { @@ -38,21 +39,17 @@ class CommController extends Controller } $code = Helper::randomChar(6); $subject = config('v2board.app_name', 'V2Board') . '邮箱验证码'; - Mail::send( - 'mail.sendEmailVerify', - [ - 'code' => $code, + + SendEmail::dispatch([ + 'email' => $user->email, + 'subject' => $subject, + 'template_name' => 'mail.sendEmailVerify', + 'template_value' => [ 'name' => config('v2board.app_name', 'V2Board'), + 'code' => $code, 'url' => config('v2board.app_url') - ], - function ($message) use ($email, $subject) { - $message->to($email)->subject($subject); - } - ); - if (count(Mail::failures()) >= 1) { - // 发送失败 - abort(500, '发送失败'); - } + ] + ])->onQueue('verify_mail'); Cache::put($cacheKey, $code, 60); return response([