You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
5.7 KiB
PHP
179 lines
5.7 KiB
PHP
<?php
|
|
namespace App\Http\Controllers;
|
|
use DateTime;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Login;
|
|
use Yo;
|
|
|
|
class FenZhenController extends Controller
|
|
{
|
|
public $baseUrl='https://bjgk.fenzhen.sa0.online';
|
|
|
|
//通知分诊登记
|
|
public function FenZhenDengJI($order_id)
|
|
{
|
|
// $order_id=91;
|
|
$order_info= DB::table('user_orders')->where('id', $order_id)->first();
|
|
if(!!$order_info){
|
|
$appointmentDate=substr($order_info->appointment_time, 0, 10).' 08:00:00';
|
|
$item_ids=json_decode($order_info->item_ids, true);
|
|
$dataList=[];
|
|
$currentHour = date('H'); // 获取小时
|
|
$currentMinute = date('i'); // 获取分钟
|
|
$currentSecond = date('s'); // 获取秒
|
|
$regnum=$currentHour . $currentMinute . $currentSecond.$order_info->user;
|
|
foreach ($item_ids as $item_id) {
|
|
$data=[
|
|
"time_start" => $appointmentDate,
|
|
"time_end" => $appointmentDate,
|
|
"department_name" => "",
|
|
"doctor_name" => "",
|
|
"up_type" => "2",
|
|
"department_id" => "0",
|
|
"clinic_id" => "0",
|
|
"doctor_id" => "0",
|
|
"item_id" => $item_id,
|
|
"reg_number" => $regnum
|
|
];
|
|
$dataList[]=$data;
|
|
}
|
|
$array = array(
|
|
"name" => $order_info->name,
|
|
"id_number" => $order_info->id_number,
|
|
"social_security" => "",
|
|
"type" => "0",
|
|
"sex" => $order_info->sex,
|
|
"birthday" => $order_info->birthday,
|
|
"phone" => $order_info->phone,
|
|
"push_type" => "1",
|
|
"group_id" => "0",
|
|
"line_up" => "1",
|
|
"data" =>$dataList
|
|
);
|
|
$url = $this->baseUrl.'/in/push_order.php';
|
|
$res = self::post($url,$array);
|
|
$res=json_decode($res,true);
|
|
if($res['code']===200 and isset($res['data']['create_ids'])){
|
|
$u= DB::table('user_orders')->where('id', $order_id)->update(['fenzhen_create_ids' => $res['data']['create_ids']]);
|
|
if($u>0){
|
|
return response()->json(['code' => 0, 'msg' => '通知成功']);
|
|
}else{
|
|
return response()->json(['code' => -1, 'msg' => '存储更新失败']);
|
|
}
|
|
|
|
}else{
|
|
//调用远程接口出错
|
|
return Yo::error_echo(200091);
|
|
}
|
|
|
|
}else{
|
|
return Yo::error_echo(100000, ['订单']);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//查询分诊那边的记录
|
|
public function FenZhenChaXun(Request $request){
|
|
|
|
|
|
$url = $this->baseUrl.'/in/get_list.php';
|
|
Login::user();
|
|
$sfz = $request->post('sfz');
|
|
$order_info= DB::table('user_orders')->where(['user'=>Login::$info->id,'id_number'=>$sfz])
|
|
->whereNotNull('fenzhen_create_ids')
|
|
->where('fenzhen_create_ids', '!=', '')
|
|
->orderBy('id','desc')->first();
|
|
|
|
if(!!$order_info){
|
|
//用户信息
|
|
$buy_info=json_decode($order_info->buy_info, true);
|
|
$sex=$order_info->sex;
|
|
$birthday = new DateTime($order_info->birthday);
|
|
// 今天的日期
|
|
$today = new DateTime();
|
|
// 计算年龄差
|
|
$diff = $today->diff($birthday);
|
|
|
|
|
|
|
|
$create_ids=json_decode($order_info->fenzhen_create_ids, true);
|
|
$group_id= min($create_ids);
|
|
$array = array(
|
|
"group_id" => $group_id,
|
|
);
|
|
$res = self::post($url,$array,'Bearer password.123456');
|
|
$res=json_decode($res,true);
|
|
|
|
if($res['code']===200){
|
|
$reg_num= isset($res['data']['list'][0]['reg_number'])?$res['data']['list'][0]['reg_number']:'';
|
|
$generator = new \Picqer\Barcode\BarcodeGeneratorHTML();
|
|
$a= $generator->getBarcode($reg_num, $generator::TYPE_CODE_128, 3, 50);
|
|
$user_info=[
|
|
"name" => $order_info->name,
|
|
"sex" => $sex==1?'男':'女',
|
|
"comboName" =>isset($buy_info['combo']['name'])? $buy_info['combo']['name']:'' ,
|
|
"appointment_date" => substr($order_info->appointment_time, 0, 10),
|
|
"age"=>$diff->y,
|
|
'tiaoma'=>$a,
|
|
'tiaoma_num'=>$reg_num,
|
|
];
|
|
return Yo::echo(['list' => $res['data']['list'],'user_info'=>$user_info]);
|
|
}else{
|
|
//调用远程接口出错
|
|
return Yo::error_echo(200091);
|
|
}
|
|
}else{
|
|
//未查询到该用户分诊记录
|
|
return Yo::error_echo(200090);
|
|
}
|
|
}
|
|
public function FenZhenQuXiao(){
|
|
$url = $this->baseUrl.'/in/drop_item.php';
|
|
$order_id=91;
|
|
$order_info= DB::table('user_orders')->where('id', $order_id)->first();
|
|
if(!!$order_info){
|
|
$create_ids=json_decode($order_info->fenzhen_create_ids, true);
|
|
$group_id= min($create_ids);
|
|
$array = array(
|
|
"group_id" => $group_id,
|
|
"ids"=> implode(',', $create_ids)
|
|
);
|
|
$res = self::post($url,$array,'Bearer password.123456');
|
|
$res=json_decode($res,true);
|
|
|
|
if($res['code']===200){
|
|
return response()->json(['code' => 0, 'msg' => '取消成功']);
|
|
}else{
|
|
return response()->json(['code' => -1, 'msg' => '远程调用失败']);
|
|
}
|
|
}
|
|
}
|
|
public static function post($url, $data,$Authorization='', $type = 'json')
|
|
{
|
|
$curl = curl_init();
|
|
curl_setopt($curl, CURLOPT_URL, $url);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($curl, CURLOPT_POST, true);
|
|
if ($type === 'data') {
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
|
}
|
|
if ($type === 'json') {
|
|
$data_string = json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
|
'Content-Type: application/json; charset=utf-8',
|
|
'Content-Length: ' . strlen($data_string),
|
|
'Authorization:'.$Authorization
|
|
]);
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
|
|
}
|
|
$r = curl_exec($curl);
|
|
curl_close($curl);
|
|
return $r;
|
|
}
|
|
}
|