瀏覽代碼

提现相关

zhangxiaobin 1 年之前
父節點
當前提交
0959e2b5f2

+ 100 - 14
application/api/controller/Usercenter.php

@@ -1149,11 +1149,11 @@ class UserCenter extends Common
      * 提现配置列表
      * @return void
      */
-    public function withdrawalList()
+    public function withdrawalConfigList()
     {
         try {
             $field = 'id,money,real_money';
-            $result = model('Withdrawal')->field($field)->autopage()->order('weigh asc')->select();
+            $result = model('WithdrawalConfig')->field($field)->autopage()->order('weigh asc')->select();
 
             $this->success('获取成功',$result);
         } catch (Exception $e) {
@@ -1167,11 +1167,14 @@ class UserCenter extends Common
      */
     public function withdrawal()
     {
+        Db::startTrans();
         try {
             $withdrawConfigId = $this->request->param('id',0);
             $money = $this->request->param('money',0.00);
+            $type = $this->request->param('type',0);
             $userId = $this->auth->id;
             $isAnchor = $this->auth->is_anchor;
+            $userMoney = $this->auth->money;
             if (empty($withdrawConfigId) && empty($money)) {
                 throw new Exception('参数错误');
             }
@@ -1179,23 +1182,106 @@ class UserCenter extends Common
             if ($isAnchor != 2) {
                 throw new Exception('您不是主播不允许提现');
             }
+            //验证提现类型
+            $withdrawTypeConfig = config('wallet.withdraw_type');
+            $typeIds = array_keys($withdrawTypeConfig);
+            if (!in_array($type,$typeIds)) {
+                throw new Exception('未知的提现类型');
+            }
+            $typeStr = isset($withdrawTypeConfig[$type]) ? $withdrawTypeConfig[$type] : '';
+            $withdrawRateConfig = config('site.withdrawRate');//用户获取的金额比例(需要/100)
+            $withdrawRate = bcdiv($withdrawRateConfig,100,2);
+            if (!empty($money)) {//自定义金额
+                if ($money <= 0) {
+                    throw new Exception('金额有误');
+                }
+                $moneys = bcmul($money,$withdrawRate,2);
+                $platformMoney = bcsub($money,$moneys,2);
+            } else {//提现配置
+                $where['id'] = $withdrawConfigId;
+                $withdrawalConfig = model('WithdrawalConfig')->where($where)->find();
+                if (empty($withdrawalConfig)) {
+                    throw new Exception('未知的配置信息');
+                }
+                $moneys = $withdrawalConfig['money'];
+                $platformMoney = bcsub($moneys,$withdrawalConfig['real_money'],2);;
+            }
+            if ($moneys <= 0) {
+                throw new Exception('申请金额异常');
+            }
+            //扣减余额 记录余额日志
+            $walletRes = model('wallet')->lockChangeAccountRemain($userId, $moneys, '-', $userMoney, '申请提现', 104,'money');
+            if (!$walletRes['status']) {
+                throw new Exception($walletRes['msg']);
+            }
+            $account = $name = '';
+            if ($type == 1) {//微信
+                $account = '';
+                $name = '';
+            } elseif ($type == 2) {//支付宝
+                $userAlipayWhere['user_id'] = $userId;
+                $userAlipay = model('UserAlipay')->where($userAlipayWhere)->find();
+                if (empty($userAlipay)) {
+                    throw new Exception('请绑定支付宝');
+                }
+                $account = $userAlipay['pay_no'];
+                $name = $userAlipay['realname'];
+            } elseif ($type == 3) {//银行
+                $userBankWhere['user_id'] = $userId;
+                $userBank = model('UserBank')->where($userBankWhere)->find();
+                if (empty($userBank)) {
+                    throw new Exception('请绑定银行卡');
+                }
+                $account = $userBank['bank_no'];
+                $name = $userBank['realname'];
+            }
             $data = [
                 'user_id'       => $userId,//用户ID
-                'money'         => '',//金额
-                'handingfee'    => '',//手续费
-                'taxes'         => '',//税费
-                'type'          => '',//类型
-                'account'       => '',//提现账户
-                'name'          => '',//真实姓名
-                'memo'          => '',//备注
-                'orderid'       => '',//订单号
-                'transactionid' => '',//流水号
-                'status'        => '',//状态:created=申请中,successed=成功,rejected=已拒绝
-                'transfertime'  => '',//转账时间
-                'createtime'    => '',//添加时间
+                'money'         => $moneys,//金额
+                'handingfee'    => $platformMoney,//手续费
+                'taxes'         => 0.00,//税费
+                'type'          => $typeStr,//类型
+                'account'       => $account,//提现账户
+                'name'          => $name,//真实姓名
+                //'memo'          => '',//备注
+                //'orderid'       => '',//订单号
+                //'transactionid' => '',//流水号
+                'status'        => 'created',//状态:created=申请中,successed=成功,rejected=已拒绝
+                //'transfertime'  => '',//转账时间
+                'createtime'    => time(),//添加时间
             ];
+            $withdrawRes = model('Withdraw')->insertGetId($data);
+            if (!$withdrawRes) {
+                throw new Exception('提现失败');
+            }
+            Db::commit();
             $this->success('操作成功待审核');
         } catch (Exception $e) {
+            Db::rollback();
+            $this->error($e->getMessage());
+        }
+    }
+
+    /**
+     * 提现列表
+     * @return void
+     */
+    public function withdrawalList()
+    {
+        try {
+            $field = 'id,money,type,status,createtime,transfertime';
+            $where=[];
+            //$where['status'] = 'successed';//状态:created=申请中,successed=成功,rejected=已拒绝
+            $result = model('Withdraw')->field($field)->where($where)->autopage()->order('createtime desc')->select();
+            if (!empty($result)) {
+                foreach ($result as $key => &$value) {
+                    $value['money'] = '-'.$value['money'];
+                    $value['createtime'] = !empty($value['createtime']) ? date('Y-m-d H:i', $value['createtime']) : '';
+                    $value['transfertime'] = !empty($value['transfertime']) ? date('Y-m-d H:i', $value['transfertime']) : '';
+                }
+            }
+            $this->success('获取成功',$result);
+        } catch (Exception $e) {
             $this->error($e->getMessage());
         }
     }

+ 52 - 0
application/common/model/Withdraw.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+
+class Withdraw extends Model
+{
+
+
+    // 表名
+    protected $name = 'withdraw';
+
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+    protected $updateTime = 'updatetime';
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'status_text',
+        'type_text',
+    ];
+
+    public function getStatusList()
+    {
+        return ['created'=>'申请中', 'successed'=>'成功', 'rejected'=>'已拒绝'];
+    }
+
+    public function getStatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
+        $list = $this->getStatusList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+    public function getTypeList()
+    {
+        return ['wechat'=>'微信', 'alipay'=>'支付宝', 'bank'=> '银行'];
+    }
+
+    public function getTypeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
+        $list = $this->getTypeList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+}

+ 1 - 1
application/common/model/Withdrawal.php → application/common/model/WithdrawalConfig.php

@@ -5,7 +5,7 @@ namespace app\common\model;
 use think\Model;
 
 
-class Withdrawal extends Model
+class WithdrawalConfig extends Model
 {
 
 

+ 2 - 5
application/common/service/RoomService.php

@@ -217,22 +217,19 @@ class RoomService
             $partyId = isset($params['party_id']) ? $params['party_id'] : 0;
             $userIds = $this->redis->zRange("party_user_".$partyId,0,-1);
             $field = 'id,avatar,nickname';
-            $fieldArr = explode(',',$field);
             $userWhere['id'] = ['in', $userIds];
             $userModel = new \app\common\model\User();
             $userData = $userModel->field($field)->where($userWhere)->select();
             $userDatas = [];
             if (!empty($userData)) {
                 foreach($userData as $key => $value) {
-                    foreach ($fieldArr as $fieldk => $fieldv) {
-                        $userDatas[$key][$fieldv] = $value[$fieldv];
-                    }
+                    $userDatas[$key] = $value;
                 }
                 $userDatas = list_domain_image($userDatas,['avatar']);
             }
             $partyUserList = [
                 'member_list' => $userDatas,
-                'online_num' => count($userData),
+                'online_num' => !empty($userDatas) ? count($userDatas) : 0,
             ];
             $result['data'] = $partyUserList;
         } catch (Exception $e) {

+ 1 - 1
application/common/service/UserService.php

@@ -164,7 +164,7 @@ class UserService
                         if (!empty($preUser)) {
                             //查看是否赠送过金额
                             $moneyLogWhere['invite_user_id'] = $userId;
-                            $moneyLogWhere['type'] = 15;
+                            $moneyLogWhere['type'] = 103;
                             $moneyLog = model('UserMoneyLog')->where($moneyLogWhere)->find();
                             if (empty($moneyLog)) {
                                 $money = config('site.invite_money');

+ 1 - 1
application/extra/site.php

@@ -99,7 +99,7 @@ return [
     'withdraw' => '<p>提现说明</p><p>1、GG语音服务人员随时可以申请提现,到账时间为T+1,如果遇到双休日或者国家法定节假日,则会在休假完毕后的第一个工作日的当日24:00前到账,如提现申请过多,可能会延迟到账,可联系官方在线客服进行咨询;</p><p>2、GG语音服务人员在平台内可以使用声币进行提现,提现收取5%的手续费</p><p>3、收益支持银行卡提现,GG语音服务人员需要先绑定本人经过实名认证的身份证信息才可以提现,绑定时务必确保所填信息真实有效,因为填写资料错误导致的提现失败损失由伴声服务人员自行承担。注意:同一个银行卡只能绑定一个实名认证用户,修改是不支持对账号主体(即真实姓名和身份证号)进行修改;</p><p>4、提现金额仅限整数,当前可提现额度小于30元时,不可进行收益体现,当日提现金额最高50000元;</p><p>5、如公司检测到GG语音服务人员的GG账户有作弊或者异常,或者违反国家法律法规的异常情况,公司将拒绝该GG语音服务人员对收入进行提现;</p><p>6、收益提现规则最终解释权归GG语音所有。</p>',
     'uidsale' => '11111111,22222222,33333333,44444444,55555555,66666666,77777777,88888888,99999999,12345678,10000000,20000000,30000000,400000000,50000000,60000000,70000000,80000000,90000000',
     'getempirical' => '1',
-    'withdrawRate' => '100',
+    'withdrawRate' => '99',
     'switch' => '1',
     'appShare' => '/uploads/20210422/75744fbe87ee36e52ffffcb82acdc403.png',
     'roomLimit' => '50',

+ 9 - 2
application/extra/wallet.php

@@ -19,14 +19,21 @@ return [
         12 => '私聊到账',  //增加
         13 => '抽奖箱子和转盘', //减少
         14 => '余额兑换钻石', //增加
-        15 => '邀请用户充值赠送金额', //增加
+
         //money
         101 => '获赠礼物', //增加
         102 => '房间礼物抽成', //增加
+        103 => '邀请用户充值赠送金额', //增加
+        104 => '申请提现', //减少
+        105 => '申请提现驳回', //增加
     ],
     'moneyname' => [
         'jewel'    => '钻石',
         'money'    => '余额',
     ],
-
+    'withdraw_type' => [
+        1 => 'wechat',//微信
+        2 => 'alipay',//支付宝
+        3 => 'bank',  //银行
+    ],
 ];