|
@@ -13,6 +13,7 @@ use app\common\state\CommonConst;
|
|
|
use app\common\state\HouseStateEnum;
|
|
|
use app\common\model\HousePurchase as houseModel;
|
|
|
use app\common\api\HouseApi;
|
|
|
+use app\common\model\HousePurchaseHouseInfo as houseInfoModel;
|
|
|
|
|
|
/**
|
|
|
* Description of House
|
|
@@ -188,51 +189,52 @@ class House extends AdminController {
|
|
|
* 审核保存
|
|
|
*/
|
|
|
public function check() {
|
|
|
- $obj = $this->request->param();
|
|
|
- if (!$obj["checkState"]) {
|
|
|
+ $id = $this->request["id"];
|
|
|
+ $process = $this->request["process"];
|
|
|
+ $toProcess = $this->request["toProcess"];
|
|
|
+ $toDep = $this->request["toDep"];
|
|
|
+ $checkState = $this->request["checkState"];
|
|
|
+ $checkMsg = $this->request["checkMsg"];
|
|
|
+ $cashType = $this->request["cashType"];
|
|
|
+ $fields = $this->request["fields"];
|
|
|
+ $files = $this->request["files"];
|
|
|
+ if (!$checkState) {
|
|
|
return new Response(Response::ERROR, "请选择审核状态");
|
|
|
}
|
|
|
-
|
|
|
- $oldObj = TalentAllowanceApi::getInfoById($obj["id"]);
|
|
|
-
|
|
|
- if (!$oldObj) {
|
|
|
- return new Response(Response::ERROR, "审核对象不存在");
|
|
|
+ if ($process == 1) {
|
|
|
+ $old = HouseApi::getInfoById($id);
|
|
|
+ $old["fields"] = $fields;
|
|
|
+ $old["files"] = $files;
|
|
|
+ houseModel::update($old);
|
|
|
}
|
|
|
-
|
|
|
- $newObj = [];
|
|
|
- $newObj["id"] = $obj["id"];
|
|
|
- $projectList = [];
|
|
|
- $fileList = [];
|
|
|
- if ($obj["process"] == 1) {
|
|
|
- if (\StrUtil::isNotEmpAndNull($obj["projects"])) {
|
|
|
- $projectList = array_filter(explode(",", $obj["projects"]));
|
|
|
- $newObj["projects"] = implode(",", $projectList);
|
|
|
+ if ($process == 3) {
|
|
|
+ $data["id"] = $id;
|
|
|
+ if ($checkState == 2) {
|
|
|
+ if ($toProcess == 2) {
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["code", "in", $toDep];
|
|
|
+ $companyIds = \app\common\model\Company::where($where)->column("id");
|
|
|
+ $data["toDep"] = implode(",", $companyIds);
|
|
|
+ }
|
|
|
+ $data["toProcess"] = $toProcess;
|
|
|
}
|
|
|
- if (\StrUtil::isNotEmpAndNull($obj["files"])) {
|
|
|
- $fileList = array_filter(explode(",", $obj["files"]));
|
|
|
- $newObj["files"] = implode(",", $fileList);
|
|
|
+ if ($checkState == 3) {
|
|
|
+ $data["cashType"] = $cashType;
|
|
|
}
|
|
|
- //if (Const.RSJ.equals(checkCompany.getCode())) {
|
|
|
- $newObj["concats"] = $obj["concats"];
|
|
|
- $newObj["fields"] = $obj["fields"];
|
|
|
- //}
|
|
|
- }
|
|
|
- if ($obj["process"] == 3) {
|
|
|
- $newObj["toProcess"] = $obj["toProcess"];
|
|
|
- $newObj["toDep"] = $obj["toDep"];
|
|
|
+ houseModel::update($data);
|
|
|
}
|
|
|
- TaModel::update($newObj);
|
|
|
+
|
|
|
//添加日志
|
|
|
TalentChecklog::create([
|
|
|
'id' => getStringId(),
|
|
|
- 'mainId' => $obj['id'],
|
|
|
- 'type' => intval(ProjectState::JBT),
|
|
|
+ 'mainId' => $id,
|
|
|
+ 'type' => intval(ProjectState::HOUSE),
|
|
|
'typeFileId' => null,
|
|
|
'active' => 2,
|
|
|
- 'state' => $obj["checkState"],
|
|
|
- 'step' => $obj["process"],
|
|
|
- 'stateChange' => null,
|
|
|
- 'description' => $obj["checkMsg"],
|
|
|
+ 'state' => $checkState,
|
|
|
+ 'step' => $process,
|
|
|
+ 'stateChange' => "保存未提交",
|
|
|
+ 'description' => $checkMsg,
|
|
|
'createTime' => date("Y-m-d H:i:s", time()),
|
|
|
'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
|
|
|
]);
|
|
@@ -246,128 +248,267 @@ class House extends AdminController {
|
|
|
public function submitCheck() {
|
|
|
$id = $this->request["id"];
|
|
|
$process = $this->request["process"];
|
|
|
- $old = TalentAllowanceApi::getInfoById($id);
|
|
|
- if (!$old) {
|
|
|
- return new Response(Response::ERROR, "审核对象不存在");
|
|
|
- }
|
|
|
- $updCheck = [];
|
|
|
- $updCheck["id"] = $id;
|
|
|
- $updCheck["type"] = $old["type"];
|
|
|
- /* * 查询审核日志 */
|
|
|
- $log = TalentLogApi::getLastLogByStep($id, ProjectState::JBT, $process);
|
|
|
+ $companyId = $this->request["companyId"];
|
|
|
+ if ($process != 2) {
|
|
|
+ $companyId = null;
|
|
|
+ }
|
|
|
+ $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $companyId);
|
|
|
if (!$log) {
|
|
|
return new Response(Response::ERROR, "请先审核后再提交");
|
|
|
}
|
|
|
- $updCheck["checkMsg"] = $log["description"];
|
|
|
- /* * 判断到达的最高流程 */
|
|
|
- $updCheck["highProcess"] = !$old["highProcess"] || $old["highProcess"] < $process ? $process : $old["process"];
|
|
|
+ $checkState = $log["state"];
|
|
|
+ $housepurchase = [];
|
|
|
+ $housepurchase["id"] = $id;
|
|
|
+ $housepurchase["checkMsg"] = $log["description"];
|
|
|
+ $old = HouseApi::getInfoById($id);
|
|
|
+ //判断到达的最高流程
|
|
|
+ $housepurchase["highProcess"] = $old["highProcess"] == null ? $process : ($old["highProcess"] < $process ? $process : $old["highProcess"]);
|
|
|
switch ($process) {
|
|
|
case 1:
|
|
|
- switch ($log["state"]) {
|
|
|
- case 3:
|
|
|
- $updCheck["firstPassTime"] = $old["firstPassTime"];
|
|
|
- if (!$old["firstPassTime"]) {
|
|
|
- $updCheck["firstPassTime"] = date("Y-m-d H:i:s");
|
|
|
+ if ($checkState == -1) {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
|
|
|
+ $housepurchase["realEnjoyMoney"] = 0;
|
|
|
+ }
|
|
|
+ if ($checkState == 2) {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
|
|
|
+ }
|
|
|
+ if ($checkState == 3) { //审核通过
|
|
|
+ $depCount = Db::table("un_talent_depcheckstate")->where("mainId", $id)->count();
|
|
|
+ if ($depCount > 0) {
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["mainId", "=", $id];
|
|
|
+ $where[] = ["state", "=", 2];
|
|
|
+ $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
|
|
|
+ if ($rejectCount > 0) {
|
|
|
+ $updDep["state"] = 9;
|
|
|
+ $updDep["updateTime"] = date("Y-m-d H:i:s");
|
|
|
+ $updDep["updateUser"] = $this->user["name"];
|
|
|
+ Db::table("un_talent_depcheckstate")->where($where)->update($updDep);
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
|
|
|
+ } else {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
|
|
|
}
|
|
|
- if (!$old["visitPassTime"]) {
|
|
|
- $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
|
|
|
+ } else {
|
|
|
+ /* * 生成各部门数据审核 */
|
|
|
+ $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"]
|
|
|
+ ];
|
|
|
}
|
|
|
- $updCheck["submitTime"] = date("Y-m-d H:i:s");
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT;
|
|
|
- break;
|
|
|
- case -2:
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT_BRANCH;
|
|
|
- break;
|
|
|
- case -1:
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
|
|
|
- $updCheck["recommendAllowanceType"] = 3;
|
|
|
- $updCheck["recommendMoney"] = 0;
|
|
|
- $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
|
|
|
- break;
|
|
|
- default:
|
|
|
- return new Response(Response::ERROR, "未知的审核状态");
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ /* * 判断夫妻是否同时申报 */
|
|
|
+ if (\StrUtil::isNotEmpAndNull($old["spouseIdcard"])) {
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["idCard", "=", $old["spouseIdcard"]];
|
|
|
+ $where[] = ["year", "=", $old["year"]];
|
|
|
+ $where[] = ["delete", "=", 0];
|
|
|
+ $count = houseModel::where($where)->count();
|
|
|
+ $housepurchase["isConflict"] = $count > 0 ? 1 : 2;
|
|
|
+ }
|
|
|
}
|
|
|
//添加日志
|
|
|
TalentChecklog::create([
|
|
|
'id' => getStringId(),
|
|
|
'mainId' => $id,
|
|
|
- 'type' => intval(ProjectState::JBT),
|
|
|
+ 'type' => intval(ProjectState::HOUSE),
|
|
|
'typeFileId' => null,
|
|
|
'active' => 1,
|
|
|
- 'state' => $log["state"],
|
|
|
+ 'state' => $checkState,
|
|
|
'step' => $process,
|
|
|
- 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
|
|
|
+ '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"])
|
|
|
]);
|
|
|
+ TalentChecklog::delete($log["id"]);
|
|
|
+ houseModel::update($housepurchase);
|
|
|
break;
|
|
|
case 2:
|
|
|
- if ($old["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $old["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
|
|
|
- return new Response(Response::ERROR, "不在审核范围内");
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["mainId", "=", $id];
|
|
|
+ $where[] = ["companyId", "=", $companyId];
|
|
|
+ $tds = Db::table("un_talent_depcheckstate")->where($where)->find();
|
|
|
+ $tds["state"] = 3;
|
|
|
+ $tds["submitTime"] = date("Y-m-d H:i:s");
|
|
|
+ Db::table("un_talent_depcheckstate")->update($tds);
|
|
|
+ //判断所有部门是否全部通过
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["mainId", "=", $id];
|
|
|
+ $where[] = ["state", "in", [1, 4, 9]];
|
|
|
+ $needCount = Db::table("un_talent_depcheckstate")->where($where)->count();
|
|
|
+ if ($needCount == 0) {
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["mainId", "=", $id];
|
|
|
+ $where[] = ["state", "=", 2];
|
|
|
+ $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
|
|
|
+ if ($rejectCount > 0) {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::DEP_REJECT;
|
|
|
+ } else {
|
|
|
+ if (\StrUtil::isEmpOrNull($old["depPassTime"])) {
|
|
|
+ $housepurchase["depPassTime"] = date("Y-m-d H:i:s");
|
|
|
+ }
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
|
|
|
+ }
|
|
|
+ houseModel::update($housepurchase);
|
|
|
}
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
|
|
|
- $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
|
|
|
+
|
|
|
//添加日志
|
|
|
TalentChecklog::create([
|
|
|
'id' => getStringId(),
|
|
|
'mainId' => $id,
|
|
|
- 'type' => intval(ProjectState::JBT),
|
|
|
+ 'type' => intval(ProjectState::HOUSE),
|
|
|
+ "companyId" => $companyId,
|
|
|
'typeFileId' => null,
|
|
|
'active' => 1,
|
|
|
'state' => 3,
|
|
|
'step' => $process,
|
|
|
- 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
|
|
|
- 'description' => "走访核查提交审核",
|
|
|
+ '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"])
|
|
|
]);
|
|
|
+ TalentChecklog::delete($log["id"]);
|
|
|
break;
|
|
|
case 3:
|
|
|
- switch ($log["state"]) {
|
|
|
- case 3:
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::REVIEW_PASS;
|
|
|
- $updCheck["reviewPassTime"] = date("Y-m-d H:i:s");
|
|
|
- /* * * 在此处需要判断津补贴类型 */
|
|
|
- $arrangeList = $this->validateAllowanceType($updCheck);
|
|
|
- $taaModel = new TalentAllowanceArrange();
|
|
|
- $taaModel->saveAll($arrangeList);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::REJECT_TO_FIRST;
|
|
|
- $updCheck["toProcess"] = null;
|
|
|
- $updCheck["toDep"] = "";
|
|
|
- break;
|
|
|
- case -1:
|
|
|
- $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
|
|
|
- $updCheck["recommendAllowanceType"] = 3;
|
|
|
- $updCheck["recommendMoney"] = 0;
|
|
|
- $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
|
|
|
- break;
|
|
|
- default:
|
|
|
- return new Response(Response::ERROR, "未知的审核状态");
|
|
|
+ if ($checkState == -1) {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
|
|
|
+ $housepurchase["cashType"] = 2;
|
|
|
+ $housepurchase["realEnjoyMoney"] = 0;
|
|
|
}
|
|
|
- //添加日志
|
|
|
- TalentChecklog::create([
|
|
|
- 'id' => getStringId(),
|
|
|
- 'mainId' => $id,
|
|
|
- 'type' => intval(ProjectState::JBT),
|
|
|
- 'typeFileId' => null,
|
|
|
- 'active' => 1,
|
|
|
- 'state' => $log["state"],
|
|
|
- 'step' => $process,
|
|
|
- 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
|
|
|
- 'description' => $log["description"],
|
|
|
- 'createTime' => date("Y-m-d H:i:s", time()),
|
|
|
- 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
|
|
|
- ]);
|
|
|
+ if ($checkState == 2) {
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["mainId", "=", $id];
|
|
|
+ $where[] = ["companyId", "in", $old["toDep"]];
|
|
|
+ if ($old["toProcess"] == -1) {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
|
|
|
+ if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
|
|
|
+ $updTds["state"] = 2;
|
|
|
+ Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($old["toProcess"] == 1) {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_FIRST;
|
|
|
+ if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
|
|
|
+ $updTds["state"] = 2;
|
|
|
+ Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
|
|
|
+ }
|
|
|
+ } else if ($old["toProcess"] == 2) {
|
|
|
+ $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_DEP;
|
|
|
+ if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
|
|
|
+ $updTds["state"] = 4;
|
|
|
+ Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($checkState == 3) {
|
|
|
+ /**
|
|
|
+ * 通过需要判定补贴类型及享受金额
|
|
|
+ * */
|
|
|
+ $where = [];
|
|
|
+ $where[] = ["idCard", "=", $old["idCard"]];
|
|
|
+ $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, "当前申报人的津补贴申报暂未公示通过,无法审核通过");
|
|
|
+ }
|
|
|
+ $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.获取社保/个税数据并判断是否可以享受* */
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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);
|
|
|
break;
|
|
|
}
|
|
|
- TalentChecklog::where("id", $log["id"])->delete();
|
|
|
- TaModel::update($updCheck);
|
|
|
return new Response(Response::SUCCESS, "提交审核成功");
|
|
|
}
|
|
|
|
|
@@ -1596,112 +1737,156 @@ class House extends AdminController {
|
|
|
* @description 计算购房补贴金额
|
|
|
* */
|
|
|
private function calculate($old, $type) {
|
|
|
+ $housepurchase = [];
|
|
|
+ $descideDesc = [];
|
|
|
$count = $old["type"] == 1 ? 5 : 3; //最大申报数
|
|
|
/* * 1、查询申报人和配偶的房产信息 */
|
|
|
$houseInfo = HouseApi::getHouseInfo($old["idCard"]);
|
|
|
$spouseHouseInfo = HouseApi::getHouseInfo($old["spouseIdCard"]);
|
|
|
if (!$houseInfo) {
|
|
|
$houseInfo = [
|
|
|
- "idCard"=>$old["idCard"],
|
|
|
- =>null,
|
|
|
- "houseAddress"=>$old["houseAddress"],
|
|
|
- "houseArea"=>$old["houseArea"],
|
|
|
- "houseMoney"=>$old["houseMoney"],
|
|
|
- "recordTime"=>$old["recordTime"],
|
|
|
- "realEstateNo"=>$old["realEstateNo"],
|
|
|
- "recordNo"=>$old["recordNo"],
|
|
|
- =>$old["houseMoney"],
|
|
|
- =>0,
|
|
|
- =>0
|
|
|
+ "idCard" => $old["idCard"],
|
|
|
+ "spouseIdCard" => null,
|
|
|
+ "houseAddress" => $old["houseAddress"],
|
|
|
+ "houseArea" => $old["houseArea"],
|
|
|
+ "houseMoney" => $old["houseMoney"],
|
|
|
+ "recordTime" => $old["recordTime"],
|
|
|
+ "realEstateNo" => $old["realEstateNo"],
|
|
|
+ "recordNo" => $old["recordNo"],
|
|
|
+ "balanceMoney" => $old["houseMoney"],
|
|
|
+ "count" => 0,
|
|
|
+ "lastYearArrears" => 0
|
|
|
];
|
|
|
- old . getRecordNo(), old . getHouseMoney(), 0, BigDecimal . ZERO
|
|
|
- houseInfo = new HousepurchaseHouseInfo(old . getIdCard(), null, old . getHouseAddress(), old . getHouseArea(), old . getHouseMoney(), old . getRecordTime(), old . getRealEstateNo(), old . getRecordNo(), old . getHouseMoney(), 0, BigDecimal . ZERO);
|
|
|
}
|
|
|
//判断是否超过五次申报
|
|
|
if ($houseInfo["count"] >= $count) {
|
|
|
return new Response(Response::ERROR, "申报人已享受五次购房补贴,无法再次享受");
|
|
|
}
|
|
|
- if (BigDecimal . ZERO . compareTo(houseInfo . getBalanceMoney()) >= 0) {
|
|
|
- return new ResponseObj(ResponseObj . FAILD, "申报房产可享受余额不足,无法享受");
|
|
|
+ if ($houseInfo["balanceMoney"] <= 0) {
|
|
|
+ return new Response(Response::ERROR, "申报房产可享受余额不足,无法享受");
|
|
|
}
|
|
|
/* * 2.查询购房补贴费用标准,根据人才层次计算可享受金额 */
|
|
|
- AmountStandard amountStandard = amountStandardService.selectOne(new EntityWrapper<AmountStandard>().eq("type", ShiroKit.getUser().getType()).eq("allowanceType", 3).eq("talentArrange", old.getTalentArrange()));
|
|
|
- if (amountStandard == null)
|
|
|
- return new ResponseObj(ResponseObj . FAILD, "系统暂未设置该人才层次的购房补贴享受金额,请设置后再提交");
|
|
|
- if (old . getType() == 1) {
|
|
|
- housepurchase . setTalentArrangeMoney(new BigDecimal(0.2) . multiply(amountStandard . getMoney()) . setScale(2, BigDecimal . ROUND_HALF_UP));
|
|
|
- } else {
|
|
|
- Dict dic = this . dictService . findByParentCodeAndCode(DictConst . UN_HOUSEPURCHASE_PERCENTAGE_IC, String . valueOf(houseInfo . getCount() + 1));
|
|
|
- housepurchase . setTalentArrangeMoney(new BigDecimal(dic . getName()) . multiply(amountStandard . getMoney()) . setScale(2, BigDecimal . ROUND_HALF_UP));
|
|
|
- }
|
|
|
- /* * 3.计算当年度录入享受其他政策的金额 */
|
|
|
- List<HousepurchaseEnjoyOther> otherList = this.housepurchaseEnjoyOtherService.selectList(new EntityWrapper<HousepurchaseEnjoyOther>().eq("pId", old.getId()));
|
|
|
- if (otherList == null || otherList . size() == 0) {
|
|
|
- housepurchase . setNowOtherMoney(BigDecimal . ZERO);
|
|
|
+ $amountStandard = \app\common\api\AmountStandardApi::getStandard($this->user["type"], 3, $old["talentArrange"]);
|
|
|
+ if (!$amountStandard)
|
|
|
+ return new Response(Response::ERROR, "系统暂未设置该人才层次的购房补贴享受金额,请设置后再提交");
|
|
|
+ if ($old["type"] == 1) {
|
|
|
+ $housepurchase["talentArrangeMoney"] = round(0.2 * $amountStandard["money"], 2);
|
|
|
} else {
|
|
|
- for (HousepurchaseEnjoyOther other : otherList) {
|
|
|
- housepurchase . setNowOtherMoney(housepurchase . getNowOtherMoney() == null ? other . getMoney() : housepurchase . getNowOtherMoney() . add(other . getMoney()));
|
|
|
+ $code = "housepurchase_percentage_";
|
|
|
+ switch ($old["type"]) {
|
|
|
+ case CommonConst::ENTERPRISE_JC:
|
|
|
+ $code .= "ic";
|
|
|
+ break;
|
|
|
+ case CommonConst::ENTERPRISE_WJ:
|
|
|
+ $code .= "wj";
|
|
|
+ break;
|
|
|
+ case CommonConst::ENTERPRISE_GJ:
|
|
|
+ $code .= "gj";
|
|
|
+ break;
|
|
|
}
|
|
|
+ $dic = DictApi::findByParentCodeAndCode($code, $houseInfo["count"] + 1);
|
|
|
+ if (!$dic)
|
|
|
+ return new Response(Response::ERROR, "系统字典中暂未设置购房补贴年度比例,请设置后再提交。字典代码以[集成电路:housepurchase_percentage_ic][卫健:housepurchase_percentage_wj][高教:housepurchase_percentage_gj]为准");
|
|
|
+ if (!is_numeric($dic["name"]) || $dic["name"] > 1 || $dic["name"] < 0)
|
|
|
+ return new Response(Response::ERROR, "系统字典中设置的购房补贴年度比例应该是介于0~1之间的数字");
|
|
|
+ $housepurchase["talentArrangeMoney"] = round($dic["name"] * $amountStandard["money"], 2);
|
|
|
}
|
|
|
- housepurchase . setLastOtherMoney(spouseHouseInfo != null ? houseInfo . getLastYearArrears() . add(spouseHouseInfo . getLastYearArrears()) . setScale(2, BigDecimal . ROUND_HALF_UP) : houseInfo . getLastYearArrears());
|
|
|
- BigDecimal totalOtherMoney = housepurchase . getNowOtherMoney() . add(housepurchase . getLastOtherMoney()) . setScale(2, BigDecimal . ROUND_HALF_UP);
|
|
|
+ /* * 3.计算当年度录入享受其他政策的金额 */
|
|
|
+ $otherList = HouseApi::getEnjoyOtherList($old["id"]);
|
|
|
+ $housepurchase["nowOtherMoney"] = 0;
|
|
|
+ foreach ($otherList as $other) {
|
|
|
+ $housepurchase["nowOtherMoney"] += $other["money"];
|
|
|
+ }
|
|
|
+ $lastOtherMoney = $spouseHouseInfo ? $houseInfo["lastYearArrears"] + $spouseHouseInfo["lastYearArrears"] : $houseInfo["lastYearArrears"];
|
|
|
+ $housepurchase["lastOtherMoney"] = round($lastOtherMoney, 2);
|
|
|
+ $totalOtherMoney = round($housepurchase["nowOtherMoney"] + $housepurchase["lastOtherMoney"], 2);
|
|
|
/* * 计算当前人才层次可享受金额 */
|
|
|
- BigDecimal banaleMoney = amountStandard . getMoney() . subtract(houseInfo . getHouseMoney() . subtract(houseInfo . getBalanceMoney())) . setScale(2, BigDecimal . ROUND_HALF_UP);
|
|
|
+ $balanceMoney = round($amountStandard["money"] - ($houseInfo["houseMoney"] - $houseInfo["balanceMoney"]), 2);
|
|
|
/* * 判断余额 */
|
|
|
- banaleMoney = banaleMoney . compareTo(houseInfo . getBalanceMoney()) >= 0 ? houseInfo . getBalanceMoney() : banaleMoney;
|
|
|
- if (BigDecimal . ZERO . compareTo(banaleMoney) >= 0) {
|
|
|
- descideDesc . append("可享受余额为:" + banaleMoney + "元;");
|
|
|
+ $balanceMoney = $balanceMoney >= $houseInfo["balanceMoney"] ? $houseInfo["balanceMoney"] : $balanceMoney;
|
|
|
+
|
|
|
+ if ($balanceMoney <= 0) {
|
|
|
+ $descideDesc[] = "可享受余额为:" . $balanceMoney . "元;";
|
|
|
/* * 判断享受其他政策是否大于0 */
|
|
|
- if (BigDecimal . ZERO . compareTo(totalOtherMoney) < 0) {
|
|
|
- housepurchase . setIsRecover(1);
|
|
|
- descideDesc . append("需要追讨金额为:" + totalOtherMoney + "元;");
|
|
|
+ if ($totalOtherMoney > 0) {
|
|
|
+ $housepurchase["isRecover"] = 1;
|
|
|
+ $descideDesc[] = "需要追讨金额为:" . $totalOtherMoney . "元;";
|
|
|
}
|
|
|
- housepurchase . setShouldEnjoyMoney(BigDecimal . ZERO);
|
|
|
- housepurchase . setRealEnjoyMoney(BigDecimal . ZERO);
|
|
|
- housepurchase . setNowSubOtherMoney(BigDecimal . ZERO);
|
|
|
- housepurchase . setNowNotSubOtherMoney(totalOtherMoney);
|
|
|
+ $housepurchase["shouldEnjoyMoney"] = 0;
|
|
|
+ $housepurchase["realEnjoyMoney"] = 0;
|
|
|
+ $housepurchase["nowSubOtherMoney"] = 0;
|
|
|
+ $housepurchase["nowNotSubOtherMoney"] = $totalOtherMoney;
|
|
|
} else {
|
|
|
/* * 比较余额和人才层次金额的20% */
|
|
|
- int tmpInt = banaleMoney . compareTo(housepurchase . getTalentArrangeMoney());
|
|
|
- housepurchase . setShouldEnjoyMoney(tmpInt >= 0 ? housepurchase . getTalentArrangeMoney() : banaleMoney);
|
|
|
+ $housepurchase["shouldEnjoyMoney"] = $balanceMoney >= $housepurchase["talentArrangeMoney"] ? $housepurchase["talentArrangeMoney"] : $balanceMoney;
|
|
|
/* * 计算可享受金额 */
|
|
|
- BigDecimal realEnjoyMoney = housepurchase . getShouldEnjoyMoney() . subtract(totalOtherMoney);
|
|
|
- if (BigDecimal . ZERO . compareTo(realEnjoyMoney) == 0) {
|
|
|
- housepurchase . setRealEnjoyMoney(realEnjoyMoney);
|
|
|
- housepurchase . setNowSubOtherMoney(totalOtherMoney);
|
|
|
- housepurchase . setNowNotSubOtherMoney(realEnjoyMoney);
|
|
|
+ $realEnjoyMoney = $housepurchase["shouldEnjoyMoney"] - $totalOtherMoney;
|
|
|
+ if ($realEnjoyMoney == 0) {
|
|
|
+ $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
|
|
|
+ $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
|
|
|
+ $housepurchase["nowNotSubOtherMoney"] = $realEnjoyMoney;
|
|
|
/* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
|
|
|
- } else if (BigDecimal . ZERO . compareTo(realEnjoyMoney) < 0) {
|
|
|
- housepurchase . setRealEnjoyMoney(realEnjoyMoney);
|
|
|
- housepurchase . setNowSubOtherMoney(totalOtherMoney);
|
|
|
- housepurchase . setNowNotSubOtherMoney(BigDecimal . ZERO);
|
|
|
+ } else if ($realEnjoyMoney > 0) {
|
|
|
+ $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
|
|
|
+ $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
|
|
|
+ $housepurchase["nowNotSubOtherMoney"] = 0;
|
|
|
/* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
|
|
|
- } else if (BigDecimal . ZERO . compareTo(realEnjoyMoney) > 0) {
|
|
|
- housepurchase . setIsRecover(1);
|
|
|
- descideDesc . append("需要追讨金额为:" + realEnjoyMoney . abs() + "元;");
|
|
|
- housepurchase . setRealEnjoyMoney(BigDecimal . ZERO);
|
|
|
- housepurchase . setNowSubOtherMoney(housepurchase . getShouldEnjoyMoney());
|
|
|
- housepurchase . setNowNotSubOtherMoney(realEnjoyMoney . abs());
|
|
|
+ } else if ($realEnjoyMoney < 0) {
|
|
|
+ $housepurchase["isRecover"] = 1;
|
|
|
+ $descideDesc[] = "需要追讨金额为:" . abs($realEnjoyMoney) . "元;";
|
|
|
+ $housepurchase["realEnjoyMoney"] = 0;
|
|
|
+ $housepurchase["nowSubOtherMoney"] = $housepurchase["shouldEnjoyMoney"];
|
|
|
+ $housepurchase["nowNotSubOtherMoney"] = abs($realEnjoyMoney);
|
|
|
/* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录并生成新的未扣除记录 */
|
|
|
}
|
|
|
- if (type == 2) {
|
|
|
- houseInfo . setCount(houseInfo . getCount() + 1);
|
|
|
- houseInfo . setBalanceMoney(houseInfo . getBalanceMoney() . subtract(housepurchase . getShouldEnjoyMoney()) . setScale(2, BigDecimal . ROUND_HALF_UP));
|
|
|
- houseInfo . setLastYearArrears(housepurchase . getNowSubOtherMoney());
|
|
|
- if (FengStringUtil . isNotEmpAndNull(housepurchase . getSpouseIdcard())) {
|
|
|
- if (spouseHouseInfo == null) {
|
|
|
- spouseHouseInfo = new HousepurchaseHouseInfo(old . getSpouseIdcard(), null, old . getHouseAddress(), old . getHouseArea(), old . getHouseMoney(), old . getRecordTime(), old . getRealEstateNo(), old . getRecordNo(), houseInfo . getBalanceMoney(), houseInfo . getCount(), houseInfo . getLastYearArrears());
|
|
|
+ if ($type == 2) {
|
|
|
+ $houseInfo["count"] = $houseInfo["count"] + 1;
|
|
|
+ $houseInfo["balanceMoney"] = round($houseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"], 2);
|
|
|
+ $houseInfo["lastYearArrears"] = $housepurchase["nowSubOtherMoney"];
|
|
|
+ if (\StrUtil::isNotEmpAndNull($housepurchase["spouseIdcard"])) {
|
|
|
+ if (!$spouseHouseInfo) {
|
|
|
+ $spouseHouseInfo = [
|
|
|
+ "idCard" => $old["spouseIdcard"],
|
|
|
+ "spouseIdCard" => null,
|
|
|
+ "houseAddress" => $old["houseAddress"],
|
|
|
+ "houseArea" => $old["houseArea"],
|
|
|
+ "houseMoney" => $old["houseMoney"],
|
|
|
+ "recordTime" => $old["recordTime"],
|
|
|
+ "realEstateNo" => $old["realEstateNo"],
|
|
|
+ "recordNo" => $old["recordNo"],
|
|
|
+ "balanceMoney" => $houseInfo["balanceMoney"],
|
|
|
+ "count" => $houseInfo["count"],
|
|
|
+ "lastYearArrears" => $houseInfo["lastYearArrears"]
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ $spouseHouseInfo["count"] = $spouseHouseInfo["count"] + 1;
|
|
|
+ $spouseHouseInfo["lastYearArrears"] = $houseInfo["lastYearArrears"];
|
|
|
+ $spouseHouseInfo["balanceMoney"] = $spouseHouseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"];
|
|
|
+ }
|
|
|
+ if ($spouseHouseInfo["id"]) {
|
|
|
+ $spouseHouseInfo["updateTime"] = date("Y-m-d H:i:s");
|
|
|
+ $spouseHouseInfo["updateUser"] = $this->user["uid"];
|
|
|
+ houseInfoModel::update($spouseHouseInfo);
|
|
|
} else {
|
|
|
- spouseHouseInfo . setCount(spouseHouseInfo . getCount() + 1);
|
|
|
- spouseHouseInfo . setLastYearArrears(houseInfo . getLastYearArrears());
|
|
|
- spouseHouseInfo . setBalanceMoney(spouseHouseInfo . getBalanceMoney() . subtract(housepurchase . getShouldEnjoyMoney()));
|
|
|
+ $spouseHouseInfo["id"] = getStringId();
|
|
|
+ $spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
|
|
|
+ $spouseHouseInfo["createUser"] = $this->user["uid"];
|
|
|
+ houseInfoModel::insert($spouseHouseInfo);
|
|
|
}
|
|
|
- this . housepurchaseHouseInfoService . insertOrUpdate(houseInfo);
|
|
|
}
|
|
|
- this . housepurchaseHouseInfoService . insertOrUpdate(houseInfo);
|
|
|
+ if ($houseInfo["id"]) {
|
|
|
+ $houseInfo["updateTime"] = date("Y-m-d H:i:s");
|
|
|
+ $houseInfo["updateUser"] = $this->user["uid"];
|
|
|
+ houseInfoModel::update($houseInfo);
|
|
|
+ } else {
|
|
|
+ $houseInfo["id"] = getStringId();
|
|
|
+ $houseInfo["createTime"] = date("Y-m-d H:i:s");
|
|
|
+ $houseInfo["createUser"] = $this->user["uid"];
|
|
|
+ houseInfoModel::insert($houseInfo);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- housepurchase . setDecideDetail(descideDesc . toString());
|
|
|
+ $housepurchase["decideDetail"] = implode("", $descideDesc);
|
|
|
return new Response(Response::SUCCESS, "", $housepurchase);
|
|
|
}
|
|
|
|