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.
55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\H5;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class QuestionController extends Controller
|
|
{
|
|
public function GetList()
|
|
{
|
|
$hospital_id = request('hospital_id');
|
|
$q_type = request('q_type');
|
|
if (!isset($hospital_id)) return \Yz::echoError1("医院id不能为空");
|
|
if (!isset($q_type)) return \Yz::echoError1("问卷类型不能为空");
|
|
$list = DB::table('questions')
|
|
->where(['hospital_id'=>$hospital_id,
|
|
'q_type'=>$q_type,
|
|
'status'=>1,
|
|
'is_del'=>0,
|
|
])->orderBy('order','asc')->get();
|
|
foreach ($list as $key=>$item){
|
|
$item->content=json_decode($item->content,true);
|
|
|
|
|
|
}
|
|
return \Yz::Return(true,"查询成功",['list'=>$list]);
|
|
}
|
|
//提交调查
|
|
public function SubmitAnswer()
|
|
{
|
|
$openid = request('openid');
|
|
$content = request('content');
|
|
$q_type = request('q_type');
|
|
|
|
$user = DB::table('web_users')->where(['openid' => $openid, 'status' => 1, 'is_del' => 0])->first();
|
|
if (!$user) return \Yz::echoError1('用户不存在');
|
|
if(!isset($q_type)) return \Yz::echoError1('问卷类型不能为空');
|
|
if(!isset($content) or empty($content)) return \Yz::echoError1('内容不能为空');
|
|
$data=[
|
|
'userid'=>$user->id,
|
|
'q_type'=>$q_type,
|
|
'content'=>json_encode($content,JSON_UNESCAPED_UNICODE)
|
|
];
|
|
$i=DB::table('questions_log')->insert($data);
|
|
if($i){
|
|
return \Yz::Return(true,"提交成功",[]);
|
|
}else{
|
|
return \Yz::echoError1('提交失败');
|
|
}
|
|
|
|
}
|
|
}
|