* 'main' of https://git.cjy.net.cn/zhangyan/hainan_2024:
  对接思信预约登记
  创建订单判断团检,根据统收限额计算金额
  封装号源检查,增加体检类型判断
  创建订单增加团检类型、完善细节、对接思信套餐项目检查。
  团检登记查询获取单位分组、获取团检套餐、更新购买详情加入团检
  核磁号源接口
wenjuan
鹿和sa0ChunLuyu 1 year ago
commit 5efc18d70a

@ -42,6 +42,11 @@ class ApiMapController extends Controller
'DoctorGetList' => $base_url . '/api/H5/DoctorGetList',//获取体检医生列表
'ComboRecommend' => $base_url . '/api/H5/ComboRecommend',//套餐推荐
'GetReadme' => $base_url . '/api/H5/GetReadme',//须知
'NMRGetMonthPlanCount' => $base_url . '/api/H5/NMRGetMonthPlanCount',//核磁每日号源
'NMRGetDayPlanList' => $base_url . '/api/H5/NMRGetDayPlanList',//核磁每日号源
'GetGroupUnit' => $base_url . '/api/H5/GetGroupUnit',//团检登记查询获取单位分组
'GetGroupCombo' => $base_url . '/api/H5/GetGroupCombo',//获取团检套餐
'OrderCreate' => $base_url . '/api/H5/OrderCreate',//创建订单
];
}

