xialei пре 1 година
родитељ
комит
e063618b54
2 измењених фајлова са 43 додато и 0 уклоњено
  1. 41 0
      app/controller/api/user/User.php
  2. 2 0
      route/api.php

+ 41 - 0
app/controller/api/user/User.php

@@ -3137,7 +3137,48 @@ class User extends BaseController
3137 3137
     }
3138 3138
 
3139 3139
 
3140
+    /**
3141
+     * 转VR
3142
+     */
3143
+    public function transition_vr()
3144
+    { 
3145
+        $uid = $this->request->uid();
3146
+        $user = $this->request->userInfo();
3147
+        $type = $this->request->param('type', 'brokerage');
3148
+        $extract_amount = $this->request->param('extract_amount', 0);
3149
+        if ($type == 'brokerage') {
3150
+            $brokerage_price = Db::name('user')->where('uid', $uid)->value('brokerage_price');
3151
+            $no_clear_amount = Db::name('user_bill')
3152
+            ->where('uid', $uid)
3153
+            ->where('commission_type', '<>', 5)
3154
+            ->where('pm', 1)
3155
+            ->where('status', 0)
3156
+            ->sum('number');
3157
+            $clear_amount = $brokerage_price - $no_clear_amount;
3158
+            if ($user['brokerage_price'] < (systemConfig('withdrawal_money'))){
3159
+                return app('json')->fail('未到达提现最低额度');
3160
+            }
3161
+            if($extract_amount > $clear_amount){
3162
+                return app('json')->fail("可用金额不足提现");
3163
+            }
3164
+
3165
+            $brokerage_price = bcsub($user['brokerage_price'], $extract_amount,2);
3166
+            $user->brokerage_price = $brokerage_price;
3167
+            $user->vr = bcadd($user['vr'], $extract_amount, 2);
3168
+            $res = $user->save();
3169
+            if ($res){
3170
+                //加入账单记录
3171
+
3172
+
3173
+
3140 3174
 
3175
+                return app('json')->success('转VR成功');
3176
+            }else{
3177
+                return app('json')->fail('转VR失败');
3178
+            }
3179
+        }
3180
+        return app('json')->fail('转VR失败');
3181
+    }
3141 3182
 
3142 3183
 
3143 3184
     /**

+ 2 - 0
route/api.php

@@ -301,6 +301,8 @@ Route::group('api/', function () {
301 301
             Route::get('get_team_list', 'User/get_team_list');
302 302
             Route::post('get_team_info', 'User/get_team_info');
303 303
             Route::get('get_brokerage_info', 'User/get_brokerage_info');
304
+            Route::post('transition_vr', 'User/transition_vr');
305
+            
304 306
             Route::post('get_token_by_phone', 'User/get_token_by_phone');
305 307
 
306 308
             Route::get('hongbao_info','User/hongbao_info');//红包