tokumeikoi 3 years ago
parent
commit
b0c818c661
2 changed files with 8 additions and 5 deletions
  1. 7 4
      app/Services/UserService.php
  2. 1 1
      app/Utils/CacheKey.php

+ 7 - 4
app/Services/UserService.php

@@ -87,10 +87,13 @@ class UserService
         if (!$user) {
             return true;
         }
-        $user->t = time();
-        $user->u = $user->u + $u;
-        $user->d = $user->d + $d;
-        if (!$user->save()) {
+        try {
+            $user->update([
+                't' => time(),
+                'u' => DB::raw("u + {$u}"),
+                'd' => DB::raw("d + {$d}")
+            ]);
+        } catch (\Exception $e) {
             return false;
         }
         $mailService = new MailService();

+ 1 - 1
app/Utils/CacheKey.php

@@ -17,7 +17,7 @@ class CacheKey
         'SERVER_SHADOWSOCKS_LAST_CHECK_AT' => 'ss节点最后检查时间',
         'SERVER_SHADOWSOCKS_LAST_PUSH_AT' => 'ss节点最后推送时间',
         'TEMP_TOKEN' => '临时令牌',
-        'LAST_SEND_EMAIL_REMIND_TRAFFIC'
+        'LAST_SEND_EMAIL_REMIND_TRAFFIC' => '最后发送流量邮件提醒'
     ];
 
     public static function get(string $key, $uniqueValue)