sugangqiang 2 years ago
parent
commit
9c853b04a5
1 changed files with 46 additions and 1 deletions
  1. 46 1
      app/enterprise/controller/Talent.php

+ 46 - 1
app/enterprise/controller/Talent.php

@@ -491,15 +491,60 @@ class Talent extends EnterpriseController {
             }
             $param = $request->param();
             validate(TalentInfo::class)->check($param);
+            $id = $param["id"];
+            if ($id) {
+                $data["id"] = $id;
+                if (!$info) {
+                    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>");
+
+
             $data["apply_year"] = $batch["batch"];
 
-            $all_valid_keys = ["applay_year", "import_way", "cur_entry_time", "position",
+            $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"];