瀏覽代碼

Merge branch 'master' of http://59.57.98.130:3000/jjhc/jucai

linwu 2 年之前
父節點
當前提交
7eb59f9333

+ 54 - 12
app/Http/Controllers/Web/Recruit/IndexController.php

@@ -19,15 +19,17 @@ use App\Models\RecruitAppointExpandSpecial;
 use App\Models\RecruitAppointDetail;
 use App\Models\RecruitArticle;
 use Illuminate\Support\Facades\Cache;
+use App\Services\Common\BaiduService;
 
 class IndexController extends WebBaseController
 {
 
-    protected $recruitService;
+    protected $recruitService,$baiduService;
 
-    public function __construct(RecruitService $recruitService)
+    public function __construct(RecruitService $recruitService,BaiduService $baiduService)
     {
         $this->recruitService = $recruitService;
+        $this->baiduService = $baiduService;
     }
 
     /**
@@ -83,11 +85,16 @@ class IndexController extends WebBaseController
             //笔试
             $pen_ticket = RecruitTicket::where('appoint_id',$appoint_info->id)->where('ex_type',1)->first();
             if($pen_ticket){
-                $time = time();
-                if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
-                    $appoint_info->pen_ticket = 1;
+                $pen_health = RecruitSupplement::where("appoint_id",$appoint_info->id)->where("type","pen")->first();
+                if(!$pen_health){
+                    $appoint_info->pen_ticket = -2;
                 }else{
-                    $appoint_info->pen_ticket = -1;
+                    $time = time();
+                    if(strtotime($pen_ticket->ex_start) < $time && strtotime($pen_ticket->ex_end) > $time){
+                        $appoint_info->pen_ticket = 1;
+                    }else{
+                        $appoint_info->pen_ticket = -1;
+                    }
                 }
             }else{
                 $appoint_info->pen_ticket = 0;
@@ -827,8 +834,8 @@ class IndexController extends WebBaseController
                                 }
                             }
                             $special['material'] = json_encode($special['material']);
-
                         }else{
+                            $special['condition'] = '';
                             $special['material'] = json_encode([]);
                         }
                         $hasRecord = RecruitAppointExpandSpecial::where('recruit_appoint_id',$appoint_info->id)->first();
@@ -1633,16 +1640,45 @@ class IndexController extends WebBaseController
         }
 
         $time = time();
-        if($time > 1656043200){//手动截止
+        $type = $request->input('type',null);
+        $where = [];
+        if($type){
+            switch ($type){
+                case 'pen':
+                    $start = strtotime($recruit->pen_health_start);
+                    $end = strtotime($recruit->pen_health_end);
+                    break;
+                case 'computer':
+                    $start = strtotime($recruit->computer_health_start);
+                    $end = strtotime($recruit->computer_health_end);
+                    break;
+                case 'face':
+                    $start = strtotime($recruit->face_health_start);
+                    $end = strtotime($recruit->face_health_end);
+                    break;
+                default:
+                    $start = strtotime($recruit->supplement_start);
+                    $end = strtotime($recruit->supplement_end);
+                    break;
+            }
+            $where[] = ['type', '=', $type];
+        }else{
+            $start = strtotime($recruit->supplement_start);
+            $end = strtotime($recruit->supplement_end);
+
+        }
+        if($time > $end || $time < $start){
             return $this->showMessage('抱歉,考察审核端口已关闭!', route('recruit.show',array('id',$recruit['id'])), true, '上一页', '3');
         }
 
-        $info = RecruitSupplement::where('appoint_id',$appoint_info->id)->first();
+        $where[] = ['appoint_id', '=', $appoint_info->id];
+        $info = RecruitSupplement::where($where)->first();
         if(!$info){
             $info = [
                 'appoint_id' => $appoint_info->id,
                 'health_code' => '',
-                'trip_code' => ''
+                'trip_code' => '',
+                'type' => $type
             ];
         }else{
             $info = $info->toArray();
@@ -1834,11 +1870,12 @@ class IndexController extends WebBaseController
             return redirect(route('login'));
         }
         $appoint_id = $request->input('appoint_id');
+        $type = $request->input('type');
         $appoint_info = RecruitAppointInfo::where('uid',$uid)->where('id',$appoint_id)->first();
         if(!$appoint_info){
             return ['status' => 0, 'msg' => '抱歉,找不到您要登记的报名记录!'];
         }
-        $info = RecruitSupplement::where('appoint_id',$appoint_id)->first();
+        $info = RecruitSupplement::where('appoint_id',$appoint_id)->where('type',$type)->first();
         if($info){
             if($info->h_status == 1){
                 return ['status' => 0, 'msg' => '材料已审核通过,不允许修改'];
@@ -1881,6 +1918,11 @@ class IndexController extends WebBaseController
                     }
                 }
             }
+
+            $this->baiduService->health_code(file_get_contents(base_path() . "/public" . $health_code[0]['response']['path']));
+
+            dd($health_code);
+
             $data['health_code'] = json_encode($health_code);
 
             $trip_code = $request->input('trip_code');
@@ -1893,7 +1935,7 @@ class IndexController extends WebBaseController
                 }
             }
             $data['trip_code'] = json_encode($trip_code);
-
+            $data['type'] = $type;
             $data['h_status'] = 0;
             RecruitSupplement::create($data);
             $appoint_info->health_audit = 4;

+ 66 - 0
app/Services/Common/BaiduService.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace App\Services\Common;
+
+use GuzzleHttp\Client;
+use Illuminate\Support\Facades\Cache;
+
+/**
+ * 百度智能云
+ * Class BaiduService
+ * @package App\Services\Common
+ */
+class BaiduService
+{
+
+    protected $url = "https://aip.baidubce.com/";
+
+    protected $appid;
+
+    protected $appkey;
+
+    protected $httpClient;
+
+    /**
+     * BaiduService constructor.
+     */
+    public function __construct()
+    {
+        $this->httpClient=new Client([
+            'http_errors' => false
+        ]);
+
+        $this->appid=config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.client_id');
+        $this->appkey=config('aix.fangyi.fangyi_zhaokao.fangyi_zhaokao.client_secret');
+
+    }
+
+    public function getAccessToken()
+    {
+        $access_token = Cache::get('baidu_access_token');
+        if (empty($access_token)) {
+            $uri=$this->url."oauth/2.0/token?grant_type=client_credentials&client_id=$this->appid&client_secret=$this->appkey";
+            $curl = new CurlService();
+            $resopnse= $curl->get($uri);
+            $result = json_decode($resopnse, true);
+            Cache::put("wechat_access_token", $result['access_token'], 24*60*29);
+            return $result['access_token'];
+        }
+        return $access_token;
+    }
+
+    public function health_code($image, $options=array())
+    {
+        $data = array();
+
+        $data['image'] = base64_encode($image);
+
+        $data = array_merge($data, $options);
+
+        $curl = new CurlService();
+
+        $resopnse = $this->httpClient->post($this->url . "rest/2.0/ocr/v1/health_code",['form_params' => $data]);
+
+        dd($resopnse->getBody()->getContents());
+    }
+}

File diff suppressed because it is too large
+ 0 - 0
public/themes/default/views/app/person/recruit_info.blade.php


File diff suppressed because it is too large
+ 7 - 2
public/themes/default/views/app/recruit/sign_up.blade.php


Some files were not shown because too many files changed in this diff