Browse Source

代理提现

lizhen_gitee 1 year ago
parent
commit
8f320a95fc

+ 1 - 1
application/api/controller/Takecash.php

@@ -21,7 +21,7 @@ class Takecash extends Api
             '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.withdraw_rule'),
+            'remark' => config('site.takecash_rule'),
         ];
 
         $this->success('success',$data);

+ 144 - 0
application/api/controller/Withdraw.php

@@ -0,0 +1,144 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 提现
+ */
+class Withdraw extends Api
+{
+    protected $noNeedLogin = [];
+    protected $noNeedRight = ['*'];
+
+    //提现配置
+    public function config(){
+
+        $data = [
+            'agentjewel' => model('wallet')->getwallet($this->auth->id,'agentjewel'),
+            '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.withdraw_rule'),
+
+            'min' => config('site.withdraw_min_price'),
+            'plat_bilv' => config('site.withdrawal_plat_bili'),
+            'agentjewel_to_money' => config('site.agentjewel_to_money'),
+        ];
+
+        $this->success('success',$data);
+    }
+
+    //提现
+    public function withdraw(){
+        $freemoney = input('freemoney',0);
+        $type = input('type',1);
+
+        if(!$freemoney){
+            $this->error('请填写金额');
+        }
+
+        if (!in_array($type,[1,2])) {
+            $this->error('未知的提现类型');
+        }
+
+        //验证提现类型
+        if(!$this->user_auth_limit()){
+            $this->error('请先完成实名认证');
+        }
+
+
+        //自由输入覆盖
+        $money = floatval($freemoney);
+
+        //
+        if($money<=0)
+        {
+            $this->error('金额必须大于0');
+        }
+
+        $min = config('site.withdraw_min_price');
+        if($money < $min){
+            $this->error('提现金额不能小于'.$min);
+        }
+
+        $check = Db::name('withdraw')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
+        if($check){
+            $this->error('您已经申请了提现,请等待审核');
+        }
+
+        $user_money = model('wallet')->getwallet($this->auth->id,'agentjewel');
+        if($money > $user_money){
+            $this->error('提现金额不能大于可提现余额');
+        }
+
+        if($type == 1){
+            $table_name = 'user_alipay';
+            $account_json = Db::name($table_name)->where('user_id',$this->auth->id)->find();
+            if(empty($account_json)){
+                $this->error('未绑定对应的提现账号');
+            }
+        }else{
+            $table_name = 'user_bank';
+            $account_json = Db::name($table_name)->where('user_id',$this->auth->id)->find();
+            if(empty($account_json)){
+                $this->error('未绑定对应的提现账号');
+            }
+        }
+
+        $plat_bilv = config('site.withdrawal_plat_bili');
+        $get_money = bcdiv(bcmul($money,(100-$plat_bilv),2),100,2);
+
+        $huilv = config('agentjewel_to_money') ?: 10;
+        $get_money = bcdiv($get_money,$huilv,2);
+
+        $data = [
+            'user_id' => $this->auth->id,
+            'money' => $get_money,
+            'agentjewel' => $money,
+            'type' => $type,
+            'acount_json' => json_encode($account_json),
+            'createtime' => time(),
+            'updatetime' => time(),
+            'status' => 0,
+        ];
+        Db::startTrans();
+
+        $log_id = Db::name('withdraw')->insertGetId($data);
+        if(!$log_id){
+            Db::rollback();
+            $this->error('提现失败');
+        }
+
+        //扣除money
+        $rs_wallet = model('Wallet')->lockChangeAccountRemain($this->auth->id,'agentjewel',-$money,55,'提现','withdraw',$log_id);
+        if($rs_wallet['status']===false)
+        {
+            Db::rollback();
+            $this->error($rs_wallet['msg']);
+        }
+
+        Db::commit();
+
+        $this->success('申请成功请等待审核');
+    }
+
+    //提现记录
+    public function withdraw_log(){
+        $list = Db::name('withdraw')->field('id,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'] = '微信提现';
+            }
+        }
+
+        $this->success('success',$list);
+    }
+
+}

+ 7 - 1
application/extra/site.php

@@ -91,7 +91,7 @@ return array (
 6、请确保所有交易已完结且无纠纷,账户注销后,历史交易可能产生的资金退回权益将视作自动放弃:
 7、其他不限于以上所列举的,账号的资产和权益将视为自动放弃:
 815天后自动注销,15天内再次登录账号即视为放弃注销;请谨慎使用账号注销功能,账号一旦注销将无法找回,因该账号注销带来的问题,平台不承担任何责任。',
-  'withdraw_rule' => '提现规则:
+  'takecash_rule' => '提现规则:
 1、每日可提现一次,单次最高可提现2000
 2、提现到账时间:每日18:00之前提现申请,当日23:00前到账
 3、收益提现收取6.5%手续费',
@@ -105,4 +105,10 @@ return array (
   'recharge_d2c_rate' => '10',
   'shouyi_b2a_rate' => '10',
   'shouyi_c2a_rate' => '10',
+  'withdraw_min_price' => '100',
+  'withdrawal_plat_bili' => '6.5',
+  'agentjewel_to_money' => '10',
+  'withdraw_rule' => '1、每日提现一次,累计100金币可提现
+2、到账时间:每天18:00点之前申请提现,当日24:00前到账,每天18:00后申请提现,将在次日24:00前到账(节假日及特殊情况,提现到账将适度延迟)
+3、收益提现时平台将收取6.5%的手续费',
 );

+ 6 - 2
application/extra/wallet.php

@@ -29,14 +29,18 @@ return [
         42 => '好友提现',//jewel + 提现审核通过触发
 
 ///////////
-        51 => '超推充值',//jewel + 充值的计划任务触发
-        52 => '超推收益',//jewel + 收益的计划任务触发
+        51 => '充值超推收益',//agentjewel + 充值的计划任务触发
+        52 => '收益超推收益',//agentjewel + 收益的计划任务触发
+        55 => '提现',//agentjewel - 收益的计划任务触发
+        56 => '提现拒绝返回',//agentjewel + 收益的计划任务触发
+
 
 
     ],
     'moneyname' => [
         'gold'     => '充值账户',
         'jewel'    => '收入账户',
+        'agentjewel'    => '代理收益账户',
     ],
 
 ];