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.
75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\H5;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ItemController extends Controller
|
|
{
|
|
//获取全部自选项目
|
|
public function GetItems()
|
|
{
|
|
$openid= request('openid');
|
|
$person=DB::table('web_users as a') ->leftJoin('web_user_person as b' ,'a.id','=','b.user_id')
|
|
->where(['openid'=>$openid,'b.is_del'=>0,'b.is_default'=>1])
|
|
->first();
|
|
if(!$person) return \Yz::echoError1("就诊人信息不存在");
|
|
//查询所有可以自选的项目
|
|
$items=DB::table('items')->where(['is_choose'=>1,'status'=>1])->get();
|
|
$search= request('search');
|
|
$list = [];
|
|
$group_arr = [];
|
|
$group_list = [];
|
|
foreach ($items as $item) {
|
|
if($item->sex <> $person->sex and $item->sex<>0){
|
|
continue;
|
|
}
|
|
$push_type = false;
|
|
if ($search == '') {
|
|
$push_type = true;
|
|
} else {
|
|
$check_name = $item->name;
|
|
if (strpos($check_name, $search) !== false) {
|
|
$push_type = true;
|
|
}
|
|
|
|
$check_py = $item->pinyin;
|
|
if (strpos($check_py, mb_strtoupper($search)) !== false) {
|
|
$push_type = true;
|
|
}
|
|
|
|
$check_group = $item->keshi_name;
|
|
if (strpos($check_group, $search) !== false) {
|
|
$push_type = true;
|
|
}
|
|
}
|
|
if ($push_type) {
|
|
if (!in_array($item->keshi_id, $group_arr)) {
|
|
$group_list["科室{$item->keshi_id}"] = [
|
|
'id' => $item->keshi_id,
|
|
'title' => $item->keshi_name,
|
|
'head_img'=>'/storage/20240822/banner1.png',
|
|
'children' => [],
|
|
];
|
|
$group_arr[] = $item->keshi_id;
|
|
}
|
|
|
|
$group_list["科室{$item->keshi_id}"]['children'][] = [
|
|
'id' => $item->item_id,
|
|
'title' => $item->name,
|
|
'price' =>$item->price,
|
|
'original_price'=>$item->original_price,
|
|
'pinyin' => $item->pinyin,
|
|
'desc'=>$item->jianjie
|
|
];
|
|
|
|
|
|
}
|
|
|
|
}
|
|
return \Yz::Return(true,"查询成功",['list'=>$group_list]);
|
|
}
|
|
}
|