Browse Source

Merge branch 'master' of https://git.bjtdba.com/shop/php

chengzhiyixia 1 year ago
parent
commit
995b2f5efa

+ 38 - 1
app/common/repositories/user/UserExtractRepository.php

@@ -357,17 +357,35 @@ class UserExtractRepository extends BaseRepository
357 357
             return false;
358 358
         }
359 359
         if ($data["extract_type"]==3){
360
-            $data = Db::transaction(function()use($user,$data, $type){
360
+            $data = Db::transaction(function()use($user,$data, $type,$uid){
361 361
                 if($type==1){
362 362
                     $brokerage_price = bcsub($user['brokerage_price'],$data['extract_price'],2);
363 363
                     $user->brokerage_price = $brokerage_price;
364 364
                 }else if ($type == 2) {
365 365
                     $brokerage_price = bcsub($user['member_brokerage_price'],$data['extract_price'],2);
366 366
                     $user->member_brokerage_price = $brokerage_price;
367
+                }else if ($type == 3) {
368
+                    $hongbao = bcsub($user['hongbao'],$data['extract_price'],2);
369
+                    $user->hongbao = $hongbao;
367 370
                 }
368 371
 
369 372
                 $user->save();
370 373
 
374
+                if($type == 3){
375
+                    //加入红包提现记录
376
+                   $insertdata = [
377
+                       'uid'=> $uid,
378
+                       'number' =>  $data['extract_price'],
379
+                       'surplus' => $user->hongbao,
380
+                       'mark' => '红包提现',
381
+                       'type' => 2,
382
+                       'status' => -1,
383
+                       'addtime' => time(),
384
+                   ];
385
+                   Db::name('user_sign_hongbao')->insertGetId($insertdata);
386
+               }
387
+
388
+
371 389
                 $service_money=bcmul($data['extract_price'],'0.1',2);
372 390
                 $data['service_money']=$service_money;
373 391
                 $data['status'] = 0;
@@ -384,6 +402,9 @@ class UserExtractRepository extends BaseRepository
384 402
                 }else if ($type == 2) {
385 403
                     $brokerage_price = bcsub($user['member_brokerage_price'],$data['extract_price'],2);
386 404
                     $user->member_brokerage_price = $brokerage_price;
405
+                }else if ($type == 3) {
406
+                    $hongbao = bcsub($user['hongbao'],$data['extract_price'],2);
407
+                    $user->hongbao = $hongbao;
387 408
                 }
388 409
                 $user->save();
389 410
                 $service_money=bcmul($data['extract_price'],'0.1',2);
@@ -404,8 +425,24 @@ class UserExtractRepository extends BaseRepository
404 425
                         $extract_price_yihu= $tea_price;
405 426
                         $service_money_yihu= bcmul($tea_price,'0.1',2);
406 427
                     }
428
+                }
407 429
 
430
+
431
+                if($type == 3){
432
+                     //加入红包提现记录
433
+                    $insertdata = [
434
+                        'uid'=> $uid,
435
+                        'number' =>  $data['extract_price'],
436
+                        'surplus' => $user->hongbao,
437
+                        'mark' => '红包提现',
438
+                        'type' => 2,
439
+                        'status' => -1,
440
+                        'addtime' => time(),
441
+                    ];
442
+                    Db::name('user_sign_hongbao')->insertGetId($insertdata);
408 443
                 }
444
+
445
+
409 446
 //                    if($extract_price_yihu>0){
410 447
                 $insertAll[]=array(
411 448
                     'extract_id'=>$extract->extract_id,

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

@@ -3312,6 +3312,60 @@ return app("json")->success($data);
3312 3312
                 return app('json')->fail('转VR失败');
3313 3313
             }
3314 3314
         }
3315
+
3316
+
3317
+        if ($type == 'hongbao') {
3318
+            $hongbao = Db::name('user')->where('uid', $uid)->value('hongbao');
3319
+            $no_clear_amount = Db::name('user_sign_hongbao')
3320
+                ->where('uid', $uid)
3321
+                ->where('type', 1)
3322
+                ->where('status', -1)
3323
+                ->sum('number');
3324
+            $clear_amount = $hongbao - $no_clear_amount;
3325
+            if ($user['hongbao'] < (systemConfig('withdrawal_money'))){
3326
+                return app('json')->fail('未到达提现最低额度');
3327
+            }
3328
+            if($extract_amount > $clear_amount){
3329
+                return app('json')->fail("可用金额不足提现");
3330
+            }
3331
+
3332
+            $hongbao = bcsub($user['hongbao'], $extract_amount,2);
3333
+            $user->hongbao = $hongbao;
3334
+
3335
+            $vr = bcadd($user['vr'], $extract_amount, 2);
3336
+            $user->vr = $vr;
3337
+
3338
+            $res = $user->save();
3339
+            if ($res){
3340
+                //加入转VR记录
3341
+                $insertdata = [
3342
+                    'uid'=> $uid,
3343
+                    'number' =>  $extract_amount,
3344
+                    'surplus' => $vr,
3345
+                    'mark' => '红包转VR',
3346
+                    'type' => 2,
3347
+                    'status' => -1,
3348
+                    'addtime' => time(),
3349
+                ];
3350
+                Db::name('user_sign_hongbao')->insertGetId($insertdata);
3351
+                //VR入账
3352
+                $insertdata = [
3353
+                    'uid'=> $uid,
3354
+                    'number' =>  $extract_amount,
3355
+                    'surplus' => $vr,
3356
+                    'mark' => '红包转VR',
3357
+                    'order_id'=> 0,
3358
+                    'type' => 1,
3359
+                    'addtime' => time(),
3360
+                    'settlement_time'=> date('Y-m-d H:i:s', time())
3361
+                ];
3362
+                Db::name('user_sign_vr')->insertGetId($insertdata);
3363
+                return app('json')->success('转VR成功');
3364
+            }else{
3365
+        return app('json')->fail('转VR失败');
3366
+            }
3367
+        }
3368
+
3315 3369
         return app('json')->fail('转VR失败');
3316 3370
     }
