Kirin 3 tahun lalu
induk
melakukan
44723d548e

+ 6 - 0
app/admin/controller/finance/UserExtract.php

@@ -9,6 +9,7 @@
 namespace app\admin\controller\finance;
 
 use app\admin\controller\AuthController;
+use app\models\user\UserBill;
 use think\facade\Route as Url;
 use crmeb\services\JsonService;
 use app\admin\model\user\UserExtract as UserExtractModel;
@@ -143,6 +144,11 @@ class UserExtract extends AuthController
         if ($extract->status == 1) return JsonService::fail('您已提现,请勿重复提现!');
         if ($extract->status == -1) return JsonService::fail('您的提现申请已被拒绝!');
         $res = UserExtractModel::changeSuccess($id);
+        if ($extract['extract_price'] > $extract['real_get']) {
+            $num = $extract['extract_price'] - $extract['real_get'];
+            $res = $res && UserBill::income('提现转换', $extract['uid'], 'integral', 'extract_get', $num, $extract['id'], \app\admin\model\user\User::where('uid', $extract['uid'])->value('integral') + $num, '提现申请通过,其中部分佣金转换为响亮积分' . $num);
+            $res = $res && \app\admin\model\user\User::where('uid', $extract['uid'])->inc('integral', $num)->update();
+        }
         if ($res) {
             UserExtractModel::commitTrans();
             return JsonService::successful('操作成功!');

+ 18 - 14
app/admin/view/finance/user_extract/index.php

@@ -93,16 +93,17 @@
                 <div class="table-responsive">
                     <table class="table table-striped  table-bordered">
                         <thead>
-                            <tr>
-                                <th class="text-center">编号</th>
-                                <th class="text-center">用户信息</th>
-                                <th class="text-center">提现金额</th>
-                                <th class="text-center">提现方式</th>
-                                <th class="text-center">添加时间</th>
-                                <th class="text-center">备注</th>
-                                <th class="text-center">审核状态</th>
-                                <th class="text-center">操作</th>
-                            </tr>
+                        <tr>
+                            <th class="text-center">编号</th>
+                            <th class="text-center">用户信息</th>
+                            <th class="text-center">提现金额</th>
+                            <th class="text-center">实际到账</th>
+                            <th class="text-center">提现方式</th>
+                            <th class="text-center">添加时间</th>
+                            <th class="text-center">备注</th>
+                            <th class="text-center">审核状态</th>
+                            <th class="text-center">操作</th>
+                        </tr>
                         </thead>
                         <tbody class="">
                         {volist name="list" id="vo"}
@@ -111,23 +112,26 @@
                                 {$vo.id}
                             </td>
                             <td class="text-center">
-                               用户昵称: {$vo.nickname}/用户id:{$vo.uid}
+                                用户昵称: {$vo.nickname}/用户id:{$vo.uid}
                             </td>
                             <td class="text-center" style="color: #00aa00;">
                                 {$vo.extract_price}
                             </td>
+                            <td class="text-center" style="color: #00aa00;">
+                                {$vo.real_get}
+                            </td>
                             <td class="text-left">
                                 {if condition="$vo['extract_type'] eq 'bank'"}
                                 姓名:{$vo.real_name}<br>
-                                 银行卡号:{$vo.bank_code}
+                                银行卡号:{$vo.bank_code}
                                 <br/>
-                                 银行开户地址:{$vo.bank_address}
+                                银行开户地址:{$vo.bank_address}
                                 {elseif condition="$vo['extract_type'] eq 'weixin'"/}
                                 昵称:{$vo.nickname}<br>
                                 微信号:{$vo.wechat}
                                 {else/}
                                 姓名:{$vo.real_name}<br>
-                                  支付宝号:{$vo.alipay_code}
+                                支付宝号:{$vo.alipay_code}
                                 {/if}
                             </td>
                             <td class="text-center">

+ 48 - 44
app/models/user/UserExtract.php

@@ -40,14 +40,14 @@ class UserExtract extends BaseModel
     //已提现
     const SUCCESS_STATUS = 1;
 
-    protected static $extractType = ['alipay','bank','weixin'];
+    protected static $extractType = ['alipay', 'bank', 'weixin'];
 
-    protected static $extractTypeMsg = ['alipay'=>'支付宝','bank'=>'银行卡','weixin'=>'微信'];
+    protected static $extractTypeMsg = ['alipay' => '支付宝', 'bank' => '银行卡', 'weixin' => '微信'];
 
     protected static $status = array(
-        -1=>'未通过',
-        0 =>'审核中',
-        1 =>'已提现'
+        -1 => '未通过',
+        0 => '审核中',
+        1 => '已提现'
     );
 
     /**
@@ -56,61 +56,65 @@ class UserExtract extends BaseModel
      * @param array $data 提现详细信息
      * @return bool
      */
-    public static function userExtract($userInfo,$data){
-        if(!in_array($data['extract_type'],self::$extractType))
+    public static function userExtract($userInfo, $data)
+    {
+        if (!in_array($data['extract_type'], self::$extractType))
             return self::setErrorInfo('提现方式不存在');
         $userInfo = User::get($userInfo['uid']);
         $extractPrice = $userInfo['brokerage_price'];
-        if($extractPrice < 0) return self::setErrorInfo('提现佣金不足'.$data['money']);
-        if($data['money'] > $extractPrice) return self::setErrorInfo('提现佣金不足'.$data['money']);
-        if($data['money'] <= 0) return self::setErrorInfo('提现佣金大于0');
-        $balance = bcsub($userInfo['brokerage_price'],$data['money'],2);
-        if($balance < 0) $balance=0;
+        if ($extractPrice < 0) return self::setErrorInfo('提现佣金不足' . $data['money']);
+        if ($data['money'] > $extractPrice) return self::setErrorInfo('提现佣金不足' . $data['money']);
+        if ($data['money'] <= 0) return self::setErrorInfo('提现佣金大于0');
+        $balance = bcsub($userInfo['brokerage_price'], $data['money'], 2);
+        if ($balance < 0) $balance = 0;
+        $real_get_ratio = sys_config('extract_ratio', 100);//实际到账率
         $insertData = [
             'uid' => $userInfo['uid'],
             'extract_type' => $data['extract_type'],
             'extract_price' => $data['money'],
             'add_time' => time(),
             'balance' => $balance,
+            'real_get' => bcmul(bcdiv($real_get_ratio, 100, 4), $data['money'], 2),
             'status' => self::AUDIT_STATUS
         ];
-        if(isset($data['name']) && strlen(trim($data['name']))) $insertData['real_name'] = $data['name'];
+        if (isset($data['name']) && strlen(trim($data['name']))) $insertData['real_name'] = $data['name'];
         else $insertData['real_name'] = $userInfo['nickname'];
-        if(isset($data['cardnum'])) $insertData['bank_code'] = $data['cardnum'];
+        if (isset($data['cardnum'])) $insertData['bank_code'] = $data['cardnum'];
         else $insertData['bank_code'] = '';
-        if(isset($data['bankname'])) $insertData['bank_address']=$data['bankname'];
-        else $insertData['bank_address']='';
-        if(isset($data['weixin'])) $insertData['wechat'] = $data['weixin'];
+        if (isset($data['bankname'])) $insertData['bank_address'] = $data['bankname'];
+        else $insertData['bank_address'] = '';
+        if (isset($data['weixin'])) $insertData['wechat'] = $data['weixin'];
         else $insertData['wechat'] = $userInfo['nickname'];
-        if($data['extract_type'] == 'alipay'){
-            if(!$data['alipay_code']) return self::setErrorInfo('请输入支付宝账号');
+        if ($data['extract_type'] == 'alipay') {
+            if (!$data['alipay_code']) return self::setErrorInfo('请输入支付宝账号');
             $insertData['alipay_code'] = $data['alipay_code'];
-            $mark = '使用支付宝提现'.$insertData['extract_price'].'元';
-        }else if($data['extract_type'] == 'bank'){
-            if(!$data['cardnum']) return self::setErrorInfo('请输入银行卡账号');
-            if(!$data['bankname']) return self::setErrorInfo('请输入开户行信息');
-            $mark = '使用银联卡'.$insertData['bank_code'].'提现'.$insertData['extract_price'].'元';
-        }else if($data['extract_type'] == 'weixin'){
-            if(!$data['weixin']) return self::setErrorInfo('请输入微信账号');
-            $mark = '使用微信提现'.$insertData['extract_price'].'元';
+            $mark = '使用支付宝提现' . $insertData['extract_price'] . '元';
+        } else if ($data['extract_type'] == 'bank') {
+            if (!$data['cardnum']) return self::setErrorInfo('请输入银行卡账号');
+            if (!$data['bankname']) return self::setErrorInfo('请输入开户行信息');
+            $mark = '使用银联卡' . $insertData['bank_code'] . '提现' . $insertData['extract_price'] . '元';
+        } else if ($data['extract_type'] == 'weixin') {
+            if (!$data['weixin']) return self::setErrorInfo('请输入微信账号');
+            $mark = '使用微信提现' . $insertData['extract_price'] . '元';
         }
         self::beginTrans();
-        try{
+        try {
             $res1 = self::create($insertData);
-            if(!$res1) return self::setErrorInfo('提现失败');
-            $res2 = User::edit(['brokerage_price'=>$balance],$userInfo['uid'],'uid');
-            $res3 = UserBill::expend('余额提现',$userInfo['uid'],'now_money','extract',$data['money'],$res1['id'],$balance,$mark);
+            if (!$res1) return self::setErrorInfo('提现失败');
+            $res2 = User::edit(['brokerage_price' => $balance], $userInfo['uid'], 'uid');
+            $res3 = UserBill::expend('余额提现', $userInfo['uid'], 'now_money', 'extract', $data['money'], $res1['id'], $balance, $mark);
             $res = $res2 && $res3;
-            if($res){
+            if ($res) {
                 self::commitTrans();
-                try{
-                    ChannelService::instance()->send('WITHDRAW', ['id'=>$res1->id]);
-                }catch (\Exception $e){}
+                try {
+                    ChannelService::instance()->send('WITHDRAW', ['id' => $res1->id]);
+                } catch (\Exception $e) {
+                }
                 event('AdminNewPush');
                 //发送模板消息
                 return true;
-            }else return self::setErrorInfo('提现失败!');
-        }catch (\Exception $e){
+            } else return self::setErrorInfo('提现失败!');
+        } catch (\Exception $e) {
             self::rollbackTrans();
             return self::setErrorInfo('提现失败!');
         }
@@ -131,9 +135,9 @@ class UserExtract extends BaseModel
      * @param $uid
      * @return mixed
      */
-    public static function userExtractTotalPrice($uid,$status=self::SUCCESS_STATUS)
+    public static function userExtractTotalPrice($uid, $status = self::SUCCESS_STATUS)
     {
-        return self::where('uid',$uid)->where('status',$status)->value('SUM(extract_price)')?:0;
+        return self::where('uid', $uid)->where('status', $status)->value('SUM(extract_price)') ?: 0;
     }
 
     /**
@@ -146,11 +150,11 @@ class UserExtract extends BaseModel
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      */
-    public static function extractList($uid,$first = 0,$limit = 8)
+    public static function extractList($uid, $first = 0, $limit = 8)
     {
-        $list=UserExtract::where('uid',$uid)->order('add_time desc')->limit($first,$limit)->select();
-        foreach($list as &$v){
-            $v['add_time']=date('Y/m/d',$v['add_time']);
+        $list = UserExtract::where('uid', $uid)->order('add_time desc')->limit($first, $limit)->select();
+        foreach ($list as &$v) {
+            $v['add_time'] = date('Y/m/d', $v['add_time']);
         }
         return $list;
     }
@@ -162,7 +166,7 @@ class UserExtract extends BaseModel
      */
     public static function extractSum($uid)
     {
-        return self::where('uid',$uid)->where('status',1)->sum('extract_price');
+        return self::where('uid', $uid)->where('status', 1)->sum('extract_price');
     }
 
 }