search_url = strtolower($this->request->controller()).'/index_search'; $this->title = '提现列表'; $sel_where = []; $sel_where[] = ['w.is_deleted','=',0]; $this->dep_type = ['','支付宝','银行卡','微信']; $this->status_arr = ['待审核','已审核','已到账','已拒绝','打款异常']; if($name = $this->request->get('name')) $sel_where[] =['w.user_name','=',$name]; if($phone = $this->request->get('phone')) $sel_where[] =['m.phone','=',$phone]; if($type = $this->request->get('type')) $sel_where[] =['w.type','=',$type]; $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.user_id'); $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){ } } 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['user_id']); } // 提现审核 if($this->request->isPost() && $this->request->action() == 'edit'){ // 同意提现 if($data['status'] == 1){ $remit_success = 0; $withdrawal = UserWithdrawLog::where('id',$data['id'])->find()->toArray(); if($withdrawal['status'] == 2) $this->error('已提现成功'); if($withdrawal['status'] == 3) $this->error('余额已退回,无法进行退款操作'); switch ($withdrawal['type'] ){ case 1:// 提现到银行卡 break; case 2:// 提现到支付宝 $result = Alipay::ali_withdrawal($withdrawal['trade_no'],$withdrawal['account'],$withdrawal['card_no'],$withdrawal['user_name']); if($result) $remit_success = 1; break; case 3:// 提现到微信 $app = Factory::payment(config('app.wx_pay')); $res = $app->transfer->toBalance([ 'partner_trade_no' => $withdrawal['trade_no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号) 'openid' => $withdrawal['card_no'], 'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名 're_user_name' => '', // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名 'amount' =>$withdrawal['account'] * 100,// 企业付款金额,单位为分 'desc' =>'会员提现'//企业付款操作说明信息。必填 ]); if(isset($res['err_code_des'])) $this->error($res['err_code_des']); $remit_success = 1; break; } if($remit_success == 1){ UserWithdrawLog::where('id',$data['id'])->update(['status'=>2,'desc'=>$data['desc']]); $this->success('提现成功'); }else{ UserWithdrawLog::where('id',$data['id'])->update(['status'=>4,'desc'=>$data['desc']]); $this->error('打款失败'); } }else if ($data['status'] ==3 ){ // 拒绝提现 返回余额 $withdrawal = UserWithdrawLog::where('id',$data['id'])->find()->toArray(); if($withdrawal['status'] == 2) $this->error('已提现成功'); if($withdrawal['status'] == 3) $this->error('余额已退回,无法进行退款操作'); Db::startTrans(); try { // 退还余额 UserWallet::userMoneyChange($withdrawal['user_id'],$withdrawal['money'],'提现拒绝',11, 1,$withdrawal['id']); // 修改状态 UserWithdrawLog::where('id',$data['id'])->update(['status'=>$data['status'],'desc'=>$data['desc']]); Db::commit(); }catch (\Exception $e){ Db::rollback(); $this->error($e->getMessage()); } $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'); } }