|
@@ -17,6 +17,7 @@ use Illuminate\Support\Facades\DB;
|
|
|
use App\Models\RecruitAppointExpandSpecial;
|
|
|
use App\Models\RecruitAppointDetail;
|
|
|
use App\Models\RecruitArticle;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
|
|
|
class IndexController extends WebBaseController
|
|
|
{
|
|
@@ -162,6 +163,109 @@ class IndexController extends WebBaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 上传文件的方法
|
|
|
+ * @param Request $request
|
|
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
+ */
|
|
|
+ public function upload(Request $request)
|
|
|
+ {
|
|
|
+ $user = $this->getUser();
|
|
|
+ if($user){
|
|
|
+ $uid = $user->id;
|
|
|
+ $utype = $user->utype;
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
+ $utype = 0;
|
|
|
+ }
|
|
|
+ $file = $request->file('file');
|
|
|
+ if ($file->isValid()) { //判断文件是否存在
|
|
|
+ //获取文件的扩展名
|
|
|
+ $ext = $file->getClientOriginalExtension();
|
|
|
+
|
|
|
+ if (!in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'doc', 'docx', 'pdf'])) {
|
|
|
+ $res['status'] = 0;
|
|
|
+ $res['msg'] = '文件格式不正确';
|
|
|
+ } else {
|
|
|
+ //获取文件的绝对路径
|
|
|
+ $path = $file->getRealPath();
|
|
|
+
|
|
|
+ $oldname = $file->getClientOriginalName();
|
|
|
+
|
|
|
+ //定义文件名
|
|
|
+ $filename = 'storage/recruit/' . uniqid() . mt_rand(10000, 99999) . '.' . $ext;
|
|
|
+
|
|
|
+ //存储文件。disk里面的public。总的来说,就是调用disk模块里的public配置
|
|
|
+ Storage::disk('public')->put($filename, file_get_contents($path));
|
|
|
+
|
|
|
+ $res['status'] = 1;
|
|
|
+ $res['filename'] = $oldname;
|
|
|
+ $res['path'] = "/storage/" . $filename;
|
|
|
+ $res['msg'] = '上传成功';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $res['status'] = 0;
|
|
|
+ $res['msg'] = '上传失败';
|
|
|
+ }
|
|
|
+ return response()->json($res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看报名人数统计
|
|
|
+ * @param Request $request
|
|
|
+ * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View|mixed|\think\response\Redirect|\think\response\View|void
|
|
|
+ */
|
|
|
+ public function sign_up_count(Request $request)
|
|
|
+ {
|
|
|
+ $user = $this->getUser();
|
|
|
+ if($user){
|
|
|
+ $uid = $user->id;
|
|
|
+ $utype = $user->utype;
|
|
|
+ }else{
|
|
|
+ $uid = 0;
|
|
|
+ $utype = 0;
|
|
|
+ }
|
|
|
+ $id = $request->input('id', 0);
|
|
|
+ if (empty($id)) {
|
|
|
+ return $this->showMessage('抱歉,请输入指定的招考场次!', route('recruit.list'), true, '上一页', '2');
|
|
|
+ }
|
|
|
+ $recruit = Recruit::find($id);
|
|
|
+ if (empty($recruit)) {
|
|
|
+ return redirect(route('/recruit/list'));
|
|
|
+ }
|
|
|
+ if(!$recruit->show_report){
|
|
|
+ return $this->showMessage('抱歉,该场次不允许查看报名人数统计结果!', route('recruit.list'), true, '上一页', '2');
|
|
|
+ }
|
|
|
+ if(Cache::has("sign_up_count_{$recruit->id}")) {
|
|
|
+ $cache_data = Cache::get("sign_up_count_{$recruit->id}");
|
|
|
+ $list = $cache_data['list'];
|
|
|
+ $time = $cache_data['time'];
|
|
|
+ }else{
|
|
|
+ $list = RecruitPost::where('recruit_id',$recruit->id)->where('status',1)->get();
|
|
|
+ if(!$list){
|
|
|
+ return $this->showMessage('抱歉,数据暂时未更新或更新出错!', route('recruit.list'), true, '上一页', '2');
|
|
|
+ }
|
|
|
+ foreach ($list as $k => $v){
|
|
|
+ $res = RecruitAppointInfo::select(DB::raw("count(case audit when 1 then 1 end) as 'checking', count(case audit when 2 then 2 end) as 'fail',count(case audit when 3 then 3 end) as 'success'"))->where('recruit_id',$recruit->id)->where('post_id',$v->id)->first();
|
|
|
+ $list[$k]['checking'] = $res->checking;
|
|
|
+ $list[$k]['fail'] = $res->fail;
|
|
|
+ $list[$k]['success'] = $res->success;
|
|
|
+ }
|
|
|
+ $time = date('Y-m-d H:i',time());
|
|
|
+ $cache_data = [
|
|
|
+ 'list' => $list,
|
|
|
+ 'time' => $time
|
|
|
+ ];
|
|
|
+ Cache::put("sign_up_count_{$recruit->id}",$cache_data,60);
|
|
|
+ }
|
|
|
+
|
|
|
+ $view_data = [
|
|
|
+ 'list' => $list,
|
|
|
+ 'time' => $time
|
|
|
+ ];
|
|
|
+ return view('app.recruit.sign_up_count')->with($view_data);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 报名功能页
|
|
|
* @param Request $request
|