|
|
|
@ -17,19 +17,25 @@ class OrderController extends Controller
|
|
|
|
$openid = $request->post('openid');
|
|
|
|
$openid = $request->post('openid');
|
|
|
|
$user = DB::table('web_users')->where(['openid' => $openid, 'is_del' => 0])->first();
|
|
|
|
$user = DB::table('web_users')->where(['openid' => $openid, 'is_del' => 0])->first();
|
|
|
|
if (!$user) return \Yz::echoError1("openid对应用户不存在");
|
|
|
|
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')
|
|
|
|
$OrderList = DB::table('orders')
|
|
|
|
->select('id', 'title', 'status', 'name', 'appointment_time as time', 'order_number as order',
|
|
|
|
->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"),
|
|
|
|
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')
|
|
|
|
'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');//支付等待時間
|
|
|
|
$WaitingPaymentTime = config('app.globals.WaitingPaymentTime');//支付等待時間
|
|
|
|
foreach ($OrderList as $key => $list) {
|
|
|
|
foreach ($OrderList as $key => $list) {
|
|
|
|
if ($list->status == 1) {
|
|
|
|
if ($list->status == 1) {
|
|
|
|
$datetime = new DateTime($list->created_at);
|
|
|
|
$datetime = new DateTime($list->created_at);
|
|
|
|
$timestamp = $datetime->getTimestamp();
|
|
|
|
$timestamp = $datetime->getTimestamp();
|
|
|
|
$list->end_time = $timestamp + (60 * $WaitingPaymentTime);
|
|
|
|
$list->end_time = $timestamp + (60 * $WaitingPaymentTime);
|
|
|
|
if(time() > $list->end_time){
|
|
|
|
if (time() > $list->end_time) {
|
|
|
|
$list->status=3;
|
|
|
|
$list->status = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -38,6 +44,7 @@ class OrderController extends Controller
|
|
|
|
'list' => $OrderList
|
|
|
|
'list' => $OrderList
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function GetDetail()
|
|
|
|
public function GetDetail()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$id = request('id');
|
|
|
|
$id = request('id');
|
|
|
|
@ -248,21 +255,21 @@ class OrderController extends Controller
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
if ($insert and $up_plan) {
|
|
|
|
if ($insert and $up_plan) {
|
|
|
|
DB::commit();
|
|
|
|
DB::commit();
|
|
|
|
$action=false;
|
|
|
|
$action = false;
|
|
|
|
if($true_price===0){
|
|
|
|
if ($true_price === 0) {
|
|
|
|
//如果是免费的,直接去预约
|
|
|
|
//如果是免费的,直接去预约
|
|
|
|
$yuyue= self::Finish($order_num);
|
|
|
|
$yuyue = self::Finish($order_num);
|
|
|
|
if($yuyue['status']===true){
|
|
|
|
if ($yuyue['status'] === true) {
|
|
|
|
return \Yz::return(true, "操作成功", ['action' => $action,'orderid'=>$insert]);
|
|
|
|
return \Yz::return(true, "操作成功", ['action' => $action, 'orderid' => $insert]);
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
return \Yz::echoError1($yuyue['msg']);
|
|
|
|
return \Yz::echoError1($yuyue['msg']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($true_price>0){
|
|
|
|
if ($true_price > 0) {
|
|
|
|
//如果大于0则提示前端去支付
|
|
|
|
//如果大于0则提示前端去支付
|
|
|
|
$action="pay";
|
|
|
|
$action = "pay";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return \Yz::return(true, "操作成功", ['action' => $action,'orderid'=>$insert]);
|
|
|
|
return \Yz::return(true, "操作成功", ['action' => $action, 'orderid' => $insert]);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
DB::rollBack();
|
|
|
|
DB::rollBack();
|
|
|
|
return \Yz::echoError1('操作失败');
|
|
|
|
return \Yz::echoError1('操作失败');
|
|
|
|
@ -293,7 +300,7 @@ class OrderController extends Controller
|
|
|
|
|
|
|
|
|
|
|
|
public function Finish_test() //删除!!!
|
|
|
|
public function Finish_test() //删除!!!
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$f=self::Finish('20240916154519911MbHwIE');
|
|
|
|
$f = self::Finish('20240916154519911MbHwIE');
|
|
|
|
dd($f);
|
|
|
|
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,
|
|
|
|
'status' => 2,
|
|
|
|
'pay_time' => date('Y-m-d H:i:s'),
|
|
|
|
'pay_time' => date('Y-m-d H:i:s'),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
//查询确认订单已经是支付状态
|
|
|
|
//查询确认订单已经是支付状态
|
|
|
|
$cha=DB::table('orders')->where(['order_number' => $order_number,'status'=>2])->first();
|
|
|
|
$cha = DB::table('orders')->where(['order_number' => $order_number, 'status' => 2])->first();
|
|
|
|
if(!$cha) return ['status' => false, 'msg' => "订单未支付,禁止预约"];
|
|
|
|
if (!$cha) return ['status' => false, 'msg' => "订单未支付,禁止预约"];
|
|
|
|
//把状态更新为支付后,然后再开始预约思信
|
|
|
|
//把状态更新为支付后,然后再开始预约思信
|
|
|
|
$create_appointment = self::create_appointment($order_info->hospital_id, $cad);
|
|
|
|
$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, [
|
|
|
|
$appointment_info = self::appointment_info($order_info->hospital_id, [
|
|
|
|
@ -370,12 +377,25 @@ class OrderController extends Controller
|
|
|
|
"电话号码" => null,
|
|
|
|
"电话号码" => null,
|
|
|
|
"预约Id" => $create_appointment['data'][0][0],
|
|
|
|
"预约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([
|
|
|
|
DB::table('orders')->where(['order_number' => $order_number])->update([
|
|
|
|
'appointment_number' => $create_appointment['data'][0][0],
|
|
|
|
'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' => "完成"];
|
|
|
|
return ['status' => true, 'msg' => "完成"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function create_appointment($hospital, $data)
|
|
|
|
public function create_appointment($hospital, $data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
@ -384,6 +404,7 @@ class OrderController extends Controller
|
|
|
|
$info = $peis::Post($url_code, $hospital, $data);
|
|
|
|
$info = $peis::Post($url_code, $hospital, $data);
|
|
|
|
return $info;
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function appointment_info($hospital, $data)
|
|
|
|
public function appointment_info($hospital, $data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
@ -392,6 +413,7 @@ class OrderController extends Controller
|
|
|
|
$info = $peis::Post($url_code, $hospital, $data);
|
|
|
|
$info = $peis::Post($url_code, $hospital, $data);
|
|
|
|
return $info;
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function cancel_appointment($hospital, $data)
|
|
|
|
public function cancel_appointment($hospital, $data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
|