Bläddra i källkod

购房补贴++

sugangqiang 10 månader sedan
förälder
incheckning
b004774b20
1 ändrade filer med 452 tillägg och 110 borttagningar
  1. 452 110
      app/admin/controller/House.php

+ 452 - 110
app/admin/controller/House.php

@@ -218,6 +218,282 @@ class House extends AdminController {
         return new Response(Response::SUCCESS, "审核成功");
         return new Response(Response::SUCCESS, "审核成功");
     }
     }
 
 
+    /**
+     * @param obj
+     * @description 住建局审核
+     * */
+    public function zjjCheck() {
+        $obj = [
+            "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
+            "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
+            "checkIsTradeRecord" => \StrUtil::getRequestDecodeParam($this->request, "checkIsTradeRecord"),
+            "checkRecordTime" => \StrUtil::getRequestDecodeParam($this->request, "checkRecordTime"),
+            "zjjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zjjCheckDetail"),
+            "otherList" => \StrUtil::getRequestDecodeParam($this->request, "otherList"),
+            "houseList" => \StrUtil::getRequestDecodeParam($this->request, "houseList")
+        ];
+        if (!$obj) {
+            return new Response(Response::ERROR, "请填写信息后保存");
+        }
+        $mzj = \app\common\model\Company::where("code", CommonConst::MZJ)->find();
+        $where = [];
+        $where[] = ["mainId", "=", $obj["id"]];
+        $where[] = ["companyId", "=", $mzj["id"]];
+        $depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
+        if ($depcheckstate["state"] != 3) {
+            return new Response(Response::ERROR, "请等待民政局录入婚姻信息后,根据婚姻信息查询!");
+        }
+        $where = [];
+        $where[] = ["mainId", "=", $obj["id"]];
+        $where[] = ["companyId", "=", $obj["companyId"]];
+        $oldDep = Db::table("un_talent_depcheckstate")->where($where)->find();
+        if ($oldDep["state"] != 1 && $oldDep["state"] != 4 && $oldDep["state"] != 9) {
+            return new Response(Response::ERROR, "不在审核范围内!");
+        }
+        $old = HouseApi::getInfoById($obj["id"]);
+        if ($old["declareType"] == 1) {
+            if ($obj["checkIsTradeRecord"] == 1 && \StrUtil::isEmpOrNull($obj["checkRecordTime"])) {
+                return new Response(Response::ERROR, "请填写交易备案时间");
+            }
+        } else {
+            $obj["checkIsTradeRecord"] = null;
+            $obj["checkRecordTime"] = "";
+        }
+        if ($obj["otherList"] && count($obj["otherList"]) > 0) {
+            foreach ($obj["otherList"] as $other) {
+                if ($other["id"]) {
+                    $other["updateTime"] = date("Y-m-d H:i:s");
+                    $other["updateUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseEnjoyOther::update($other);
+                } else {
+                    $other["id"] = getStringId();
+                    $other["pId"] = $obj["id"];
+                    $other["createTime"] = date("Y-m-d H:i:s");
+                    $other["createUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseEnjoyOther::insert($other);
+                }
+            }
+        }
+
+        if ($obj["houseList"] && count($obj["houseList"]) > 0) {
+            foreach ($obj["houseList"] as $house) {
+                if ($house["id"]) {
+                    $house["updateTime"] = date("Y-m-d H:i:s");
+                    $house["updateUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::update($house);
+                } else {
+                    $house["id"] = getStringId();
+                    $house["pId"] = $obj["id"];
+                    $house["createTime"] = date("Y-m-d H:i:s");
+                    $house["createUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::insert($house);
+                }
+            }
+        }
+        houseModel::update($obj);
+        TalentChecklog::create([
+            'id' => getStringId(),
+            "companyId" => $obj["companyId"],
+            'mainId' => $obj["id"],
+            'type' => intval(ProjectState::HOUSE),
+            'typeFileId' => null,
+            'active' => 2,
+            'state' => 3,
+            'step' => 2,
+            'stateChange' => "保存未提交",
+            'description' => "录入核查数据",
+            'createTime' => date("Y-m-d H:i:s", time()),
+            'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
+        ]);
+        return new Response(Response::SUCCESS, "审核成功", $obj);
+    }
+
+    /**
+     * @param obj
+     * @description 自然资源局核查
+     * */
+    public function zrzyjCheck() {
+        $obj = [
+            "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
+            "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
+            "isHasBdcCard" => \StrUtil::getRequestDecodeParam($this->request, "isHasBdcCard"),
+            "bdcRegistTime" => \StrUtil::getRequestDecodeParam($this->request, "bdcRegistTime"),
+            "isOwner" => \StrUtil::getRequestDecodeParam($this->request, "isOwner"),
+            "transferMethod" => \StrUtil::getRequestDecodeParam($this->request, "transferMethod"),
+            "transferTime" => \StrUtil::getRequestDecodeParam($this->request, "transferTime"),
+            "zrzzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zrzzjCheckDetail"),
+            "houseList" => \StrUtil::getRequestDecodeParam($this->request, "houseList")
+        ];
+        if (!$obj) {
+            return new Response(Response::ERROR, "请填写信息后保存");
+        }
+        $mzj = \app\common\model\Company::where("code", CommonConst::MZJ)->find();
+        $where = [];
+        $where[] = ["mainId", "=", $obj["id"]];
+        $where[] = ["companyId", "=", $mzj["id"]];
+        $depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
+        if ($depcheckstate["state"] != 3) {
+            return new Response(Response::ERROR, "请等待民政局录入婚姻信息后,根据婚姻信息查询!");
+        }
+        $where = [];
+        $where[] = ["mainId", "=", $obj["id"]];
+        $where[] = ["companyId", "=", $obj["companyId"]];
+        $oldDep = Db::table("un_talent_depcheckstate")->where($where)->find();
+        if ($oldDep["state"] != 1 && $oldDep["state"] != 4 && $oldDep["state"] != 9) {
+            return new Response(Response::ERROR, "不在审核范围内!");
+        }
+        $old = HouseApi::getInfoById($obj["id"]);
+        if ($old["declareType"] == 1) {
+            if ($obj["isHasBdcCard"] == 1 && \StrUtil::isEmpOrNull($obj["bdcRegistTime"])) {
+                return new Response(Response::ERROR, "请填写不动产权证书登记时间");
+            }
+            if (!$obj["isOwner"]) {
+                return new Response(Response::ERROR, "请选择其购置的房屋是否还在名下");
+            }
+            if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferMethod"])) {
+                return new Response(Response::ERROR, "请填写过户方式");
+            }
+            if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferTime"])) {
+                return new Response(Response::ERROR, "请填写过户时间");
+            }
+        } else {
+            $obj["isHasBdcCard"] = null;
+            $obj["bdcRegistTime"] = "";
+            $obj["isOwner"] = null;
+            $obj["transferMethod"] = "";
+            $obj["transferTime"] = "";
+        }
+
+        if ($obj["houseList"] && count($obj["houseList"]) > 0) {
+            foreach ($obj["houseList"] as $house) {
+                if ($house["id"]) {
+                    $house["updateTime"] = date("Y-m-d H:i:s");
+                    $house["updateUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::update($house);
+                } else {
+                    $house["id"] = getStringId();
+                    $house["pId"] = $obj["id"];
+                    $house["createTime"] = date("Y-m-d H:i:s");
+                    $house["createUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::insert($house);
+                }
+            }
+        }
+        houseModel::update($obj);
+        TalentChecklog::create([
+            'id' => getStringId(),
+            "companyId" => $obj["companyId"],
+            'mainId' => $obj["id"],
+            'type' => intval(ProjectState::HOUSE),
+            'typeFileId' => null,
+            'active' => 2,
+            'state' => 3,
+            'step' => 2,
+            'stateChange' => "保存未提交",
+            'description' => "录入核查数据",
+            'createTime' => date("Y-m-d H:i:s", time()),
+            'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
+        ]);
+        return new Response(Response::SUCCESS, "审核成功", $obj);
+    }
+
+    /**
+     * @param obj
+     * @description 民政局核查
+     * */
+    public function mzjCheck() {
+        $obj = [
+            "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
+            "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
+            "mzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "mzjCheckDetail"),
+            "spouseList" => \StrUtil::getRequestDecodeParam($this->request, "spouseList")
+        ];
+
+        if (!$obj) {
+            return new Response(Response::ERROR, "请填写信息后保存");
+        }
+        $where = [];
+        $where[] = ["mainId", "=", $obj["id"]];
+        $where[] = ["companyId", "=", $obj["companyId"]];
+        $oldDep = Db::table("un_talent_depcheckstate")->where($where)->find();
+        if ($oldDep["state"] != 1 && $oldDep["state"] != 4 && $oldDep["state"] != 9) {
+            return new Response(Response::ERROR, "不在审核范围内!");
+        }
+        if ($obj["spouseList"] && count($obj["spouseList"]) > 0) {
+            foreach ($obj["spouseList"] as $spouse) {
+                if ($spouse["id"]) {
+                    $spouse["updateTime"] = date("Y-m-d H:i:s");
+                    $spouse["updateUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseSpouse::update($spouse);
+                } else {
+                    $spouse["id"] = getStringId();
+                    $spouse["pId"] = $obj["id"];
+                    $spouse["createTime"] = date("Y-m-d H:i:s");
+                    $spouse["createUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseSpouse::insert($spouse);
+                }
+            }
+        }
+        houseModel::update($obj);
+        TalentChecklog::create([
+            'id' => getStringId(),
+            "companyId" => $obj["companyId"],
+            'mainId' => $obj["id"],
+            'type' => intval(ProjectState::HOUSE),
+            'typeFileId' => null,
+            'active' => 2,
+            'state' => 3,
+            'step' => 2,
+            'stateChange' => "保存未提交",
+            'description' => "录入核查数据",
+            'createTime' => date("Y-m-d H:i:s", time()),
+            'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
+        ]);
+        return new Response(Response::SUCCESS, "审核成功", $obj);
+    }
+
+    /**
+     * @param obj
+     * @description 部门审核
+     * */
+    public function depCheck() {
+        $obj = [
+            "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
+            "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
+            "description" => \StrUtil::getRequestDecodeParam($this->request, "description")
+        ];
+        $desc = $obj["description"];
+        $company = getCacheById("Company", $obj["companyId"]);
+        switch ($company["code"]) {
+            case CommonConst::ZJJ:
+                $obj["zjjCheckDetail"] = $obj["description"];
+                break;
+            case CommonConst::ZRZYJ:
+                $obj["zrzzjCheckDetail"] = $obj["description"];
+                break;
+            case CommonConst::MZJ:
+                $obj["mzjCheckDetail"] = $obj["description"];
+                break;
+        }
+        $obj["description"] = "";
+        houseModel::update($obj);
+        TalentChecklog::create([
+            'id' => getStringId(),
+            "companyId" => $obj["companyId"],
+            'mainId' => $obj["id"],
+            'type' => intval(ProjectState::HOUSE),
+            'typeFileId' => null,
+            'active' => 2,
+            'state' => 3,
+            'step' => 2,
+            'stateChange' => "保存未提交",
+            'description' => sprintf("录入核查数据(%s):%s", $company["name"], $desc),
+            'createTime' => date("Y-m-d H:i:s", time()),
+            'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
+        ]);
+        return new Response(Response::SUCCESS, "审核成功");
+    }
+
     /**
     /**
      * 提交审核
      * 提交审核
      * @return Response
      * @return Response
@@ -373,6 +649,7 @@ class House extends AdminController {
                 $where = [];
                 $where = [];
                 $where[] = ["mainId", "=", $id];
                 $where[] = ["mainId", "=", $id];
                 $where[] = ["active", "=", 2];
                 $where[] = ["active", "=", 2];
+                $where[] = ["companyId", "=", $companyId];
                 TalentChecklog::where($where)->delete();
                 TalentChecklog::where($where)->delete();
                 break;
                 break;
             case 3:
             case 3:
@@ -753,139 +1030,169 @@ class House extends AdminController {
     }
     }
 
 
     /**
     /**
-     * 跳转到公示再审核页面
+     * @param obj
+     * @description 公示再审核修改住建局、自然资源局数据
      * */
      * */
-    public function toSupplePage() {
-        $id = $this->request["id"];
-        $process = $this->request["process"];
-        $obj = TalentAllowanceApi::getInfoById($id);
-        $this->translateToChinese($obj);
-        if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
-            $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
-            $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
-            if ($need_choose_post_type[$obj["enterpriseId"]]) {
-                $postTypes = DictApi::findChildDictByCode("PostType");
-                foreach ($postTypes as $key => $pt) {
-                    if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
-                        unset($postTypes[$key]);
-                    }
+    public function afterCheckEdit() {
+        $obj = [
+            "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
+            "checkIsTradeRecord" => \StrUtil::getRequestDecodeParam($this->request, "checkIsTradeRecord"),
+            "checkRecordTime" => \StrUtil::getRequestDecodeParam($this->request, "checkRecordTime"),
+            "zjjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zjjCheckDetail"),
+            "isHasBdcCard" => \StrUtil::getRequestDecodeParam($this->request, "isHasBdcCard"),
+            "bdcRegistTime" => \StrUtil::getRequestDecodeParam($this->request, "bdcRegistTime"),
+            "isOwner" => \StrUtil::getRequestDecodeParam($this->request, "isOwner"),
+            "transferMethod" => \StrUtil::getRequestDecodeParam($this->request, "transferMethod"),
+            "transferTime" => \StrUtil::getRequestDecodeParam($this->request, "transferTime"),
+            "zrzzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zrzzjCheckDetail"),
+            "zjjHouseList" => \StrUtil::getRequestDecodeParam($this->request, "zjjHouseList"),
+            "zrzyjHouseList" => \StrUtil::getRequestDecodeParam($this->request, "zrzyjHouseList"),
+            "otherList" => \StrUtil::getRequestDecodeParam($this->request, "otherList")
+        ];
+        if (!$obj) {
+            return new Response(Response::ERROR, "系统错误,请联系管理员");
+        }
+        $old = HouseApi::getInfoById($obj["id"]);
+        if ($old["checkState"] != HouseStateEnum::REVIEW_PASS || $old["publicState"] != 3) {
+            return new Response(Response::ERROR, "不在审核范围内,无法操作");
+        }
+        if ($old["declareType"] == 1) {
+            if ($obj["isHasBdcCard"] == 1 && \StrUtil::isEmpOrNull($obj["bdcRegistTime"])) {
+                return new Response(Response::ERROR, "请填写不动产权证书登记时间");
+            }
+            if (!$obj["isOwner"]) {
+                return new Response(Response::ERROR, "请选择其购置的房屋是否还在名下");
+            }
+            if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferMethod"])) {
+                return new Response(Response::ERROR, "请填写过户方式");
+            }
+            if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferTime"])) {
+                return new Response(Response::ERROR, "请填写过户时间");
+            }
+            if ($obj["checkIsTradeRecord"] == 1 && \StrUtil::isEmpOrNull($obj["checkRecordTime"])) {
+                return new Response(Response::ERROR, "请填写交易备案时间");
+            }
+        } else {
+            $obj["isHasBdcCard"] = null;
+            $obj["bdcRegistTime"] = "";
+            $obj["isOwner"] = null;
+            $obj["transferMethod"] = "";
+            $obj["transferTime"] = "";
+            $obj["checkIsTradeRecord"] = null;
+            $obj["checkRecordTime"] = "";
+        }
+        if ($obj["zrzyjHouseList"] && count($obj["zrzyjHouseList"]) > 0) {
+            foreach ($obj["zrzyjHouseList"] as $other) {
+                if ($other["id"]) {
+                    $other["updateTime"] = date("Y-m-d H:i:s");
+                    $other["updateUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::update($other);
+                } else {
+                    $other["id"] = getStringId();
+                    $other["pId"] = $obj["id"];
+                    $other["createTime"] = date("Y-m-d H:i:s");
+                    $other["createUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::insert($other);
                 }
                 }
             }
             }
-            if (in_array($obj["enterpriseId"], $need_choose_institution)) {
-                $institutions = DictApi::findChildDictByCode("Institution");
+        }
+        if ($obj["otherList"] && count($obj["otherList"]) > 0) {
+            foreach ($obj["otherList"] as $other) {
+                if ($other["id"]) {
+                    $other["updateTime"] = date("Y-m-d H:i:s");
+                    $other["updateUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseEnjoyOther::update($other);
+                } else {
+                    $other["id"] = getStringId();
+                    $other["pId"] = $obj["id"];
+                    $other["createTime"] = date("Y-m-d H:i:s");
+                    $other["createUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseEnjoyOther::insert($other);
+                }
+            }
+        }
+        if ($obj["zjjHouseList"] && count($obj["zjjHouseList"]) > 0) {
+            foreach ($obj["zjjHouseList"] as $other) {
+                if ($other["id"]) {
+                    $other["updateTime"] = date("Y-m-d H:i:s");
+                    $other["updateUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::update($other);
+                } else {
+                    $other["id"] = getStringId();
+                    $other["pId"] = $obj["id"];
+                    $other["createTime"] = date("Y-m-d H:i:s");
+                    $other["createUser"] = $this->user["name"];
+                    \app\common\model\HousePurchaseOtherHouse::insert($other);
+                }
             }
             }
         }
         }
-        return view("public_check", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
+        houseModel::update($obj);
+        return new Response(Response::SUCCESS, "审核成功", $obj);
     }
     }
 
 
     /**
     /**
      *  公示后审核
      *  公示后审核
      */
      */
     public function afterCheck() {
     public function afterCheck() {
-        $param = $this->request->param();
-        if (!$param["id"]) {
-            return new Response(Response::ERROR, "系统错误,请联系管理员");
-        }
-        $old = TalentAllowanceApi::getInfoById($param["id"]);
-        if ($old["publicState"] != 3) {
-            return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
-        }
         try {
         try {
-            $arrangeList = null;
-            $desc = "审核意见:" . $param["checkMsg"] . ";\n";
-            $desc .= "征信:" . ($param["zxState"] == 1 ? "征信通过" : $param["zxMsg"] . ";\n");
+            $data = [
+                "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
+                "checkState" => \StrUtil::getRequestDecodeParam($this->request, "checkState"),
+                "checkMsg" => \StrUtil::getRequestDecodeParam($this->request, "checkMsg"),
+                "cashType" => \StrUtil::getRequestDecodeParam($this->request, "cashType"),
+                "decideMoneyDetail" => \StrUtil::getRequestDecodeParam($this->request, "decideMoneyDetail"),
+                "shouldEnjoyMoney" => \StrUtil::getRequestDecodeParam($this->request, "shouldEnjoyMoney"),
+            ];
+            $old = HouseApi::getInfoById($data["id"]);
+            if (!$old) {
+                return new Response(Response::ERROR, "系统错误,请联系管理员");
+            }
+            if ($old["publicState"] != 3) {
+                return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
+            }
+            if ($data["checkState"] == 3) {
+                $data["checkState"] = HouseStateEnum::REVIEW_PASS;
+                if ($data["cashType"] == 1 && $old["declareType"] == 1) {
+                    $houseBalanceMoney = $old["houseBalanceMoney"] ?: 0;
+                    $balanceMoney = $old["balanceMoney"] ?: 0;
+                    $talentArrangeMoney = $old["talentArrangeMoney"] ?: 0;
+                    $minMoney = $houseBalanceMoney >= $balanceMoney ? ($balanceMoney >= $talentArrangeMoney ? $talentArrangeMoney : $balanceMoney) : ($houseBalanceMoney >= $talentArrangeMoney ? $talentArrangeMoney : $houseBalanceMoney);
 
 
-            $data["id"] = $param["id"];
-            if ($param["checkState"] == -1) {
-                $data["checkState"] = -1;
-                $data["checkMsg"] = $param["checkMsg"];
-                $data["allowanceType"] = 3;
-                $data["allowanceMsg"] = "审核不通过,原因:" . $param["checkMsg"];
-                $data["outMsg"] = $param["zxState"] == 1 ? "" : $param["zxMsg"];
-            } else if ($param["checkState"] == 3) {
-                if ($param["zxState"] == 1) {
-                    $typeName = "";
-                    $old["recommendAllowanceMsg"] = "";
-                    if ($param["source"] == 1) {            //遵循系统结果
-                        $arrangeList = $this->validateAllowanceType($old);
-                        $typeName = "系统判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["allowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
-                        $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $old["recommendAllowanceMsg"] . ";";
-                    } else if ($param["source"] == 2) {
-                        $detailIds = array_column($param["details"], "id");
-                        $where = [];
-                        $where[] = ["id", "in", $detailIds];
-                        $detailList = \app\common\model\TalentAllowancecontractDetail::where($where)->select()->toArray();
-                        $set = [];
-                        if ($params["resAllowanceType"] == 1) {
-                            $monthsMap = [];
-                            for ($i = 0; $i < count($param["details"]); $i++) {
-                                $monthsMap[$param["details"][$i]["id"]] = $param["details"][$i]["months"];
-                            }
-                            foreach ($detailList as &$detail) {
-                                $months = $monthdsMap[$detail["id"]];
-                                if (\StrUtil::isNotEmpAndNull($months)) {
-                                    $detail["months"] = $months;
-                                    $set = array_merge($set, explode(",", $months));
-                                }
-                            }unset($detail);
-                        }
-                        $set = array_filter($set);
-                        usort($set, function($a, $b) {
-                            return (int) $a - (int) $b;
-                        });
-                        $old["recommendAllowanceType"] = $param["resAllowanceType"];
-                        $old["recommendMonths"] = implode(",", $set);
-                        $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["recommendAllowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
-                        $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $obj["resAllowanceMsg"] . ";";
-                        $arrangeList = $this->calculateAllowance($old, $set, $detailList);
+                    if ($data["shouldEnjoyMoney"] > $minMoney) {
+                        return new Response(Response::ERROR, "当前申报的最高可享受金额为:" . $minMoney . "元!请重新计算并填写");
+                    }
+                    $result = $this->calculate($old, $data, $decideDetail, 2);
+                    if ($result->code == 500) {
+                        return $result;
                     }
                     }
-                    $desc .= "判定结果:" . $typeName;
-                    $data["checkState"] = 30;
-                    $data["outMsg"] = "";
-                    $data["allowanceType"] = $old["recommendAllowanceType"];
-                    $data["allowanceMsg"] = $old["recommendAllowanceMsg"];
-                    $data["months"] = $old["recommendMonths"];
-                    $data["money"] = $old["recommendMoney"];
-                    $data["moneyDesc"] = $old["recommendMoneyDesc"];
-                    $data["jtTalentArrange"] = $old["recommendTalentArrange"];
-                    $data["workAllowanceMoney"] = $old["workAllowanceMoney"];
-                    $data["developAllowanceMoney"] = $old["developAllowanceMoney"];
-                } else {
-                    $data["checkState"] = -1;
-                    $data["outMsg"] = $param["zxMsg"];
-                    $data["allowanceType"] = 3;
-                    $data["allowanceMsg"] = "征信失信(不予兑现),原因:" . $param["zxMsg"];
                 }
                 }
+                if ($data["cashType"] != 1) {
+                    $data["shouldEnjoyMoney"] = 0;
+                    $data["nowSubOtherMoney"] = 0;
+                }
+            } else if ($data["checkState"] == -1) {
+                $data["isRecover"] = 2;
+                $data["shouldEnjoyMoney"] = null;
+                $data["realEnjoyMoney"] = null;
+                $data["decideMoneyDetail"] = null;
+                $data["decideDetail"] = null;
             }
             }
-            if ($param["allowanceType"] == 3) {
-                $data["months"] = "";
-                $data["money"] = 0;
-                $data["moneyDesc"] = "";
-                $data["jtTalentArrange"] = "";
-                $data["workAllowanceMoney"] = null;
-                $data["developAllowanceMoney"] = null;
-            }
-            $data["isPublicCheck"] = 1;
             $data["publicState"] = 4;
             $data["publicState"] = 4;
-            //添加日志            
+            houseModel::update($data);
+            //添加日志
             TalentChecklog::create([
             TalentChecklog::create([
                 'id' => getStringId(),
                 'id' => getStringId(),
-                'mainId' => $old['id'],
-                'type' => intval(ProjectState::JBT),
+                'mainId' => $data['id'],
+                'type' => intval(ProjectState::HOUSE),
                 'typeFileId' => null,
                 'typeFileId' => null,
                 'active' => 1,
                 'active' => 1,
-                'state' => $param["checkState"] == AllowanceStateEnum::REVIEW_PASS ? 3 : $param["checkState"],
+                'state' => $old["checkState"],
                 'step' => 6,
                 'step' => 6,
                 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
                 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
-                'description' => $desc,
+                'description' => "公示再审核",
                 'createTime' => date("Y-m-d H:i:s", time()),
                 'createTime' => date("Y-m-d H:i:s", time()),
                 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
                 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
             ]);
             ]);
-            TaModel::update($data);
-            if ($arrangeList != null) {
-                $taaModel = new TalentAllowanceArrange();
-                $taaModel->saveAll($arrangeList);
-            }
             return new Response(Response::SUCCESS, "审核成功");
             return new Response(Response::SUCCESS, "审核成功");
         } catch (\think\Exception $e) {
         } catch (\think\Exception $e) {
             return new Response(Response::ERROR, "系统异常,请联系管理员");
             return new Response(Response::ERROR, "系统异常,请联系管理员");
@@ -1370,7 +1677,7 @@ class House extends AdminController {
             case 4:
             case 4:
                 if ($checkState != HouseStateEnum::REVIEW_PASS && $checkState != HouseStateEnum::NOTPASS) {
                 if ($checkState != HouseStateEnum::REVIEW_PASS && $checkState != HouseStateEnum::NOTPASS) {
                     return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
                     return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
-                } else if ($old["publicState"] != 2) {
+                } else if ($old["publicState"] != 3) {
                     return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
                     return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
                 } else {
                 } else {
                     $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
                     $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
@@ -1382,7 +1689,7 @@ class House extends AdminController {
                         $old["checkMsg"] = "";
                         $old["checkMsg"] = "";
                     }
                     }
                     $housepurchase = [];
                     $housepurchase = [];
-                    $this->calculate($old, $housepurchase, [], 1);
+                    $this->calculate($old, $housepurchase, $decideDesc, 1);
                     if ($res->code == 500) {
                     if ($res->code == 500) {
                         return $res;
                         return $res;
                     }
                     }
@@ -1921,10 +2228,45 @@ class House extends AdminController {
                 }
                 }
             }
             }
         }
         }
-        $housepurchase["decideDetail"] = implode("", $descideDesc);
+        $housepurchase["decideDetail"] = $old["decideDetail"] . ($descideDesc ? implode("", $descideDesc) : "");
         return new Response(Response::SUCCESS, "", $housepurchase);
         return new Response(Response::SUCCESS, "", $housepurchase);
     }
     }
 
 
+    private function calculateOld($old, &$housepurchase = [], &$descideDesc = [], $type = 1) {
+        $count = $old["type"] == 1 ? 5 : 3;            //最大申报数
+        /*         * 1、查询享受人可享受的金额(可能存在多人),无记录则生成数据,并判断是否超过申报次数 */
+        $cashIdCard = explode(",", $old["cashIdCards"]);
+        $personMoneyDict = [];
+        foreach ($cashIdCard as $idCard) {
+            $where = [];
+            $where[] = ["code", "=", $idCard];
+            $where[] = ["type", "=", 1];
+            $dict = Db::table("un_house_money_dict")->where($where)->find();
+            if (!$dict) {
+                $dict = [
+                    "id" => getStringId(),
+                    "type" => 1,
+                    "code" => $idCard,
+                    "total" => $old["houseMoney"],
+                    "balance" => $old["houseMoney"],
+                    "count" => 0,
+                    "createTime" => date("Y-m-d H:i:s"),
+                    "createUser" => $this->user["uid"]
+                ];
+            }
+            $personMoneyDict[] = $dict;
+        }
+        $personMoneyMap = [];
+        foreach ($personMoneyDict as $hmd) {
+            $personMoneyMap[$hmd["code"]] = $hmd;
+        }
+        $personDict = $personMoneyMap[$old["idCard"]];
+        if ($personDict && $personDict[$old["idCard"]] >= $count) {
+            return new Response(Response::ERROR, "申报人已享受" . $count . "次购房补贴,无法再次享受");
+        }
+        $housepurchase["totalMoney"] = $personDict["total"];
+    }
+
     private function setHousepurchase($request) {
     private function setHousepurchase($request) {
         $name = \StrUtil::getRequestDecodeParam($request, "name");
         $name = \StrUtil::getRequestDecodeParam($request, "name");
         $idCard = \StrUtil::getRequestDecodeParam($request, "idCard");
         $idCard = \StrUtil::getRequestDecodeParam($request, "idCard");