|
@@ -73,8 +73,16 @@ class Talent extends EnterpriseController {
|
|
|
if ($request->isPost()) {
|
|
|
$checkState = $info["checkState"] ?: 0;
|
|
|
if ($checkState == TalentState::SCND_SAVE || $checkState == 0) {
|
|
|
- $this->mixSave($info, $request, TalentState::SCND_SAVE);
|
|
|
- exit();
|
|
|
+ switch ($type) {
|
|
|
+ case 1:
|
|
|
+ $this->mixSave($info, $request, TalentState::SCND_SAVE);
|
|
|
+ exit();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ $this->icSave($info, $request, TalentState::SCND_SAVE);
|
|
|
+ exit();
|
|
|
+ break;
|
|
|
+ }
|
|
|
} else if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, TalentState::BASE_REVERIFY_FAIL, TalentState::FST_VERIFY_FAIL, TalentState::REVERIFY_FAIL])) {
|
|
|
$res = ["msg" => "审核失败,不能再保存"];
|
|
|
echo sprintf("<script>parent.TalentInfoInfoDlg.infoCallback(%s);</script>", json_encode($res));
|
|
@@ -711,6 +719,227 @@ class Talent extends EnterpriseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function icSave($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);
|
|
|
+ $id = $param["id"];
|
|
|
+ if ($id) {
|
|
|
+ if (!$info || $info["id"] != $id || $info["enterprise_id"] != $this->user["uid"]) {
|
|
|
+ throw new ValidateException("没有对应的人才认定申报信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $files = $param["uploadFiles"];
|
|
|
+ $data["headimgurl"] = $info["headimgurl"];
|
|
|
+ if ($request->file()) {
|
|
|
+ $headimg = $request->file("photo");
|
|
|
+ $upload = new \app\common\api\UploadApi();
|
|
|
+ $result = $upload->uploadOne($headimg, "image", "talent/photo");
|
|
|
+ $file = imagecreatefromstring(file_get_contents("storage/" . $result->filepath));
|
|
|
+ $width = imagesx($file);
|
|
|
+ $height = imagesy($file);
|
|
|
+ //免冠二寸照长宽413:579
|
|
|
+ if ($width * 579 != $height * 413) {
|
|
|
+ @unlink("storage/" . $result->filepath); //像素不符合,删除上传文件
|
|
|
+ throw new ValidateException("近期免冠半身彩照(二寸)不符合二寸像素标准。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
|
|
|
+ }
|
|
|
+ if ($info && $info["headimgurl"]) {
|
|
|
+ //如果新照片符合像素要求,则删除旧照片
|
|
|
+ $old_head_url = "storage/" . $info["headimgurl"];
|
|
|
+ if (file_exists($old_head_url))
|
|
|
+ @unlink($old_head_url);
|
|
|
+ }
|
|
|
+ $data["headimgurl"] = $result->filepath;
|
|
|
+ }
|
|
|
+ if (!$data["headimgurl"] && $checkState == TalentState::SCND_SUBMIT)
|
|
|
+ throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
|
|
|
+
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["project", "=", 1];
|
|
|
+ $where[] = ["type", "=", $this->user["type"]];
|
|
|
+ $where[] = ["must", "=", 1];
|
|
|
+ $where[] = ["active", "=", 1];
|
|
|
+ $where[] = ["delete", "=", 0];
|
|
|
+ $filetypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
|
|
|
+
|
|
|
+ $age = 0;
|
|
|
+ if ($param["birthday"]) {
|
|
|
+ $birthday = $param["birthday"];
|
|
|
+ $birthdayYear = substr($birthday, 0, 4);
|
|
|
+ $currentYear = date("Y");
|
|
|
+ $age = $currentYear - $birthdayYear;
|
|
|
+ }
|
|
|
+ $ft_ids = [];
|
|
|
+ $deletes = [];
|
|
|
+ foreach ($filetypes as $ft) {
|
|
|
+ if ($ft["option"]) {
|
|
|
+ if ($ft["rel"] == "birthday") {
|
|
|
+ if ($age < $ft["option"]) {
|
|
|
+ $deletes[] = $ft["id"];
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $selectVal = $param[$ft["rel"]];
|
|
|
+ $conditions = array_filter(explode(",", $ft["option"]));
|
|
|
+ if (!in_array($selectVal, $conditions)) {
|
|
|
+ $deletes[] = $ft["id"];
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $ft_ids[] = $ft["id"];
|
|
|
+ }
|
|
|
+
|
|
|
+ $data["apply_year"] = $batch["batch"];
|
|
|
+
|
|
|
+ $all_valid_keys = ["talent_type", "name", "card_type", "card_number", "sex", "birthday", "nationality", "province", "city", "county", "nation", "politics", "experience", "education",
|
|
|
+ "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 (in_array($data["talent_type"], [1, 2])) {
|
|
|
+ $data["tax_insurance_month"] = $param["tax_insurance_month"];
|
|
|
+ $data["labor_contract_rangetime"] = $param["labor_contract_rangetime"];
|
|
|
+ $data["fst_work_time"] = $param["fst_work_time"];
|
|
|
+ $data['pre_import_type'] = null;
|
|
|
+ } else {
|
|
|
+ $data["tax_insurance_month"] = null;
|
|
|
+ $data["labor_contract_rangetime"] = null;
|
|
|
+ $data["fst_work_time"] = null;
|
|
|
+ $data['pre_import_type'] = $param["pre_import_type"];
|
|
|
+ }
|
|
|
+
|
|
|
+ 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) {
|
|
|
+ //真实状态11是驳回,需要判断什么字段可以提交
|
|
|
+ $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"] = $id;
|
|
|
+ $success_msg = "提交成功";
|
|
|
+ $error_msg = "提交失败";
|
|
|
+ if ($checkState == TalentState::SCND_SAVE) {
|
|
|
+ $success_msg = "保存成功";
|
|
|
+ if ($data["id"]) {
|
|
|
+ //编辑
|
|
|
+ TalentModel::update($data);
|
|
|
+ $last_log = TalentLogApi::getLastLog($data["id"], 1);
|
|
|
+ if ($last_log["new_state"] != TalentState::SCND_SAVE) {
|
|
|
+ TalentLogApi::write(1, $data["id"], $checkState, "保存未提交", 1);
|
|
|
+ } else {
|
|
|
+ TalentLogApi::setActive($last_log["id"], 1); //更新修改时间
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //新增
|
|
|
+ $data["enterprise_id"] = $this->user["uid"];
|
|
|
+ $id = TalentModel::insertGetId($data);
|
|
|
+ TalentLogApi::write(1, $id, $checkState, "保存未提交", 1);
|
|
|
+ $whr = [];
|
|
|
+ $whr[] = ["fileId", "in", $files];
|
|
|
+ $upd_checklog["mainId"] = $id;
|
|
|
+ Db::table("new_talent_checklog")->where($whr)->save($upd_checklog);
|
|
|
+ }
|
|
|
+ } else if ($checkState == TalentState::SCND_SUBMIT) {
|
|
|
+ $data["new_submit_time"] = date("Y-m-d H:i:s");
|
|
|
+ TalentModel::update($data);
|
|
|
+ TalentLogApi::write(1, $data["id"], $checkState, "确认提交审核", 1);
|
|
|
+ } else {
|
|
|
+ throw new ValidateException($error_msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($id) {
|
|
|
+ if ($deletes) {
|
|
|
+ //删除多余的附件,一般是选择人才类型留下来的
|
|
|
+ $whr = [];
|
|
|
+ $whr[] = ["typeId", "in", $deletes];
|
|
|
+ $whr[] = ["id", "in", $files];
|
|
|
+ $_wait_del_files = Db::table("new_talent_file")->where($whr)->select()->toArray();
|
|
|
+ $_logfileIds[] = [];
|
|
|
+ foreach ($_wait_del_files as $_del_file) {
|
|
|
+ $_logfileIds[] = $_del_file["id"];
|
|
|
+ @unlink("storage/" . $_del_file["url"]);
|
|
|
+ }
|
|
|
+ Db::table("new_talent_file")->where($whr)->delete();
|
|
|
+ if ($_logfileIds) {
|
|
|
+ $whr = [];
|
|
|
+ $whr[] = ["fileId", "in", $_logfileIds];
|
|
|
+ $_upd_checklog["description"] = "删除附件";
|
|
|
+ $_upd_checklog["updateUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"] ?: $this->user["rolename"]);
|
|
|
+ $_upd_checklog["updateTime"] = date("Y-m-d H:i:s");
|
|
|
+ Db::table("new_talent_checklog")->where($whr)->save($_upd_checklog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $whr = [];
|
|
|
+ $whr[] = ["id", "in", $files];
|
|
|
+ Db::table("new_talent_file")->where($whr)->save(["mainId" => $id]);
|
|
|
+ $res = ["code" => 200, "msg" => $success_msg, "obj" => ["id" => $id, "checkState" => $checkState]];
|
|
|
+ $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
|
|
|
+ echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
|
|
|
+ exit();
|
|
|
+ } else {
|
|
|
+ throw new ValidateException($error_msg);
|
|
|
+ }
|
|
|
+ } catch (ValidateException $e) {
|
|
|
+ $res = ["msg" => $e->getMessage()];
|
|
|
+ $callback = $checkState == TalentState::SCND_SAVE ? "infoCallback" : "submitCallback";
|
|
|
+ echo sprintf("<script>parent.TalentInfoInfoDlg.{$callback}(%s);</script>", json_encode($res));
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function delete() {
|
|
|
$id = $this->request->param("talentInfoId");
|
|
|
$info = Talent::chkIsOwner($id, $this->user["uid"]);
|