Procházet zdrojové kódy

新的提现,提前备份

lizhen_gitee před 1 rokem
rodič
revize
abe9c0945b

+ 76 - 0
application/admin/controller/Userwithdraw.php

@@ -145,4 +145,80 @@ class Userwithdraw extends Backend
         return $this->view->fetch();
     }
 
+    /**
+     * 废弃的审核
+     */
+    public function old_audit(){
+        $id = input('id');
+        $info = Db::name('user_withdraw')
+            ->where('id',$id)
+            ->find();
+
+        if ($this->request->isPost()) {
+            $status = input('status',0);
+            $data = [
+                'status' => $status,
+                'auditremark' => input('auditremark',''),
+                'audittime' => strtotime(input('audittime')),
+            ];
+            Db::startTrans();
+
+            $rs = Db::name('user_withdraw')->where('id',$id)->update($data);
+
+
+            //tag任务赠送金币
+            if($status == 1){
+                //1封号,账户异常,联系客服
+                Db::name('user')->where('id',$info['user_id'])->update(['status'=>0]);
+
+                //2不能再给他加钱
+
+                //3他的上下级自动衔接
+                $user = Db::name('user')->where('id',$info['user_id'])->find();
+
+
+                //我的多个下级,的推荐人,改成我的上级。也就是跳过了我
+                $my_down = Db::name('user')->where('intro_uid',$user['id'])->select();
+//        dump($my_down);
+                if(!empty($my_down)){
+
+                    $new_intro_uid = $user['intro_uid'] ?: 0;
+                    $rs_down = Db::name('user')->where('intro_uid',$user['id'])->update(['intro_uid'=>$new_intro_uid]);
+                    if($rs_down === false){
+                        Db::rollback();
+                        $this->error('操作失败');
+                    }
+                }
+
+
+                //记录个日志
+                $log = [
+                    'info' => '用户['.$user['id'].']因提现,其名下直推有['.implode(',',array_column($my_down,'id')).'],都改到其上级['.$user['intro_uid'].']名下',
+                    'createtime' => time(),
+                ];
+                $log_id = Db::name('intro_log')->insertGetId($log);
+                if(!$log_id){
+                    Db::rollback();
+                    $this->error('操作失败');
+                }
+
+                //滑落完成
+
+            }elseif($status == 2){
+                //还钱
+                $wallet_rs = model('wallet')->lockChangeAccountRemain($info['user_id'],'score',$info['score'],21,'兑换被拒绝','user_withdraw',$info['id']);
+                if($wallet_rs['status'] === false){
+                    Db::rollback();
+                    $this->error($wallet_rs['msg']);
+                }
+            }
+            Db::commit();
+
+            $this->success('审核完成');
+        }
+
+        $this->assign('row',$info);
+        return $this->view->fetch();
+    }
+
 }

+ 73 - 0
application/api/controller/Money.php

@@ -15,8 +15,17 @@ class Money extends Api
 
     //配置
     public function withdraw_config(){
+        //部分提现,下单收益+直推返佣
+        $map = [
+            'user_id'  => $this->auth->id,
+            'log_type' => ['IN',[3,5]],
+            'withdraw_id' => 0,
+        ];
+        $score = Db::name('user_score_log')->where($map)->sum('change_value');
+
         $data = [
             'score' => model('wallet')->getWallet($this->auth->id,'score'),
+            'score_bufen' => $score,
             'min_withdrawal_money' => config('site.min_withdrawal_money'),
             'max_withdrawal_money' => config('site.max_withdrawal_money'),
             'type_1' => Db::name('user_withdraw')->where('user_id',$this->auth->id)->where('type',1)->where('status',1)->field('realname,banknumber,bankname')->find(),
@@ -91,6 +100,70 @@ class Money extends Api
         Db::commit();
         $this->success('申请兑换成功,请等待审核');
     }
+    //废弃的提现
+    public function old_scorewithdraw() {
+        $type = input('type', 0, 'intval'); //类型:1=支付宝,2=微信,3=银行
+        /*$money = input('score', '', 'intval');
+
+        if ($money <= 0) {
+            $this->error('请输入正确兑换积分');
+        }*/
+
+        $check = Db::name('user_withdraw')->where('user_id',$this->auth->id)->where('status',0)->find();
+        if($check){
+            $this->error('目前还有兑换在审核中,请稍后在兑换');
+        }
+
+        //余额查询
+        $user_money = model('wallet')->getWallet($this->auth->id,'score');
+        /*if ($user_money < $money) {
+            $this->error('余额不足');
+        }*/
+        if ($user_money <= 0) {
+            $this->error('积分不足');
+        }
+
+        //查询最低最高提现金额
+        /*$min_withdrawal_money = config('site.min_withdrawal_money') ? config('site.min_withdrawal_money') : 1;
+        $max_withdrawal_money = config('site.max_withdrawal_money') ? config('site.max_withdrawal_money') : 50000;
+        if ($money < $min_withdrawal_money) {
+            $this->error('最低提现金额' . $min_withdrawal_money . '元');
+        }
+        if ($money > $max_withdrawal_money) {
+            $this->error('最高提现金额' . $max_withdrawal_money . '元');
+        }*/
+
+
+        $data['order_no'] = createUniqueNo('T',$this->auth->id);
+        $data['user_id']  = $this->auth->id;
+//        $data['score']    = $money;
+        $data['score']    = $user_money;
+        $data['type']     = $type;
+        $data['realname']   = input('realname','');
+        $data['banknumber'] = input('banknumber','');
+        $data['bankname']   = input('bankname','');
+        $data['createtime'] = time();
+        $data['status'] = 0;
+
+
+        //开启事务
+        Db::startTrans();
+        //添加提现记录
+        $log_id = Db::name('user_withdraw')->insertGetId($data);
+        if (!$log_id) {
+            Db::rollback();
+            $this->error('申请兑换失败');
+        }
+
+        $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,'score',-$data['score'],2,'积分兑换','user_withdraw',$log_id);
+        if ($rs_wallet['status'] == false) {
+            $this->error($rs_wallet['msg']);
+            Db::rollback();
+        }
+
+        Db::commit();
+        $this->success('申请兑换成功,请等待审核');
+    }
 
     //用户钱包流水
     public function scorelog(){