给小程序提供查询接口 ,对接跳转

main
yanzai 3 months ago
parent b5d5dc905d
commit c911b93a52

@ -59,6 +59,7 @@ class OrderController extends Controller
$WaitingPaymentTime = config('app.globals.WaitingPaymentTime');//支付等待時間
$DaiBanCountArr=[0,0,0,0];
foreach ($OrderList as $key => $list) {
if ($list->status == 1) {
$datetime = new DateTime($list->created_at);
@ -68,6 +69,15 @@ class OrderController extends Controller
$list->status = 3;
}
}
if ($list->status == 1) {//待支付
$DaiBanCountArr[0]++;
}
if($list->status == 2 and empty($list->appointment_number)){ //待预约
$DaiBanCountArr[1]++;
}
if($list->status == 2 and !empty($list->appointment_number)){ //进行中
$DaiBanCountArr[2]++;
}
if($list->checkup_type_id==4 and $list->status==2 and $list->hunjian_status==0 and !empty($list->appointment_number)){
//查询配偶是否预约
$buy_info=json_decode($list->buy_info,true);
@ -87,7 +97,8 @@ class OrderController extends Controller
}
return \Yz::Return(true, '获取成功', [
'list' => $OrderList
'list' => $OrderList,
'DaiBanCountArr'=>$DaiBanCountArr
]);
}
//查询某个人的预约记录

@ -4,6 +4,7 @@ namespace App\Http\Controllers\API\Internal;
use App\Http\Controllers\API\PEISApiController;
use App\Http\Controllers\Controller;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@ -240,5 +241,161 @@ class OrderController extends Controller
return \Yz::echoErrorJson("未获取到预约信息");
}
}
//给三方(非思信)提供的查询订单列表接口
public function GetOrderList()
{
// $openid = request('openid');
// $ghzid = request('ghzid');
// $date_range = request('date_range');
// $status = request('status');
$encrypted_data = request('encrypted_data');
$iv = request('iv');
if (!isset($iv)) return \Yz::echoError1('加密时使用的iv不能为空');
$encrypted_data = \App\Lib\Tools::AESDecrypt($encrypted_data, config('app.globals.AES_KEY'), $iv);
if (!$encrypted_data) return \Yz::echoError1('encrypted_data解密失败');
$encrypted_data = json_decode($encrypted_data, true);
if (!isset($encrypted_data['openid'])) return \Yz::echoError1('openid不能为空');
$openid = $encrypted_data['openid'];
if (!isset($encrypted_data['ghzid'])) return \Yz::echoError1('ghzid不能为空');
$ghzid = $encrypted_data['ghzid'];
// if (!isset($encrypted_data['date_range'])) return \Yz::echoError1('date_range不能为空');
$date_range = isset($encrypted_data['date_range'])?$encrypted_data['date_range']:null;
$status =isset($encrypted_data['status'])? $encrypted_data['status']:null;
$encrypt_iv = bin2hex(random_bytes(16 / 2));
if (!isset($ghzid)) return \Yz::echoError1("ghzid不能为空");
$user = DB::table('web_users')->where(['openid' => $openid, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1("openid对应用户不存在");
$persons_sfz = DB::table('web_user_person')->where(['ghzid' => $ghzid, 'is_del' => 0])->first();
// $where=['web_user_id' => $user->id];
$OrderList = DB::table('orders');
$OrderList=$OrderList
->select('id', 'source','title','person_id','checkup_type_id','status','sex', 'name','appointment_number','appointment_date as date', 'appointment_time as time',
DB::raw("CASE WHEN type = 1 THEN '个检' WHEN type = 2 THEN '团检' ELSE 'unknown' END as type"),
'plan_number','price', 'true_price', 'pay_time', 'refund_time', 'hospital_id','doctor','created_at');
if(isset($status)){
if($status==1){
$OrderList=$OrderList->where('status',1);
}
if($status==2){
$OrderList=$OrderList->where('status',2)
->whereNull('appointment_number');
}
if($status==3){
$OrderList=$OrderList->where('status',2)
->whereNotNull('appointment_number');
}
}
if(is_array($date_range) and count($date_range)==2){
$OrderList=$OrderList ->whereBetween('created_at', [$date_range[0], $date_range[1].' 23:59:59']);
}
$OrderList=$OrderList ->where(function ($query) use ($persons_sfz,$user) {
$query->where('web_user_id', $user->id)
->orWhere(function ($q) use ($persons_sfz) {
$q->where('id_number', $persons_sfz->id_number)
->where('person_id', 0);
});
})->orderBy('id', 'desc')->get();
$WaitingPaymentTime = config('app.globals.WaitingPaymentTime');//支付等待時間
foreach ($OrderList as $key => $list) {
if($list->hospital_id==1){
$list->yuanqu_id=6;
}
if($list->hospital_id==4){
$list->yuanqu_id=2;
}
$list->keshiname="健康管理中心";
$list->jiuzhendidian="健康管理中心1区";
if($list->sex==1) $list->jiuzhendidian="健康管理中心1楼男宾区";
if($list->sex==2) $list->jiuzhendidian="健康管理中心2楼女宾区";
$list->zhuyishixiang="";
if ($list->status == 1) {
$datetime = new DateTime($list->created_at);
$timestamp = $datetime->getTimestamp();
$list->end_time = $timestamp + (60 * $WaitingPaymentTime);
if (time() > $list->end_time and strpos($list->source, '线下体检预约') === false) {
$list->status = 3;
}
}
if($list->checkup_type_id==4 and $list->status==2 and $list->hunjian_status==0 and !empty($list->appointment_number)){
//查询配偶是否预约
$buy_info=json_decode($list->buy_info,true);
if(isset($buy_info['peiou_info']['sfz'])){
$peiou_check= DB::select("select * from orders where id_number=?
and checkup_type_id = 4
and status in(2,4)
and appointment_number is not null
", [$buy_info['peiou_info']['sfz']]);
if(count($peiou_check)==0){
$datetime = new DateTime($list->created_at);
$timestamp = $datetime->getTimestamp();
$list->end_time = $timestamp + (60 * config('app.globals.WaitingHunJianPeiOuTime'));
}
}
}
}
$info_data = [
'list' => $OrderList
];
$info_data = json_encode($info_data, JSON_UNESCAPED_UNICODE);
return \Yz::Return(true,'查询成功',['info' =>$this->AESEncrypt($info_data, $encrypt_iv) , 'iv' => $encrypt_iv]);
}
//给三方(非思信)提供的查询订单详情
public function GetOrderDetail()
{
$encrypted_data = request('encrypted_data');
$iv = request('iv');
if (!isset($iv)) return \Yz::echoError1('加密时使用的iv不能为空');
$encrypted_data = \App\Lib\Tools::AESDecrypt($encrypted_data, config('app.globals.AES_KEY'), $iv);
if (!$encrypted_data) return \Yz::echoError1('encrypted_data解密失败');
$encrypted_data = json_decode($encrypted_data, true);
if (!isset($encrypted_data['order_id'])) return \Yz::echoError1('order_id不能为空');
$order_id = $encrypted_data['order_id'];
$order = DB::table('orders')
->select('id', 'source','title','person_id','checkup_type_id','status','sex', 'name','appointment_number','appointment_date as date', 'appointment_time as time',
DB::raw("CASE WHEN type = 1 THEN '个检' WHEN type = 2 THEN '团检' ELSE 'unknown' END as type"),
'plan_number','price', 'true_price', 'pay_time', 'refund_time', 'hospital_id','doctor','created_at')
->where(['id' => $order_id])->first();
if (!$order) return \Yz::echoError1('订单不存在');
if($order->hospital_id==1){
$order->yuanqu_id=6;
}
if($order->hospital_id==4){
$order->yuanqu_id=2;
}
$order->keshiname="健康管理中心";
$order->jiuzhendidian="健康管理中心1区";
if($order->sex==1) $order->jiuzhendidian="健康管理中心1楼男宾区";
if($order->sex==2) $order->jiuzhendidian="健康管理中心2楼女宾区";
$order->zhuyishixiang="";
$encrypt_iv = bin2hex(random_bytes(16 / 2));
$info_data = json_encode($order, JSON_UNESCAPED_UNICODE);
return \Yz::Return(true,'查询成功',['info' =>$this->AESEncrypt($info_data, $encrypt_iv) , 'iv' => $encrypt_iv]);
}
function AESEncrypt($data, $encrypt_iv)
{
// return $data;
return \App\Lib\Tools::AESEncrypt($data, config('app.globals.AES_KEY'), $encrypt_iv);
}
}

@ -150,6 +150,31 @@ class Tools
self::$request = new \App\Models\PEISLog();
self::$request->setTable($table_name);
}
public static function AESEncrypt($data, $key,$iv){
// 使用openssl_encrypt进行加密
$encryptedData = openssl_encrypt(
$data,
'AES-256-CBC',
$key,
OPENSSL_RAW_DATA,
$iv
);
// 返回包含IV的加密数据通常会将IV放在加密数据之前
return base64_encode( $encryptedData);
}
//AES解密
public static function AESDecrypt($data, $key,$iv){
// 解码base64编码的数据
$data = base64_decode($data);
$encryptedData = $data;
// 使用openssl_decrypt进行解密
return openssl_decrypt(
$encryptedData,
'AES-256-CBC',
$key,
OPENSSL_RAW_DATA,
$iv
);
}
}

