|
|
|
|
@ -22,6 +22,12 @@ class OrderController extends Controller
|
|
|
|
|
// status 1-待支付 2-已预约 3-交易关闭 4-已完成 5-已退款
|
|
|
|
|
$openid = $request->post('openid');
|
|
|
|
|
$searchInfo = $request->post('searchInfo');
|
|
|
|
|
$page = $request->post('page');
|
|
|
|
|
if(isset($page)){
|
|
|
|
|
$page = intval($page);
|
|
|
|
|
}else{
|
|
|
|
|
$page = 1;
|
|
|
|
|
}
|
|
|
|
|
$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();
|
|
|
|
|
@ -43,7 +49,10 @@ class OrderController extends Controller
|
|
|
|
|
->orWhere(function ($query) use ($persons_sfz) {
|
|
|
|
|
$query->WhereIn('id_number', $persons_sfz)
|
|
|
|
|
->where('person_id', 0);
|
|
|
|
|
})->orderBy('id', 'desc')->get();
|
|
|
|
|
})->orderBy('id', 'desc') ->skip(($page - 1) * 100) // 跳过前9999条记录
|
|
|
|
|
->take(100)->get();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$WaitingPaymentTime = config('app.globals.WaitingPaymentTime');//支付等待時間
|
|
|
|
|
foreach ($OrderList as $key => $list) {
|
|
|
|
|
if ($list->status == 1) {
|
|
|
|
|
@ -148,7 +157,7 @@ class OrderController extends Controller
|
|
|
|
|
$sanfang_code=request('sanfang_code'); //第三方code
|
|
|
|
|
$yuyue_fangshi=request('yuyue_fangshi'); //预约方式 个检、团检、个检先选号源等,非必填
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$order_id= request('order_id');//如果是线下预约的,这里获取订单id,这种直接进行更新,不新建
|
|
|
|
|
$wj_flag = request('wj'); //问卷标记
|
|
|
|
|
if (isset($wj_flag) and $wj_flag == 1) {
|
|
|
|
|
$wj_zhekou = config('app.globals.Wj_ZheKou');//问卷过来的折扣率
|
|
|
|
|
@ -175,6 +184,14 @@ class OrderController extends Controller
|
|
|
|
|
if (!$user) return \Yz::echoError1('用户不存在');
|
|
|
|
|
$person = DB::table('web_user_person')->where(['id' => $person_id, 'is_del' => 0])->first();
|
|
|
|
|
if (!$person) return \Yz::echoError1('体检人不存在');
|
|
|
|
|
$do_type='insert';
|
|
|
|
|
if(isset($order_id)){
|
|
|
|
|
$order_info=DB::table('orders')->where(['id'=>$order_id])->first();
|
|
|
|
|
if (strpos($order_info->source, '线下体检预约') !== false){
|
|
|
|
|
$do_type='update';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$title = "自选项目";
|
|
|
|
|
$price = 0;
|
|
|
|
|
$quanInfo=false;
|
|
|
|
|
@ -409,10 +426,17 @@ class OrderController extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//检查号源是否可用
|
|
|
|
|
if($do_type=='update'){
|
|
|
|
|
//如果是线下预约的订单,则不进行号源检测
|
|
|
|
|
$plan = DB::table('plans')->where(['id' => $plan_id, 'hospital_id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
$plan = new PlanController();
|
|
|
|
|
$plan_check = $plan->CheckPlan($plan_id, $hospital_id, $type, $person->sex, $price, $checkup_type_id,$user->id);
|
|
|
|
|
if ($plan_check['status'] === false) return \Yz::echoError1($plan_check['msg']);
|
|
|
|
|
$plan = $plan_check['plan'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -584,11 +608,17 @@ class OrderController extends Controller
|
|
|
|
|
'paycheck_time'=>$now_datetime
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($do_type=='update'){
|
|
|
|
|
$insert = DB::table('orders')->where(['id'=>$order_id])->update($data);
|
|
|
|
|
$insert=$order_id;
|
|
|
|
|
$up_plan=true;
|
|
|
|
|
}else{
|
|
|
|
|
$insert = DB::table('orders')->insertGetId($data);
|
|
|
|
|
$up_plan = DB::table('plans')->where(['id' => $plan->id, 'status' => 1])->update([
|
|
|
|
|
'status' => 2
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新问卷log表
|
|
|
|
|
DB::table('questionnaires_logs')->where(['person_id' => $person->id, 'order_id' => 0])->update([
|
|
|
|
|
'order_id' => $insert,
|
|
|
|
|
@ -1047,7 +1077,7 @@ class OrderController extends Controller
|
|
|
|
|
|
|
|
|
|
public function Finish_test() //删除!!!
|
|
|
|
|
{
|
|
|
|
|
$f = self::Finish('20241030111035259T2IBC6');
|
|
|
|
|
$f = self::Finish('20250729122601478wq5l6d');
|
|
|
|
|
dd($f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1057,6 +1087,52 @@ class OrderController extends Controller
|
|
|
|
|
$AspNet=new AspNetZhuanController();
|
|
|
|
|
$order_info = DB::table('orders')->where(['order_number' => $order_number])->first();
|
|
|
|
|
if (!$order_info) return ['status' => false, 'msg' => "未找到有效订单。"];
|
|
|
|
|
|
|
|
|
|
//如果是线下预约完的订单,直接走思信修改信息接口
|
|
|
|
|
if(strpos($order_info->source, '线下体检预约') !== false){
|
|
|
|
|
$BuyInfo=json_decode($order_info->buy_info,true);
|
|
|
|
|
$items=[];
|
|
|
|
|
if(isset($BuyInfo['items']) and count($BuyInfo['items'])>0){
|
|
|
|
|
foreach($BuyInfo['items'] as $it){
|
|
|
|
|
$items[]=[
|
|
|
|
|
'Id'=>$it['id'],
|
|
|
|
|
'名称'=>$it['name'],
|
|
|
|
|
'原价'=>$it['price'],
|
|
|
|
|
'数量'=>1,
|
|
|
|
|
'价格'=>$it['price'],
|
|
|
|
|
'优惠方式'=>$it['youhui_fangshi'],
|
|
|
|
|
'优惠值'=>$it['youhui_zhi'],
|
|
|
|
|
'附加项目'=>true,
|
|
|
|
|
'收费方式'=>'自费',
|
|
|
|
|
'已收费'=>$order_info->status==2,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$peis = new PEISApiController();
|
|
|
|
|
$res=$peis::Post('个检预约设置套餐和项目信息', $order_info->hospital_id, [
|
|
|
|
|
'预约Id' => $order_info->appointment_number,
|
|
|
|
|
'已收费' => $order_info->status==2,
|
|
|
|
|
'套餐Id' => $order_info->combo_id==0?null:$order_info->combo_id,
|
|
|
|
|
'项目列表' => $items,
|
|
|
|
|
]);
|
|
|
|
|
if($res['message']=='设置成功'){
|
|
|
|
|
//预约完成后查询预约结果
|
|
|
|
|
$appointment_info = self::appointment_info($order_info->hospital_id, [
|
|
|
|
|
'type' => 1,
|
|
|
|
|
"证件号码" => null,
|
|
|
|
|
"电话号码" => null,
|
|
|
|
|
"预约Id" => $order_info->appointment_number,
|
|
|
|
|
]);
|
|
|
|
|
$u = DB::table('orders')->where(['id' => $order_info->id])->update([
|
|
|
|
|
'appointment_back_info' => json_encode($appointment_info['data'][0], JSON_UNESCAPED_UNICODE),
|
|
|
|
|
]);
|
|
|
|
|
return ['status' => true, 'msg' => "完成"];
|
|
|
|
|
}else{
|
|
|
|
|
return ['status' => false, 'msg' => "操作失败"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$person=DB::table('web_user_person')->where(['id' => $order_info->person_id])->first();
|
|
|
|
|
if(!$person) return ['status' => false, 'msg' => "体检人信息无效。"];
|
|
|
|
|
$yyid=6;
|
|
|
|
|
@ -1321,7 +1397,12 @@ class OrderController extends Controller
|
|
|
|
|
//未支付取消订单
|
|
|
|
|
public function Cancel()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$order_number=request('order_number');
|
|
|
|
|
$orderInfo = DB::table('orders')->where(['order_number' => $order_number,'status'=>1])->first();
|
|
|
|
|
if (!$orderInfo) return \Yz::echoErrorJson('未找到有效订单');
|
|
|
|
|
$do = new OrderService();
|
|
|
|
|
$do->Cancel($orderInfo);
|
|
|
|
|
return \Yz::Return(true,"取消完成",['order_id'=>$orderInfo->id]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//批量取消订单
|
|
|
|
|
|