request["process"];
$type = $this->user["type"];
$assigns = ["process" => $process, "type" => $type];
if ($process == 4) {
if ($type == CommonConst::ENTERPRISE_NORMAL) {
$msgBody["typeName"] = "晋江市现代产业体系人才津补贴申报";
$msgBody["address"] = "聚才网/人才晋江微信公众号";
$msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
$msgBody["phone"] = "0595-85633128";
$msgBody["email"] = "jjrc85661234@163.com";
}
if ($type == CommonConst::ENTERPRISE_JC) {
$msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
$msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
$msgBody["dep"] = "集成电路产业园区";
$msgBody["phone"] = "0595-82250007、0595-82250001";
$msgBody["email"] = "jjjcdr@163.com";
}
if ($type == CommonConst::ENTERPRISE_WJ) {
$msgBody["typeName"] = "晋江市医疗卫生人才津补贴申报";
$msgBody["address"] = "“健康晋江”微信公众号";
$msgBody["dep"] = "晋江市卫生健康局";
$msgBody["phone"] = "0595-85636159";
$msgBody["email"] = "jjswjjrsk@163.com";
}
if ($type == CommonConst::ENTERPRISE_GJ) {
$msgBody["typeName"] = "晋江市高等教育人才津补贴申报";
$msgBody["address"] = "“泉州市高教发展中心”微信公众号";
$msgBody["dep"] = "泉州市高教发展中心";
$msgBody["phone"] = "0595-85002588";
$msgBody["email"] = "jjsgjrc@126.com";
}
$assigns["message"] = $msgBody;
}
return view("", $assigns);
}
/**
* 获取优秀人才津补贴列表
*/
public function list($process) {
$param = $this->request->param();
$offset = $param["offset"] ?: 0;
$limit = $param["limit"] ?: 10;
$param["process"] = $process;
$param["type"] = $this->user["type"];
$where = [];
$where[] = ["type", "=", $this->user["type"]];
$where[] = ["delete", "=", 0];
$order = "createTime desc";
$this->setCondition($where, $param);
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])) {
$count = houseModel::where($where)->count();
$list = houseModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
} else {
$company = getCacheById("Company", $this->user["companyId"]);
$result = HouseApi::selectForHousePurchase($param, $company, ProjectState::HOUSE, $offset, $limit);
$count = $result["total"];
$list = $result["rows"];
}
$list = $this->translateChinese($list, $process);
return json(["rows" => $list, "total" => $count]);
}
/**
* 审核页面
* @return type
*/
public function toCheckPage() {
$id = $this->request["id"];
$process = $this->request["process"];
$companyId = $this->request["companyId"];
$hand = $this->request["hand"];
$housepurchase = HouseApi::getInfoById($id);
$company = getCacheById("Company", $this->user["companyId"]);
$enterprise = \app\common\api\EnterpriseApi::getOne($housepurchase["enterpriseId"]);
$housepurchase["enterpriseName"] = $enterprise["name"];
$housepurchase["process"] = $process;
$housepurchase["companyId"] = $companyId;
$housepurchase["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $housepurchase["talentArrange"])["name"];
$housepurchase["marryStatusName"] = DictApi::findByParentCodeAndCode("marry_status", $housepurchase["marryStatus"])["name"];
$housepurchase["cardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["cardType"])["name"];
if (\StrUtil::isNotEmpAndNull($housepurchase["spouseCardType"])) {
$housepurchase["spouseCardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["spouseCardType"])["name"];
}
if (\StrUtil::isNotEmpAndNull($housepurchase["childCardType"])) {
$housepurchase["childCardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["childCardType"])["name"];
}
$housepurchase["streetName"] = DictApi::findByParentCodeAndCode("street", $housepurchase["street"])["name"];
if ($housepurchase["type"] == 1) {
$housepurchase["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $housepurchase["talentType"])["name"];
}
$housepurchase["identifyConditionCH"] = \app\common\api\TalentConditionApi::getOne($housepurchase["identifyCondition"])["name"];
/* * 历史申报享受其他政策数据* */
$historyOtherList = HouseApi::getHistoryEnjoyOtherList($id, $housepurchase["idCard"], $housepurchase["spouseIdcard"]);
/* * 当前申报录入的享受其他政策数据 */
$nowOtherList = HouseApi::getEnjoyOtherList($id);
/* * 其他房产信息 */
$zzjOtherHouseList = HouseApi::getOtherHouseList($id, 1);
$zrzyOtherHouseList = HouseApi::getOtherHouseList($id, 2);
/* * 未成年子女信息 */
$childrenList = HouseApi::getChildren($id);
/* * 配偶信息 */
$spouseList = HouseApi::getSpouse($id);
$dicts = DictApi::findChildDictByCode("card_type");
$vars = [
"dicts" => $dicts,
"row" => $housepurchase,
"company" => $company,
"historyOtherList" => $historyOtherList,
"nowOtherList" => $nowOtherList,
"zzjOtherHouseList" => $zzjOtherHouseList,
"zrzyOtherHouseList" => $zrzyOtherHouseList,
"childrenList" => $childrenList,
"spouseList" => $spouseList
];
$template = $hand == 1 ? "info" : "select";
return view($template, $vars);
}
/**
* 审核保存
*/
public function check() {
$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, "请选择审核状态");
}
if ($process == 1) {
$old = HouseApi::getInfoById($id);
$old["fields"] = $fields;
$old["files"] = $files;
houseModel::update($old);
}
if ($process == 3) {
$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");
$data["toDep"] = implode(",", $companyIds);
}
$data["toProcess"] = $toProcess;
}
if ($checkState == 3) {
$data["cashType"] = $cashType;
}
houseModel::update($data);
}
//添加日志
TalentChecklog::create([
'id' => getStringId(),
'mainId' => $id,
'type' => intval(ProjectState::HOUSE),
'typeFileId' => null,
'active' => 2,
'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"])
]);
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" => $this->request["otherList"],
"houseList" => $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' => $obj["zjjCheckDetail"] ? "录入核查数据:" . $obj["zjjCheckDetail"] : "录入核查数据:",
'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" => $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' => $obj["zrzzjCheckDetail"] ? "录入核查数据:" . $obj["zrzzjCheckDetail"] : "录入核查数据",
'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" => $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' => $obj["mzjCheckDetail"] ? "录入核查数据:" . $obj["mzjCheckDetail"] : "录入核查数据:",
'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, "审核成功");
}
/**
* @param id
* @param type
* @description 删除享受其他政策记录/历年享受记录
* */
public function deleteOtherOrHouse($id, $type) {
if (\StrUtil::isEmpOrNull($id)) {
return new Response(Response::ERROR, "系统错误");
}
if ($type == 1) { //享受其他政策
\app\common\model\HousePurchaseEnjoyOther::where("id", $id)->delete();
} else if (type == 2) { //其他房产信息
\app\common\model\HousePurchaseOtherHouse::where("id", $id)->delete();
}
return new Response(Response::SUCCESS, "删除成功");
}
/**
* @param id
* @description 删除配偶信息
* */
public function deleteSpouse($id) {
if (\StrUtil::isEmpOrNull($id)) {
return new Response(Response::ERROR, "系统错误");
}
\app\common\model\HousePurchaseSpouse::where("id", $id)->delete();
return new Response(Response::SUCCESS, "删除成功");
}
/**
* 提交审核
* @return Response
*/
public function submitCheck() {
$id = $this->request["id"];
$process = $this->request["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, "请先审核后再提交");
}
$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:
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;
}
} else {
/* * 生成各部门数据审核 */
$depList = [];
$depCodes = getJsonConfig("../sys_config.json", "housepurchase_dep_list")[$old["type"]];
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;
}
}
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::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;
case 2:
$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);
}
//添加日志
TalentChecklog::create([
'id' => getStringId(),
'mainId' => $id,
'type' => intval(ProjectState::HOUSE),
"companyId" => $companyId,
'typeFileId' => null,
'active' => 1,
'state' => 3,
'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];
$where[] = ["companyId", "=", $companyId];
TalentChecklog::where($where)->delete();
break;
case 3:
if ($checkState == -1) {
$housepurchase["checkState"] = HouseStateEnum::NOTPASS;
$housepurchase["cashType"] = 2;
$housepurchase["realEnjoyMoney"] = 0;
}
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["checkState"] == \app\common\state\AllowanceStateEnum::REVIEW_PASS && $info["publicState"] == 4) {
$housepurchase["allowanceType"] = $info["allowanceType"];
}
$housepurchase["cashType"] = $old["cashType"];
$descideDesc[] = "审核意见:" . $log["description"] . ";";
$housepurchase["checkState"] = HouseStateEnum::REVIEW_PASS;
if ($old["declareType"] == 1) { //购房补贴
/* * 对需要兑现的计算享受金额 */
if ($housepurchase["cashType"] == 1) {
$result = $this->calculate($old, $housepurchase, $descideDesc, 1);
if ($result->code == 500) {
return $result;
}
}
}
$housepurchase["decideDetail"] = implode("", $descideDesc);
if (\StrUtil::isEmpOrNull($old["reviewPassTime"])) {
$housepurchase["reviewPassTime"] = date("Y-m-d H:i:s");
}
}
//添加日志
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;
$ids = $this->request->param("ids");
$ids_arr = array_filter(explode(",", $ids));
if (!$ids_arr) {
$response->msg = "没有选择导出的名单";
return \StrUtil::back($response, "Housepurchase.callBack");
}
$where = [];
$where[] = ["id", "in", $ids_arr];
$list = houseModel::field("id,cardType,idCard,name,enterpriseId,year")->where($where)->select()->toArray();
if (!$list) {
$response->msg = "暂无可核查征信的数据";
return \StrUtil::back($response, "Housepurchase.callBack");
}
$columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "年度"];
$enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
$cardTypeName = DictApi::selectByParentCode("card_type");
$rows = [];
for ($i = 0; $i < count($list); $i++) {
$item = $list[$i];
$row = [
$i + 1, $item["name"], $cardTypeName[$item["cardType"]], $item["idCard"], $enterpriseMap[$item["enterpriseId"]], $item["year"]
];
$rows[] = $row;
}
$filename = "购房补贴待核查征信名单导出";
if ($rows) {
export($columns, $rows, $filename);
exit();
} else {
$response->msg = "没有选择导出的名单";
return \StrUtil::back($response, "Housepurchase.callBack");
}
}
/**
* 核查征信驳回
*/
public function hczxReject() {
$param = $this->request->param();
if (!$param) {
return new Response(Response::ERROR, "系统错误,请联系管理员");
}
$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["zxMsg"] = $param["outMsg"];
$data["cashType"] = 2;
$data["descideDesc"] = $old . "(1)核查征信结果:" . $param["outMsg"] . ";无法享受";
//添加日志
TalentChecklog::create([
'id' => getStringId(),
'mainId' => $param["id"],
'type' => intval(ProjectState::HOUSE),
'typeFileId' => null,
'active' => 1,
'state' => 2,
'step' => 4,
'stateChange' => HouseStateEnum::getStateName($old["checkState"]) . "->" . HouseStateEnum::getStateName($data["checkState"]) . "
公示状态:待核查->待公示",
'description' => $param["outMsg"],
'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, "核查征信成功");
}
/**
* 核查征信批量通过
*/
public function hczxPass() {
$ids = $this->request["ids"];
if (\StrUtil::isEmpOrNull($ids)) {
return new Response(Response::ERROR, "请选择核查征信通过的数据");
}
$where = [];
$where[] = ["id", "in", $ids];
$list = houseModel::where($where)->select()->toArray();
$logList = [];
$upds = [];
$new_ids = [];
foreach ($list as $obj) {
if ($obj["checkState"] == HouseStateEnum::REVIEW_PASS && $obj["publicState"] == 1) {
$new_ids[] = $obj["id"];
$logList[] = [
"id" => getStringId(),
"type" => ProjectState::HOUSE,
"mainId" => $obj["id"],
"active" => 1,
"state" => 3,
"step" => 4,
"stateChange" => "待核查->待公示",
"description" => "核查征信通过",
"createTime" => date("Y-m-d H:i:s"),
'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
];
}
}
$upd = [
"publicState" => 2,
];
if ($new_ids) {
$where = [];
$where[] = ["id", "in", $new_ids];
houseModel::where($where)->update($upd);
Db::table("new_talent_checklog")->insertAll($logList);
return new Response(Response::SUCCESS, "核查征信通过成功");
}
return new Response(Response::ERROR, "没有待核查的列表");
}
/**
* 公示
* */
public function publicBatch() {
$params = $this->request->param();
$ids = $params["ids"];
$ids = array_filter(explode(",", $ids));
if (!$ids) {
return new Response(Response::ERROR, "请至少选择一行数据");
}
$isMessage = $params["isMessage"] == 1 ? true : false;
if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
return new Response(Response::ERROR, "短信参数不能为空");
}
$where = [];
$where[] = ["id", "in", $ids];
$list = houseModel::where($where)->select()->toArray();
Db::startTrans();
try {
$logList = [];
$phones = [];
$newIds = [];
foreach ($list as $info) {
if ($info["checkState"] == HouseStateEnum::REVIEW_PASS && $info["publicState"] == 2) {
/* * 添加日志 */
$newIds[] = $info["id"];
$logList[] = [
"id" => getStringId(),
"type" => ProjectState::HOUSE,
"mainId" => $info["id"],
"active" => 1,
"state" => 3,
"step" => 5,
"stateChange" => "待公示->公示中",
"description" => "批量公示",
"createTime" => date("Y-m-d H:i:s"),
'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
];
$phones[] = $info["phone"];
}
}
if ($newIds) {
$where = [];
$where[] = ["id", "in", $newIds];
$data["publicState"] = 3;
Db::table("un_housepurchase")->where($where)->update($data);
$effect = Db::table("new_talent_checklog")->insertAll($logList);
Db::commit();
if ($phones && $isMessage && $effect) {
$tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
$params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
$phones = array_filter($phones);
foreach ($phones as $phone) {
queue("app\job\Messenger", ["type" => 6, "userId" => 0, "phone" => $phone, "template" => $tpl_content, "processName" => "购房补贴-批量公示", "userType" => 3]);
}
}
return new Response(Response::SUCCESS, "公示成功");
}
return new Response(Response::ERROR, "没有待公示的列表");
} catch (\think\db\exception\DbException $e) {
Db::rollback();
return new Response(Response::SUCCESS, "公示失败:" . $e->getMessage());
}
}
/**
* @param obj
* @description 公示再审核修改住建局、自然资源局数据
* */
public function afterCheckEdit() {
$obj = [
"id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
"checkIsTradeRecord" => \StrUtil::getRequestDecodeParam($this->request, "checkIsTradeRecord"),
"checkRecordTime" => \StrUtil::getRequestDecodeParam($this->request, "checkRecordTime"),
"mzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "mzjCheckDetail"),
"mzjSpouseList" => $this->request["mzjSpouseList"],
"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" => $this->request["zjjHouseList"],
"zrzyjHouseList" => $this->request["zrzyjHouseList"],
"otherList" => $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["mzjSpouseList"] && count($obj["mzjSpouseList"]) > 0) {
foreach ($obj["mzjSpouseList"] 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);
}
}
}
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 ($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);
}
}
}
houseModel::update($obj);
return new Response(Response::SUCCESS, "审核成功", $obj);
}
/**
* 公示后审核
*/
public function afterCheck() {
try {
$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) {
$maxMoney = $old["talentArrangeMoney"];
if ($data["shouldEnjoyMoney"] > $maxMoney) {
return new Response(Response::ERROR, "当前申报的最高可享受金额为:" . $maxMoney . "元!请重新计算并填写");
}
$result = $this->calculate($old, $data, $decideDetail, 2);
if ($result->code == 500) {
return $result;
}
}
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;
}
$data["publicState"] = 4;
houseModel::update($data);
//添加日志
TalentChecklog::create([
'id' => getStringId(),
'mainId' => $data['id'],
'type' => intval(ProjectState::HOUSE),
'typeFileId' => null,
'active' => 1,
'state' => $old["checkState"],
'step' => 6,
'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, "审核成功");
} catch (\think\Exception $e) {
return new Response(Response::ERROR, "系统异常,请联系管理员");
}
}
/**
* 批量公示通过
*/
public function publicPass() {
$ids = $this->request["ids"];
$ids = explode(",", $ids);
if (!$ids) {
return new Response(Response::ERROR, "请至少选择一行数据");
}
$where = [];
$where[] = ["id", "in", $ids];
$list = houseModel::where($where)->select()->toArray();
$houseInfoList = houseInfoModel::where(null)->select()->toArray();
$houseInfoMap = [];
foreach ($houseInfoList as $houseInfo) {
$houseInfoMap[$houseInfo["idCard"]] = $houseInfo;
}
$logList = [];
$insertHouseInfoList = [];
try {
Db::startTrans();
for ($i = 0; $i < count($list); $i++) {
$obj = $list[$i];
if ($obj["cashType"] == 1 && $obj["declareType"] == 1) {
$houseInfo = $houseInfoMap[$obj["idCard"]];
$spouseHouseInfo = $houseInfoMap[$obj["spouseIdcard"]];
if (!$houseInfo) {
$houseInfo = [
"idCard" => $obj["idCard"],
"spouseIdCard" => null,
"houseAddress" => $obj["houseAddress"],
"houseArea" => $obj["houseArea"],
"houseMoney" => $obj["houseMoney"],
"recordTime" => $obj["recordTime"],
"realEstateNo" => $obj["realEstateNo"],
"recordNo" => $obj["recordNo"],
"balanceMoney" => $obj["houseMoney"],
"count" => 0,
"lastYearArrears" => 0,
];
}
$houseInfo["count"] = $houseInfo["count"] + 1;
$houseInfo["balanceMoney"] = $houseInfo["balanceMoney"] - $obj["shouldEnjoyMoney"];
$houseInfo["lastYearArrears"] = $obj["nowNotSubOtherMoney"];
if (\StrUtil::isNotEmpAndNull($obj["spouseIdcard"])) {
if (!$spouseHouseInfo) {
$spouseHouseInfo = [
"idCard" => $obj["spouseIdcard"],
"spouseIdCard" => null,
"houseAddress" => $obj["houseAddress"],
"houseArea" => $obj["houseArea"],
"houseMoney" => $obj["houseMoney"],
"recordTime" => $obj["recordTime"],
"realEstateNo" => $obj["realEstateNo"],
"recordNo" => $obj["recordNo"],
"balanceMoney" => $houseInfo["balanceMoney"],
"count" => $houseInfo["count"],
"lastYearArrears" => $houseInfo["lastYearArrears"],
];
} else {
$spouseHouseInfo["count"] = $spouseHouseInfo["count"] + 1;
$spouseHouseInfo["lastYearArrears"] = $houseInfo["lastYearArrears"];
$spouseHouseInfo["balanceMoney"] = $spouseHouseInfo["balanceMoney"] - $obj["shouldEnjoyMoney"];
}
if ($spouseHouseInfo["id"]) {
$spouseHouseInfo["updateTime"] = date("Y-m-d H:i:s");
$spouseHouseInfo["updateUser"] = $this->user["uid"];
Db::table("un_housepurchase_house_info")->update($spouseHouseInfo);
} else {
$spouseHouseInfo["id"] = getStringId();
$spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
$spouseHouseInfo["createUser"] = $this->user["uid"];
$insertHouseInfoList[] = $spouseHouseInfo;
}
}
if ($houseInfo["id"]) {
$houseInfo["updateTime"] = date("Y-m-d H:i:s");
$houseInfo["updateUser"] = $this->user["uid"];
Db::table("un_housepurchase_house_info")->update($houseInfo);
} else {
$houseInfo["id"] = getStringId();
$houseInfo["createTime"] = date("Y-m-d H:i:s");
$houseInfo["createUser"] = $this->user["uid"];
$insertHouseInfoList[] = $houseInfo;
}
}
//添加日志
$logList[] = [
"id" => getStringId(),
"type" => ProjectState::HOUSE,
"mainId" => $obj["id"],
"active" => 1,
"state" => 3,
"step" => 6,
"stateChange" => "公示中->待公布;",
"description" => "批量公示通过",
"createTime" => date("Y-m-d H:i:s"),
'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
];
}
$upd["publicState"] = 4;
Db::table("un_housepurchase")->where($where)->update($upd);
if ($insertHouseInfoList) {
Db::table("un_housepurchase_house_info")->insertAll($insertHouseInfoList);
}
Db::table("new_talent_checklog")->insertAll($logList);
Db::commit();
return new Response(Response::SUCCESS, "批量公示通过成功");
} catch (\think\db\exception\DbException $e) {
Db::rollback();
return new Response(Response::ERROR, "批量公示失败:" . $e->getCode());
}
}
/**
* 兑现
*/
public function cash() {
$ids = $this->request["ids"];
$ids = array_filter(explode(",", $ids));
if (!$ids) {
return new Response(Response::ERROR, "请至少选择一行数据");
}
$where = [];
$where[] = ["id", "in", $ids];
$list = houseModel::where($where)->select()->toArray();
//添加日志
$logList = [];
try {
Db::startTrans();
for ($i = 0; $i < count($list); $i++) {
$obj = $list[$i];
$logList[] = [
"id" => getStringId(),
"type" => ProjectState::HOUSE,
"mainId" => $obj["id"],
"active" => 1,
"state" => 3,
"step" => 50,
"stateChange" => "待兑现->已兑现;",
"description" => "批量兑现",
"createTime" => date("Y-m-d H:i:s"),
'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
];
}
$upd["publicState"] = 5;
Db::table("un_housepurchase")->where($where)->update($upd);
Db::table("new_talent_checklog")->insertAll($logList);
Db::commit();
return new Response(Response::SUCCESS, "批量兑现成功");
} catch (\think\db\exception\DbException $e) {
Db::rollback();
return new Response(Response::ERROR, "批量兑现失败:" . $e->getCode());
}
}
/**
* 公示预览(不予兑现)
*/
public function exportPublicNotCash() {
$response = new \stdClass();
$response->code = 500;
//获取字典表人才层次+
$levelMap = DictApi::selectByParentCode("talent_arrange");
$streetMap = DictApi::selectByParentCode("street");
//查询企业信息
$enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
//查询所有
$where = [];
$where[] = ["id", "in", explode(",", $this->request["ids"])];
$list = TaModel::where($where)->select()->toArray();
$rows = [];
for ($i = 0; $i < count($list); $i++) {
$item = $list[$i];
$rows[] = [
$i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
];
}
$filename = CommonConst::getTypeName($this->user["type"]) . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
$columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
if ($rows) {
export($columns, $rows, $filename);
exit();
} else {
$response->msg = "没有选择导出的名单";
return \StrUtil::back($response, "Housepurchase.callBack");
}
}
/**
* @param ids
* @param type 1-需要兑现,2-不予兑现
* @description 公示预览
* */
public function exportPublic() {
/* * 查询需要公示的数据 */
$ids = array_filter(explode(",", $this->request["ids"]));
if (!$ids) {
return new Response(Response::ERROR, "请至少选择一行数据");
}
$type = $this->request["type"];
$where = [];
$where[] = ["id", "in", $ids];
$list = houseModel::where($where)->select()->toArray();
$where = [];
$where[] = ["pId", "in", $ids];
$otherList = \app\common\model\HousePurchaseEnjoyOther::where($where)->select()->toArray();
$otherMap = [];
foreach ($otherList as $ol) {
$otherMap[$ol["pId"]][] = $ol;
}
//查询企业信息
$enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
$levelMap = DictApi::selectByParentCode("talent_arrange");
$year = $list[0]["year"];
foreach ($list as $key => &$obj) {
$obj["talentArrangeName"] = $levelMap[$obj["talentArrange"]];
$obj["enterpriseName"] = $enterpriseMap[$obj["enterpriseId"]];
$obj["sn"] = $key + 1;
if ($obj["declareType"] == 1) {
$obj["declareTypeName"] = "购房补贴";
$otherHouses = $otherMap[$obj["id"]];
$desc = [];
if ($otherHouses) {
foreach ($otherHouses as $house) {
$desc[] = $house["enjoyPolicyName"];
}
}
$obj["description"] = $desc ? "扣除已享受" . implode(";\n", $desc) . "部分" : "";
} else if ($obj["declareType"] == 2) {
$obj["declareTypeName"] = "免租入住";
$obj["description"] = $year . "年度取得免租入住资格";
}
}unset($obj);
$userTypeName = CommonConst::getTypeName($this->user["type"]);
if ($type == 1) {
//兑现
$title = ["序号", "申报类型", "姓名", "工作单位", "人才层次", $year . "年度拟发放购房补贴金额(元)", "备注"];
$value = ["sn", "declareTypeName", "name", "enterpriseName", "talentArrangeName", "realEnjoyMoney", "description"];
$fileName = sprintf("%s%s年度购房补贴拟发放对象名单", $userTypeName, $year);
} else {
//不予兑现
$title = ["序号", "申报类型", "姓名", "工作单位", "人才层次", "备注"];
$value = ["sn", "declareTypeName", "name", "enterpriseName", "talentArrangeName", "description"];
$fileName = sprintf("%s%s年度购房补贴不予兑现对象名单", $userTypeName, $year);
}
$rows = [];
foreach ($list as $row) {
$newRow = [];
for ($i = 0; $i < count($value); $i++) {
$newRow[] = $row[$value[$i]];
}
$rows[] = $newRow;
}
export($title, $rows, $fileName);
}
/**
* 导出基本信息
*/
public function exportBasicInfo() {
$obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
$obj["enterpriseName"] = \StrUtil::getRequestDecodeParam($this->request, "enterpriseName");
$obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
$obj["idCard"] = \StrUtil::getRequestDecodeParam($this->request, "idCard");
$obj["talentType"] = \StrUtil::getRequestDecodeParam($this->request, "talentType");
$obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
$obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
$obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
$obj["isSupple"] = \StrUtil::getRequestDecodeParam($this->request, "isSupple");
$obj["checkState"] = \StrUtil::getRequestDecodeParam($this->request, "checkState");
$obj["publicState"] = \StrUtil::getRequestDecodeParam($this->request, "publicState");
$obj["companyName"] = \StrUtil::getRequestDecodeParam($this->request, "companyName");
$obj["allowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "allowanceType");
$obj["recommendAllowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "recommendAllowanceType");
$obj["introductionMode"] = \StrUtil::getRequestDecodeParam($this->request, "introductionMode");
$obj["firstJJStartTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJStartTime");
$obj["firstJJEndTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJEndTime");
$obj["process"] = intval(\StrUtil::getRequestDecodeParam($this->request, "process"));
$obj["type"] = $this->user["type"];
$where = [];
$where[] = ["ta.delete", "=", 0];
$where[] = ["ta.type", "=", $this->user["type"]];
$this->setTalentAllowanceInfoForExport($where, $obj, $obj["process"]);
switch ($obj["process"]) {
case 1:
$where[] = ["ta.checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
break;
case 2:
$where[] = ["ta.firstPassTime", "EXP", Db::raw("is not null")];
break;
case 3:
$where[] = ["ta.visitPassTime", "EXP", Db::raw("is not null")];
break;
case 4:
if ($obj["publicState"]) {
$where[] = ["publicState", "=", $obj["publicState"]];
}
$where[] = ["ta.checkState", "in", [-1, 30]];
break;
}
$projects = [
AllowanceProjectEnum::PROJECT_TAX,
AllowanceProjectEnum::PROJECT_WAGES,
AllowanceProjectEnum::PROJECT_ATTENDANCE,
AllowanceProjectEnum::PROJECT_SB_PENSION,
AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
AllowanceProjectEnum::PROJECT_SB_MEDICA,
];
$months = [];
for ($m = 1; $m <= 12; $m++) {
$months[] = $m . "月";
}
$columns = [["年度", [1, 2]], ["所属镇街", [1, 2]], ["姓名", [1, 2]], ["性别", [1, 2]], ["证件号码", [1, 2]], ["人才层次", [1, 2]], ["认定条件", [1, 2]], ["认定条件取得时间", [1, 2]], ["认定条件名称", [1, 2]], ["公布入选月份", [1, 2]], ["拟认定津补贴类型", [1, 2]], ["拟兑现月份", [1, 2]], ["拟兑现金额", [1, 2]], ["拟兑现金额说明", [1, 2]], ["津补贴类型", [1, 2]], ["兑现月份", [1, 2]], ["兑现金额", [1, 2]], ["金额说明", [1, 2]], ["审核状态", [1, 2]], ["缴纳单位", [1, 2]]];
$infoCols = count($columns);
for ($i = 0; $i < count($projects); $i++) {
$columns[] = [AllowanceProjectEnum::getProjectName($projects[$i]), $months];
}
$list = \app\common\model\TalentAllowanceProject::alias("pro")
->field("ta.id,ta.year,ta.enterpriseId as curEnterpriseId,ta.address,ta.name,ta.sex,ta.idCard,ta.talentArrange,ta.identifyCondition,ta.identifyGetTime,ta.identifyConditionName,ta.identifyMonth,ta.recommendAllowanceType,ta.recommendMonths,ta.recommendMoney,ta.recommendMoneyDesc,ta.allowanceType,ta.months,ta.money,ta.moneyDesc,ta.checkState,ta.publicState,pro.project,pro.months as pre_months,con.enterpriseId,con.startTime,con.endTime,con.entryTime,con.quitTime,con.isQuit")
->leftJoin("un_talent_allowance_info ta", "ta.id=pro.mainId")
->leftJoin("un_talent_allowancecontract_detail con", "pro.baseId=con.id")
->where($where)
->order("ta.year desc,ta.createTime desc,pro.project asc")
->select()->toArray();
$tmpList = [];
$levelMap = DictApi::selectByParentCode("talent_arrange");
$streetMap = DictApi::selectByParentCode("street");
$where = [];
$where[] = ["id", "in", array_column($list, "identifyCondition")];
$icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
$where = [];
$where[] = ["id", "in", array_column($list, "enterpriseId")];
$enterpriseMap = \app\common\model\Enterprise::where($where)->column("name", "id");
foreach ($list as $item) {
//组装数据
if (!$tmpList[$item["id"]]) {
$tmpList[$item["id"]]["curEnterpriseId"] = $item["curEnterpriseId"];
$tmpList[$item["id"]]["info"] = [$item["year"], $streetMap[$item["address"]], $item["name"], $item["sex"] == 1 ? "男" : "女", $item["idCard"], $levelMap[$item["talentArrange"]],
$icmap[$item["identifyCondition"]], $item["identifyGetTime"], $item["identifyConditionName"], $item["identifyMonth"], AllowanceTypeEnum::getTypeName($item["recommendAllowanceType"]), $item["recommendMonths"], $item["recommendMoney"],
$item["recommendMoneyDesc"], AllowanceTypeEnum::getTypeName($item["allowanceType"]), $item["months"], $item["money"],
$item["moneyDesc"], $this->getCheckStateName($item["checkState"], $item["publicState"], $item["allowanceType"])];
}
if (!$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]) {
$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]] = [
"startTime" => $item["startTime"],
"endTime" => $item["endTime"],
"entryTime" => $item["entryTime"],
"isQuit" => $item["isQuit"]
];
}
$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]["projects"][$item["project"]] = $item["pre_months"];
}
$rows = [];
$colorset = [];
foreach ($tmpList as $id => $item) {
foreach ($item["enterprise"] as $enterpriseId => $enterprise) {
$row = $item["info"];
$row[] = $this->user["uid"] == $enterpriseId ? "本单位" : $enterpriseMap[$enterpriseId];
for ($i = 0; $i < count($projects); $i++) {
if (strpos($enterprise["projects"][$projects[$i]], "=") === false) {
$months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
for ($m = 1; $m <= 12; $m++) {
$_month = str_pad($m, 2, "0", STR_PAD_LEFT);
if (in_array($_month, $months)) {
$row[] = "✔";
$colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
} else {
$row[] = "";
}
}
} else {
$months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
$_months = [];
foreach ($months as $month) {
$kv = explode("=", $month);
$_months[$kv[0]] = $kv[1];
}
for ($m = 1; $m <= 12; $m++) {
$_month = str_pad($m, 2, "0", STR_PAD_LEFT);
$days = $_months[$_month];
if ($days && $days > 0) {
$row[] = $days . "天";
$colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
} else {
$row[] = "";
}
}
}
}
$rows[] = $row;
}
}
$cols = $infoCols + count($projects) * 12 - 1;
$settings = [
"width" => [["A", 8], ["C", 12], ["D", 6], ["E", 20], ["F", 12], ["G", 70], ["H", 12], ["I", 15], ["J", 12], ["K", 12], ["P", 30]],
"height" => [18],
"freeze" => "D3",
"color" => $colorset
];
for ($i = 0; $i < count($projects) * 12; $i++) {
$settings["width"][] = [getExcelColumnByIndex($infoCols + $i), 6]; //批设置项目的宽度
}
$settings["background-color"][] = [sprintf("%s2:%s2", getExcelColumnByIndex($infoCols), getExcelColumnByIndex($cols)), "E1F1DE"];
export($columns, $rows, "津补贴申报名单", $settings);
}
/**
* 校验是否在审核范围内
*/
public function validateIsCheck() {
$id = $this->request["id"];
$process = $this->request["process"];
$compnayId = $this->request["companyId"];
$old = HouseApi::getInfoById($id);
$checkState = $old["checkState"];
$res = null;
switch ($process) {
case 1:
if ($checkState != HouseStateEnum::NEED_CHECK && $checkState != HouseStateEnum::REJECT_TO_FIRST && $checkState != HouseStateEnum::DEP_REJECT) {
return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
} else {
$log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
if ($log) {
$old["checkState"] = $log["state"];
$old["checkMsg"] = $log["description"];
} else {
$old["checkState"] = null;
$old["checkMsg"] = "";
}
}
break;
case 2:
if ($checkState != HouseStateEnum::NEED_DEP_CHECK && $checkState != HouseStateEnum::REJECT_TO_DEP) {
return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
} else {
$where = [];
$where[] = ["mainId", "=", $id];
$where[] = ["companyId", "=", $compnayId];
$where[] = ["type", "=", ProjectState::HOUSE];
$depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
if ($depcheckstate["state"] != 1 && $depcheckstate["state"] != 4 && $depcheckstate["state"] != 9) {
return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
} else {
$log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $compnayId);
if ($log) {
$old["checkState"] = $log["state"];
$old["checkMsg"] = $log["description"];
} else {
$old["checkState"] = null;
$old["checkMsg"] = "";
}
$res["company"] = getCacheById("Company", $compnayId);
}
}
break;
case 3:
if ($checkState != HouseStateEnum::NEED_REVIEW_CHECK && $checkState != HouseStateEnum::REJECT_TO_REVIEW) {
return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
} else {
$log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
if ($log) {
$old["checkState"] = $log["state"];
$old["checkMsg"] = $log["description"];
} else {
$old["checkState"] = null;
$old["checkMsg"] = "";
}
}
break;
case 4:
if ($checkState != HouseStateEnum::REVIEW_PASS && $checkState != HouseStateEnum::NOTPASS) {
return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
} else if ($old["publicState"] != 3) {
return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
} else {
$log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
if ($log) {
$old["checkState"] = $log["state"];
$old["checkMsg"] = $log["description"];
} else {
$old["checkState"] = null;
$old["checkMsg"] = "";
}
$housepurchase = [];
$result = $this->calculate($old, $housepurchase, $decideDesc, 1);
if ($result->code == 500) {
return $result;
}
$res["housepurchase"] = $housepurchase;
}
break;
}
$where = [];
$where[] = ["type", "=", $old["type"]];
$where[] = ["project", "=", ProjectState::HOUSE];
$where[] = ["active", "=", 1];
$where[] = ["delete", "=", 0];
$filetypeList = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
/* * 查询之前是否享受过 */
$count = HouseApi::getEnjoyTimesByIdCard($old["idCard"]);
$res["number"] = $count;
$res["obj"] = $old;
$res["fileTypeList"] = $filetypeList;
return new Response(Response::SUCCESS, "", $res);
}
/**
* 初始化可修改的项目/附件/合同
* */
public function findFieldsAndFiles() {
$id = $this->request["id"];
if (\StrUtil::isEmpOrNull($id)) {
return new Response(Response::ERROR, "请选择需要修改的对象");
}
$info = HouseApi::getInfoById($id);
if (!$info) {
return new Response(Response::ERROR, "系统错误,请联系管理员");
}
if ($info["checkState"] != HouseStateEnum::FIRST_REJECT) {
return new Response(Response::ERROR, "只能修改初审驳回的数据");
}
$res = [];
$where = [];
$where[] = ["type", "=", $info["type"]];
$where[] = ["project", "=", ProjectState::HOUSE];
$where[] = ["active", "=", 1];
$where[] = ["delete", "=", 0];
$filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
$res["files"] = $filetypes;
$res["obj"] = $info;
return new Response(Response::SUCCESS, "", $res);
}
/**
* 修改驳回项目/附件/合同
* */
public function updateFieldsAndFiles() {
$data = $this->request->param();
if (!$data["id"]) {
return new Response(Response::ERROR, "系统错误,请联系管理员");
}
houseModel::update($data);
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"]];
}
if (\StrUtil::isNotEmpAndNull($query["name"])) {
$where[] = ["name", "like", "%" . $query["name"] . "%"];
}
if (\StrUtil::isNotEmpAndNull($query["idCard"])) {
$where[] = ["idCard", "like", "%" . $query["idCard"] . "%"];
}
if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
$where[] = ["talentArrange", "=", $query["talentArrange"]];
}
if (\StrUtil::isNotEmpAndNull($query["spouseName"])) {
$where[] = ["spouseName", "like", "%" . $query["spouseName"] . "%"];
}
if (\StrUtil::isNotEmpAndNull($query["spouseIdcard"])) {
$where[] = ["spouseIdcard", "like", "%" . $query["spouseIdcard"] . "%"];
}
if (\StrUtil::isNotEmpAndNull($query["childName"])) {
$where[] = ["childName", "like", "%" . $query["childName"] . "%"];
}
if (\StrUtil::isNotEmpAndNull($query["childIdCard"])) {
$where[] = ["childIdCard", "like", "%" . $query["childIdCard"] . "%"];
}
if (\StrUtil::isNotEmpAndNull($query["marryStatus"])) {
$where[] = ["marryStatus", "=", $query["marryStatus"]];
}
if ($query["isConflict"]) {
$where[] = ["isConflict", "=", $query["isConflict"]];
}
if ($query["isRecover"]) {
$where[] = ["isRecover", "=", $query["isRecover"]];
}
if ($query["checkState"]) {
switch ($query["checkState"]) {
case -1:
$where[] = ["checkState", "=", HouseStateEnum::NOTPASS];
break;
case 1:
$where[] = ["checkState", "=", HouseStateEnum::SAVE];
break;
case 2:
switch ($query["process"]) {
case 1:
$where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
$where[] = ["highProcess", "<", $query["process"]];
break;
case 2:
$query["state"] = 1;
break;
case 3:
$where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
$where[] = ["highProcess", "<", $query["process"]];
break;
}
break;
case 3:
switch ($query["process"]) {
case 1:
$where[] = ["checkState", "=", HouseStateEnum::FIRST_REJECT];
break;
case 2:
$query["state"] = 2;
break;
case 3:
$where[] = ["checkState", "<=", HouseStateEnum::REJECT_TO_DEP];
break;
}
break;
case 4:
switch ($query["process"]) {
case 1:
$where[] = ["checkState", "in", [HouseStateEnum::NEED_DEP_CHECK, HouseStateEnum::REJECT_TO_DEP, HouseStateEnum::NEED_REVIEW_CHECK, HouseStateEnum::REVIEW_PASS]];
break;
case 2:
$query["state"] = 3;
break;
case 3:
case 4:
$where[] = ["checkState", "=", HouseStateEnum::REVIEW_PASS];
break;
}
break;
case 5:
switch ($query["process"]) {
case 1:
$where[] = ["checkState", "in", [HouseStateEnum::REJECT_TO_FIRST, HouseStateEnum::DEP_REJECT]];
break;
case 2:
$query["state"] = 4;
break;
case 3:
$where[] = ["checkState", "=", HouseStateEnum::REJECT_TO_REVIEW];
break;
}
break;
case 6:
switch ($query["process"]) {
case 1:
$where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
$where[] = ["highProcess", ">=", $query["process"]];
break;
case 2:
$query["state"] = 9;
break;
case 3:
$where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
$where[] = ["highProcess", ">=", $query["process"]];
break;
}
break;
}
}
}
private function translateToChinese(&$obj) {
if (\StrUtil::isNotEmpAndNull($obj["address"])) {
$obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
}
if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
$obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
}
if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
$obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
}
if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
$obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
}
if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
$obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
}
}
private function translateChinese($list, $process) {
//获取字典表
$marryMap = DictApi::selectByParentCode("marry_status");
$cardTypeMap = DictApi::selectByParentCode("card_type");
$streetMap = DictApi::selectByParentCode("street");
$levelMap = DictApi::selectByParentCode("talent_arrange");
$talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
$enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
$where = [];
$where[] = ["type", "=", $this->user["type"]];
$conditionMap = \app\common\model\TalentCondition::where($where)->column("name", "id");
$where = [];
$where[] = ["pId", "in", array_column($list, "id")];
$childrens = \app\common\model\HousePurchaseChildren::where($where)->select()->toArray();
$childMap = [];
foreach ($childrens as $child) {
$childMap[$child["pId"]][] = $child;
}
foreach ($list as &$info) {
$info["marryStatusName"] = $marryMap[$info["marryStatus"]];
$info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
$info["spouseCardTypeName"] = $cardTypeMap[$info["spouseCardType"]];
$info["childCardTypeName"] = $cardTypeMap[$info["childCardType"]];
$info["streetName"] = $streetMap[$info["street"]];
$info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
$info["identifyConditionCH"] = $conditionMap[$info["identifyCondition"]];
$info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
$info["declareTypeName"] = $info["declareType"] == 1 ? "购房补贴" : "免租入住";
$info["enterpriseName"] = $enterpriseMap[$info["enterpriseId"]];
$info["isEnjoyOtherName"] = $info["isEnjoyOther"] == 1 ? "是" : "否";
$info["spouseIsLibraryName"] = $info["spouseIsLibrary"] == 1 ? "是" : "否";
$childs = $childMap[$info["id"]];
$childStr = "";
if ($childs) {
for ($i = 0; $i < count($childs); $i++) {
$childStr .= $childs[$i]["name"] . "-" . $childs[$i]["idCard"] . ";";
}
}
$info["childs"] = $childStr;
switch ($process) {
case 1:
if ($info["checkState"] == HouseStateEnum::NOTPASS) {
$info["checkStateName"] = "审核不通过";
}
if ($info["checkState"] == HouseStateEnum::SAVE) {
$info["checkStateName"] = "待提交";
}
if ($info["checkState"] == HouseStateEnum::NEED_CHECK) {
$info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
}
if ($info["checkState"] == HouseStateEnum::FIRST_REJECT) {
$info["checkStateName"] = "已驳回";
}
if ($info["checkState"] == HouseStateEnum::REJECT_TO_FIRST || $info["checkState"] == HouseStateEnum::DEP_REJECT) {
$info["checkStateName"] = "上级驳回";
}
if ($info["checkState"] == HouseStateEnum::NEED_DEP_CHECK || $info["checkState"] >= HouseStateEnum::REJECT_TO_DEP) {
$info["checkStateName"] = "已通过";
}
break;
case 2:
if ($info["state"] == 1) {
$info["checkStateName"] = "待审核";
}
if ($info["state"] == 2) {
$info["checkStateName"] = "已驳回";
}
if ($info["state"] == 3) {
$info["checkStateName"] = "已通过";
}
if ($info["state"] == 4) {
$info["checkStateName"] = "上级驳回";
}
if ($info["state"] == 9) {
$info["checkStateName"] = "重新提交";
}
break;
case 3:
if ($info["checkState"] <= HouseStateEnum::REJECT_TO_DEP) {
$info["checkStateName"] = "已驳回";
} else if ($info["checkState"] == HouseStateEnum::NEED_REVIEW_CHECK) {
$info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
} else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
$info["checkStateName"] = "已通过";
}
break;
case 4:
if ($info["checkState"] == HouseStateEnum::NOTPASS) {
$info["checkStateName"] = "审核不通过";
} else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
$info["checkStateName"] = "已通过";
}
break;
}
}unset($info);
return $list;
}
private function getCheckStateName($checkState, $publicState, $allowanceType) {
switch ($checkState) {
case 1:
return "待提交";
case 5:
case 13:
case 15:
case 20:
case 25:
case 35:
return "审核中";
case 10:
return "已驳回";
case - 1:
if ($publicState >= 3) {
return "审核不通过";
} else {
return "审核中";
}
break;
case 30:
if ($publicState == 1) {
return "待核查征信";
} else if ($publicState == 2) {
return "待公示";
} else if ($publicState == 3) {
return "公示中";
} else if ($publicState == 4) {
return $allowanceType != 3 ? "待兑现" : "不予兑现";
} else if ($publicState == 5) {
return "已兑现";
}
default:
return "未知状态";
}
}
/**
* @param $old 原来的记录
* @param $housepurchase 新的记录
* @param $descideDesc 记录文本
* @param $type 1-复核阶段,不生成享受人的剩余享受金额记录,2-公示再审核阶段,生成享受记录
* @description 计算购房补贴金额
* */
private function calculate($old, &$housepurchase = [], &$descideDesc = [], $type = 1) {
/* * 1、查询申报人和配偶的房产信息 */
$houseInfo = HouseApi::getHouseInfo($old["idCard"]);
$spouseHouseInfo = HouseApi::getHouseInfo($old["spouseIdCard"]);
if (!$houseInfo) {
$houseInfo = [
"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
];
}
//判断是否超过五次申报
if ($houseInfo["balanceMoney"] <= 0) {
return new Response(Response::ERROR, "申报房产可享受余额不足,无法享受");
}
/* * 2.查询购房补贴费用标准,根据人才层次计算可享受金额 */
$amountStandard = \app\common\api\AmountStandardApi::getStandard($this->user["type"], 3, $old["talentArrange"]);
if (!$amountStandard)
return new Response(Response::ERROR, "系统暂未设置该人才层次的购房补贴享受金额,请设置后再提交");
$code = "housepurchase_percentage_";
switch ($old["type"]) {
case CommonConst::ENTERPRISE_NORMAL:
$code .= "normal";
break;
case CommonConst::ENTERPRISE_JC:
$code .= "ic";
break;
case CommonConst::ENTERPRISE_WJ:
$code .= "wj";
break;
case CommonConst::ENTERPRISE_GJ:
$code .= "gj";
break;
}
$dicts = DictApi::findChildDictByCode($code);
if (!$dicts)
return new Response(Response::ERROR, "系统字典中暂未设置购房补贴年度比例,请设置后再提交。");
$dicts = bubbleSort($dicts, "code");
$count = count($dicts);
if ($houseInfo["count"] >= $count) {
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之间的数字");
$housepurchase["talentArrangeMoney"] = round($dic["name"] * $amountStandard["money"], 2);
/* * 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);
/* * 计算当前人才层次可享受金额 */
$balanceMoney = round($amountStandard["money"] - ($houseInfo["houseMoney"] - $houseInfo["balanceMoney"]), 2);
/* * 判断余额 */
$balanceMoney = $balanceMoney >= $houseInfo["balanceMoney"] ? $houseInfo["balanceMoney"] : $balanceMoney;
if ($balanceMoney <= 0) {
$descideDesc[] = "可享受余额为:" . $balanceMoney . "元;";
/* * 判断享受其他政策是否大于0 */
if ($totalOtherMoney > 0) {
$housepurchase["isRecover"] = 1;
$descideDesc[] = "需要追讨金额为:" . $totalOtherMoney . "元;";
}
$housepurchase["shouldEnjoyMoney"] = 0;
$housepurchase["realEnjoyMoney"] = 0;
$housepurchase["nowSubOtherMoney"] = 0;
$housepurchase["nowNotSubOtherMoney"] = $totalOtherMoney;
} else {
/* * 比较余额和人才层次金额 */
$housepurchase["shouldEnjoyMoney"] = $balanceMoney >= $housepurchase["talentArrangeMoney"] ? $housepurchase["talentArrangeMoney"] : $balanceMoney;
/* * 计算可享受金额 */
$realEnjoyMoney = $housepurchase["shouldEnjoyMoney"] - $totalOtherMoney;
if ($realEnjoyMoney == 0) {
$housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
$housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
$housepurchase["nowNotSubOtherMoney"] = $realEnjoyMoney;
/* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
} else if ($realEnjoyMoney > 0) {
$housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
$housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
$housepurchase["nowNotSubOtherMoney"] = 0;
/* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
} 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["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["id"] = getStringId();
$spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
$spouseHouseInfo["createUser"] = $this->user["uid"];
houseInfoModel::insert($spouseHouseInfo);
}
}
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["decideDetail"] = $old["decideDetail"] . ($descideDesc ? implode("", $descideDesc) : "");
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;
}
}