@ -262,11 +262,11 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
$groupedData = [];
foreach ($items as $item){
// $price=$price+$item->price;
$price= bcadd($price, $item->price, 0);
$price= bcadd($price, $item->price, 2);
// $all_original_price+=$item->original_price;
$all_original_price=bcadd($all_original_price, $item->original_price, 0);
$all_original_price=bcadd($all_original_price, $item->original_price, 2);
// $items_original_price+=$item->original_price;
$items_original_price=bcadd($items_original_price, $item->original_price, 0);
$items_original_price=bcadd($items_original_price, $item->original_price, 2);
$keshiName = $item->keshi_name;
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
@ -289,7 +289,23 @@ select combo_id as c_id,count(*) as sale_count from orders where status in(2,4)
$coupon_money=50;//优惠券抵扣金额
$true_price+=$items_info['price']; //用户真实支付价格,应减去抵扣(二期实现)
$group_info = false;
if (!!$group_id) {
$P=new PersonController();
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id'=>$group_id
];
$group_info = $P->group_info($hospital_id,$data);
}
$data=[
'group_info'=>$group_info,
'combo_info'=>$combo_info,
'items_info'=>$items_info,
'integral_money'=>$integral_money,

@ -0,0 +1,50 @@
<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class NMRController extends Controller
{
//获取核磁号 本月每日剩余号源数量
public function GetMonthPlanCount()
{
$hospital_id =request('hospital_id');
$month=request('month');
$list=[
[
'date'=>'2024-9-29',
'count'=>20,
],
[
'date'=>'2024-9-30',
'count'=>10,
],
];
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
//核磁当日号源
public function GetDayPlanList()
{
$hospital_id =request('hospital');
$date=request('date');
$list=[
[
'id'=>1,
'status'=>1,
'time'=>'10:15'
],
[
'id'=>1,
'status'=>1,
'time'=>'10:45'
]
];
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
}

@ -3,6 +3,7 @@
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use App\Http\Controllers\API\PEISApiController;
use App\Services\ConfigService;
use DateTime;
use Illuminate\Http\Request;
@ -100,7 +101,15 @@ class OrderController extends Controller
$type = request('type');//1个检2团检
$group_id = request('group_id');//团检id
$item_ids = request('item_ids');//自选item的ids
$plan_id = request('plan_id');//自选item的ids
$plan_id = request('plan_id');//号源id
if (!isset($hospital_id)) return \Yz::echoError1('医院id不能为空');
if (!isset($openid)) return \Yz::echoError1('openid不能为空');
if (!isset($person_id)) return \Yz::echoError1('person_id不能为空');
if (!isset($type)) return \Yz::echoError1('type体检类型不能为空');
if (!isset($plan_id)) return \Yz::echoError1('号源id不能为空');
if ($type == 2 and !isset($group_id)) return \Yz::echoError1('团检group_id不能为空');
if ($type == 1 and isset($group_id)) return \Yz::echoError1('体检类型:个检 与group_id冲突');
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
if (!$user) return \Yz::echoError1('用户不存在');
@ -108,6 +117,7 @@ class OrderController extends Controller
if (!$person) return \Yz::echoError1('体检人不存在');
$title = "自选项目";
$price = 0;
$true_price = 0;//订单真实支付金额
$buy_info = [
'combo' => [
'id' => 0,
@ -120,9 +130,12 @@ class OrderController extends Controller
],
];
//如果是套餐
$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;
$price += $combo_info->price;
$title = $combo_info->name;
$buy_info['combo'] = [
@ -136,43 +149,111 @@ class OrderController extends Controller
$items_list = [];
if (count($item_ids) != 0) {
$items_list = DB::table('items')->whereIn('item_id', $item_ids)->where(['status' => 1])->get();
$existingIds = [];
foreach ($items_list as $item) {
$price += $item->price;
$existingIds[] = $item->item_id;
$buy_info['items'][] = [
'id' => $item->item_id,
'name' => $item->name,
'price' => $item->price
];
}
$missingIds = array_diff($item_ids, $existingIds);
if (count($missingIds) > 0) return \Yz::echoError1("部分自选项目不可用Id:" . implode(', ', $missingIds));
}
$true_price = $price;
//如果是团检
$group_info = false;
if ($type == 2) {
$P = new PersonController();
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id' => $group_id
];
$group_info = $P->group_info($hospital_id, $data);
$group_info = $group_info[0];
$buy_info['group'] = [
'id' => $group_id,
'combo_name' => $group_info['combo_name'],
'combo_id' => $group_info['combo_id'],
'group_name' => $group_info['group_name'],
'items' => $group_info['items'],
'group_id' => $group_info['group_id'],
];
$title = "单位团检" . $group_info['combo_name'];
$price = $price + $group_info['sixi_zong_ji_jin_e'];
$need_pay = ($price - $group_info['tongshou_xiane']) > 0 ? $price - $group_info['tongshou_xiane'] : 0;
//团检订单金额为减去统收后的金的
$price = $need_pay;
$true_price = $need_pay;
}
//调用思信接口判断各个项目是否可用
$check_items = [];
foreach ($item_ids as $item_id) {
$check_items[] = ['Id' => $item_id];
}
if ((isset($combo_id) and $combo_id <> 0) || count($check_items) != 0) {
$item_check = self::item_check($hospital_id, [
'人员信息列表' => [[
"序号" => 0,
"性别" => $person->sex == 1 ? '男' : '女',
"年龄" => floor((time() - strtotime($person->birthday)) / 86400 / 360),
"婚姻状态" => $person->married == 1 ? '已婚' : '未婚',
]],
'套餐Id' => $combo_id == 0 ? null : $combo_id,
'可选项目信息' => $check_items,
]);
if (count($item_check['data']) != 1) {
return \Yz::echoError1("体检系统提示:" . $item_check['message']);
}
}
//检查号源是否可用
$plan = new PlanController();
$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'];
//判断号源是否可用vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$plan = DB::table('plans')->where(['id' => $plan_id, 'hospital_id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
if (!$plan) return \Yz::echoError1("号源不可用");
//判断个检/团检类型
if ($plan->use_type <> 0 and $plan->use_type <> $type) {
$type_temp = '';
if ($plan->use_type == 1) $type_temp = '个检';
if ($plan->use_type == 2) $type_temp = '团检';
return \Yz::echoError1("此号源为" . $type_temp . "号源,不可用");
}
//判断是否是预留号源
if ($plan->type <> 1) return \Yz::echoError1("此号源为预留号源,不可用");
//判断是否是vip
//判断性别
if ($plan->sex <> 0 and $plan->sex <> $person->sex) return \Yz::echoError1("此号源性别与体检人性别不符,不可用");
//判断体检类型checkup_type
//判断金额
if ($plan->use_type == 1 and $plan->amount_limit1 <> 0) {
if ($price < $plan->amount_limit1) return \Yz::echoError1("未达到此号源限制的金额,不可用");
}
if ($plan->use_type == 2 and $plan->amount_limit2 <> 0) {
if ($price < $plan->amount_limit2) return \Yz::echoError1("未达到此号源限制的金额,不可用");
}
//判断时间是否过期
$plan_datetime=$plan->date.' '.$plan->time;
if($plan_datetime < date('Y-m-d H:i:s')) return \Yz::echoError1("");
// $plan = DB::table('plans')->where(['id' => $plan_id, 'hospital_id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
// if (!$plan) return \Yz::echoError1("号源不可用");
// //判断个检/团检类型
// if ($plan->use_type <> 0 and $plan->use_type <> $type) {
// $type_temp = '';
// if ($plan->use_type == 1) $type_temp = '个检';
// if ($plan->use_type == 2) $type_temp = '团检';
// return \Yz::echoError1("此号源为" . $type_temp . "号源,不可用");
// }
// //判断是否是预留号源
// if ($plan->type <> 1) return \Yz::echoError1("此号源为预留号源,不可用");
// //判断是否是vip
// //判断性别
// if ($plan->sex <> 0 and $plan->sex <> $person->sex) return \Yz::echoError1("此号源性别与体检人性别不符,不可用");
// //判断体检类型checkup_type
// //判断金额
// if ($plan->use_type == 1 and $plan->amount_limit1 <> 0) {
// if ($price < $plan->amount_limit1) return \Yz::echoError1("未达到此号源限制的金额,不可用");
// }
// if ($plan->use_type == 2 and $plan->amount_limit2 <> 0) {
// if ($price < $plan->amount_limit2) return \Yz::echoError1("未达到此号源限制的金额,不可用");
// }
// //判断时间是否过期
// $plan_datetime = $plan->date . ' ' . $plan->time;
// if ($plan_datetime < date('Y-m-d H:i:s')) return \Yz::echoError1("");
//判断号源是否可用^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//如果是团检 判断号源在 团检登记人的有效时间范围内
$plan_datetime = $plan->date . ' ' . $plan->time;
if (!!$group_info) {
if (!($plan_datetime > $group_info['start_time'] . ' 00:00:00' and $plan_datetime < $group_info['end_time'] . ' 23:59:59')) {
return \Yz::echoError1("预约日期不在单位有效时间范围内,请重新选择");
}
}
//构建订单号
$order_num = $this->generateOrderNumber();
$data = [
@ -184,7 +265,7 @@ class OrderController extends Controller
'id_number' => $person->id_number,
'buy_info' => json_encode($buy_info, JSON_UNESCAPED_UNICODE),
'price' => $price,
'true_price'=>$price,
'true_price' => $true_price,
'order_number' => $order_num,
'status' => 1,
'appointment_date' => $plan->date,
@ -212,7 +293,8 @@ class OrderController extends Controller
}
}
function generateOrderNumber() {
function generateOrderNumber()
{
// 获取当前时间的时间戳(精确到毫秒)
$timestamp = round(microtime(true) * 1000);
@ -224,4 +306,79 @@ class OrderController extends Controller
return $orderNumber;
}
public function item_check($hospital, $data)
{
$peis = new PEISApiController();
$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'),
]);
//先把状态更新为支付,然后再开始预约思信
}
}

