|
|
|
@ -23,49 +23,119 @@ class UserController extends Controller
|
|
|
|
"action" => "1"
|
|
|
|
"action" => "1"
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$id_type_map = [
|
|
|
|
|
|
|
|
'居民身份证' => '1'
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
$person_info = [
|
|
|
|
|
|
|
|
'姓名' => ''
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
if (!!$res) {
|
|
|
|
|
|
|
|
$person_info = [
|
|
|
|
|
|
|
|
'国籍' => $res['MZ'] == '外国血统' ? '外国' : '中国',
|
|
|
|
|
|
|
|
'证件类型' => 1,
|
|
|
|
|
|
|
|
'证件号' => $res['ID_No'] ?? '',
|
|
|
|
|
|
|
|
'姓名' => $res['Patname'] ?? '',
|
|
|
|
|
|
|
|
'生日' => $res['Patbdate'] ? date('Y-m-d', strtotime($res['Patbdate'])) : date('Y-m-d'),
|
|
|
|
|
|
|
|
'民族' => $res['MZ'] ?? '',
|
|
|
|
|
|
|
|
'现地址省市区' => [
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '11',
|
|
|
|
|
|
|
|
'text' => '北京市'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '1101',
|
|
|
|
|
|
|
|
'text' => '市辖区'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '110101',
|
|
|
|
|
|
|
|
'text' => '东城区'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'现地址' => $res['Address'] ?? '',
|
|
|
|
|
|
|
|
'详细地址省市区' => [
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '11',
|
|
|
|
|
|
|
|
'text' => '北京市'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '1101',
|
|
|
|
|
|
|
|
'text' => '市辖区'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '110101',
|
|
|
|
|
|
|
|
'text' => '东城区'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'详细地址' => $res['Fulladdress'] ?? '',
|
|
|
|
|
|
|
|
'户籍地址省市区' => [
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '11',
|
|
|
|
|
|
|
|
'text' => '北京市'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '1101',
|
|
|
|
|
|
|
|
'text' => '市辖区'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'value' => '110101',
|
|
|
|
|
|
|
|
'text' => '东城区'
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
'户籍地址' => '',
|
|
|
|
|
|
|
|
'工作单位' => "",
|
|
|
|
|
|
|
|
'文化程度' => "",
|
|
|
|
|
|
|
|
'职业' => "",
|
|
|
|
|
|
|
|
'出生地' => "",
|
|
|
|
|
|
|
|
'配偶姓名' => "",
|
|
|
|
|
|
|
|
'配偶证件类型' => 0,
|
|
|
|
|
|
|
|
'配偶证件号' => "",
|
|
|
|
|
|
|
|
'血缘关系' => "无",
|
|
|
|
|
|
|
|
'邮政编码' => "",
|
|
|
|
|
|
|
|
'手机号码' => $res['Mobile'] ?? '',
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
}
|
|
|
|
return \Yz::Return(true, '获取成功', [
|
|
|
|
return \Yz::Return(true, '获取成功', [
|
|
|
|
'info' => $res ?? ['Patid' => '']
|
|
|
|
'info' => $person_info
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取配置更新时间
|
|
|
|
// 获取配置更新时间
|
|
|
|
public function info(Request $request)
|
|
|
|
public function info(Request $request)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$openid = $request->post('openid');
|
|
|
|
$openid = $request->post('openid');
|
|
|
|
if(!isset($openid)) return \Yz::echoError1("openid不能为空");
|
|
|
|
if (!isset($openid)) return \Yz::echoError1("openid不能为空");
|
|
|
|
$user=DB::table('web_users')->where(['openid'=>$openid])->first();
|
|
|
|
$user = DB::table('web_users')->where(['openid' => $openid])->first();
|
|
|
|
$userid=false;
|
|
|
|
$userid = false;
|
|
|
|
if(!$user){
|
|
|
|
if (!$user) {
|
|
|
|
$userid=DB::table('web_users')->insertGetId(['openid'=>$openid]);
|
|
|
|
$userid = DB::table('web_users')->insertGetId(['openid' => $openid]);
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
$userid=$user->id;
|
|
|
|
$userid = $user->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($userid) {
|
|
|
|
if ($userid) {
|
|
|
|
if(self::UpdatePersonList($openid)){//调用更新就诊人方法
|
|
|
|
if (self::UpdatePersonList($openid)) { //调用更新就诊人方法
|
|
|
|
//查询默认就诊人
|
|
|
|
//查询默认就诊人
|
|
|
|
$person_list=DB::table('web_user_person')->where(['user_id'=>$userid,'is_del'=>0])->get();
|
|
|
|
$person_list = DB::table('web_user_person')->where(['user_id' => $userid, 'is_del' => 0])->get();
|
|
|
|
$default_person=DB::table('web_user_person')->where(['user_id'=>$userid,'is_default'=>1,'is_del'=>0])->first();
|
|
|
|
$default_person = DB::table('web_user_person')->where(['user_id' => $userid, 'is_default' => 1, 'is_del' => 0])->first();
|
|
|
|
$count=count($person_list);
|
|
|
|
$count = count($person_list);
|
|
|
|
if($count>0 and !$default_person){
|
|
|
|
if ($count > 0 and !$default_person) {
|
|
|
|
DB::table('web_user_person')->where(['id'=>$person_list[0]->id])->update(['is_default'=>1]);
|
|
|
|
DB::table('web_user_person')->where(['id' => $person_list[0]->id])->update(['is_default' => 1]);
|
|
|
|
$default_person=$person_list[0];
|
|
|
|
$default_person = $person_list[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$info = [
|
|
|
|
$info = [
|
|
|
|
'name' => isset($default_person->name)? $default_person->name:null,
|
|
|
|
'name' => isset($default_person->name) ? $default_person->name : null,
|
|
|
|
'sex' => isset($default_person->sex)?$default_person->sex:null,
|
|
|
|
'sex' => isset($default_person->sex) ? $default_person->sex : null,
|
|
|
|
'phone'=>$default_person->phone,
|
|
|
|
'phone' => $default_person->phone,
|
|
|
|
'id_number'=>$default_person->id_number,
|
|
|
|
'id_number' => $default_person->id_number,
|
|
|
|
'count' => $count,
|
|
|
|
'count' => $count,
|
|
|
|
'openid' => $openid,
|
|
|
|
'openid' => $openid,
|
|
|
|
'person_id' => $default_person->id,
|
|
|
|
'person_id' => $default_person->id,
|
|
|
|
'married'=>$default_person->married
|
|
|
|
'married' => $default_person->married
|
|
|
|
];
|
|
|
|
];
|
|
|
|
return \Yz::Return(true, '获取成功', [
|
|
|
|
return \Yz::Return(true, '获取成功', [
|
|
|
|
'info' => $info
|
|
|
|
'info' => $info
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取名下体检人列表
|
|
|
|
//获取名下体检人列表
|
|
|
|
@ -110,43 +180,43 @@ class UserController extends Controller
|
|
|
|
//调用his接口查询用户积分和预存款
|
|
|
|
//调用his接口查询用户积分和预存款
|
|
|
|
$integral = 90;
|
|
|
|
$integral = 90;
|
|
|
|
$save_money = 150;
|
|
|
|
$save_money = 150;
|
|
|
|
$coupon_count = 2;//优惠券数量
|
|
|
|
$coupon_count = 2; //优惠券数量
|
|
|
|
|
|
|
|
|
|
|
|
$person->integral = $integral;
|
|
|
|
$person->integral = $integral;
|
|
|
|
$person->save_money = $save_money;
|
|
|
|
$person->save_money = $save_money;
|
|
|
|
$person->coupon_count = $coupon_count;
|
|
|
|
$person->coupon_count = $coupon_count;
|
|
|
|
return \Yz::Return(true, "查询完成", ['person_info' => $person]);
|
|
|
|
return \Yz::Return(true, "查询完成", ['person_info' => $person]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function tttt(){
|
|
|
|
public function tttt()
|
|
|
|
$XCX=new XCXApiController();
|
|
|
|
{
|
|
|
|
$data=[
|
|
|
|
$XCX = new XCXApiController();
|
|
|
|
'wxid'=>'oosgJj-SVIxTrm_g1p213tsSHK5g'
|
|
|
|
$data = [
|
|
|
|
|
|
|
|
'wxid' => 'oosgJj-SVIxTrm_g1p213tsSHK5g'
|
|
|
|
];
|
|
|
|
];
|
|
|
|
$res=$XCX::Post('就诊人列表',$data);
|
|
|
|
$res = $XCX::Post('就诊人列表', $data);
|
|
|
|
$ApiPersonList=$res['data'];
|
|
|
|
$ApiPersonList = $res['data'];
|
|
|
|
//dd($ApiPersonList[0]);
|
|
|
|
//dd($ApiPersonList[0]);
|
|
|
|
$XCX::XCXDecode($ApiPersonList[0]['idNumber']);
|
|
|
|
$XCX::XCXDecode($ApiPersonList[0]['idNumber']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//更新用户列表,调用远程小程序接口
|
|
|
|
//更新用户列表,调用远程小程序接口
|
|
|
|
public function UpdatePersonList($openid)
|
|
|
|
public function UpdatePersonList($openid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$env=config('app.globals.Env');
|
|
|
|
$env = config('app.globals.Env');
|
|
|
|
if($env=='pro'){ //如果是正式环境
|
|
|
|
if ($env == 'pro') { //如果是正式环境
|
|
|
|
$XCX=new XCXApiController();
|
|
|
|
$XCX = new XCXApiController();
|
|
|
|
$data=[
|
|
|
|
$data = [
|
|
|
|
'wxid'=>$openid
|
|
|
|
'wxid' => $openid
|
|
|
|
];
|
|
|
|
];
|
|
|
|
$res=$XCX::Post('就诊人列表',$data);
|
|
|
|
$res = $XCX::Post('就诊人列表', $data);
|
|
|
|
$ApiPersonList=$res['data'];
|
|
|
|
$ApiPersonList = $res['data'];
|
|
|
|
// dd($ApiPersonList);
|
|
|
|
// dd($ApiPersonList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($env=='dev'){//如果是开发环境
|
|
|
|
if ($env == 'dev') { //如果是开发环境
|
|
|
|
$ApiPersonList = [
|
|
|
|
$ApiPersonList = [
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'ghzid' => 'ghz11',
|
|
|
|
'ghzid' => 'ghz11',
|
|
|
|
'idNumber'=>'15210219920524154X',
|
|
|
|
'idNumber' => '15210219920524154X',
|
|
|
|
'name' => '周京京',
|
|
|
|
'name' => '周京京',
|
|
|
|
'phone' => '11111111111',
|
|
|
|
'phone' => '11111111111',
|
|
|
|
'sex' => '1',
|
|
|
|
'sex' => '1',
|
|
|
|
@ -156,7 +226,7 @@ class UserController extends Controller
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'ghzid' => 'ghz22',
|
|
|
|
'ghzid' => 'ghz22',
|
|
|
|
'idNumber'=>'460026199002190013',
|
|
|
|
'idNumber' => '460026199002190013',
|
|
|
|
'name' => '测试2',
|
|
|
|
'name' => '测试2',
|
|
|
|
'phone' => '222222222',
|
|
|
|
'phone' => '222222222',
|
|
|
|
'sex' => '1',
|
|
|
|
'sex' => '1',
|
|
|
|
@ -166,7 +236,7 @@ class UserController extends Controller
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'ghzid' => 'ghz22555',
|
|
|
|
'ghzid' => 'ghz22555',
|
|
|
|
'idNumber'=>'411329199901052356',
|
|
|
|
'idNumber' => '411329199901052356',
|
|
|
|
'name' => '信息科1',
|
|
|
|
'name' => '信息科1',
|
|
|
|
'phone' => '222222222',
|
|
|
|
'phone' => '222222222',
|
|
|
|
'sex' => '1',
|
|
|
|
'sex' => '1',
|
|
|
|
@ -183,7 +253,7 @@ class UserController extends Controller
|
|
|
|
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
|
|
|
|
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
|
|
|
|
if (!$user) return \Yz::echoError1('用户不存在');
|
|
|
|
if (!$user) return \Yz::echoError1('用户不存在');
|
|
|
|
//库里存在的用户ghzid数组
|
|
|
|
//库里存在的用户ghzid数组
|
|
|
|
$db_person_ghzids = DB::table('web_user_person')->where(['user_id' => $user->id,'is_del'=>0])->pluck('ghzid')->toArray();
|
|
|
|
$db_person_ghzids = DB::table('web_user_person')->where(['user_id' => $user->id, 'is_del' => 0])->pluck('ghzid')->toArray();
|
|
|
|
//接口返回的用户ghzids数组
|
|
|
|
//接口返回的用户ghzids数组
|
|
|
|
$api_person_ghzids = [];
|
|
|
|
$api_person_ghzids = [];
|
|
|
|
foreach ($ApiPersonList as $apiperson) {
|
|
|
|
foreach ($ApiPersonList as $apiperson) {
|
|
|
|
@ -195,50 +265,49 @@ class UserController extends Controller
|
|
|
|
$onlyInDb = array_diff($db_person_ghzids, $api_person_ghzids);
|
|
|
|
$onlyInDb = array_diff($db_person_ghzids, $api_person_ghzids);
|
|
|
|
// 仅存在于 api接口 中的ghzid
|
|
|
|
// 仅存在于 api接口 中的ghzid
|
|
|
|
$onlyInApi = array_diff($api_person_ghzids, $db_person_ghzids);
|
|
|
|
$onlyInApi = array_diff($api_person_ghzids, $db_person_ghzids);
|
|
|
|
$success_count=0;
|
|
|
|
$success_count = 0;
|
|
|
|
foreach ($ApiPersonList as $apiperson) {
|
|
|
|
foreach ($ApiPersonList as $apiperson) {
|
|
|
|
$marriage=0;
|
|
|
|
$marriage = 0;
|
|
|
|
if($apiperson['marriage']=='未婚'){
|
|
|
|
if ($apiperson['marriage'] == '未婚') {
|
|
|
|
$marriage=2;
|
|
|
|
$marriage = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($apiperson['marriage']=='已婚'){
|
|
|
|
if ($apiperson['marriage'] == '已婚') {
|
|
|
|
$marriage=1;
|
|
|
|
$marriage = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$personInfo = [
|
|
|
|
$personInfo = [
|
|
|
|
'ghzid' => $apiperson['ghzid'],
|
|
|
|
'ghzid' => $apiperson['ghzid'],
|
|
|
|
'id_number' => $env=='dev'? $apiperson['idNumber']:$XCX::XCXDecode($apiperson['idNumber']),
|
|
|
|
'id_number' => $env == 'dev' ? $apiperson['idNumber'] : $XCX::XCXDecode($apiperson['idNumber']),
|
|
|
|
'name' => $apiperson['name'],
|
|
|
|
'name' => $apiperson['name'],
|
|
|
|
'birthday' => $apiperson['birthday'],
|
|
|
|
'birthday' => $apiperson['birthday'],
|
|
|
|
'sex' => $apiperson['sex'],
|
|
|
|
'sex' => $apiperson['sex'],
|
|
|
|
'phone' => $env=='dev'?$apiperson['phone']:$XCX::XCXDecode($apiperson['phone']),
|
|
|
|
'phone' => $env == 'dev' ? $apiperson['phone'] : $XCX::XCXDecode($apiperson['phone']),
|
|
|
|
'married' =>$marriage,
|
|
|
|
'married' => $marriage,
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'user_id' => $user->id,
|
|
|
|
'patient_type' => $apiperson['patientType'],
|
|
|
|
'patient_type' => $apiperson['patientType'],
|
|
|
|
'updated_at'=>date('Y-m-d H:i:s')
|
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
];
|
|
|
|
];
|
|
|
|
if (in_array($apiperson['ghzid'], $intersection)) {//双方都有的,更新
|
|
|
|
if (in_array($apiperson['ghzid'], $intersection)) { //双方都有的,更新
|
|
|
|
$u=DB::table('web_user_person')->where(['user_id' => $user->id, 'ghzid' => $apiperson['ghzid']])->update($personInfo);
|
|
|
|
$u = DB::table('web_user_person')->where(['user_id' => $user->id, 'ghzid' => $apiperson['ghzid']])->update($personInfo);
|
|
|
|
if($u) $success_count+=$u;
|
|
|
|
if ($u) $success_count += $u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (in_array($apiperson['ghzid'], $onlyInApi)) { //小程序新增的 添加
|
|
|
|
if (in_array($apiperson['ghzid'], $onlyInApi)) { //小程序新增的 添加
|
|
|
|
$i=DB::table('web_user_person')->insert($personInfo);
|
|
|
|
$i = DB::table('web_user_person')->insert($personInfo);
|
|
|
|
if($i) $success_count++;
|
|
|
|
if ($i) $success_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (count($onlyInDb) > 0) { //小程序不存在的用户 ,数据进行删除
|
|
|
|
if (count($onlyInDb) > 0) { //小程序不存在的用户 ,数据进行删除
|
|
|
|
$d=DB::table('web_user_person')->where(['user_id' => $user->id])->whereIn('ghzid',$onlyInDb)->update([
|
|
|
|
$d = DB::table('web_user_person')->where(['user_id' => $user->id])->whereIn('ghzid', $onlyInDb)->update([
|
|
|
|
'is_del' => 1
|
|
|
|
'is_del' => 1
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
if($d) $success_count++;
|
|
|
|
if ($d) $success_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//设置默认体检人
|
|
|
|
//设置默认体检人
|
|
|
|
// $default=DB::table('web_user_person')->where(['user_id' => $user->id,'is_del'=>0,'is_default'=>1])->get();
|
|
|
|
// $default=DB::table('web_user_person')->where(['user_id' => $user->id,'is_del'=>0,'is_default'=>1])->get();
|
|
|
|
// $p_list=DB::table('web_user_person')->where(['user_id' => $user->id,'is_del'=>0])->get();
|
|
|
|
// $p_list=DB::table('web_user_person')->where(['user_id' => $user->id,'is_del'=>0])->get();
|
|
|
|
// if(count($p_list)>0 and count($default)===0){
|
|
|
|
// if(count($p_list)>0 and count($default)===0){
|
|
|
|
// DB::table('web_user_person')->where(['id'=>$p_list[0]->id])->update(['is_default'=>1]);
|
|
|
|
// DB::table('web_user_person')->where(['id'=>$p_list[0]->id])->update(['is_default'=>1]);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|