Browse Source

更新硕博人才

sandm 3 years ago
parent
commit
91b6a0e43e

+ 128 - 4
app/Http/Controllers/Web/Talent/ShuoboController.php

@@ -8,35 +8,83 @@ use App\Services\Common\SmsService;
 use App\Models\Member;
 use Illuminate\Http\Request;
 use App\Services\Common\SearchService;
+use App\Models\C2M;
+use Illuminate\Support\Facades\DB;
 
 class ShuoboController extends WebBaseController
 {
 
     private $smsService;
     protected $searchService;
+    protected $c2m;
 
     public function __construct(SmsService $smsService,SearchService $searchService)
     {
         $this->smsService = $smsService;
         $this->searchService = $searchService;
+        $this->c2m = new C2M();
     }
 
     public function talent()
     {
-        dd(MemberShuobo::search("郑明炜")->get());
 
         return view('app.shuobo.talent');
     }
 
+    public function getCompanyToShuobo(Request $request){
+        $user = auth('web-company')->user();
+        if($user){
+            $info = $this->c2m->where("company_id",$user->id)->where('status',0)->first();
+            if($info){
+                $data = [
+                    'number' => 1,
+                    'shuobo_id' => $info->shuobo_id,
+                    'info' => MemberShuobo::where('id',$info->shuobo_id)->first()
+                ];
+            }else{
+                $data = [
+                    'number' => 0
+                ];
+            }
+
+            return json_encode(['status' => 1,'data' => $data,'msg' => '','login' => 1]);
+        }else{
+            return json_encode(['status' => 1,'data' => '','msg' => '未登录','login' => 0]);
+        }
+
+    }
+
     public function getTalentData(Request $request)
     {
-
         $keyword = $request->input('keyword');
         $page = $request->input('page');
-        $list = $this->searchService->search('Shuobo', [], [], $keyword,10,$page);
+        $list = $this->searchService->search('Shuobo', [], ['sort'=>'desc','updated_at' => 'desc','id'=>'desc'], $keyword,10,$page);
         $list_data =[];
+        $has_shuobo_id = $this->c2m->whereRaw('status = 0 or status = 1')->select('shuobo_id')->get()->toArray();
+        $no_show_shuobo = [];
+        if(is_array($has_shuobo_id)){
+            foreach ($has_shuobo_id as $v){
+                array_push($no_show_shuobo,$v['shuobo_id']);
+            }
+        }
+        $user = auth('web-company')->user();
+        $notice_show_shuobo = [];
+        if($user){
+            //如果有登录,查找之前有跟进过的人才并标记
+            $notice_shobo_id = $this->c2m->where('company_id',$user->id)->select('shuobo_id')->get()->toArray();
+            if(is_array($notice_shobo_id)){
+                foreach ($notice_shobo_id as $v){
+                    array_push($notice_show_shuobo,$v['shuobo_id']);
+                }
+            }
+        }
+
         foreach ($list->items() as $k => $v){
+            if(in_array($v->id,$no_show_shuobo)){
+                continue;
+            }
             $item = [
+                'id' => $v->id,
                 'name' => $this->splitName($v->realname)[0] . ($v->sex == '男' ? '先生' : '女士'),
                 'sex' => $v->sex,
                 'birthday' => date('Y-m-d H:i:s',$v->birthday),
@@ -44,7 +92,8 @@ class ShuoboController extends WebBaseController
                 'school' => $v->school,
                 'pro' => $v->pro,
                 'trade_type' => $v->trade_type,
-                'speciality' => $v->speciality
+                'speciality' => $v->speciality,
+                'notice' => in_array($v->id,$notice_show_shuobo) ? 1 : 0
             ];
             array_push($list_data,$item);
         }
@@ -54,6 +103,81 @@ class ShuoboController extends WebBaseController
             'list' => $list_data
         );
 
+
+        return json_encode($data);
+    }
+
+    public function getTalentInfo(Request $request)
+    {
+        $user = auth('web-company')->user();
+        if(!$user){
+            return json_encode(['status' => 1,'data' => '','msg' => '未登录']);
+        }
+        $id = $request->input('id');
+        $info = MemberShuobo::where('id',$id)->first();
+        if(!$info){
+            return json_encode(['status' => 1,'data' => '','msg' => '找不到该人才信息']);
+        }
+        $c2m_data = [
+            'company_id' => $user->id,
+            'company_name' => $user->companyname,
+            'shuobo_id' => $id,
+            'shuobo_name' => $info->realname,
+            'status' => 0
+        ];
+
+        $scid = $this->c2m->create($c2m_data);
+
+        return json_encode(['status' => 1,'data' => $info,'msg' => '']);
+
+    }
+
+    public function updateCompanyToShuobo(Request $request)
+    {
+        $user = auth('web-company')->user();
+        if($user){
+            $id = $request->input('id');
+            if(!$id){
+                return json_encode(['status' => 1,'data' => '','msg' => '必要参数缺失!']);
+            }
+            $info = $this->c2m->where("company_id",$user->id)->where('shuobo_id',$id)->where('status',0)->first();
+            if(!$info){
+                return json_encode(['status' => 1,'data' => '','msg' => '这条硕博跟进记录不存在。']);
+            }
+            $status = $request->input('status');
+            $remark = $request->input('remark');
+            if(!in_array($status,[-1,0,1,2])){
+                return json_encode(['status' => 1,'data' => '','msg' => '状态不正确。']);
+            }
+            $this->c2m->where("company_id",$user->id)->where('shuobo_id',$id)->update(['status' => $status,'remark' => $remark]);
+            $ret = [
+                'number' => 0
+            ];
+            return json_encode(['status' => 1,'data' => $ret,'msg' => '更新成功。']);
+        }
+        return json_encode(['status' => 1,'data' => '','msg' => '未登录','login' => 0]);
+    }
+
+    public function enterprise(Request $request)
+    {
+        return view('app.shuobo.enterprise');
+    }
+
+    public function getShuoboJob(Request $request)
+    {
+        $keyword = $request->input('keyword');
+        $page = $request->input('page');
+        if(!empty($keyword)){
+            $list = DB::table("shuobo_jobs")->where("company_name","like","%{$keyword}%")->orWhere("job",'like',"%{$keyword}%")->orderBy('id','desc')->get()->toArray();
+        }else{
+            $list = DB::table("shuobo_jobs")->orderBy('id','desc')->get()->toArray();
+        }
+
+        $data = array(
+            'total' => count($list),
+            'list' => array_slice($list,($page-1)*10,10)
+        );
+
         return json_encode($data);
     }
 

