Browse Source

提现一整套

lizhen_gitee 2 months ago
parent
commit
7318527a18
3 changed files with 217 additions and 7 deletions
  1. 203 2
      application/api/controller/Hexiao.php
  2. 12 3
      application/extra/site.php
  3. 2 2
      application/extra/wallet.php

+ 203 - 2
application/api/controller/Hexiao.php

@@ -26,13 +26,13 @@ class Hexiao extends Api
         $rs = [
             'hexiaomoney' => $wallet['hexiaomoney'],
             'takecash'    => $wallet['hexiaomoney'],
-            'wait'        => 0,
+            'wait'        => '0.00',
         ];
 
         $this->success(1,$rs);
     }
 
-    //订单详情
+    //扫核销码获取订单详情
     //code:order_hexiao_no|2024090466d7c9d5abb1c1
     //order_no:2024090466d7c9d5abb1c1
     public function order_info()
@@ -225,4 +225,205 @@ class Hexiao extends Api
 
 
     }
+
+    //提现配置
+    public function take_cash_config(){
+
+        $plat_bilv      = config('site.hexiao_takecash_plat_bili');
+        $take_cash_days = config('site.hexiao_take_cash_days');
+        $take_cash_days_str = implode(',',$take_cash_days);
+
+        $data = [
+            'hexiaomoney' => model('wallet')->getwallet($this->auth->id,'hexiaomoney'),
+            'plat_bilv'   => $plat_bilv,
+            'user_bank'   => Db::name('user_bank')->where('user_id',$this->auth->id)->find(),
+            'take_cash_days' => $take_cash_days_str,
+            'remark'         => '每月'.$take_cash_days_str.'日可以提现',
+            'take_cash_button' => in_array(date('d'),$take_cash_days) ? 1 : 0,
+        ];
+
+        $this->success('success',$data);
+    }
+
+    //提现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.hexiao_min_takecash_money');
+        $max = config('site.hexiao_max_takecash_money');
+        if($money < $min){
+            $this->error('提现金额不能小于'.$min);
+        }
+        if($money > $max){
+            $this->error('提现金额不能大于'.$max);
+        }
+
+        $user_money = model('wallet')->getwallet($this->auth->id,'hexiaomoney');
+        if($money > $user_money){
+            $this->error('提现金额不能大于可提现余额');
+        }
+
+        //平台手续费
+        $plat_bilv = config('site.hexiao_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);
+//        $type = input('type',1);
+        $type = 2;
+
+        if(!$freemoney){
+            $this->error('请填写金额');
+        }
+
+        if (!in_array($type,[1,2,3])) {
+            $this->error('未知的提现类型');
+        }
+
+        //提现日期限制
+        $take_cash_days = config('site.hexiao_take_cash_days');
+        if(!in_array(date('d'),$take_cash_days)){
+            $take_cash_days_str = implode(',',$take_cash_days);
+            $this->error('每月'.$take_cash_days_str.'日才可以提现');
+        }
+
+
+        //赋值money
+        /*if($rc_id){
+            $recharge_config = Db::name('take_cash_config')->where('id',$rc_id)->find();
+            $money = $recharge_config['money'] ?: 0;
+        }*/
+
+        //自由输入覆盖
+        if(!empty($freemoney)){
+            $rc_id = 0;
+            $money = floatval($freemoney);
+        }
+
+        //
+        if($money<=0)
+        {
+            $this->error('金额必须大于0');
+        }
+
+        $min = config('site.hexiao_min_takecash_money');
+        $max = config('site.hexiao_max_takecash_money');
+        if($money < $min){
+            $this->error('提现金额不能小于'.$min);
+        }
+        if($money > $max){
+            $this->error('提现金额不能大于'.$max);
+        }
+
+        $check = Db::name('hexiao_user_take_cash')->where(['user_id'=>$this->auth->id,'status'=>0])->find();
+        if($check){
+            $this->error('您已经申请了提现,请等待审核');
+        }
+
+        $user_money = model('wallet')->getwallet($this->auth->id,'hexiaomoney');
+        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('未绑定对应的提现账号');
+            }
+        }elseif($type == 2){
+            $table_name = 'user_bank';
+            $account_json = Db::name($table_name)->where('user_id',$this->auth->id)->find();
+            if(empty($account_json)){
+                $this->error('未绑定对应的提现账号');
+            }
+        }elseif($type == 3){
+            //微信支付
+            $table_name = 'user_wechat';
+            $account_json = Db::name($table_name)->where('user_id',$this->auth->id)->find();
+            if(empty($account_json)){
+                $this->error('未绑定对应的提现账号');
+            }
+        }
+
+        //平台手续费
+        $plat_bilv = config('site.unishop_order_hexiaomoney_bili');
+        $plat_money = bcdiv(bcmul($money,$plat_bilv,2),100,2);
+
+        //减去手续费,得实得金额
+        $get_money = bcsub($money,$plat_money,2);
+
+        $data = [
+            'user_id' => $this->auth->id,
+            'money' => $money,
+            'plat_bilv'  => $plat_bilv,
+            'plat_money' => $plat_money,
+            'get_money'  => $get_money,
+            'type' => $type,
+            'acount_json' => json_encode($account_json),
+            'createtime' => time(),
+            'updatetime' => time(),
+            'status' => 0,
+        ];
+        Db::startTrans();
+
+        $log_id = Db::name('hexiao_user_take_cash')->insertGetId($data);
+        if(!$log_id){
+            Db::rollback();
+            $this->error('提现失败');
+        }
+
+        //扣除money
+        $rs_wallet = model('Wallet')->lockChangeAccountRemain($this->auth->id,'hexiaomoney',-$money,221,'提现(审核中)','hexiao_user_take_cash',$log_id);
+        if($rs_wallet['status']===false)
+        {
+            Db::rollback();
+            $this->error($rs_wallet['msg']);
+        }
+
+        Db::commit();
+        $this->success('申请成功请等待审核');
+    }
+
+    //提现记录
+    public function take_cash_log(){
+        $list = Db::name('hexiao_user_take_cash')->field('id,money,get_money,type,createtime,status')->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);
+    }
+
 }

+ 12 - 3
application/extra/site.php

@@ -46,10 +46,19 @@ return array (
   'apisite_switch' => '1',
   'apisite_notice' => '全站维护中敬请期待新版本',
   'kefuphoneno' => '400-1234-1175',
-  'min_takecash_money' => '1',
-  'max_takecash_money' => '10000',
-  'takecash_plat_bili' => '1',
+  'hexiao_min_takecash_money' => '1',
+  'hexiao_max_takecash_money' => '10000',
+  'hexiao_takecash_plat_bili' => '6',
   'user_default_avatar' => '/uploads/20240522/47eb7f0430d48a73346b1630692e20ae.png',
   'unishop_order_hexiaomoney_bili' => '10',
   'index_show_product' => '18',
+  'hexiao_take_cash_days' => 
+  array (
+    0 => '21',
+    1 => '22',
+    2 => '23',
+    3 => '24',
+    4 => '25',
+    5 => '26',
+  ),
 );

+ 2 - 2
application/extra/wallet.php

@@ -20,8 +20,8 @@ return [
 ///////////////////////
         201 => '核销订单',//hexiaomoney +
 
-        221 => '钱包余额提现',//money -
-        222 => '提现拒绝返回',//money +
+        221 => '核销余额提现',//hexiaomoney -
+        222 => '提现拒绝返回',//hexiaomoney +