lizhen_gitee 1 gadu atpakaļ
vecāks
revīzija
814ecc3114
1 mainītis faili ar 15 papildinājumiem un 43 dzēšanām
  1. 15 43
      application/api/controller/Takecash.php

+ 15 - 43
application/api/controller/Takecash.php

@@ -16,20 +16,12 @@ class Takecash extends Api
     public function take_cash_config(){
         $config = Db::name('take_cash_config')->order('weigh asc,id asc')->select();
 
-        $plat_bilv = config('site.withdrawal_plat_bili');
-        foreach($config as $key => &$val){
-            $val['get_money'] = bcdiv(bcmul($val['money'],(100-$plat_bilv),2),100,2);
-        }
-
         $data = [
             'config' => $config,
-            'wallet' => model('wallet')->getwallet($this->auth->id),
-            'min' => config('site.min_withdrawal_money'),
-            'max' => config('site.max_withdrawal_money'),
-            'plat_bilv' => $plat_bilv,
+            'jewel' => model('wallet')->getwallet($this->auth->id,'jewel'),
             'user_bank' => Db::name('user_bank')->where('user_id',$this->auth->id)->find(),
             'user_alipay' => Db::name('user_alipay')->where('user_id',$this->auth->id)->find(),
-            'remark' => config('site.take_cash_rule'),
+            'remark' => config('site.withdraw_rule'),
         ];
 
         $this->success('success',$data);
@@ -37,15 +29,14 @@ class Takecash extends Api
 
     //提现
     public function take_cash(){
-        $rc_id     = input_post('rc_id',0);
-        $freemoney = input_post('freemoney',0);
-        $type = input_post('type',1);
+        $rc_id     = input('rc_id',0);
+        $type = input('type',1);
 
-        if(!$rc_id && !$freemoney){
-            $this->error('请选择或填写金额');
+        if(!$rc_id){
+            $this->error('请选择金额');
         }
 
-        if (!in_array($type,[1,2,3])) {
+        if (!in_array($type,[1,2])) {
             $this->error('未知的提现类型');
         }
 
@@ -57,35 +48,23 @@ class Takecash extends Api
         if($rc_id){
             $recharge_config = Db::name('take_cash_config')->where('id',$rc_id)->find();
             $money = $recharge_config['money'] ?: 0;
+            $jewel = $recharge_config['jewel'] ?: 0;
         }
 
-        //自由输入覆盖
-        if(!empty($freemoney)){
-            $rc_id = 0;
-            $money = floatval($freemoney);
-        }
 
         //
-        if($money<=0)
+        if($money<=0 || $jewel<=0)
         {
             $this->error('金额必须大于0');
         }
 
-        $min = config('site.min_withdrawal_money');
-        $max = config('site.max_withdrawal_money');
-        if($money < $min){
-            $this->error('提现金额不能小于'.$min);
-        }
-        if($money > $max){
-            $this->error('提现金额不能大于'.$max);
-        }
 
         $check = Db::name('take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
         if($check){
             $this->error('您已经申请了提现,请等待审核');
         }
 
-        $user_money = model('wallet')->getwallet($this->auth->id,'money');
+        $user_money = model('wallet')->getwallet($this->auth->id,'jewel');
         if($money > $user_money){
             $this->error('提现金额不能大于可提现余额');
         }
@@ -96,24 +75,19 @@ class Takecash extends Api
             if(empty($account_json)){
                 $this->error('未绑定对应的提现账号');
             }
-        }elseif($type == 2){
+        }else{
             $table_name = 'user_bank';
             $account_json = Db::name($table_name)->where('user_id',$this->auth->id)->find();
             if(empty($account_json)){
                 $this->error('未绑定对应的提现账号');
             }
-        }else{
-            //微信支付
-            $account_json = [];
         }
 
-        $plat_bilv = config('site.withdrawal_plat_bili');
-        $get_money = bcdiv(bcmul($money,(100-$plat_bilv),2),100,2);
 
         $data = [
             'user_id' => $this->auth->id,
             'money' => $money,
-            'get_money' => $get_money,
+            'jewel' => $jewel,
             'type' => $type,
             'acount_json' => json_encode($account_json),
             'createtime' => time(),
@@ -129,7 +103,7 @@ class Takecash extends Api
         }
 
         //扣除money
-        $rs_wallet = model('Wallet')->lockChangeAccountRemain($this->auth->id,'money',-$money,15,'提现','take_cash',$log_id);
+        $rs_wallet = model('Wallet')->lockChangeAccountRemain($this->auth->id,'jewel',-$jewel,15,'提现','take_cash',$log_id);
         if($rs_wallet['status']===false)
         {
             Db::rollback();
@@ -142,16 +116,14 @@ class Takecash extends Api
 
     //提现记录
     public function take_cash_log(){
-        $list = Db::name('take_cash')->field('id,money,type,createtime')->where(['user_id'=>$this->auth->id])->autopage()->select();
+        $list = Db::name('take_cash')->field('id,jewel,money,type,createtime')->where(['user_id'=>$this->auth->id])->autopage()->select();
         foreach($list as $key => &$val){
             $val['remark'] = '';
 
             if($val['type'] == 1){
                 $val['remark'] = '支付宝提现';
-            }elseif($val['type'] == 2){
-                $val['remark'] = '银行卡提现';
             }else{
-                $val['remark'] = '微信提现';
+                $val['remark'] = '银行卡提现';
             }
         }