| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 | 
							- <?php
 
- /**
 
-  * Created by PhpStorm.
 
-  * User: Administrator
 
-  * Date: 2018/10/17
 
-  * Time: 15:07
 
-  */
 
- namespace App\Admin\Controllers\Company;
 
- use App\Http\Controllers\Controller;
 
- use App\Models\Company;
 
- use App\Models\Jobs;
 
- use App\Models\Member;
 
- use App\Models\Pms;
 
- use App\Models\Resume;
 
- use App\Models\SmsRule;
 
- use App\Repositories\SmsTemplateRepository;
 
- use App\Services\Common\EmailService;
 
- use App\Services\Common\SmsService;
 
- use Encore\Admin\Facades\Admin;
 
- use Illuminate\Http\Request;
 
- class AjaxController extends Controller
 
- {
 
-     protected $smsService;
 
-     protected $smsTemplateRepository;
 
-     protected $emailService;
 
-     /**
 
-      * AjaxController constructor.
 
-      * @param $smsService
 
-      * @param $smsTemplateRepository
 
-      */
 
-     public function __construct(SmsService $smsService, SmsTemplateRepository $smsTemplateRepository, EmailService $emailService)
 
-     {
 
-         $this->smsService = $smsService;
 
-         $this->smsTemplateRepository = $smsTemplateRepository;
 
-         $this->emailService = $emailService;
 
-     }
 
-     public function getInfo(Request $request)
 
-     {
 
-         if ($request->utype == 1) {
 
-             $data['info'] = Company::findOrFail($request->id);
 
-             $data['utype'] =1;
 
-         } else {
 
-             $data['info'] = Member::findOrFail($request->id);
 
-             $data['utype'] = 2;
 
-         }
 
-         return view('admin.ajax.getInfo')->with('info', $data);
 
-     }
 
-     public function getPromotion(Request $request)
 
-     {
 
-         $where = [];
 
-         if ($request->id) {
 
-             $where[] =['id', '=', $request->id];
 
-         }
 
-         if ($request->jobs_name) {
 
-             $where[] =['jobs_name', 'like', "%$request->jobs_name%"];
 
-         }
 
-         if ($request->company_id) {
 
-             $where[] =['company_id', '=', $request->company_id];
 
-         }
 
-         if ($request->company_name) {
 
-             $where[] =['company_name', 'like', "%$request->company_name%"];
 
-         }
 
-         if ($where) {
 
-             $where['valid'] = 1;
 
-             $where['audit'] = 1;
 
-             $where['display'] = 1;
 
-             $where['subsite_id'] = get_subsite_id();
 
-             $data = Jobs::select('id', 'company_id', 'jobs_name', 'company_name', 'deadline', 'created_at', 'refresh_time')->where($where)->get();
 
-             if (!$data->isEmpty()) {
 
-                 return  json_encode(['data'=>$data, 'code'=>1]);
 
-             }
 
-         }
 
-         return  json_encode(['msg'=>'<tr><td colspan="5">暂无数据</td></tr>', 'code'=>0]);
 
-     }
 
-     public function getResume(Request $request)
 
-     {
 
-         $where = [];
 
-         if ($request->id) {
 
-             $where[] =['id', '=', $request->id];
 
-         }
 
-         if ($request->fullname) {
 
-             $where[] =['fullname', 'like', "%$request->fullname%"];
 
-         }
 
-         if ($request->uid) {
 
-             $where[] =['uid', '=', $request->uid];
 
-         }
 
-         if ($where) {
 
-             $where[] = ['audit','=',2];
 
-             $where[] = ['subsite_id', '=',get_subsite_id()];
 
-             $data = Resume::select('id', 'uid', 'fullname', 'created_at', 'updated_at')->where($where)->get()->toArray();
 
-         }
 
-         if (!empty($data)) {
 
-             return json_encode(['data'=>$data, 'code'=>1]);
 
-         }
 
-         return json_encode(['msg'=>'<tr><td colspan="5">暂无数据</td></tr>', 'code'=>0]);
 
-     }
 
-     /**发送站内信
 
-      * @param Request $request
 
-      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
 
-      */
 
-     public function sendSys(Request $request)
 
-     {
 
-         $psm = new Pms();
 
-         $data = $request->except(['_token']);
 
-         $company = Company::where('id', $data['uid'])->first();
 
-         $psm->utype = 1;
 
-         $psm->msgtype = 1;
 
-         $psm->msgfromuid = Admin::user()->id;
 
-         $psm->msgfrom = Admin::user()->username;
 
-         $psm->msgtoname = $company->username;
 
-         $psm->msgtouid = $company->id;
 
-         $psm->message = $data['body'];
 
-         if ($psm->save()) {
 
-              admin_toastr('站内信发送成功', 'success');
 
-              return redirect(route("company.index"));
 
-         }
 
-         admin_toastr('站内信发送失败', 'error');
 
-         return back();
 
-     }
 
-     public function sendEmail(Request $request)
 
-     {
 
-         $email = $request->email;
 
-         $title = $request->title;
 
-         $body = $request->body;
 
-         $this->emailService->sendMail($email, EmailService::TEMPLATE_SEND_CONTENT, ['title'=>$title], ['content'=>$body]);
 
-             admin_toastr('邮件发送成功', 'success');
 
-             return back();
 
-     }
 
-     public function sendSms(Request $request)
 
-     {
 
-         $mobile = $request->mobile;
 
-         $body = $request->body;
 
-         $sms_id = $request->sms_id;
 
- //        $sms_alias = $this->smsTemplateRepository->findWhere(['id'=>$sms_id], ['alias']);
 
-         $SmsRule = SmsRule::where('alias', $sms_id)->first();
 
-         if (isset($SmsRule->status) && !empty($SmsRule->status)) {
 
-             $this->smsService->sendSms($mobile, $sms_id, ['content'=>$body]);
 
-             admin_toastr('短信发送成功', 'success');
 
-         } else {
 
-             admin_toastr('请先开启短信-短信规则配置!', 'error');
 
-         }
 
-         return back();
 
-     }
 
- }
 
 
  |