diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/AppointmentController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/AppointmentController.php index 618f66b..477ddb5 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/AppointmentController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/AppointmentController.php @@ -28,9 +28,15 @@ class AppointmentController extends Controller $source='接口'; $info=request('info'); + //HSM加密 + $HSM =\App\Lib\HSM::HsmEncrypt($info['id_card_num']); + if($HSM['status']!=true){ + return \Yz::echoError1('身份证号加密失败'); + } + $info['id_card_num']=$HSM['data']; $c=DB::table('appointment_record as a') - ->where([['a.id_card_num','=',$info['id_card_num']],['a.fee_type','=',0],['a.created_at','>=',$firstDay],['a.created_at','<=',$lastDay]])->get(); + ->where([['a.id_card_num','=',$info['id_card_num']],['a.is_del','=',0],['a.fee_type','=',0],['a.created_at','>=',$firstDay],['a.created_at','<=',$lastDay]])->get(); if(count($c)>0){ $result['status']=false; $result['msg']='已体检过'; @@ -51,6 +57,7 @@ class AppointmentController extends Controller 'sex'=>$info['sex'], 'tel'=>$info['tel'], 'status'=>1, + 'is_del'=>0, //'content'=>json_encode($info['content']), 'content'=>isset($info['content'])?json_encode($info['content'],JSON_UNESCAPED_UNICODE):'', 'fee_type'=>$info['fee_type'], @@ -65,4 +72,16 @@ class AppointmentController extends Controller return \Yz::echoError1('保存失败'); } } + public function Del() + { + $id=request('id'); + $d=DB::table('appointment_record')->where('id',$id)->update([ + 'is_del'=>1 + ]); + if($d){ + return \Yz::Return(true,'操作成功',[]); + }else{ + return \Yz::echoError1('操作失败'); + } + } } diff --git a/Laravel/app/Services/Admin/YeWu/AppointmentService.php b/Laravel/app/Services/Admin/YeWu/AppointmentService.php index 7717739..dc6a2b4 100644 --- a/Laravel/app/Services/Admin/YeWu/AppointmentService.php +++ b/Laravel/app/Services/Admin/YeWu/AppointmentService.php @@ -12,12 +12,26 @@ class AppointmentService $sql=$sql .' and a.status = ? '; array_push($canshu, $arr['searchInfo']['status']); } + if($arr['searchInfo']['userinfo']){ + if (preg_match('/\d/', $arr['searchInfo']['userinfo'])) { + $HSM =\App\Lib\HSM::HsmEncrypt($arr['searchInfo']['userinfo']); + if($HSM['status'] !=true){ + return \Yz::echoError1('身份证号加密失败'); + } + $encode_id_card_num=$HSM['data']; + $sql=$sql .' and (a.id_card_num like ? or a.id_card_num = ?)'; + array_push($canshu, '%'.$arr['searchInfo']['userinfo'].'%'); + array_push($canshu, $encode_id_card_num); + }else{ + $sql=$sql .' and a.name like ?'; + array_push($canshu, '%'.$arr['searchInfo']['userinfo'].'%'); + } + } if($arr['searchInfo']['calendarId']){ $sql=$sql .' and a.calendar_id = ? '; array_push($canshu, $arr['searchInfo']['calendarId']); } - if($arr['searchInfo']['dateRange']){ $sql=$sql . ' and a.date>=? and a.date<=? '; @@ -41,9 +55,9 @@ class AppointmentService array_push($canshu,($arr['page']-1)*$arr['pageSize'],$arr['pageSize']); $query=DB::select("select a.*,b.org_name from appointment_record as a LEFT JOIN - medical_institution as b on a.org_id=b.id ".$sql." order by a.id desc limit ?,?",$canshu); + medical_institution as b on a.org_id=b.id ".$sql." and (a.is_del<>1 or a.is_del is null) order by a.id desc limit ?,?",$canshu); - $count=DB::select("select count(*) as c from appointment_record as a ".$sql,$canshu); + $count=DB::select("select count(*) as c from appointment_record as a ".$sql ." and (a.is_del<>1 or a.is_del is null) ",$canshu); return \Yz::Return(true,'',['list'=>$query,'count'=>$count[0]->c]); } @@ -60,10 +74,26 @@ class AppointmentService if($type==2 and $this->isOver65($id_card_num)===false){ return \Yz::echoError1("年龄不满足条件"); } + $HSM =\App\Lib\HSM::HsmEncrypt($id_card_num); + if($HSM['status'] !=true){ + return \Yz::echoError1('身份证号加密失败'); + } + $encode_id_card_num=$HSM['data']; +// $c=DB::table('appointment_record as a') +// ->leftJoin('medical_institution as b', 'a.org_id', '=', 'b.id') +// ->select(['a.id','a.org_id','a.id_card_num','a.created_at as insertime','b.org_name']) +// ->where(['a.id_card_num'=>$id_card_num,'a.is_del'=>0,'a.type'=>$type,['a.created_at','>=',$firstDay],['a.created_at','<=',$lastDay]])->whereIn('a.status',[1,2])->get(); + $c=DB::table('appointment_record as a') ->leftJoin('medical_institution as b', 'a.org_id', '=', 'b.id') ->select(['a.id','a.org_id','a.id_card_num','a.created_at as insertime','b.org_name']) - ->where(['a.id_card_num'=>$id_card_num,'a.type'=>$type,['a.created_at','>=',$firstDay],['a.created_at','<=',$lastDay]])->whereIn('a.status',[1,2])->get(); + ->where(function ($query) use ($id_card_num, $encode_id_card_num) { + $query->where('a.id_card_num', $id_card_num) + ->orWhere('a.id_card_num', $encode_id_card_num); + }) + ->where(['a.type' => $type,'a.is_del'=>0, ['a.created_at', '>=', $firstDay], ['a.created_at', '<=', $lastDay]]) + ->whereIn('a.status', [1, 2]) + ->get(); if(count($c)){ $result['status']=false; $result['msg']='已体检过';