recuperateService = $recuperateService; $this->recuperateApplyService = $recuperateApplyService; } /** * 列表 */ public function list(Request $request) { $key = $request->input('key'); $list = $this->recuperateService->list($key, 10); $return_data = [ 'list' => $list, 'key' => $key, ]; return view('app.recuperate.list', $return_data); } /** * 详情 */ public function show($id) { //获取详情 $info = $this->recuperateService->getRecuperateInfo($id); if (!$info) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('资讯不存在', $back_url, true, '上一页', '3'); } $uid = auth('web-member')->id(); $recuperate_app=RecuperateApply::where('uid',$uid)->where('recuperate_id',$id)->first(); //增加点击量 $this->recuperateService->incrementData(['id' => $id], 1, 'click'); $return_data = array( 'info'=>$info, 'recuperate_app'=>$recuperate_app ); return view('app.recuperate.show', $return_data); } public function apply($id) { // http://120.26.63.153:8080/JJRCW/api/jucaiInterface/getDevelopAllowance?idCard=350581198601242040&phone=15959581739&year=2019 /* $data['idCard']='350581198601242040'; $data['phone']='15959581739'; $data['year']='2019'; $result_json = https_request('http://120.26.63.153:8080/JJRCW/api/jucaiInterface/getDevelopAllowance', $data); dd(json_decode($result_json));*/ /* $data['idCard']='130630199212251815'; $data['phone']='17689494919'; $data['year']='2019'; $result_json = https_request('http://rc.jucai.gov.cn/api/jucaiInterface/getDevelopAllowance', $data); dd(json_decode($result_json)->state);*/ //获取详情 $info = $this->recuperateService->getRecuperateInfo($id); if (!$info) { $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('资讯不存在', $back_url, true, '上一页', '3'); } /*查看手机是否认证*/ $member = auth('web-member')->user(); if($member->mobile_audit!='1'){ // $back_url = \Illuminate\Support\Facades\URL::previous();; return $this->showMessage('请到个人中心先认证手机号码', route('person.memberInfo'), true, '上一页', '3'); } $members_info=MemberInfo::where('uid',$member->id)->select('realname','id_card','phone','card_t_cn')->first(); /* if($members_info->card_t_cn!='306' || !$members_info->id_card){ $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage('请到个人中心填写身份证号', $back_url, true, '上一页', '3'); }*/ if(date('Y',time())!='2021'){ $verification=$this->verification($member->id,$info,$members_info); if(!$verification['state']){ $back_url = \Illuminate\Support\Facades\URL::previous(); return $this->showMessage($verification['msg'], $back_url, true, '上一页', '3'); } } $return_data = [ 'info' => $info, 'members' =>array_merge($member->toArray(),$members_info->toArray(),['year'=>date('Y',strtotime("-1 year"))]) ]; return view('app.recuperate.apply', $return_data); } protected function verification($uid,$info,$members_info=false){ $year=date('Y', strtotime("-1 year")); $recuperate_time=RecuperateTime::where('uid',$uid)->where('year',$year)->first(); if($recuperate_time){ $old_integral=RecuperateApply::where('uid',$uid)->where('recuperate_time_id',$recuperate_time->id)->where('status','!=',2)->sum('price'); if($recuperate_time->price<($old_integral+$info['price'])){ return ['state'=>0,'msg'=>'今年的金额额度不够']; }else{ return ['state'=>1,'msg'=>'ok','info'=>$recuperate_time]; } }else{ $data['idCard']=$members_info->id_card; $data['phone']=$members_info->phone; $arr['year']=$data['year']=$year;; $result_json = https_request('https://rc.jucai.gov.cn/api/jucaiInterface/getDevelopAllowance', $data); // $result_json = https_request('http://120.26.63.153:8080/JJRCW/api/jucaiInterface/getDevelopAllowance', $data); $result_json=json_decode($result_json); if($result_json->state=='3'){ if($result_json->total<$info['price']){ return ['state'=>0,'msg'=>'今年的金额额度不够']; } $arr['price']=$result_json->total; $arr['uid']=$uid; RecuperateTime::create($arr); return ['state'=>1,'msg'=>$result_json->msg]; }else{ return ['state'=>0,'msg'=>$result_json->msg]; } } } public function applyPost(Request $request) { //身份证号验证 /*$reg = "/^(([1][1-5])|([2][1-3])|([3][1-7])|([4][1-6])|([5][0-4])|([6][1-5])|([7][1])|([8][1-2]))\d{4}(([1][9]\d{2})|([2]\d{3}))(([0][1-9])|([1][0-2]))(([0][1-9])|([1-2][0-9])|([3][0-1]))\d{3}[0-9xX]$/"; $reg_id = preg_match($reg, $request['user_idcard']); if (empty($reg_id)) { return $this->sendErrorResponse('身份证号格式不正确', '', 400); }*/ $data = $request->all(); $uid = auth('web-member')->id(); $id_card=MemberInfo::where('uid',$uid)->value('id_card'); if(empty($id_card)){ $member_info = MemberInfo::where('id_card',$data['user_idcard'])->first(); if(empty($member_info)){ MemberInfo::where('uid',$uid)->update(['card_t_cn'=>306,'id_card'=>$data['user_idcard']]); } } //一个活动只能报名一次 $recuperate_apply = RecuperateApply::where('uid',$uid)->where('recuperate_id',$data['recuperate_id'])->first(); if ($recuperate_apply) { return $this->sendErrorResponse('一个活动只能报名一次', '', 400); } $recuperate=Recuperate::where('id',$data['recuperate_id'])->select('price')->first(); if(date('Y',time())!='2021'){ $verification=$this->verification($uid,$recuperate); if(!$verification['state']){ return $this->sendErrorResponse($verification['msg'], '', 400); } $data['recuperate_time_id'] = $verification['info']->id; } //一人只能报两个 /* $count = RecuperateApply::where('uid',$uid)->count(); if ($count >= 2) { return $this->sendErrorResponse('一人只能报两个活动', '', 400); }*/ //报名 $data['uid'] = $uid; $data['price'] = $recuperate->price; $res = $this->recuperateApplyService->create($data); if ($res) { return $this->sendSuccessResponse(); } else { return $this->sendErrorResponse('网络问题,请刷新重试', '', 400); } } /** * 方案 */ public function project() { return view('app.recuperate.project'); } }