浏览代码

购房补贴++

sugangqiang 10 月之前
父节点
当前提交
118e5be4c2

+ 2 - 1
app/common/api/HouseApi.php

@@ -6,6 +6,7 @@ use app\common\state\MainState;
 use think\facade\Db;
 use app\common\model\HousePurchase as houseModel;
 use app\common\model\HousePurchaseChildren as houseChildModel;
+use app\common\model\HousePurchaseHouseInfo as houseInfoModel;
 
 /**
  * Description of HouseApi
@@ -24,7 +25,7 @@ class HouseApi {
         }
         $where = [];
         $where[] = ["idCard", "=", $idCard];
-        return houseModel::where($where)->find();
+        return houseInfoModel::where($where)->find();
     }
 
     public static function getChildren($id) {

+ 16 - 0
app/common/model/HousePurchaseHouseInfo.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace app\common\model;
+
+use think\model;
+
+/**
+ * Description of HousePurchaseHouseInfo
+ *
+ * @author sgq
+ */
+class HousePurchaseHouseInfo extends model {
+
+    protected $table = "un_housepurchase_house_info";
+
+}

+ 152 - 167
app/enterprise/controller/House.php

@@ -16,6 +16,7 @@ use app\common\api\DictApi;
 use app\common\state\CommonConst;
 use app\common\state\MainState;
 use app\common\api\Response;