@ -15,7 +15,8 @@ return [
'erxian_kuadu'=>3,//二线时间跨度,单位天
'plan_lock_time'=>10,//先选号源,号源锁定时长,超过时长未预约 进行释放,单位分钟
'KeShiPaiXu'=>["预检咨询","体格检查","人体成分","呼气试验","采血室(化验)","内科","妇科","妇科(化验)","妇科(病理)","婚前医学检查","外科","外科(化验)","眼科","耳鼻喉科","肺功能室","口腔科","超声科","骨密度室","CT室","影像科","住院体检","胃肠镜室"],
'KeShiTypePaiXu'=>["预检","检查","检验","病理","超声","影像"]
'KeShiTypePaiXu'=>["预检","检查","检验","病理","超声","影像"],
'AES_KEY'=>'7Kj9P1pL0f8e7Vw3I2qX4mP6zJ1OxWcQ',
],
/*

@ -142,3 +142,6 @@ Route::any('/GetTransferCode', 'App\Http\Controllers\API\Internal\TransferCodeCo
Route::any('/HandleTransferCode', 'App\Http\Controllers\API\Internal\TransferCodeController@HandleTransferCode')->middleware('log');//查询转赠码
Route::post('/UnLockPlan', 'App\Http\Controllers\API\H5\PlanController@UnLockPlan')->middleware('log');//解锁号源
Route::any('T/GetOrderList', 'App\Http\Controllers\API\Internal\OrderController@GetOrderList')->middleware('log');//给三方接口,查询订单列表
Route::any('T/GetOrderDetail', 'App\Http\Controllers\API\Internal\OrderController@GetOrderDetail')->middleware('log');//给三方接口,查询订单列表

Loading…
Cancel
Save