Browse Source

购房补贴++

sugangqiang 10 months ago
parent
commit
b3e640cee9

+ 287 - 140
app/admin/controller/House.php

@@ -211,6 +211,10 @@ class House extends AdminController {
             $data["id"] = $id;
             if ($checkState == 2) {
                 if ($toProcess == 2) {
+                    $depCodes = getJsonConfig("../sys_config.json", "housepurchase_dep_list")[$old["type"]];
+                    if (!$depCodes || count($depCodes) == 0) {
+                        return new Response(Response::ERROR, "没有配置部门审核,不能选择驳回至部门审核");
+                    }
                     $where = [];
                     $where[] = ["code", "in", $toDep];
                     $companyIds = \app\common\model\Company::where($where)->column("id");
@@ -292,22 +296,29 @@ class House extends AdminController {
                         /*                         * 生成各部门数据审核 */
                         $depList = [];
                         $depCodes = getJsonConfig("../sys_config.json", "housepurchase_dep_list")[$old["type"]];
-                        $where = [];
-                        $where[] = ["code", "in", $depCodes];
-                        $companies = \app\common\model\Company::where($where)->select()->toArray();
-                        foreach ($companies as $company) {
-                            $depList[] = [
-                                "id" => getStringId(),
-                                "type" => ProjectState::HOUSE,
-                                "mainId" => $id,
-                                "companyId" => $company["id"],
-                                "state" => 1,
-                                "createTime" => date("Y-m-d H:i:s"),
-                                "createUser" => $this->user["name"]
-                            ];
+                        if ($depCodes && count($depCodes) > 0) {
+                            $where = [];
+                            $where[] = ["code", "in", $depCodes];
+                            $companies = \app\common\model\Company::where($where)->select()->toArray();
+                            foreach ($companies as $company) {
+                                $depList[] = [
+                                    "id" => getStringId(),
+                                    "type" => ProjectState::HOUSE,
+                                    "mainId" => $id,
+                                    "companyId" => $company["id"],
+                                    "state" => 1,
+                                    "createTime" => date("Y-m-d H:i:s"),
+                                    "createUser" => $this->user["name"]
+                                ];
+                            }
+                            Db::table("un_talent_depcheckstate")->insertAll($depList);
+                            $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
+                        } else {
+                            if (\StrUtil::isEmpOrNull($old["depPassTime"])) {
+                                $housepurchase["depPassTime"] = date("Y-m-d H:i:s");
+                            }
+                            $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
                         }
-                        Db::table("un_talent_depcheckstate")->insertAll($depList);
-                        $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
                     }
                     if (\StrUtil::isEmpOrNull($old["firstPassTime"])) {
                         $housepurchase["firstPassTime"] = date("Y-m-d H:i:s");
@@ -336,7 +347,10 @@ class House extends AdminController {
                     'createTime' => date("Y-m-d H:i:s", time()),
                     'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
                 ]);
-                TalentChecklog::delete($log["id"]);
+                $where = [];
+                $where[] = ["mainId", "=", $id];
+                $where[] = ["active", "=", 2];
+                TalentChecklog::where($where)->delete();
                 houseModel::update($housepurchase);
                 break;
             case 2:
@@ -383,7 +397,10 @@ class House extends AdminController {
                     'createTime' => date("Y-m-d H:i:s", time()),
                     'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
                 ]);
-                TalentChecklog::delete($log["id"]);
+                $where = [];
+                $where[] = ["mainId", "=", $id];
+                $where[] = ["active", "=", 2];
+                TalentChecklog::where($where)->delete();
                 break;
             case 3:
                 if ($checkState == -1) {
@@ -425,93 +442,158 @@ class House extends AdminController {
                     $where[] = ["year", "=", $old["year"]];
                     $where[] = ["delete", "=", 0];
                     $info = \app\common\model\TalentAllowance::where($where)->find();
-                    if (!$info) {
-                        return new Response(Response::ERROR, "当前申报人暂未申报津补贴,无法审核通过");
-                    }
-                    if ($info["checkState"] != \app\common\state\AllowanceStateEnum::REVIEW_PASS || $info["publicState"] < 4) {
-                        return new Response(Response::ERROR, "当前申报人的津补贴申报暂未公示通过,无法审核通过");
+                    if ($info["checkState"] == \app\common\state\AllowanceStateEnum::REVIEW_PASS && $info["publicState"] == 4) {
+                        $housepurchase["allowanceType"] = $info["allowanceType"];
                     }
                     $housepurchase["cashType"] = $old["cashType"];
-                    $descideDesc[] = "审核意见:" . $log["description"] . ";系统根据津补贴情况判断说明:";
-                    /*                     * 1.判断征信信息 */
-                    if (\StrUtil::isNotEmpAndNull($info["outMsg"]) && $info["checkState"] == \app\common\state\AllowanceStateEnum::NOTPASS) {
-                        $housepurchase["zxMsg"] = $info["outMsg"];
-                        $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
-                        $housepurchase["cashType"] = 2;
-                        $descideDesc[] = "(1)核查征信结果:" . $info["outMsg"] . ";无法享受";
-                    } else {
-                        $descideDesc[] = "(1)核查征信结果:征信通过;";
-                        $housepurchase["zxMsg"] = "";
-                        $housepurchase["checkState"] = HouseStateEnum::REVIEW_PASS;
-                    }
-                    /*                     * 2.获取社保/个税数据并判断是否可以享受* */
+                    $descideDesc[] = "审核意见:" . $log["description"] . ";";
+                    $housepurchase["checkState"] = HouseStateEnum::REVIEW_PASS;
                     if ($old["declareType"] == 1) {              //购房补贴
-                        $sbSet = [];
-                        if ($old["type"] == 1) {
-                            sbSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB . getCode());
-                        } else {
-                            Set<String> pensionSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_PENSION . getCode());
-                            Set<String> unemploymentSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_UNEMPLOYMENT . getCode());
-                            Set<String> medicalSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_MEDICA . getCode());
-                            pensionSet . retainAll(unemploymentSet);
-                            pensionSet . retainAll(medicalSet);
-                            sbSet . addAll(pensionSet);
-                        }
-                        Set<String> taxSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_TAX . getCode());
-                        housepurchase . setSbPayDetail(sbSet . stream() . collect(Collectors . joining(",")));
-                        housepurchase . setTaxPayDetail(taxSet . stream() . collect(Collectors . joining(",")));
-                        housepurchase . setAllowanceType(info . getAllowanceType());
-                        /*                         * 获取社保个税交集 */
-                        Set<String> totalMonth = new TreeSet <> (Arrays . asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"));
-                        totalMonth . retainAll(sbSet);
-                        taxSet . retainAll(taxSet);
-                        /*                         * 判断是否享受人才津贴 */
-                        if (info . getAllowanceType() != 1 && housepurchase . getCashType() == 1) {
-                            housepurchase . setCashType(2);
-                            descideDesc . append("(2)上一年度未享受人才津贴,无法享受;");
-                        } else {
-                            descideDesc . append("(2)上一年度享受人才津贴;");
-                        }
-                        /*                         * 判断社保个税共同缴纳是否满足几个月 */
-                        if (totalMonth . size() < 9 && housepurchase . getCashType() == 1) {
-                            housepurchase . setCashType(2);
-                            descideDesc . append("(3)社保和个税上一年度共同缴纳未满足9个月,无法享受;");
-                        } else {
-                            descideDesc . append("(3)社保和个税上一年度共同缴纳满足9个月;");
-                        }
-                        housepurchase . setDecideDetail(descideDesc . toString());
                         /*                         * 对需要兑现的计算享受金额 */
-                        if (housepurchase . getCashType() == 1) {
-                            ResponseObj responseObj = calculateOld(old, housepurchase, descideDesc, 1);
-                            if (responseObj . getCode() == 500) {
-                                return responseObj;
+                        if ($housepurchase["cashType"] == 1) {
+                            $result = $this->calculate($old, $housepurchase, $descideDesc, 1);
+                            if ($result->code == 500) {
+                                return $result;
                             }
                         }
-                    } else if (old . getDeclareType() == 2) {      //免租入住
-                        Set<String> set = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_LETTER . getCode());
-                        housepurchase . setLetterDetail(set . stream() . collect(Collectors . joining(",")));
-                        if (set . size() < 9 && housepurchase . getCashType() == 1) {
-                            housepurchase . setCashType(2);
-                            housepurchase . setDecideDetail("(2)上一年度行政介绍信未满足9个月");
-                        } else {
-                            housepurchase . setDecideDetail("(2)上一年度行政介绍信满足9个月");
-                        }
                     }
-                    if (FengStringUtil . isEmpOrNull(old . getReviewPassTime())) {
-                        housepurchase . setReviewPassTime(DateUtil . getTime());
+                    $housepurchase["decideDetail"] = implode("", $descideDesc);
+                    if (\StrUtil::isEmpOrNull($old["reviewPassTime"])) {
+                        $housepurchase["reviewPassTime"] = date("Y-m-d H:i:s");
                     }
                 }
-                TalentChecklog newLog3 = new TalentChecklog(ProjectEnum . HOUSE . getCode(), obj . getId(), null, StateConst . ACTIVE_YES, checkState,
-                        obj . getProcess(), HousePurechaseStateEnum . valueOf(old . getCheckState()) + "->" + HousePurechaseStateEnum . valueOf(housepurchase . getCheckState()), log . getDescription(), DateUtil . getTime(),
-                        ShiroKit . getUser() . getAccount() + "(" + company . getName() + ")");
-                this.talentChecklogService.delete(new EntityWrapper<TalentChecklog>().eq("mainId", obj.getId()).eq("active", StateConst.ACTIVE_NO));
-                this . talentChecklogService . insert(newLog3);
-                this . housepurchaseService . updateById(housepurchase);
+                //添加日志
+                TalentChecklog::create([
+                    'id' => getStringId(),
+                    'mainId' => $id,
+                    'type' => intval(ProjectState::HOUSE),
+                    'typeFileId' => null,
+                    'active' => 1,
+                    'state' => $checkState,
+                    'step' => $process,
+                    'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
+                    'description' => $log["description"],
+                    'createTime' => date("Y-m-d H:i:s", time()),
+                    'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
+                ]);
+                $where = [];
+                $where[] = ["mainId", "=", $id];
+                $where[] = ["active", "=", 2];
+                TalentChecklog::where($where)->delete();
+                houseModel::update($housepurchase);
                 break;
         }
         return new Response(Response::SUCCESS, "提交审核成功");
     }
 
+    /**
+     * 撤销审核
+     * @return \app\admin\controller\ResponseObj
+     */
+    public function cancleThirdCheck() {
+        $id = $this->request["id"];
+        $checkMsg = $this->request["checkMsg"];
+        if (\StrUtil::isEmpOrNull($id)) {
+            return new Response(Response::ERROR, "请选择需要撤销的对象");
+        }
+        $old = HouseApi::getInfoById($id);
+        if ($old["checkState"] != HouseStateEnum::REVIEW_PASS) {
+            return new Response(Response::ERROR, "当前对象不是复核通过状态,无法撤销");
+        }
+        if ($old["publicState"] != 1) {
+            return new Response(Response::ERROR, "当前对象不是待公示状态,无法撤销");
+        }
+        $data["id"] = $id;
+        $data["checkMsg"] = $checkMsg;
+        $data["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
+        $data["cashIdCards"] = "";
+        $data["cashType"] = null;
+        $data["decideMoneyDetail"] = "";
+        $data["decideDetail"] = "";
+        $where = [];
+        $where[] = ["mainId", "=", $id];
+        $count = Db::table("un_talent_depcheckstate")->where($where)->count();
+        $data["highProcess"] = $count > 0 ? 2 : 1;
+
+        //添加日志
+        TalentChecklog::create([
+            'id' => getStringId(),
+            'mainId' => $id,
+            'type' => intval(ProjectState::HOUSE),
+            'typeFileId' => null,
+            'active' => 1,
+            'state' => 11,
+            'step' => 3,
+            'stateChange' => HouseStateEnum::getStateName($old["checkState"]) . "->" . HouseStateEnum::getStateName($data["checkState"]),
+            'description' => "撤销原因:" . $checkMsg,
+            'createTime' => date("Y-m-d H:i:s", time()),
+            'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
+        ]);
+        houseModel::update($data);
+        return new Response(Response::SUCCESS, "撤销成功");
+    }
+
+    /**
+     * @param type
+     * @description 查询需要审核的数据(待核查征信 /待公示 / 待公示通过 / 待兑现)
+     * */
+    public function selectNeedCheckData() {
+        $type = $this->request["type"];
+        $name = $this->request["name"];
+        $idCard = $this->request["idCard"];
+        $where = [];
+        if (\StrUtil::isNotEmpAndNull($name)) {
+            $where[] = ["name", "like", "%$name%"];
+        }
+        if (\StrUtil::isNotEmpAndNull($idCard)) {
+            $where[] = ["idCard", "like", "%$idCard%"];
+        }
+        $where[] = ["type", "=", $this->user["type"]];
+        $field = "id,year,idCard,name,enterpriseId";
+        $error = null;
+        switch ($type) {
+            case -1:
+            case 0:
+                $where[] = ["publicState", "=", 1];
+                $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
+                $error = "暂无可核查征信的数据";
+                break;
+            case 1:
+            case 5:
+                $where[] = ["publicState", "=", 2];
+                $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
+                $where[] = ["cashType", "=", 1];
+                $error = "暂无可公示(兑现)的数据";
+                break;
+            case 2:
+            case 6:
+                $where[] = ["publicState", "=", 2];
+                $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
+                $where[] = ["cashType", "=", 2];
+                $error = "暂无可公示(不予兑现)的数据";
+                break;
+            case 3:
+                $where[] = ["publicState", "=", 3];
+                $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
+                $error = "暂无需要公示通过的数据";
+                break;
+            case 4:
+                $where[] = ["publicState", "=", 4];
+                $where[] = ["checkState", "in", [HouseStateEnum::REVIEW_PASS]];
+                $where[] = ["cashType", "=", 1];
+                $error = "暂无待兑现的数据";
+                break;
+        }
+        $list = HouseApi::getList($where, $field);
+        //查询企业信息        
+        $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
+        foreach ($list as &$row) {
+            $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
+        }
+        $res = ["rows" => $list, "total" => count($list)];
+        return new Response(Response::SUCCESS, "", $res);
+    }
+
     public function exportHczx() {
         $response = new \stdClass();
         $response->code = 500;
@@ -558,35 +640,33 @@ class House extends AdminController {
         if (!$param) {
             return new Response(Response::ERROR, "系统错误,请联系管理员");
         }
-        $old = TalentAllowanceApi::getInfoById($param["id"]);
+        $old = HouseApi::getInfoById($param["id"]);
         if ($old["publicState"] != 1) {
             return new Response(Response::ERROR, "当前记录不是待核查征信状态,无法核查");
         }
+
         $data["id"] = $param["id"];
+        $data["checkState"] = HouseStateEnum::NOTPASS;
         $data["publicState"] = 2;
-        $data["checkState"] = AllowanceStateEnum::NOTPASS;
-        $data["recommendAllowanceType"] = 3;
-        $data["recommendAllowanceMsg"] = "征信失信,不予兑现,失信原因:" . $param["outMsg"];
-        $data["recommendMonths"] = "";
-        $data["recommendMoney"] = 0.00;
-        $data["workAllowanceMoney"] = null;
-        $data["developAllowanceMoney"] = null;
+        $data["zxMsg"] = $param["outMsg"];
+        $data["cashType"] = 2;
+        $data["descideDesc"] = $old . "(1)核查征信结果:" . $param["outMsg"] . ";无法享受";
 
         //添加日志
         TalentChecklog::create([
             'id' => getStringId(),
             'mainId' => $param["id"],
-            'type' => intval(ProjectState::JBT),
+            'type' => intval(ProjectState::HOUSE),
             'typeFileId' => null,
             'active' => 1,
             'state' => 2,
             'step' => 4,
-            'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "-><span class='label label-primary'>审核不通过</span>" . "公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
+            'stateChange' => HouseStateEnum::getStateName($old["checkState"]) . "->" . HouseStateEnum::getStateName($data["checkState"]) . "<br>公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
             'description' => $param["outMsg"],
             'createTime' => date("Y-m-d H:i:s", time()),
             'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
         ]);
-        TaModel::update($data);
+        houseModel::update($data);
         return new Response(Response::SUCCESS, "核查征信成功");
     }
 
@@ -664,7 +744,7 @@ class House extends AdminController {
                 ];
                 $phones[] = $info["phone"];
             }
-            $data["publicState"] = 2;
+            $data["publicState"] = 3;
             Db::table("un_housepurchase")->where($where)->update($data);
             $effect = Db::table("new_talent_checklog")->insertAll($logList);
             Db::commit();
@@ -709,33 +789,6 @@ class House extends AdminController {
         return view("public_check", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
     }
 
-    /**
-     * 公示再审核计算津补贴
-     * */
-    public function suppleCheckCalculate() {
-        $id = $this->request["id"];
-        try {
-            $info = TalentAllowanceApi::getInfoById($id);
-            $arrangeList = $this->validateAllowanceType($info);
-            $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
-            $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
-            $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
-            foreach ($detailList as &$detail) {
-                $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
-                if (\StrUtil::isNotEmpAndNull($detail["talentType"])) {
-                    $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
-                }
-            }
-            $res = [
-                "info" => $info,
-                "detailList" => $detailList
-            ];
-            return new Response(Response::SUCCESS, "计算成功", $res);
-        } catch (\think\Exception $e) {
-            return new Response(Response::ERROR, "系统异常,请联系管理员");
-        }
-    }
-
     /**
      *  公示后审核
      */
@@ -893,7 +946,7 @@ class House extends AdminController {
                     }
                     $houseInfo["count"] = $houseInfo["count"] + 1;
                     $houseInfo["balanceMoney"] = $houseInfo["balanceMoney"] - $obj["shouldEnjoyMoney"];
-                    $houseInfo["lastYearArrears"] = $obj["nowNotSubOtherMoney"]
+                    $houseInfo["lastYearArrears"] = $obj["nowNotSubOtherMoney"];
                     if (\StrUtil::isNotEmpAndNull($obj["spouseIdcard"])) {
                         if (!$spouseHouseInfo) {
                             $spouseHouseInfo = [
@@ -950,7 +1003,7 @@ class House extends AdminController {
                     'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
                 ];
             }
-            $upd["publicState"] = 3;
+            $upd["publicState"] = 4;
             Db::table("un_housepurchase")->where($where)->update($upd);
             if ($insertHouseInfoList) {
                 Db::table("un_housepurchase_house_info")->insertAll($insertHouseInfoList);
@@ -995,7 +1048,7 @@ class House extends AdminController {
                     'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
                 ];
             }
-            $upd["publicState"] = 4;
+            $upd["publicState"] = 5;
             Db::table("un_housepurchase")->where($where)->update($upd);
             Db::table("new_talent_checklog")->insertAll($logList);
             Db::commit();
@@ -1147,7 +1200,7 @@ class House extends AdminController {
                 break;
             case 4:
                 if ($obj["publicState"]) {
-                    $where[] = ["publicState", "=", $param["publicState"]];
+                    $where[] = ["publicState", "=", $obj["publicState"]];
                 }
                 $where[] = ["ta.checkState", "in", [-1, 30]];
                 break;
@@ -1338,11 +1391,12 @@ class House extends AdminController {
                         $old["checkState"] = null;
                         $old["checkMsg"] = "";
                     }
-                    $res = $this->calculate($old, 1);
+                    $housepurchase = [];
+                    $this->calculate($old, $housepurchase, [], 1);
                     if ($res->code == 500) {
                         return $res;
                     }
-                    $res["housepurchase"] = $res->obj;
+                    $res["housepurchase"] = $housepurchase;
                 }
                 break;
         }
@@ -1400,6 +1454,59 @@ class House extends AdminController {
         return new Response(Response::SUCCESS, "修改成功");
     }
 
+    public function basicDataExport() {
+        $names = \StrUtil::getRequestDecodeParam($this->request, "names");
+        $values = \StrUtil::getRequestDecodeParam($this->request, "values");
+        $process = \StrUtil::getRequestDecodeParam($this->request, "process");
+
+        $where = [];
+        $obj = $this->setHousepurchase($this->request);
+        $obj["process"] = $process;
+        $obj["type"] = $this->user["type"];
+        $this->setCondition($where, $obj);
+
+        switch ($process) {
+            case 1:
+                break;
+            case 2:
+                break;
+            case 3:
+                $where[] = ["depPassTime", "EXP", Db::raw("is not null")];
+                break;
+            case 4:
+                $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
+                $where[] = ["reviewPassTime", "EXP", Db::raw("is not null")];
+                break;
+        }
+        if (in_array($process, [1, 3, 4])) {
+            $list = houseModel::where($where)->order($order)->select()->toArray();
+        } else {
+            $company = getCacheById("Company", $this->user["companyId"]);
+            $result = HouseApi::selectForHousePurchase($obj, $company, ProjectState::HOUSE, 0, 99999);
+            $list = $result["rows"];
+        }
+        $list = $this->translateChinese($list, $process);
+
+        if ($list) {
+            $filename = "购房补贴导出";
+            $columns = array_filter(explode(",", $names));
+            $keys = array_filter(explode(",", $values));
+            $rows = [];
+            foreach ($list as $item) {
+                $row = [];
+                foreach ($keys as $key) {
+                    $row[] = $item[$key];
+                }
+                $rows[] = $row;
+            }
+            export($columns, $rows, $filename);
+            exit();
+        } else {
+            $response = new Response(Response::ERROR, "没有可导出的内容");
+            return \StrUtil::back($response, "Housepurchase.callBack");
+        }
+    }
+
     private function setCondition(&$where, &$query) {
         if (\StrUtil::isNotEmpAndNull($query["year"])) {
             $where[] = ["year", "=", $query["year"]];
@@ -1670,13 +1777,13 @@ class House extends AdminController {
     }
 
     /**
-     * @param old
-     * @param type          1-复核阶段,不生成享受人的剩余享受金额记录,2-公示再审核阶段,生成享受记录
+     * @param $old 原来的记录
+     * @param $housepurchase 新的记录
+     * @param $descideDesc 记录文本
+     * @param $type          1-复核阶段,不生成享受人的剩余享受金额记录,2-公示再审核阶段,生成享受记录
      * @description 计算购房补贴金额
      * */
-    private function calculate($old, $type) {
-        $housepurchase = [];
-        $descideDesc = [];
+    private function calculate($old, &$housepurchase = [], &$descideDesc = [], $type = 1) {
         $count = $old["type"] == 1 ? 5 : 3;            //最大申报数
         /*         * 1、查询申报人和配偶的房产信息 */
         $houseInfo = HouseApi::getHouseInfo($old["idCard"]);
@@ -1828,4 +1935,44 @@ class House extends AdminController {
         return new Response(Response::SUCCESS, "", $housepurchase);
     }
 
+    private function setHousepurchase($request) {
+        $name = \StrUtil::getRequestDecodeParam($request, "name");
+        $idCard = \StrUtil::getRequestDecodeParam($request, "idCard");
+        $yearStr = \StrUtil::getRequestDecodeParam($request, "year");
+        $talentArrangeStr = \StrUtil::getRequestDecodeParam($request, "talentArrange");
+        $spouseName = \StrUtil::getRequestDecodeParam($request, "spouseName");
+        $spouseIdcard = \StrUtil::getRequestDecodeParam($request, "spouseIdcard");
+        $childName = \StrUtil::getRequestDecodeParam($request, "childName");
+        $childIdCard = \StrUtil::getRequestDecodeParam($request, "childIdCard");
+        $marryStatus = \StrUtil::getRequestDecodeParam($request, "marryStatus");
+        $checkStateStr = \StrUtil::getRequestDecodeParam($request, "checkState");
+        $isConflictStr = \StrUtil::getRequestDecodeParam($request, "isConflict");
+        $isRecoverStr = \StrUtil::getRequestDecodeParam($request, "isRecover");
+        $talentArrange = null;
+        $year = null;
+        $checkState = null;
+        $isRecover = null;
+        $isConflict = null;
+        if (\StrUtil::isNotEmpAndNull($talentArrangeStr)) {
+            $talentArrange = intval($talentArrangeStr);
+        }
+        if (\StrUtil::isNotEmpAndNull($yearStr)) {
+            $year = intval($yearStr);
+        }
+        if (\StrUtil::isNotEmpAndNull($checkStateStr)) {
+            $checkState = intval($checkStateStr);
+        }
+        if (\StrUtil::isNotEmpAndNull($isConflictStr)) {
+            $isConflict = intval($isConflictStr);
+        }
+        if (\StrUtil::isNotEmpAndNull($isRecoverStr)) {
+            $isRecover = intval($isRecoverStr);
+        }
+        $obj = ["year" => $year,
+            "name" => $name, "cardType" => null, "idCard" => $idCard, "talentArrange" => $talentArrange,
+            "spouseName" => $spouseName, "spouseIdcard" => $spouseIdcard, "childName" => $childName, "childIdCard" => $childIdCard,
+            "marryStatus" => $marryStatus, "checkState" => $checkState, "publicState" => null, "cashType" => null, "isRecover" => $isRecover, "isConflict" => $isConflict];
+        return $obj;
+    }
+
 }

+ 3 - 2
app/admin/view/amount_standard/edit.html

@@ -30,6 +30,7 @@
                                     <option value="">---请选择---</option>
                                     <option value="1">工作津贴</option>
                                     <option value="2">一次性交通补贴</option>
+                                    <option value="3">购房补贴</option>
                                 </select>
                             </div>
                         </div>
@@ -60,8 +61,8 @@
                 </div>
                 <div class="row btn-group-m-t">
                     <div class="col-sm-12" style="text-align: center">
-                        <button type="button" class="btn btn-sm btn-info " onclick="{gt name='info.id' value='0'}AmountStandardInfoDlg.editSubmit(){else/}AmountStandardInfoDlg.addSubmit(){/gt}" id="ensure">
-                            <i class="fa fa-check"></i>&nbsp;提交
+                        <button type="button" class="btn btn-sm btn-info " {gt name='info.id' value='0'}onclick="AmountStandardInfoDlg.editSubmit()"{else/}onclick="AmountStandardInfoDlg.addSubmit()"{/gt} id="ensure">
+                                <i class="fa fa-check"></i>&nbsp;提交
                         </button>
                         <button type="button" class="btn btn-sm btn-danger " onclick="AmountStandardInfoDlg.close()" id="cancel">
                             <i class="fa fa-eraser"></i>&nbsp;取消

+ 1 - 0
app/admin/view/amount_standard/index.html

@@ -21,6 +21,7 @@
                                         <option value="">---请选择---</option>
                                         <option value="1">工作津贴(元/月)</option>
                                         <option value="2">一次性交通补贴(元)</option>
+                                        <option value="3">购房补贴(元)</option>
                                     </select>
                                 </div>
                             </div>

+ 20 - 5
app/admin/view/house/index.html

@@ -255,6 +255,21 @@
                             {/if}
                             {/eq}
                             {eq name="process" value="4"}
+                            {if condition="chkCommission('/admin/house/prepareHczx','/housepurchase/prepareHczx')"}
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.showDataCheckModal(-1)" id="">
+                                <i class="fa fa-file-excel-o"></i>&nbsp;导出核查征信
+                            </button>
+                            {/if}
+                            {if condition="chkCommission('/admin/house/hczxReject','/housepurchase/hczxReject')"}
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.showHczxRejectModal()" id="">
+                                <i class="fa fa-external-link"></i>&nbsp;征信失信
+                            </button>
+                            {/if}
+                            {if condition="chkCommission('/admin/house/hczxPass','/housepurchase/hczxPass')"}
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.showDataCheckModal(0)" id="">
+                                <i class="fa fa-external-link"></i>&nbsp;征信通过
+                            </button>
+                            {/if}
                             {if condition="chkCommission('/admin/house/publicExportBefore','/housepurchase/publicExportBefore')"}
                             <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.showDataCheckModal(5)" id="">
                                 <i class="fa fa-file-excel-o"></i>&nbsp;公示预览(兑现)
@@ -276,27 +291,27 @@
                             </button>
                             {/if}
                             {if condition="chkCommission('/admin/house/publicAfterCheck','/housepurchase/publicAfterCheck')"}
-                            <button type="button" class="btn btn-sm btn-danger " onclick="Housepurchase.openCheckHousepurchase()" id="">
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.openCheckHousepurchase()" id="">
                                 <i class="fa fa-check-square-o"></i>&nbsp;公示再审核
                             </button>
                             {/if}
                             {if condition="chkCommission('/admin/house/publicPass','/housepurchase/publicPass')"}
-                            <button type="button" class="btn btn-sm btn-danger " onclick="Housepurchase.showDataCheckModal(3)" id="">
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.showDataCheckModal(3)" id="">
                                 <i class="fa fa-compass"></i>&nbsp;公示通过
                             </button>
                             {/if}
                             {if condition="chkCommission('/admin/house/cash','/housepurchase/cash')"}
-                            <button type="button" class="btn btn-sm btn-danger " onclick="Housepurchase.showDataCheckModal(4)" id="">
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.showDataCheckModal(4)" id="">
                                 <i class="fa fa-newspaper-o"></i>&nbsp;兑现
                             </button>
                             {/if}
                             {if condition="chkCommission('/admin/house/publicExport','/housepurchase/publicExport')"}
-                            <button type="button" class="btn btn-sm btn-danger " onclick="Housepurchase.showExportModal()" id="">
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.showExportModal()" id="">
                                 <i class="fa fa-file-excel-o"></i>&nbsp;导出
                             </button>
                             {/if}
                             {if condition="chkCommission('/admin/house/publicDetail','/housepurchase/publicDetail')"}
-                            <button type="button" class="btn btn-sm btn-danger " onclick="Housepurchase.openHousepurchaseDetail()" id="">
+                            <button type="button" class="btn btn-sm btn-primary " onclick="Housepurchase.openHousepurchaseDetail()" id="">
                                 <i class="fa fa-eye"></i>&nbsp;查看
                             </button>
                             {/if}

+ 1 - 1
app/common/api/DictApi.php

@@ -679,7 +679,7 @@ class DictApi {
     public static function findByParentCodeAndCode($parentCode, $code) {
         $parent_info = Dict::where('code', $parentCode)->findOrEmpty();
         if ($parent_info) {
-            return Dict::where('pid', $parent_info['id'])->where('code', $code)->findOrEmpty();
+            return Dict::where('pid', $parent_info['id'])->where('code', $code)->find();
         }
         return false;
     }

+ 4 - 0
app/common/api/HouseApi.php

@@ -19,6 +19,10 @@ use app\common\state\HouseStateEnum;
  */
 class HouseApi {
 
+    public static function getList($where = [], $field = "*") {
+        return houseModel::where($where)->field($field)->select()->order("createTime desc")->toArray();
+    }
+
     public static function getInfoById($id) {
         return houseModel::findOrEmpty($id)->toArray();
     }

+ 8 - 2
app/enterprise/controller/House.php

@@ -415,7 +415,10 @@ class House extends EnterpriseController {
 
             //设置上一年度人才层次有效月份
             $info["monthCount"] = count($resInfo["monthList"]);
-            if ($info["monthCount"] < 9) {
+            if (in_array($info["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC]) && $info["monthCount"] < 6) {
+                return new Response(Response::ERROR, "申报年度人才证书有效期未满足六个月,无法申报购房补贴");
+            }
+            if (in_array($info["type"], [CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]) && $info["monthCount"] < 9) {
                 return new Response(Response::ERROR, "申报年度人才证书有效期未满足九个月,无法申报购房补贴");
             }
             $info["talentArrangeMonths"] = implode(",", $resInfo["monthList"]);
@@ -506,7 +509,10 @@ class House extends EnterpriseController {
                 }
             }
             $resTalentInfo["monthList"] = $months;
-            if (count($months) < 9) {
+            if (in_array($talentInfo["enterpriseType"], [CommonConst::ENTERPRISE_JC, CommonConst::ENTERPRISE_NORMAL]) && count($months) < 6) {
+                return new Response(Response::ERROR, "申报年度人才证书有效期未满足六个月,无法申报购房补贴");
+            }
+            if (in_array($talentInfo["enterpriseType"], [CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]) && count($months) < 9) {
                 return new Response(Response::ERROR, "申报年度人才证书有效期未满足九个月,无法申报购房补贴");
             }
             return new Response(Response::SUCCESS, "", $resTalentInfo);

+ 131 - 7
public/static/modular/house/housepurchase/housepurchase.js

@@ -162,7 +162,9 @@ Housepurchase.initColumn = function () {
                         return "<span class='label label-success'>重新提交</span>"
                     }
                 } else if (process == 3) {
-                    if (value <= 30) {
+                    if (value == -1) {
+                        return "<span class='label label-danger'>审核不通过</span>"
+                    } else if (value <= 30) {
                         return "<span class='label label-danger'>已驳回</span>"
                     } else if (value == 35) {
                         return (Feng.isNotEmptyStr(row.highProcess) && row.highProcess >= 3) ? "<span class='label label-success'>重新提交</span>" : "<span class='label label-success'>待审核</span>";
@@ -181,12 +183,14 @@ Housepurchase.initColumn = function () {
         {title: '公示状态', field: "publicState", visible: process == 4, align: 'center', valign: 'middle', 'class': 'uitd_showTip', width: "80px",
             formatter: function (value, row, index) {
                 if (value == 1)
-                    return "<span class='label label-warning'>待公示</span>";
+                    return "<span class='label label-warning'>待核查征信</span>";
                 if (value == 2)
-                    return "<span class='label label-success'>公示中</span>";
+                    return "<span class='label label-warning'>待公示</span>";
                 if (value == 3)
-                    return "<span class='label label-info'>待兑现</span>";
+                    return "<span class='label label-success'>公示中</span>";
                 if (value == 4)
+                    return "<span class='label label-info'>待兑现</span>";
+                if (value == 5)
                     return "<span class='label label-primary'>已兑现</span>";
             }
         },
@@ -220,8 +224,8 @@ Housepurchase.check = function () {
 Housepurchase.updateFieldsAndFiles = function () {
     if (this.check()) {
         var ajax = new $ax(Feng.ctxPath + "/admin/house/findFieldsAndFiles?id=" + Housepurchase.seItem.id, function (data) {
-            var obj = data.obj;
             if (data.code == 200) {
+                var obj = data.obj.obj;
                 layer.open({
                     type: 1,
                     id: "neewFieldFormModel",
@@ -230,12 +234,12 @@ Housepurchase.updateFieldsAndFiles = function () {
                     fix: false, //不固定
                     shade: 0,
                     maxmin: true,
-                    content: Housepurchase.creatFieldCheckModal(data.obj.obj),
+                    content: Housepurchase.creatFieldCheckModal(obj),
                     btn: ['<i class="fa fa-save"></i>&nbsp;&nbsp;提交', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
                     btnAlign: 'c',
                     zIndex: layer.zIndex,
                     success: function (layero, index) {
-                        var fileList = data.obj.fileList;
+                        var fileList = data.obj.files;
                         var html = '';
                         for (var key in fileList) {
                             html = html + '<ul><li style="width: 100%"><input type="checkbox" value="' + fileList[key].id + '"><span>' + fileList[key].name + '</span></li></ul>';
@@ -485,6 +489,14 @@ Housepurchase.cancleReview = function () {
 Housepurchase.showDataCheckModal = function (type) {
     $("#hczxForm").css("display", "none");
     switch (type) {
+        case - 1:             //核查征信
+            $("#hczxButton").attr("onclick", "Housepurchase.exportHczx()").text("导出");
+            $("#exportCommonModalLabel").text("待核查征信导出");
+            break;
+        case 0:             //征信通过
+            $("#hczxButton").attr("onclick", "Housepurchase.hczxPass()").text("提交");
+            $("#exportCommonModalLabel").text("批量征信通过");
+            break;
         case 1:                     //待公示名单(兑现)
             $("#hczxButton").attr("onclick", "Housepurchase.public(1)").text("公示");
             $("#exportCommonModalLabel").text("待公示名单(兑现)");
@@ -560,6 +572,118 @@ Housepurchase.showDataCheckModal = function (type) {
     });
 }
 
+/**
+ * 核查征信导出
+ * @returns {undefined}
+ */
+Housepurchase.exportHczx = function () {
+    var selected = $('#dataTable').bootstrapTable('getSelections');
+    if (!selected || selected.length < 1) {
+        Feng.info("请至少选择一行数据!");
+        return;
+    }
+    var ids = "";
+    for (var i = 0; i < selected.length; i++) {
+        ids = ids + selected[i].id + ",";
+    }
+    ids = ids.substring(0, ids.length - 1);
+    var operation = function () {
+        window.location.href = Feng.ctxPath + "/admin/house/exportHczx?ids=" + ids;
+    }
+    Feng.confirm("确定导出吗?", operation);
+}
+
+/**
+ * 征信通过
+ */
+Housepurchase.hczxPass = function () {
+    var selected = $('#dataTable').bootstrapTable('getSelections');
+    if (!selected || selected.length < 1) {
+        Feng.info("请至少选择一行数据!");
+        return;
+    }
+    var ids = "";
+    for (var i = 0; i < selected.length; i++) {
+        ids = ids + selected[i].id + ",";
+    }
+    ids = ids.substring(0, ids.length - 1);
+    var operation = function () {
+        var ajax = new $ax(Feng.ctxPath + "/admin/house/hczxPass", function (data) {
+            if (data.code == 200) {
+                Feng.success(data.msg);
+                Housepurchase.table.refresh();
+                $("#exportCommonModal").modal("hide");
+            } else {
+                Feng.error(data.msg);
+            }
+        }, function (data) {
+            Feng.error("核查征信失败!" + data.responseJSON.message + "!");
+        });
+        ajax.set("ids", ids);
+        ajax.start();
+    }
+    Feng.confirm("一旦提交无法修改,确定核查征信通过吗?", operation);
+}
+
+/***
+ * 显示核查征信失信
+ */
+Housepurchase.showHczxRejectModal = function () {
+    if (this.check()) {
+        if (Housepurchase.seItem.publicState != 1) {
+            Feng.info("当前记录不是待核查征信状态,无法核查");
+            return;
+        }
+        layer.open({
+            type: 1,
+            id: "neewFieldFormModel",
+            title: '征信失信',
+            area: ['800px', '450px'], //宽高
+            fix: false, //不固定
+            shade: 0,
+            maxmin: true,
+            content: '<form id="hczxRejectForm" class="form-horizontal">\n' +
+                    '                    <input type="hidden" name="hczxId" id="hczxId" >\n' +
+                    '                    <div class="form-group" style="margin: 10px;">\n' +
+                    '                            <label class=" control-label">失信原因</label>\n' +
+                    '                                <textarea id="hczxMsg" name="hczxMsg" class="form-control"></textarea>\n' +
+                    '                    </div>\n' +
+                    '                </form>',
+            btn: ['<i class="fa fa-save"></i>&nbsp;&nbsp;提交', '<i class="fa fa-eraser"></i>&nbsp;&nbsp;关闭'],
+            btnAlign: 'c',
+            zIndex: layer.zIndex,
+            success: function (layero, index) {
+                $("#hczxId").val(Housepurchase.seItem.id);
+                $("#hczxMsg").val("");
+            },
+            yes: function (index, layero) {
+                var id = $("#hczxId").val();
+                var msg = $("#hczxMsg").val();
+                if (msg == null || msg == '') {
+                    Feng.info("请填写失信原因");
+                    return;
+                }
+                var operation = function () {
+                    var ajax = new $ax(Feng.ctxPath + "/admin/house/hczxReject", function (data) {
+                        if (data.code == 200) {
+                            Feng.success(data.msg);
+                            Housepurchase.table.refresh();
+                            layer.close(index);
+                        } else {
+                            Feng.error(data.msg);
+                        }
+                    }, function (data) {
+                        Feng.error("核查征信失败!" + data.responseJSON.message + "!");
+                    });
+                    ajax.setData({"id": id, "outMsg": msg});
+                    ajax.start();
+                }
+                Feng.confirm("一旦提交无法修改,确定提交吗?", operation);
+            }
+        });
+    }
+}
+
 /**
  * 公示预览
  * @param type 1-需要兑现,2-不予兑现

+ 8 - 2
public/static/modular/house/housepurchase/housepurchase_info.js

@@ -204,8 +204,14 @@ HousepurchaseInfoDlg.showThirdCheckModal = function () {
                 zIndex: layer.zIndex,
                 success: function (layero, index) {
                     layer.setTop(layero);
-                    $('#toDep').chosen({width: '100%', placeholder_text_multiple: '请选择兑现对象'});
+                    $('#toDep').chosen({width: '100%', placeholder_text_multiple: '请选择驳回部门'});
                     $("#checkStateFirstModal").val(data.obj.obj.checkState);
+                    if (data.obj.obj.checkState == 2) {
+                        $("#toProcessDiv,#toDepDiv").css("display", "block");
+                    }
+                    if (data.obj.obj.checkState == 3) {
+                        $("#cashTypeDiv").css("display", "block");
+                    }
                     $("#checkMsgFirst").val(data.obj.obj.checkMsg);
                     $("#toProcess").val(data.obj.obj.toProcess);
                     $("#cashType").val(data.obj.obj.cashType).trigger("change");
@@ -550,7 +556,7 @@ HousepurchaseInfoDlg.createThirdCheckHtml = function () {
             '</div>\n' +
             '<div class="form-group" style="display: none;margin: 10px;" id="cashTypeDiv">\n' +
             '<label for="processLable" class=" control-label">兑现状态</label>\n' +
-            '<select class="form-control" id="cashType" onchange="HousepurchaseInfoDlg.cashTypeChange()">\n' +
+            '<select class="form-control" id="cashType" onchange="HousepurchaseInfoDlg.afterCashTypeChange()">\n' +
             '<option value="">请选择</option>\n' +
             '<option value="1">兑现</option>\n' +
             '<option value="2">不予兑现</option>\n' +

+ 3 - 0
public/static/modular/system/amountStandard/amountStandard.js

@@ -38,6 +38,9 @@ AmountStandard.initColumn = function () {
                 if (value == 2) {
                     return "一次性交通津贴";
                 }
+                if (value == 3) {
+                    return "购房补贴";
+                }
             }
         },
         {title: '人才层次', field: 'talentArrangeName', visible: true, align: 'center', valign: 'middle'},

+ 3 - 3
sys_config.json

@@ -162,8 +162,8 @@
     },
     "housepurchase_dep_list": {
         "1": ["zjj", "mzj", "zrzyj", "rsj"],
-        "2": ["zjj", "mzj", "zrzyj", "ic"],
-        "5": ["zjj", "mzj", "zrzyj", "rsj"],
-        "6": ["zjj", "mzj", "zrzyj", "晋江市卫健局人事科"]
+        "2": [],
+        "5": ["zjj", "mzj", "zrzyj", "晋江市卫健局人事科"],
+        "6": ["zjj", "mzj", "zrzyj", "jyj"]
     }
 }