+use app\common\model\HousePurchase as houseModel;
 
 /**
  * Description of House
@@ -64,8 +65,8 @@ class House extends EnterpriseController {
             $where[] = ["marryStatus", "=", $params["marryStatus"]];
         }
 
-        $count = Db::table("un_housepurchase")->where($where)->count();
-        $list = Db::table("un_housepurchase")->where($where)->limit($offset, $limit)->order("createTime $order")->select()->toArray();
+        $count = houseModel::where($where)->count();
+        $list = houseModel::where($where)->limit($offset, $limit)->order("createTime $order")->select()->toArray();
         //获取字典表婚姻状态
         $marryMap = DictApi::selectByParentCode("marry_status");
         $cardTypeMap = DictApi::selectByParentCode("card_type");
@@ -124,62 +125,65 @@ class House extends EnterpriseController {
         return view("", $vars);
     }
 
-    private function other_validate($info) {
-        $responseObj = new \stdClass();
-
-        /* 校验姓名是否与人才库一致 */
-        $where = [];
-        $where[] = ["checkState", ">=", \app\common\api\TalentState::REVERIFY_PASS];
-        $where[] = ["checkState", "not in", [\app\common\api\TalentState::REVERIFY_REJECT, \app\common\api\TalentState::REVERIFY_FAIL]];
-        $where[] = ["card_number", "=", $info["idCard"]];
-        $talentInfo = Db::table("new_talent_info")->where($where)->order("createTime desc")->find();
-        if ($talentInfo && $talentInfo["name"] != $info["name"]) {
-            $responseObj->msg = "该证件号码的姓名与人才库姓名不匹配!";
-            return $responseObj;
-        }
-        $year = substr($info["year"], 0, 4);
-        /* 查询当前批次审核通过的数量以及当前批次未审核完成的数量 */
-        $where = [];
-        $where[] = ["year", "like", "{$year}%"];
-        $where[] = ["idCard", "=", $info["idCard"]];
-        $where[] = ["checkState", "<>", LaState::LA_NOTPASS];
-        if ($info["id"]) {
-            $where[] = ["id", "<>", $info["id"]];
-        }
-        $nowYearApplyCount = LaModel::where($where)->count();
-        if ($nowYearApplyCount > 0) {
-            $responseObj->msg = "不能重复申报";
-            return $responseObj;
+    private function other_validate(&$info, $type) {
+        //校验配偶是否在库
+        if ($info["spouseIsLibrary"] && $info["spouseIsLibrary"] == 1) {
+            if (\StrUtil::isEmpOrNull($info["spouseIdcard"])) {
+                return new Response(Response::ERROR, "请填写配偶证件号码");
+            }
+            if (\StrUtil::isEmpOrNull($info["spouseName"])) {
+                return new Response(Response::ERROR, "请填写配偶姓名");
+            }
+            $where = [];
+            $where[] = ["card_number", "=", $info["spouseIdcard"]];
+            $where[] = ["name", "=", $info["spouseName"]];
+            $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
+            $where[] = ["isEffect", "<>", 4];
+            $where[] = ["delete", "=", 0];
+            $count = Db::table("new_talent_info")->where($where)->count();
+            if ($count == 0) {
+                return new Response(Response::ERROR, "人才库中未查询到配偶相关信息");
+            }
         }
-        if (!$info["id"]) {
-            $passYears = CommonLaApi::getPassYearsByIdCard($info["idCard"]);
-            if (in_array($year, $passYears)) {
-                return $responseObj->msg = "您今年度已经申报过了,每年度仅能享受一次生活补贴!";
+        $ti = \app\common\api\VerifyApi::getTalentInfoById($info["talentId"]);
+        $info["provinceCode"] = $ti["province"];
+        $info["provinceName"] = $ti["provinceName"];
+        $info["cityCode"] = $ti["city"];
+        $info["cityName"] = $ti["cityName"];
+        $info["countyCode"] = $ti["county"];
+        $info["countyName"] = $ti["countyName"];
+        $info["street"] = $ti["street"];
+        $info["bank"] = $ti["bank"];
+        $info["bankAccount"] = $ti["bank_account"];
+        $info["bankNetwork"] = $ti["bank_branch_name"];
+        $info["bankNumber"] = $ti["bank_number"];
+        /*         * 校验上一年度人才层次 */
+        if ($type == 1) {
+            $responseObj = $this->getTalentArrange($ti, $info["year"]);
+            if ($responseObj->code == 500) {
+                return $responseObj;
             }
-
-            if (count($passYears) >= 3) {
-                return $responseObj->msg = "一个人最多享受三次!";
+            $resInfo = $responseObj->obj;
+            $info["talentArrange"] = $resInfo["talentArrange"];
+            $info["identifyCondition"] = $resInfo["identifyCondition"];
+            $info["idenfityConditionName"] = $resInfo["identifyConditionName"];
+            $info["identifyGetTime"] = $resInfo["identifyGetTime"];
+
+            //设置上一年度人才层次有效月份
+            $info["monthCount"] = count($resInfo["monthList"]);
+            if ($info["monthCount"] < 9) {
+                return new Response(Response::ERROR, "申报年度人才证书有效期未满足九个月,无法申报购房补贴");
             }
+            $info["talentArrangeMonths"] = implode(",", $resInfo["monthList"]);
         }
-        $responseObj->code = 200;
-        return $responseObj;
+        return new Response(Response::SUCCESS, "");
     }
 
     private function validateIsEdit($checkState) {
-        $responseObj = new \stdClass();
-        if ($checkState != LaState::LA_SAVE && $checkState != LaState::LA_BEFORE_REJECT && $checkState != LaState::LA_FIRST_REJECT) {
-            if ($checkState == LaState::LA_NOTPASS) {
-                $responseObj->msg = "您的申报审核不通过,无法操作";
-            } else if ($checkState >= LaState::LA_PASS) {
-                $responseObj->msg = "您的申报已审核通过,无法操作";
-            } else {
-                $responseObj->msg = "您的申报正在审核中,请耐心等待";
-            }
-            $responseObj->code = 500;
-            return $responseObj;
+        if ($checkState != MainState::SAVE && $checkState != MainState::FIRST_REJECT) {
+            return new Response(Response::ERROR, "正在审核中,无法修改");
         }
-        $responseObj->code = 200;
-        return $responseObj;
+        return new Response(Response::SUCCESS, "");
     }
 
     /**
@@ -188,14 +192,14 @@ class House extends EnterpriseController {
     public function submitToCheck() {
         try {
             $id = $this->request["id"];
-            $info = CommonLaApi::getInfoById($id);
+            $info = HouseApi::getInfoById($id);
             if (!$info) {
                 throw new ValidateException("提交审核失败,请先填写基础信息");
             }
             if ($info["enterpriseId"] != $this->user["uid"]) {
                 throw new ValidateException("没有对应的人才认定申报信息");
             }
-            $batch = BatchApi::checkBatchValid(["type" => ProjectState::LIVINGALLOWANCE, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
+            $batch = BatchApi::checkBatchValid(["type" => ProjectState::HOUSE, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
             if ($batch["code"] != 200) {
                 throw new ValidateException($batch["msg"]);
             }
@@ -203,19 +207,19 @@ class House extends EnterpriseController {
             if ($response->code != 200) {
                 throw new ValidateException($response->msg);
             }
-            validate(LivingAllowanceValidator::class)->check($info);
-            $response = $this->other_validate($info);
+            validate(\app\enterprise\validate\HouseValidator::class)->check($info);
+            $response = $this->other_validate($info, 2);
             if ($response->code != 200) {
                 throw new ValidateException($response->msg);
             }
 
             $where = [];
             $where[] = ["mainId", "=", $id];
-            $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
+            $where[] = ["type", "=", ProjectState::HOUSE];
             $uploadedFileTypes = Db::table("new_talent_file")->where($where)->column("distinct typeId");
 
             $where = [];
-            $where[] = ["project", "=", ProjectState::LIVINGALLOWANCE];
+            $where[] = ["project", "=", ProjectState::HOUSE];
             $where[] = ["type", "=", $this->user["type"]];
             $where[] = ["must", "=", 1];
             $where[] = ["active", "=", 1];
@@ -278,7 +282,7 @@ class House extends EnterpriseController {
 
     public function save($info, \think\Request $request) {
         try {
-            $batch = BatchApi::checkBatchValid(["type" => ProjectState::LIVINGALLOWANCE, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
+            $batch = BatchApi::checkBatchValid(["type" => ProjectState::HOUSE, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
 
             if ($batch["code"] != 200) {
                 throw new ValidateException($batch["msg"]);
@@ -291,9 +295,10 @@ class House extends EnterpriseController {
             }
             $data = $request->param();
             $data["year"] = $batch["batch"];
-            validate(LivingAllowanceValidator::class)->check($data);
+            $data["type"] = $this->user["type"];
+            validate(\app\enterprise\validate\HouseValidator::class)->check($data);
 
-            $response = $this->other_validate($data);
+            $response = $this->other_validate($data, $info ? 2 : 1);
             if ($response->code != 200) {
                 throw new ValidateException($response->msg);
             }
@@ -306,75 +311,54 @@ class House extends EnterpriseController {
                 $data["checkState"] = $info["checkState"];
             } else {
                 $data["id"] = getStringId();
-                $data["active"] = 1;
-                $data["checkState"] = LaState::LA_SAVE;
-                $data["isPublic"] = 1;
-                $data["recommendIsPay"] = 0;
-                $data["isPay"] = 0;
-                $data["createTime"] = date("Y-m-d H:i:s");
+                $data["checkState"] = MainState::SAVE;
                 $data["createUser"] = $this->user["uid"];
-                $data["creditStatus"] = 1;
-                $count = count(CommonLaApi::getPassYearsByIdCard($data["idCard"]));
-                $data["applyCount"] = $count + 1;
-                if ($data["applyCount"] > 1 && !$data["personalTax"]) {
-                    throw new ValidateException("非首年申报必须填写个税缴交情况!");
-                }
-            }
-            $checkState = $data["checkState"];
-            $data["photo"] = $info["photo"];
-            if ($request->file()) {
-                $headimg = $request->file("file");
-                $upload = new \app\common\api\UploadApi();
-                $result = $upload->uploadOne($headimg, "image", "talent/photo");
-                if ($result->code != 200) {
-                    throw new ValidateException($result->msg);
-                }
-                $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["photo"]) {
-                    //如果新照片符合像素要求,则删除旧照片
-                    $old_head_url = "storage/" . $info["photo"];
-                    if (file_exists($old_head_url))
-                        @unlink($old_head_url);
-                }
-                $data["photo"] = $result->filepath;
-            }
-            if (!$data["photo"])
-                throw new ValidateException("请上传头像。*<span style='color:#ff0000;'>二寸像素标准[413*579]</span>");
-
+                $data["createTime"] = date("Y-m-d H:i:s");
+                $data["enterpriseId"] = $this->user["uid"];
+                $data["isConflict"] = 2;
+                $data["isRecover"] = 2;
 
-            if ($info["checkState"] == LaState::LA_FIRST_REJECT) {
-                //驳回,需要判断什么字段可以提交                
-                $modify_fields = array_filter(explode(",", $info["fields"]));
-                $tmp_data = $data;
-                $data = [];
-                foreach ($modify_fields as $field) {
-                    $data[$field] = $tmp_data[$field];
-                }
-                $data["id"] = $id;
+                $houseInfo = HouseApi::getHouseInfo($data["idCard"]);
+                $data["number"] = !$houseInfo ? 1 : $houseInfo["count"] + 1;
             }
+            $childList = $data["childList"];
+            unset($data["jstime"]);
+            unset($data["childList"]);
             if ($id) {
-                $res = LaModel::update($data);
+                $res = houseModel::update($data);
             } else {
-                $res = LaModel::insertGetId($data);
+                $res = houseModel::insertGetId($data);
             }
-            if ($res) {
-                return json(["code" => 200, "msg" => "保存成功", "obj" => ["id" => $data["id"], "checkState" => $checkState]]);
+            foreach ($childList as &$children) {
+                $children["pId"] = $data["id"];
+                if (\StrUtil::isEmpOrNull($children["id"])) {
+                    $children["id"] = getStringId();
+                    $children["createTime"] = date("Y-m-d H:i:s");
+                } else {
+                    $children["updateTime"] = date("Y-m-d H:i:s");
+                }
+            }
+            if ($childList) {
+                \app\common\model\HousePurchaseChildren::insertAll($childList);
             }
-            throw new ValidateException("保存失败");
+            //添加日志
+            \app\common\model\TalentChecklog::create([
+                'id' => getStringId(),
+                'mainId' => $data['id'],
+                'type' => intval(ProjectState::HOUSE),
+                'typeFileId' => null,
+                'active' => 1,
+                'state' => 1,
+                'step' => 0,
+                'stateChange' => "保存未提交",
+                'description' => "添加购房补贴申报",
+                'createTime' => date("Y-m-d H:i:s", time()),
+                'createUser' => "申报用户"
+            ]);
+            return json(new Response(Response::SUCCESS, "添加成功", $data));
         } catch (ValidateException $e) {
-            $responseObj = new \stdClass();
-            $responseObj->code = 500;
-            $responseObj->msg = $e->getMessage();
-            return json($responseObj);
+            return json(new Response(Response::ERROR, $e->getMessage()));
         } catch (\think\Exception $e) {
-            $res = ["code" => 500, "msg" => "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()];
             $logInfo = [
                 "enterprise_id" => $this->user["uid"],
                 "data" => $data,
@@ -384,7 +368,7 @@ class House extends EnterpriseController {
                 "errMsg" => $e->getMessage()
             ];
             Log::write($logInfo, "error");
-            return json($res);
+            return json(new Response(Response::ERROR, "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()));
         }
     }
 
@@ -417,37 +401,21 @@ class House extends EnterpriseController {
 
     public function getTalentInfo($id, $year, $declareType) {
         $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
-        if ($ti["enterpriseType"] == CommonConst::ENTERPRISE_NORMAL) {
-            $response = $this->getTalentArrange($ti, $year);
-            if ($response->code == 500) {
-                return $response;
-            }
-        }
-        if (en . getType() == 1) {
-            /* List<String> totalMonth = DateUtil.getMonthBetweenDates(year + "-01-01", year + "-12-31");
-              TalentInfo resInfo = (TalentInfo) responseObj.getObj();
-              ti.setTalentArrange(resInfo.getTalentArrange());
-              ti.setIdentifyCondition(resInfo.getIdentifyCondition());
-              ti.setIdentifyConditionName(resInfo.getIdentifyConditionName());
-              ti.setIdentifyGetTime(resInfo.getIdentifyGetTime());
-              ti.setCertificateStartTime(resInfo.getCertificateStartTime());
-              ti.setQzgccrcActiveTime(resInfo.getQzgccrcActiveTime());
-              /**校验上一年度人才标签 */
-            /* responseObj = getTalentType(ti, declareType);
-              if (responseObj.getCode() == 500) {
-              return responseObj;
-              }
-              TalentQuit resQuit = (TalentQuit) responseObj.getObj();
-              ti.setTalentType(resQuit.getTalentType()); */
+        $response = $this->getTalentArrange($ti, $year);
+        if ($response->code == 500) {
+            return $response;
         }
+        $resTalentInfo = $response->obj;
+        $ti["talentArrange"] = $resTalentInfo["talentArrange"];
+        $ti["identifyCondition"] = $resTalentInfo["identifyCondition"];
+        $ti["identifyConditionName"] = $resTalentInfo["identifyConditionName"];
+        $ti["identifyMonth"] = $resTalentInfo["identifyMonth"];
+        $ti["identifyGetTime"] = $resTalentInfo["identifyGetTime"];
+        $ti["certificateStartTime"] = $resTalentInfo["certificateStartTime"];
+        $ti["certificateOutTime"] = $resTalentInfo["certificateOutTime"];
         //查询房产库中是否存在房产信息
-        /* Housepurchase housepurchase = new Housepurchase();
-          housepurchase.setIdCard(ti.getIdCard());
-          HousepurchaseHouseInfo houseInfo = HousepurchaseUtil.getHouseInfo(housepurchase.getIdCard());
-          Map<String, Object> res = new HashMap<>();
-          res.put("talentInfo", ti);
-          res.put("houseInfo", houseInfo);
-          return new ResponseObj(ResponseObj.SUCCESS, "", res); */
+        $houseInfo = HouseApi::getHouseInfo($ti["card_number"]);
+        return new Response(Response::SUCCESS, "", ["talentInfo" => $ti, "houseInfo" => $houseInfo]);
     }
 
     /**
@@ -477,10 +445,8 @@ class House extends EnterpriseController {
         $where[] = ["checkState", "=", MainState::PASS];
         $where[] = ["isPublic", "=", 6];
         $where[] = [$oldStartTimeField, "<=", $year . "-12-31"];
-        $typeChanges = TalentTypeChange::where($where)->field("oldTalentArrange,oldIdentifyCondition,oldIdentifyGetTime,oldIdentifyOutTime,oldIdentifyConditionName,oldIdentifyMonth,oldCertificateStartTime,oldCertificateOutTime,newIdentifyMonth,newIdentifyGetTime")->order("createTime desc")->select()->toArray();
-        $jjList = [];
-        $unionList = [];
-        $totalMonth = \DateUtil::getMonthBetweenDates($year . "-01-01", $year . "-12-31");
+        $typeChanges = \app\enterprise\model\TalentTypeChange::where($where)->field("oldTalentArrange,oldIdentifyCondition,oldIdentifyGetTime,oldIdentifyOutTime,oldIdentifyConditionName,oldIdentifyMonth,oldCertificateStartTime,oldCertificateOutTime,newIdentifyMonth,newIdentifyGetTime")->order("createTime desc")->select()->toArray();
+
         if (!$typeChanges && strtotime($year . "-12-31") > strtotime($talentInfo[$identifyTimeField])) {
             return new Response(Response::ERROR, "在上一年度未认定优秀人才,无法申报");
         } else {
@@ -496,23 +462,42 @@ class House extends EnterpriseController {
                 "newIdentifyMonth" => ($year + 1) . "-01-01",
                 "newIdentifyGetTime" => ($year + 1) . "-01-01"
             ];
+            $totalMonth = \DateUtil::getMonthBetweenDates($year . "-01-01", $year . "-12-31");
+            usort($typeChanges, function($a, $b) {
+                return (int) $b["oldTalentArrange"] - (int) $a["oldTalentArrange"];
+            });
+            $months = []; //当年度可用月份
+            $talentArrange = 8; //当年度最高层次
+            $resTalentInfo = [];
             foreach ($typeChanges as $typeChange) {
-                $monthList = \DateUtil::getMonthBetweenDatesNotEnd($typeChange["oldCertificateStartTime"], $typeChange["oldCertificateOutTime"]);
-                $res = \DateUtil::getEveryMonthDayBetween($typeChange["oldCertificateStartTime"], $typeChange["oldCertificateOutTime"], $monthList);
-            }
-
-
-            for (TalentTypeChange typeChange : typeChanges) {
-                List<String> monthList = DateUtil . getMonthBetweenDatesNotEnd(typeChange . getOldCertificateStartTime(), typeChange . getOldCertificateOutTime());
-                Map<String, Integer> res = DateUtil . getEveryMonthDayBetween(typeChange . getOldCertificateStartTime(), typeChange . getOldCertificateOutTime(), monthList);
-                if (res . size() > 0) {
-                    unionList . removeAll(monthList);
-                    unionList . addAll(monthList);
-                    TalentInfo info = new TalentInfo(typeChange . getOldTalentArrange(), typeChange . getOldIdentifyCondition(), typeChange . getOldIdentifyGetTime(), typeChange . getOldIdentifyConditionName(), typeChange . getOldCertificateStartTime(), typeChange . getOldCertificateOutTime(), typeChange . getOldIdentifyMonth());
-                    info . setDayMap(res);
-                    jjList . add(info);
+                $startTime = $typeChange[$oldStartTimeField];
+                $endTime = $typeChange[$newStartTimeField];
+                $monthList = \DateUtil::getMonthBetweenDatesNotEnd($startTime, $endTime);
+                $res = \DateUtil::getEveryMonthDayBetween($endTime, $endTime, $monthList);
+                $intersectMonthList = array_intersect($totalMonth, $monthList);
+                if (count($intersectMonthList) > 0) {
+                    if ($typeChange["oldTalentArrange"] < $talentArrange) {
+                        //按当年度最高
+                        $talentArrange = $typeChange["oldTalentArrange"];
+                        $resTalentInfo = [
+                            "talentArrange" => $typeChange["oldTalentArrange"],
+                            "identifyCondition" => $typeChange["oldIdentifyCondition"],
+                            "identifyGetTime" => $typeChange["oldIdentifyGetTime"],
+                            "identifyConditionName" => $typeChange["oldIdentifyConditionName"],
+                            "certificateStartTime" => $typeChange["oldCertificateStartTime"],
+                            "certificateOutTime" => $typeChange["oldCertificateOutTime"],
+                            "identifyMonth" => $typeChange["oldIdentifyMonth"],
+                            "dayMap" => $res
+                        ];
+                    }
+                    $months = array_unique(array_merge($months, $intersectMonthList));
                 }
             }
+            $resTalentInfo["monthList"] = $months;
+            if (count($months) < 9) {
+                return new Response(Response::ERROR, "申报年度人才证书有效期未满足九个月,无法申报购房补贴");
+            }
+            return new Response(Response::SUCCESS, "", $resTalentInfo);
         }
     }
 

+ 129 - 0
app/enterprise/validate/HouseValidator.php

@@ -0,0 +1,129 @@
+<?php
+
+namespace app\enterprise\validate;
+
+use think\Validate;
+
+/**
+ * Description of HouseValidator
+ * @author sgq
+ */
+class HouseValidator extends Validate {
+
+    protected $rule = [
+        "type" => "require",
+        "name" => "require",
+        "cardType" => "require",
+        "idCard" => "require|checkCardNumber",
+        "declareObject" => "require",
+        "declareType" => "require|checkDeclareType",
+        "phone" => "require|mobile",
+        "marryStatus" => "require"
+    ];
+    protected $message = [
+        "type.require" => "人才类别不能为空",
+        "name.require" => "姓名不能为空",
+        "cardType.require" => "证件类型不能为空",
+        "idCard.require" => "证件号码不能为空",
+        "declareObject.require" => "申报对象不能为空",
+        "declareType.require" => "申报类型不能为空",
+        "phone.require" => "手机号码不能为空",
+        "phone.mobile" => "手机号格式不正确",
+        "marryStatus.require" => "婚姻状态不能为空"
+    ];
+
+    protected function checkCardNumber($value, $rule, $data = []) {
+        if (!$data["cardType"]) {
+            return "填写证件号码前请先选择证件类型";
+        }
+        if ($data["cardType"] == 1) {
+            $num = strlen($value);
+            switch ($num) {
+                case 15:
+                case 18:
+                    return \app\common\api\IdCardApi::isValid($value) ?: "身份证号码不合法";
+                    break;
+                default:
+                    //return \app\common\api\IdCardApi::isValidExceptMainland($value) ?: "身份证号码不合法";
+                    break;
+            }
+            return "身份证号码不合法";
+        } else if ($data["cardType"] == 2) {
+            if (preg_match("/^[a-zA-Z0-9]{6,10}$/", $value) || preg_match("/^([0-9]{8}|[0-9]{10})$/", $value)) {
+                return true;
+            }
+            return "通行证号码不合法";
+        } else {
+            if (preg_match("/^([a-zA-z]|[0-9]){5,17}$/", $value)) {
+                return true;
+            }
+            return "护照号码不合法";
+        }
+    }
+
+    protected function checkDeclareType($value, $rule, $data = []) {
+        if ($value == 1) {
+
+            if (\StrUtil::isEmpOrNull($data["houseAddress"])) {
+                return "房屋坐落地址不能为空";
+            }
+            if (!$data["houseArea"]) {
+                return "房屋建筑面积不能为空";
+            }
+            if (\StrUtil::isEmpOrNull($data["recordTime"])) {
+                return "商品房购房合同备案时间不能为空";
+            }
+            if (!$data["houseMoney"]) {
+                return "房屋成交金额不能为空";
+            }
+            if (!$data["isEnjoyOther"]) {
+                return "是否享受我市其他政策不能为空";
+            }
+            if (\StrUtil::isEmpOrNull($data["realEstateNo"]) && \StrUtil::isEmpOrNull($data["recordNo"])) {
+                return "不动产权证编号和备案合同编号至少填写一个";
+            }
+            if (\StrUtil::isNotEmpAndNull($data["realEstateNo"]) && !preg_match("/^闽(\\(|()[0-9]{4}(\\)|))晋江市不动产权第(\\(|()[0-9]+(\\)|))号$/", $data["realEstateNo"])) {
+                return "不动产权证编号格式不正确";
+            }
+            if (\StrUtil::isNotEmpAndNull($data["recordNo"]) && !preg_match("/^\\d{12}$/", $data["recordNo"])) {
+                return "备案合同编号格式不正确";
+            }
+        }
+        return true;
+    }
+
+    protected function checkRangeDate($value, $rule, $data = []) {
+        $title = "";
+        $format = "[yyyy-MM-dd - yyyy-MM-dd]";
+        $str = "日期";
+        switch ($rule) {
+            case "tax_insurance_month":
+                $format = "[yyyy-MM - yyyy-MM]";
+                $str = "月份";
+                if ($data["talent_type"] == 1) {
+                    $title = "缴交社会保险或个人所得税月份";
+                }
+                if ($data["talent_type"] == 2) {
+                    $title = "首次在我市缴交社会保险或个人所得税月份";
+                }
+                break;
+            case "labor_contract_rangetime":
+                $title = "劳动合同起止时间";
+                break;
+            case "salary_pay_month":
+                $format = "[yyyy-MM - yyyy-MM]";
+                $str = "月份";
+                $title = "工资发放月份";
+                break;
+        }
+        $arr = explode(" - ", $value);
+        $chk1 = strtotime($arr[0]);
+        $chk2 = strtotime($arr[1]);
+        if (!$chk1 || !$chk2)
+            return "{$title}日期范围格式应为{$format}";
+        if ($chk1 > $chk2)
+            return "{$title}起始{$str}不能大于结束{$str}";
+        return true;
+    }
+
+}

+ 3 - 2
app/enterprise/view/house/apply.html

@@ -87,7 +87,6 @@
                                                 <input type="hidden" name="type" id="type" value="{$type}">
                                                 <input type="hidden" name="year" id="year" value="{$year}">
                                                 <input type="hidden" name="checkState" id="checkState" value="{$row.checkState}">
-                                                <input type="hidden" name="talentId" id="talentId" value="{$row.talentId}">
                                                 <input type="hidden" name="files" id="files" value="{$row.files}">
                                                 <input type="hidden" name="fields" id="fields" value="{$row.fields}">
                                                 <div class="bs-callout bs-callout-info" id="callout-helper-context-color-specificity">
@@ -114,8 +113,10 @@
                                                                 <label class=" control-label spacing"><span style="color: red">*</span>姓名</label>
                                                                 {if condition="$row['id']"}
                                                                 <input type="text" class="form-control" readonly="readonly" id="name" name="name" value="{$row.name}" >
+                                                                <input type="hidden" name="talentId" id="talentId" value="{$row.talentId}">
                                                                 {else/}
-                                                                <select type="text" class="form-control" id="name" name="name" onchange="HousepurchaseInfoDlg.nameChange()"></select>
+                                                                <select type="text" class="form-control" id="talentId" name="talentId" onchange="HousepurchaseInfoDlg.nameChange()"></select>
+                                                                <input type="hidden" name="name" id="name">
                                                                 {/if}
                                                             </div>
                                                             <div class="rowGroup col-sm-3">

+ 0 - 1
extend/DateUtil.php

@@ -59,7 +59,6 @@ class DateUtil {
 
     public static function getEveryMonthDayBetween($startTime, $endTime, $monthList) {
         $res = [];
-        $sdf = new DateTimeFormatter('yyyy-MM-dd');
 
         $min = new DateTime($startTime);
         $min->setTime(0, 0, 0);

+ 1 - 1
public/static/modular/gate/house/housepurchase.js

@@ -194,7 +194,7 @@ Housepurchase.openHousepurchaseDetail = function () {
         });
         ajax.set("type", CONFIG.project_house);
         ajax.set("year", Housepurchase.seItem.year);
-        ajax.set("first_submit_time", TalentAllowanceInfo.seItem.firstSubmitTime);
+        ajax.set("first_submit_time", Housepurchase.seItem.firstSubmitTime);
         ajax.start();
     }
 };

+ 22 - 22
public/static/modular/gate/house/housepurchase_info.js

@@ -186,11 +186,11 @@ HousepurchaseInfoDlg.validate = function () {
 }
 
 HousepurchaseInfoDlg.nameChange = function () {
-    var talentId = $("#name").val();
+    var talentId = $("#talentId").val();
     var declareType = $("#declareType").val();
     if (Feng.isEmptyStr(declareType)) {
         Feng.info("请先选择申报类型");
-        $("#name").val("").trigger('chosen:updated');
+        $("#talentId").val("").trigger('chosen:updated');
         ;
         return;
     }
@@ -199,26 +199,26 @@ HousepurchaseInfoDlg.nameChange = function () {
             if (data.code == 200) {
                 var talentInfo = data.obj.talentInfo;
                 var houseInfo = data.obj.houseInfo;
-                if (houseInfo.count >= 5) {
+                if (houseInfo && houseInfo.count >= 5) {
                     Feng.info("当前申报人所关联房产已享受5次补贴,无法再次申报");
                     return;
                 }
                 $("#name").val(talentInfo.name);
-                $("#cardType").val(talentInfo.cardType);
-                $("#idCard").val(talentInfo.idCard);
-                $("#provinceCode").val(talentInfo.provinceCode).trigger("change");
-                $("#cityCode").val(talentInfo.cityCode).trigger("change");
-                $("#countyCode").val(talentInfo.countyCode);
-                $("#street").val(talentInfo.address);
+                $("#cardType").val(talentInfo.card_type);
+                $("#idCard").val(talentInfo.card_number);
+                $("#provinceCode").val(talentInfo.province).trigger("change");
+                $("#cityCode").val(talentInfo.city).trigger("change");
+                $("#countyCode").val(talentInfo.county);
+                $("#street").val(talentInfo.street);
                 $("#phone").val(talentInfo.phone);
                 $("#bank").val(talentInfo.bank);
-                $("#bankNumber").val(talentInfo.bankNumber);
-                $("#bankNetwork").val(talentInfo.bankNetwork);
-                $("#bankAccount").val(talentInfo.bankAccount);
+                $("#bankNumber").val(talentInfo.bank_number);
+                $("#bankNetwork").val(talentInfo.bank_branch_name);
+                $("#bankAccount").val(talentInfo.bank_account);
                 $("#talentArrange").val(talentInfo.talentArrange).trigger("change");
                 $("#certificateStartTime").val(talentInfo.certificateStartTime);
-                $("#certificateEndTime").val(talentInfo.qzgccrcActiveTime);
-                $("#identifyCondition").val(talentInfo.identifyCondition);
+                $("#certificateEndTime").val(talentInfo.certificateOutTime);
+                $("#identifyCondition").val(talentInfo.talent_condition);
                 $("#idenfityConditionName").val(talentInfo.identifyConditionName);
                 $("#identifyGetTime").val(talentInfo.identifyGetTime);
                 if (Feng.isNotEmptyStr(houseInfo)) {
@@ -351,7 +351,7 @@ HousepurchaseInfoDlg.addSubmit = function () {
         }
     });
     this.housepurchaseInfoData['childList'] = child;
-    var ajax = new $ax(Feng.ctxPath + "/api/housepurchase/add", function (data) {
+    var ajax = new $ax(Feng.ctxPath + "/enterprise/house/apply", function (data) {
         if (data.code == 200) {
             var obj = data.obj;
             var childList = obj.childList;
@@ -360,7 +360,7 @@ HousepurchaseInfoDlg.addSubmit = function () {
             $("#type").val(obj.type);
             $("#fileLi").removeAttr("style");
             $("#checkState").val(obj.checkState);
-            $("#name").prop("disabled", true).trigger("chosen:updated");
+            $("#talentId").prop("disabled", true).trigger("chosen:updated");
             HousepurchaseInfoDlg.initChildData(childList);
         } else {
             Feng.info(data.msg);
@@ -412,7 +412,7 @@ HousepurchaseInfoDlg.editSubmit = function (type) {
     });
     this.housepurchaseInfoData['childList'] = child;
     //提交信息
-    var ajax = new $ax(Feng.ctxPath + "/api/housepurchase/update", function (data) {
+    var ajax = new $ax(Feng.ctxPath + "/enterprise/house/apply", function (data) {
         if (data.code == 200) {
             if (type == 1) {
                 var childList = data.obj.childList;
@@ -575,7 +575,7 @@ HousepurchaseInfoDlg.getIdentifyCondition = function () {
         "displayCode": "id",
         "displayName": "name",
         "type": "GET",
-        "url": Feng.ctxPath + "/api/common/findIdentifyConditionByLevel?talentLevel=" + level
+        "url": Feng.ctxPath + "/common/api/findIdentifyConditionByLevel?level=" + level
     });
 }
 
@@ -664,7 +664,7 @@ HousepurchaseInfoDlg.getHouseInfo = function () {
         Feng.info("请选择申报人");
         return;
     }
-    var ajax = new $ax(Feng.ctxPath + "/api/housepurchase/getHouseInfo", function (data) {
+    var ajax = new $ax(Feng.ctxPath + "/enterprise/house/getHouseInfo", function (data) {
         if (data.code == 200) {
             var houseInfo = data.obj;
             if (houseInfo.count >= 5) {
@@ -702,7 +702,7 @@ HousepurchaseInfoDlg.getHouseInfo = function () {
 $(function () {
     Feng.initValidatorTip("houseInfoForm", HousepurchaseInfoDlg.validateFields);
     Feng.addAjaxSelect({
-        "id": 'name',
+        "id": 'talentId',
         "displayCode": "id",
         "displayName": "name",
         "type": "GET",
@@ -735,10 +735,10 @@ $(function () {
         Feng.getCheckLog("logTable", {"type": CONFIG.project_house, "mainId": id, "typeFileId": "", "active": 1})
     } else {
         $("#fileLi").attr("style", "pointer-events: none");
-        $("#name").on('chosen:ready', function (e, params) {
+        $("#talentId").on('chosen:ready', function (e, params) {
             $(".chosen-container-single .chosen-single").css("padding", "4px 0px 0px 4px");
         });
-        $("#name").chosen({
+        $("#talentId").chosen({
             search_contains: true,       //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
             disable_search: false,
             width: "100%",