hefei 1 год назад
Родитель
Сommit
2a14c08b26
1 измененных файлов с 17 добавлено и 18 удалено
  1. 17 18
      app/common/repositories/user/UserExtractRepository.php

+ 17 - 18
app/common/repositories/user/UserExtractRepository.php

@@ -370,22 +370,6 @@ class UserExtractRepository extends BaseRepository
370 370
                 }
371 371
 
372 372
                 $user->save();
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
-
389 373
                 $service_money=bcmul($data['extract_price'],'0.1',2);
390 374
                 $data['service_money']=$service_money;
391 375
                 $data['status'] = 0;
@@ -498,9 +482,9 @@ class UserExtractRepository extends BaseRepository
498 482
     {
499 483
 
500 484
         Db::transaction(function()use($id,$data){
485
+            $extract = $this->dao->getWhere(['extract_id' => $id]);
486
+            $user = app()->make(UserRepository::class)->get($extract['uid']);
501 487
             if($data['status'] == '-1'){
502
-                $extract = $this->dao->getWhere(['extract_id' => $id]);
503
-                $user = app()->make(UserRepository::class)->get($extract['uid']);
504 488
                 if (!empty($extract['mer_id'])) {
505 489
                     //商户提现逻辑处理
506 490
                     $mer = app()->make(MerchantRepository::class)->get($extract['mer_id']);
@@ -513,6 +497,8 @@ class UserExtractRepository extends BaseRepository
513 497
                         $brokerage_price = bcadd($user['brokerage_price'] ,$extract['extract_price'],2);
514 498
                         //返回余额
515 499
                         $user->brokerage_price = $brokerage_price;
500
+                    }else if($extract['types']==3){
501
+                        $user->hongbao = bcadd($user->hongbao,$extract['extract_price'],2);
516 502
                     }else{
517 503
                         $member_brokerage_price = bcadd($user['member_brokerage_price'] ,$extract['extract_price'],2);
518 504
                         //返回余额
@@ -534,6 +520,19 @@ class UserExtractRepository extends BaseRepository
534 520
 //                $user->save();
535 521
 //                Db::name('user_sign_score')->where("order_type","extract") -> where("order_id",$id) -> update(['status'=>0]);
536 522
             }else{
523
+                if($extract['types']==3){
524
+                    //加入红包出账记录
525
+                    $insertdata = [
526
+                        'uid'=> $user->uid,
527
+                        'number' =>  $extract['extract_price'],
528
+                        'surplus' => $user->hongbao,
529
+                        'mark' => '红包提现',
530
+                        'type' => 2,
531
+                        'status' => 1,
532
+                        'addtime' => time(),
533
+                    ];
534
+                    Db::name('user_sign_hongbao')->insertGetId($insertdata);
535
+                }
537 536
                 //积分扣除
538 537
 //                Db::name('user_sign_score')->where("order_type","extract") -> where("order_id",$id) -> update(['status'=>1]);
539 538
             }