@ -12,8 +12,10 @@ class PersonController extends Controller
{
$peis = new PEISApiController();
$info = $peis::Post('团检登记查询', $hospital, $data);
$group_list=[];
foreach ($info['data'] as $it) {
$items = [];
$group_info = $info['data'][0];
$group_info = $it;
if (isset($group_info['项目列表'])) {
foreach ($group_info['项目列表'] as $datum) {
$items[] = [
@ -22,7 +24,7 @@ class PersonController extends Controller
];
}
}
return [
$data=[
'name' => $group_info['姓名'],
'id_number' => $group_info['证件号码'],
'combo_name' => $group_info['套餐名称'],
@ -30,8 +32,45 @@ class PersonController extends Controller
'start_time' => $group_info['预约开始日期'],
'end_time' => $group_info['预约结束日期'],
'group_name' => $group_info['单位名称'] . ($group_info['部门名称']),
'group_id' => $group_info['预约Id'],
'tongshou_xiane'=>$group_info['统收限额'],
'sixi_zong_ji_jin_e'=>$group_info['总计金额'],
'items' => $items,
'appointment_number' => $group_info['预约Id']
];
$group_list[]=$data;
}
return $group_list;
}
//团检登记查询根据身份证和电话查分组id
public function GetGroupUnit()
{
$phone = request('phone');
$id_number = request('id_number');
$hospital_id = request('hospital_id');
if (!isset($phone)) return \Yz::echoError1('电话不能为空');
if (!isset($id_number)) return \Yz::echoError1('身份证不能为空');
if (!isset($hospital_id)) return \Yz::echoError1('医院id不能为空');
$data = [
'电话号码' => $phone,
'证件号码' => $id_number
];
$res = self::group_info($hospital_id, $data);
return \Yz::Return(true,"查询完成",['unit'=>$res]);
}
//获取团检套餐
public function GetGroupCombo()
{
$hospital_id = request('hospital_id');
$group_id = request('group_id');
if (!isset($group_id)) return \Yz::echoError1('group_id不能为空');
$data = [
'电话号码' => null,
'证件号码' => null,
'预约Id'=>$group_id
];
$res = self::group_info($hospital_id, $data);
return \Yz::Return(true,"查询完成",['unit'=>$res]);
}
}

