user_id)->value('is_agency'); if($is_agency) $this->error('您已经是区域代理'); $check_apply = RegionalAgency::where(['pro_id'=>$pro_id,'city_id'=>$city_id])->find(); if($check_apply){ if($check_apply->user_id == $this->user_id && $check_apply->status == 0) $this->error('已申请,请等待审核'); if($check_apply->user_id == $this->user_id && $check_apply->status == 1) $this->error('您已经是该区域代理'); if($check_apply->user_id != $this->user_id && in_array( $check_apply->status ,[0,1])) $this->error('该区域已有代理'); } $apply_info = [ 'user_id' => $this->user_id , 'true_name' => $true_name , 'birth' => $birth, 'pro_id' => $pro_id , 'city_id' => $city_id , 'pro_name' => $pro_name , 'city_name' => $city_name , 'cer_type' => $cer_type , 'cer_num' => $cer_num , 'detail' => $detail , 'create_at' => date('Y-m-d H:i:s') , 'status'=> 0 , ]; Data::save('RegionalAgency',$apply_info,'user_id',['user_id'=>$this->user_id]); $this->success('申请成功,请等待审核'); } /** * @title 验证区域代理 * @desc 验证区域代理 * @author qc * @url /api/User_rank/checkAgency * @method GET * @header name:Authorization require:1 desc:Token * @param name:pro_id type:int default:-- desc:省id * @param name:city_id type:int default:-- desc:市id * @return name:check_id type:int default:-- desc:大于0该市有申请记录 */ public function checkAgency() { $pro_id = input('get.pro_id'); $city_id = input('get.city_id'); $check_id = RegionalAgency::where(['pro_id'=>$pro_id,'city_id'=>$city_id])->where('status','<',2)->value('id'); $this->success('ok',['check_id'=>intval($check_id)]); } /** * @title 获取我的区域申请记录 * @desc 获取我的区域申请记录 * @author qc * @url /api/User_rank/getAgencyApply * @method GET * @header name:Authorization require:1 desc:Token * @return name:true_name:int default:-- desc:名称 * @return name:birth:int default:-- desc:出生日期 * @return name:pro_id type:int default:-- desc:省id * @return name:city_id type:int default:-- desc:省id * @return name:pro_name type:string default:-- desc:省名 * @return name:city_name type:string default:-- desc:市名 * @return name:cer_type type:int default:1 desc:证件类型(1身份证) * @return name:cer_num type:string default:-- desc:证件号 * @return name:detail type:srting default:-- desc:申请详情介绍 * @return name:status type:int default:-- desc:审核状态(0未审核,1审核通过,2审核拒绝) * @return name:check_desc type:string default:-- desc:审核备注 */ public function getAgencyApply() { $detail = RegionalAgency::where(['user_id'=>$this->user_id])->find(); $this->success('ok',['list'=>$detail ? $detail->toArray() :[]]); } /** * @title 申请(编辑)成为分销商 * @desc 申请(编辑)成为分销商 * @author qc * @url /api/User_rank/applyPartner * @method POST * @header name:Authorization require:1 desc:Token * @param name:true_name:int default:-- desc:名称 * @param name:cer_num type:string default:-- desc:证件号 * @param name:address type:string default:-- desc:地址 * @param name:phone type:string default:-- desc:电话 * @param name:detail type:srting default:-- desc:申请详情介绍 */ public function applyPartner() { $true_name = input('post.true_name'); $cer_num = input('post.cer_num'); $address = input('post.address'); $detail = input('post.detail'); $phone = input('post.phone'); $partner_lev = User::where(['id'=>$this->user_id])->value('partner_lev'); if($partner_lev) $this->error('您已经是分销商'); $apply_info = [ 'user_id' => $this->user_id , 'true_name' => $true_name , 'cer_num' => $cer_num , 'address' => $address , 'phone' => $phone , 'detail' => $detail , 'create_at' => date('Y-m-d H:i:s') , 'status'=> 0 , ]; Data::save('UserPartner',$apply_info,'user_id',['user_id'=>$this->user_id]); $this->success('申请成功,请等待审核'); } /** * @title 获取成为分销商记录申请记录 * @desc 获取成为分销商记录申请记录 * @author qc * @url /api/User_rank/getPartnerApply * @method GET * @header name:Authorization require:1 desc:Token * @return name:true_name:int default:-- desc:名称 * @return name:cer_num type:string default:-- desc:证件号 * @return name:address type:string default:-- desc:地址 * @return name:phone type:string default:-- desc:电话 * @return name:detail type:srting default:-- desc:申请详情介绍 * @return name:status type:int default:-- desc:审核状态(0未审核,1审核通过,2审核拒绝) * @return name:check_desc type:string default:-- desc:审核备注 */ public function getPartnerApply() { $detail = UserPartner::where(['user_id'=>$this->user_id])->find(); $this->success('ok',['list'=>$detail ? $detail->toArray() :[]]); } }