|
@@ -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) {
|