where('id',$id)->first(); if(!$order) return ['status'=>false,'msg'=>'订单不存在']; $hospital=DB::table('hospitals')->where('id',$order->hospital_id)->first(); if(!$hospital) return ['status'=>false,'msg'=>'医院不存在']; $wait_day=false; $is_checked_sign_in=false; if(isset($order->tj_number) and !empty($order->tj_number)){ $peis = new PEISApiController(); $wait=$peis::Get($peis::Api('报告时间计算',$order->tj_number),$hospital->code,"报告时间计算"); if(isset($wait['Data'][0]['预计所需天数'])){ $wait_day=$wait['Data'][0]['预计所需天数']; } else { $wait_day=-1; //查询体检报告 $data = [ '电话号码' => "", '证件号码' => "", '体检号' => $order->tj_number, '包含内部信息' => true ]; $res = $peis::Post('体检报告查询', $order->hospital_id, $data); if(count($res['data']) > 0) { $res = $res['data'][0]; if (isset($res['收费项目列表'])) { foreach ($res['收费项目列表'] as $it) { if($it['项目状态']=='未完成'){ $is_checked_sign_in=false; break; }else{ $is_checked_sign_in=true; } } } } } } $buy_info=json_decode($order->buy_info,true); $list=[]; $drop_ids = ['519', '603']; if($buy_info['combo']['id']<>0){ $combo_items=DB::table('combo_items')->where(['combo_id'=>$buy_info['combo']['id'],'status'=>1])->get(); foreach($combo_items as $item){ if(!in_array((string)$item->keshi_id,$drop_ids)){ $list[]=[ 'item_id'=>$item->item_id, 'keshi_name'=>$item->keshi_name, 'keshi_id'=>$item->keshi_id, ]; } } } if(count($buy_info['items'])>0){ $item_ids=[]; foreach($buy_info['items'] as $item){ $item_ids[]=$item['id']; } $itemsInfo=DB::table('items')->whereIn('item_id',$item_ids)->get(); foreach($itemsInfo as $item){ $list[]=[ 'item_id'=>$item->item_id, 'keshi_name'=>$item->keshi_name, 'keshi_id'=>$item->keshi_id, ]; } } if($buy_info['group']['id']<>''){ $item_ids=[]; foreach($buy_info['group']['items'] as $item){ $item_ids[]=$item['id']; } $itemsInfo=DB::table('items')->whereIn('item_id',$item_ids)->get(); foreach($itemsInfo as $item){ $list[]=[ 'item_id'=>$item->item_id, 'keshi_name'=>$item->keshi_name, 'keshi_id'=>$item->keshi_id, ]; } } $groupedData = []; foreach ($list as $key => $item) { $keshiName = $item['keshi_name']; if (!isset($groupedData[$keshiName])) { $groupedData[$keshiName] = []; } $groupedData[$keshiName][] = $item; } $de_list=[]; foreach ($groupedData as $key => $item) { $de_list[]=[ 'name'=>$key, 'keshi_id'=>$item[0]['keshi_id'], 'count'=>count($item), ]; } return ['department_list'=>$de_list,'wait_day'=>$wait_day,'is_checked_sign_in'=>$is_checked_sign_in]; } public function Cancel($orderInfo) { $person=DB::table('web_user_person')->where(['id' => $orderInfo->person_id])->first(); $now_datetime=date('Y-m-d H:i:s'); //调用接口恢复积分和预存款 $env=config('app.globals.Env'); $AspNet=new AspNetZhuanController(); $jifen_huifu_status=true; $yucunkuan_huifu_status=true; $r_yyid=$orderInfo->hospital_id; if($r_yyid==1){ $yyid=6; } if($r_yyid==4){ $yyid=2; } if($env=='pro') { //如果是正式环境 //如果有二线取消二线 $AspNet=new AspNetZhuanController(); $erxian_info=json_decode($orderInfo->erxian_appointment_info, true); if (isset($erxian_info) and !empty($erxian_info)) { foreach ($erxian_info as $key => $plan_nmr) { if(isset($plan_nmr['gid'])){ //调用接口校验号源是否可用 $erxian_status = $AspNet::ErXian(['id' =>$plan_nmr['gid'], 'yyid' => $yyid, 'action' => 3], uniqid()); $erxian_info[$key]['gid']=''; $ex_u= DB::table('orders')->where(['id' => $orderInfo->id])->update([ 'erxian_appointment_info'=>json_encode($erxian_info, JSON_UNESCAPED_UNICODE), ]); } } } if($orderInfo->jifen>0 and $orderInfo->is_refund_jifen==0) { $jifen_huifu_status=false; $jifen_huifu_status= $AspNet::UseJiFen($person->ghzid,$orderInfo->jifen,$yyid,$orderInfo->id,'tj_h5','抵扣体检H5订单',$now_datetime); if( $jifen_huifu_status===true){ DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_jifen'=>1]); } } if($orderInfo->yucunkuan>0 and $orderInfo->is_refund_yucunkuan==0) { $yucunkuan_huifu_status=false; $yucunkuan_huifu_status= $AspNet::UseYuCunKuan($person->ghzid,$orderInfo->yucunkuan,$yyid,0,$orderInfo->id,'tj_h5','抵扣体检H5订单',$now_datetime); if($yucunkuan_huifu_status===true){ DB::table('orders')->where('id',$orderInfo->id)->update(['is_refund_yucunkuan'=>1]); } } if(!empty($orderInfo->youhuiquan)){ $youhuiquan=json_decode( $orderInfo->youhuiquan,true); $data=[ 'action'=>4, 'ghzid'=>$person->ghzid, 'dzjid'=>$youhuiquan['id'], 'hxbz'=>"H5撤销核销", 'yyid'=>$yyid ]; $AspNet::YouHuiQuan($data); } } DB::table('orders')->where(['id' => $orderInfo->id,'status'=>1])->update([ 'status' => 3 ]); //恢复号源 $up_plan = DB::table('plans')->where(['id' => $orderInfo->plan_id, 'status' => 2])->update([ 'status' => 1 ]); return true; } }