3317 3371
 

+ 17 - 2
app/controller/api/user/UserExtract.php

@@ -46,7 +46,7 @@ class UserExtract extends BaseController
46 46
     public function lst()
47 47
     {
48 48
         [$page,$limit] = $this->getPage();
49
-        $where = $this->request->params(['status']);
49
+        $where = $this->request->params(['status', 'type']);
50 50
         $where['uid'] = $this->request->uid();
51 51
         return app('json')->success($this->repository->serach($where,$page,$limit));
52 52
     }
@@ -76,7 +76,7 @@ class UserExtract extends BaseController
76 76
         $data = $this->checkParams($validate);
77 77
         $user = $this->request->userInfo();
78 78
         $uid = $this->request->uid();
79
-        $type = input("type/d", 1);//1-佣金 2-红积分
79
+        $type = $this->request->param('type', 1);//1-佣金 2-会员商品直推佣金 3红包
80 80
 
81 81
         $sms_code = $this->request->param('sms_code');
82 82
 
@@ -106,7 +106,22 @@ class UserExtract extends BaseController
106 106
                     return app('json')->fail('请先绑定提现微信');
107 107
                 }
108 108
             }
109
+        }elseif ($type == 3) {
110
+            if ($data['extract_price'] < (systemConfig('withdrawal_money')))
111
+            return app('json')->fail('未到达提现最低额度');
112
+            if ($user['hongbao'] < $data['extract_price'])
113
+                return app('json')->fail('提现金额不足');
114
+
115
+            if ($data['extract_type'] == 3){
116
+                if (!$data['bank_id']) return app('json')->fail('请选择银行卡信息');
117
+            }
109 118
 
119
+            if($data["extract_type"] == 1){
120
+                $user_extract_openid=Db::name('user_extract_openid')->where('uid',$uid)->find();
121
+                if(!$user_extract_openid || $user_extract_openid['openid']==''){
122
+                    return app('json')->fail('请先绑定提现微信');
123
+                }
124
+            }
110 125
         }else{
111 126
             if ($user['member_brokerage_price'] < (systemConfig('withdrawal_money')))
112 127
                 return app('json')->fail('未到达提现最低额度');