获取购买详情内容(详情页信息)

wenjuan
yanzai 1 year ago
parent c9f4aacccb
commit 6aab8a8ddc

@ -124,4 +124,65 @@ select combo_id as c_id,count(*) as count from orders where status in(2,4) group
return \Yz::Return(true,"查询成功",['type'=>$type,'crowd'=>$crowd]);
}
//获取购买详情内容(详情页信息)
public function BuyInfo()
{
$hospital_id =request('hospital');
$combo_id =request('combo_id'); //购买的套餐id
$item_ids =request('item_ids'); //自选项目ids
$group_id =request('group_id'); //团检登记id
if(!isset($hospital_id)) return \Yz::echoError1("医院id不能为空");
$hospital=DB::table('hospitals')->where(['id'=>1,'status'=>1,'is_del'=>0])->first();
$combo_info=[];//套餐信息
if(isset($combo_id)){
$combo=DB::table('combos')->where(['hospital_id'=>$hospital_id,'combo_id'=>$combo_id,'status'=>1])->first();
if(!$combo) return \Yz::echoError1("套餐不存在");
$combo_info['price']=$combo->price;
$combo_info['original_price']=$combo->original_price;
$combo_items=json_decode($combo->items,true);
$groupedData = [];
foreach ($combo_items as $item){
$keshiName = $item['keshi_name'];
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = $item;
}
foreach ($groupedData as $keshiName => $children) {
$combo_info['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
}
$items_info=[];//自选项目信息
if(isset($item_ids) and !empty($item_ids)){
$price=0;
$items=DB::table('items')->whereIn('item_id',$item_ids)->where(['status'=>1])->get();
$groupedData = [];
foreach ($items as $item){
$price=$price+$item->price;
$keshiName = $item->keshi_name;
if (!isset($groupedData[$keshiName])) {
$groupedData[$keshiName] = [];
}
$groupedData[$keshiName][] = ['desc'=>$item->jianjie,'name'=>$item->name];
}
$items_info['price']=$price;
foreach ($groupedData as $keshiName => $children) {
$items_info['items'][] = [
'keshi_name' => $keshiName,
'children' => $children
];
}
}
$data=[
'combo_info'=>$combo_info,
'items_info'=>$items_info
];
return \Yz::Return(true,"查询成功",$data);
}
}

@ -30,7 +30,11 @@ Route::get('/wxGetCode', 'App\Http\Controllers\API\mH5\LoginController@wxGetCode
Route::get('/test', 'App\Http\Controllers\TestController@DBtest');
Route::any('/payNotify', 'App\Http\Controllers\API\H5\PayController@Notify')->middleware('log');//支付回调
Route::post('/CheckUpTypeGetList', 'App\Http\Controllers\API\H5\CheckUpTypeController@GetList');//获取体检类型分类
Route::post('/GetComboSort', 'App\Http\Controllers\API\H5\ComboController@GetComboSort');// //获取套餐类型、适用人群
Route::post('/GetAllItems', 'App\Http\Controllers\API\H5\ItemController@GetItems');//获取所有自选项目
Route::group([ 'prefix' => 'H5'], function () {
Route::post('/CheckUpTypeGetList', 'App\Http\Controllers\API\H5\CheckUpTypeController@GetList');//获取体检类型分类
Route::post('/GetComboSort', 'App\Http\Controllers\API\H5\ComboController@GetComboSort');// //获取套餐类型、适用人群
Route::post('/BuyInfo', 'App\Http\Controllers\API\H5\ComboController@BuyInfo');//获取购买详情内容(详情页信息)
Route::post('/GetAllItems', 'App\Http\Controllers\API\H5\ItemController@GetItems');//获取所有自选项目
});

Loading…
Cancel
Save