'未处理', '1'=>'提现成功', '2'=>'拒绝提现', ); if($k===''){ return $status; } return isset($status[$k]) ? $status[$k]: ''; } protected function getTypes($k=''){ $type=array( '1'=>'支付宝', '2'=>'微信', '3'=>'银行卡', ); if($k===''){ return $type; } return isset($type[$k]) ? $type[$k]: ''; } function index(){ $data = $this->request->param(); $map=[]; $status=isset($data['status']) ? $data['status']: ''; if($status!=''){ $map[]=['status','=',$status]; } $cash_type=isset($data['cash_type']) ? $data['cash_type']: ''; if($cash_type!=''){ $map[]=['cash_type','=',$cash_type]; } $start_time=isset($data['start_time']) ? $data['start_time']: ''; $end_time=isset($data['end_time']) ? $data['end_time']: ''; if($start_time!=""){ $map[]=['addtime','>=',strtotime($start_time)]; } if($end_time!=""){ $map[]=['addtime','<=',strtotime($end_time) + 60*60*24]; } $uid=isset($data['uid']) ? $data['uid']: ''; if($uid!=''){ $map[]=['uid','=',$uid]; } $keyword=isset($data['keyword']) ? $data['keyword']: ''; if($keyword!=''){ $map[]=['orderno|trade_no','like',"%".$keyword."%"]; } /*var_dump($map); die;*/ $lists = DB::name("user_cashrecord") ->where($map) ->order('id desc') ->paginate(20); $lists->each(function($v,$k){ $v['userinfo']=getUserInfo($v['uid']); if($v['cash_type']==0){ $v['cash_type_name']='普通提现'; }else{ $v['cash_type_name']='视频红包提现'; } return $v; }); $lists->appends($data); $page = $lists->render(); $cashrecord_total = DB::name("user_cashrecord")->where($map)->sum("money"); if($status==''){ $success=$map; $success[]=['status','=',1]; $fail=$map; $fail[]=['status','=',2]; $wait=$map; $wait[]=['status','=',0]; $cashrecord_success = DB::name("user_cashrecord")->where($success)->sum("money"); $cashrecord_fail = DB::name("user_cashrecord")->where($fail)->sum("money"); $cashrecord_wait = DB::name("user_cashrecord")->where($wait)->sum("money"); $cash['success']=$cashrecord_success; $cash['fail']=$cashrecord_fail; $cash['wait']=$cashrecord_wait; $cash['type']=0; } $cash['total']=$cashrecord_total; $this->assign('cash', $cash); $this->assign('lists', $lists); $this->assign('type', $this->getTypes()); $this->assign('status', $this->getStatus()); $this->assign("page", $page); return $this->fetch(); } function del(){ $id = $this->request->param('id', 0, 'intval'); if($id){ $result=DB::name("user_cashrecord")->delete($id); if($result){ $this->success('删除成功'); }else{ $this->error('删除失败'); } }else{ $this->error('数据传入失败!'); } } function edit(){ $id = $this->request->param('id', 0, 'intval'); $data=Db::name('user_cashrecord') ->where("id={$id}") ->find(); if(!$data){ $this->error("信息错误"); } $data['userinfo']=getUserInfo($data['uid']); $this->assign('type', $this->getTypes()); $this->assign('status', $this->getStatus()); $configpub=getConfigPub(); $this->assign('name_coin',$configpub['name_coin']); $this->assign('cash', $data); return $this->fetch(); } function edit_post(){ if ($this->request->isPost()) { $data = $this->request->param(); $status=$data['status']; $uid=$data['uid']; $votes=$data['votes']; $id=$data['id']; $cash_type=$data['cash_type']; if($status=='0'){ $this->success("修改成功!"); } $data['uptime']=time(); $rs = DB::name('user_cashrecord')->update($data); if($rs===false){ $this->error("修改失败!"); } if($status=='2' && $cash_type==0){ DB::name("user")->where(["id"=>$uid])->inc("votes",$votes)->update(); } if($status=='2' && $cash_type==1){ DB::name("user")->where(["id"=>$uid])->inc("red_votes",$votes)->update(); } $this->success("修改成功!"); } } function export(){ $data = $this->request->param(); $map=[]; $status=isset($data['status']) ? $data['status']: ''; if($status!=''){ $map[]=['status','=',$status]; } $cash_type=isset($data['cash_type']) ? $data['cash_type']: ''; if($cash_type!=''){ $map[]=['cash_type','=',$cash_type]; } $start_time=isset($data['start_time']) ? $data['start_time']: ''; $end_time=isset($data['end_time']) ? $data['end_time']: ''; if($start_time!=""){ $map[]=['addtime','>=',strtotime($start_time)]; } if($end_time!=""){ $map[]=['addtime','<=',strtotime($end_time) + 60*60*24]; } $keyword=isset($data['keyword']) ? $data['keyword']: ''; if($keyword!=''){ $map[]=['uid|orderno|trade_no','like',"%".$keyword."%"]; } $xlsName = "提现"; $xlsData=DB::name("user_cashrecord") ->where($map) ->order('id desc') ->select() ->toArray(); foreach ($xlsData as $k => $v){ $userinfo=getUserInfo($v['uid']); $xlsData[$k]['user_nickname']= $userinfo['user_nickname']."(".$v['uid'].")"; $xlsData[$k]['addtime']=date("Y-m-d H:i:s",$v['addtime']); $xlsData[$k]['uptime']=date("Y-m-d H:i:s",$v['uptime']); $xlsData[$k]['status']=$this->getStatus($v['status']); if($v['type']==1){ //支付宝 $xlsData[$k]['account']=$this->getTypes($v['type']).'|'.$v['name'].'|'.$v['account']; }else if($v['type']==2){ //微信 $xlsData[$k]['account']=$this->getTypes($v['type']).'|'.$v['account']; }else{ $xlsData[$k]['account']=$this->getTypes($v['type']).'|'.$v['name'].'|'.$v['account'].'|'.$v['account_bank']; } if($v['cash_type']==0){ $xlsData[$k]['cash_type_name']='普通提现'; }else{ $xlsData[$k]['cash_type_name']='视频红包提现'; } } $cellName = array('A','B','C','D','E','F','G','H','I','J'); $xlsCell = array( array('id','序号'), array('user_nickname','主播名称'), array('votes','金币'), array('money','提现金额'), array('account','提现账号'), array('trade_no','第三方支付订单号'), array('status','状态'), array('addtime','提交时间'), array('uptime','处理时间'), array('cash_type_name','提现类型'), ); exportExcel($xlsName,$xlsCell,$xlsData,$cellName); } }