Ken 3 days ago
parent
commit
38234fb090
2 changed files with 8 additions and 8 deletions
  1. 2 2
      app/Http/Controllers/api/ActivityReward.php
  2. 6 6
      app/Services/SmsService.php

+ 2 - 2
app/Http/Controllers/api/ActivityReward.php

@@ -34,7 +34,7 @@ class ActivityReward extends BaseController
 //            $key = 'api_request_' . md5(json_encode($keys));
 //            if (Cache::has($key)) throw new Exception("请求太频繁,请稍后再试。", HttpStatus::CUSTOM_ERROR);
 //            Cache::put($key, true, 60);
-            SmsService::sendPhoneCode($params['phone']);
+            $code = SmsService::sendPhoneCode($params['phone']);
         } catch (ValidationException $e) {
 
             return $this->error($e->validator->errors()->first());
@@ -42,7 +42,7 @@ class ActivityReward extends BaseController
 
             return $this->error($e->getMessage(), [], $e->getCode());
         }
-        return $this->success();
+        return $this->success($code);
     }
 
     public function participate(): JsonResponse

+ 6 - 6
app/Services/SmsService.php

@@ -19,10 +19,9 @@ class SmsService
 
     /**
      * @param $phone
-     * @return void
      * @throws Exception
      */
-    public static function sendPhoneCode($phone): void
+    public static function sendPhoneCode($phone)
     {
 
         $username = config('services.sms.username');
@@ -37,9 +36,10 @@ class SmsService
         $url .= "&c=" . urlencode($content);
         $url .= "&m=" . $phone;
         $code = file_get_contents($url);
-        if (!empty(static::$errors[$code])) {
-            throw new Exception(static::$errors[$code], HttpStatus::CUSTOM_ERROR);
-        }
-        if ($code != 0) throw new Exception("发送失败:$code", HttpStatus::CUSTOM_ERROR);
+        return $code;
+//        if (!empty(static::$errors[$code])) {
+//            throw new Exception(static::$errors[$code], HttpStatus::CUSTOM_ERROR);
+//        }
+//        if ($code != 0) throw new Exception("发送失败:$code", HttpStatus::CUSTOM_ERROR);
     }
 }