|
@@ -9,6 +9,7 @@ use App\Services\ActivityRewardService;
|
|
|
use App\Services\ActivityUserService;
|
|
use App\Services\ActivityUserService;
|
|
|
use App\Services\UserService;
|
|
use App\Services\UserService;
|
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
use Illuminate\Validation\ValidationException;
|
|
|
use Exception;
|
|
use Exception;
|
|
@@ -17,6 +18,30 @@ use Exception;
|
|
|
class ActivityReward extends BaseController
|
|
class ActivityReward extends BaseController
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
|
|
+ //发送手机验证码
|
|
|
|
|
+ public function sendPhoneCode()
|
|
|
|
|
+ {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $params = request()->validate([
|
|
|
|
|
+ 'member_id' => ['required', 'integer'],
|
|
|
|
|
+ 'phone' => ['required', 'string'],
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $params['action'] = request()->action;
|
|
|
|
|
+ $key = 'api_request_' . md5(json_encode($params));
|
|
|
|
|
+ if (Cache::has($key)) throw new Exception("请求太频繁,请稍后再试。", HttpStatus::CUSTOM_ERROR);
|
|
|
|
|
+ Cache::put($key, true, 3);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } catch (ValidationException $e) {
|
|
|
|
|
+
|
|
|
|
|
+ return $this->error($e->validator->errors()->first());
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+
|
|
|
|
|
+ return $this->error($e->getMessage(), [], $e->getCode());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function participate(): JsonResponse
|
|
public function participate(): JsonResponse
|
|
|
{
|
|
{
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|