<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-08 16:22:09
 技术支持 口号帮 
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Controllers\Admin;use App\Models\CashRefundList;use App\Models\Member;use App\Models\MemberInfo;use App\Models\MemberMoneyRecord;use App\Traits\ApplyLogs;use App\Traits\CustomExcel;use Carbon\Carbon;use Illuminate\Http\Request;use App\Http\Controllers\Controller;use Illuminate\Support\Facades\DB;class RefundController extends Controller{use ApplyLogs,CustomExcel;public function index(){$list=CashRefundList::get();return view('admin.account.refund.index',compact('list'));}public function data(Request $request,CashRefundList $message){$message=$message->query();if($request->create_start)goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:$message=$message->where('created_at','>=',$request->create_start);goto P2gx1;P2gNextx2:P2gx1:if($request->create_end)goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:$message=$message->where('created_at','<',$request->create_end);goto P2gx3;P2gNextx4:P2gx3:if($request->phone)goto P2gBodyx6;goto P2gNextx6;P2gBodyx6:$member=Member::where(['phone'=>$request->phone])->first();$message=$message->where(['mid'=>$member->id]);goto P2gx5;P2gNextx6:P2gx5:if($request->type)goto P2gBodyx8;goto P2gNextx8;P2gBodyx8:$message=$message->where(['type'=>$request->type]);goto P2gx7;P2gNextx8:P2gx7:$data=$message->with('member','user')->orderBy('id','desc')->paginate($request->get('limit',$this->pageSize))->toArray();$P2gAC0=array();$P2gAC0['code']=0;$P2gAC0['msg']='正在请求中...';$P2gAC0['count']=$data['total'];$P2gAC0['data']=$data['data'];$data=$P2gAC0;return response()->json($data);}public function create(){return view('admin.account.refund.create');}public function store(Request $request){$member=Member::where(['phone'=>$request->phone])->first();$P2gAC0=array();$P2gAC0['apply_money']=$request->money;$P2gAC0['check_money']=$request->received;$P2gAC0['uid']=auth()->user()->id;$P2gAC0['mid']=$member->id;$P2gAC0['status']=3;$P2g0=$request->money-$request->received;$P2g1='退款手续费' . $P2g0;$P2g2=$P2g1 . '元';$P2gAC0['mark']=$P2g2;$data=$P2gAC0;DB::beginTransaction();try{$data['image']=$request->logo;$P2g0=$request->account_no . '(';$P2g1=$P2g0 . $request->account_name;$P2g2=$P2g1 . ')';$data['account']=$P2g2;$res=CashRefundList::create($data);$money=MemberMoneyRecord::where(['mid'=>$member->id])->orderBy('id','desc')->first();MemberMoneyRecord::create(['mid'=>$member->id,'money'=>$request->money,'type'=>6,'total_money'=>$money->total_money-$request->money,'freeze_money'=>$money->freeze_money,'uid'=>auth()->user()->id,'created_at'=>Carbon::now(),'updated_at'=>Carbon::now(),'mark'=>'退款扣除'.$request->apply_money.'元','refund_id'=>$res->id]);DB::commit();}catch(\Exception $e){DB::rollBack();}return redirect()->route('admin.refund');}public function edit($id){$info=CashRefundList::with(['member'=>function($query){$query->select('id','phone');},'user'=>function($query){$query->select('id','name');}])->find($id);$money=$this->getMemberMoney($info->member['id']);$account=MemberInfo::where(['mid'=>$info->member['id']])->first();$total_money=$money->total_money;return view('admin.account.refund.create',compact('info','total_money','account'));}public function exportExcelData(Request $request){$message=CashRefundList::select();if($request->create_start)goto P2gBodyxb;goto P2gNextxb;P2gBodyxb:$message=$message->where('created_at','>=',$request->create_start);goto P2gxa;P2gNextxb:P2gxa:if($request->create_end)goto P2gBodyxd;goto P2gNextxd;P2gBodyxd:$message=$message->where('created_at','<',$request->create_end);goto P2gxc;P2gNextxd:P2gxc:if($request->phone)goto P2gBodyxf;goto P2gNextxf;P2gBodyxf:$member=Member::where(['phone'=>$request->phone])->first();$message=$message->where(['mid'=>$member->id]);goto P2gxe;P2gNextxf:P2gxe:$list=$message->with(['member','user'])->orderBy('id','desc')->get();$A_A_AA__="count";$P2gAC0=$A_A_AA__($list);if($P2gAC0)goto P2gBodyxh;goto P2gNextxh;P2gBodyxh:$P2gAC0=array();$result=$P2gAC0;$P2gAC0=array();$P2gAC0[]='编号';$P2gAC0[]='电话';$P2gAC0[]='申请金额(元)';$P2gAC0[]='打款金额';$P2gAC0[]='打款账户';$P2gAC0[]='打款凭证';$P2gAC0[]='操作人';$P2gAC0[]='备注';$P2gAC0[]='时间';$result[]=$P2gAC0;$P2g0=$P2gAC0;foreach($list as $item){$P2gAC0=array();$arr=$P2gAC0;$arr[]=$item->id;$P2g0=$item->id;$arr[]=$item->member['phone'];$P2g0=$item->member['phone'];$arr[]=$item->apply_money;$P2g0=$item->apply_money;$arr[]=$item->check_money;$P2g0=$item->check_money;$arr[]=$item->account;$P2g0=$item->account;$arr[]=$item->image;$P2g0=$item->image;$arr[]=$item->user['name'];$P2g0=$item->user['name'];$arr[]=$item->mark;$P2g0=$item->mark;$arr[]=$item->created_at;$P2g0=$item->created_at;$result[]=$arr;$P2g0=$arr;}$A_A_AA_A="date";$P2gAC0=$A_A_AA_A('YmdHis');$P2g0='退款流水' . $P2gAC0;$title=$P2g0;$this->excelExport($title,$result);die();goto P2gxg;P2gNextxh:P2gxg:}}
?>