House.php 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. use app\common\api\Response;
  6. use app\common\api\DictApi;
  7. use app\common\api\TalentLogApi;
  8. use app\common\model\TalentChecklog;
  9. use app\common\state\ProjectState;
  10. use app\common\state\CommonConst;
  11. use app\common\state\HouseStateEnum;
  12. use app\common\model\HousePurchase as houseModel;
  13. use app\common\api\HouseApi;
  14. use app\common\model\HousePurchaseHouseInfo as houseInfoModel;
  15. /**
  16. * Description of House
  17. *
  18. * @author sgq
  19. */
  20. class House extends AdminController {
  21. public function index() {
  22. $process = $this->request["process"];
  23. $type = $this->user["type"];
  24. $assigns = ["process" => $process, "type" => $type];
  25. if ($process == 4) {
  26. if ($type == CommonConst::ENTERPRISE_NORMAL) {
  27. $msgBody["typeName"] = "晋江市现代产业体系人才津补贴申报";
  28. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  29. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  30. $msgBody["phone"] = "0595-85633128";
  31. $msgBody["email"] = "jjrc85661234@163.com";
  32. }
  33. if ($type == CommonConst::ENTERPRISE_JC) {
  34. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  35. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  36. $msgBody["dep"] = "集成电路产业园区";
  37. $msgBody["phone"] = "0595-82250007、0595-82250001";
  38. $msgBody["email"] = "jjjcdr@163.com";
  39. }
  40. if ($type == CommonConst::ENTERPRISE_WJ) {
  41. $msgBody["typeName"] = "晋江市医疗卫生人才津补贴申报";
  42. $msgBody["address"] = "“健康晋江”微信公众号";
  43. $msgBody["dep"] = "晋江市卫生健康局";
  44. $msgBody["phone"] = "0595-85636159";
  45. $msgBody["email"] = "jjswjjrsk@163.com";
  46. }
  47. if ($type == CommonConst::ENTERPRISE_GJ) {
  48. $msgBody["typeName"] = "晋江市高等教育人才津补贴申报";
  49. $msgBody["address"] = "“泉州市高教发展中心”微信公众号";
  50. $msgBody["dep"] = "泉州市高教发展中心";
  51. $msgBody["phone"] = "0595-85002588";
  52. $msgBody["email"] = "jjsgjrc@126.com";
  53. }
  54. $assigns["message"] = $msgBody;
  55. }
  56. return view("", $assigns);
  57. }
  58. /**
  59. * 获取优秀人才津补贴列表
  60. */
  61. public function list($process) {
  62. $param = $this->request->param();
  63. $offset = $param["offset"] ?: 0;
  64. $limit = $param["limit"] ?: 10;
  65. $param["process"] = $process;
  66. $param["type"] = $this->user["type"];
  67. $where = [];
  68. $where[] = ["type", "=", $this->user["type"]];
  69. $where[] = ["delete", "=", 0];
  70. $order = "createTime desc";
  71. $this->setCondition($where, $param);
  72. switch ($process) {
  73. case 1:
  74. break;
  75. case 2:
  76. break;
  77. case 3:
  78. $where[] = ["depPassTime", "EXP", Db::raw("is not null")];
  79. break;
  80. case 4:
  81. $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
  82. $where[] = ["reviewPassTime", "EXP", Db::raw("is not null")];
  83. break;
  84. }
  85. if (in_array($process, [1, 3, 4])) {
  86. $count = houseModel::where($where)->count();
  87. $list = houseModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  88. } else {
  89. $company = getCacheById("Company", $this->user["companyId"]);
  90. $result = HouseApi::selectForHousePurchase($param, $company, ProjectState::HOUSE, $offset, $limit);
  91. $count = $result["total"];
  92. $list = $result["rows"];
  93. }
  94. $list = $this->translateChinese($list, $process);
  95. return json(["rows" => $list, "total" => $count]);
  96. }
  97. /**
  98. * 审核页面
  99. * @return type
  100. */
  101. public function toCheckPage() {
  102. $id = $this->request["id"];
  103. $process = $this->request["process"];
  104. $companyId = $this->request["companyId"];
  105. $hand = $this->request["hand"];
  106. $housepurchase = HouseApi::getInfoById($id);
  107. $company = getCacheById("Company", $this->user["companyId"]);
  108. $enterprise = \app\common\api\EnterpriseApi::getOne($housepurchase["enterpriseId"]);
  109. $housepurchase["enterpriseName"] = $enterprise["name"];
  110. $housepurchase["process"] = $process;
  111. $housepurchase["companyId"] = $companyId;
  112. $housepurchase["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $housepurchase["talentArrange"])["name"];
  113. $housepurchase["marryStatusName"] = DictApi::findByParentCodeAndCode("marry_status", $housepurchase["marryStatus"])["name"];
  114. $housepurchase["cardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["cardType"])["name"];
  115. if (\StrUtil::isNotEmpAndNull($housepurchase["spouseCardType"])) {
  116. $housepurchase["spouseCardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["spouseCardType"])["name"];
  117. }
  118. if (\StrUtil::isNotEmpAndNull($housepurchase["childCardType"])) {
  119. $housepurchase["childCardTypeName"] = DictApi::findByParentCodeAndCode("card_type", $housepurchase["childCardType"])["name"];
  120. }
  121. $housepurchase["streetName"] = DictApi::findByParentCodeAndCode("street", $housepurchase["street"])["name"];
  122. if ($housepurchase["type"] == 1) {
  123. $housepurchase["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $housepurchase["talentType"])["name"];
  124. }
  125. $housepurchase["identifyConditionCH"] = \app\common\api\TalentConditionApi::getOne($housepurchase["identifyCondition"])["name"];
  126. /* * 历史申报享受其他政策数据* */
  127. $historyOtherList = HouseApi::getHistoryEnjoyOtherList($id, $housepurchase["idCard"], $housepurchase["spouseIdcard"]);
  128. /* * 当前申报录入的享受其他政策数据 */
  129. $nowOtherList = HouseApi::getEnjoyOtherList($id);
  130. /* * 其他房产信息 */
  131. $zzjOtherHouseList = HouseApi::getOtherHouseList($id, 1);
  132. $zrzyOtherHouseList = HouseApi::getOtherHouseList($id, 2);
  133. /* * 未成年子女信息 */
  134. $childrenList = HouseApi::getChildren($id);
  135. /* * 配偶信息 */
  136. $spouseList = HouseApi::getSpouse($id);
  137. $dicts = DictApi::findChildDictByCode("card_type");
  138. $vars = [
  139. "dicts" => $dicts,
  140. "row" => $housepurchase,
  141. "company" => $company,
  142. "historyOtherList" => $historyOtherList,
  143. "nowOtherList" => $nowOtherList,
  144. "zzjOtherHouseList" => $zzjOtherHouseList,
  145. "zrzyOtherHouseList" => $zrzyOtherHouseList,
  146. "childrenList" => $childrenList,
  147. "spouseList" => $spouseList
  148. ];
  149. $template = $hand == 1 ? "info" : "select";
  150. return view($template, $vars);
  151. }
  152. /**
  153. * 查看详情
  154. * @return type
  155. */
  156. public function toSelectPage() {
  157. $id = $this->request["id"];
  158. $process = $this->request["process"];
  159. $obj = TalentAllowanceApi::getInfoById($id);
  160. $this->translateToChinese($obj);
  161. if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  162. $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
  163. $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
  164. if ($need_choose_post_type[$obj["enterpriseId"]]) {
  165. $postTypes = DictApi::findChildDictByCode("PostType");
  166. foreach ($postTypes as $key => $pt) {
  167. if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
  168. unset($postTypes[$key]);
  169. }
  170. }
  171. }
  172. if (in_array($obj["enterpriseId"], $need_choose_institution)) {
  173. $institutions = DictApi::findChildDictByCode("Institution");
  174. }
  175. }
  176. return view("select", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
  177. }
  178. /**
  179. * 审核保存
  180. */
  181. public function check() {
  182. $id = $this->request["id"];
  183. $process = $this->request["process"];
  184. $toProcess = $this->request["toProcess"];
  185. $toDep = $this->request["toDep"];
  186. $checkState = $this->request["checkState"];
  187. $checkMsg = $this->request["checkMsg"];
  188. $cashType = $this->request["cashType"];
  189. $fields = $this->request["fields"];
  190. $files = $this->request["files"];
  191. if (!$checkState) {
  192. return new Response(Response::ERROR, "请选择审核状态");
  193. }
  194. if ($process == 1) {
  195. $old = HouseApi::getInfoById($id);
  196. $old["fields"] = $fields;
  197. $old["files"] = $files;
  198. houseModel::update($old);
  199. }
  200. if ($process == 3) {
  201. $data["id"] = $id;
  202. if ($checkState == 2) {
  203. if ($toProcess == 2) {
  204. $where = [];
  205. $where[] = ["code", "in", $toDep];
  206. $companyIds = \app\common\model\Company::where($where)->column("id");
  207. $data["toDep"] = implode(",", $companyIds);
  208. }
  209. $data["toProcess"] = $toProcess;
  210. }
  211. if ($checkState == 3) {
  212. $data["cashType"] = $cashType;
  213. }
  214. houseModel::update($data);
  215. }
  216. //添加日志
  217. TalentChecklog::create([
  218. 'id' => getStringId(),
  219. 'mainId' => $id,
  220. 'type' => intval(ProjectState::HOUSE),
  221. 'typeFileId' => null,
  222. 'active' => 2,
  223. 'state' => $checkState,
  224. 'step' => $process,
  225. 'stateChange' => "保存未提交",
  226. 'description' => $checkMsg,
  227. 'createTime' => date("Y-m-d H:i:s", time()),
  228. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  229. ]);
  230. return new Response(Response::SUCCESS, "审核成功");
  231. }
  232. /**
  233. * 提交审核
  234. * @return Response
  235. */
  236. public function submitCheck() {
  237. $id = $this->request["id"];
  238. $process = $this->request["process"];
  239. $companyId = $this->request["companyId"];
  240. if ($process != 2) {
  241. $companyId = null;
  242. }
  243. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $companyId);
  244. if (!$log) {
  245. return new Response(Response::ERROR, "请先审核后再提交");
  246. }
  247. $checkState = $log["state"];
  248. $housepurchase = [];
  249. $housepurchase["id"] = $id;
  250. $housepurchase["checkMsg"] = $log["description"];
  251. $old = HouseApi::getInfoById($id);
  252. //判断到达的最高流程
  253. $housepurchase["highProcess"] = $old["highProcess"] == null ? $process : ($old["highProcess"] < $process ? $process : $old["highProcess"]);
  254. switch ($process) {
  255. case 1:
  256. if ($checkState == -1) {
  257. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  258. $housepurchase["realEnjoyMoney"] = 0;
  259. }
  260. if ($checkState == 2) {
  261. $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
  262. }
  263. if ($checkState == 3) { //审核通过
  264. $depCount = Db::table("un_talent_depcheckstate")->where("mainId", $id)->count();
  265. if ($depCount > 0) {
  266. $where = [];
  267. $where[] = ["mainId", "=", $id];
  268. $where[] = ["state", "=", 2];
  269. $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  270. if ($rejectCount > 0) {
  271. $updDep["state"] = 9;
  272. $updDep["updateTime"] = date("Y-m-d H:i:s");
  273. $updDep["updateUser"] = $this->user["name"];
  274. Db::table("un_talent_depcheckstate")->where($where)->update($updDep);
  275. $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
  276. } else {
  277. $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  278. }
  279. } else {
  280. /* * 生成各部门数据审核 */
  281. $depList = [];
  282. $depCodes = getJsonConfig("../sys_config.json", "housepurchase_dep_list")[$old["type"]];
  283. $where = [];
  284. $where[] = ["code", "in", $depCodes];
  285. $companies = \app\common\model\Company::where($where)->select()->toArray();
  286. foreach ($companies as $company) {
  287. $depList[] = [
  288. "id" => getStringId(),
  289. "type" => ProjectState::HOUSE,
  290. "mainId" => $id,
  291. "companyId" => $company["id"],
  292. "state" => 1,
  293. "createTime" => date("Y-m-d H:i:s"),
  294. "createUser" => $this->user["name"]
  295. ];
  296. }
  297. Db::table("un_talent_depcheckstate")->insertAll($depList);
  298. $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
  299. }
  300. if (\StrUtil::isEmpOrNull($old["firstPassTime"])) {
  301. $housepurchase["firstPassTime"] = date("Y-m-d H:i:s");
  302. }
  303. /* * 判断夫妻是否同时申报 */
  304. if (\StrUtil::isNotEmpAndNull($old["spouseIdcard"])) {
  305. $where = [];
  306. $where[] = ["idCard", "=", $old["spouseIdcard"]];
  307. $where[] = ["year", "=", $old["year"]];
  308. $where[] = ["delete", "=", 0];
  309. $count = houseModel::where($where)->count();
  310. $housepurchase["isConflict"] = $count > 0 ? 1 : 2;
  311. }
  312. }
  313. //添加日志
  314. TalentChecklog::create([
  315. 'id' => getStringId(),
  316. 'mainId' => $id,
  317. 'type' => intval(ProjectState::HOUSE),
  318. 'typeFileId' => null,
  319. 'active' => 1,
  320. 'state' => $checkState,
  321. 'step' => $process,
  322. 'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
  323. 'description' => $log["description"],
  324. 'createTime' => date("Y-m-d H:i:s", time()),
  325. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  326. ]);
  327. TalentChecklog::delete($log["id"]);
  328. houseModel::update($housepurchase);
  329. break;
  330. case 2:
  331. $where = [];
  332. $where[] = ["mainId", "=", $id];
  333. $where[] = ["companyId", "=", $companyId];
  334. $tds = Db::table("un_talent_depcheckstate")->where($where)->find();
  335. $tds["state"] = 3;
  336. $tds["submitTime"] = date("Y-m-d H:i:s");
  337. Db::table("un_talent_depcheckstate")->update($tds);
  338. //判断所有部门是否全部通过
  339. $where = [];
  340. $where[] = ["mainId", "=", $id];
  341. $where[] = ["state", "in", [1, 4, 9]];
  342. $needCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  343. if ($needCount == 0) {
  344. $where = [];
  345. $where[] = ["mainId", "=", $id];
  346. $where[] = ["state", "=", 2];
  347. $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  348. if ($rejectCount > 0) {
  349. $housepurchase["checkState"] = HouseStateEnum::DEP_REJECT;
  350. } else {
  351. if (\StrUtil::isEmpOrNull($old["depPassTime"])) {
  352. $housepurchase["depPassTime"] = date("Y-m-d H:i:s");
  353. }
  354. $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  355. }
  356. houseModel::update($housepurchase);
  357. }
  358. //添加日志
  359. TalentChecklog::create([
  360. 'id' => getStringId(),
  361. 'mainId' => $id,
  362. 'type' => intval(ProjectState::HOUSE),
  363. "companyId" => $companyId,
  364. 'typeFileId' => null,
  365. 'active' => 1,
  366. 'state' => 3,
  367. 'step' => $process,
  368. 'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
  369. 'description' => $log["description"],
  370. 'createTime' => date("Y-m-d H:i:s", time()),
  371. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  372. ]);
  373. TalentChecklog::delete($log["id"]);
  374. break;
  375. case 3:
  376. if ($checkState == -1) {
  377. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  378. $housepurchase["cashType"] = 2;
  379. $housepurchase["realEnjoyMoney"] = 0;
  380. }
  381. if ($checkState == 2) {
  382. $where = [];
  383. $where[] = ["mainId", "=", $id];
  384. $where[] = ["companyId", "in", $old["toDep"]];
  385. if ($old["toProcess"] == -1) {
  386. $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
  387. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  388. $updTds["state"] = 2;
  389. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  390. }
  391. }
  392. if ($old["toProcess"] == 1) {
  393. $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_FIRST;
  394. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  395. $updTds["state"] = 2;
  396. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  397. }
  398. } else if ($old["toProcess"] == 2) {
  399. $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_DEP;
  400. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  401. $updTds["state"] = 4;
  402. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  403. }
  404. }
  405. }
  406. if ($checkState == 3) {
  407. /**
  408. * 通过需要判定补贴类型及享受金额
  409. * */
  410. $where = [];
  411. $where[] = ["idCard", "=", $old["idCard"]];
  412. $where[] = ["year", "=", $old["year"]];
  413. $where[] = ["delete", "=", 0];
  414. $info = \app\common\model\TalentAllowance::where($where)->find();
  415. if (!$info) {
  416. return new Response(Response::ERROR, "当前申报人暂未申报津补贴,无法审核通过");
  417. }
  418. if ($info["checkState"] != \app\common\state\AllowanceStateEnum::REVIEW_PASS || $info["publicState"] < 4) {
  419. return new Response(Response::ERROR, "当前申报人的津补贴申报暂未公示通过,无法审核通过");
  420. }
  421. $housepurchase["cashType"] = $old["cashType"];
  422. $descideDesc[] = "审核意见:" . $log["description"] . ";系统根据津补贴情况判断说明:";
  423. /* * 1.判断征信信息 */
  424. if (\StrUtil::isNotEmpAndNull($info["outMsg"]) && $info["checkState"] == \app\common\state\AllowanceStateEnum::NOTPASS) {
  425. $housepurchase["zxMsg"] = $info["outMsg"];
  426. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  427. $housepurchase["cashType"] = 2;
  428. $descideDesc[] = "(1)核查征信结果:" . $info["outMsg"] . ";无法享受";
  429. } else {
  430. $descideDesc[] = "(1)核查征信结果:征信通过;";
  431. $housepurchase["zxMsg"] = "";
  432. $housepurchase["checkState"] = HouseStateEnum::REVIEW_PASS;
  433. }
  434. /* * 2.获取社保/个税数据并判断是否可以享受* */
  435. if ($old["declareType"] == 1) { //购房补贴
  436. $sbSet = [];
  437. if ($old["type"] == 1) {
  438. sbSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB . getCode());
  439. } else {
  440. Set<String> pensionSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_PENSION . getCode());
  441. Set<String> unemploymentSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_UNEMPLOYMENT . getCode());
  442. Set<String> medicalSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_SB_MEDICA . getCode());
  443. pensionSet . retainAll(unemploymentSet);
  444. pensionSet . retainAll(medicalSet);
  445. sbSet . addAll(pensionSet);
  446. }
  447. Set<String> taxSet = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_TAX . getCode());
  448. housepurchase . setSbPayDetail(sbSet . stream() . collect(Collectors . joining(",")));
  449. housepurchase . setTaxPayDetail(taxSet . stream() . collect(Collectors . joining(",")));
  450. housepurchase . setAllowanceType(info . getAllowanceType());
  451. /* * 获取社保个税交集 */
  452. Set<String> totalMonth = new TreeSet <> (Arrays . asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"));
  453. totalMonth . retainAll(sbSet);
  454. taxSet . retainAll(taxSet);
  455. /* * 判断是否享受人才津贴 */
  456. if (info . getAllowanceType() != 1 && housepurchase . getCashType() == 1) {
  457. housepurchase . setCashType(2);
  458. descideDesc . append("(2)上一年度未享受人才津贴,无法享受;");
  459. } else {
  460. descideDesc . append("(2)上一年度享受人才津贴;");
  461. }
  462. /* * 判断社保个税共同缴纳是否满足几个月 */
  463. if (totalMonth . size() < 9 && housepurchase . getCashType() == 1) {
  464. housepurchase . setCashType(2);
  465. descideDesc . append("(3)社保和个税上一年度共同缴纳未满足9个月,无法享受;");
  466. } else {
  467. descideDesc . append("(3)社保和个税上一年度共同缴纳满足9个月;");
  468. }
  469. housepurchase . setDecideDetail(descideDesc . toString());
  470. /* * 对需要兑现的计算享受金额 */
  471. if (housepurchase . getCashType() == 1) {
  472. ResponseObj responseObj = calculateOld(old, housepurchase, descideDesc, 1);
  473. if (responseObj . getCode() == 500) {
  474. return responseObj;
  475. }
  476. }
  477. } else if (old . getDeclareType() == 2) { //免租入住
  478. Set<String> set = getAllowanceProjectSet(info, old, AllowanceProjectEnum . PROJECT_LETTER . getCode());
  479. housepurchase . setLetterDetail(set . stream() . collect(Collectors . joining(",")));
  480. if (set . size() < 9 && housepurchase . getCashType() == 1) {
  481. housepurchase . setCashType(2);
  482. housepurchase . setDecideDetail("(2)上一年度行政介绍信未满足9个月");
  483. } else {
  484. housepurchase . setDecideDetail("(2)上一年度行政介绍信满足9个月");
  485. }
  486. }
  487. if (FengStringUtil . isEmpOrNull(old . getReviewPassTime())) {
  488. housepurchase . setReviewPassTime(DateUtil . getTime());
  489. }
  490. }
  491. TalentChecklog newLog3 = new TalentChecklog(ProjectEnum . HOUSE . getCode(), obj . getId(), null, StateConst . ACTIVE_YES, checkState,
  492. obj . getProcess(), HousePurechaseStateEnum . valueOf(old . getCheckState()) + "->" + HousePurechaseStateEnum . valueOf(housepurchase . getCheckState()), log . getDescription(), DateUtil . getTime(),
  493. ShiroKit . getUser() . getAccount() + "(" + company . getName() + ")");
  494. this.talentChecklogService.delete(new EntityWrapper<TalentChecklog>().eq("mainId", obj.getId()).eq("active", StateConst.ACTIVE_NO));
  495. this . talentChecklogService . insert(newLog3);
  496. this . housepurchaseService . updateById(housepurchase);
  497. break;
  498. }
  499. return new Response(Response::SUCCESS, "提交审核成功");
  500. }
  501. public function exportHczx() {
  502. $response = new \stdClass();
  503. $response->code = 500;
  504. $ids = $this->request->param("ids");
  505. $ids_arr = array_filter(explode(",", $ids));
  506. if (!$ids_arr) {
  507. $response->msg = "没有选择导出的名单";
  508. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  509. }
  510. $where = [];
  511. $where[] = ["id", "in", $ids_arr];
  512. $list = TaModel::field("id,cardType,idCard,name,enterpriseId,year")->where($where)->select()->toArray();
  513. if (!$list) {
  514. $response->msg = "暂无可核查征信的数据";
  515. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  516. }
  517. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "备注"];
  518. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  519. $cardTypeName = DictApi::selectByParentCode("card_type");
  520. $rows = [];
  521. for ($i = 0; $i < count($list); $i++) {
  522. $item = $list[$i];
  523. $row = [
  524. $i + 1, $item["name"], $cardTypeName[$item["cardType"]], $item["idCard"], $enterpriseMap[$item["enterpriseId"]], $item["description"]
  525. ];
  526. $rows[] = $row;
  527. }
  528. $filename = "津补贴待核查征信名单导出";
  529. if ($rows) {
  530. export($columns, $rows, $filename);
  531. exit();
  532. } else {
  533. $response->msg = "没有选择导出的名单";
  534. return \StrUtil::back($response, "TalentTypeChange.callBack");
  535. }
  536. }
  537. /**
  538. * 核查征信驳回
  539. */
  540. public function hczxReject() {
  541. $param = $this->request->param();
  542. if (!$param) {
  543. return new Response(Response::ERROR, "系统错误,请联系管理员");
  544. }
  545. $old = TalentAllowanceApi::getInfoById($param["id"]);
  546. if ($old["publicState"] != 1) {
  547. return new Response(Response::ERROR, "当前记录不是待核查征信状态,无法核查");
  548. }
  549. $data["id"] = $param["id"];
  550. $data["publicState"] = 2;
  551. $data["checkState"] = AllowanceStateEnum::NOTPASS;
  552. $data["recommendAllowanceType"] = 3;
  553. $data["recommendAllowanceMsg"] = "征信失信,不予兑现,失信原因:" . $param["outMsg"];
  554. $data["recommendMonths"] = "";
  555. $data["recommendMoney"] = 0.00;
  556. $data["workAllowanceMoney"] = null;
  557. $data["developAllowanceMoney"] = null;
  558. //添加日志
  559. TalentChecklog::create([
  560. 'id' => getStringId(),
  561. 'mainId' => $param["id"],
  562. 'type' => intval(ProjectState::JBT),
  563. 'typeFileId' => null,
  564. 'active' => 1,
  565. 'state' => 2,
  566. 'step' => 4,
  567. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "-><span class='label label-primary'>审核不通过</span>" . "公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  568. 'description' => $param["outMsg"],
  569. 'createTime' => date("Y-m-d H:i:s", time()),
  570. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  571. ]);
  572. TaModel::update($data);
  573. return new Response(Response::SUCCESS, "核查征信成功");
  574. }
  575. /**
  576. * 核查征信批量通过
  577. */
  578. public function hczxPass() {
  579. $ids = $this->request["ids"];
  580. if (\StrUtil::isEmpOrNull($ids)) {
  581. return new Response(Response::ERROR, "请选择核查征信通过的数据");
  582. }
  583. $where = [];
  584. $where[] = ["id", "in", $ids];
  585. $list = TaModel::where($where)->select()->toArray();
  586. $logList = [];
  587. $upds = [];
  588. foreach ($list as $obj) {
  589. $upds[] = [
  590. "id" => $obj["id"],
  591. "publicState" => 2,
  592. ];
  593. $logList[] = [
  594. "id" => getStringId(),
  595. "type" => ProjectState::JBT,
  596. "mainId" => $obj["id"],
  597. "active" => 1,
  598. "state" => 3,
  599. "step" => 4,
  600. "stateChange" => "<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  601. "description" => "核查征信通过",
  602. "createTime" => date("Y-m-d H:i:s"),
  603. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  604. ];
  605. }
  606. $taModel = new TaModel();
  607. $taModel->saveAll($upds);
  608. Db::table("new_talent_checklog")->insertAll($logList);
  609. return new Response(Response::SUCCESS, "核查征信通过成功");
  610. }
  611. /**
  612. * 公示
  613. * */
  614. public function publicBatch() {
  615. $params = $this->request->param();
  616. $ids = $params["ids"];
  617. $ids = array_filter(explode(",", $ids));
  618. if (!$ids) {
  619. return new Response(Response::ERROR, "请至少选择一行数据");
  620. }
  621. $isMessage = $params["isMessage"] == 1 ? true : false;
  622. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  623. return new Response(Response::ERROR, "短信参数不能为空");
  624. }
  625. $where = [];
  626. $where[] = ["id", "in", $ids];
  627. $list = houseModel::where($where)->select()->toArray();
  628. Db::startTrans();
  629. try {
  630. $logList = [];
  631. $phones = [];
  632. foreach ($list as $info) {
  633. /* * 添加日志 */
  634. $logList[] = [
  635. "id" => getStringId(),
  636. "type" => ProjectState::HOUSE,
  637. "mainId" => $info["id"],
  638. "active" => 1,
  639. "state" => 3,
  640. "step" => 5,
  641. "stateChange" => "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>",
  642. "description" => "批量公示",
  643. "createTime" => date("Y-m-d H:i:s"),
  644. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  645. ];
  646. $phones[] = $info["phone"];
  647. }
  648. $data["publicState"] = 2;
  649. Db::table("un_housepurchase")->where($where)->update($data);
  650. $effect = Db::table("new_talent_checklog")->insertAll($logList);
  651. Db::commit();
  652. if ($phones && $isMessage && $effect) {
  653. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  654. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  655. $phones = array_filter($phones);
  656. foreach ($phones as $phone) {
  657. queue("app\job\Messenger", ["type" => 6, "userId" => 0, "phone" => $phone, "template" => $tpl_content, "processName" => "购房补贴-批量公示", "userType" => 3]);
  658. }
  659. }
  660. return new Response(Response::SUCCESS, "公示成功");
  661. } catch (\think\db\exception\DbException $e) {
  662. Db::rollback();
  663. return new Response(Response::SUCCESS, "公示失败:" . $e->getMessage());
  664. }
  665. }
  666. /**
  667. * 跳转到公示再审核页面
  668. * */
  669. public function toSupplePage() {
  670. $id = $this->request["id"];
  671. $process = $this->request["process"];
  672. $obj = TalentAllowanceApi::getInfoById($id);
  673. $this->translateToChinese($obj);
  674. if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  675. $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
  676. $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
  677. if ($need_choose_post_type[$obj["enterpriseId"]]) {
  678. $postTypes = DictApi::findChildDictByCode("PostType");
  679. foreach ($postTypes as $key => $pt) {
  680. if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
  681. unset($postTypes[$key]);
  682. }
  683. }
  684. }
  685. if (in_array($obj["enterpriseId"], $need_choose_institution)) {
  686. $institutions = DictApi::findChildDictByCode("Institution");
  687. }
  688. }
  689. return view("public_check", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
  690. }
  691. /**
  692. * 公示再审核计算津补贴
  693. * */
  694. public function suppleCheckCalculate() {
  695. $id = $this->request["id"];
  696. try {
  697. $info = TalentAllowanceApi::getInfoById($id);
  698. $arrangeList = $this->validateAllowanceType($info);
  699. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  700. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  701. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  702. foreach ($detailList as &$detail) {
  703. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  704. if (\StrUtil::isNotEmpAndNull($detail["talentType"])) {
  705. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  706. }
  707. }
  708. $res = [
  709. "info" => $info,
  710. "detailList" => $detailList
  711. ];
  712. return new Response(Response::SUCCESS, "计算成功", $res);
  713. } catch (\think\Exception $e) {
  714. return new Response(Response::ERROR, "系统异常,请联系管理员");
  715. }
  716. }
  717. /**
  718. * 公示后审核
  719. */
  720. public function afterCheck() {
  721. $param = $this->request->param();
  722. if (!$param["id"]) {
  723. return new Response(Response::ERROR, "系统错误,请联系管理员");
  724. }
  725. $old = TalentAllowanceApi::getInfoById($param["id"]);
  726. if ($old["publicState"] != 3) {
  727. return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
  728. }
  729. try {
  730. $arrangeList = null;
  731. $desc = "审核意见:" . $param["checkMsg"] . ";\n";
  732. $desc .= "征信:" . ($param["zxState"] == 1 ? "征信通过" : $param["zxMsg"] . ";\n");
  733. $data["id"] = $param["id"];
  734. if ($param["checkState"] == -1) {
  735. $data["checkState"] = -1;
  736. $data["checkMsg"] = $param["checkMsg"];
  737. $data["allowanceType"] = 3;
  738. $data["allowanceMsg"] = "审核不通过,原因:" . $param["checkMsg"];
  739. $data["outMsg"] = $param["zxState"] == 1 ? "" : $param["zxMsg"];
  740. } else if ($param["checkState"] == 3) {
  741. if ($param["zxState"] == 1) {
  742. $typeName = "";
  743. $old["recommendAllowanceMsg"] = "";
  744. if ($param["source"] == 1) { //遵循系统结果
  745. $arrangeList = $this->validateAllowanceType($old);
  746. $typeName = "系统判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["allowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  747. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $old["recommendAllowanceMsg"] . ";";
  748. } else if ($param["source"] == 2) {
  749. $detailIds = array_column($param["details"], "id");
  750. $where = [];
  751. $where[] = ["id", "in", $detailIds];
  752. $detailList = \app\common\model\TalentAllowancecontractDetail::where($where)->select()->toArray();
  753. $set = [];
  754. if ($params["resAllowanceType"] == 1) {
  755. $monthsMap = [];
  756. for ($i = 0; $i < count($param["details"]); $i++) {
  757. $monthsMap[$param["details"][$i]["id"]] = $param["details"][$i]["months"];
  758. }
  759. foreach ($detailList as &$detail) {
  760. $months = $monthdsMap[$detail["id"]];
  761. if (\StrUtil::isNotEmpAndNull($months)) {
  762. $detail["months"] = $months;
  763. $set = array_merge($set, explode(",", $months));
  764. }
  765. }unset($detail);
  766. }
  767. $set = array_filter($set);
  768. usort($set, function($a, $b) {
  769. return (int) $a - (int) $b;
  770. });
  771. $old["recommendAllowanceType"] = $param["resAllowanceType"];
  772. $old["recommendMonths"] = implode(",", $set);
  773. $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["recommendAllowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  774. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $obj["resAllowanceMsg"] . ";";
  775. $arrangeList = $this->calculateAllowance($old, $set, $detailList);
  776. }
  777. $desc .= "判定结果:" . $typeName;
  778. $data["checkState"] = 30;
  779. $data["outMsg"] = "";
  780. $data["allowanceType"] = $old["recommendAllowanceType"];
  781. $data["allowanceMsg"] = $old["recommendAllowanceMsg"];
  782. $data["months"] = $old["recommendMonths"];
  783. $data["money"] = $old["recommendMoney"];
  784. $data["moneyDesc"] = $old["recommendMoneyDesc"];
  785. $data["jtTalentArrange"] = $old["recommendTalentArrange"];
  786. $data["workAllowanceMoney"] = $old["workAllowanceMoney"];
  787. $data["developAllowanceMoney"] = $old["developAllowanceMoney"];
  788. } else {
  789. $data["checkState"] = -1;
  790. $data["outMsg"] = $param["zxMsg"];
  791. $data["allowanceType"] = 3;
  792. $data["allowanceMsg"] = "征信失信(不予兑现),原因:" . $param["zxMsg"];
  793. }
  794. }
  795. if ($param["allowanceType"] == 3) {
  796. $data["months"] = "";
  797. $data["money"] = 0;
  798. $data["moneyDesc"] = "";
  799. $data["jtTalentArrange"] = "";
  800. $data["workAllowanceMoney"] = null;
  801. $data["developAllowanceMoney"] = null;
  802. }
  803. $data["isPublicCheck"] = 1;
  804. $data["publicState"] = 4;
  805. //添加日志
  806. TalentChecklog::create([
  807. 'id' => getStringId(),
  808. 'mainId' => $old['id'],
  809. 'type' => intval(ProjectState::JBT),
  810. 'typeFileId' => null,
  811. 'active' => 1,
  812. 'state' => $param["checkState"] == AllowanceStateEnum::REVIEW_PASS ? 3 : $param["checkState"],
  813. 'step' => 6,
  814. 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
  815. 'description' => $desc,
  816. 'createTime' => date("Y-m-d H:i:s", time()),
  817. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  818. ]);
  819. TaModel::update($data);
  820. if ($arrangeList != null) {
  821. $taaModel = new TalentAllowanceArrange();
  822. $taaModel->saveAll($arrangeList);
  823. }
  824. return new Response(Response::SUCCESS, "审核成功");
  825. } catch (\think\Exception $e) {
  826. return new Response(Response::ERROR, "系统异常,请联系管理员");
  827. }
  828. }
  829. /**
  830. * 批量公示通过
  831. */
  832. public function publicPass() {
  833. $ids = $this->request["ids"];
  834. $ids = explode(",", $ids);
  835. if (!$ids) {
  836. return new Response(Response::ERROR, "请至少选择一行数据");
  837. }
  838. $where = [];
  839. $where[] = ["id", "in", $ids];
  840. $list = houseModel::where($where)->select()->toArray();
  841. $houseInfoList = houseInfoModel::where(null)->select()->toArray();
  842. $houseInfoMap = [];
  843. foreach ($houseInfoList as $houseInfo) {
  844. $houseInfoMap[$houseInfo["idCard"]] = $houseInfo;
  845. }
  846. $logList = [];
  847. $insertHouseInfoList = [];
  848. try {
  849. Db::startTrans();
  850. for ($i = 0; $i < count($list); $i++) {
  851. $obj = $list[$i];
  852. if ($obj["cashType"] == 1 && $obj["declareType"] == 1) {
  853. $houseInfo = $houseInfoMap[$obj["idCard"]];
  854. $spouseHouseInfo = $houseInfoMap[$obj["spouseIdcard"]];
  855. if (!$houseInfo) {
  856. $houseInfo = [
  857. "idCard" => $obj["idCard"],
  858. "spouseIdCard" => null,
  859. "houseAddress" => $obj["houseAddress"],
  860. "houseArea" => $obj["houseArea"],
  861. "houseMoney" => $obj["houseMoney"],
  862. "recordTime" => $obj["recordTime"],
  863. "realEstateNo" => $obj["realEstateNo"],
  864. "recordNo" => $obj["recordNo"],
  865. "balanceMoney" => $obj["houseMoney"],
  866. "count" => 0,
  867. "lastYearArrears" => 0,
  868. ];
  869. }
  870. $houseInfo["count"] = $houseInfo["count"] + 1;
  871. $houseInfo["balanceMoney"] = $houseInfo["balanceMoney"] - $obj["shouldEnjoyMoney"];
  872. $houseInfo["lastYearArrears"] = $obj["nowNotSubOtherMoney"]
  873. if (\StrUtil::isNotEmpAndNull($obj["spouseIdcard"])) {
  874. if (!$spouseHouseInfo) {
  875. $spouseHouseInfo = [
  876. "idCard" => $obj["spouseIdcard"],
  877. "spouseIdCard" => null,
  878. "houseAddress" => $obj["houseAddress"],
  879. "houseArea" => $obj["houseArea"],
  880. "houseMoney" => $obj["houseMoney"],
  881. "recordTime" => $obj["recordTime"],
  882. "realEstateNo" => $obj["realEstateNo"],
  883. "recordNo" => $obj["recordNo"],
  884. "balanceMoney" => $houseInfo["balanceMoney"],
  885. "count" => $houseInfo["count"],
  886. "lastYearArrears" => $houseInfo["lastYearArrears"],
  887. ];
  888. } else {
  889. $spouseHouseInfo["count"] = $spouseHouseInfo["count"] + 1;
  890. $spouseHouseInfo["lastYearArrears"] = $houseInfo["lastYearArrears"];
  891. $spouseHouseInfo["balanceMoney"] = $spouseHouseInfo["balanceMoney"] - $obj["shouldEnjoyMoney"];
  892. }
  893. if ($spouseHouseInfo["id"]) {
  894. $spouseHouseInfo["updateTime"] = date("Y-m-d H:i:s");
  895. $spouseHouseInfo["updateUser"] = $this->user["uid"];
  896. Db::table("un_housepurchase_house_info")->update($spouseHouseInfo);
  897. } else {
  898. $spouseHouseInfo["id"] = getStringId();
  899. $spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
  900. $spouseHouseInfo["createUser"] = $this->user["uid"];
  901. $insertHouseInfoList[] = $spouseHouseInfo;
  902. }
  903. }
  904. if ($houseInfo["id"]) {
  905. $houseInfo["updateTime"] = date("Y-m-d H:i:s");
  906. $houseInfo["updateUser"] = $this->user["uid"];
  907. Db::table("un_housepurchase_house_info")->update($houseInfo);
  908. } else {
  909. $houseInfo["id"] = getStringId();
  910. $houseInfo["createTime"] = date("Y-m-d H:i:s");
  911. $houseInfo["createUser"] = $this->user["uid"];
  912. $insertHouseInfoList[] = $houseInfo;
  913. }
  914. }
  915. //添加日志
  916. $logList[] = [
  917. "id" => getStringId(),
  918. "type" => ProjectState::HOUSE,
  919. "mainId" => $obj["id"],
  920. "active" => 1,
  921. "state" => 3,
  922. "step" => 6,
  923. "stateChange" => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待公布</span>;",
  924. "description" => "批量公示通过",
  925. "createTime" => date("Y-m-d H:i:s"),
  926. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  927. ];
  928. }
  929. $upd["publicState"] = 3;
  930. Db::table("un_housepurchase")->where($where)->update($upd);
  931. if ($insertHouseInfoList) {
  932. Db::table("un_housepurchase_house_info")->insertAll($insertHouseInfoList);
  933. }
  934. Db::table("new_talent_checklog")->insertAll($logList);
  935. Db::commit();
  936. return new Response(Response::SUCCESS, "批量公示通过成功");
  937. } catch (\think\db\exception\DbException $e) {
  938. Db::rollback();
  939. return new Response(Response::ERROR, "批量公示失败:" . $e->getCode());
  940. }
  941. }
  942. /**
  943. * 兑现
  944. */
  945. public function cash() {
  946. $ids = $this->request["ids"];
  947. $ids = array_filter(explode(",", $ids));
  948. if (!$ids) {
  949. return new Response(Response::ERROR, "请至少选择一行数据");
  950. }
  951. $where = [];
  952. $where[] = ["id", "in", $ids];
  953. $list = houseModel::where($where)->select()->toArray();
  954. //添加日志
  955. $logList = [];
  956. try {
  957. Db::startTrans();
  958. for ($i = 0; $i < count($list); $i++) {
  959. $obj = $list[$i];
  960. $logList[] = [
  961. "id" => getStringId(),
  962. "type" => ProjectState::HOUSE,
  963. "mainId" => $obj["id"],
  964. "active" => 1,
  965. "state" => 3,
  966. "step" => 50,
  967. "stateChange" => "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>;",
  968. "description" => "批量兑现",
  969. "createTime" => date("Y-m-d H:i:s"),
  970. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  971. ];
  972. }
  973. $upd["publicState"] = 4;
  974. Db::table("un_housepurchase")->where($where)->update($upd);
  975. Db::table("new_talent_checklog")->insertAll($logList);
  976. Db::commit();
  977. return new Response(Response::SUCCESS, "批量兑现成功");
  978. } catch (\think\db\exception\DbException $e) {
  979. Db::rollback();
  980. return new Response(Response::ERROR, "批量兑现失败:" . $e->getCode());
  981. }
  982. }
  983. /**
  984. * 公示预览(不予兑现)
  985. */
  986. public function exportPublicNotCash() {
  987. $response = new \stdClass();
  988. $response->code = 500;
  989. //获取字典表人才层次+
  990. $levelMap = DictApi::selectByParentCode("talent_arrange");
  991. $streetMap = DictApi::selectByParentCode("street");
  992. //查询企业信息
  993. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  994. //查询所有
  995. $where = [];
  996. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  997. $list = TaModel::where($where)->select()->toArray();
  998. $rows = [];
  999. for ($i = 0; $i < count($list); $i++) {
  1000. $item = $list[$i];
  1001. $rows[] = [
  1002. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  1003. ];
  1004. }
  1005. $filename = CommonConst::getTypeName($this->user["type"]) . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
  1006. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  1007. if ($rows) {
  1008. export($columns, $rows, $filename);
  1009. exit();
  1010. } else {
  1011. $response->msg = "没有选择导出的名单";
  1012. return \StrUtil::back($response, "TalentTypeChange.callBack");
  1013. }
  1014. }
  1015. /**
  1016. * @param ids
  1017. * @param type 1-需要兑现,2-不予兑现
  1018. * @description 公示预览
  1019. * */
  1020. public function exportPublic() {
  1021. /* * 查询需要公示的数据 */
  1022. $ids = array_filter(explode(",", $this->request["ids"]));
  1023. if (!$ids) {
  1024. return new Response(Response::ERROR, "请至少选择一行数据");
  1025. }
  1026. $type = $this->request["type"];
  1027. $where = [];
  1028. $where[] = ["id", "in", $ids];
  1029. $list = houseModel::where($where)->select()->toArray();
  1030. $where = [];
  1031. $where[] = ["pId", "in", $ids];
  1032. $otherList = \app\common\model\HousePurchaseEnjoyOther::where($where)->select()->toArray();
  1033. $otherMap = [];
  1034. foreach ($otherList as $ol) {
  1035. $otherMap[$ol["pId"]][] = $ol;
  1036. }
  1037. //查询企业信息
  1038. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1039. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1040. $year = $list[0]["year"];
  1041. foreach ($list as $key => $obj) {
  1042. $obj["talentArrangeName"] = $levelMap[$obj["talentArrange"]];
  1043. $obj["enterpriseName"] = $enterpriseMap[$obj["enterpriseId"]];
  1044. $obj["sn"] = $key + 1;
  1045. if ($obj["declareType"] == 1) {
  1046. $obj["declareTypeName"] = "购房补贴";
  1047. $otherHouses = $otherMap[$obj["id"]];
  1048. $desc = [];
  1049. foreach ($otherHouses as $house) {
  1050. $desc[] = $house["enjoyPolicyName"];
  1051. }
  1052. $obj["description"] = $desc = "扣除已享受" . implode(";\n", $desc) . "部分";
  1053. } else if ($obj["declareType"] == 2) {
  1054. $obj["declareTypeName"] = "免租入住";
  1055. $obj["description"] = $year . "年度取得免租入住资格";
  1056. }
  1057. }
  1058. $userTypeName = CommonConst::getTypeName($this->user["type"]);
  1059. if ($type == 1) {
  1060. //兑现
  1061. $title = ["序号", "申报类型", "姓名", "工作单位", "人才层次", $year . "年度拟发放购房补贴金额(元)", "备注"];
  1062. $value = ["sn", "declareTypeName", "name", "enterpriseName", "talentArrangeName", "realEnjoyMoney", "description"];
  1063. $fileName = sprintf("%s%s年度购房补贴拟发放对象名单", $userTypeName, $year);
  1064. } else {
  1065. //不予兑现
  1066. $title = ["序号", "申报类型", "姓名", "工作单位", "人才层次", "备注"];
  1067. $value = ["sn", "declareTypeName", "name", "enterpriseName", "talentArrangeName", "description"];
  1068. $fileName = sprintf("%s%s年度购房补贴不予兑现对象名单", $userTypeName, $year);
  1069. }
  1070. $rows = [];
  1071. foreach ($list as $row) {
  1072. $newRow = [];
  1073. for ($i = 0; $i < count($value); $i++) {
  1074. $newRow[] = $row[$value[$i]];
  1075. }
  1076. $rows[] = $newRow;
  1077. }
  1078. export($title, $rows, $fileName);
  1079. }
  1080. /**
  1081. * 导出基本信息
  1082. */
  1083. public function exportBasicInfo() {
  1084. $obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
  1085. $obj["enterpriseName"] = \StrUtil::getRequestDecodeParam($this->request, "enterpriseName");
  1086. $obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
  1087. $obj["idCard"] = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1088. $obj["talentType"] = \StrUtil::getRequestDecodeParam($this->request, "talentType");
  1089. $obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
  1090. $obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
  1091. $obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
  1092. $obj["isSupple"] = \StrUtil::getRequestDecodeParam($this->request, "isSupple");
  1093. $obj["checkState"] = \StrUtil::getRequestDecodeParam($this->request, "checkState");
  1094. $obj["publicState"] = \StrUtil::getRequestDecodeParam($this->request, "publicState");
  1095. $obj["companyName"] = \StrUtil::getRequestDecodeParam($this->request, "companyName");
  1096. $obj["allowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "allowanceType");
  1097. $obj["recommendAllowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "recommendAllowanceType");
  1098. $obj["introductionMode"] = \StrUtil::getRequestDecodeParam($this->request, "introductionMode");
  1099. $obj["firstJJStartTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJStartTime");
  1100. $obj["firstJJEndTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJEndTime");
  1101. $obj["process"] = intval(\StrUtil::getRequestDecodeParam($this->request, "process"));
  1102. $obj["type"] = $this->user["type"];
  1103. $where = [];
  1104. $where[] = ["ta.delete", "=", 0];
  1105. $where[] = ["ta.type", "=", $this->user["type"]];
  1106. $this->setTalentAllowanceInfoForExport($where, $obj, $obj["process"]);
  1107. switch ($obj["process"]) {
  1108. case 1:
  1109. $where[] = ["ta.checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  1110. break;
  1111. case 2:
  1112. $where[] = ["ta.firstPassTime", "EXP", Db::raw("is not null")];
  1113. break;
  1114. case 3:
  1115. $where[] = ["ta.visitPassTime", "EXP", Db::raw("is not null")];
  1116. break;
  1117. case 4:
  1118. if ($obj["publicState"]) {
  1119. $where[] = ["publicState", "=", $param["publicState"]];
  1120. }
  1121. $where[] = ["ta.checkState", "in", [-1, 30]];
  1122. break;
  1123. }
  1124. $projects = [
  1125. AllowanceProjectEnum::PROJECT_TAX,
  1126. AllowanceProjectEnum::PROJECT_WAGES,
  1127. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1128. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1129. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1130. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1131. ];
  1132. $months = [];
  1133. for ($m = 1; $m <= 12; $m++) {
  1134. $months[] = $m . "月";
  1135. }
  1136. $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]]];
  1137. $infoCols = count($columns);
  1138. for ($i = 0; $i < count($projects); $i++) {
  1139. $columns[] = [AllowanceProjectEnum::getProjectName($projects[$i]), $months];
  1140. }
  1141. $list = \app\common\model\TalentAllowanceProject::alias("pro")
  1142. ->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")
  1143. ->leftJoin("un_talent_allowance_info ta", "ta.id=pro.mainId")
  1144. ->leftJoin("un_talent_allowancecontract_detail con", "pro.baseId=con.id")
  1145. ->where($where)
  1146. ->order("ta.year desc,ta.createTime desc,pro.project asc")
  1147. ->select()->toArray();
  1148. $tmpList = [];
  1149. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1150. $streetMap = DictApi::selectByParentCode("street");
  1151. $where = [];
  1152. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1153. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1154. $where = [];
  1155. $where[] = ["id", "in", array_column($list, "enterpriseId")];
  1156. $enterpriseMap = \app\common\model\Enterprise::where($where)->column("name", "id");
  1157. foreach ($list as $item) {
  1158. //组装数据
  1159. if (!$tmpList[$item["id"]]) {
  1160. $tmpList[$item["id"]]["curEnterpriseId"] = $item["curEnterpriseId"];
  1161. $tmpList[$item["id"]]["info"] = [$item["year"], $streetMap[$item["address"]], $item["name"], $item["sex"] == 1 ? "男" : "女", $item["idCard"], $levelMap[$item["talentArrange"]],
  1162. $icmap[$item["identifyCondition"]], $item["identifyGetTime"], $item["identifyConditionName"], $item["identifyMonth"], AllowanceTypeEnum::getTypeName($item["recommendAllowanceType"]), $item["recommendMonths"], $item["recommendMoney"],
  1163. $item["recommendMoneyDesc"], AllowanceTypeEnum::getTypeName($item["allowanceType"]), $item["months"], $item["money"],
  1164. $item["moneyDesc"], $this->getCheckStateName($item["checkState"], $item["publicState"], $item["allowanceType"])];
  1165. }
  1166. if (!$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]) {
  1167. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]] = [
  1168. "startTime" => $item["startTime"],
  1169. "endTime" => $item["endTime"],
  1170. "entryTime" => $item["entryTime"],
  1171. "isQuit" => $item["isQuit"]
  1172. ];
  1173. }
  1174. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]["projects"][$item["project"]] = $item["pre_months"];
  1175. }
  1176. $rows = [];
  1177. $colorset = [];
  1178. foreach ($tmpList as $id => $item) {
  1179. foreach ($item["enterprise"] as $enterpriseId => $enterprise) {
  1180. $row = $item["info"];
  1181. $row[] = $this->user["uid"] == $enterpriseId ? "本单位" : $enterpriseMap[$enterpriseId];
  1182. for ($i = 0; $i < count($projects); $i++) {
  1183. if (strpos($enterprise["projects"][$projects[$i]], "=") === false) {
  1184. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1185. for ($m = 1; $m <= 12; $m++) {
  1186. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1187. if (in_array($_month, $months)) {
  1188. $row[] = "✔";
  1189. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1190. } else {
  1191. $row[] = "";
  1192. }
  1193. }
  1194. } else {
  1195. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1196. $_months = [];
  1197. foreach ($months as $month) {
  1198. $kv = explode("=", $month);
  1199. $_months[$kv[0]] = $kv[1];
  1200. }
  1201. for ($m = 1; $m <= 12; $m++) {
  1202. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1203. $days = $_months[$_month];
  1204. if ($days && $days > 0) {
  1205. $row[] = $days . "天";
  1206. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1207. } else {
  1208. $row[] = "";
  1209. }
  1210. }
  1211. }
  1212. }
  1213. $rows[] = $row;
  1214. }
  1215. }
  1216. $cols = $infoCols + count($projects) * 12 - 1;
  1217. $settings = [
  1218. "width" => [["A", 8], ["C", 12], ["D", 6], ["E", 20], ["F", 12], ["G", 70], ["H", 12], ["I", 15], ["J", 12], ["K", 12], ["P", 30]],
  1219. "height" => [18],
  1220. "freeze" => "D3",
  1221. "color" => $colorset
  1222. ];
  1223. for ($i = 0; $i < count($projects) * 12; $i++) {
  1224. $settings["width"][] = [getExcelColumnByIndex($infoCols + $i), 6]; //批设置项目的宽度
  1225. }
  1226. $settings["background-color"][] = [sprintf("%s2:%s2", getExcelColumnByIndex($infoCols), getExcelColumnByIndex($cols)), "E1F1DE"];
  1227. export($columns, $rows, "津补贴申报名单", $settings);
  1228. }
  1229. /**
  1230. * 校验是否在审核范围内
  1231. */
  1232. public function validateIsCheck() {
  1233. $id = $this->request["id"];
  1234. $process = $this->request["process"];
  1235. $compnayId = $this->request["companyId"];
  1236. $old = HouseApi::getInfoById($id);
  1237. $checkState = $old["checkState"];
  1238. $res = null;
  1239. switch ($process) {
  1240. case 1:
  1241. if ($checkState != HouseStateEnum::NEED_CHECK && $checkState != HouseStateEnum::REJECT_TO_FIRST && $checkState != HouseStateEnum::DEP_REJECT) {
  1242. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1243. } else {
  1244. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1245. if ($log) {
  1246. $old["checkState"] = $log["state"];
  1247. $old["checkMsg"] = $log["description"];
  1248. } else {
  1249. $old["checkState"] = null;
  1250. $old["checkMsg"] = "";
  1251. }
  1252. }
  1253. break;
  1254. case 2:
  1255. if ($checkState != HouseStateEnum::NEED_DEP_CHECK && $checkState != HouseStateEnum::REJECT_TO_DEP) {
  1256. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1257. } else {
  1258. $where = [];
  1259. $where[] = ["mainId", "=", $id];
  1260. $where[] = ["companyId", "=", $compnayId];
  1261. $where[] = ["type", "=", ProjectState::HOUSE];
  1262. $depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
  1263. if ($depcheckstate["state"] != 1 && $depcheckstate["state"] != 4 && $depcheckstate["state"] != 9) {
  1264. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1265. } else {
  1266. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $compnayId);
  1267. if ($log) {
  1268. $old["checkState"] = $log["state"];
  1269. $old["checkMsg"] = $log["description"];
  1270. } else {
  1271. $old["checkState"] = null;
  1272. $old["checkMsg"] = "";
  1273. }
  1274. $res["company"] = getCacheById("Company", $compnayId);
  1275. }
  1276. }
  1277. break;
  1278. case 3:
  1279. if ($checkState != HouseStateEnum::NEED_REVIEW_CHECK && $checkState != HouseStateEnum::REJECT_TO_REVIEW) {
  1280. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1281. } else {
  1282. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1283. if ($log) {
  1284. $old["checkState"] = $log["state"];
  1285. $old["checkMsg"] = $log["description"];
  1286. } else {
  1287. $old["checkState"] = null;
  1288. $old["checkMsg"] = "";
  1289. }
  1290. }
  1291. break;
  1292. case 4:
  1293. if ($checkState != HouseStateEnum::REVIEW_PASS && $checkState != HouseStateEnum::NOTPASS) {
  1294. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1295. } else if ($old["publicState"] != 2) {
  1296. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1297. } else {
  1298. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1299. if ($log) {
  1300. $old["checkState"] = $log["state"];
  1301. $old["checkMsg"] = $log["description"];
  1302. } else {
  1303. $old["checkState"] = null;
  1304. $old["checkMsg"] = "";
  1305. }
  1306. $res = $this->calculate($old, 1);
  1307. if ($res->code == 500) {
  1308. return $res;
  1309. }
  1310. $res["housepurchase"] = $res->obj;
  1311. }
  1312. break;
  1313. }
  1314. $where = [];
  1315. $where[] = ["type", "=", $old["type"]];
  1316. $where[] = ["project", "=", ProjectState::HOUSE];
  1317. $where[] = ["active", "=", 1];
  1318. $where[] = ["delete", "=", 0];
  1319. $filetypeList = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1320. /* * 查询之前是否享受过 */
  1321. $count = HouseApi::getEnjoyTimesByIdCard($old["idCard"]);
  1322. $res["number"] = $count;
  1323. $res["obj"] = $old;
  1324. $res["fileTypeList"] = $filetypeList;
  1325. return new Response(Response::SUCCESS, "", $res);
  1326. }
  1327. /**
  1328. * 初始化可修改的项目/附件/合同
  1329. * */
  1330. public function findFieldsAndFiles() {
  1331. $id = $this->request["id"];
  1332. if (\StrUtil::isEmpOrNull($id)) {
  1333. return new Response(Response::ERROR, "请选择需要修改的对象");
  1334. }
  1335. $info = HouseApi::getInfoById($id);
  1336. if (!$info) {
  1337. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1338. }
  1339. if ($info["checkState"] != HouseStateEnum::FIRST_REJECT) {
  1340. return new Response(Response::ERROR, "只能修改初审驳回的数据");
  1341. }
  1342. $res = [];
  1343. $where = [];
  1344. $where[] = ["type", "=", $info["type"]];
  1345. $where[] = ["project", "=", ProjectState::HOUSE];
  1346. $where[] = ["active", "=", 1];
  1347. $where[] = ["delete", "=", 0];
  1348. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1349. $res["files"] = $filetypes;
  1350. $res["obj"] = $info;
  1351. return new Response(Response::SUCCESS, "", $res);
  1352. }
  1353. /**
  1354. * 修改驳回项目/附件/合同
  1355. * */
  1356. public function updateFieldsAndFiles() {
  1357. $data = $this->request->param();
  1358. if (!$data["id"]) {
  1359. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1360. }
  1361. houseModel::update($data);
  1362. return new Response(Response::SUCCESS, "修改成功");
  1363. }
  1364. private function setCondition(&$where, &$query) {
  1365. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1366. $where[] = ["year", "=", $query["year"]];
  1367. }
  1368. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1369. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1370. }
  1371. if (\StrUtil::isNotEmpAndNull($query["idCard"])) {
  1372. $where[] = ["idCard", "like", "%" . $query["idCard"] . "%"];
  1373. }
  1374. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1375. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1376. }
  1377. if (\StrUtil::isNotEmpAndNull($query["spouseName"])) {
  1378. $where[] = ["spouseName", "like", "%" . $query["spouseName"] . "%"];
  1379. }
  1380. if (\StrUtil::isNotEmpAndNull($query["spouseIdcard"])) {
  1381. $where[] = ["spouseIdcard", "like", "%" . $query["spouseIdcard"] . "%"];
  1382. }
  1383. if (\StrUtil::isNotEmpAndNull($query["childName"])) {
  1384. $where[] = ["childName", "like", "%" . $query["childName"] . "%"];
  1385. }
  1386. if (\StrUtil::isNotEmpAndNull($query["childIdCard"])) {
  1387. $where[] = ["childIdCard", "like", "%" . $query["childIdCard"] . "%"];
  1388. }
  1389. if (\StrUtil::isNotEmpAndNull($query["marryStatus"])) {
  1390. $where[] = ["marryStatus", "=", $query["marryStatus"]];
  1391. }
  1392. if ($query["isConflict"]) {
  1393. $where[] = ["isConflict", "=", $query["isConflict"]];
  1394. }
  1395. if ($query["isRecover"]) {
  1396. $where[] = ["isRecover", "=", $query["isRecover"]];
  1397. }
  1398. if ($query["checkState"]) {
  1399. switch ($query["checkState"]) {
  1400. case -1:
  1401. $where[] = ["checkState", "=", HouseStateEnum::NOTPASS];
  1402. break;
  1403. case 1:
  1404. $where[] = ["checkState", "=", HouseStateEnum::SAVE];
  1405. break;
  1406. case 2:
  1407. switch ($query["process"]) {
  1408. case 1:
  1409. $where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
  1410. $where[] = ["highProcess", "<", $query["process"]];
  1411. break;
  1412. case 2:
  1413. $query["state"] = 1;
  1414. break;
  1415. case 3:
  1416. $where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
  1417. $where[] = ["highProcess", "<", $query["process"]];
  1418. break;
  1419. }
  1420. break;
  1421. case 3:
  1422. switch ($query["process"]) {
  1423. case 1:
  1424. $where[] = ["checkState", "=", HouseStateEnum::FIRST_REJECT];
  1425. break;
  1426. case 2:
  1427. $query["state"] = 2;
  1428. break;
  1429. case 3:
  1430. $where[] = ["checkState", "<=", HouseStateEnum::REJECT_TO_DEP];
  1431. break;
  1432. }
  1433. break;
  1434. case 4:
  1435. switch ($query["process"]) {
  1436. case 1:
  1437. $where[] = ["checkState", "in", [HouseStateEnum::NEED_DEP_CHECK, HouseStateEnum::REJECT_TO_DEP, HouseStateEnum::NEED_REVIEW_CHECK, HouseStateEnum::REVIEW_PASS]];
  1438. break;
  1439. case 2:
  1440. $query["state"] = 3;
  1441. break;
  1442. case 3:
  1443. case 4:
  1444. $where[] = ["checkState", "=", HouseStateEnum::REVIEW_PASS];
  1445. break;
  1446. }
  1447. break;
  1448. case 5:
  1449. switch ($query["process"]) {
  1450. case 1:
  1451. $where[] = ["checkState", "in", [HouseStateEnum::REJECT_TO_FIRST, HouseStateEnum::DEP_REJECT]];
  1452. break;
  1453. case 2:
  1454. $query["state"] = 4;
  1455. break;
  1456. case 3:
  1457. $where[] = ["checkState", "=", HouseStateEnum::REJECT_TO_REVIEW];
  1458. break;
  1459. }
  1460. break;
  1461. case 6:
  1462. switch ($query["process"]) {
  1463. case 1:
  1464. $where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
  1465. $where[] = ["highProcess", ">=", $query["process"]];
  1466. break;
  1467. case 2:
  1468. $query["state"] = 9;
  1469. break;
  1470. case 3:
  1471. $where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
  1472. $where[] = ["highProcess", ">=", $query["process"]];
  1473. break;
  1474. }
  1475. break;
  1476. }
  1477. }
  1478. }
  1479. private function translateToChinese(&$obj) {
  1480. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  1481. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  1482. }
  1483. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  1484. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  1485. }
  1486. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  1487. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  1488. }
  1489. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  1490. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  1491. }
  1492. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  1493. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  1494. }
  1495. }
  1496. private function translateChinese($list, $process) {
  1497. //获取字典表
  1498. $marryMap = DictApi::selectByParentCode("marry_status");
  1499. $cardTypeMap = DictApi::selectByParentCode("card_type");
  1500. $streetMap = DictApi::selectByParentCode("street");
  1501. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1502. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1503. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1504. $where = [];
  1505. $where[] = ["type", "=", $this->user["type"]];
  1506. $conditionMap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1507. $where = [];
  1508. $where[] = ["pId", "in", array_column($list, "id")];
  1509. $childrens = \app\common\model\HousePurchaseChildren::where($where)->select()->toArray();
  1510. $childMap = [];
  1511. foreach ($childrens as $child) {
  1512. $childMap[$child["pId"]][] = $child;
  1513. }
  1514. foreach ($list as &$info) {
  1515. $info["marryStatusName"] = $marryMap[$info["marryStatus"]];
  1516. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  1517. $info["spouseCardTypeName"] = $cardTypeMap[$info["spouseCardType"]];
  1518. $info["childCardTypeName"] = $cardTypeMap[$info["childCardType"]];
  1519. $info["streetName"] = $streetMap[$info["street"]];
  1520. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  1521. $info["identifyConditionCH"] = $conditionMap[$info["identifyCondition"]];
  1522. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  1523. $info["declareTypeName"] = $info["declareType"] == 1 ? "购房补贴" : "免租入住";
  1524. $info["enterpriseName"] = $enterpriseMap[$info["enterpriseId"]];
  1525. $info["isEnjoyOtherName"] = $info["isEnjoyOther"] == 1 ? "是" : "否";
  1526. $info["spouseIsLibraryName"] = $info["spouseIsLibrary"] == 1 ? "是" : "否";
  1527. $childs = $childMap[$info["id"]];
  1528. $childStr = "";
  1529. if ($childs) {
  1530. for ($i = 0; $i < count($childs); $i++) {
  1531. $childStr .= $childs[$i]["name"] . "-" . $childs[$i]["idCard"] . ";";
  1532. }
  1533. }
  1534. $info["childs"] = $childStr;
  1535. switch ($process) {
  1536. case 1:
  1537. if ($info["checkState"] == HouseStateEnum::NOTPASS) {
  1538. $info["checkStateName"] = "审核不通过";
  1539. }
  1540. if ($info["checkState"] == HouseStateEnum::SAVE) {
  1541. $info["checkStateName"] = "待提交";
  1542. }
  1543. if ($info["checkState"] == HouseStateEnum::NEED_CHECK) {
  1544. $info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
  1545. }
  1546. if ($info["checkState"] == HouseStateEnum::FIRST_REJECT) {
  1547. $info["checkStateName"] = "已驳回";
  1548. }
  1549. if ($info["checkState"] == HouseStateEnum::REJECT_TO_FIRST || $info["checkState"] == HouseStateEnum::DEP_REJECT) {
  1550. $info["checkStateName"] = "上级驳回";
  1551. }
  1552. if ($info["checkState"] == HouseStateEnum::NEED_DEP_CHECK || $info["checkState"] >= HouseStateEnum::REJECT_TO_DEP) {
  1553. $info["checkStateName"] = "已通过";
  1554. }
  1555. break;
  1556. case 2:
  1557. if ($info["state"] == 1) {
  1558. $info["checkStateName"] = "待审核";
  1559. }
  1560. if ($info["state"] == 2) {
  1561. $info["checkStateName"] = "已驳回";
  1562. }
  1563. if ($info["state"] == 3) {
  1564. $info["checkStateName"] = "已通过";
  1565. }
  1566. if ($info["state"] == 4) {
  1567. $info["checkStateName"] = "上级驳回";
  1568. }
  1569. if ($info["state"] == 9) {
  1570. $info["checkStateName"] = "重新提交";
  1571. }
  1572. break;
  1573. case 3:
  1574. if ($info["checkState"] <= HouseStateEnum::REJECT_TO_DEP) {
  1575. $info["checkStateName"] = "已驳回";
  1576. } else if ($info["checkState"] == HouseStateEnum::NEED_REVIEW_CHECK) {
  1577. $info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
  1578. } else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
  1579. $info["checkStateName"] = "已通过";
  1580. }
  1581. break;
  1582. case 4:
  1583. if ($info["checkState"] == HouseStateEnum::NOTPASS) {
  1584. $info["checkStateName"] = "审核不通过";
  1585. } else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
  1586. $info["checkStateName"] = "已通过";
  1587. }
  1588. break;
  1589. }
  1590. }unset($info);
  1591. return $list;
  1592. }
  1593. private function getCheckStateName($checkState, $publicState, $allowanceType) {
  1594. switch ($checkState) {
  1595. case 1:
  1596. return "待提交";
  1597. case 5:
  1598. case 13:
  1599. case 15:
  1600. case 20:
  1601. case 25:
  1602. case 35:
  1603. return "审核中";
  1604. case 10:
  1605. return "已驳回";
  1606. case - 1:
  1607. if ($publicState >= 3) {
  1608. return "审核不通过";
  1609. } else {
  1610. return "审核中";
  1611. }
  1612. break;
  1613. case 30:
  1614. if ($publicState == 1) {
  1615. return "待核查征信";
  1616. } else if ($publicState == 2) {
  1617. return "待公示";
  1618. } else if ($publicState == 3) {
  1619. return "公示中";
  1620. } else if ($publicState == 4) {
  1621. return $allowanceType != 3 ? "待兑现" : "不予兑现";
  1622. } else if ($publicState == 5) {
  1623. return "已兑现";
  1624. }
  1625. default:
  1626. return "未知状态";
  1627. }
  1628. }
  1629. /**
  1630. * @param old
  1631. * @param type 1-复核阶段,不生成享受人的剩余享受金额记录,2-公示再审核阶段,生成享受记录
  1632. * @description 计算购房补贴金额
  1633. * */
  1634. private function calculate($old, $type) {
  1635. $housepurchase = [];
  1636. $descideDesc = [];
  1637. $count = $old["type"] == 1 ? 5 : 3; //最大申报数
  1638. /* * 1、查询申报人和配偶的房产信息 */
  1639. $houseInfo = HouseApi::getHouseInfo($old["idCard"]);
  1640. $spouseHouseInfo = HouseApi::getHouseInfo($old["spouseIdCard"]);
  1641. if (!$houseInfo) {
  1642. $houseInfo = [
  1643. "idCard" => $old["idCard"],
  1644. "spouseIdCard" => null,
  1645. "houseAddress" => $old["houseAddress"],
  1646. "houseArea" => $old["houseArea"],
  1647. "houseMoney" => $old["houseMoney"],
  1648. "recordTime" => $old["recordTime"],
  1649. "realEstateNo" => $old["realEstateNo"],
  1650. "recordNo" => $old["recordNo"],
  1651. "balanceMoney" => $old["houseMoney"],
  1652. "count" => 0,
  1653. "lastYearArrears" => 0
  1654. ];
  1655. }
  1656. //判断是否超过五次申报
  1657. if ($houseInfo["count"] >= $count) {
  1658. return new Response(Response::ERROR, "申报人已享受五次购房补贴,无法再次享受");
  1659. }
  1660. if ($houseInfo["balanceMoney"] <= 0) {
  1661. return new Response(Response::ERROR, "申报房产可享受余额不足,无法享受");
  1662. }
  1663. /* * 2.查询购房补贴费用标准,根据人才层次计算可享受金额 */
  1664. $amountStandard = \app\common\api\AmountStandardApi::getStandard($this->user["type"], 3, $old["talentArrange"]);
  1665. if (!$amountStandard)
  1666. return new Response(Response::ERROR, "系统暂未设置该人才层次的购房补贴享受金额,请设置后再提交");
  1667. if ($old["type"] == 1) {
  1668. $housepurchase["talentArrangeMoney"] = round(0.2 * $amountStandard["money"], 2);
  1669. } else {
  1670. $code = "housepurchase_percentage_";
  1671. switch ($old["type"]) {
  1672. case CommonConst::ENTERPRISE_JC:
  1673. $code .= "ic";
  1674. break;
  1675. case CommonConst::ENTERPRISE_WJ:
  1676. $code .= "wj";
  1677. break;
  1678. case CommonConst::ENTERPRISE_GJ:
  1679. $code .= "gj";
  1680. break;
  1681. }
  1682. $dic = DictApi::findByParentCodeAndCode($code, $houseInfo["count"] + 1);
  1683. if (!$dic)
  1684. return new Response(Response::ERROR, "系统字典中暂未设置购房补贴年度比例,请设置后再提交。字典代码以[集成电路:housepurchase_percentage_ic][卫健:housepurchase_percentage_wj][高教:housepurchase_percentage_gj]为准");
  1685. if (!is_numeric($dic["name"]) || $dic["name"] > 1 || $dic["name"] < 0)
  1686. return new Response(Response::ERROR, "系统字典中设置的购房补贴年度比例应该是介于0~1之间的数字");
  1687. $housepurchase["talentArrangeMoney"] = round($dic["name"] * $amountStandard["money"], 2);
  1688. }
  1689. /* * 3.计算当年度录入享受其他政策的金额 */
  1690. $otherList = HouseApi::getEnjoyOtherList($old["id"]);
  1691. $housepurchase["nowOtherMoney"] = 0;
  1692. foreach ($otherList as $other) {
  1693. $housepurchase["nowOtherMoney"] += $other["money"];
  1694. }
  1695. $lastOtherMoney = $spouseHouseInfo ? $houseInfo["lastYearArrears"] + $spouseHouseInfo["lastYearArrears"] : $houseInfo["lastYearArrears"];
  1696. $housepurchase["lastOtherMoney"] = round($lastOtherMoney, 2);
  1697. $totalOtherMoney = round($housepurchase["nowOtherMoney"] + $housepurchase["lastOtherMoney"], 2);
  1698. /* * 计算当前人才层次可享受金额 */
  1699. $balanceMoney = round($amountStandard["money"] - ($houseInfo["houseMoney"] - $houseInfo["balanceMoney"]), 2);
  1700. /* * 判断余额 */
  1701. $balanceMoney = $balanceMoney >= $houseInfo["balanceMoney"] ? $houseInfo["balanceMoney"] : $balanceMoney;
  1702. if ($balanceMoney <= 0) {
  1703. $descideDesc[] = "可享受余额为:" . $balanceMoney . "元;";
  1704. /* * 判断享受其他政策是否大于0 */
  1705. if ($totalOtherMoney > 0) {
  1706. $housepurchase["isRecover"] = 1;
  1707. $descideDesc[] = "需要追讨金额为:" . $totalOtherMoney . "元;";
  1708. }
  1709. $housepurchase["shouldEnjoyMoney"] = 0;
  1710. $housepurchase["realEnjoyMoney"] = 0;
  1711. $housepurchase["nowSubOtherMoney"] = 0;
  1712. $housepurchase["nowNotSubOtherMoney"] = $totalOtherMoney;
  1713. } else {
  1714. /* * 比较余额和人才层次金额的20% */
  1715. $housepurchase["shouldEnjoyMoney"] = $balanceMoney >= $housepurchase["talentArrangeMoney"] ? $housepurchase["talentArrangeMoney"] : $balanceMoney;
  1716. /* * 计算可享受金额 */
  1717. $realEnjoyMoney = $housepurchase["shouldEnjoyMoney"] - $totalOtherMoney;
  1718. if ($realEnjoyMoney == 0) {
  1719. $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
  1720. $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
  1721. $housepurchase["nowNotSubOtherMoney"] = $realEnjoyMoney;
  1722. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
  1723. } else if ($realEnjoyMoney > 0) {
  1724. $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
  1725. $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
  1726. $housepurchase["nowNotSubOtherMoney"] = 0;
  1727. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
  1728. } else if ($realEnjoyMoney < 0) {
  1729. $housepurchase["isRecover"] = 1;
  1730. $descideDesc[] = "需要追讨金额为:" . abs($realEnjoyMoney) . "元;";
  1731. $housepurchase["realEnjoyMoney"] = 0;
  1732. $housepurchase["nowSubOtherMoney"] = $housepurchase["shouldEnjoyMoney"];
  1733. $housepurchase["nowNotSubOtherMoney"] = abs($realEnjoyMoney);
  1734. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录并生成新的未扣除记录 */
  1735. }
  1736. if ($type == 2) {
  1737. $houseInfo["count"] = $houseInfo["count"] + 1;
  1738. $houseInfo["balanceMoney"] = round($houseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"], 2);
  1739. $houseInfo["lastYearArrears"] = $housepurchase["nowSubOtherMoney"];
  1740. if (\StrUtil::isNotEmpAndNull($housepurchase["spouseIdcard"])) {
  1741. if (!$spouseHouseInfo) {
  1742. $spouseHouseInfo = [
  1743. "idCard" => $old["spouseIdcard"],
  1744. "spouseIdCard" => null,
  1745. "houseAddress" => $old["houseAddress"],
  1746. "houseArea" => $old["houseArea"],
  1747. "houseMoney" => $old["houseMoney"],
  1748. "recordTime" => $old["recordTime"],
  1749. "realEstateNo" => $old["realEstateNo"],
  1750. "recordNo" => $old["recordNo"],
  1751. "balanceMoney" => $houseInfo["balanceMoney"],
  1752. "count" => $houseInfo["count"],
  1753. "lastYearArrears" => $houseInfo["lastYearArrears"]
  1754. ];
  1755. } else {
  1756. $spouseHouseInfo["count"] = $spouseHouseInfo["count"] + 1;
  1757. $spouseHouseInfo["lastYearArrears"] = $houseInfo["lastYearArrears"];
  1758. $spouseHouseInfo["balanceMoney"] = $spouseHouseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"];
  1759. }
  1760. if ($spouseHouseInfo["id"]) {
  1761. $spouseHouseInfo["updateTime"] = date("Y-m-d H:i:s");
  1762. $spouseHouseInfo["updateUser"] = $this->user["uid"];
  1763. houseInfoModel::update($spouseHouseInfo);
  1764. } else {
  1765. $spouseHouseInfo["id"] = getStringId();
  1766. $spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
  1767. $spouseHouseInfo["createUser"] = $this->user["uid"];
  1768. houseInfoModel::insert($spouseHouseInfo);
  1769. }
  1770. }
  1771. if ($houseInfo["id"]) {
  1772. $houseInfo["updateTime"] = date("Y-m-d H:i:s");
  1773. $houseInfo["updateUser"] = $this->user["uid"];
  1774. houseInfoModel::update($houseInfo);
  1775. } else {
  1776. $houseInfo["id"] = getStringId();
  1777. $houseInfo["createTime"] = date("Y-m-d H:i:s");
  1778. $houseInfo["createUser"] = $this->user["uid"];
  1779. houseInfoModel::insert($houseInfo);
  1780. }
  1781. }
  1782. }
  1783. $housepurchase["decideDetail"] = implode("", $descideDesc);
  1784. return new Response(Response::SUCCESS, "", $housepurchase);
  1785. }
  1786. }