Browse Source

购房补贴++

sugangqiang 1 năm trước cách đây
mục cha
commit
f8f1fdf64c

+ 25 - 50
app/admin/controller/House.php

@@ -1199,13 +1199,10 @@ class House extends AdminController {
             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);
+                    $maxMoney = $old["talentArrangeMoney"];
 
-                    if ($data["shouldEnjoyMoney"] > $minMoney) {
-                        return new Response(Response::ERROR, "当前申报的最高可享受金额为:" . $minMoney . "元!请重新计算并填写");
+                    if ($data["shouldEnjoyMoney"] > $maxMoney) {
+                        return new Response(Response::ERROR, "当前申报的最高可享受金额为:" . $maxMoney . "元!请重新计算并填写");
                     }
                     $result = $this->calculate($old, $data, $decideDetail, 2);
                     if ($result->code == 500) {
@@ -1735,9 +1732,9 @@ class House extends AdminController {
                         $old["checkMsg"] = "";
                     }
                     $housepurchase = [];
-                    $this->calculate($old, $housepurchase, $decideDesc, 1);
-                    if ($res->code == 500) {
-                        return $res;
+                    $result = $this->calculate($old, $housepurchase, $decideDesc, 1);
+                    if ($result->code == 500) {
+                        return $result;
                     }
                     $res["housepurchase"] = $housepurchase;
                 }
@@ -2168,12 +2165,25 @@ class House extends AdminController {
                 $code .= "gj";
                 break;
         }
-        $dic = DictApi::findByParentCodeAndCode($code, $houseInfo["count"] + 1);
-        if (!$dic)
+        $dicts = DictApi::findChildDictByCode($code);
+        if (!$dicts)
             return new Response(Response::ERROR, "系统字典中暂未设置购房补贴年度比例,请设置后再提交。");
-        $count = count(DictApi::findChildDictByCode($code));
+        $dicts = bubbleSort($dicts, "code");
+        $count = count($dicts);
         if ($houseInfo["count"] >= $count) {
-            return new Response(Response::ERROR, "申报人已享受五次购房补贴,无法再次享受");
+            return new Response(Response::ERROR, "申报人已享受{$count}次购房补贴,无法再次享受");
+        }
+        $dic = $dicts[$houseInfo["count"]];
+        if ($houseInfo["count"] > 0 && $count > 1) {
+            if (!is_numeric($dic["code"]) || ceil($dic["code"]) != $dic["code"]) {
+                return new Response(Response::ERROR, "系统字典中设置的购房补贴年度应该是整数,例如第一年应为1,第四年应为4");
+            }
+            $firstInfo = HouseApi::getFstInfoById($old["idCard"]);
+            $firstYear = substr($firstInfo["year"], 0, 4);
+            $nextApplyYear = date("Y", strtotime(sprintf("%d +%d years", $firstYear, $dic["code"] - $dicts[0]["code"])));
+            if (substr($old["year"], 0, 4) != $nextApplyYear) {
+                return new Response(Response::ERROR, "未到申报年度,下次申报年度为" . $nextApplyYear);
+            }
         }
         if (!is_numeric($dic["name"]) || $dic["name"] > 1 || $dic["name"] < 0)
             return new Response(Response::ERROR, "系统字典中设置的购房补贴年度比例应该是介于0~1之间的数字");
@@ -2204,7 +2214,7 @@ class House extends AdminController {
             $housepurchase["nowSubOtherMoney"] = 0;
             $housepurchase["nowNotSubOtherMoney"] = $totalOtherMoney;
         } else {
-            /*             * 比较余额和人才层次金额的20% */
+            /*             * 比较余额和人才层次金额 */
             $housepurchase["shouldEnjoyMoney"] = $balanceMoney >= $housepurchase["talentArrangeMoney"] ? $housepurchase["talentArrangeMoney"] : $balanceMoney;
             /*             * 计算可享受金额 */
             $realEnjoyMoney = $housepurchase["shouldEnjoyMoney"] - $totalOtherMoney;
@@ -2274,42 +2284,7 @@ class House extends AdminController {
             }
         }
         $housepurchase["decideDetail"] = $old["decideDetail"] . ($descideDesc ? implode("", $descideDesc) : "");
-        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"];
+        return new Response(Response:: SUCCESS, "", $housepurchase);
     }
 
     private function setHousepurchase($request) {

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

@@ -27,10 +27,20 @@ class HouseApi {
         return houseModel::findOrEmpty($id)->toArray();
     }
 
+    public static function getFstInfoById($idCard) {
+        $where = [];
+        $where[] = ["declareType", "=", 1];
+        $where[] = ["publicState", "=", 5];
+        $where[] = ["checkState", "=", HouseStateEnum::REVIEW_PASS];
+        $where[] = ["cashType", "=", 1];
+        $where[] = ["idCard", "=", $idCard];
+        return houseModel::where($where)->order("firstSubmitTime asc")->find();
+    }
+
     public static function getEnjoyTimesByIdCard($idCard) {
         $where = [];
         $where[] = ["declareType", "=", 1];
-        $where[] = ["publicState", "=", 4];
+        $where[] = ["publicState", "=", 5];
         $where[] = ["cashType", "=", 1];
         $where[] = ["cashIdCards", "like", "%" . $idCard . "%"];
         $count = houseModel::where($where)->order("year desc")->count();
@@ -71,7 +81,7 @@ class HouseApi {
         }
         $where[] = ["cashType", "=", 1];
         $where[] = ["checkState", "=", HouseStateEnum::REVIEW_PASS];
-        $where[] = ["publicState", "=", 3];
+        $where[] = ["publicState", ">=", 4];
         $where[] = ["id", "<>", $id];
         $whereRaw = sprintf("idCard in ('%s') or spouseIdcard in ('%s')", implode("','", $idCards), implode("','", $idCards));
         $ids = houseModel::field("id")->where($where)->whereRaw($whereRaw)->column("id");

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

@@ -113,9 +113,7 @@ Housepurchase.initColumn = function () {
                             "万元</br>8.本年度扣除享受其他政策金额:" + (parseFloat(row.nowSubOtherMoney) / 10000).toFixed(2) +
                             "万元</br>9.本年度未扣除享受其他政策金额:" + (parseFloat(row.nowNotSubOtherMoney) / 10000).toFixed(2) +
                             "万元</br>10.本年度最终可到账金额:" + (parseFloat(row.realEnjoyMoney) / 10000).toFixed(2) +
-                            "万元</br>11.社保缴纳情况:" + row.sbPayDetail +
-                            "</br>12.个税缴纳情况:" + row.taxPayDetail +
-                            "</br>13.判定说明:" + row.decideDetail;
+                            "</br>11.判定说明:" + row.decideDetail;
                     return "<span class='label label-success' onclick=\"layer.alert('" + html + "', {title:'计算结果', skin: 'layui-layer-molv',closeBtn: 0,area: ['500px', '500px']})\" >" +
                             "<i class=\"fa fa-book\"></i>查看" +
                             "</span>";