diff --git a/Laravel/app/Http/Controllers/API/Internal/OrderController.php b/Laravel/app/Http/Controllers/API/Internal/OrderController.php index 226d67b..4569de7 100644 --- a/Laravel/app/Http/Controllers/API/Internal/OrderController.php +++ b/Laravel/app/Http/Controllers/API/Internal/OrderController.php @@ -136,13 +136,13 @@ class OrderController extends Controller public function GetH5Order() { $appointment_number = request('appointment_number');//思信预约完成后的id - if (!isset($appointment_number) || empty($appointment_number)) return \Yz::echoError1('预约id 不能为空'); + if (!isset($appointment_number) || empty($appointment_number)) return \Yz::echoErrorJson('预约id 不能为空'); $order_info = DB::table('orders')->where(['appointment_number' => $appointment_number, 'status' => 2, 'check_status' => 1])->first(); if (!!$order_info) { $order_info->buy_info = json_decode($order_info->buy_info, true); $order_info->erxian_appointment_info = json_decode($order_info->erxian_appointment_info, true); } else { - return \Yz::echoError1('未找到有效订单'); + return \Yz::echoErrorJson('未找到有效订单'); } return \Yz::Return(true, '获取成功', [ 'info' => $order_info @@ -242,6 +242,15 @@ class OrderController extends Controller return \Yz::echoErrorJson("未获取到预约信息"); } } + function XingDianNull($msg) + { + $encrypt_iv = bin2hex(random_bytes(16 / 2)); + $info_data = [ + 'list' => [] + ]; + $info_data = json_encode($info_data, JSON_UNESCAPED_UNICODE); + return \Yz::Return(true,$msg,['info' =>$this->AESEncrypt($info_data, $encrypt_iv) , 'iv' => $encrypt_iv]); + } //给三方(非思信)提供的查询订单列表接口 public function GetOrderList() { @@ -252,29 +261,29 @@ class OrderController extends Controller $encrypted_data = request('encrypted_data'); $iv = request('iv'); - if (!isset($iv)) return \Yz::echoError1('加密时使用的iv不能为空'); + if (!isset($iv)) return $this->XingDianNull('加密时使用的iv不能为空'); $encrypted_data = \App\Lib\Tools::AESDecrypt($encrypted_data, config('app.globals.AES_KEY'), $iv); - if (!$encrypted_data) return \Yz::echoError1('encrypted_data解密失败'); + if (!$encrypted_data) return $this->XingDianNull('encrypted_data解密失败'); $encrypted_data = json_decode($encrypted_data, true); - if (!isset($encrypted_data['openid'])) return \Yz::echoError1('openid不能为空'); + if (!isset($encrypted_data['openid'])) return $this->XingDianNull('openid不能为空'); $openid = $encrypted_data['openid']; - if (!isset($encrypted_data['ghzid'])) return \Yz::echoError1('ghzid不能为空'); + if (!isset($encrypted_data['ghzid'])) return $this->XingDianNull('ghzid不能为空'); $ghzid = $encrypted_data['ghzid']; - // if (!isset($encrypted_data['date_range'])) return \Yz::echoError1('date_range不能为空'); + // if (!isset($encrypted_data['date_range'])) return $this->XingDianNull('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不能为空"); + if (!isset($ghzid)) return $this->XingDianNull("ghzid不能为空"); $user = DB::table('web_users')->where(['openid' => $openid, 'is_del' => 0])->first(); - if (!$user) return \Yz::echoError1("openid对应用户不存在"); + if (!$user) return $this->XingDianNull("openid对应用户不存在"); $persons_sfz = DB::table('web_user_person')->where(['ghzid' => $ghzid, 'is_del' => 0])->first(); // $where=['web_user_id' => $user->id]; - if(!$persons_sfz) return \Yz::echoError1("ghzid对应用户不存在,ghzid:".$ghzid); + if(!$persons_sfz) return $this->XingDianNull("ghzid对应用户不存在,ghzid:".$ghzid); $OrderList = DB::table('orders'); @@ -356,7 +365,7 @@ class OrderController extends Controller } } $info_data = [ - 'list' => $OrderList + 'list' => count($OrderList)===0?[]:$OrderList ]; $info_data = json_encode($info_data, JSON_UNESCAPED_UNICODE); return \Yz::Return(true,'查询成功',['info' =>$this->AESEncrypt($info_data, $encrypt_iv) , 'iv' => $encrypt_iv]); @@ -367,19 +376,19 @@ class OrderController extends Controller { $encrypted_data = request('encrypted_data'); $iv = request('iv'); - if (!isset($iv)) return \Yz::echoError1('加密时使用的iv不能为空'); + if (!isset($iv)) return \Yz::echoErrorJson('加密时使用的iv不能为空'); $encrypted_data = \App\Lib\Tools::AESDecrypt($encrypted_data, config('app.globals.AES_KEY'), $iv); - if (!$encrypted_data) return \Yz::echoError1('encrypted_data解密失败'); + if (!$encrypted_data) return \Yz::echoErrorJson('encrypted_data解密失败'); $encrypted_data = json_decode($encrypted_data, true); - if (!isset($encrypted_data['order_id'])) return \Yz::echoError1('order_id不能为空'); + if (!isset($encrypted_data['order_id'])) return \Yz::echoErrorJson('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) return \Yz::echoErrorJson('订单不存在'); if($order->hospital_id==1){ $order->yuanqu_id=6;