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.
98 lines
2.5 KiB
PHP
98 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\Web;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ComboController extends Controller
|
|
{
|
|
//医生端网页打开页面获取套餐列表
|
|
public function GetList(){
|
|
$hospital = request('hospital');
|
|
$sex=request('sex');
|
|
|
|
|
|
$combo_sort = request('combo_sort');
|
|
$combo_type = request('combo_type');
|
|
$combo_crowd = request('combo_crowd');
|
|
$combo_price =request('combo_price');
|
|
$combo_item = request('combo_item');
|
|
|
|
$hospital = DB::table('hospitals')->select('id', 'name', 'address', 'latitude', 'longitude')->where(['id' => $hospital])->first();
|
|
|
|
$canshu = [];
|
|
$canshu[]=$sex;
|
|
$sql = '';
|
|
if (isset($combo_price)) {
|
|
$price_list = [
|
|
"1" => [0, 299],
|
|
"2" => [300, 999],
|
|
"3" => [1000, 1499],
|
|
"4" => [1500, 2999],
|
|
"5" => [3000, 999999],
|
|
];
|
|
|
|
$sql = " and (a.price>=? and a.price<=?) ";
|
|
$canshu[] = $price_list[$combo_price][0];
|
|
$canshu[] = $price_list[$combo_price][1];
|
|
|
|
}
|
|
if (isset($combo_type)) {
|
|
$sql = $sql . " and a.type_id=? ";
|
|
$canshu[] = $combo_type;
|
|
}
|
|
if (isset($combo_crowd)) {
|
|
$sql = $sql . " and a.crowd_id=? ";
|
|
$canshu[] = $combo_crowd;
|
|
}
|
|
if (isset($combo_sort)) {
|
|
if ($combo_sort == 1) {
|
|
$sql = $sql . " ";
|
|
}
|
|
if ($combo_sort == 2) {
|
|
$sql = $sql . " ";
|
|
}
|
|
if ($combo_sort == 3) {
|
|
$sql = $sql . " order by a.price";
|
|
}
|
|
if ($combo_sort == 4) {
|
|
$sql = $sql . " order by a.price desc";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$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 and a.sex=?" . $sql, $canshu);
|
|
|
|
foreach ($combos as $key => $combo) {
|
|
$combo->count=$combo->count?$combo->count:0;
|
|
$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',
|
|
];
|
|
}
|
|
|
|
$hospital_info = $hospital;
|
|
|
|
|
|
return \Yz::Return(true, '获取成功', [
|
|
'list' => $combos,
|
|
'hospital' => $hospital_info
|
|
]);
|
|
}
|
|
}
|