订单关联web端用户,支付后调用预约时段修改,传医生名称

wenjuan
yanzai 1 year ago
parent d8070b37f2
commit cce06f3d6a

@ -17,19 +17,25 @@ class OrderController extends Controller
$openid = $request->post('openid');
$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(['user_id' => $user->id,'is_del'=>0])->pluck('id_number')->toArray();
$OrderList = DB::table('orders')
->select('id', 'title', 'status', 'name', 'appointment_time as time', 'order_number as order',
DB::raw("CASE WHEN type = 1 THEN '个检' WHEN type = 2 THEN '团检' ELSE 'unknown' END as type"),
'price', 'true_price', 'pay_time', 'refund_time', 'created_at')
->where(['web_user_id' => $user->id])->get();
->where(['web_user_id' => $user->id])
->orWhere(function($query) use ($persons_sfz) {
$query->WhereIn('id_number', $persons_sfz)
->where('person_id', 0);
})->get();
$WaitingPaymentTime = config('app.globals.WaitingPaymentTime');//支付等待時間
foreach ($OrderList as $key => $list) {
if ($list->status == 1) {
$datetime = new DateTime($list->created_at);
$timestamp = $datetime->getTimestamp();
$list->end_time = $timestamp + (60 * $WaitingPaymentTime);
if(time() > $list->end_time){
$list->status=3;
if (time() > $list->end_time) {
$list->status = 3;
}
}
}
@ -38,6 +44,7 @@ class OrderController extends Controller
'list' => $OrderList
]);
}
public function GetDetail()
{
$id = request('id');
@ -248,21 +255,21 @@ class OrderController extends Controller
]);
if ($insert and $up_plan) {
DB::commit();
$action=false;
if($true_price===0){
$action = false;
if ($true_price === 0) {
//如果是免费的,直接去预约
$yuyue= self::Finish($order_num);
if($yuyue['status']===true){
return \Yz::return(true, "操作成功", ['action' => $action,'orderid'=>$insert]);
}else{
$yuyue = self::Finish($order_num);
if ($yuyue['status'] === true) {
return \Yz::return(true, "操作成功", ['action' => $action, 'orderid' => $insert]);
} else {
return \Yz::echoError1($yuyue['msg']);
}
}
if($true_price>0){
if ($true_price > 0) {
//如果大于0则提示前端去支付
$action="pay";
$action = "pay";
}
return \Yz::return(true, "操作成功", ['action' => $action,'orderid'=>$insert]);
return \Yz::return(true, "操作成功", ['action' => $action, 'orderid' => $insert]);
} else {
DB::rollBack();
return \Yz::echoError1('操作失败');
@ -293,7 +300,7 @@ class OrderController extends Controller
public function Finish_test() //删除!!!
{
$f=self::Finish('20240916154519911MbHwIE');
$f = self::Finish('20240916154519911MbHwIE');
dd($f);
}
@ -351,17 +358,17 @@ class OrderController extends Controller
];
}
//如果是 如果订单未支付 在这里更新订单状态为已支付。
DB::table('orders')->where(['order_number' => $order_number,'status'=>1])->update([
DB::table('orders')->where(['order_number' => $order_number, 'status' => 1])->update([
'status' => 2,
'pay_time' => date('Y-m-d H:i:s'),
]);
//查询确认订单已经是支付状态
$cha=DB::table('orders')->where(['order_number' => $order_number,'status'=>2])->first();
if(!$cha) return ['status' => false, 'msg' => "订单未支付,禁止预约"];
$cha = DB::table('orders')->where(['order_number' => $order_number, 'status' => 2])->first();
if (!$cha) return ['status' => false, 'msg' => "订单未支付,禁止预约"];
//把状态更新为支付后,然后再开始预约思信
$create_appointment = self::create_appointment($order_info->hospital_id, $cad);
if(!isset($create_appointment['data'][0][0])) return ['status' => false, 'msg' => "体检预约,返回非预期结果"];
if (!isset($create_appointment['data'][0][0])) return ['status' => false, 'msg' => "体检预约,返回非预期结果"];
//预约完成后查询预约结果
$appointment_info = self::appointment_info($order_info->hospital_id, [
@ -370,12 +377,25 @@ class OrderController extends Controller
"电话号码" => null,
"预约Id" => $create_appointment['data'][0][0],
]);
//如果是医生web端预约则调用预约时段修改接口传入医生名称
if ($order_info->source == 'web') {
$peis = new PEISApiController();
$dat = [
"预约Id" => $create_appointment['data'][0][0],
"预约开始时间" => $order_info->appointment_date . ' ' . $order_info->appointment_time,
"预约截止时间" => $order_info->appointment_date . ' ' . $order_info->appointment_time,
"AppDoctor" => $order_info->appdoctor
];
$info = $peis::Post('预约时段修改', $order_info->hospital_id,$dat);
}
DB::table('orders')->where(['order_number' => $order_number])->update([
'appointment_number' => $create_appointment['data'][0][0],
'appointment_back_info'=> json_encode($appointment_info['data'][0], JSON_UNESCAPED_UNICODE)
'appointment_back_info' => json_encode($appointment_info['data'][0], JSON_UNESCAPED_UNICODE)
]);
return ['status' => true, 'msg' => "完成"];
}
public function create_appointment($hospital, $data)
{
$peis = new PEISApiController();
@ -384,6 +404,7 @@ class OrderController extends Controller
$info = $peis::Post($url_code, $hospital, $data);
return $info;
}
public function appointment_info($hospital, $data)
{
$peis = new PEISApiController();
@ -392,6 +413,7 @@ class OrderController extends Controller
$info = $peis::Post($url_code, $hospital, $data);
return $info;
}
public function cancel_appointment($hospital, $data)
{
$peis = new PEISApiController();

@ -28,7 +28,7 @@ class PEISApiController extends Controller
$api['团检预约查询'] = "{$url}/PEISCommon/QueryUnitAppointment/{$code}";
$api['团检预约取消'] = "{$url}/PEISCommon/CancelUnitAppointment/{$code}";
$api['体检报告查询'] = "{$url}/PEISCommon/QueryExamReport/{$code}";
$api['预约时段修改'] = "{$url}/PEISCommon/ModifyAppointmentDTRange/{$code}";
return $api["{$url_code}"] ?? $url_code;
}

Loading…
Cancel
Save