对接思信预约登记

wenjuan
yanzai 1 year ago
parent 35c13b4c3f
commit f68ae46188

@ -117,7 +117,7 @@ class OrderController extends Controller
if (!$person) return \Yz::echoError1('体检人不存在');
$title = "自选项目";
$price = 0;
$true_price=0;//订单真实支付金额
$true_price = 0;//订单真实支付金额
$buy_info = [
'combo' => [
'id' => 0,
@ -130,12 +130,12 @@ class OrderController extends Controller
],
];
//如果是套餐
$checkup_type_id=false; //体检类型id
$checkup_type_id = false; //体检类型id
if (isset($combo_id) and $combo_id <> 0) {
$combo_info = DB::table('combos')->where(['combo_id' => $combo_id, 'status' => 1])->first();
if (!$combo_info) return \Yz::echoError1("套餐不存在");
if(!isset($combo_info->checkup_type_id)) return \Yz::echoError1("套餐未关联体检类型");
$checkup_type_id=$combo_info->checkup_type_id;
if (!isset($combo_info->checkup_type_id)) return \Yz::echoError1("套餐未关联体检类型");
$checkup_type_id = $combo_info->checkup_type_id;
$price += $combo_info->price;
$title = $combo_info->name;
$buy_info['combo'] = [
@ -162,7 +162,7 @@ class OrderController extends Controller
$missingIds = array_diff($item_ids, $existingIds);
if (count($missingIds) > 0) return \Yz::echoError1("部分自选项目不可用Id:" . implode(', ', $missingIds));
}
$true_price=$price;
$true_price = $price;
//如果是团检
$group_info = false;
if ($type == 2) {
@ -184,7 +184,10 @@ class OrderController extends Controller
];
$title = "单位团检" . $group_info['combo_name'];
$price = $price + $group_info['sixi_zong_ji_jin_e'];
$true_price = ($price - $group_info['tongshou_xiane']) > 0 ? $price - $group_info['tongshou_xiane'] : 0;
$need_pay = ($price - $group_info['tongshou_xiane']) > 0 ? $price - $group_info['tongshou_xiane'] : 0;
//团检订单金额为减去统收后的金的
$price = $need_pay;
$true_price = $need_pay;
}
//调用思信接口判断各个项目是否可用
@ -210,9 +213,9 @@ class OrderController extends Controller
//检查号源是否可用
$plan = new PlanController();
$plan_check = $plan->CheckPlan($plan_id, $hospital_id, $type, $person->sex,$price,$checkup_type_id);
$plan_check = $plan->CheckPlan($plan_id, $hospital_id, $type, $person->sex, $price, $checkup_type_id);
if ($plan_check['status'] === false) return \Yz::echoError1($plan_check['msg']);
$plan=$plan_check['plan'];
$plan = $plan_check['plan'];
//判断号源是否可用vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// $plan = DB::table('plans')->where(['id' => $plan_id, 'hospital_id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
@ -310,4 +313,72 @@ class OrderController extends Controller
$check = $peis::Post('套餐项目检查', $hospital, $data);
return $check;
}
public function Finish_test() //删除!!!
{
self::Finish('20240915183440999WMp2yu');
}
//最后步骤,开始通知思信预约
public function Finish($order_number)
{
$order_info = DB::table('orders')->where(['order_number' => $order_number, 'status' => 1])->first();
if (!$order_info) return ['status' => false, 'msg' => "未找到有效订单"];
$buy_info = json_decode($order_info->buy_info, true);
$combo_id = $buy_info['combo']['id'];
$item_arr = [];
foreach ($buy_info['items'] as $item) {
$item_arr[] = ['Id' => $item['id'], '已收费' => true];
}
//调用思信 套餐项目检查
if ((isset($combo_id) and $combo_id <> 0) || count($item_arr) != 0) {
$item_check = self::item_check($order_info->hospital_id, [
'人员信息列表' => [[
"序号" => 0,
"性别" => $order_info->sex == 1 ? '男' : '女',
"年龄" => floor((time() - strtotime($order_info->birthday)) / 86400 / 360),
"婚姻状态" => $order_info->married == 1 ? '已婚' : '未婚',
]],
'套餐Id' => $combo_id == 0 ? null : $combo_id,
'可选项目信息' => $item_arr,
]);
if (count($item_check['data']) != 1) {
return \Yz::echoError1("体检系统提示:" . $item_check['message']);
}
}
//如果是个检
if ($order_info->type == 1) {
$cad = [
'type' => 1,
"姓名" => $order_info->name,
"性别" => $order_info->sex == 1 ? '男' : '女',
"年龄" => floor((time() - strtotime($order_info->birthday)) / 86400 / 360),
"婚姻状态" => $order_info->married == 1 ? '已婚' : '未婚',
"证件号码" => $order_info->id_number,
"电话号码" => $order_info->phone,
"预约时间" => $order_info->appointment_date . ' ' . $order_info->appointment_time,
"介绍人" => $order_info->referral,
'套餐Id' => $order_info->combo_id == 0 ? null : $order_info->combo_id,
"可选项目信息" => $item_arr,
"已收费" => true,
"总计金额" => $order_info->price,
];
} else {
$cad = [
'type' => 2,
"预约Id" => $buy_info['group']['group_id'],
"预约时间" => $order_info->appointment_date . ' ' . $order_info->appointment_time,
'套餐Id' => null,
"可选项目信息" => $item_arr
];
}
//更新订单状态为已支付, 支付流水号在 上一步(方法)更新,
DB::table('orders')->where(['order_number' => $order_number])->update([
'status' => 2,
'pay_time' => date('Y-m-d H:i:s'),
]);
//先把状态更新为支付,然后再开始预约思信
}
}

@ -57,6 +57,10 @@ Route::group(['prefix' => 'api/H5'], function () {
Route::post('/GetGroupUnit', 'App\Http\Controllers\API\H5\PersonController@GetGroupUnit');//团检登记查询获取单位分组
Route::post('/GetGroupCombo', 'App\Http\Controllers\API\H5\PersonController@GetGroupCombo');//获取团检套餐
//测试----------------------------
Route::post('/Finish_test', 'App\Http\Controllers\API\H5\OrderController@Finish_test');//测试
});

Loading…
Cancel
Save