|
@@ -0,0 +1,1437 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Admin\Controllers\Company;
|
|
|
+
|
|
|
+use Aix\Sms\Contracts\Smser;
|
|
|
+use App\Admin\Exports\Company\CompanyExport;
|
|
|
+use App\Admin\Extensions\Form\ValidateForm;
|
|
|
+use App\Admin\Extensions\Tools\DialogTool;
|
|
|
+use App\Http\Controllers\Controller;
|
|
|
+use App\Models\Admin\AdminRole;
|
|
|
+use App\Models\AuditReason;
|
|
|
+use App\Models\Category;
|
|
|
+use App\Models\CategoryDistrict;
|
|
|
+use App\Models\Company;
|
|
|
+use App\Models\CompanyConsultant;
|
|
|
+use App\Models\CompanyImg;
|
|
|
+use App\Models\Consultant;
|
|
|
+use App\Models\Jobs;
|
|
|
+use App\Models\MembersChargeLog;
|
|
|
+use App\Models\MembersPoint;
|
|
|
+use App\Models\MembersSetmeal;
|
|
|
+use App\Models\Setmeal;
|
|
|
+use App\Models\Subsite;
|
|
|
+use App\Models\SubsiteJob;
|
|
|
+use App\Repositories\CompanyRepository;
|
|
|
+use App\Repositories\JobsContactRepository;
|
|
|
+use App\Repositories\JobsRepository;
|
|
|
+use App\Repositories\MemberPointRepository;
|
|
|
+use App\Repositories\MembersChargeLogRepository;
|
|
|
+use App\Repositories\MemberSetmealRepository;
|
|
|
+use App\Repositories\SubsiteJobRepository;
|
|
|
+use App\Repositories\SubsiteRepository;
|
|
|
+use App\Repositories\TplRepository;
|
|
|
+use App\Repositories\Jobfair\JobfairCompanyRepository;
|
|
|
+use App\Repositories\Jobfair\JobfairJobRepository;
|
|
|
+use App\Repositories\Jobfair\JobfairJobsContactRepository;
|
|
|
+use App\Repositories\Jobfair\JobfairPutJobRepository;
|
|
|
+use App\Services\Common\PmsService;
|
|
|
+use App\Services\Common\SmsService;
|
|
|
+use App\Services\Common\TaskService;
|
|
|
+use App\Services\Company\ServiceService;
|
|
|
+use App\Services\SubsiteService;
|
|
|
+use App\Validators\Rules\MobileRule;
|
|
|
+use Encore\Admin\Auth\Permission;
|
|
|
+use Encore\Admin\Controllers\HasResourceActions;
|
|
|
+use Encore\Admin\Facades\Admin;
|
|
|
+use Encore\Admin\Form;
|
|
|
+use Encore\Admin\Grid;
|
|
|
+use Encore\Admin\Layout\Content;
|
|
|
+use Encore\Admin\Show;
|
|
|
+use Encore\Admin\Widgets\Table;
|
|
|
+use function foo\func;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use Illuminate\Support\Facades\Cache;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+use Illuminate\Validation\Rule;
|
|
|
+use Illuminate\Support\Facades\Validator;
|
|
|
+
|
|
|
+
|
|
|
+class CompanyController extends Controller
|
|
|
+{
|
|
|
+ use HasResourceActions;
|
|
|
+
|
|
|
+ public $taskService;
|
|
|
+ public $companyRepository;
|
|
|
+ public $pmsService;
|
|
|
+ public $subsiteService;
|
|
|
+ public $jobsRepository;
|
|
|
+ public $subsiteJobRepository;
|
|
|
+ public $membersChargeLogRepository;
|
|
|
+ public $memberSetmealRepository;
|
|
|
+ public $jobsContactRepository;
|
|
|
+ public $memberPointRepository;
|
|
|
+ public $tplRepository;
|
|
|
+ public $jobfairCompanyRepository;
|
|
|
+ public $jobfairJobRepository;
|
|
|
+ public $jobfairJobsContactRepository;
|
|
|
+ public $jobfairPutJobRepository;
|
|
|
+ /**
|
|
|
+ * CompanyController constructor.
|
|
|
+ * @param $companyRepository
|
|
|
+ * @param $pmsService
|
|
|
+ * @param $subsiteService
|
|
|
+ * @param $jobsRepository
|
|
|
+ * @param $subsiteJobRepository
|
|
|
+ * @param $taskService
|
|
|
+ * @param $membersChargeLogRepository
|
|
|
+ * @param $memberSetmealRepository
|
|
|
+ * @param $jobsContactRepository
|
|
|
+ * @param $subsiteRepository
|
|
|
+ * @param $memberPointRepository
|
|
|
+ * @param $jobfairCompanyRepository
|
|
|
+ * @param $jobfairJobRepository
|
|
|
+ * @param $jobfairJobsContactRepository
|
|
|
+ * @param $jobfairPutJobRepository
|
|
|
+ * @param $smsService
|
|
|
+ * @param $tplRepository
|
|
|
+ */
|
|
|
+ public function __construct(
|
|
|
+ TaskService $taskService,
|
|
|
+ MemberPointRepository $memberPointRepository,
|
|
|
+ SmsService $smsService,
|
|
|
+ SubsiteRepository $subsiteRepository,
|
|
|
+ JobsContactRepository $jobsContactRepository,
|
|
|
+ MemberSetmealRepository $memberSetmealRepository,
|
|
|
+ MembersChargeLogRepository $membersChargeLogRepository,
|
|
|
+ JobsRepository $jobsRepository,
|
|
|
+ SubsiteJobRepository $subsiteJobRepository,
|
|
|
+ SubsiteService $subsiteService,
|
|
|
+ CompanyRepository $companyRepository,
|
|
|
+ PmsService $pmsService,
|
|
|
+ TplRepository $tplRepository,
|
|
|
+ JobfairCompanyRepository $jobfairCompanyRepository,
|
|
|
+ JobfairJobRepository $jobfairJobRepository,
|
|
|
+ JobfairJobsContactRepository $jobfairJobsContactRepository,
|
|
|
+ JobfairPutJobRepository $jobfairPutJobRepository
|
|
|
+ )
|
|
|
+ {
|
|
|
+ $this->taskService = $taskService;
|
|
|
+ $this->companyRepository = $companyRepository;
|
|
|
+ $this->pmsService = $pmsService;
|
|
|
+ $this->subsiteService = $subsiteService;
|
|
|
+ $this->jobsRepository = $jobsRepository;
|
|
|
+ $this->subsiteJobRepository = $subsiteJobRepository;
|
|
|
+ $this->membersChargeLogRepository = $membersChargeLogRepository;
|
|
|
+ $this->memberSetmealRepository = $memberSetmealRepository;
|
|
|
+ $this->jobsContactRepository = $jobsContactRepository;
|
|
|
+ $this->subsiteRepository = $subsiteRepository;
|
|
|
+ $this->smsService = $smsService;
|
|
|
+ $this->memberPointRepository = $memberPointRepository;
|
|
|
+ $this->tplRepository = $tplRepository;
|
|
|
+ $this->jobfairCompanyRepository = $jobfairCompanyRepository;
|
|
|
+ $this->jobfairJobRepository = $jobfairJobRepository;
|
|
|
+ $this->jobfairJobsContactRepository = $jobfairJobsContactRepository;
|
|
|
+ $this->jobfairPutJobRepository = $jobfairPutJobRepository;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Index interface.
|
|
|
+ *
|
|
|
+ * @param Content $content
|
|
|
+ * @return Content
|
|
|
+ */
|
|
|
+ public function index(Content $content)
|
|
|
+ {
|
|
|
+ $grid=$this->grid()->render();
|
|
|
+ return $content
|
|
|
+ ->header('企业会员')
|
|
|
+ ->description('列表')
|
|
|
+ ->body(view('admin.company.index')->with('grid', $grid));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Show interface.
|
|
|
+ *
|
|
|
+ * @param mixed $id
|
|
|
+ * @param Content $content
|
|
|
+ * @return Content
|
|
|
+ */
|
|
|
+ public function show($id, Content $content)
|
|
|
+ {
|
|
|
+ return $content
|
|
|
+ ->header('企业会员')
|
|
|
+ ->description('详情')
|
|
|
+ ->body($this->detail($id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Edit interface.
|
|
|
+ *
|
|
|
+ * @param mixed $id
|
|
|
+ * @param Content $content
|
|
|
+ * @return Content
|
|
|
+ */
|
|
|
+ public function edit($id, Content $content)
|
|
|
+ {
|
|
|
+ return $content
|
|
|
+ ->header('企业会员')
|
|
|
+ ->description('编辑')
|
|
|
+ ->body($this->editForm($id)->edit($id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Create interface.
|
|
|
+ *
|
|
|
+ * @param Content $content
|
|
|
+ * @return Content
|
|
|
+ */
|
|
|
+ public function create(Content $content)
|
|
|
+ {
|
|
|
+ Permission::check('company_manager_create');
|
|
|
+ return $content
|
|
|
+ ->header('企业会员')
|
|
|
+ ->description('新增')
|
|
|
+ ->body($this->createForm());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Make a grid builder.
|
|
|
+ *
|
|
|
+ * @return Grid
|
|
|
+ */
|
|
|
+ protected function grid()
|
|
|
+ {
|
|
|
+ $grid = new Grid(new Company);
|
|
|
+ $grid->model()->when(get_subsite_id()>0, function ($query) {
|
|
|
+ $query->where('subsite_id', get_subsite_id());
|
|
|
+ })->when(Admin::user()->isRole(AdminRole::$consultantSlug), function ($query) {
|
|
|
+ $query->whereHas('companyConsultant', function ($query) {
|
|
|
+ $query->where('consultant_id', isset(Admin::user()->consultant->id) ? Admin::user()->consultant->id : -1);
|
|
|
+ });
|
|
|
+ $query->whereHas("membersSetmeal", function ($query) {
|
|
|
+ $query->where('subsite_id', get_subsite_id());
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ })->orderByRaw("field(audit,2,1,3,0)")->orderBy('id', 'desc');
|
|
|
+
|
|
|
+ $grid->id('ID');
|
|
|
+ $grid->companyname('公司名称')->display(function ($companyname) {
|
|
|
+ $html='';
|
|
|
+ if ($this->logo) {
|
|
|
+ $html.='<span style="padding-left:5px;color: #3c8dbc;" class="vtip" title="<img src=\''.upload_asset($this->logo).'\' width=120 height=120>"><i class="fa fa-file-image-o"></i></span>';
|
|
|
+ }
|
|
|
+ $html .= "<a href=". route(url_rewrite('AIX_companyshow'), ['id'=>$this->id])." target='_blank'>".$companyname."</a>";
|
|
|
+ return $html;
|
|
|
+ })->width(200);
|
|
|
+ $grid->certificate_img('营业执照')->display(function ($certificate_img) {
|
|
|
+ if ($certificate_img) {
|
|
|
+ return '<span style="padding-left:5px;color: #3c8dbc;" class="show-img"><img src=\''.upload_asset($certificate_img).'\' width=22 height=26></span>';
|
|
|
+ } else {
|
|
|
+ return "未上传";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $grid->audit('企业认证')->display(function ($audit) {
|
|
|
+ switch ($audit) {
|
|
|
+ case 1:
|
|
|
+ return '<span style="color: green">认证通过<a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a></span>';
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ return '<span style="color: red">待认证</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ return '<span style="color: black">认证未通过</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
|
|
|
+ break;
|
|
|
+ case 0:
|
|
|
+ return '<span style="color: gray">未认证</span><a class="logview" data-id='.$this->id.'><i class="fa fa-eye"></i></a>';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if(get_subsite_open()){
|
|
|
+ $grid->subsite_id('所属分站')->display(function ($subsite_id) {
|
|
|
+ if ($subsite_id == 0) {
|
|
|
+ return "总站";
|
|
|
+ } else {
|
|
|
+ $subsite = Subsite::findOrFail($subsite_id);
|
|
|
+ return $subsite->sitename;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = Consultant::get()->toArray();
|
|
|
+
|
|
|
+ if($result){
|
|
|
+ $consultant = Consultant::pluck('name','id')->toArray();
|
|
|
+ $grid->column('companyConsultant.consultant_id', '所属顾问')->display(function ($consultant_id) use($consultant) {
|
|
|
+ if (!isset($consultant_id)) {
|
|
|
+ return "未分配";
|
|
|
+ }
|
|
|
+ return isset($consultant[$consultant_id]) ? $consultant[$consultant_id] : '未分配';
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ $grid->address('公司地址');
|
|
|
+ $grid->created_at('注册时间');
|
|
|
+ $grid->refresh_time('刷新时间')->display(function ($refresh_time) {
|
|
|
+ return date('Y-m-d H:i:s', $refresh_time);
|
|
|
+ });
|
|
|
+
|
|
|
+ $grid->column('membersSetmeal.endtime','到期时间')->display(function ($endtime){
|
|
|
+ return $endtime;
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ $grid->column('membersSetmeal.setmeal_name', '套餐名称')->display(function ($setmeal_name) {
|
|
|
+ if (!$setmeal_name) {
|
|
|
+ return "--";
|
|
|
+ } else {
|
|
|
+ $setmeal_name=$setmeal_name=="年度会员" ? "年度会员vip" : $setmeal_name;
|
|
|
+ return $setmeal_name."<a class=\"setmealrecord\" data-id='{$this->id}'><i class=\"fa fa-eye\"></i></a>";
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ if (Admin::user()->can('company_export')) {
|
|
|
+ $grid->disableExport(false); //显示导出按钮
|
|
|
+ $grid->exporter(new CompanyExport()); //传入自己在第1步创建的导出类
|
|
|
+ }
|
|
|
+ $grid->filter(function ($filter) {
|
|
|
+ $filter->column(1/2, function ($filter) {
|
|
|
+ // 在这里添加字段过滤器
|
|
|
+ $filter->like('companyname', '企业名称');
|
|
|
+ $filter->equal('id', '企业ID');
|
|
|
+ $filter->like('username', '会员名称');
|
|
|
+ $filter->like('mobile', '手机');
|
|
|
+ $filter->like('address', '地址');
|
|
|
+
|
|
|
+ $filter->where(function ($query) {
|
|
|
+ $member_day=$this->input;
|
|
|
+
|
|
|
+ $query->whereHas('membersSetmeal', function ($query) use ($member_day) {
|
|
|
+ if($member_day==-1){
|
|
|
+ $query->whereRaw("members_setmeals.`endtime`<UNIX_TIMESTAMP(NOW())")
|
|
|
+ ->where('utype','=','1')
|
|
|
+ ->where('members_setmeals.endtime','!=','0');
|
|
|
+ }else{
|
|
|
+ $query->whereRaw("DATEDIFF(DATE_FORMAT(FROM_UNIXTIME(`members_setmeals`.`endtime`),'%Y-%m-%d'),NOW()) BETWEEN 0 AND {$member_day}")
|
|
|
+ ->where('expire','=','0')
|
|
|
+ ->where('utype','=','1');
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }, '套餐到期')->select(['3'=>"三天内",'7'=>'一周内','15'=>'半个月内','-1'=>'已经到期']);
|
|
|
+ });
|
|
|
+ $filter->column(1/2, function ($filter) {
|
|
|
+ $filter->equal('membersSetmeal.setmeal_id', '套餐类型')->select(Setmeal::get()->pluck('setmeal_name', 'id'));
|
|
|
+ $filter->equal('audit', '企业认证')->select(['1' => '认证通过', '2' => '待认证', '3' => '认证未通过','0'=>"未认证"]);
|
|
|
+ $subsite = Subsite::where('effective', 1)->select('id', 'sitename')->get();
|
|
|
+ $subsiteArr=[];
|
|
|
+ if ($subsite) {
|
|
|
+ $subsiteArr = $subsite->toArray();
|
|
|
+ $subsiteArr = array_column($subsiteArr, 'sitename', 'id');
|
|
|
+ }
|
|
|
+ $subsiteArr[0] = "总站";
|
|
|
+ ksort($subsiteArr);
|
|
|
+ if (get_subsite_id()== 0 && get_subsite_open()) {
|
|
|
+ $filter->equal('subsite_id', '所属分站')->select($subsiteArr);
|
|
|
+ }
|
|
|
+ $filter->like('email','邮箱');
|
|
|
+// $filter->equal('certificate_img_audit', '营业执照认证')->select(['1' => '已认证', '2' => '待认证', '3' => '认证未通过', '0' => '未认证']);
|
|
|
+ $filter->between('created_at', '注册时间')->datetime();
|
|
|
+ $result = Consultant::get()->toArray();
|
|
|
+ if($result){
|
|
|
+ if(get_subsite_id()==0){
|
|
|
+ $arr_con = Consultant::pluck('name','id');
|
|
|
+ }else{
|
|
|
+ $arr_con = Consultant::where('subsite_id', get_subsite_id())->pluck('name','id');
|
|
|
+ }
|
|
|
+ $filter->equal('companyConsultant.consultant_id','顾问')->select($arr_con);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ if (Admin::user()->can('company_manager_create')) {
|
|
|
+ $grid->disableCreateButton(false);
|
|
|
+ }
|
|
|
+ $grid->actions(function ($actions) {
|
|
|
+ if (Admin::user()->can('company_manager_bussiness')) {
|
|
|
+ $actions->append("<button class='btn btn-primary btn-xs business' id=".$actions->row['id'].">业务</button>");
|
|
|
+ }
|
|
|
+ if (Admin::user()->can('company_manager_audit')) {
|
|
|
+ $actions->append("<button class='btn btn-primary btn-xs jobaudit' data-code=".$actions->row['id'].">审核</button>");
|
|
|
+ }
|
|
|
+ if (Admin::user()->can('company_manager_edit')) {
|
|
|
+ $actions->disableEdit(false);
|
|
|
+ }
|
|
|
+ if (Admin::user()->can('company_manager_delete')) {
|
|
|
+ $actions->disableDelete(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $grid->tools(function (Grid\Tools $tools) {
|
|
|
+ $but = <<<EOT
|
|
|
+ <div class="btn-group" data-toggle="buttons">
|
|
|
+ <label class="btn btn-google btn-sm" id="update_password" title="重置密码">
|
|
|
+ <i class="fa fa-audio-description"></i>
|
|
|
+ <input type="radio" class="user-gender">重置密码
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+EOT;
|
|
|
+ if (Admin::user()->can('company_reset_password')) {
|
|
|
+ $tools->append($but);
|
|
|
+ }
|
|
|
+ if (Admin::user()->can('company_manager_delete')) {
|
|
|
+ $tools->batch(function (Grid\Tools\BatchActions $batch) {
|
|
|
+ $batch->disableDelete(false);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Admin::user()->can('company_manager_refresh')) {
|
|
|
+ $tools->append('<a class=\'btn btn-sm btn-primary btn-refresh\'><i class=\'fa fa-refresh\'></i>企业刷新排名</a>');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Admin::user()->can('company_manager_audit')) {
|
|
|
+ $form = new \Encore\Admin\Widgets\Form();
|
|
|
+ $form->action(route('company.audit'));
|
|
|
+
|
|
|
+ $form->radio('audit1', '审核状态')->options([1=>'审核通过', 3=>'审核未通过'])->default(1);
|
|
|
+ $states = [
|
|
|
+ 'on' => ['value' => 1, 'text' => '是', 'color' => 'success'],
|
|
|
+ 'off' => ['value' => 0, 'text' => '否', 'color' => 'danger'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $form->textarea('reason', '备注');
|
|
|
+ $form->html("<input type='checkbox' name='is_send' checked value='1'/>站内信通知");
|
|
|
+ $config = array(
|
|
|
+ 'button' => "企业审核",//添加的按钮文字
|
|
|
+ 'title' => "将所选企业",//弹窗标题
|
|
|
+ 'dialog_cancel' => "取消",//取消文字
|
|
|
+ 'dialog_ok' => "确认",//确认文字
|
|
|
+ 'is_batch' => true//是否批量操作,如果是批量操作则提交表单时会带上ids参数
|
|
|
+ );
|
|
|
+ $tools->append(new DialogTool($form, $config));
|
|
|
+ }
|
|
|
+
|
|
|
+ $consultant = <<<EOT
|
|
|
+ <div class="btn-group" data-toggle="buttons">
|
|
|
+ <label class="btn btn-google btn-sm" id="consultant" title="设置顾问">
|
|
|
+ <i class="fa fa-audio-description"></i>
|
|
|
+ <input type="radio" class="user-gender">设置顾问
|
|
|
+ </label>
|
|
|
+ </div>
|
|
|
+EOT;
|
|
|
+ $result = Consultant::get()->toArray();
|
|
|
+ if($result){
|
|
|
+ if (Admin::user()->can('company_manager_consultant')) {
|
|
|
+ $tools->append($consultant);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return $grid;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Make a show builder.
|
|
|
+ *
|
|
|
+ * @param mixed $id
|
|
|
+ * @return Show
|
|
|
+ */
|
|
|
+ protected function detail($id)
|
|
|
+ {
|
|
|
+ $show = new Show(Company::findOrFail($id));
|
|
|
+ $show->id('ID');
|
|
|
+ $show->username('用户名');
|
|
|
+ $show->mobile('联系电话');
|
|
|
+ $show->landline_tel('固定电话')->as(function ($landline_tel) {
|
|
|
+ if ($landline_tel == '--' || $landline_tel == '---') {
|
|
|
+ return '';
|
|
|
+ } else {
|
|
|
+ return $landline_tel;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $show->email('电子邮箱');
|
|
|
+ $show->contact('企业联系人');
|
|
|
+ $show->subsite_id('分站')->as(function ($subsite_id) {
|
|
|
+ if ($subsite_id == 0) {
|
|
|
+ return '总站';
|
|
|
+ } else {
|
|
|
+ $subsite_name = Subsite::findOrFail($subsite_id);
|
|
|
+ return $subsite_name->sitename;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $show->companyname('公司名称');
|
|
|
+ $show->short_name('公司简称');
|
|
|
+ $show->audit('审核状态')->as(function ($audit) {
|
|
|
+ switch ($audit) {
|
|
|
+ case 1:
|
|
|
+ return '审核通过';
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ return '待审核';
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ return '审核未通过';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $show->nature('企业性质')->as(function ($nature) {
|
|
|
+ return get_category($nature);
|
|
|
+ });
|
|
|
+ $show->trade('企业行业')->as(function ($trade) {
|
|
|
+ return get_category($trade);
|
|
|
+ });
|
|
|
+ $show->district('所在地区')->as(function ($district) {
|
|
|
+ return get_district_cn($district);
|
|
|
+ });
|
|
|
+ $show->scale('企业规模')->as(function ($scale) {
|
|
|
+ return get_category($scale);
|
|
|
+ });
|
|
|
+ $show->registered('注册资金');
|
|
|
+ $show->currency('资金形式');
|
|
|
+ $show->tag('企业福利')->as(function ($tag) {
|
|
|
+ foreach ($tag as $key => $val) {
|
|
|
+ $tag_cn[] = get_tag_cn($val);
|
|
|
+ }
|
|
|
+ return implode('+', $tag_cn);
|
|
|
+ });
|
|
|
+
|
|
|
+ $show->website('企业网站');
|
|
|
+ $show->address('企业地址');
|
|
|
+ $show->contents('企业详情');
|
|
|
+ $show->logo('企业Logo')->image();
|
|
|
+ $show->created_at('Created at');
|
|
|
+ $show->updated_at('Updated at');
|
|
|
+
|
|
|
+ return $show;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Make a form builder.
|
|
|
+ *
|
|
|
+ * @return Form
|
|
|
+ */
|
|
|
+ protected function createForm()
|
|
|
+ {
|
|
|
+ Permission::check('company_manager_create');
|
|
|
+ $form = new ValidateForm(new Company);
|
|
|
+
|
|
|
+ $form->tab('用户信息', function ($form) {
|
|
|
+ $form->text('username', '用户名')->rules('required|between:6,31|regex:/^[a-zA-Z][a-zA-Z0-9]{5,16}+$/|unique:companys', [
|
|
|
+ 'required' => '请填写会员名',
|
|
|
+ 'between' => '会员名长度为6~30个字符',
|
|
|
+ 'regex' => '会员名为字母或字母+数字',
|
|
|
+ 'unique' => '会员名已存在'
|
|
|
+ ])->setWidth(3)->setMustMark();
|
|
|
+ $form->mobile('mobile', '手机号码')->rules('required|unique:companys', [
|
|
|
+ 'required'=>'请填写手机号',
|
|
|
+ 'unique'=>'手机号已经存在'
|
|
|
+ ])->setWidth(3)->setMustMark();
|
|
|
+ $form->radio('mobile_audit','手机认证')->options([1=>'认证通过',0=>'未认证'])->default(0);
|
|
|
+ $form->text('landline_tel', '固定号码')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)');
|
|
|
+ $form->text('email', 'email')->rules('required|regex:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/|unique:companys', [
|
|
|
+ 'required' => 'email为必填信息',
|
|
|
+ 'regex' => 'email格式不正确',
|
|
|
+ 'unique' => 'email已存在'
|
|
|
+ ])->setWidth(3)->setMustMark();
|
|
|
+ $form->radio('email_audit','邮箱认证')->options([1=>'认证通过',0=>'未认证'])->default(0);
|
|
|
+ $form->text('contact', '企业联系人')->rules('required', [
|
|
|
+ 'required'=>'请填写企业联系人'
|
|
|
+ ])->setWidth(3)->setMustMark();
|
|
|
+
|
|
|
+ $form->password('password', '密码')->rules('required|confirmed|between:6,16', [
|
|
|
+ 'required' => '密码为必填信息',
|
|
|
+ 'between' => '密码长度要求为6~16'
|
|
|
+ ])->setWidth(3)->setMustMark();
|
|
|
+
|
|
|
+ $form->password('password_confirmation', '确认密码')->rules('required|between:6,16')->setWidth(3)->default(function ($form) {
|
|
|
+ return $form->model()->password;
|
|
|
+ })->setMustMark();
|
|
|
+ $form->ignore('password_confirmation');
|
|
|
+
|
|
|
+ if ($this->subsiteService->getSiteId() == 0 && get_subsite_open()) {
|
|
|
+ $subsiteArr = $this->subsiteService->getAllSubsite();
|
|
|
+ $subData = array_column($subsiteArr, 'sitename', 'id');
|
|
|
+ $form->radio('subsite_id', '分站')->options($subData)->default($this->subsiteService->getSiteId());
|
|
|
+ }
|
|
|
+ $form->switch('user_status', '账号状态')->default(1);
|
|
|
+ })->tab('企业信息', function ($form) {
|
|
|
+
|
|
|
+ $form->text('companyname', '企业名称')->rules('required|unique:companys', ['required'=>'请填写企业名称','unique' => '企业名称已经存在'])->setWidth(3)->setMustMark();
|
|
|
+ $form->text('short_name', '企业简称')->rules(
|
|
|
+ [
|
|
|
+ 'required',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required' => '企业简称必填',
|
|
|
+ ]
|
|
|
+ )->setWidth(3)->setMustMark()->attribute(['maxlength'=>25])->help('请填写25个字符以内');
|
|
|
+ $form->text('organization_code', '社会统一信用码')->rules(
|
|
|
+ [
|
|
|
+ 'required','unique:companys','alpha_num','between:15,18'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required'=>'请填写企业社会统一信用码',
|
|
|
+ 'unique'=>'企业社会统一信用码已存在',
|
|
|
+ 'alpha_num'=>'企业社会统一信用码必须是字母或数字',
|
|
|
+ 'between'=>'企业社会统一信用码长度是15-18位',
|
|
|
+ ]
|
|
|
+ )->setWidth(3)->setMustMark();
|
|
|
+ //企业性质给定数组
|
|
|
+ $com_type = Category::categoryType('AIX_company_type');
|
|
|
+ $form->radio('nature', '企业性质')->options($com_type)->default(key($com_type))->setMustMark();
|
|
|
+ $form->select('trade', '所属行业')->options(Category::categoryType('AIX_trade'))->setWidth(3)->rules('required', ['required'=>'请选择相应的企业所属行业'])->setMustMark();
|
|
|
+ $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属省份'])->setMustMark();
|
|
|
+ $form->select('city', '所属城市')->setWidth(3)->load('area', admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属城市'])->setMustMark();
|
|
|
+ //$form->select('area', '所属县区')->setWidth(3)->rules('required', ['required'=>'请选择相应的企业所属县区'])->setMustMark();
|
|
|
+ $form->select('scale', '公司规模')->options(Category::categoryType('AIX_scale'))->setWidth(3)->rules('required', ['required'=>'请选择相应的企业公司规模'])->setMustMark();
|
|
|
+ $form->number('registered', '注册资金')->setWidth(3)->min(0);
|
|
|
+ $form->radio('currency', '资金类型')->options(['万人民币' => '万人民币', '万美元' => '万美元'])->default('万人民币');
|
|
|
+ $form->multipleSelect('tag', '企业福利')->options(Category::categoryType('AIX_jobtag'));
|
|
|
+ $form->url('website', '公司网站')->setWidth(3);
|
|
|
+ $form->text('address', '公司地址')->setWidth(6);
|
|
|
+ $form->text('legal', '公司法人姓名')->setWidth(6);
|
|
|
+ $form->text('legal_idcard', '公司法人身份证')->setWidth(6);
|
|
|
+ $form->textarea('contents', '公司介绍')->rows(10)->attribute(['maxlength'=>2000])->setMustMark();
|
|
|
+ })->tab('证照信息', function ($form) {
|
|
|
+ $form->image('logo', '企业logo')->uniqueName()->setWidth(3);
|
|
|
+ $form->image('certificate_img', '营业执照')->setWidth(3);
|
|
|
+ })->tab('套餐信息', function ($form) {
|
|
|
+ $form->radio('regpoints', '赠送积分')->options([0=>'不赠送', 1=>'赠送' ])->default('0');
|
|
|
+ $form->number('points', '赠送数量')->min(0);
|
|
|
+ $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
|
|
|
+ $form->radio('setmeal_id', '会员套餐')->options($setmeal)->default(config('aix.companyset.setmeal_com.setmeal_com_set.reg_service'));
|
|
|
+ $form->switch('is_money', '是否收费');
|
|
|
+ $form->number('amount', '收费金额')->min(0);
|
|
|
+ });
|
|
|
+ return $form;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function store(Request $request)
|
|
|
+ {
|
|
|
+ $data = $this->createForm()->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
|
|
|
+ if($data['legal_idcard'] && !isCreditNo($data['legal_idcard'])){
|
|
|
+ admin_toastr('法人代表身份证格式不正确', 'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ $res1= [];
|
|
|
+ $res = [];
|
|
|
+ $res2 = [];
|
|
|
+ foreach ($data as $key => $val) {
|
|
|
+ if ($key == 'regpoints') {
|
|
|
+ $res1['regpoints'] = $val;
|
|
|
+ } else if ($key == 'points') {
|
|
|
+ $res1['points'] = $val;
|
|
|
+ } else if ($key == 'setmeal_id') {
|
|
|
+ $res2['setmeal_id'] = $val;
|
|
|
+ } else if ($key == "is_money") {
|
|
|
+ $res2['is_money'] = $val;
|
|
|
+ } else if ($key == 'amount') {
|
|
|
+ $res2['amount'] = $val;
|
|
|
+ } else {
|
|
|
+ if ($key == 'password') {
|
|
|
+ $res[$key] = bcrypt($val);
|
|
|
+ } else if ($key == 'tag') {
|
|
|
+ $res[$key] = $val;
|
|
|
+ } elseif ($key == 'province') {
|
|
|
+ $res['district'] = $val;
|
|
|
+ } elseif ($key == 'city') {
|
|
|
+ $res['district'] = $res['district'].".".$val;
|
|
|
+ } elseif ($key == 'area') {
|
|
|
+ $res['district'] = $res['district'].".".$val;
|
|
|
+ } elseif ($key =='logo') {
|
|
|
+ $res[$key] = $val;
|
|
|
+ } elseif ($key == 'certificate_img') {
|
|
|
+ $res[$key] = 'company/certificate/'.$val;
|
|
|
+ } else {
|
|
|
+ $res[$key] = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isset($res['certificate_img'])) {
|
|
|
+ $res['audit'] = 2;
|
|
|
+ }
|
|
|
+ $res['district_cn'] =get_district_cn($res['district']);
|
|
|
+ $res['subsite_id'] = $this->subsiteService->getSiteId();
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $res['reg_time'] = time();
|
|
|
+ $res['refresh_time'] = time();
|
|
|
+ $res['reg_ip'] = ip2long($request->getClientIp());
|
|
|
+ $res['last_login_ip'] = ip2long($request->getClientIp());
|
|
|
+ $res['last_login_time'] = time();
|
|
|
+ $res['reg_address'] = getAddressByIp($request->getClientIp());
|
|
|
+ $res['setmeal_id'] = $res2['setmeal_id'];
|
|
|
+ $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
|
|
|
+ $res['setmeal_name'] = $setmeal[$res2['setmeal_id']];
|
|
|
+ $getDefaultTpl =$this->tplRepository->getDefaultTpl(['tpl_type'=>1,'display'=>1,'default'=>1]);
|
|
|
+ if($getDefaultTpl){
|
|
|
+ if($getDefaultTpl->blade_name){
|
|
|
+ $res['tpl'] = $getDefaultTpl->blade_name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!$uid = $this->companyRepository->create($res)) {
|
|
|
+ throw new \Exception('新增失败');
|
|
|
+ }
|
|
|
+ $role_id = $uid->id;
|
|
|
+ $taskdata = $this->taskService->doTask(17, $role_id, 1);
|
|
|
+ if ($res1['regpoints']) {
|
|
|
+ $pointData['uid'] = $role_id;
|
|
|
+ $pointData['utype'] = 1;
|
|
|
+ $pointData['points'] = $res1['points'];
|
|
|
+ if (!$ids = MembersPoint::insert($pointData)) {
|
|
|
+ throw new \Exception('企业增加积分失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $set_data = Setmeal::select('id', 'setmeal_name', 'days', 'expense', 'jobs_meanwhile', 'jobfair_num', 'refresh_jobs_free', 'download_resume', 'download_resume_max', 'added', 'setmeal_img', 'show_apply_contact', 'is_free', 'discount_download_resume', 'discount_sms', 'discount_stick', 'discount_emergency', 'discount_tpl', 'discount_auto_refresh_jobs')->findOrFail($res2['setmeal_id'])->toArray();
|
|
|
+ $createData = $set_data;
|
|
|
+ $createData['uid'] = $role_id;
|
|
|
+ $createData['utype'] = 1;
|
|
|
+ $createData['setmeal_id'] = $set_data['id'];
|
|
|
+ $createData['starttime'] = time();
|
|
|
+ unset($createData['id']);
|
|
|
+ if (!MembersSetmeal::insert($createData)) {
|
|
|
+ throw new \Exception('企业增加套餐失败');
|
|
|
+ }
|
|
|
+ $amount = 0;
|
|
|
+ if ($res2['is_money']) {
|
|
|
+ $amount = $res2['amount'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $logData['log_uid'] = $role_id;
|
|
|
+ $logData['log_utype'] = 1;
|
|
|
+ $logData['log_username'] = $res['username'];
|
|
|
+ $logData['log_value'] = "操作人:".Admin::user()->username.",说明:创建会员:{$res['username']},(+{$taskdata['data']['points']})积分,收到{$amount}元。";
|
|
|
+ $logData['log_amount'] = $amount;
|
|
|
+ $logData['log_ismoney'] = $res2['is_money'];
|
|
|
+ $logData['log_type'] = 2;
|
|
|
+ $logData['log_mode'] = 1;
|
|
|
+ $logData['created_at'] = date('Y-m-d H:i:s', time());
|
|
|
+ $logData['updated_at'] = date('Y-m-d H:i:s', time());
|
|
|
+ if (!$this->membersChargeLogRepository->create($logData)) {
|
|
|
+ throw new \Exception('企业增加记录失败');
|
|
|
+ }
|
|
|
+ $this->smsService->sendSms($res['mobile'], Smser::TEMPLATE_SMS_QUICK_REGISTER, ['username'=>$data['username'],'password'=>$data['password']]);
|
|
|
+ DB::commit();
|
|
|
+ admin_toastr('企业新增成功', 'success');
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ DB::rollback();
|
|
|
+ admin_toastr($e->getMessage(), 'error');
|
|
|
+ }
|
|
|
+ return redirect(route("company.index"));
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function editForm($id)
|
|
|
+ {
|
|
|
+ Permission::check('company_manager_edit');
|
|
|
+ $form = new ValidateForm(new Company);
|
|
|
+ $form->display('id')->setWidth(3);
|
|
|
+ $district = $this->companyRepository->find($id)->toArray();
|
|
|
+ if ($district) {
|
|
|
+ $districtArr = string_to_array('.', $district['district']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $form->tab('用户信息', function ($form) use ($id,$district) {
|
|
|
+ $form->text('username', '用户名')
|
|
|
+ ->rules(
|
|
|
+ [
|
|
|
+ 'required',
|
|
|
+ 'between:6,31|regex:/^[a-zA-Z][a-zA-Z0-9]{5,16}+$/',
|
|
|
+ Rule::unique('companys')->ignore($id),
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required' => '会员名为必填信息',
|
|
|
+ 'between' => '会员名长度为6~30个字符',
|
|
|
+ 'regex' => '会员名为字母或字母+数字',
|
|
|
+ 'unique' => '会员名已存在'
|
|
|
+ ]
|
|
|
+ )->setWidth(3)->setMustMark();
|
|
|
+ $form->mobile('mobile', '手机号码')->help('手机、固话二选一')->setWidth(3);
|
|
|
+ $form->radio('mobile_audit','手机认证')->options([1=>'认证通过',0=>'未认证'])->default($district['mobile_audit']);
|
|
|
+ $form->text('landline_tel', '固定号码')->setWidth(3)->help('区号-号码-分机号(以“-”分隔)');
|
|
|
+ $form->email('email', 'email')
|
|
|
+ ->rules(
|
|
|
+ [
|
|
|
+ 'required',
|
|
|
+ 'regex:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/',
|
|
|
+ Rule::unique('companys')->ignore($id),
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required' => 'email为必填信息',
|
|
|
+ 'regex' => 'email格式不正确',
|
|
|
+ 'unique' => 'email已存在',
|
|
|
+ ]
|
|
|
+ )->setWidth(3);
|
|
|
+ $form->radio('email_audit','邮箱认证')->options([1=>'认证通过',0=>'未认证'])->default($district['email_audit']);
|
|
|
+ $form->text('contact', '企业联系人')->setWidth(3)->setMustMark();
|
|
|
+ if ($this->subsiteService->getSiteId() == 0 && get_subsite_open()) {
|
|
|
+ $subsiteArr = $this->subsiteService->getAllSubsite();
|
|
|
+ $subData = array_column($subsiteArr, 'sitename', 'id');
|
|
|
+ $form->radio('subsite_id', '分站')->options($subData);
|
|
|
+ }
|
|
|
+ $form->switch('user_status', '账号状态');
|
|
|
+ })->tab('企业信息', function ($form) use ($id, $districtArr) {
|
|
|
+ if (config('aix.companyset.comset.other_set.company_repeat') == 1) {
|
|
|
+ $form->text('companyname', '企业名称')->rules(
|
|
|
+ [
|
|
|
+ 'required',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required' => '企业名称必填',
|
|
|
+ ]
|
|
|
+ )->setWidth(3)->setMustMark();
|
|
|
+ } else {
|
|
|
+ $form->text('companyname', '企业名称')->rules(
|
|
|
+ [
|
|
|
+ 'required',
|
|
|
+ Rule::unique('companys')->ignore($id),
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required' => '企业名称必填',
|
|
|
+ 'unique' => '公司名已经存在',
|
|
|
+ ]
|
|
|
+ )->setWidth(3)->setMustMark();
|
|
|
+ }
|
|
|
+
|
|
|
+ $form->text('short_name', '企业简称')->rules(
|
|
|
+ [
|
|
|
+ 'required',
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required' => '企业简称必填',
|
|
|
+ ]
|
|
|
+ )->setWidth(3)->setMustMark()->attribute(['maxlength'=>25])->help('请填写25个字符以内');
|
|
|
+ $form->text('organization_code', '社会统一信用码')->setWidth(3)->rules(
|
|
|
+ [
|
|
|
+ 'required',
|
|
|
+ Rule::unique('companys')->ignore($id),
|
|
|
+ 'alpha_num','between:15,18'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'required' => '请填写社会统一信用码',
|
|
|
+ 'unique' => '社会统一信用码已经存在',
|
|
|
+ 'alpha_num'=>'企业社会统一信用码必须是字母或数字',
|
|
|
+ 'between'=>'企业社会统一信用码长度是15-18位',
|
|
|
+ ]
|
|
|
+ )->setMustMark();
|
|
|
+ //企业性质给定数组
|
|
|
+ $nature = Category::categoryType('AIX_company_type');
|
|
|
+ $form->radio('nature', '企业性质')->options($nature)->default(key($nature))->rules(['required'], ['required'=>'请选择相应的企业性质'])->setMustMark();
|
|
|
+ $form->select('trade', '所属行业')->options(Category::categoryType('AIX_trade'))->setWidth(3)->rules('required', ['required'=>'请选择相应的企业所属行业'])->setMustMark();
|
|
|
+ //单位性质
|
|
|
+// $unit_character = Category::categoryType('AIX_company_type');
|
|
|
+// $form->select('unit_character', '单位性质')->options($unit_character)->setWidth(3)->rules('required', ['required'=>'请选择相应的单位性质'])->setMustMark();
|
|
|
+// //产业类别
|
|
|
+// $industry = Category::categoryType('AIX_cylb');
|
|
|
+// $form->select('industry', '产业类别')->options($industry)->setWidth(3)->rules('required', ['required'=>'请选择相应的产业类别'])->setMustMark();
|
|
|
+// //经济类型
|
|
|
+// $economy = Category::categoryType('AIX_jjlx');
|
|
|
+// $form->select('economy', '经济类型')->options($economy)->setWidth(3)->rules('required', ['required'=>'请选择相应的经济类型'])->setMustMark();
|
|
|
+
|
|
|
+ if (!empty($districtArr)) {
|
|
|
+ $form->select('province', '所属省份')->default(isset($districtArr[0])?$districtArr[0]:0)->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属省份'])->setMustMark();
|
|
|
+ $form->select('city', '所属城市')->default(isset($districtArr[1])?$districtArr[1]:0)->options(CategoryDistrict::categoryDis(isset($districtArr[0])?$districtArr[0]:0))->setWidth(3)->load('area', admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属城市'])->setMustMark();
|
|
|
+ //$form->select('area', '所属县区')->default(isset($districtArr[2])?$districtArr[2]:0)->options(CategoryDistrict::categoryDis(isset($districtArr[1])?$districtArr[1]:0))->setWidth(3)->setMustMark();
|
|
|
+ } else {
|
|
|
+ $form->select('province', '所属省份')->options(CategoryDistrict::List()->pluck('name', 'id'))->setWidth(3)->load('city', admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属省份'])->setMustMark();
|
|
|
+ $form->select('city', '所属城市')->setWidth(3)->load('area',admin_base_path("/sys/category/categoryDis"))->rules('required', ['required'=>'请选择相应的企业所属城市'])->setMustMark();
|
|
|
+ //$form->select('area', '所属县区')->default(0)->setWidth(3)->setMustMark();
|
|
|
+ }
|
|
|
+
|
|
|
+ $form->select('scale', '公司规模')->options(Category::categoryType('AIX_scale'))->setWidth(3)->setMustMark();
|
|
|
+ $form->number('registered', '注册资金')->setWidth(3);
|
|
|
+ $form->radio('currency', '资金类型')->options(['万人民币' => '万人民币', '万美元' => '万美元'])->default('万人民币');
|
|
|
+ $form->multipleSelect('tag', '企业福利')->options(Category::categoryType('AIX_jobtag'))->setWidth(3);
|
|
|
+ $form->url('website', '公司网站')->setWidth(3);
|
|
|
+ $form->text('address', '公司地址')->setWidth(4);
|
|
|
+ $form->text('legal', '公司法人姓名')->setWidth(6);
|
|
|
+ $form->text('legal_idcard', '公司法人身份证')->setWidth(6);
|
|
|
+ $form->textarea('contents', '公司介绍')->attribute(['maxlength'=>2000])->setMustMark()->setWidth(4)->help('请输入2000字以内公司介绍');
|
|
|
+ })->tab('证照信息', function ($form) {
|
|
|
+ $form->image('logo', '企业logo')->uniqueName()->setWidth(3);
|
|
|
+ $form->image('certificate_img', '营业执照')->setWidth(3);
|
|
|
+ });
|
|
|
+
|
|
|
+ $form->hidden('regpoints', '管理积分')->options([0=>'减少', 1=>'增加' ])->default('1');
|
|
|
+ $form->hidden('points', '赠送数量')->default(0);
|
|
|
+
|
|
|
+ $form->hidden('is_money', '是否收费');
|
|
|
+ $form->hidden('amount', '收费金额');
|
|
|
+ $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
|
|
|
+
|
|
|
+ empty(\request('setmeal_id')) ? request()->offsetSet('setmeal_id', key($setmeal)) : "" ;
|
|
|
+ $form->hidden("setmeal_id");
|
|
|
+
|
|
|
+
|
|
|
+ return $form;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function update($id,ServiceService $serviceService,CompanyRepository $companyRepository)
|
|
|
+ {
|
|
|
+ if (request()->has(Form\Field::FILE_DELETE_FLAG)) {
|
|
|
+ return $this->editForm($id)->update($id);
|
|
|
+ }
|
|
|
+ $data = $this->editForm($id)->getValidateInput();//这个方法会调用Form自带的验证和表单处理(文件上传等)验证错误会直接返回错误.不需要判断;
|
|
|
+
|
|
|
+ if($data['legal_idcard'] && !isCreditNo($data['legal_idcard'])){
|
|
|
+ admin_toastr('法人代表身份证格式不正确', 'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ if(!empty(request("mobile")) || !empty(request("landline_tel"))){
|
|
|
+
|
|
|
+ if (!empty(request("mobile"))){
|
|
|
+ $validator = Validator::make(\request()->all(),
|
|
|
+ ['mobile' => ['required',new MobileRule(),Rule::unique('companys')->ignore($id)]],
|
|
|
+ ['mobile.required'=>"请填写手机号!",'mobile.unique'=>"手机号已经存在!",]
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (!empty(request("landline_tel"))){
|
|
|
+ if (request('landline_tel')=="--" || request('landline_tel')=="-"){
|
|
|
+
|
|
|
+ request()->offsetSet("landline_tel","");
|
|
|
+
|
|
|
+ if (empty(request("mobile"))){
|
|
|
+ admin_toastr("手机、固话二选一",'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $last_tel=substr(request('landline_tel'),-1);
|
|
|
+ if ($last_tel=="-"){
|
|
|
+ $new_tel = substr(request('landline_tel'),0,strlen(request('landline_tel'))-1);
|
|
|
+ request()->offsetSet("landline_tel",$new_tel);
|
|
|
+ $data['landline_tel']=$new_tel;
|
|
|
+ }
|
|
|
+
|
|
|
+ $validator = Validator::make(\request()->all(),
|
|
|
+ ['landline_tel' => ['required','regex: /^(([0\+]\d{1,9}-)?(\d{2,6})-)(\d{1,12})(-(\d{1,8}))?$/']
|
|
|
+ ],
|
|
|
+ ['landline_tel.required'=>"请填写固话!",'landline_tel.regex'=>"固话格式不对"]
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($validator) && $validator->fails()) {
|
|
|
+ admin_toastr($validator->errors()->first(), 'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ admin_toastr("手机、固话二选一",'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $res= [];
|
|
|
+ $res1= [];
|
|
|
+ $res2= [];
|
|
|
+ foreach ($data as $key => $val) {
|
|
|
+ if ($key == 'regpoints') {
|
|
|
+ $res1['regpoints'] = $val;
|
|
|
+ } else if ($key == 'points') {
|
|
|
+ $res1['points'] = $val;
|
|
|
+ } else if ($key == 'setmeal_id') {
|
|
|
+ $res2['setmeal_id'] = $val;
|
|
|
+ } else if ($key == "is_money") {
|
|
|
+ $res2['is_money'] = $val;
|
|
|
+ } else if ($key == 'amount') {
|
|
|
+ $res2['amount'] = $val;
|
|
|
+ } else {
|
|
|
+ if ($key == 'tag') {
|
|
|
+ $res[$key] = implode(',', $val);
|
|
|
+ } elseif ($key == 'province') {
|
|
|
+ $res['district'] = $val;
|
|
|
+ } elseif ($key == 'city') {
|
|
|
+ $res['district'] = $res['district'].".".$val;
|
|
|
+ } elseif ($key == 'area') {
|
|
|
+ $res['district'] = $res['district'].".".$val;
|
|
|
+ } else {
|
|
|
+ $res[$key] = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $res['district_cn'] =get_district_cn($res['district']);
|
|
|
+ $comInfo = $this->companyRepository->find($id);
|
|
|
+ //设置当前分站
|
|
|
+ if (!isset($res['subsite_id'])){
|
|
|
+
|
|
|
+ $comInfo->subsite_id=get_subsite_id();
|
|
|
+ $res['subsite_id']=get_subsite_id();
|
|
|
+
|
|
|
+ }
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ $res['setmeal_id'] = $res2['setmeal_id'];
|
|
|
+ $setmeal = Setmeal::where('display', 1)->list()->pluck('setmeal_name', 'id')->toArray();
|
|
|
+ $res['setmeal_name'] = $setmeal[$res2['setmeal_id']];
|
|
|
+ if (!Company::where('id', $id)->update($res)) {
|
|
|
+ throw new \Exception('修改失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ $updateJob['company_name'] = $res['companyname'];
|
|
|
+ $jid = $this->jobsRepository->findWhere(['company_id'=>$id], ['id']);
|
|
|
+ if ($jid) {
|
|
|
+ $jids = array_column($jid->toArray(), 'id');
|
|
|
+ if ($this->jobsRepository->modifyCom($jids, $updateJob)) {
|
|
|
+ $condition1 = [['whereIn','id', $jids]];
|
|
|
+ event_search_update(Jobs::class, $condition1, 'update');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (get_subsite_open() && $comInfo->subsite_id != $res['subsite_id']) {
|
|
|
+ $this->modifySubsite($id, $res['subsite_id']);
|
|
|
+ CompanyImg::where('company_id', $id)->update(['subsite_id'=>$res['subsite_id']]);//修改企业风采中的分站id;
|
|
|
+ }
|
|
|
+//
|
|
|
+ event_search_update(Company::class, (string)$id, 'update');
|
|
|
+ DB::commit();
|
|
|
+ admin_toastr('企业修改成功', 'success');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ DB::rollback();
|
|
|
+ admin_toastr($e->getMessage(), 'error');
|
|
|
+ }
|
|
|
+ return redirect(route("company.index"));
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function modifySubsite($company_id, $subsite_id)
|
|
|
+ {
|
|
|
+ $jobsList = $this->jobsRepository->findWhere(['company_id'=>$company_id], ['id','subsite_id']);
|
|
|
+ if ($jobsList->isNotEmpty()) {
|
|
|
+ $jobsArr = $jobsList->toArray();
|
|
|
+ $jid = array_column($jobsArr, 'id');
|
|
|
+ if (is_array($jid)) {
|
|
|
+ $this->jobsRepository->updateSubsite($jid, $subsite_id);
|
|
|
+ event_search_update(Jobs::class, implode(',', $jid), 'update');
|
|
|
+ $subjobData = SubsiteJob::whereIn('jobs_id', $jid)->where('subsite_id', $subsite_id)->select('id')->get()->toArray();
|
|
|
+ if ($subjobData) {
|
|
|
+ SubsiteJob::destroy(array_column($subjobData, 'id'));
|
|
|
+ }
|
|
|
+ SubsiteJob::whereIn('jobs_id', $jid)->where('subsite_id', $jobsArr[0]['subsite_id'])->update(['subsite_id'=>$subsite_id]);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function destroy($id)
|
|
|
+ {
|
|
|
+ Permission::check('company_manager_delete');
|
|
|
+ $ids = explode(',', $id);
|
|
|
+ if (Company::destroy($ids)) {
|
|
|
+ // 删除企业下面所有职位
|
|
|
+ $jobs = $this->jobsRepository->findWhereIn('company_id', $ids, ['id']);
|
|
|
+ if ($jobs) {
|
|
|
+ $jids = array_column($jobs->toArray(), 'id');
|
|
|
+ $this->jobsRepository->delJobs($jids);
|
|
|
+ $this->jobsContactRepository->delJobsContact($jids);
|
|
|
+ $condition1 = [['whereIn','id', $jids]];
|
|
|
+ event_search_update(Jobs::class, $condition1, 'delete');
|
|
|
+ }
|
|
|
+ //删除招聘会职位,参展记录
|
|
|
+ $fairjobs = $this->jobfairJobRepository->findWhereIn('company_id', $ids, ['id']);
|
|
|
+ $this->jobfairCompanyRepository->delJobs('company_id',$ids);
|
|
|
+ $this->jobfairJobRepository->delJobs('company_id',$ids);
|
|
|
+ if($fairjobs){
|
|
|
+ $this->jobfairJobsContactRepository->deleteJobContact($fairjobs);
|
|
|
+ $this->jobfairPutJobRepository->delJobIds($fairjobs);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'status' => true,
|
|
|
+ 'message' => trans('admin.delete_succeeded'),
|
|
|
+ ];
|
|
|
+ $condition = [['whereIn','id', $ids]];
|
|
|
+ event_search_update(Company::class, $condition, 'delete');
|
|
|
+ } else {
|
|
|
+ $data = [
|
|
|
+ 'status' => false,
|
|
|
+ 'message' => trans('admin.delete_failed'),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ return response()->json($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function companyAudit(Request $request)
|
|
|
+ {
|
|
|
+ $ids = $request->ids;
|
|
|
+ if (!$ids) {
|
|
|
+ return admin_toastr('请选择要审核的企业', 'error');
|
|
|
+ }
|
|
|
+ $id = explode(',', $ids);
|
|
|
+ $reason = $request->reason;
|
|
|
+ $data = ['audit'=>$request->audit1];
|
|
|
+
|
|
|
+ if (Company::companyAudit($id, $data)) {
|
|
|
+ $jid = $this->jobsRepository->findWhereIn('company_id', $id, ['id']);
|
|
|
+ if ($jid) {
|
|
|
+ $jids = array_column($jid->toArray(), 'id');
|
|
|
+ //修改职位中企业状态字段
|
|
|
+ if ($this->jobsRepository->modifyCom($jids, ['company_audit'=>$request->audit1])) {
|
|
|
+ $condition1 = [['whereIn','id', $jids]];
|
|
|
+ event_search_update(Jobs::class, $condition1, 'update');
|
|
|
+ $condition2 = [['whereIn','id', $id]];
|
|
|
+ event_search_update(Company::class, $condition2, 'update');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果认证状态为通过(1)完成营业招聘审核
|
|
|
+ if ($request->audit1 == 1) {
|
|
|
+ foreach ($id as $key => $val) {
|
|
|
+ $this->taskService->doTask(30, $val, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch ($request->audit1) {
|
|
|
+ case 1:
|
|
|
+ $html = "企业通过审核";
|
|
|
+ $alias =Smser::TEMPLATE_SMS_LICENSEALLOW;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ $html = "企业未通过审核";
|
|
|
+ $alias=Smser::TEMPLATE_SMS_LICENSENOTALLOW;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ foreach ($id as $key => $val) {
|
|
|
+ $companyInfo = $this->companyRepository->find($val, ['mobile']);
|
|
|
+ if ($companyInfo->mobile) {
|
|
|
+ $this->smsService->sendSms($companyInfo->mobile, $alias, ['sitename'=>config('aix.system.site.site.site_name'),'sitedomain'=>config('aix.system.site.site.site_domain')]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $auditData= [];
|
|
|
+ $auditData['ids'] = $id;
|
|
|
+ $auditData['status'] = $request->audit1;
|
|
|
+ $auditData['type'] = 8;
|
|
|
+ $auditData['reason'] = $reason;
|
|
|
+ AuditReason::addData($auditData);
|
|
|
+ if ($request->is_send) {
|
|
|
+ //站内信
|
|
|
+ switch ($request->audit1) {
|
|
|
+ case 1:
|
|
|
+ $html = "企业通过审核";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ $html = "企业未通过审核";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ foreach ($id as $key => $val) {
|
|
|
+ $com = $this->companyRepository->findWhere(['id'=>$val], ['*']);
|
|
|
+ $insert_data[$key] = array(
|
|
|
+ 'utype' => 1,
|
|
|
+ 'msgtype' => 1,
|
|
|
+ 'msgfromuid' => admin::user()->id,
|
|
|
+ 'msgfrom' => admin::user()->username,
|
|
|
+ 'msgtoname' =>$com[0]->username,
|
|
|
+ 'msgtouid' => $val,
|
|
|
+ 'message' => $html.'【备注】'.$reason,
|
|
|
+ 'new' => 1,
|
|
|
+ 'created_at' =>date('Y-m-d H:i:s', time()),
|
|
|
+ 'updated_at' =>date('Y-m-d H:i:s', time()),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $this->pmsService->addBatchPms($insert_data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return admin_toastr('企业审核成功', 'success');
|
|
|
+ } else {
|
|
|
+ return admin_toastr('企业审核失败!', 'error');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function companyRefresh(Request $request)
|
|
|
+ {
|
|
|
+ $ids = $request->ids;
|
|
|
+ if (!$ids) {
|
|
|
+ return admin_toastr('请选择要刷新的企业', 'error');
|
|
|
+ }
|
|
|
+ $id = explode(',', $ids);
|
|
|
+ $data = ['refresh_time'=>time(),'last_login_time'=>time()];
|
|
|
+ if (Company::companyAudit($id, $data)) {
|
|
|
+ return admin_toastr('企业刷新成功', 'success');
|
|
|
+ } else {
|
|
|
+ return admin_toastr('企业刷新失败!', 'error');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function manager($id = 0)
|
|
|
+ {
|
|
|
+ if (!$id) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $company = Company::findOrFail($id);
|
|
|
+ if (!$company) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $key=uniqid();
|
|
|
+ Cache::put($key, $company, 1);
|
|
|
+ $url=route('auth.thirdlogin.background', ['ticket' => $key])."?redirect_url=".urlencode(route('com.index'));
|
|
|
+ return redirect($url);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送短信
|
|
|
+ * return json
|
|
|
+ */
|
|
|
+ public function sms(Request $request)
|
|
|
+ {
|
|
|
+ $mobile = $request->mobile;
|
|
|
+ $form = new \Encore\Admin\Widgets\Form();
|
|
|
+ $form->action(route('company.ajax.sendsms'));
|
|
|
+ $form->disableReset();
|
|
|
+ $form->html('
|
|
|
+ <strong style="color:#FF6600">
|
|
|
+ <span>您当前配置的短信接口是【阿里大鱼】。</span>
|
|
|
+ </strong>
|
|
|
+ ');
|
|
|
+ $form->mobile('mobile', '接受手机')->default($mobile);
|
|
|
+ $form->textarea('body', '发送内容')->help('内容超过70个字符将自动截取');
|
|
|
+ $form->hidden('sms_id')->default('sms_custom');
|
|
|
+ return json_encode(['html'=>$form->render(),'detail'=>'发送短信']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送Email.
|
|
|
+ * return json
|
|
|
+ */
|
|
|
+ public function email(Request $request)
|
|
|
+ {
|
|
|
+ $email = $request->email;
|
|
|
+ $form = new \Encore\Admin\Widgets\Form();
|
|
|
+ $form->action(route('company.ajax.sendemail'));
|
|
|
+ $form->disableReset();
|
|
|
+ $form->email('email', '收件地址')->default($email);
|
|
|
+ $form->text('title', '邮件标题');
|
|
|
+ $form->textarea('body', '邮件内容');
|
|
|
+ return json_encode(['html'=>$form->render(),'detail'=>'发送邮件']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送站内信
|
|
|
+ * return json
|
|
|
+ */
|
|
|
+ public function sys(Request $request)
|
|
|
+ {
|
|
|
+ $uid = $request->uid;
|
|
|
+ $form = new \Encore\Admin\Widgets\Form();
|
|
|
+ $form->action(route('company.ajax.sendsys'));
|
|
|
+ $form->disableReset();
|
|
|
+ $form->hidden('uid')->default($uid);
|
|
|
+ $form->textarea('body', '发送内容');
|
|
|
+ return json_encode(['html'=>$form->render(),'detail'=>'发送站内信']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重置密码
|
|
|
+ * return json
|
|
|
+ */
|
|
|
+ public function auditPassword(Request $request)
|
|
|
+ {
|
|
|
+ $id = $request->id;
|
|
|
+ $form = new \Encore\Admin\Widgets\Form();
|
|
|
+ $form->action(route('audit.pass'));
|
|
|
+ $form->disableReset();
|
|
|
+ $form->hidden('id', 'ID')->default($id);
|
|
|
+ $form->html('<div>重置的新密码为123456,是否重置?</div>');
|
|
|
+ return json_encode(['html'=>$form->render(),'detail'=>'重置密码']);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function auditPass(Request $request)
|
|
|
+ {
|
|
|
+ $id = $request->id;
|
|
|
+ $arr = array_filter(explode(',', $id));
|
|
|
+ if (empty($arr)) {
|
|
|
+ admin_toastr('数据异常', 'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ $result = Company::whereIn('id', $arr)->update(['password'=>\Hash::make(123456)]);
|
|
|
+ if ($result) {
|
|
|
+ admin_toastr('重置成功', 'success');
|
|
|
+ foreach ($arr as $key => $val) {
|
|
|
+ $company = Company::findOrFail($val);
|
|
|
+ if ($company->mobile) {
|
|
|
+ $this->smsService->sendSms($company->mobile, Smser::TEMPLATE_SMS_EDITPWD, ['sitename'=>config('aix.system.site.site.site_name'),'newpassword'=>'123456']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ admin_toastr('重置失败', 'error');
|
|
|
+ }
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单个企业审核
|
|
|
+ */
|
|
|
+ public function auditOne(Request $request)
|
|
|
+ {
|
|
|
+ $ids = $request->ids;
|
|
|
+ $company = Company::findOrFail($ids);
|
|
|
+ if (!$ids) {
|
|
|
+ return admin_toastr('请选择要审核的企业', 'error');
|
|
|
+ }
|
|
|
+ $id = explode(',', $ids);
|
|
|
+ $reason = $request->reason;
|
|
|
+ $data = ['audit'=>$request->audit1];
|
|
|
+
|
|
|
+ if (true == Company::companyAudit($id, $data)) {
|
|
|
+// event_search_update(Company::class, (string)$id, 'update');
|
|
|
+ $jid = $this->jobsRepository->findWhereIn('company_id', $id, ['id']);
|
|
|
+ if ($jid) {
|
|
|
+ $jids = array_column($jid->toArray(), 'id');
|
|
|
+ //修改职位中企业状态字段
|
|
|
+ if ($this->jobsRepository->modifyCom($jids, ['company_audit'=>$request->audit1])) {
|
|
|
+ $condition1 = [['whereIn','id', $jids]];
|
|
|
+// event_search_update(Jobs::class, $condition1, 'update');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果认证状态为通过(1)完成营业执照审核
|
|
|
+ if ($request->audit1 == 1) {
|
|
|
+ foreach ($id as $key => $val) {
|
|
|
+ $this->taskService->doTask(30, $val, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch ($request->audit1) {
|
|
|
+ case 1:
|
|
|
+ $html = "企业通过审核";
|
|
|
+ $alias =Smser::TEMPLATE_SMS_LICENSEALLOW;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ $html = "企业未通过审核";
|
|
|
+ $alias=Smser::TEMPLATE_SMS_LICENSENOTALLOW;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if ($company->mobile) {
|
|
|
+ $this->smsService->sendSms($company->mobile, $alias, ['sitename'=>config('aix.system.site.site.site_name'),'sitedomain'=>config('aix.system.site.site.site_domain')]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $auditData= [];
|
|
|
+ $auditData['ids'] = $id;
|
|
|
+ $auditData['status'] = $request->audit1;
|
|
|
+ $auditData['type'] = 8;
|
|
|
+ $auditData['reason'] = $reason;
|
|
|
+ AuditReason::addData($auditData);
|
|
|
+ if ($request->is_send) {
|
|
|
+ //站内信
|
|
|
+ foreach ($id as $key => $val) {
|
|
|
+ $com = $this->companyRepository->findWhere(['id'=>$val], ['*']);
|
|
|
+ $insert_data[$key] = array(
|
|
|
+ 'utype' => 1,
|
|
|
+ 'msgtype' => 1,
|
|
|
+ 'msgfromuid' => admin::user()->id,
|
|
|
+ 'msgfrom' => admin::user()->username,
|
|
|
+ 'msgtoname' =>$com[0]->username,
|
|
|
+ 'msgtouid' => $val,
|
|
|
+ 'message' => $html.'【备注】'.$reason,
|
|
|
+ 'new' => 1,
|
|
|
+ 'created_at' =>date('Y-m-d H:i:s', time()),
|
|
|
+ 'updated_at' =>date('Y-m-d H:i:s', time()),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $this->pmsService->addBatchPms($insert_data);
|
|
|
+ }
|
|
|
+ admin_toastr('企业审核成功', 'success');
|
|
|
+ return redirect(route("company.index"));
|
|
|
+ } else {
|
|
|
+ admin_toastr('企业审核失败!', 'error');
|
|
|
+ return redirect(route("company.index"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function companyLog(Request $request)
|
|
|
+ {
|
|
|
+
|
|
|
+ $id = $request->id;
|
|
|
+ $type = $request->type;
|
|
|
+ $headers = ['status'=>'审核状态', 'tim'=>'审核时间', 'sec'=>'描述'];
|
|
|
+ $data = [];
|
|
|
+ $res = AuditReason::where(['type_id'=>$id,'type'=>$type])->orderBy('id', 'desc')->get();
|
|
|
+ if (!$res) {
|
|
|
+ $rows = $data;
|
|
|
+ } else {
|
|
|
+ foreach ($res as $k => $v) {
|
|
|
+ if ($v['status']==3) {
|
|
|
+ $data[$k]['status'] = '审核失败';
|
|
|
+ } elseif ($v['status']==1) {
|
|
|
+ $data[$k]['status'] = '审核通过';
|
|
|
+ } else {
|
|
|
+ $data[$k]['status'] = '待审核';
|
|
|
+ }
|
|
|
+ $data[$k]['tim'] = $v['created_at'];
|
|
|
+ $data[$k]['sec'] = $v['audit_man'].'--'.($v['reason']?$v['reason']:"无");
|
|
|
+ }
|
|
|
+ $rows = $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ $table = new Table($headers, $rows);
|
|
|
+ return ['html'=>$table->render(),'detail'=>'审核日志'];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function consultantSet(Request $request)
|
|
|
+ {
|
|
|
+ $id = $request->id;
|
|
|
+ $form = new \Encore\Admin\Widgets\Form();
|
|
|
+ $form->action(route('consultant.set.update'));
|
|
|
+ $form->disableReset();
|
|
|
+ $form->hidden('id', 'ID')->default($id);
|
|
|
+ if(Admin::user()->isAdministrator()){
|
|
|
+ $form->select('consultant_id', '顾问名称')->options(
|
|
|
+ Consultant::pluck('name','id')
|
|
|
+ )->rules([
|
|
|
+ 'required',
|
|
|
+ ])->setMustMark();
|
|
|
+ }else{
|
|
|
+ $form->select('consultant_id', '顾问名称')->options(
|
|
|
+ Consultant::where('subsite_id', get_subsite_id())->pluck('name','id')
|
|
|
+ )->rules([
|
|
|
+ 'required',
|
|
|
+ ])->setMustMark();
|
|
|
+ }
|
|
|
+ return json_encode(['html'=>$form->render(),'detail'=>'设置顾问']);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function consultantSetUpdate(Request $request)
|
|
|
+ {
|
|
|
+ $id = $request->id;
|
|
|
+ $arr = array_filter(explode(',', $id));
|
|
|
+ if (empty($arr)) {
|
|
|
+ admin_toastr('请勾选需要设置顾问的会员', 'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ $consultant_id = $request->consultant_id;
|
|
|
+ if(empty($consultant_id)){
|
|
|
+ admin_toastr('设置顾问不能为空', 'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ $Consultant = Consultant::find($consultant_id);
|
|
|
+ $exit_company = Company::whereHas('companyConsultant')->whereIn('id', $arr)->pluck('id')->toArray();
|
|
|
+ $no_company = array_diff($arr, $exit_company);
|
|
|
+ \DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ if($exit_company){
|
|
|
+ CompanyConsultant::whereIn('company_id',$exit_company)->update(['consultant_id'=>$consultant_id,'admin_users_id'=>$Consultant->admin_users_id,'consultant_name'=>$Consultant->name]);
|
|
|
+ }
|
|
|
+ if($no_company){
|
|
|
+ $needArr=[];
|
|
|
+ foreach ($no_company as $key=>$val){
|
|
|
+ $needArr[$key]['consultant_id'] = $consultant_id;
|
|
|
+ $needArr[$key]['company_id'] = $val;
|
|
|
+ $needArr[$key]['admin_users_id'] = $Consultant->admin_users_id;
|
|
|
+ $needArr[$key]['consultant_name'] = $Consultant->name;
|
|
|
+ $needArr[$key]['created_at'] = date('Y-m-d H:i:s');
|
|
|
+ $needArr[$key]['updated_at'] = date('Y-m-d H:i:s');
|
|
|
+ }
|
|
|
+ CompanyConsultant::insert($needArr);
|
|
|
+ }
|
|
|
+ \DB::commit();
|
|
|
+ admin_toastr('设置成功', 'success');
|
|
|
+ return back();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ \DB::rollback();
|
|
|
+ admin_toastr('设置失败', 'error');
|
|
|
+ return back();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|