| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\controller\Api;
 
- use think\Db;
 
- /**
 
-  * 会员中心
 
-  */
 
- class Money extends Api
 
- {
 
-     protected $noNeedLogin = [];
 
-     protected $noNeedRight = '*';
 
-     //配置
 
-     public function withdraw_config(){
 
-         $data = [
 
-             'score' => model('wallet')->getWallet($this->auth->id,'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(),
 
-             'type_2' => Db::name('user_withdraw')->where('user_id',$this->auth->id)->where('type',2)->where('status',1)->field('realname,banknumber,bankname')->find(),
 
-             'type_3' => Db::name('user_withdraw')->where('user_id',$this->auth->id)->where('type',3)->where('status',1)->field('realname,banknumber,bankname')->find(),
 
-         ];
 
-         $this->success(1,$data);
 
-     }
 
-     //提现
 
-     public function 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('余额不足');
 
-         }
 
-         //查询最低最高提现金额
 
-         $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['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',-$money,2,'积分兑换','user_withdraw',$log_id);
 
-         if ($rs_wallet['status'] == false) {
 
-             $this->error($rs_wallet['msg']);
 
-             Db::rollback();
 
-         }
 
-         Db::commit();
 
-         $this->success('申请兑换成功,请等待审核');
 
-     }
 
-     //用户钱包流水
 
-     public function scorelog(){
 
-         $list = Db::name('user_score_log')->field('id,change_value,log_type,createtime')->where('user_id',$this->auth->id)->autopage()->order('id desc')->select();
 
-         foreach($list as $key => &$val){
 
-             $val['log_type_text'] = model('wallet')->getlogtype($val['log_type']);
 
-         }
 
-         $this->success('success',$list);
 
-     }
 
- }
 
 
  |