Browse Source

提现手续费

lizhen_gitee 6 months ago
parent
commit
f92753e121
2 changed files with 52 additions and 0 deletions
  1. 44 0
      application/api/controller/Takecash.php
  2. 8 0
      application/api/controller/Userwallet.php

+ 44 - 0
application/api/controller/Takecash.php

@@ -12,6 +12,50 @@ class Takecash extends Api
     protected $noNeedLogin = [];
     protected $noNeedRight = ['*'];
 
+    //提现before
+    public function take_cash_before(){
+        $freemoney = input('freemoney',0);
+        if(!$freemoney){
+            $this->error('请填写金额');
+        }
+
+        $money = floatval($freemoney);
+
+        if($money<=0)
+        {
+            $this->error('金额必须大于0');
+        }
+
+        $min = config('site.min_takecash_money');
+        $max = config('site.max_takecash_money');
+        if($money < $min){
+            $this->error('提现金额不能小于'.$min);
+        }
+        if($money > $max){
+            $this->error('提现金额不能大于'.$max);
+        }
+
+        $user_money = model('wallet')->getwallet($this->auth->id,'money');
+        if($money > $user_money){
+            $this->error('提现金额不能大于可提现余额');
+        }
+
+        //平台手续费
+        $plat_bilv = config('site.takecash_plat_bili');
+        $plat_money = bcdiv(bcmul($money,$plat_bilv,2),100,2);
+
+        //减去手续费,得实得金额
+        $get_money = bcsub($money,$plat_money,2);
+
+        $data = [
+            'money'      => $money,
+            'plat_bilv'  => $plat_bilv,
+            'plat_money' => $plat_money,
+            'get_money'  => $get_money,
+        ];
+        $this->success(1,$data);
+    }
+
     //提现
     public function take_cash(){
         $freemoney = input('freemoney',0);

+ 8 - 0
application/api/controller/Userwallet.php

@@ -18,6 +18,14 @@ class Userwallet extends Api
         $wallet = Db::name('user_wallet')->where(['user_id' => $this->auth->id])->find();
 
         $wallet['user_bank']   = Db::name('user_bank')->where(['user_id' => $this->auth->id])->find();
+
+        $wallet['take_cash'] = [
+            'min' => config('site.min_takecash_money'),
+            'max' => config('site.max_takecash_money'),
+            'takecash_plat_bili' => config('site.takecash_plat_bili'),
+            'take_cash_rule' => config('site.take_cash_rule'),
+        ];
+
         $this->success('success',$wallet);
     }