|
|
<?php
|
|
|
namespace App\Services\mH5;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class PersonService
|
|
|
{
|
|
|
//检测是否注册过
|
|
|
public function checkRegister($arr){
|
|
|
$openid=$arr['openid'];
|
|
|
$c=DB::table('persons')->where(['openid'=>$openid])->get();
|
|
|
if(count($c)){
|
|
|
return true;
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
//注册
|
|
|
public function Register($arr){
|
|
|
$result=array();
|
|
|
$c= $this->checkRegister(['openid'=>$arr['openid']]);
|
|
|
if($c){
|
|
|
$result['status']=false;
|
|
|
$result['msg']='已注册过,无需进行此操作';
|
|
|
}else{
|
|
|
$i=DB::table('persons')->insert([
|
|
|
'name' => $arr['info']['name'],
|
|
|
'sex' => $arr['info']['sex'],
|
|
|
'id_card_num' => $arr['info']['sfz'],
|
|
|
'tel' => $arr['info']['tel'],
|
|
|
'openid' => $arr['openid'],
|
|
|
'status'=>1
|
|
|
]);
|
|
|
if($i){
|
|
|
$result['status']=true;
|
|
|
$result['msg']='创建成功';
|
|
|
}else{
|
|
|
$result['status']=false;
|
|
|
$result['msg']='操作失败';
|
|
|
}
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
public function GetPersonRecode($arr){
|
|
|
$result=array();
|
|
|
$id_num='';
|
|
|
|
|
|
if(isset($arr['group']) and $arr['group']=='mH5user'){ //如果是本地项目请求(非对外接口)
|
|
|
$openid=$arr['openid'];
|
|
|
$c=DB::table('persons')->select(['id_card_num'])->where(['openid'=>$openid,'status'=>1])->get();
|
|
|
if(count($c)>0){
|
|
|
$id_num=$c[0]->id_card_num;
|
|
|
}else{
|
|
|
$result['status']=false;
|
|
|
$result['msg']='未找到有效用户';
|
|
|
}
|
|
|
}else{ //对外接口,直接获取证件IdNum
|
|
|
$id_num=$arr['id_num'];
|
|
|
}
|
|
|
|
|
|
if(strlen($id_num)>0){
|
|
|
date_default_timezone_set('PRC');
|
|
|
$currentYear = date('Y');
|
|
|
$firstDay = date('Y-01-01', strtotime($currentYear));
|
|
|
$lastDay = date('Y-12-31', strtotime($currentYear));
|
|
|
|
|
|
$c=DB::table('examination_records')->select(['id','id_card_num','created_at as insertime'])->where([['id_card_num','=',$id_num],['created_at','>',$firstDay],['created_at','<',$lastDay]])->get();
|
|
|
if(count($c)>0){
|
|
|
$result['status']=false;
|
|
|
$result['msg']='已体检过';
|
|
|
$result['info']=$c;
|
|
|
}else{
|
|
|
$result['status']=true;
|
|
|
$result['msg']='可以继续,本年度无体检记录';
|
|
|
}
|
|
|
}else{
|
|
|
$result['status']=false;
|
|
|
$result['msg']='用户证件号未传';
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
}
|