+ 12 - 0
app/Models/C2M.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+
+class C2M extends Model
+{
+    protected $table = 'shuobo_company';
+    protected $fillable = ['company_id','company_name','shuobo_id','shuobo_name','status','remark'];
+}

+ 0 - 9
app/Models/MemberShuobo.php

@@ -25,14 +25,5 @@ class MemberShuobo extends Model
     public function toSearchableArray()
     {
         return $this->toArray();
-        return [
-            'realname' => $this->realname,
-            'mobile' => $this->mobile,
-            'education' => $this->education,
-            'school' => $this->school,
-            'pro' => $this->pro,
-            'address' => $this->address,
-            'trade_type' => $this->trade_type
-        ];
     }
 }

+ 12 - 0
app/Services/Common/SearchService.php

@@ -856,7 +856,19 @@ class SearchService
                 return $list->paginate($limit);
             }
         } elseif ($model == 'Shuobo') {
+
             $list=MemberShuobo::search($search_key);
+            if ($order_by) {
+                if (is_array($order_by)) {
+                    foreach ($order_by as $k => $v) {
+                        $list->orderBy($k, $v);
+                    }
+                } else {
+                    $list->orderBy($order_by, 'desc');
+                }
+            } else {
+                $list->orderBy('refresh_time', 'desc');
+            }
             if ($page) {
                 return $list->paginate($limit, 'page', $page);
             } else {