Ken hace 1 semana
padre
commit
3d5166c07e

+ 2 - 1
app/Constants/HttpStatus.php

@@ -44,7 +44,8 @@ class HttpStatus
     const VERIFY_ERROR = 101033;//验证资料错误,请检查验证状态是否为待验证
     const PAY_VERIFY_ERROR = 101034;//支付验证错误
     const IM_SYSTEM_ERROR =101035;//im系统错误
-    const  CUSTOM_ERROR = -3;
+    const CUSTOM_ERROR = -3;
+    const NOT_BIND_PHONE = 101036;
 
 
 }

+ 5 - 0
app/Http/Controllers/api/ActivityReward.php

@@ -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\UserService;
 use Illuminate\Http\JsonResponse;
 use Illuminate\Validation\ValidationException;
 use Exception;
@@ -32,6 +33,10 @@ class ActivityReward extends BaseController
             if (ActivityUser::where('member_id', $memberId)->where('activity_id', $activityId)->exists()) {
                 throw new Exception('已参与过此活动,每个活动仅可参加一次', HttpStatus::CUSTOM_ERROR);
             }
+
+            $user = UserService::findOne(['member_id' => $memberId]);
+            if(empty($user->phone)) throw new Exception('请先绑定手机号', HttpStatus::NOT_BIND_PHONE);
+
             $time = time();
             $activity = ActivityRewardService::findOne([
                 'start_time' => ['<=', $time],

+ 1 - 0
app/Models/User.php

@@ -11,6 +11,7 @@ namespace App\Models;
  * @property string $register_ip
  * @property integer $status
  * @property string $visitor_id
+ * @property string $phone 用户手机号
  */
 class User extends BaseModel
 {

+ 30 - 0
database/migrations/2026_01_23_164920_update_users.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->string('phone',32)->default('')->comment('用户绑定的手机号');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+};