|
|
@@ -7,6 +7,7 @@ use App\Models\ActivityReward as ActivityRewardModel;
|
|
|
use App\Models\ActivityUser;
|
|
|
use App\Services\ActivityRewardService;
|
|
|
use App\Services\ActivityUserService;
|
|
|
+use App\Services\PhoneCodeService;
|
|
|
use App\Services\SmsService;
|
|
|
use App\Services\UserService;
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
@@ -19,8 +20,26 @@ use Exception;
|
|
|
class ActivityReward extends BaseController
|
|
|
{
|
|
|
|
|
|
+ public function verifyPhone(): JsonResponse
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $params = request()->validate([
|
|
|
+ 'member_id' => ['required', 'integer'],
|
|
|
+ 'phone' => ['required', 'string'],
|
|
|
+ 'code' => ['required', 'string'],
|
|
|
+ 'visitor_id' => ['required', 'string', 'min:1', 'max:32'],
|
|
|
+ ]);
|
|
|
+ PhoneCodeService::verify($params['phone'], $params['code'], $params['member_id'], $params['visitor_id']);
|
|
|
+ } catch (ValidationException $e) {
|
|
|
+ return $this->error($e->validator->errors()->first());
|
|
|
+ } catch (Exception $e) {
|
|
|
+ return $this->error($e->getMessage(), [], $e->getCode());
|
|
|
+ }
|
|
|
+ return $this->success();
|
|
|
+ }
|
|
|
+
|
|
|
//发送手机验证码
|
|
|
- public function sendPhoneCode()
|
|
|
+ public function sendPhoneCode(): JsonResponse
|
|
|
{
|
|
|
try {
|
|
|
$params = request()->validate([
|
|
|
@@ -36,14 +55,9 @@ class ActivityReward extends BaseController
|
|
|
if (!Cache::has($key)) {
|
|
|
Cache::put($key, true, 60);
|
|
|
$code = SmsService::sendPhoneCode($params['phone']);
|
|
|
+ PhoneCodeService::add($params['phone'], $code);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
} catch (ValidationException $e) {
|
|
|
-
|
|
|
return $this->error($e->validator->errors()->first());
|
|
|
} catch (Exception $e) {
|
|
|
return $this->error($e->getMessage(), [], $e->getCode());
|
|
|
@@ -51,6 +65,8 @@ class ActivityReward extends BaseController
|
|
|
return $this->success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //参与活动
|
|
|
public function participate(): JsonResponse
|
|
|
{
|
|
|
DB::beginTransaction();
|