@ -63,4 +63,43 @@ class PlanController extends Controller
$list=$list->get();
return \Yz::Return(true,"查询完成",['list'=>$list]);
}
//检查号源是否可用
public function CheckPlan($plan_id,$hospital_id,$type,$sex,$price,$checkup_type_id)
{
$plan = DB::table('plans')->where(['id' => $plan_id, 'hospital_id' => $hospital_id, 'status' => 1, 'is_del' => 0])->first();
if (!$plan) return ['status'=>false,'msg'=>"号源不可用"];
//判断个检/团检类型
if ($plan->use_type <> 0 and $plan->use_type <> $type) {
$type_temp = '';
if ($plan->use_type == 1) $type_temp = '个检';
if ($plan->use_type == 2) $type_temp = '团检';
return ['status'=>false,'msg'=>"此号源为" . $type_temp . "号源,不可用"];
}
//判断是否是预留号源
if ($plan->type <> 1) return ['status'=>false,'msg'=>"此号源为预留号源,不可用"];
//判断是否是vip
//判断性别
if ($plan->sex <> 0 and $plan->sex <> $sex) return ['status'=>false,'msg'=>"此号源性别与体检人性别不符,不可用"];
//判断体检类型checkup_type
if(!!$checkup_type_id){
$checkup_type_array=json_decode($plan->checkup_type_id,true);
if(!in_array($checkup_type_id,$checkup_type_array)){
return ['status'=>false,'msg'=>"此号源体检类型与套餐不匹配,不可用"];
}
}
//判断金额
if ($plan->use_type == 1 and $plan->amount_limit1 <> 0) {
if ($price < $plan->amount_limit1) return ['status'=>false,'msg'=>"未达到此号源限制的金额,不可用"];
}
if ($plan->use_type == 2 and $plan->amount_limit2 <> 0) {
if ($price < $plan->amount_limit2) return ['status'=>false,'msg'=>"未达到此号源限制的金额,不可用"];
}
//判断时间是否过期
$plan_datetime = $plan->date . ' ' . $plan->time;
if ($plan_datetime < date('Y-m-d H:i:s')) return ['status'=>false,'msg'=>"号源已过期,不可用"];
return ['status'=>true,'msg'=>"",'plan'=>$plan];
}
}

@ -179,6 +179,5 @@ class UserController extends Controller
// }
return true;
}
}

@ -3,6 +3,7 @@
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
@ -18,7 +19,16 @@ class PEISApiController extends Controller
$api['套餐详情查询'] = "{$url}/PEISCommon/QueryComboDetail/{$code}";
$api['自选项目查询'] = "{$url}/PEISCommon/QueryGroups/{$code}";
$api['套餐查询'] = "{$url}/PEISCommon/QueryCombos/{$code}";
$api['套餐项目检查'] = "{$url}/PEISCommon/CheckComboAndGroup/{$code}";
$api['个检预约'] = "{$url}/PEISCommon/PersonAppointment/{$code}";
$api['个检预约查询'] = "{$url}/PEISCommon/QueryPersonAppointment/{$code}";
$api['个检预约取消'] = "{$url}/PEISCommon/CancelPersonAppointment/{$code}";
$api['团检登记查询'] = "{$url}/PEISCommon/QueryUnitAppointmentReg/{$code}";
$api['团检预约'] = "{$url}/PEISCommon/UnitAppointment/{$code}";
$api['团检预约查询'] = "{$url}/PEISCommon/QueryUnitAppointment/{$code}";
$api['团检预约取消'] = "{$url}/PEISCommon/CancelUnitAppointment/{$code}";
return $api["{$url_code}"] ?? $url_code;
}
@ -42,7 +52,6 @@ class PEISApiController extends Controller
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$res_string = curl_exec($ch);
curl_close($ch);
$str_len = mb_strlen($res_string, 'utf-8');
$str_size = $str_len / 1024;
$save_res = $res_string;
@ -60,7 +69,9 @@ class PEISApiController extends Controller
]);
}
$res = json_decode($res_string, true);
if ($res['ResultCode'] != 0){
throw new HttpResponseException( \Yz::echoError1("体检系统提示:". $res['ResultContent']));
}
return [
'code' => $res['ResultCode'],

@ -52,7 +52,15 @@ Route::group(['prefix' => 'api/H5'], function () {
Route::post('/GetPersonIntegralSaveMoneyCouponInfo', 'App\Http\Controllers\API\H5\IntegralSaveMoneyCouponController@GetInfo');//点击个检获取页面按钮
Route::post('/DoctorGetList', 'App\Http\Controllers\API\H5\DoctorController@GetList');//获取体检医生列表
Route::post('/ComboRecommend', 'App\Http\Controllers\API\H5\ComboController@ComboRecommend');//推荐套餐
Route::post('/NMRGetMonthPlanCount', 'App\Http\Controllers\API\H5\NMRController@GetMonthPlanCount');//核磁每日号源总数
Route::post('/NMRGetDayPlanList', 'App\Http\Controllers\API\H5\NMRController@GetDayPlanList');//核磁某日号源
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