前端添加上传身份证正反面字段
This commit is contained in:
parent
63a40df24a
commit
879d6d4a7d
@ -7,9 +7,11 @@ use app\common\server\JsonServer;
|
||||
use think\exception\ValidateException;
|
||||
use app\api\validate\DistributionValidate;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAuth;
|
||||
use think\response\Json;
|
||||
use app\common\model\distribution\Distribution as DistributionModel;
|
||||
|
||||
use weixin\Getopenid;
|
||||
use think\facade\Db;
|
||||
class Distribution extends Api
|
||||
{
|
||||
public $like_not_need_login = ['fixAncestorRelation'];
|
||||
@ -21,11 +23,11 @@ class Distribution extends Api
|
||||
if($this->request->isPost()){
|
||||
$post = $this->request->post();
|
||||
$post['user_id'] = $this->user_id;
|
||||
// try{
|
||||
// validate(DistributionValidate::class)->scene('apply')->check($post);
|
||||
// }catch(ValidateException $e) {
|
||||
// return JsonServer::error($e->getError());
|
||||
// }
|
||||
try{
|
||||
validate(DistributionValidate::class)->scene('apply')->check($post);
|
||||
}catch(ValidateException $e) {
|
||||
return JsonServer::error($e->getError());
|
||||
}
|
||||
$result = DistributionLogic::apply($post);
|
||||
if($result) {
|
||||
return JsonServer::success('申请成功');
|
||||
@ -67,14 +69,104 @@ class Distribution extends Api
|
||||
/**
|
||||
* 填写邀请码
|
||||
*/
|
||||
/**
|
||||
* 填写邀请码
|
||||
*/
|
||||
public function writeCode()
|
||||
{
|
||||
|
||||
|
||||
$invite_code = $this->request->post('invite_code');
|
||||
$up_user = User::where("distribution_code",$invite_code)->where("del",0)->where("disable",0)->find();
|
||||
$user_id = $this->user_id;
|
||||
if($user_id == $up_user['id']){
|
||||
// return JsonServer::success('请求成功');
|
||||
return JsonServer::error("绑定失败,自己不能成为自己上级");
|
||||
}
|
||||
$user_msg = User::where("id",$user_id)->where("del",0)->find();
|
||||
if($user_msg['first_leader'] > 0){
|
||||
return JsonServer::error("绑定失败,已有上级");
|
||||
// return JsonServer::success('请求成功');
|
||||
}
|
||||
$is_d = Db::name("distribution")->where('user_id', $up_user['id'] )->where('is_distribution', 1 )->find();
|
||||
if($is_d == null){
|
||||
return JsonServer::error("绑定失败,绑定人员不是分销会员");
|
||||
}
|
||||
User::where("id",$user_id)->update(["first_leader"=>$up_user['id']]);
|
||||
return JsonServer::success('绑定上级成功');
|
||||
}
|
||||
public function code()
|
||||
{
|
||||
|
||||
|
||||
$code = $this->request->post('code');
|
||||
$invite_code = $this->request->post('invite_code',0);
|
||||
|
||||
|
||||
// file_put_contents('log.txt', 'invite_code= ' . $invite_code . '; code='. $code);
|
||||
// die;
|
||||
$data = [
|
||||
'user_id' => $this->user_id,
|
||||
'code' => $code,
|
||||
];
|
||||
|
||||
// trace('invite_code', $invite_code.'-'.$code);
|
||||
if(isset($invite_code)){
|
||||
if($invite_code != 0){
|
||||
$open=new Getopenid();
|
||||
$info=$open->getAcc($code);
|
||||
if(isset($info['openid'])) {
|
||||
$openid = $info['openid'];
|
||||
$user_msg = UserAuth::where("openid",$openid)->find();
|
||||
$firend_msg = User::where("distribution_code",$invite_code)->find();
|
||||
if($user_msg==null){
|
||||
$divide_role_user_id = 0;
|
||||
$firend_id = 0;
|
||||
$is_d = Db::name("distribution")->where('user_id', $firend_msg['id'] )->where('is_distribution', 1 )->find();
|
||||
if($is_d != null){
|
||||
$firend_id = $firend_msg['id'];
|
||||
if($firend_msg['first_leader'] !=0){
|
||||
$divide_role_user_id = $firend_msg['first_leader'];
|
||||
}else{
|
||||
$divide_role_user_id = $firend_id;
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'sn' => create_user_sn(),
|
||||
'create_time' => time(),
|
||||
"first_leader" => $firend_id,
|
||||
'distribution_code' => generate_invite_code(),//分销邀请码
|
||||
'is_distribution' => DistributionLogic::isDistributionMember(),
|
||||
'client' => 1,
|
||||
'is_new_user' => 1,
|
||||
'user_ad_cret' => 1,
|
||||
'divide_role_user_id' => $divide_role_user_id
|
||||
];
|
||||
$user = User::create($data);
|
||||
$user_id = $user->id;
|
||||
$UserAuth = UserAuth::create([
|
||||
"user_id"=>$user_id,
|
||||
"openid"=>$openid,
|
||||
"create_time"=>time(),
|
||||
"client"=>1
|
||||
]);
|
||||
if($is_d != null){
|
||||
$firend_id = $firend_msg['id'];
|
||||
$dat['f_user_id'] = $firend_id;
|
||||
$dat['user_id'] = $user_id;
|
||||
$dat['ditme'] = date("Y-m-d H:i:s");
|
||||
Db::name("user_firster")->save($dat);
|
||||
}
|
||||
//生成会员分销扩展表
|
||||
DistributionLogic::createUserDistribution($user_id);
|
||||
|
||||
// 生成分销基础信息表
|
||||
\app\common\logic\DistributionLogic::add($user_id);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try{
|
||||
validate(DistributionValidate::class)->scene('code')->check($data);
|
||||
}catch(ValidateException $e){
|
||||
|
||||
@ -91,25 +91,30 @@ class DistributionLogic extends Logic
|
||||
*/
|
||||
public static function apply($post)
|
||||
{
|
||||
$time = time();
|
||||
$data = [
|
||||
'user_id' => $post['user_id'],
|
||||
'real_name' => $post['real_name'],
|
||||
'mobile' => $post['mobile'],
|
||||
'province' => $post['province'],
|
||||
'city' => $post['city'],
|
||||
'district' => $post['district'],
|
||||
// 'reason' => $post['reason'],
|
||||
'status' => 1, // 待审核
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
];
|
||||
\app\common\logic\DistributionLogic::add($post['user_id']);
|
||||
Distribution::where('user_id', $post['user_id'])->update([
|
||||
'is_distribution' => 1,
|
||||
'distribution_time' => time()
|
||||
]);
|
||||
return DistributionMemberApply::create($data);
|
||||
$time = time();
|
||||
$data = [
|
||||
'user_id' => $post['user_id'],
|
||||
'real_name' => $post['real_name'],
|
||||
'mobile' => $post['mobile'],
|
||||
'province' => $post['province'],
|
||||
'city' => $post['city'],
|
||||
'district' => $post['district'],
|
||||
'reason' => $post['reason'],
|
||||
'status' => 0, // 待审核
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
//'id_card' => $post['id_card'], // todo 弃用该字段
|
||||
'front_id_card' => $post['front_id_card'],
|
||||
'back_id_card' => $post['back_id_card'],
|
||||
'hand_id_card' => $post['hand_id_card']
|
||||
];
|
||||
|
||||
\app\common\logic\DistributionLogic::add($post['user_id']);
|
||||
// Distribution::where('user_id', $post['user_id'])->update([
|
||||
// 'is_distribution' => 0,
|
||||
// 'distribution_time' => time()
|
||||
// ]);
|
||||
return DistributionMemberApply::create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +122,7 @@ class DistributionLogic extends Logic
|
||||
*/
|
||||
public static function applyDetail($userId)
|
||||
{
|
||||
$result = DistributionMemberApply::field(['real_name','mobile','province', 'city', 'district', 'reason', 'denial_reason', 'status'])
|
||||
$result = DistributionMemberApply::field(['real_name','mobile','province', 'city', 'district', 'id_card', 'hand_id_card', 'reason', 'denial_reason', 'status'])
|
||||
->where('user_id', $userId)
|
||||
->order('id', 'desc')
|
||||
->findOrEmpty();
|
||||
@ -126,9 +131,10 @@ class DistributionLogic extends Logic
|
||||
return [];
|
||||
}
|
||||
$result = $result->toArray();
|
||||
// $result['province'] = AreaServer::getAddress($result['province']);
|
||||
// $result['city'] = AreaServer::getAddress($result['city']);
|
||||
// $result['district'] = AreaServer::getAddress($result['district']);
|
||||
$result['province'] = AreaServer::getAddress($result['province']);
|
||||
$result['city'] = AreaServer::getAddress($result['city']);
|
||||
$result['district'] = AreaServer::getAddress($result['district']);
|
||||
$result['id_card'] = substr_replace($result['id_card'], '********' , 6, 8);
|
||||
|
||||
switch ($result['status']) {
|
||||
case 0:
|
||||
@ -230,9 +236,11 @@ class DistributionLogic extends Logic
|
||||
if($firstLeader->isEmpty()) {
|
||||
throw new \think\Exception('无效的邀请码');
|
||||
}
|
||||
|
||||
// 上级
|
||||
$first_leader_id = $firstLeader['id'];
|
||||
if($first_leader_id == $post['user_id']){
|
||||
return true;
|
||||
}
|
||||
// 上上级
|
||||
$second_leader_id = $firstLeader['first_leader'];
|
||||
// 上上上级
|
||||
|
||||
@ -20,6 +20,9 @@ class DistributionValidate extends Validate
|
||||
'district' => 'require|number',
|
||||
'reason' => 'require',
|
||||
'code' => 'require|checkCode',
|
||||
'front_id_card' => 'require',
|
||||
'back_id_card' => 'require',
|
||||
'hand_id_card' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
@ -35,6 +38,9 @@ class DistributionValidate extends Validate
|
||||
'district.number' => '县区段为数字代号',
|
||||
'reason.require' => '请填写申请原因',
|
||||
'code.require' => '请填写邀请码',
|
||||
'front_id_card.require' => '请上传身份证正面',
|
||||
'back_id_card.require' => '请上传身份证反面',
|
||||
'hand_id_card.require' => '请上传手持身份证照片',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -42,7 +48,7 @@ class DistributionValidate extends Validate
|
||||
*/
|
||||
public function sceneApply()
|
||||
{
|
||||
return $this->only(['user_id','real_name','mobile','province','city','district','reason']);
|
||||
return $this->only(['user_id','real_name','mobile','province','city','district','reason', 'front_id_card', 'back_id_card', 'hand_id_card']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +70,7 @@ class DistributionValidate extends Validate
|
||||
];
|
||||
$apply = DistributionMemberApply::where($where)->findOrEmpty();
|
||||
if($apply->isEmpty()) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return '正在审核中,请勿重复提交申请';
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user