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

namespace App\Http\Controllers\Web\Advert;use App\Http\Controllers\BaseController;use App\Models\Apply;use App\Models\ApplyLog;use App\Models\Cart;use App\Models\Member;use App\Models\MemberFile;use App\Models\MemberInfo;use App\Models\SystemMessageBack;use App\Models\SystemMessageClick;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;class MemberController extends BaseController{public function __construct(){view()->share('nick',preg_replace('/(\d{3})\d{4}(\d{4})/','$1****$2',auth('members')->user()['phone']));}public function index(){$type='index';$mid=auth('members')->user()->id;if(MemberInfo::where('mid',$mid)->first())goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:$P2g0=MemberInfo::where('mid',$mid)->first();goto P2gx1;P2gNextx2:$P2g0='';P2gx1:$files=$P2g0;return view('web.advert.Member.edit',compact('type','files'));}public function update(Request $request){$mid=auth('members')->user()->id;$info=MemberInfo::where('mid',$mid)->first();if($info)goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:$info->name=$request->name;$info->company=$request->company;$info->qq=$request->qq;$info->phone=$request->phone;$info->email=$request->email;$info->save();goto P2gx3;P2gNextx4:MemberInfo::create(['name'=>$request->name,'company'=>$request->company,'qq'=>$request->qq,'phone'=>$request->phone,'email'=>$request->email,'mid'=>$mid,]);P2gx3:return redirect(url('advert/member'));}public function message(){$type='message';$mid=auth('members')->user()->id;SystemMessageClick::where('mid',$mid)->update(['is_read'=>1]);return view('web.advert.Member.message',compact('type'));}public function messageData(Request $request){$list=SystemMessageBack::select();$mobile=auth('members')->user()->phone;$list=$list->where(['send_user_type'=>2])->orWhere(function($query)use($mobile){$query->where(['send_user_type'=>3])->where(function($query)use($mobile){$query->whereRaw("FIND_IN_SET(".$mobile.",numbers)");});});$list=$list->where(['send_type'=>1])->with('order')->orWhere([['send_type','=',2],['send_at','<=',date('Y-m-d H:i:s',time())]]);$list=$list->orderBy('id','desc')->paginate($request->get('limit',20))->toArray();foreach($list['data']as&$item){$AA___AAA="html_entity_decode";$P2gAC0=$AA___AAA($item['content']);$content=$P2gAC0;$item['content']=mb_substr(strip_tags($content),0,50);unset($item['send_user_type']);unset($item['object_id']);unset($item['send_at']);unset($item['updated_at']);unset($item['numbers']);if($request->uid)goto P2gBodyx6;goto P2gNextx6;P2gBodyx6:$clicks=SystemMessageClick::withTrashed()->firstOrCreate(['system_id'=>$item['id'],'mid'=>$request->uid]);if($clicks->wasRecentlyCreated)goto P2gBodyx8;goto P2gNextx8;P2gBodyx8:$item['is_read']=0;goto P2gx7;P2gNextx8:$item['is_read']=$clicks->is_read;P2gx7:goto P2gx5;P2gNextx6:$item['is_read']=0;P2gx5:}$P2gAC0=array();$P2gAC0['code']=0;$P2gAC0['msg']='正在请求中...';$P2gAC0['count']=$list['total'];$P2gAC0['data']=$list['data'];$data=$P2gAC0;return response()->json($data);}public function safe(){$type='safe';return view('web.advert.Member.safe',compact('type'));}public function updateSafe(Request $request){$mid=auth('members')->user()->id;$member=Member::where(['id'=>$mid])->first();if($member->password)goto P2gBodyxa;goto P2gNextxa;P2gBodyxa:if(Auth::attempt(['phone'=>$request->phone,'type'=>$request->type,'password'=>$request->password]))goto P2gBodyxc;goto P2gNextxc;P2gBodyxc:Member::where('id',$mid)->update(['password'=>bcrypt($request->new_password)]);goto P2gxb;P2gNextxc:Member::where('id',$mid)->update(['password'=>bcrypt($request->new_password)]);P2gxb:goto P2gx9;P2gNextxa:Member::where('id',$mid)->update(['password'=>bcrypt($request->new_password)]);P2gx9:return redirect(url('/advert/member'));}public function payPass(){$type='payPassword';return view('web.advert.Member.payPass',compact('type'));}public function setPayPass(Request $request){$mid=auth('members')->user()->id;$member=MemberInfo::where(['mid'=>$mid])->first();if($member)goto P2gBodyxe;goto P2gNextxe;P2gBodyxe:if(MemberInfo::where(['pay_pass'=>md5($request->pass)])->first())goto P2gBodyxg;goto P2gNextxg;P2gBodyxg:MemberInfo::where('mid',$mid)->update(['pay_pass'=>md5($request->pass)]);goto P2gxf;P2gNextxg:MemberInfo::where('mid',$mid)->update(['pay_pass'=>md5($request->pass)]);P2gxf:goto P2gxd;P2gNextxe:MemberInfo::create(['mid'=>$mid,'pay_pass'=>md5($request->pass),]);P2gxd:return redirect(url('/advert/member'));}}
?>