zz 6 years ago
parent
commit
c357a3c7b3

+ 7 - 2
app/Http/Controllers/Wap/User/UserController.php

@@ -447,20 +447,24 @@ class UserController extends BaseController
         AliSMS::send($phone, 'paid_user_bind_phone', ['code'=>$code]);
         return response()->success();
     }
+
     public function bindPhone(Request $request){
         $code = $request->post('code');
         $phone = $request->post('phone');
+        $from = $request->post('from');
         $old = Redis::get('code:'.$phone);
+        Redis::del('code:'.$phone);
         if($old && $old == $code){
             $user_info  = UserService::getById($this->uid);
             if(!$user_info){
                 return response()->error();
             }
             try{
-                $result = UserBindPhoneService::bind($this->uid,$user_info->openid,$phone);
+                $result = UserBindPhoneService::bind($this->uid,$user_info->openid,$phone,$from);
                 if($result == 0){
                     UserService::addBalance($this->uid,100,0,100);
                     UserWealthyOperateRecordService::create($this->uid,100,$this->distribution_channel_id,'bind_phone');
+                    return response()->success();
                 }
                 if($result == -1){
                     return response()->error('WAP_BIND_PHONE_EXIST');
@@ -469,10 +473,11 @@ class UserController extends BaseController
                     return response()->error('WAP_SEND_OPENID_EXIST');
                 }
             }catch (\Exception $e){}
-            return response()->success();
+
         }else{
             return response()->error('WAP_SEND_CODE_ERROR');
         }
+        return response()->error();
     }
 
     public function bindPhoneView(Request $request){

+ 1 - 1
app/Modules/User/Models/UserBindPhone.php

@@ -8,5 +8,5 @@ class UserBindPhone extends Model
 {
     protected $table = 'user_bind_phone';
 
-    protected $fillable = ['uid','openid','phone'];
+    protected $fillable = ['uid','openid','phone','from'];
 }

+ 2 - 1
app/Modules/User/Services/UserBindPhoneService.php

@@ -21,7 +21,7 @@ class UserBindPhoneService
             ->first();
     }
 
-    public static function bind($uid,$openid,$phone){
+    public static function bind($uid,$openid,$phone,$from){
         $model = new UserBindPhone();
         $info = $model->where('phone',$phone)->select('id')->first();
         if($info){
@@ -34,6 +34,7 @@ class UserBindPhoneService
         $model->uid = $uid;
         $model->openid = $openid;
         $model->phone = $phone;
+        $model->from = $from;
         $model->save();
         return 0;
     }

+ 2 - 1
resources/views/pay/order/bindPhone.blade.php

@@ -255,6 +255,7 @@
     var refuseNumber = 10;
     var getPhoneCodeNumber = 60;
     var order = "{{ $order }}"
+    var from = "{{ $from }}"
 
     // 倒计时
     function countDown(time, cb) {
@@ -335,7 +336,7 @@
             $.ajax({
                 url:'/api/bindphone/bind',
                 type:'post',
-                data:{phone:phone,code:code},
+                data:{phone:phone,code:code,from:from},
                 success:function ($res) {
                     if($res.code == 0){
                         $(".dialog-wrap").fadeIn();