123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- namespace app\api\controller;
- use app\common\model\RegionalAgency;
- use app\common\model\User;
- use app\common\model\UserPartner;
- use library\tools\Data;
- /**
- * @title 会员区域代理&&分销
- * @controller UserRank
- * @group base
- */
- class UserRank extends Base
- {
- public function initialize()
- {
- parent::initialize();
- parent::checkLogin();
- }
- /**
- * @title 申请(编辑)成为区域代理
- * @desc 申请(编辑)成为区域代理
- * @author qc
- * @url /api/User_rank/applyAgency
- * @method POST
- * @header name:Authorization require:1 desc:Token
- * @param name:true_name type:string default:-- desc:名称
- * @param name:birth type:string default:-- desc:出生日期
- * @param name:pro_id type:int default:-- desc:省id
- * @param name:city_id type:int default:-- desc:省id
- * @param name:pro_name type:string default:-- desc:省名
- * @param name:city_name type:string default:-- desc:市名
- * @param name:cer_type type:int default:1 desc:证件类型(1身份证)
- * @param name:cer_num type:string default:-- desc:证件号
- * @param name:detail type:srting default:-- desc:申请详情介绍
- */
- public function applyAgency()
- {
- $true_name = input('post.true_name');
- $birth = input('post.birth');
- $pro_id = input('post.pro_id');
- $city_id = input('post.city_id');
- $pro_name = input('post.pro_name');
- $city_name = input('post.city_name');
- $cer_type = input('post.cer_type');
- $cer_num = input('post.cer_num');
- $detail = input('post.detail');
- $is_agency = User::where('id',$this->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() :[]]);
- }
- }
|