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

namespace App\Http\Controllers\Web\Advert;use App\Http\Controllers\BaseController;use App\Models\Cart;use App\Models\Member;use App\Models\MemberFile;use App\Models\MemberMoneyRecord;use App\Models\ProductHasType;use App\Models\ProductTrade;use App\Models\ProductType;use Illuminate\Http\Request;use Illuminate\Support\Facades\Validator;class MemberCartController 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='cart';$productType=ProductType::all(['id','tag','name']);return view('web.advert.Member.cart',compact('type','productType'));}public function cartData(Request $request){$query=Cart::where(['mid'=>auth('members')->user()['id']]);if($request->type)goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:$ids=ProductHasType::where(['type_id'=>$request->type])->get(['product_id']);if($ids)goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:$ids=$ids->pluck('product_id')->toArray();$query=$query->whereIn('product_id',$ids);goto P2gx3;P2gNextx4:P2gx3:goto P2gx1;P2gNextx2:P2gx1:$orders=$query->with('product')->orderBy('id','desc')->paginate($request->get('limit',20))->toArray();$P2gAC0=array();$P2gAC0['code']=0;$P2gAC0['msg']='正在请求中...';$P2gAC0['count']=$orders['total'];$P2gAC0['data']=$orders['data'];$data=$P2gAC0;return response()->json($data);}public function getFodder(){$list=MemberFile::where('mid',auth('members')->user()->id)->get();return json_encode(['code'=>0,'data'=>$list]);}public function verifyPass(Request $request){$validate=Validator::make($request->all(),['pay_pass'=>'required',]);$P2g0=!$validate->fails();if($P2g0)goto P2gBodyx6;goto P2gNextx6;P2gBodyx6:$member=Member::where(['id'=>auth('members')->user()->id])->with('member_info')->first();$P2g0=!isset($member->member_info->pay_pass);$P2g2=(bool)$P2g0;$P2g3=!$P2g2;if($P2g3)goto P2gBodyx9;goto P2gNextx9;P2gBodyx9:$P2g1=!$member->member_info->pay_pass;$P2g2=(bool)$P2g1;goto P2gx8;P2gNextx9:P2gx8:if($P2g2)goto P2gBodyxa;goto P2gNextxa;P2gBodyxa:return json_encode(['code'=>'1','message'=>'请先设置支付密码']);goto P2gx7;P2gNextxa:P2gx7:$P2g0=$member->member_info->pay_pass!=md5(trim($request->pay_pass));if($P2g0)goto P2gBodyxc;goto P2gNextxc;P2gBodyxc:return json_encode(['code'=>'1','message'=>'密码不正确']);goto P2gxb;P2gNextxc:$money=MemberMoneyRecord::where('mid',$member->id)->orderBy('id','desc')->first(['total_money']);if(isset($money))goto P2gBodyxe;goto P2gNextxe;P2gBodyxe:return json_encode(['code'=>'0','message'=>'验证成功','data'=>$money->total_money]);goto P2gxd;P2gNextxe:return json_encode(['code'=>'0','message'=>'验证成功','data'=>0]);P2gxd:P2gxb:goto P2gx5;P2gNextx6:if($validate->errors()->has('pay_pass'))goto P2gBodyxg;goto P2gNextxg;P2gBodyxg:return json_encode(['code'=>'1','message'=>'请输入正确的密码']);goto P2gxf;P2gNextxg:return json_encode(['code'=>'1','message'=>'网络错误']);P2gxf:P2gx5:}public function destroy(Request $request){$ids=$request->ids;$result=Cart::whereIn('id',$ids)->delete();if($result)goto P2gBodyxi;goto P2gNextxi;P2gBodyxi:return json_encode(['code'=>200,'info'=>'处理成功']);goto P2gxh;P2gNextxi:return json_encode(['code'=>4000,'info'=>'处理失败']);P2gxh:}}
?>