From 0eaddeac553cf7fef05d360512707d4f506e9888 Mon Sep 17 00:00:00 2001 From: BrettonYe <867057410@qq.com> Date: Thu, 12 Oct 2023 23:21:17 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7Fixed=20Type=20declare=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/TaskHourly.php | 2 +- app/Notifications/DataExhaust.php | 2 +- app/Services/PaymentService.php | 4 ++-- app/Services/ProxyService.php | 2 +- app/Utils/Helpers.php | 6 +++--- app/Utils/Library/AlipayF2F.php | 14 +++++++------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/Console/Commands/TaskHourly.php b/app/Console/Commands/TaskHourly.php index 8a5bd9d9..d5f5719c 100644 --- a/app/Console/Commands/TaskHourly.php +++ b/app/Console/Commands/TaskHourly.php @@ -59,7 +59,7 @@ class TaskHourly extends Command // 用户流量异常警告 if ($data_anomaly_notification && $overall['total'] >= $traffic_ban_value) { - Notification::send(User::find(1), new DataAnomaly($user->username, formatBytes($overall['u']), formatBytes($overall['d']), formatBytes($overall['total']))); + Notification::send(User::find(1), new DataAnomaly($user->id, formatBytes($overall['u']), formatBytes($overall['d']), formatBytes($overall['total']))); } } }); diff --git a/app/Notifications/DataExhaust.php b/app/Notifications/DataExhaust.php index ee91ea72..83264962 100644 --- a/app/Notifications/DataExhaust.php +++ b/app/Notifications/DataExhaust.php @@ -15,7 +15,7 @@ class DataExhaust extends Notification implements ShouldQueue public function __construct(float|int $percent) { - $this->percent = $percent; + $this->percent = round($percent, 2); } public function via($notifiable) diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 840513ac..3d27ddf6 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -15,7 +15,7 @@ class PaymentService $payment->trade_no = Str::random(8); $payment->user_id = $uid; $payment->order_id = $oid; - $payment->amount = $amount; + $payment->amount = round($amount, 2); $payment->save(); return $payment; @@ -31,7 +31,7 @@ class PaymentService $log = new PaymentCallback(); $log->trade_no = $trade_no; $log->out_trade_no = $out_trade_no; - $log->amount = $amount; + $log->amount = round($amount, 2); return $log->save(); } diff --git a/app/Services/ProxyService.php b/app/Services/ProxyService.php index ebc24208..4114e2e8 100644 --- a/app/Services/ProxyService.php +++ b/app/Services/ProxyService.php @@ -155,7 +155,7 @@ class ProxyService return $config; } - public function failedProxyReturn(string $text, int $type = 1): string + public function failedProxyReturn(string $text, ?int $type = 1): string { $url = sysConfig('website_url'); diff --git a/app/Utils/Helpers.php b/app/Utils/Helpers.php index b8b0a726..7767c72e 100644 --- a/app/Utils/Helpers.php +++ b/app/Utils/Helpers.php @@ -182,9 +182,9 @@ class Helpers $log = new UserCreditLog(); $log->user_id = $userId; $log->order_id = $orderId; - $log->before = $before; - $log->after = $after; - $log->amount = $amount; + $log->before = round($before, 2); + $log->after = round($after, 2); + $log->amount = round($amount, 2); $log->description = $description; $log->created_at = date('Y-m-d H:i:s'); diff --git a/app/Utils/Library/AlipayF2F.php b/app/Utils/Library/AlipayF2F.php index e75cad2e..90847273 100644 --- a/app/Utils/Library/AlipayF2F.php +++ b/app/Utils/Library/AlipayF2F.php @@ -17,7 +17,7 @@ class AlipayF2F private array $config; - public function __construct(array $rawConfig = []) + public function __construct(array $rawConfig) { $config = [ 'app_id' => $rawConfig['app_id'], @@ -70,7 +70,7 @@ class AlipayF2F return $beginStr.wordwrap($keyStr, 64, "\n", true).$endStr; } - public function tradeQuery($content) + public function tradeQuery(array $content): array { $this->setMethod('alipay.trade.query'); $this->setContent($content); @@ -78,12 +78,12 @@ class AlipayF2F return $this->send(); } - private function setMethod($method): void + private function setMethod(string $method): void { $this->config['method'] = $method; } - private function setContent($content): void + private function setContent(array $content): void { $content = array_filter($content); ksort($content); @@ -92,7 +92,7 @@ class AlipayF2F private function send(): array { - $response = Http::timeout(15)->get(self::$gatewayUrl, $this->buildParams())->json(); + $response = Http::timeout(15)->retry(2)->get(self::$gatewayUrl, $this->buildParams())->json(); $resKey = str_replace('.', '_', $this->config['method']).'_response'; if (! isset($response[$resKey])) { throw new RuntimeException('请求错误-看起来是请求失败'); @@ -161,7 +161,7 @@ class AlipayF2F * * @throws RuntimeException */ - public function rsaVerify(array $data, $sign): bool + public function rsaVerify(array $data, string $sign): bool { unset($data['sign'], $data['sign_type']); $publicKey = openssl_pkey_get_public($this->config['public_key']); @@ -172,7 +172,7 @@ class AlipayF2F return (bool) openssl_verify(json_encode($data), base64_decode($sign), $publicKey, OPENSSL_ALGO_SHA256); } - public function qrCharge($content) + public function qrCharge(array $content): array { $this->setMethod('alipay.trade.precreate'); $this->setContent($content);