repository = $repository; } /** * TODO * @return mixed * @author Qinii * @day 2020-06-16 */ public function lst() { [$page,$limit] = $this->getPage(); $where = $this->request->params(['status','keyword','date','extract_type','uid']); $where['mer_id']=$this->request->merId(); $res = $this->repository->serach($where,$page,$limit); foreach ($res['list'] as $k=>$v){ $res['list'][$k]['certification']= Db::name('user_certification')->where('uid', $v['uid'])->find();; $res['list'][$k]['bank_info_data']=[]; $pay_info=''; if($v['bank_info']!=''){ $res['list'][$k]['bank_info_data']=json_decode($v['bank_info'],true); $pay_info=$res['list'][$k]['certification']['user_name'].' '; $pay_info.=$res['list'][$k]['certification']['user_card']." "; $pay_info.=$res['list'][$k]['bank_info_data']['bank_name'].' '; $pay_info.=$res['list'][$k]['bank_info_data']['bank_open_name'].' '; $pay_info.=$res['list'][$k]['bank_code']; } $res['list'][$k]['status_name']=''; if($v['status']=='0') $res['list'][$k]['status_name']='审核中'; if($v['status']=='1') $res['list'][$k]['status_name']='已打款'; if($v['status']=='-1') $res['list'][$k]['status_name']='已拒绝'; if($v['extract_type']=='3') $res['list'][$k]['extract_type_name']='银行卡'; if($v['status']=='0') $res['list'][$k]['status_time']=''; $res['list'][$k]['extract_price']=set_price_rtrim($v['extract_price']); $res['list'][$k]['service_money']=set_price_rtrim( $v['service_money']); $res['list'][$k]['money']=set_price_rtrim($v['extract_price'] - $v['service_money']); $res['list'][$k]['pay_info']=$pay_info; if($v['extract_type']=='4'){ $res['list'][$k]['status_name']='已完成'; $res['list'][$k]['pay_info']='人工减少-'.$v['mark']; } if(!$v['fail_msg'] || $v['fail_msg']==''){ $res['list'][$k]['fail_msg']='--'; } if(!$v['status_time'] || $v['status_time']==''){ $res['list'][$k]['status_time']='--'; } // $res['list'][$k]['list']=$this->repository->get_user_extract_item($v['extract_id']); } //查询用户可提现金额 $merid = $this->request->merId(); $merchant= Db::name('merchant')->where('mer_id', $merid)->find(); $res['brokerage_price'] = $merchant['brokerage_price']; return app('json')->success($res); } public function new_lst() { [$page,$limit] = $this->getPage(); $where = $this->request->params(['status','keyword','date','extract_type','uid']); $res = $this->repository->new_search($where,$page,$limit); foreach ($res['list'] as $k=>$v){ $res['list'][$k]['certification']= Db::name('user_certification')->where('uid', $v['uid'])->find();; $res['list'][$k]['bank_info_data']=[]; $pay_info=''; if($v['bank_info']!=''){ $res['list'][$k]['bank_info_data']=json_decode($v['bank_info'],true); $pay_info=$res['list'][$k]['certification']['user_name'].' '; $pay_info.=$res['list'][$k]['certification']['user_card']." "; $pay_info.=$res['list'][$k]['bank_info_data']['bank_name'].' '; $pay_info.=$res['list'][$k]['bank_info_data']['bank_open_name'].' '; $pay_info.=$res['list'][$k]['bank_code']; } $res['list'][$k]['status_name']=''; if($v['status']=='0') $res['list'][$k]['status_name']='审核中'; if($v['status']=='1') $res['list'][$k]['status_name']='已打款'; if($v['status']=='-1') $res['list'][$k]['status_name']='已拒绝'; if($v['extract_type']=='3') $res['list'][$k]['extract_type_name']='银行卡'; if($v['status']=='0') $res['list'][$k]['status_time']=''; $res['list'][$k]['extract_price']=set_price_rtrim($v['extract_price']); $res['list'][$k]['service_money']=set_price_rtrim( $v['service_money']); $res['list'][$k]['money']=set_price_rtrim($v['extract_price'] - $v['service_money']); $res['list'][$k]['pay_info']=$pay_info; if($v['extract_type']=='4'){ $res['list'][$k]['status_name']='已完成'; $res['list'][$k]['pay_info']='人工减少-'.$v['mark']; } if(!$v['fail_msg'] || $v['fail_msg']==''){ $res['list'][$k]['fail_msg']='--'; } if(!$v['status_time'] || $v['status_time']==''){ $res['list'][$k]['status_time']='--'; } // $res['list'][$k]['list']=$this->repository->get_user_extract_item($v['extract_id']); } //查询用户可提现金额 $merid = $this->request->merId(); $merchant= Db::name('merchant')->where('mer_id', $merid)->find(); $user = Db::name('user')->where('uid', $merchant['uid'])->find(); $res['brokerage_price'] = $user['brokerage_price']; return app('json')->success($res); } /** * TODO 导出文件 * @author Qinii * @day 2020-07-30 */ public function excel() { $where = $this->request->params(['status','keyword','date','extract_type']); $where['mer_id']=$this->request->merId(); $res = $this->repository->serach($where,1,100000); $arr=[]; foreach ($res['list'] as $k=>$v){ $res['list'][$k]['bank_info_data']=[]; $bane_name=''; if($v['bank_info']!=''){ $res['list'][$k]['bank_info_data']=json_decode($v['bank_info'],true); $bane_name=$res['list'][$k]['bank_info_data']['bank_name']; } $certification= Db::name('user_certification')->where('uid', $v['uid'])->find();; $v['extract_type_name']=''; $v['status_name']=''; if($v['extract_type']==1) $v['extract_type_name']='微信'; if($v['extract_type']==2) $v['extract_type_name']='支付宝'; if($v['extract_type']==3) $v['extract_type_name']='银行卡'; if($v['status']==-1) $v['status_name']='未通过'; if($v['status']=='0') $v['status_name']='审核中'; if($v['status']=='1') $v['status_name']='已提现'; $arr[]=array( $v['create_time'], $certification['user_name'], $v['extract_price'], $v['service_money'], ($v['extract_price'] - $v['service_money']), $v['extract_type_name'], $bane_name, $v['bank_address'], ' '.$v['bank_code'], $v['status_name'], ); } $header = [ '申请时间','姓名','申请金额','综合服务费','实际到账金额','提现方式','所属银行','所属银行支行','银行卡号','状态' ]; $filename = '提现列表_'.date('YmdHis').'_'.rand(10000,99999); $title = '提现列表'; $name = '提现信息'; $info = '生成时间:' . date('Y-m-d H:i:s',time()); $suffix='xlsx'; $path='extract'; unset($_instance); $_instance = SpreadsheetExcelService::instance_xin(); $_path =$_instance ->createOrActive() ->setExcelHeader($header) ->setExcelTile($title, $name, $info) ->setExcelContent($arr) ->excelSave($filename, $suffix, $path); $data= [ 'name' => $filename.'.'.$suffix, 'status' => 1, 'path' => '/'.$_path ]; return app('json')->success('ok',$data); } /** * TODO * @param $id * @return mixed * @author Qinii * @day 2020-06-16 */ public function switchStatus($id) { $data = $this->request->params(['status','fail_msg','mark']); if($data['status'] == '-1' && empty($data['fail_msg'])) return app('json')->fail('请填写拒绝原因'); if(!$this->repository->getWhereCount($id)) return app('json')->fail('数据不存在或状态错误'); $data['admin_id'] = $this->request->adminId(); $data['status_time'] = date('Y-m-d H:i:s',time()); $extract_data=Db::name('user_extract')->where('extract_id',$id)->find(); if($data['status']!='-1'){ if($extract_data['extract_type']==1){ return app('json')->success('微信不能提现'); // $res=$this->repository->WechatTransfers($id); // if($res['code']==201){ // return app('json')->success('微信处理中,请稍后'); // } // }elseif ($extract_data['extract_type']==2){ // $res=$this->repository->AliTransfers($id); }elseif ($extract_data['extract_type']==3){ $res= ['code'=>200,'msg'=>'成功']; } if($res['code']!=200 && $extract_data['types']==1){ Db::name('user_rich')->where('uid',$extract_data['uid'])->inc('red', $extract_data['extract_price'])->update(); Db::name('user_rich_log')->insert([ 'uid' => $extract_data['uid'], 'red' => $extract_data['extract_price'], 'pm' => 1, 'time' => time(), 'order_id' => 0, 'mark' => '提现失败返还红积分' ]); return app('json')->fail(isset($res['msg'])?$res['msg']:'提现失败',$res); } }else{ if($extract_data['withdrawal_type']==2) { Db::name('entropy_barter_bill')->where('order_no', $extract_data['order_sn'])->where('pm', 2)->update(['status' => 3, 'remarks' => '审核已拒绝']); $eb_bill = Db::name('entropy_barter_bill')->where('order_no', $extract_data['order_sn'])->where('pm', 2)->find(); Db::name('entropy_barter_user_' . $extract_data['mer_id'])->where('eb_id', $eb_bill['to_id'])->inc('wallet', $extract_data['extract_price'])->update(); } } if($extract_data['withdrawal_type']==1){ $this->repository->switchStatus($id,$data); }else if($extract_data['withdrawal_type']==3){ if($data['status'] == '-1'){ $where['uid'] = $extract_data['uid']; $where['mer_id'] = $extract_data['mer_id']; Db::name('enterprise_user')->where($where)->inc('commission', $extract_data['extract_price'])->update(); } Db::name('user_extract')->where('extract_id',$id)->update($data); }else{ Db::name('user_extract')->where('extract_id',$id)->update($data); } return app('json')->success('审核成功'); } public function create() { $data = $this->request->params(['extract_price']); $extract_price = $data['extract_price'] ?? 0; //查询用户可提现金额 $merid = $this->request->merId(); $merchant= Db::name('merchant')->where('mer_id', $merid)->find(); $user = Db::name('user')->where('uid', $merchant['uid'])->find(); if ($extract_price > $merchant['brokerage_price']) { return app('json')->fail('输入金额超出可提现金额~'); } if ($extract_price < 100) { return app('json')->fail('最低提现金额为100~'); } if ($extract_price % 100 != 0) { return app('json')->fail('提现金额应为100的倍数~'); } //创建提现记录 $extract = $this->repository->create_yhc($user, $merchant, [ 'extract_type' => 3, 'extract_price' => $extract_price, 'service_money' => $extract_price * $this->service_money_ratio,//综合服务费6% ]); return \app('json')->success($extract); } public function service_money() { $data = $this->request->params(['extract_price']); $extract_price = intval($data['extract_price']) ?? 0; $res = [ 'extract_price' => $extract_price, 'service_money' => $extract_price * $this->service_money_ratio,//综合服务费6% ]; $res['deserve_money'] = $res['extract_price'] - $res['service_money']; return \app('json')->success($res); } }