You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.7 KiB
PHP

<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\Controller;
use App\Services\ConfigService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class ComboController extends Controller
{
public function select(Request $request)
{
$combo=DB::table('combo_type')->select('id as value','name as label')->get();
$person=DB::table('combo_crowd')->select('id as value','name as label')->get();
// $combo = [[
// 'label' => '类型一',
// 'value' => '1',
// ], [
// 'label' => '类型二',
// 'value' => '2',
// ]];
// $person = [[
// 'label' => '类型一',
// 'value' => '1',
// ], [
// 'label' => '类型二',
// 'value' => '2',
// ]];
return \Yz::Return(true, '获取成功', [
'combo' => $combo,
'person' => $person
]);
}
public function list(Request $request)
{
$hospital = $request->post('hospital');
$doctor = $request->post('doctor');
$openid = $request->post('openid');
$hospital= DB::table('hospitals')->select('id','name','address','latitude','longitude')->where(['id'=>$hospital])->first();
$user=DB::table('web_users')->where(['openid'=>$openid,'status'=>1,'is_del'=>0])->first();
if(!$user) return \Yz::echoError1('openid对应用户不存在');
$person=DB::table('web_user_person')->where(['user_id'=>$user->id,'is_del'=>0,'is_default'=>1])->first();
if(!$person) return \Yz::echoError1("请选择就诊人");
//用户绑定就诊人数量
$personCount=DB::table('web_user_person')->where(['user_id'=>$user->id,'is_del'=>0])->count();
$combos=DB::select("select * from combos as a LEFT JOIN (
select combo_id as c_id,count(*) as count from orders where status in(2,4) group by combo_id
) as b on a.combo_id=b.c_id where a.status=1");
foreach ($combos as $key=>$combo){
$tags=json_decode($combo->tags,true);
$combo->tags2=json_decode($combo->tags2,true);
foreach ($tags as$k=> $tag){
$tags[$k]=['text'=>$tag,
'text_color' => '#47ABD8',
'color' => '#EBF5FC'
];
}
$combo->tag=$tags;
$combo->tag[]=[
'text' => $combo->item_count.'个项目',
'text_color' => '#34C292',
'color' => '#E9F8F3',
];
}
// $item = [
// 'cover' => '/assets/h5/combo.png',
// 'name' => '中老年体检套餐(女)',
// 'sex' => 2,
// 'combo_type' => '1',
// 'person_type' => '1',
// 'tag' => [[
// 'text' => '女已婚',
// 'text_color' => '#47ABD8',
// 'color' => '#EBF5FC',
// ], [
// 'text' => '22个项目',
// 'text_color' => '#34C292',
// 'color' => '#E9F8F3',
// ]],
// 'desc' => ['血糖', '腹部超声', '心电图'],
// 'price' => '1229.00',
// 'original_price' => '2048.88',
// 'count' => '77'
// ];
// $list = [];
// for ($i = 0; $i < 20; $i++) {
// $list[] = $item;
// }
// $hospital_info = [
// 'id' => $hospital,
// 'name' => '秀英院区',
// 'address' => '秀英院区秀英院区秀英院区地址',
// 'latitude' => '39.867671',
// 'longitude' => '119.514223',
// ];
$hospital_info=$hospital;
$info = [
'name' => $person->name,
'sex' => $person->sex,
'count' => $personCount
];
$doctor_info = [
'id' => $doctor,
'name' => '张大夫'
];
return \Yz::Return(true, '获取成功', [
'list' =>$combos,
'hospital' => $hospital_info,
'doctor' => $doctor_info,
'info' => $info,
]);
}
//获取套餐类型、适用人群
public function GetComboSort()
{
$type=DB::table('combo_type')->get();
$crowd=DB::table('combo_crowd')->get();
return \Yz::Return(true,"查询成功",['type'=>$type,'crowd'=>$crowd]);
}
}