request->param("isMix");
$tpl = "";
if ($isMix == 1) {
$tpl = "newIndex";
}
return view($tpl);
}
public function list() {
$step = 2;
$res = TalentApi::getList($this->request, $step);
return json($res);
}
/**
* 新人才申报企业端统一申报入口,混合基础信息及人才信息
*/
public function apply(\think\Request $request) {
$type = $this->user["type"];
$tpl = "";
switch ($type) {
case 1:
$tpl = "apply"; //晋江人才
break;
case 2:
$tpl = "ic_apply"; //集成电路
break;
}
$param = $request->param();
$id = isset($param["id"]) ? $param["id"] : 0;
$info = TalentApi::chkIsOwner($id, $this->user["uid"]);
$ep = EnterpriseApi::getOne($this->user["uid"]);
if (!chkEnterpriseFull($ep))
return;
$tagList = DictApi::selectByParentCode('enterprise_tag');
$streetList = DictApi::selectByParentCode('street');
$industryFieldNew = DictApi::selectByParentCode('industry_field');
$ep->enterpristTagName = $tagList[$ep->enterpriseTag];
$ep->streetName = $streetList[$ep->street];
$ep->industryFieldNewName = $industryFieldNew[$ep->industryFieldNew];
if ($info) {
$info["real_state"] = TalentLogApi::getLastLog($id, $type)["state"];
}
if ($info && in_array($info["checkState"], [TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS, TalentState::REVERIFY_FAIL])) {
return $this->view($request);
exit();
}
if ($request->isPost()) {
$checkState = $info["checkState"] ?: 0;
if ($checkState == TalentState::SCND_SAVE || $checkState == 0) {
$this->mixSave($info, $request, TalentState::SCND_SAVE);
exit();
} else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
$res = ["msg" => "审核失败,不能再保存"];
echo sprintf("", json_encode($res));
exit;
}
$res = ["msg" => "已提交审核,请耐心等待"];
echo sprintf("", json_encode($res));
exit;
}
$checkState = $info["checkState"] ?: 0;
$info["enterprise"] = $ep;
$info["talent_type_list"] = DictApi::findChildDictByCode("talent_type");
return view($tpl, ["year" => date("Y"), "checkState" => $checkState, "row" => $info]);
}
/**
* 旧第二步
* @param \think\Request $request
* @return type
*/
public function second(\think\Request $request) {
$params = $request->param();
$id = $params["id"];
$info = \app\common\api\VerifyApi::getTalentInfoById($id);
$info["real_state"] = TalentLogApi::getLastLog($id, 1)["state"];
if ($request->isPost()) {
if (!$info || $info["enterprise_id"] != $this->user["uid"]) {
$res = ["msg" => "没有对应的人才认定申报信息"];
echo sprintf("", json_encode($res));
exit;
}
$checkState = $info["checkState"];
if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
$this->save($info, $request, TalentState::SCND_SAVE);
exit();
} else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
$res = ["msg" => "审核失败,不能再保存"];
echo sprintf("", json_encode($res));
exit;
}
$res = ["msg" => "已提交审核,请耐心等待"];
echo sprintf("", json_encode($res));
exit;
}
$enterprise_info = \app\common\model\Enterprise::find($this->user["uid"]);
$info["enterprise"] = $enterprise_info;
$batch = \app\common\api\BatchApi::getValidBatch(1, $enterprise_info["type"]);
return view("second", ["year" => $info["apply_year"] ?: $batch["batch"], "row" => $info]);
}
public function view(\think\Request $request) {
switch ($this->user["type"]) {
case 1:
$tpl = "view"; //晋江人才
break;
case 2:
$tpl = "ic_view"; //集成电路
break;
}
$id = $request->param("id");
$info = \app\common\api\VerifyApi::getTalentInfoById($id);
return view($tpl, ["row" => $info]);
}
/**
* 提交表单(旧第二步)
*/
public function submit() {
$params = $this->request->param();
$id = $params["id"];
if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
$res = ["msg" => "没有对应的人才认定申报信息"];
echo sprintf("", json_encode($res));
exit;
}
$checkState = $info["checkState"];
if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
$field_dict = \app\common\api\DictApi::getTalentFields(2);
$no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
"bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
$where = [];
$where[] = ["rel", "=", "study_abroad"];
$where[] = ["step", "=", 2];
$where[] = ["project", "=", 1];
$where[] = ["active", "=", 1];
$where[] = ["delete", "=", 0];
$where[] = ["type", "=", $this->user["type"]];
$where[] = ["isConditionFile", "<>", 1];
$abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
$abroad_file_ids = null;
if ($abroad_files)
$abroad_file_ids = array_column($abroad_files, "id");
if ($params["study_abroad"] == 1) {
$no_empty[] = "abroad_school";
$no_empty[] = "abroad_major";
}
if (in_array($params["source"], [1, 3])) {
$no_empty[] = "source_batch";
$no_empty[] = "fujian_highcert_pubtime";
$no_empty[] = "fujian_highcert_exptime";
if ($params["source"] == 3) {
$no_empty[] = "source_city";
}
}
if (in_array($params["source"], [2, 4])) {
$no_empty[] = "source_batch";
$no_empty[] = "quanzhou_highcert_pubtime";
$no_empty[] = "quanzhou_highcert_exptime";
if ($params["source"] == 4) {
$no_empty[] = "source_county";
}
}
$condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
if ($condition_info["isSalary"] == 1) {
$no_empty[] = "annual_salary";
}
$no_empty = array_filter($no_empty);
$return = [];
foreach ($no_empty as $key) {
if (!$params[$key]) {
$return[] = sprintf("请填写“%s”", $field_dict[$key]);
}
}
if (count($return) > 0) {
$res = ["msg" => implode("
", $return)];
echo sprintf("", json_encode($res));
exit;
}
if ($condition_info["bindFileTypes"] && $info["source"] == 5) {
$whr[] = ["id", "in", $condition_info["bindFileTypes"]];
$whr[] = ["must", "=", 1];
}
$where = [];
$where[] = ["step", "=", 2];
$where[] = ["project", "=", 1];
$where[] = ["type", "=", $this->user["type"]];
$where[] = ["must", "=", 1];
$where[] = ["active", "=", 1];
$where[] = ["delete", "=", 0];
$where[] = ["isConditionFile", "<>", 1];
if ($whr) {
$filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
} else {
$filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
}
$ft_ids = array_column($filetypes, "id");
if ($params["study_abroad"] == 1) {
//选中留学,如果存在留学附件变成必传
$ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
} else {
//没选中,留学附件就算设成必传也不用验证
$ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
}
$whr = [];
$whr[] = ["typeId", "in", $ft_ids];
$whr[] = ["mainId", "=", $id];
$distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
$upload_type_counts = count($distinct_filetypes);
if ($upload_type_counts != count($ft_ids)) {
$res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
echo sprintf("", json_encode($res));
exit;
}
$this->save($info, $this->request, TalentState::SCND_SUBMIT);
} else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
$res = ["msg" => "审核失败,不能再提交审核"];
echo sprintf("", json_encode($res));
exit;
}
$res = ["msg" => "已提交审核,请耐心等待"];
echo sprintf("", json_encode($res));
exit;
}
/**
* 提交表单(新:混合基础信息人才申报信息)
*/
public function submitToCheck() {
$params = $this->request->param();
$id = $params["id"];
if (!$info = TalentApi::chkIsOwner($id, $this->user["uid"])) {
$res = ["msg" => "没有对应的人才认定申报信息"];
echo sprintf("", json_encode($res));
exit;
}
$checkState = $info["checkState"];
if ($checkState == TalentState::SCND_SAVE || $checkState == TalentState::BASE_REVERIFY_PASS) {
$field_dict = \app\common\api\DictApi::getTalentFields(2);
$no_empty = ["talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "bank", "bank_number", "bank_branch_name",
"bank_account", "study_abroad", "phone", "email", "import_way", "cur_entry_time", "cur_entry_time", "position", "source"];
$where = [];
$where[] = ["rel", "=", "study_abroad"];
$where[] = ["step", "=", 2];
$where[] = ["project", "=", 1];
$where[] = ["active", "=", 1];
$where[] = ["delete", "=", 0];
$where[] = ["type", "=", $this->user["type"]];
$where[] = ["isConditionFile", "<>", 1];
$abroad_files = Db::table("new_common_filetype")->where($where)->select()->toArray(); //留学的附件
$abroad_file_ids = null;
if ($abroad_files)
$abroad_file_ids = array_column($abroad_files, "id");
if ($params["study_abroad"] == 1) {
$no_empty[] = "abroad_school";
$no_empty[] = "abroad_major";
}
if (in_array($params["source"], [1, 3])) {
$no_empty[] = "source_batch";
$no_empty[] = "fujian_highcert_pubtime";
$no_empty[] = "fujian_highcert_exptime";
if ($params["source"] == 3) {
$no_empty[] = "source_city";
}
}
if (in_array($params["source"], [2, 4])) {
$no_empty[] = "source_batch";
$no_empty[] = "quanzhou_highcert_pubtime";
$no_empty[] = "quanzhou_highcert_exptime";
if ($params["source"] == 4) {
$no_empty[] = "source_county";
}
}
$condition_info = Db::table("new_talent_condition")->findOrEmpty($params["talent_condition"]);
if ($condition_info["isSalary"] == 1) {
$no_empty[] = "annual_salary";
}
$no_empty = array_filter($no_empty);
$return = [];
foreach ($no_empty as $key) {
if (!$params[$key]) {
$return[] = sprintf("请填写“%s”", $field_dict[$key]);
}
}
if (count($return) > 0) {
$res = ["msg" => implode("
", $return)];
echo sprintf("", json_encode($res));
exit;
}
if ($condition_info["bindFileTypes"] && $info["source"] == 5) {
$whr[] = ["id", "in", $condition_info["bindFileTypes"]];
$whr[] = ["must", "=", 1];
}
$where = [];
$where[] = ["step", "=", 2];
$where[] = ["project", "=", 1];
$where[] = ["type", "=", $this->user["type"]];
$where[] = ["must", "=", 1];
$where[] = ["active", "=", 1];
$where[] = ["delete", "=", 0];
$where[] = ["isConditionFile", "<>", 1];
if ($whr) {
$filetypes = Db::table("new_common_filetype")->whereOr([$where, $whr])->select()->toArray();
} else {
$filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
}
$ft_ids = array_column($filetypes, "id");
if ($params["study_abroad"] == 1) {
//选中留学,如果存在留学附件变成必传
$ft_ids = array_unique(array_merge($ft_ids, (array) $abroad_file_ids));
} else {
//没选中,留学附件就算设成必传也不用验证
$ft_ids = array_diff($ft_ids, (array) $abroad_file_ids);
}
$whr = [];
$whr[] = ["typeId", "in", $ft_ids];
$whr[] = ["mainId", "=", $id];
$distinct_filetypes = Db::table("new_talent_file")->where($whr)->distinct(true)->field("typeId")->select();
$upload_type_counts = count($distinct_filetypes);
if ($upload_type_counts != count($ft_ids)) {
$res = ["msg" => "请留意附件上传栏中带*号的内容均为必传项,请上传完整再提交审核"];
echo sprintf("", json_encode($res));
exit;
}
$this->save($info, $this->request, TalentState::SCND_SUBMIT);
} else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
$res = ["msg" => "审核失败,不能再提交审核"];
echo sprintf("", json_encode($res));
exit;
}
$res = ["msg" => "已提交审核,请耐心等待"];
echo sprintf("", json_encode($res));
exit;
}
/**
* 保存表单(旧第二步)
* @param type $info talent_info
* @param type $param request->param();
*/
private function save($info, \think\Request $request, $checkState) {
try {
$batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
if (!$batch) {
throw new ValidateException("不在人才认定申报申请时间内");
}
$param = $request->param();
validate(TalentInfo::class)->check($param);
$data["apply_year"] = $batch["batch"];
$all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
"source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
"talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
"study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
foreach ($all_valid_keys as $key) {
$data[$key] = trim($param[$key]);
}
if ($data["study_abroad"] == 1) {
$data["abroad_school"] = $param["abroad_school"];
$data["abroad_major"] = $param["abroad_major"];
} else {
$data["abroad_school"] = null;
$data["abroad_major"] = null;
}
switch ($data["source"]) {
case 1:
$data["source_batch"] = $param["source_batch"];
$data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
$data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
$data["source_city"] = null;
break;
case 2:
$data["source_batch"] = $param["source_batch"];
$data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
$data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
$data["source_county"] = null;
break;
case 3:
$data["source_batch"] = $param["source_batch"];
$data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
$data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
$data["source_city"] = $param["source_city"];
break;
case 4:
$data["source_batch"] = $param["source_batch"];
$data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
$data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
$data["source_county"] = $param["source_county"];
break;
}
$condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
if ($condition_info["isSalary"] == 1) {
$data["annual_salary"] = $param["annual_salary"];
} else {
$data["annual_salary"] = null;
}
if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
//真实状态8是驳回,需要判断什么字段可以提交
$modify_fields = array_filter(explode(",", $info["modify_fields"]));
$tmp_data = $data;
$data = [];
foreach ($modify_fields as $field) {
$data[$field] = $tmp_data[$field];
}
}
$data["checkState"] = $checkState;
$data["id"] = $info["id"];
$success_msg = "提交成功";
$error_msg = "提交失败";
if ($checkState == TalentState::SCND_SAVE) {
$last_log = TalentLogApi::getLastLog($data["id"], 1);
if ($last_log["new_state"] != TalentState::SCND_SAVE) {
TalentLogApi::write(1, $data["id"], $checkState, "保存认定材料未提交", 1);
}
TalentModel::update($data);
} else if ($checkState == TalentState::SCND_SUBMIT) {
$success_msg = "提交成功";
$error_msg = "提交失败";
$data["new_submit_time"] = date("Y-m-d H:i:s");
TalentModel::update($data);
TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
} else {
throw new ValidateException($error_msg);
}
$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
echo sprintf("", json_encode($res));
exit();
} catch (ValidateException $e) {
$res = ["msg" => $e->getMessage()];
$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
echo sprintf("", json_encode($res));
exit();
}
}
/**
* 保存表单(新:混合基础信息人才申报信息)
* @param type $info talent_info
* @param type $param request->param();
*/
private function mixSave($info, \think\Request $request, $checkState) {
try {
$batch = \app\common\api\BatchApi::getValidBatch(1, $this->user["type"]);
if (!$batch) {
throw new ValidateException("不在人才认定申报申请时间内");
}
$param = $request->param();
validate(TalentInfo::class)->check($param);
$data["apply_year"] = $batch["batch"];
$all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
"source", "source_batch", "fujian_highcert_pubtime", "fujian_highcert_exptime", "quanzhou_highcert_pubtime", "quanzhou_highcert_exptime", "source_city", "source_county",
"talent_arrange", "talent_condition", "highest_degree", "graduate_school", "major", "professional", "bank", "bank_number", "bank_branch_name", "bank_account",
"study_abroad", "abroad_school", "abroad_major", "phone", "email", "annual_salary", "pro_qua"];
foreach ($all_valid_keys as $key) {
$data[$key] = trim($param[$key]);
}
if ($data["study_abroad"] == 1) {
$data["abroad_school"] = $param["abroad_school"];
$data["abroad_major"] = $param["abroad_major"];
} else {
$data["abroad_school"] = null;
$data["abroad_major"] = null;
}
switch ($data["source"]) {
case 1:
$data["source_batch"] = $param["source_batch"];
$data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
$data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
$data["source_city"] = null;
break;
case 2:
$data["source_batch"] = $param["source_batch"];
$data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
$data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
$data["source_county"] = null;
break;
case 3:
$data["source_batch"] = $param["source_batch"];
$data["fujian_highcert_pubtime"] = $param["fujian_highcert_pubtime"];
$data["fujian_highcert_exptime"] = $param["fujian_highcert_exptime"];
$data["source_city"] = $param["source_city"];
break;
case 4:
$data["source_batch"] = $param["source_batch"];
$data["quanzhou_highcert_pubtime"] = $param["quanzhou_highcert_pubtime"];
$data["quanzhou_highcert_exptime"] = $param["quanzhou_highcert_exptime"];
$data["source_county"] = $param["source_county"];
break;
}
$condition_info = Db::table("new_talent_condition")->findOrEmpty($param["talent_condition"]);
if ($condition_info["isSalary"] == 1) {
$data["annual_salary"] = $param["annual_salary"];
} else {
$data["annual_salary"] = null;
}
if ($info["real_state"] == TalentState::FST_VERIFY_REJECT) {
//真实状态8是驳回,需要判断什么字段可以提交
$modify_fields = array_filter(explode(",", $info["modify_fields"]));
$tmp_data = $data;
$data = [];
foreach ($modify_fields as $field) {
$data[$field] = $tmp_data[$field];
}
}
$data["checkState"] = $checkState;
$data["id"] = $info["id"];
$success_msg = "提交成功";
$error_msg = "提交失败";
if ($checkState == TalentState::SCND_SAVE) {
$last_log = TalentLogApi::getLastLog($data["id"], 1);
if ($last_log["new_state"] != TalentState::SCND_SAVE) {
TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
}
TalentModel::update($data);
} else if ($checkState == TalentState::SCND_SUBMIT) {
$success_msg = "提交成功";
$error_msg = "提交失败";
$data["new_submit_time"] = date("Y-m-d H:i:s");
TalentModel::update($data);
TalentLogApi::write(1, $info["id"], $checkState, "确认提交审核", 1);
} else {
throw new ValidateException($error_msg);
}
$res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $info["id"], "checkState" => $checkState]];
$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
echo sprintf("", json_encode($res));
exit();
} catch (ValidateException $e) {
$res = ["msg" => $e->getMessage()];
$callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
echo sprintf("", json_encode($res));
exit();
}
}
public function delete() {
$id = $this->request->param("talentInfoId");
$info = Talent::chkIsOwner($id, $this->user["uid"]);
if (!$info) {
return json(["msg" => "操作失败"]);
}
$checkState = $info["checkState"];
if (in_array($checkState, [0, 1])) {
$log = TalentLogApi::getLastLog($id, 1);
if ($log["state"] > 1) {
//有提交审核记录
return json(["msg" => "操作失败"]);
}
}
$data["id"] = $id;
$data["delete"] = 1;
TalentModel::update($data);
return json(["msg" => "删除成功"]);
}
}