title = '提现列表'; $sel_where = []; $sel_where[] = ['w.is_deleted','=',0]; $this->dep_type = ['','微信','支付宝','银行卡']; $this->sh_arr = ['待审核','审核通过','审核拒绝','打款成功','打款失败']; if($name = $this->request->get('name')) $sel_where[] =['m.name','like','%'.$name.'%']; if($phone = $this->request->get('phone')) $sel_where[] =['m.phone','like','%'.$phone.'%']; if($type = $this->request->get('type')){ if($type == 1) $sel_where[] =['w.withdraw_type','=','wx']; if($type == 2) $sel_where[] =['w.withdraw_type','=','zfb']; if($type == 3) $sel_where[] =['w.withdraw_type','=','bank']; } $sel_sh = input('sel_sh',-1); $this->sel_sh = $sel_sh; switch ($sel_sh) { case 0 ;case 1 ; case 2: $sel_where[] =['w.sh_status','=',$sel_sh]; break; case 3: $sel_where[] =['w.sh_status','=',2]; $sel_where[] =['w.is_over','=',1]; $sel_where[] =['w.paid','=',1]; break; case 4: $sel_where[] =['w.sh_status','=',1]; $sel_where[] =['w.paid','=',0]; break; } $query = $this->_query($this->table)->alias('w') ->where($sel_where) ->field('w.*,m.headimg,m.openid,m.name as m_name') ->join('store_member m','m.id = w.mid'); $query->dateBetween('w.create_at')->order('w.id desc')->page(); } /** * 数据列表处理 * @auth true * @menu true * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(&$data) { foreach ($data as $k=>&$v){ $v['return_info'] = $v['return_info'] ? json_decode($v['return_info'],true):[]; } } protected function _form_filter(&$data){ if($this->request->isGet() && $this->request->action() == 'edit') { $this->user = Db::name('store_member')->field('headimg,name,phone')->find($data['mid']); } // 提现审核 if($this->request->isPost() && $this->request->action() == 'edit'){ // 同意提现 $withdrawal = Db::name('store_member_withdraw')->where('id',$data['id'])->find(); if($withdrawal['is_over'] == 1) $this->error('该记录已完成,无法进行操作'); $data['sh_time'] = date("Y-m-d H:i:s"); } } protected function _edit_form_result($id) { if($this->request->isPost()) { $withdrawal = Db::name('store_member_withdraw')->where('id',$id)->find(); if($withdrawal['is_over'] == 0) { // 同意提现 if($this->request->sh_status == 1){ switch ($withdrawal['withdraw_type'] ){ case 'wx':// 提现到微信 $app = Factory::payment(config('app.wx_pay')); $result = $app->transfer->toBalance([ 'partner_trade_no' => $withdrawal['order_no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号) 'openid' => $withdrawal['account_no'], 'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名 're_user_name' => '', // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名 'amount' =>$withdrawal['real_money'] * 100,// 企业付款金额,单位为分 'desc' =>'会员提现'//企业付款操作说明信息。必填 ]); if(isset($result['err_code_des'])) $this->error($result['err_code_des']); Db::name('store_member_withdraw')->where('id',$withdrawal['id'])->update(['paid'=>1,'pay_time'=>time(),'is_over'=>1,'return_info'=>json_encode($result,true)]); break; case 'zfb':// 提现到支付宝 $zfb = new AliPay2();//实例化支付宝支付控制器 $result = $zfb->FundTransToaccount($withdrawal['order_no'], $withdrawal['account_no'], $withdrawal['account_name'], $withdrawal['real_money'],'象链数藏余额提现');//调用支付宝支付的方法 if (!empty($result) && $result['code'] == 10000){ Db::name('store_member_withdraw')->where('id',$withdrawal['id'])->update(['paid'=>1,'pay_time'=>time(),'is_over'=>1,'return_info'=>json_encode($result['result'],true)]); }else{ Db::name('store_member_withdraw')->where('id',$withdrawal['id'])->update(['return_info'=>json_encode($result['result'],true)]); $this->error('提现失败,请检查绑定的支付宝信息'); } break; case 'bank': $Shande= new Shande(); $result = $Shande->payToCard($withdrawal['account_no'],$withdrawal['account_name'],$withdrawal['real_money'],$withdrawal['order_no'],'会员提现'); if(empty($result) || $result['respCode']!='0000'){//失败 Db::name('store_member_withdraw')->where('id',$withdrawal['id'])->update(['return_info'=>json_encode($result,true),'order_no'=>get_order_sn()]); $this->error($result['respDesc']); }else{ Db::name('store_member_withdraw')->where('id',$withdrawal['id'])->update(['paid'=>1,'pay_time'=>time(),'is_over'=>1,'return_info'=>json_encode($result,true)]); } break; } }else if ($this->request->sh_status ==2){ memberMoneyChange($withdrawal['price'],3,$withdrawal['mid'],'提现驳回',1,$withdrawal['id'],3); Db::name('store_member_withdraw')->where('id',$withdrawal['id'])->update(['is_over'=>1]); $this->success('保存成功'); } } } } /** * 审核 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function edit() { $this->title = '审核'; $this->_form($this->table, 'form'); } /** * 导出EXCL * @remark 根据WHERE条件导出EXCL * @param array $post 查询条件所需值 * @return array */ public function get_excl() { set_time_limit(0); $sel_where =[]; if($name = $this->request->get('name')) $sel_where[] =['m.name','like','%'.$name.'%']; if($phone = $this->request->get('phone')) $sel_where[] =['m.phone','like','%'.$phone.'%']; if($type = $this->request->get('type')){ if($type == 1) $sel_where[] =['w.withdraw_type','=','wx']; if($type == 2) $sel_where[] =['w.withdraw_type','=','zfb']; } $sel_sh = input('sel_sh',-1); switch ($sel_sh) { case 0 ;case 1 ; case 2: $sel_where[] =['w.sh_status','=',$sel_sh]; break; case 3: $sel_where[] =['w.sh_status','=',2]; $sel_where[] =['w.paid','=',1]; $sel_where[] =['w.is_over','=',1]; break; case 4: $sel_where[] =['w.sh_status','=',1]; $sel_where[] =['w.paid','=',0]; break; } $sel_time = input('create_at'); if($sel_time) { $time_arr = explode(' - ',$sel_time); $where[]= ['o.create_at','> time',$time_arr[0].' 00:00:00']; $where[]= ['o.create_at','< time',$time_arr[1].' 00:00:00']; } $list =Db::name('store_member_withdraw')->alias('w') ->where($sel_where) ->field('w.*,m.headimg,m.openid,m.name as m_name,m.phone') ->join('store_member m','m.id = w.mid') ->order('w.id desc')->select(); $export = []; $sh_dsec = ['待审核','审核通过','审核拒绝[余额已退回]']; if (is_array($list)) { foreach ($list as $index => $item) { $item['withdraw_type'] = $item['withdraw_type'] == 'wx'?'微信':'支付宝'; $item['sh_status'] = $sh_dsec[$item['sh_status']]; $item['paid'] = $item['paid'] == 1 ? '是':'否'; $export[] = [ $item['m_name'], $item['phone'], $item['order_no'], $item['price'], $item['proportion'], $item['real_money'], $item['paid'], $item['create_at'], $item['sh_time'], $item['sh_status'], $item['sh_remark'], $item['withdraw_type'], $item['account_name'], $item['account_no'], ]; } } $title = ['用户名','手机号','单号','提现金额','服务费','应到账','是否到账','申请时间','审核时间','审核状态','审核备注','提现方式','收款人','收款账号']; PHPExcelService::setExcelHeader($title) ->setExcelTile('提现记录导出' . date('YmdHis', time()), '提现记录' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time())) ->setExcelContent($export) ->ExcelSave(); } }