House.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <?php
  2. namespace app\enterprise\controller;
  3. use app\enterprise\common\EnterpriseController;
  4. use think\facade\Db;
  5. use think\facade\Log;
  6. use app\common\api\EnterpriseApi;
  7. use app\common\api\TalentLogApi;
  8. use think\exception\ValidateException;
  9. use app\common\state\ProjectState;
  10. use app\common\api\BatchApi;
  11. use app\common\api\HouseApi;
  12. use app\common\model\TalentLog;
  13. use app\common\api\DictApi;
  14. use app\common\state\CommonConst;
  15. use app\common\state\MainState;
  16. use app\common\state\HouseStateEnum;
  17. use app\common\api\Response;
  18. use app\common\model\HousePurchase as houseModel;
  19. /**
  20. * Description of House
  21. * 购房补贴
  22. * @author sgq
  23. */
  24. class House extends EnterpriseController {
  25. public function index() {
  26. return view("", ['type' => session("user")['type']]);
  27. }
  28. public function list() {
  29. $params = $this->request;
  30. $order = trim($params["order"]) ?: "desc";
  31. $offset = trim($params["offset"]) ?: 0;
  32. $limit = trim($params["limit"]) ?: 10;
  33. $where = [];
  34. $where[] = ["type", "=", $this->user["type"]];
  35. $where[] = ["enterpriseId", "=", $this->user["uid"]];
  36. $where[] = ["delete", "=", 0];
  37. if ($params["year"]) {
  38. $where[] = ["year", "=", $params["year"]];
  39. }
  40. if (\StrUtil::isNotEmpAndNull($params["name"])) {
  41. $where[] = ["name", "like", "%" . $params["name"] . "%"];
  42. }
  43. if (\StrUtil::isNotEmpAndNull($params["idCard"])) {
  44. $where[] = ["idCard", "like", "%" . $params["idCard"] . "%"];
  45. }
  46. if ($params["talentArrange"]) {
  47. $where[] = ["talentArrange", "=", $params["talentArrange"]];
  48. }
  49. if (\StrUtil::isNotEmpAndNull($params["spouseName"])) {
  50. $where[] = ["spouseName", "like", "%" . $params["spouseName"] . "%"];
  51. }
  52. if (\StrUtil::isNotEmpAndNull($params["spouseIdcard"])) {
  53. $where[] = ["spouseIdcard", "like", "%" . $params["spouseIdcard"] . "%"];
  54. }
  55. if (\StrUtil::isNotEmpAndNull($params["childName"])) {
  56. $where[] = ["childName", "like", "%" . $params["childName"] . "%"];
  57. }
  58. if (\StrUtil::isNotEmpAndNull($params["childIdCard"])) {
  59. $where[] = ["childIdCard", "like", "%" . $params["childIdCard"] . "%"];
  60. }
  61. if ($params["marryStatus"]) {
  62. $where[] = ["marryStatus", "=", $params["marryStatus"]];
  63. }
  64. $count = houseModel::where($where)->count();
  65. $list = houseModel::where($where)->limit($offset, $limit)->order("createTime $order")->select()->toArray();
  66. //获取字典表婚姻状态
  67. $marryMap = DictApi::selectByParentCode("marry_status");
  68. $cardTypeMap = DictApi::selectByParentCode("card_type");
  69. $streetMap = DictApi::selectByParentCode("street");
  70. $levelMap = DictApi::selectByParentCode("talent_arrange");
  71. $whrCondition = [];
  72. $whrCondition[] = ["type", "=", $this->user["type"]];
  73. $conditionMap = \app\common\model\TalentCondition::where($whrCondition)->column("name", "id");
  74. foreach ($list as &$item) {
  75. $item["marryStatusName"] = $marryMap[$item["marryStatus"]];
  76. $item["cardTypeName"] = $cardTypeMap[$item["cardType"]];
  77. $item["spouseCardTypeName"] = $cardTypeMap[$item["spouseCardType"]];
  78. $item["childCardTypeName"] = $cardTypeMap[$item["childCardType"]];
  79. $item["streetName"] = $streetMap[$item["street"]];
  80. $item["talentArrangeName"] = $levelMap[$item["talentArrange"]];
  81. $item["identifyConditionCH"] = $conditionMap[$item["identifyCondition"]];
  82. }unset($item);
  83. return json(["rows" => $list, "total" => $count]);
  84. }
  85. /**
  86. * 申请
  87. */
  88. public function apply(\think\Request $request) {
  89. $param = $request->param();
  90. $id = isset($param["id"]) ? $param["id"] : 0;
  91. $vars = [];
  92. if ($id) {
  93. $info = HouseApi::getInfoById($id);
  94. $childrenList = HouseApi::getChildren($id);
  95. $houseInfo = HouseApi::getHouseInfo($info["idCard"]);
  96. $dicts = DictApi::findChildDictByCode("card_type");
  97. $vars["dicts"] = $dicts;
  98. $vars["row"] = $info;
  99. $vars["hand"] = $houseInfo ? 2 : 1;
  100. $vars["childrenList"] = $childrenList;
  101. }
  102. if ($request->isPost()) {
  103. return $this->save($info, $request);
  104. }
  105. $batch = $info["year"] ?: BatchApi::getValidBatch(ProjectState::HOUSE, $this->user["type"])["batch"];
  106. $vars["year"] = $batch;
  107. $vars["type"] = $this->user["type"];
  108. return view("", $vars);
  109. }
  110. public function detail(\think\Request $request) {
  111. $id = $this->request["id"];
  112. $info = HouseApi::getInfoById($id);
  113. $childrenList = HouseApi::getChildren($id);
  114. $dicts = DictApi::findChildDictByCode("card_type");
  115. $vars["dicts"] = $dicts;
  116. $vars["row"] = $info;
  117. $vars["childrenList"] = $childrenList;
  118. $vars["type"] = $this->user["type"];
  119. return view("", $vars);
  120. }
  121. /**
  122. * 提交表单
  123. */
  124. public function submitToCheck() {
  125. try {
  126. $id = $this->request["id"];
  127. if (\StrUtil::isEmpOrNull($id)) {
  128. throw new ValidateException("系统错误,提交审核失败");
  129. }
  130. $info = HouseApi::getInfoById($id);
  131. if (!$info) {
  132. throw new ValidateException("提交审核失败,请先填写基础信息");
  133. }
  134. if ($info["enterpriseId"] != $this->user["uid"]) {
  135. throw new ValidateException("没有对应的人才认定申报信息");
  136. }
  137. $batch = BatchApi::checkBatchValid(["type" => ProjectState::HOUSE, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
  138. if ($batch["code"] != 200) {
  139. throw new ValidateException($batch["msg"]);
  140. }
  141. $response = $this->validateIsEdit($info["checkState"]);
  142. if ($response->code != 200) {
  143. throw new ValidateException($response->msg);
  144. }
  145. validate(\app\enterprise\validate\HouseValidator::class)->check($info);
  146. $response = $this->other_validate($info, 2);
  147. if ($response->code != 200) {
  148. throw new ValidateException($response->msg);
  149. }
  150. $where = [];
  151. $where[] = ["mainId", "=", $id];
  152. $where[] = ["type", "=", ProjectState::HOUSE];
  153. $uploadedFileTypes = Db::table("new_talent_file")->where($where)->column("distinct typeId");
  154. $where = [];
  155. $where[] = ["project", "=", ProjectState::HOUSE];
  156. $where[] = ["type", "=", $this->user["type"]];
  157. $where[] = ["must", "=", 1];
  158. $where[] = ["active", "=", 1];
  159. $where[] = ["delete", "=", 0];
  160. $where[] = ["id", "not in", $uploadedFileTypes];
  161. $unUploadfiletypes = Db::table("new_common_filetype")->where($where)->select()->toArray();
  162. if ($unUploadfiletypes) {
  163. $msg = "以下附件为必传:<br>";
  164. foreach ($unUploadfiletypes as $ft) {
  165. $msg .= "<span style='color:red;'>*</span>" . $ft["name"] . "<br>";
  166. }
  167. throw new ValidateException($msg);
  168. }
  169. $data["id"] = $id;
  170. if (!$info["firstSubmitTime"]) {
  171. $data["firstSubmitTime"] = date("Y-m-d H:i:s");
  172. }
  173. $data["newSubmitTime"] = date("Y-m-d H:i:s");
  174. $data["checkMsg"] = "";
  175. $data["files"] = "";
  176. $data["fields"] = "";
  177. $data["toDep"] = "";
  178. $data["toProcess"] = null;
  179. $data["checkState"] = HouseStateEnum::NEED_CHECK;
  180. $res = houseModel::update($data);
  181. if ($res) {
  182. $user = session("user");
  183. $log["id"] = getStringId();
  184. $log["active"] = 1;
  185. $log["state"] = 1;
  186. $log["step"] = 0;
  187. $log["stateChange"] = HouseStateEnum::getStateName($info["checkState"]) . "->" . HouseStateEnum::getStateName($data["checkState"]);
  188. $log["type"] = ProjectState::HOUSE;
  189. $log["mainId"] = $id;
  190. $log["description"] = "确认提交审核";
  191. $log["createUser"] = "申报用户";
  192. $log["createTime"] = date("Y-m-d H:i:s");
  193. TalentLog::create($log);
  194. return json(new Response(Response::SUCCESS, "提交审核成功"));
  195. }
  196. throw new ValidateException("提交审核失败");
  197. } catch (ValidateException $e) {
  198. return json(new Response(Response::ERROR, $e->getMessage()));
  199. } catch (\think\Exception $e) {
  200. $logInfo = [
  201. "enterprise_id" => $this->user["uid"],
  202. "data" => $data,
  203. "controller" => $this->request->controller(),
  204. "action" => $this->request->action(),
  205. "errCode" => $e->getCode(),
  206. "errMsg" => $e->getMessage()
  207. ];
  208. Log::write($logInfo, "error");
  209. return json(new Response(Response::ERROR, "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()));
  210. }
  211. }
  212. public function save($info, \think\Request $request) {
  213. Db::startTrans();
  214. try {
  215. $batch = BatchApi::checkBatchValid(["type" => ProjectState::HOUSE, "year" => $info["year"], "first_submit_time" => $info["firstSubmitTime"]], $this->user["type"]);
  216. if ($batch["code"] != 200) {
  217. throw new ValidateException($batch["msg"]);
  218. }
  219. if ($info) {
  220. $response = $this->validateIsEdit($info["checkState"]);
  221. if ($response->code != 200) {
  222. throw new ValidateException($response->msg);
  223. }
  224. }
  225. $data = $request->param();
  226. $data["year"] = $batch["batch"];
  227. $data["type"] = $this->user["type"];
  228. validate(\app\enterprise\validate\HouseValidator::class)->check($data);
  229. $response = $this->other_validate($data, $info ? 2 : 1);
  230. if ($response->code != 200) {
  231. throw new ValidateException($response->msg);
  232. }
  233. $id = $data["id"];
  234. if ($id) {
  235. if (!$info || $info["id"] != $id || $info["enterpriseId"] != $this->user["uid"]) {
  236. throw new ValidateException("没有对应的人才认定申报信息");
  237. }
  238. $data["checkState"] = $info["checkState"];
  239. $data["updateUser"] = $this->user["uid"];
  240. $data["updateTime"] = date("Y-m-d H:i:s");
  241. } else {
  242. $data["id"] = getStringId();
  243. $data["checkState"] = HouseStateEnum::SAVE;
  244. $data["createUser"] = $this->user["uid"];
  245. $data["createTime"] = date("Y-m-d H:i:s");
  246. $data["enterpriseId"] = $this->user["uid"];
  247. $data["isConflict"] = 2;
  248. $data["isRecover"] = 2;
  249. $houseInfo = HouseApi::getHouseInfo($data["idCard"]);
  250. $data["number"] = !$houseInfo ? 1 : $houseInfo["count"] + 1;
  251. }
  252. $childList = $data["childList"];
  253. unset($data["jstime"]);
  254. unset($data["childList"]);
  255. if ($id) {
  256. $res = Db::table("un_housepurchase")->update($data);
  257. } else {
  258. $res = Db::table("un_housepurchase")->insert($data);
  259. }
  260. foreach ($childList as &$children) {
  261. $children["pId"] = $data["id"];
  262. if (\StrUtil::isEmpOrNull($children["id"])) {
  263. $children["id"] = getStringId();
  264. $children["createTime"] = date("Y-m-d H:i:s");
  265. Db::table("un_housepurchase_children")->insert($children);
  266. } else {
  267. $children["updateTime"] = date("Y-m-d H:i:s");
  268. $res = Db::table("un_housepurchase_children")->update($children);
  269. }
  270. }unset($children);
  271. //添加日志
  272. Db::table("new_talent_checklog")->insert([
  273. 'id' => getStringId(),
  274. 'mainId' => $data['id'],
  275. 'type' => intval(ProjectState::HOUSE),
  276. 'typeFileId' => null,
  277. 'active' => 1,
  278. 'state' => 1,
  279. 'step' => 0,
  280. 'stateChange' => "保存未提交",
  281. 'description' => "添加购房补贴申报",
  282. 'createTime' => date("Y-m-d H:i:s", time()),
  283. 'createUser' => "申报用户"
  284. ]);
  285. $data["childList"] = $childList;
  286. Db::commit();
  287. return json(new Response(Response::SUCCESS, "添加成功", $data));
  288. } catch (ValidateException $e) {
  289. Db::rollback();
  290. return json(new Response(Response::ERROR, $e->getMessage()));
  291. } catch (\think\Exception $e) {
  292. Db::rollback();
  293. $logInfo = [
  294. "enterprise_id" => $this->user["uid"],
  295. "data" => $data,
  296. "controller" => $this->request->controller(),
  297. "action" => $this->request->action(),
  298. "errCode" => $e->getCode(),
  299. "errMsg" => $e->getMessage()
  300. ];
  301. Log::write($logInfo, "error");
  302. return json(new Response(Response::ERROR, "发生预料外错误,请联系管理员处理,错误代码:" . $e->getCode()));
  303. }
  304. }
  305. public function deleteChildren($id) {
  306. if (\StrUtil::isEmpOrNull($id)) {
  307. return new Response(Response::ERROR, "删除失败,系统错误");
  308. }
  309. $obj = HouseApi::getChildrenById($id);
  310. $housePurchase = HouseApi::getInfoById($obj["pId"]);
  311. if ($housePurchase["checkState"] != 1 && $housePurchase["checkState"] != 10) {
  312. return new Response(Response::ERROR, "正在审核中,无法删除");
  313. }
  314. if (HouseApi::deleteChildrenById($id)) {
  315. return new Response(Response::SUCCESS, "删除成功");
  316. }
  317. return new Response(Response::ERROR, "删除失败");
  318. }
  319. public function delete($id) {
  320. if (\StrUtil::isEmpOrNull($id)) {
  321. return new Response(Response::ERROR, "删除失败,系统错误");
  322. }
  323. $obj = HouseApi::getInfoById($id);
  324. if ($obj["checkState"] != 1) {
  325. return new Response(Response::ERROR, "已提交审核,无法删除");
  326. }
  327. if (HouseApi::deleteById($id)) {
  328. return new Response(Response::SUCCESS, "删除成功");
  329. }
  330. return new Response(Response::ERROR, "删除失败");
  331. }
  332. public function getTalentInfo($id, $year, $declareType) {
  333. $ti = \app\common\api\VerifyApi::getTalentInfoById($id);
  334. $response = $this->getTalentArrange($ti, $year);
  335. if ($response->code == 500) {
  336. return $response;
  337. }
  338. $resTalentInfo = $response->obj;
  339. $ti["talentArrange"] = $resTalentInfo["talentArrange"];
  340. $ti["identifyCondition"] = $resTalentInfo["identifyCondition"];
  341. $ti["identifyConditionName"] = $resTalentInfo["identifyConditionName"];
  342. $ti["identifyMonth"] = $resTalentInfo["identifyMonth"];
  343. $ti["identifyGetTime"] = $resTalentInfo["identifyGetTime"];
  344. $ti["certificateStartTime"] = $resTalentInfo["certificateStartTime"];
  345. $ti["certificateOutTime"] = $resTalentInfo["certificateOutTime"];
  346. //查询房产库中是否存在房产信息
  347. $houseInfo = HouseApi::getHouseInfo($ti["card_number"]);
  348. return new Response(Response::SUCCESS, "", ["talentInfo" => $ti, "houseInfo" => $houseInfo]);
  349. }
  350. private function other_validate(&$info, $type) {
  351. //校验配偶是否在库
  352. if ($info["spouseIsLibrary"] && $info["spouseIsLibrary"] == 1) {
  353. if (\StrUtil::isEmpOrNull($info["spouseIdcard"])) {
  354. return new Response(Response::ERROR, "请填写配偶证件号码");
  355. }
  356. if (\StrUtil::isEmpOrNull($info["spouseName"])) {
  357. return new Response(Response::ERROR, "请填写配偶姓名");
  358. }
  359. $where = [];
  360. $where[] = ["card_number", "=", $info["spouseIdcard"]];
  361. $where[] = ["name", "=", $info["spouseName"]];
  362. $where[] = ["checkState", "=", \app\common\api\TalentState::CERTIFICATED];
  363. $where[] = ["isEffect", "<>", 4];
  364. $where[] = ["delete", "=", 0];
  365. $count = Db::table("new_talent_info")->where($where)->count();
  366. if ($count == 0) {
  367. return new Response(Response::ERROR, "人才库中未查询到配偶相关信息");
  368. }
  369. }
  370. $ti = \app\common\api\VerifyApi::getTalentInfoById($info["talentId"]);
  371. $info["provinceCode"] = $ti["province"];
  372. $info["provinceName"] = $ti["provinceName"];
  373. $info["cityCode"] = $ti["city"];
  374. $info["cityName"] = $ti["cityName"];
  375. $info["countyCode"] = $ti["county"];
  376. $info["countyName"] = $ti["countyName"];
  377. $info["street"] = $ti["street"];
  378. $info["bank"] = $ti["bank"];
  379. $info["bankAccount"] = $ti["bank_account"];
  380. $info["bankNetwork"] = $ti["bank_branch_name"];
  381. $info["bankNumber"] = $ti["bank_number"];
  382. /* * 校验上一年度人才层次 */
  383. if ($type == 1) {
  384. $responseObj = $this->getTalentArrange($ti, $info["year"]);
  385. if ($responseObj->code == 500) {
  386. return $responseObj;
  387. }
  388. $resInfo = $responseObj->obj;
  389. $info["talentArrange"] = $resInfo["talentArrange"];
  390. $info["identifyCondition"] = $resInfo["identifyCondition"];
  391. $info["idenfityConditionName"] = $resInfo["identifyConditionName"];
  392. $info["identifyGetTime"] = $resInfo["identifyGetTime"];
  393. //设置上一年度人才层次有效月份
  394. $info["monthCount"] = count($resInfo["monthList"]);
  395. if (in_array($info["type"], [CommonConst::ENTERPRISE_NORMAL, CommonConst::ENTERPRISE_JC]) && $info["monthCount"] < 6) {
  396. return new Response(Response::ERROR, "申报年度人才证书有效期未满足六个月,无法申报购房补贴");
  397. }
  398. if (in_array($info["type"], [CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]) && $info["monthCount"] < 9) {
  399. return new Response(Response::ERROR, "申报年度人才证书有效期未满足九个月,无法申报购房补贴");
  400. }
  401. $info["talentArrangeMonths"] = implode(",", $resInfo["monthList"]);
  402. }
  403. return new Response(Response::SUCCESS, "");
  404. }
  405. private function validateIsEdit($checkState) {
  406. if ($checkState != HouseStateEnum::SAVE && $checkState != HouseStateEnum::FIRST_REJECT) {
  407. return new Response(Response::ERROR, "正在审核中,无法修改");
  408. }
  409. return new Response(Response::SUCCESS, "");
  410. }
  411. /**
  412. * @param talentInfo
  413. * @param year
  414. * @description 获取上一年度的人才层次,规则如下:上一年度存在多个人才层次则取占比大的人才层次,占比相同则取人才层次高者
  415. * @returns com.stylefeng.guns.core.common.model.ResponseObj
  416. * @author Liu
  417. * @date 2020/5/6
  418. * */
  419. private function getTalentArrange($talentInfo, $year) {
  420. /**
  421. * 判定在申报年度内或之前是否认定,申报年度之后认定无效,根据公布入选月份判断(此处还要考虑人才层次变更)
  422. */
  423. $year = substr($year, 0, 4);
  424. $identifyTimeField = "identifyMonth";
  425. $oldStartTimeField = "oldIdentifyMonth";
  426. $newStartTimeField = "newIdentifyMonth";
  427. if ($talentInfo["enterpriseType"] == CommonConst::ENTERPRISE_JC) {
  428. $identifyTimeField = "identifyGetTime";
  429. $oldStartTimeField = "oldIdentifyGetTime";
  430. $newStartTimeField = "newIdentifyGetTime";
  431. }
  432. $where = [];
  433. $where[] = ["idCard", "=", $talentInfo["card_number"]];
  434. $where[] = ["checkState", "=", MainState::PASS];
  435. $where[] = ["isPublic", "=", 6];
  436. $where[] = [$oldStartTimeField, "<=", $year . "-12-31"];
  437. $typeChanges = \app\enterprise\model\TalentTypeChange::where($where)->field("oldTalentArrange,oldIdentifyCondition,oldIdentifyGetTime,oldIdentifyOutTime,oldIdentifyConditionName,oldIdentifyMonth,oldCertificateStartTime,oldCertificateOutTime,newIdentifyMonth,newIdentifyGetTime")->order("createTime desc")->select()->toArray();
  438. if (!$typeChanges && strtotime($year . "-12-31") > strtotime($talentInfo[$identifyTimeField])) {
  439. return new Response(Response::ERROR, "在上一年度未认定优秀人才,无法申报");
  440. } else {
  441. $typeChanges[] = [
  442. "oldTalentArrange" => $talentInfo["talent_arrange"],
  443. "oldIdentifyCondition" => $talentInfo["talent_condition"],
  444. "oldIdentifyGetTime" => $talentInfo["identifyGetTime"],
  445. "oldIdentifyOutTime" => $talentInfo["identifyExpireTime"],
  446. "oldIdentifyConditionName" => $talentInfo["identifyConditionName"],
  447. "oldIdentifyMonth" => $talentInfo["identifyMonth"],
  448. "oldCertificateStartTime" => $talentInfo["certificateGetTime"],
  449. "oldCertificateOutTime" => $talentInfo["certificateExpireTime"] ?: date("Y-m-d", strtotime(sprintf("%s +6 years -1 days", $talentInfo["certificateGetTime"]))),
  450. "newIdentifyMonth" => ($year + 1) . "-01-01",
  451. "newIdentifyGetTime" => ($year + 1) . "-01-01"
  452. ];
  453. $totalMonth = \DateUtil::getMonthBetweenDates($year . "-01-01", $year . "-12-31");
  454. usort($typeChanges, function($a, $b) {
  455. return (int) $b["oldTalentArrange"] - (int) $a["oldTalentArrange"];
  456. });
  457. $months = []; //当年度可用月份
  458. $talentArrange = 8; //当年度最高层次
  459. $resTalentInfo = [];
  460. foreach ($typeChanges as $typeChange) {
  461. $startTime = $typeChange[$oldStartTimeField];
  462. $endTime = $typeChange[$newStartTimeField];
  463. $monthList = \DateUtil::getMonthBetweenDatesNotEnd($startTime, $endTime);
  464. $res = \DateUtil::getEveryMonthDayBetween($endTime, $endTime, $monthList);
  465. $intersectMonthList = array_intersect($totalMonth, $monthList);
  466. if (count($intersectMonthList) > 0) {
  467. if ($typeChange["oldTalentArrange"] < $talentArrange) {
  468. //按当年度最高
  469. $talentArrange = $typeChange["oldTalentArrange"];
  470. $resTalentInfo = [
  471. "talentArrange" => $typeChange["oldTalentArrange"],
  472. "identifyCondition" => $typeChange["oldIdentifyCondition"],
  473. "identifyGetTime" => $typeChange["oldIdentifyGetTime"],
  474. "identifyConditionName" => $typeChange["oldIdentifyConditionName"],
  475. "certificateStartTime" => $typeChange["oldCertificateStartTime"],
  476. "certificateOutTime" => $typeChange["oldCertificateOutTime"],
  477. "identifyMonth" => $typeChange["oldIdentifyMonth"],
  478. "dayMap" => $res
  479. ];
  480. }
  481. $months = array_unique(array_merge($months, $intersectMonthList));
  482. }
  483. }
  484. $resTalentInfo["monthList"] = $months;
  485. if (in_array($talentInfo["enterpriseType"], [CommonConst::ENTERPRISE_JC, CommonConst::ENTERPRISE_NORMAL]) && count($months) < 6) {
  486. return new Response(Response::ERROR, "申报年度人才证书有效期未满足六个月,无法申报购房补贴");
  487. }
  488. if (in_array($talentInfo["enterpriseType"], [CommonConst::ENTERPRISE_WJ, CommonConst::ENTERPRISE_GJ]) && count($months) < 9) {
  489. return new Response(Response::ERROR, "申报年度人才证书有效期未满足九个月,无法申报购房补贴");
  490. }
  491. return new Response(Response::SUCCESS, "", $resTalentInfo);
  492. }
  493. }
  494. }