House.php 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330
  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. */
  155. public function check() {
  156. $id = $this->request["id"];
  157. $process = $this->request["process"];
  158. $toProcess = $this->request["toProcess"];
  159. $toDep = $this->request["toDep"];
  160. $checkState = $this->request["checkState"];
  161. $checkMsg = $this->request["checkMsg"];
  162. $cashType = $this->request["cashType"];
  163. $fields = $this->request["fields"];
  164. $files = $this->request["files"];
  165. if (!$checkState) {
  166. return new Response(Response::ERROR, "请选择审核状态");
  167. }
  168. if ($process == 1) {
  169. $old = HouseApi::getInfoById($id);
  170. $old["fields"] = $fields;
  171. $old["files"] = $files;
  172. houseModel::update($old);
  173. }
  174. if ($process == 3) {
  175. $data["id"] = $id;
  176. if ($checkState == 2) {
  177. if ($toProcess == 2) {
  178. $depCodes = getJsonConfig("../sys_config.json", "housepurchase_dep_list")[$old["type"]];
  179. if (!$depCodes || count($depCodes) == 0) {
  180. return new Response(Response::ERROR, "没有配置部门审核,不能选择驳回至部门审核");
  181. }
  182. $where = [];
  183. $where[] = ["code", "in", $toDep];
  184. $companyIds = \app\common\model\Company::where($where)->column("id");
  185. $data["toDep"] = implode(",", $companyIds);
  186. }
  187. $data["toProcess"] = $toProcess;
  188. }
  189. if ($checkState == 3) {
  190. $data["cashType"] = $cashType;
  191. }
  192. houseModel::update($data);
  193. }
  194. //添加日志
  195. TalentChecklog::create([
  196. 'id' => getStringId(),
  197. 'mainId' => $id,
  198. 'type' => intval(ProjectState::HOUSE),
  199. 'typeFileId' => null,
  200. 'active' => 2,
  201. 'state' => $checkState,
  202. 'step' => $process,
  203. 'stateChange' => "保存未提交",
  204. 'description' => $checkMsg,
  205. 'createTime' => date("Y-m-d H:i:s", time()),
  206. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  207. ]);
  208. return new Response(Response::SUCCESS, "审核成功");
  209. }
  210. /**
  211. * @param obj
  212. * @description 住建局审核
  213. * */
  214. public function zjjCheck() {
  215. $obj = [
  216. "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
  217. "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
  218. "checkIsTradeRecord" => \StrUtil::getRequestDecodeParam($this->request, "checkIsTradeRecord"),
  219. "checkRecordTime" => \StrUtil::getRequestDecodeParam($this->request, "checkRecordTime"),
  220. "zjjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zjjCheckDetail"),
  221. "otherList" => $this->request["otherList"],
  222. "houseList" => $this->request["houseList"]
  223. ];
  224. if (!$obj) {
  225. return new Response(Response::ERROR, "请填写信息后保存");
  226. }
  227. $mzj = \app\common\model\Company::where("code", CommonConst::MZJ)->find();
  228. $where = [];
  229. $where[] = ["mainId", "=", $obj["id"]];
  230. $where[] = ["companyId", "=", $mzj["id"]];
  231. $depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
  232. if ($depcheckstate["state"] != 3) {
  233. return new Response(Response::ERROR, "请等待民政局录入婚姻信息后,根据婚姻信息查询!");
  234. }
  235. $where = [];
  236. $where[] = ["mainId", "=", $obj["id"]];
  237. $where[] = ["companyId", "=", $obj["companyId"]];
  238. $oldDep = Db::table("un_talent_depcheckstate")->where($where)->find();
  239. if ($oldDep["state"] != 1 && $oldDep["state"] != 4 && $oldDep["state"] != 9) {
  240. return new Response(Response::ERROR, "不在审核范围内!");
  241. }
  242. $old = HouseApi::getInfoById($obj["id"]);
  243. if ($old["declareType"] == 1) {
  244. if ($obj["checkIsTradeRecord"] == 1 && \StrUtil::isEmpOrNull($obj["checkRecordTime"])) {
  245. return new Response(Response::ERROR, "请填写交易备案时间");
  246. }
  247. } else {
  248. $obj["checkIsTradeRecord"] = null;
  249. $obj["checkRecordTime"] = "";
  250. }
  251. if ($obj["otherList"] && count($obj["otherList"]) > 0) {
  252. foreach ($obj["otherList"] as $other) {
  253. if ($other["id"]) {
  254. $other["updateTime"] = date("Y-m-d H:i:s");
  255. $other["updateUser"] = $this->user["name"];
  256. \app\common\model\HousePurchaseEnjoyOther::update($other);
  257. } else {
  258. $other["id"] = getStringId();
  259. $other["pId"] = $obj["id"];
  260. $other["createTime"] = date("Y-m-d H:i:s");
  261. $other["createUser"] = $this->user["name"];
  262. \app\common\model\HousePurchaseEnjoyOther::insert($other);
  263. }
  264. }
  265. }
  266. if ($obj["houseList"] && count($obj["houseList"]) > 0) {
  267. foreach ($obj["houseList"] as $house) {
  268. if ($house["id"]) {
  269. $house["updateTime"] = date("Y-m-d H:i:s");
  270. $house["updateUser"] = $this->user["name"];
  271. \app\common\model\HousePurchaseOtherHouse::update($house);
  272. } else {
  273. $house["id"] = getStringId();
  274. $house["pId"] = $obj["id"];
  275. $house["createTime"] = date("Y-m-d H:i:s");
  276. $house["createUser"] = $this->user["name"];
  277. \app\common\model\HousePurchaseOtherHouse::insert($house);
  278. }
  279. }
  280. }
  281. houseModel::update($obj);
  282. TalentChecklog::create([
  283. 'id' => getStringId(),
  284. "companyId" => $obj["companyId"],
  285. 'mainId' => $obj["id"],
  286. 'type' => intval(ProjectState::HOUSE),
  287. 'typeFileId' => null,
  288. 'active' => 2,
  289. 'state' => 3,
  290. 'step' => 2,
  291. 'stateChange' => "保存未提交",
  292. 'description' => $obj["zjjCheckDetail"] ? "录入核查数据:" . $obj["zjjCheckDetail"] : "录入核查数据:",
  293. 'createTime' => date("Y-m-d H:i:s", time()),
  294. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  295. ]);
  296. return new Response(Response::SUCCESS, "审核成功", $obj);
  297. }
  298. /**
  299. * @param obj
  300. * @description 自然资源局核查
  301. * */
  302. public function zrzyjCheck() {
  303. $obj = [
  304. "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
  305. "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
  306. "isHasBdcCard" => \StrUtil::getRequestDecodeParam($this->request, "isHasBdcCard"),
  307. "bdcRegistTime" => \StrUtil::getRequestDecodeParam($this->request, "bdcRegistTime"),
  308. "isOwner" => \StrUtil::getRequestDecodeParam($this->request, "isOwner"),
  309. "transferMethod" => \StrUtil::getRequestDecodeParam($this->request, "transferMethod"),
  310. "transferTime" => \StrUtil::getRequestDecodeParam($this->request, "transferTime"),
  311. "zrzzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zrzzjCheckDetail"),
  312. "houseList" => $this->request["houseList"]
  313. ];
  314. if (!$obj) {
  315. return new Response(Response::ERROR, "请填写信息后保存");
  316. }
  317. $mzj = \app\common\model\Company::where("code", CommonConst::MZJ)->find();
  318. $where = [];
  319. $where[] = ["mainId", "=", $obj["id"]];
  320. $where[] = ["companyId", "=", $mzj["id"]];
  321. $depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
  322. if ($depcheckstate["state"] != 3) {
  323. return new Response(Response::ERROR, "请等待民政局录入婚姻信息后,根据婚姻信息查询!");
  324. }
  325. $where = [];
  326. $where[] = ["mainId", "=", $obj["id"]];
  327. $where[] = ["companyId", "=", $obj["companyId"]];
  328. $oldDep = Db::table("un_talent_depcheckstate")->where($where)->find();
  329. if ($oldDep["state"] != 1 && $oldDep["state"] != 4 && $oldDep["state"] != 9) {
  330. return new Response(Response::ERROR, "不在审核范围内!");
  331. }
  332. $old = HouseApi::getInfoById($obj["id"]);
  333. if ($old["declareType"] == 1) {
  334. if ($obj["isHasBdcCard"] == 1 && \StrUtil::isEmpOrNull($obj["bdcRegistTime"])) {
  335. return new Response(Response::ERROR, "请填写不动产权证书登记时间");
  336. }
  337. if (!$obj["isOwner"]) {
  338. return new Response(Response::ERROR, "请选择其购置的房屋是否还在名下");
  339. }
  340. if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferMethod"])) {
  341. return new Response(Response::ERROR, "请填写过户方式");
  342. }
  343. if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferTime"])) {
  344. return new Response(Response::ERROR, "请填写过户时间");
  345. }
  346. } else {
  347. $obj["isHasBdcCard"] = null;
  348. $obj["bdcRegistTime"] = "";
  349. $obj["isOwner"] = null;
  350. $obj["transferMethod"] = "";
  351. $obj["transferTime"] = "";
  352. }
  353. if ($obj["houseList"] && count($obj["houseList"]) > 0) {
  354. foreach ($obj["houseList"] as $house) {
  355. if ($house["id"]) {
  356. $house["updateTime"] = date("Y-m-d H:i:s");
  357. $house["updateUser"] = $this->user["name"];
  358. \app\common\model\HousePurchaseOtherHouse::update($house);
  359. } else {
  360. $house["id"] = getStringId();
  361. $house["pId"] = $obj["id"];
  362. $house["createTime"] = date("Y-m-d H:i:s");
  363. $house["createUser"] = $this->user["name"];
  364. \app\common\model\HousePurchaseOtherHouse::insert($house);
  365. }
  366. }
  367. }
  368. houseModel::update($obj);
  369. TalentChecklog::create([
  370. 'id' => getStringId(),
  371. "companyId" => $obj["companyId"],
  372. 'mainId' => $obj["id"],
  373. 'type' => intval(ProjectState::HOUSE),
  374. 'typeFileId' => null,
  375. 'active' => 2,
  376. 'state' => 3,
  377. 'step' => 2,
  378. 'stateChange' => "保存未提交",
  379. 'description' => $obj["zrzzjCheckDetail"] ? "录入核查数据:" . $obj["zrzzjCheckDetail"] : "录入核查数据",
  380. 'createTime' => date("Y-m-d H:i:s", time()),
  381. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  382. ]);
  383. return new Response(Response::SUCCESS, "审核成功", $obj);
  384. }
  385. /**
  386. * @param obj
  387. * @description 民政局核查
  388. * */
  389. public function mzjCheck() {
  390. $obj = [
  391. "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
  392. "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
  393. "mzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "mzjCheckDetail"),
  394. "spouseList" => $this->request["spouseList"]
  395. ];
  396. if (!$obj) {
  397. return new Response(Response::ERROR, "请填写信息后保存");
  398. }
  399. $where = [];
  400. $where[] = ["mainId", "=", $obj["id"]];
  401. $where[] = ["companyId", "=", $obj["companyId"]];
  402. $oldDep = Db::table("un_talent_depcheckstate")->where($where)->find();
  403. if ($oldDep["state"] != 1 && $oldDep["state"] != 4 && $oldDep["state"] != 9) {
  404. return new Response(Response::ERROR, "不在审核范围内!");
  405. }
  406. if ($obj["spouseList"] && count($obj["spouseList"]) > 0) {
  407. foreach ($obj["spouseList"] as $spouse) {
  408. if ($spouse["id"]) {
  409. $spouse["updateTime"] = date("Y-m-d H:i:s");
  410. $spouse["updateUser"] = $this->user["name"];
  411. \app\common\model\HousePurchaseSpouse::update($spouse);
  412. } else {
  413. $spouse["id"] = getStringId();
  414. $spouse["pId"] = $obj["id"];
  415. $spouse["createTime"] = date("Y-m-d H:i:s");
  416. $spouse["createUser"] = $this->user["name"];
  417. \app\common\model\HousePurchaseSpouse::insert($spouse);
  418. }
  419. }
  420. }
  421. houseModel::update($obj);
  422. TalentChecklog::create([
  423. 'id' => getStringId(),
  424. "companyId" => $obj["companyId"],
  425. 'mainId' => $obj["id"],
  426. 'type' => intval(ProjectState::HOUSE),
  427. 'typeFileId' => null,
  428. 'active' => 2,
  429. 'state' => 3,
  430. 'step' => 2,
  431. 'stateChange' => "保存未提交",
  432. 'description' => $obj["mzjCheckDetail"] ? "录入核查数据:" . $obj["mzjCheckDetail"] : "录入核查数据:",
  433. 'createTime' => date("Y-m-d H:i:s", time()),
  434. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  435. ]);
  436. return new Response(Response::SUCCESS, "审核成功", $obj);
  437. }
  438. /**
  439. * @param obj
  440. * @description 部门审核
  441. * */
  442. public function depCheck() {
  443. $obj = [
  444. "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
  445. "companyId" => \StrUtil::getRequestDecodeParam($this->request, "companyId"),
  446. "description" => \StrUtil::getRequestDecodeParam($this->request, "description")
  447. ];
  448. $desc = $obj["description"];
  449. $company = getCacheById("Company", $obj["companyId"]);
  450. switch ($company["code"]) {
  451. case CommonConst::ZJJ:
  452. $obj["zjjCheckDetail"] = $obj["description"];
  453. break;
  454. case CommonConst::ZRZYJ:
  455. $obj["zrzzjCheckDetail"] = $obj["description"];
  456. break;
  457. case CommonConst::MZJ:
  458. $obj["mzjCheckDetail"] = $obj["description"];
  459. break;
  460. }
  461. $obj["description"] = "";
  462. houseModel::update($obj);
  463. TalentChecklog::create([
  464. 'id' => getStringId(),
  465. "companyId" => $obj["companyId"],
  466. 'mainId' => $obj["id"],
  467. 'type' => intval(ProjectState::HOUSE),
  468. 'typeFileId' => null,
  469. 'active' => 2,
  470. 'state' => 3,
  471. 'step' => 2,
  472. 'stateChange' => "保存未提交",
  473. 'description' => sprintf("录入核查数据(%s):%s", $company["name"], $desc),
  474. 'createTime' => date("Y-m-d H:i:s", time()),
  475. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  476. ]);
  477. return new Response(Response::SUCCESS, "审核成功");
  478. }
  479. /**
  480. * @param id
  481. * @param type
  482. * @description 删除享受其他政策记录/历年享受记录
  483. * */
  484. public function deleteOtherOrHouse($id, $type) {
  485. if (\StrUtil::isEmpOrNull($id)) {
  486. return new Response(Response::ERROR, "系统错误");
  487. }
  488. if ($type == 1) { //享受其他政策
  489. \app\common\model\HousePurchaseEnjoyOther::where("id", $id)->delete();
  490. } else if (type == 2) { //其他房产信息
  491. \app\common\model\HousePurchaseOtherHouse::where("id", $id)->delete();
  492. }
  493. return new Response(Response::SUCCESS, "删除成功");
  494. }
  495. /**
  496. * @param id
  497. * @description 删除配偶信息
  498. * */
  499. public function deleteSpouse($id) {
  500. if (\StrUtil::isEmpOrNull($id)) {
  501. return new Response(Response::ERROR, "系统错误");
  502. }
  503. \app\common\model\HousePurchaseSpouse::where("id", $id)->delete();
  504. return new Response(Response::SUCCESS, "删除成功");
  505. }
  506. /**
  507. * 提交审核
  508. * @return Response
  509. */
  510. public function submitCheck() {
  511. $id = $this->request["id"];
  512. $process = $this->request["process"];
  513. $companyId = $this->request["companyId"];
  514. if ($process != 2) {
  515. $companyId = null;
  516. }
  517. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $companyId);
  518. if (!$log) {
  519. return new Response(Response::ERROR, "请先审核后再提交");
  520. }
  521. $checkState = $log["state"];
  522. $housepurchase = [];
  523. $housepurchase["id"] = $id;
  524. $housepurchase["checkMsg"] = $log["description"];
  525. $old = HouseApi::getInfoById($id);
  526. //判断到达的最高流程
  527. $housepurchase["highProcess"] = $old["highProcess"] == null ? $process : ($old["highProcess"] < $process ? $process : $old["highProcess"]);
  528. switch ($process) {
  529. case 1:
  530. if ($checkState == -1) {
  531. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  532. $housepurchase["realEnjoyMoney"] = 0;
  533. }
  534. if ($checkState == 2) {
  535. $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
  536. }
  537. if ($checkState == 3) { //审核通过
  538. $depCount = Db::table("un_talent_depcheckstate")->where("mainId", $id)->count();
  539. if ($depCount > 0) {
  540. $where = [];
  541. $where[] = ["mainId", "=", $id];
  542. $where[] = ["state", "=", 2];
  543. $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  544. if ($rejectCount > 0) {
  545. $updDep["state"] = 9;
  546. $updDep["updateTime"] = date("Y-m-d H:i:s");
  547. $updDep["updateUser"] = $this->user["name"];
  548. Db::table("un_talent_depcheckstate")->where($where)->update($updDep);
  549. $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
  550. } else {
  551. $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  552. }
  553. } else {
  554. /* * 生成各部门数据审核 */
  555. $depList = [];
  556. $depCodes = getJsonConfig("../sys_config.json", "housepurchase_dep_list")[$old["type"]];
  557. if ($depCodes && count($depCodes) > 0) {
  558. $where = [];
  559. $where[] = ["code", "in", $depCodes];
  560. $companies = \app\common\model\Company::where($where)->select()->toArray();
  561. foreach ($companies as $company) {
  562. $depList[] = [
  563. "id" => getStringId(),
  564. "type" => ProjectState::HOUSE,
  565. "mainId" => $id,
  566. "companyId" => $company["id"],
  567. "state" => 1,
  568. "createTime" => date("Y-m-d H:i:s"),
  569. "createUser" => $this->user["name"]
  570. ];
  571. }
  572. Db::table("un_talent_depcheckstate")->insertAll($depList);
  573. $housepurchase["checkState"] = HouseStateEnum::NEED_DEP_CHECK;
  574. } else {
  575. if (\StrUtil::isEmpOrNull($old["depPassTime"])) {
  576. $housepurchase["depPassTime"] = date("Y-m-d H:i:s");
  577. }
  578. $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  579. }
  580. }
  581. if (\StrUtil::isEmpOrNull($old["firstPassTime"])) {
  582. $housepurchase["firstPassTime"] = date("Y-m-d H:i:s");
  583. }
  584. /* * 判断夫妻是否同时申报 */
  585. if (\StrUtil::isNotEmpAndNull($old["spouseIdcard"])) {
  586. $where = [];
  587. $where[] = ["idCard", "=", $old["spouseIdcard"]];
  588. $where[] = ["year", "=", $old["year"]];
  589. $where[] = ["delete", "=", 0];
  590. $count = houseModel::where($where)->count();
  591. $housepurchase["isConflict"] = $count > 0 ? 1 : 2;
  592. }
  593. }
  594. //添加日志
  595. TalentChecklog::create([
  596. 'id' => getStringId(),
  597. 'mainId' => $id,
  598. 'type' => intval(ProjectState::HOUSE),
  599. 'typeFileId' => null,
  600. 'active' => 1,
  601. 'state' => $checkState,
  602. 'step' => $process,
  603. 'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
  604. 'description' => $log["description"],
  605. 'createTime' => date("Y-m-d H:i:s", time()),
  606. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  607. ]);
  608. $where = [];
  609. $where[] = ["mainId", "=", $id];
  610. $where[] = ["active", "=", 2];
  611. TalentChecklog::where($where)->delete();
  612. houseModel::update($housepurchase);
  613. break;
  614. case 2:
  615. $where = [];
  616. $where[] = ["mainId", "=", $id];
  617. $where[] = ["companyId", "=", $companyId];
  618. $tds = Db::table("un_talent_depcheckstate")->where($where)->find();
  619. $tds["state"] = 3;
  620. $tds["submitTime"] = date("Y-m-d H:i:s");
  621. Db::table("un_talent_depcheckstate")->update($tds);
  622. //判断所有部门是否全部通过
  623. $where = [];
  624. $where[] = ["mainId", "=", $id];
  625. $where[] = ["state", "in", [1, 4, 9]];
  626. $needCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  627. if ($needCount == 0) {
  628. $where = [];
  629. $where[] = ["mainId", "=", $id];
  630. $where[] = ["state", "=", 2];
  631. $rejectCount = Db::table("un_talent_depcheckstate")->where($where)->count();
  632. if ($rejectCount > 0) {
  633. $housepurchase["checkState"] = HouseStateEnum::DEP_REJECT;
  634. } else {
  635. if (\StrUtil::isEmpOrNull($old["depPassTime"])) {
  636. $housepurchase["depPassTime"] = date("Y-m-d H:i:s");
  637. }
  638. $housepurchase["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  639. }
  640. houseModel::update($housepurchase);
  641. }
  642. //添加日志
  643. TalentChecklog::create([
  644. 'id' => getStringId(),
  645. 'mainId' => $id,
  646. 'type' => intval(ProjectState::HOUSE),
  647. "companyId" => $companyId,
  648. 'typeFileId' => null,
  649. 'active' => 1,
  650. 'state' => 3,
  651. 'step' => $process,
  652. 'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
  653. 'description' => $log["description"],
  654. 'createTime' => date("Y-m-d H:i:s", time()),
  655. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  656. ]);
  657. $where = [];
  658. $where[] = ["mainId", "=", $id];
  659. $where[] = ["active", "=", 2];
  660. $where[] = ["companyId", "=", $companyId];
  661. TalentChecklog::where($where)->delete();
  662. break;
  663. case 3:
  664. if ($checkState == -1) {
  665. $housepurchase["checkState"] = HouseStateEnum::NOTPASS;
  666. $housepurchase["cashType"] = 2;
  667. $housepurchase["realEnjoyMoney"] = 0;
  668. }
  669. if ($checkState == 2) {
  670. $where = [];
  671. $where[] = ["mainId", "=", $id];
  672. $where[] = ["companyId", "in", $old["toDep"]];
  673. if ($old["toProcess"] == -1) {
  674. $housepurchase["checkState"] = HouseStateEnum::FIRST_REJECT;
  675. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  676. $updTds["state"] = 2;
  677. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  678. }
  679. }
  680. if ($old["toProcess"] == 1) {
  681. $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_FIRST;
  682. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  683. $updTds["state"] = 2;
  684. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  685. }
  686. } else if ($old["toProcess"] == 2) {
  687. $housepurchase["checkState"] = HouseStateEnum::REJECT_TO_DEP;
  688. if (\StrUtil::isNotEmpAndNull($old["toDep"])) {
  689. $updTds["state"] = 4;
  690. Db::table("un_talent_depcheckstate")->where($where)->update($updTds);
  691. }
  692. }
  693. }
  694. if ($checkState == 3) {
  695. /**
  696. * 通过需要判定补贴类型及享受金额
  697. * */
  698. $where = [];
  699. $where[] = ["idCard", "=", $old["idCard"]];
  700. $where[] = ["year", "=", $old["year"]];
  701. $where[] = ["delete", "=", 0];
  702. $info = \app\common\model\TalentAllowance::where($where)->find();
  703. if ($info["checkState"] == \app\common\state\AllowanceStateEnum::REVIEW_PASS && $info["publicState"] == 4) {
  704. $housepurchase["allowanceType"] = $info["allowanceType"];
  705. }
  706. $housepurchase["cashType"] = $old["cashType"];
  707. $descideDesc[] = "审核意见:" . $log["description"] . ";";
  708. $housepurchase["checkState"] = HouseStateEnum::REVIEW_PASS;
  709. if ($old["declareType"] == 1) { //购房补贴
  710. /* * 对需要兑现的计算享受金额 */
  711. if ($housepurchase["cashType"] == 1) {
  712. $result = $this->calculate($old, $housepurchase, $descideDesc, 1);
  713. if ($result->code == 500) {
  714. return $result;
  715. }
  716. }
  717. }
  718. $housepurchase["decideDetail"] = implode("", $descideDesc);
  719. if (\StrUtil::isEmpOrNull($old["reviewPassTime"])) {
  720. $housepurchase["reviewPassTime"] = date("Y-m-d H:i:s");
  721. }
  722. }
  723. //添加日志
  724. TalentChecklog::create([
  725. 'id' => getStringId(),
  726. 'mainId' => $id,
  727. 'type' => intval(ProjectState::HOUSE),
  728. 'typeFileId' => null,
  729. 'active' => 1,
  730. 'state' => $checkState,
  731. 'step' => $process,
  732. 'stateChange' => sprintf("%s->%s", HouseStateEnum::getStateName($old["checkState"]), HouseStateEnum::getStateName($housepurchase["checkState"])),
  733. 'description' => $log["description"],
  734. 'createTime' => date("Y-m-d H:i:s", time()),
  735. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  736. ]);
  737. $where = [];
  738. $where[] = ["mainId", "=", $id];
  739. $where[] = ["active", "=", 2];
  740. TalentChecklog::where($where)->delete();
  741. houseModel::update($housepurchase);
  742. break;
  743. }
  744. return new Response(Response::SUCCESS, "提交审核成功");
  745. }
  746. /**
  747. * 撤销审核
  748. * @return \app\admin\controller\ResponseObj
  749. */
  750. public function cancleThirdCheck() {
  751. $id = $this->request["id"];
  752. $checkMsg = $this->request["checkMsg"];
  753. if (\StrUtil::isEmpOrNull($id)) {
  754. return new Response(Response::ERROR, "请选择需要撤销的对象");
  755. }
  756. $old = HouseApi::getInfoById($id);
  757. if ($old["checkState"] != HouseStateEnum::REVIEW_PASS) {
  758. return new Response(Response::ERROR, "当前对象不是复核通过状态,无法撤销");
  759. }
  760. if ($old["publicState"] != 1) {
  761. return new Response(Response::ERROR, "当前对象不是待公示状态,无法撤销");
  762. }
  763. $data["id"] = $id;
  764. $data["checkMsg"] = $checkMsg;
  765. $data["checkState"] = HouseStateEnum::NEED_REVIEW_CHECK;
  766. $data["cashIdCards"] = "";
  767. $data["cashType"] = null;
  768. $data["decideMoneyDetail"] = "";
  769. $data["decideDetail"] = "";
  770. $where = [];
  771. $where[] = ["mainId", "=", $id];
  772. $count = Db::table("un_talent_depcheckstate")->where($where)->count();
  773. $data["highProcess"] = $count > 0 ? 2 : 1;
  774. //添加日志
  775. TalentChecklog::create([
  776. 'id' => getStringId(),
  777. 'mainId' => $id,
  778. 'type' => intval(ProjectState::HOUSE),
  779. 'typeFileId' => null,
  780. 'active' => 1,
  781. 'state' => 11,
  782. 'step' => 3,
  783. 'stateChange' => HouseStateEnum::getStateName($old["checkState"]) . "->" . HouseStateEnum::getStateName($data["checkState"]),
  784. 'description' => "撤销原因:" . $checkMsg,
  785. 'createTime' => date("Y-m-d H:i:s", time()),
  786. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  787. ]);
  788. houseModel::update($data);
  789. return new Response(Response::SUCCESS, "撤销成功");
  790. }
  791. /**
  792. * @param type
  793. * @description 查询需要审核的数据(待核查征信 /待公示 / 待公示通过 / 待兑现)
  794. * */
  795. public function selectNeedCheckData() {
  796. $type = $this->request["type"];
  797. $name = $this->request["name"];
  798. $idCard = $this->request["idCard"];
  799. $where = [];
  800. if (\StrUtil::isNotEmpAndNull($name)) {
  801. $where[] = ["name", "like", "%$name%"];
  802. }
  803. if (\StrUtil::isNotEmpAndNull($idCard)) {
  804. $where[] = ["idCard", "like", "%$idCard%"];
  805. }
  806. $where[] = ["type", "=", $this->user["type"]];
  807. $field = "id,year,idCard,name,enterpriseId";
  808. $error = null;
  809. switch ($type) {
  810. case -1:
  811. case 0:
  812. $where[] = ["publicState", "=", 1];
  813. $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
  814. $error = "暂无可核查征信的数据";
  815. break;
  816. case 1:
  817. case 5:
  818. $where[] = ["publicState", "=", 2];
  819. $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
  820. $where[] = ["cashType", "=", 1];
  821. $error = "暂无可公示(兑现)的数据";
  822. break;
  823. case 2:
  824. case 6:
  825. $where[] = ["publicState", "=", 2];
  826. $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
  827. $where[] = ["cashType", "=", 2];
  828. $error = "暂无可公示(不予兑现)的数据";
  829. break;
  830. case 3:
  831. $where[] = ["publicState", "=", 3];
  832. $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
  833. $error = "暂无需要公示通过的数据";
  834. break;
  835. case 4:
  836. $where[] = ["publicState", "=", 4];
  837. $where[] = ["checkState", "in", [HouseStateEnum::REVIEW_PASS]];
  838. $where[] = ["cashType", "=", 1];
  839. $error = "暂无待兑现的数据";
  840. break;
  841. }
  842. $list = HouseApi::getList($where, $field);
  843. //查询企业信息
  844. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  845. foreach ($list as &$row) {
  846. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  847. }
  848. $res = ["rows" => $list, "total" => count($list)];
  849. return new Response(Response::SUCCESS, "", $res);
  850. }
  851. public function exportHczx() {
  852. $response = new \stdClass();
  853. $response->code = 500;
  854. $ids = $this->request->param("ids");
  855. $ids_arr = array_filter(explode(",", $ids));
  856. if (!$ids_arr) {
  857. $response->msg = "没有选择导出的名单";
  858. return \StrUtil::back($response, "Housepurchase.callBack");
  859. }
  860. $where = [];
  861. $where[] = ["id", "in", $ids_arr];
  862. $list = houseModel::field("id,cardType,idCard,name,enterpriseId,year")->where($where)->select()->toArray();
  863. if (!$list) {
  864. $response->msg = "暂无可核查征信的数据";
  865. return \StrUtil::back($response, "Housepurchase.callBack");
  866. }
  867. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "年度"];
  868. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  869. $cardTypeName = DictApi::selectByParentCode("card_type");
  870. $rows = [];
  871. for ($i = 0; $i < count($list); $i++) {
  872. $item = $list[$i];
  873. $row = [
  874. $i + 1, $item["name"], $cardTypeName[$item["cardType"]], $item["idCard"], $enterpriseMap[$item["enterpriseId"]], $item["year"]
  875. ];
  876. $rows[] = $row;
  877. }
  878. $filename = "购房补贴待核查征信名单导出";
  879. if ($rows) {
  880. export($columns, $rows, $filename);
  881. exit();
  882. } else {
  883. $response->msg = "没有选择导出的名单";
  884. return \StrUtil::back($response, "Housepurchase.callBack");
  885. }
  886. }
  887. /**
  888. * 核查征信驳回
  889. */
  890. public function hczxReject() {
  891. $param = $this->request->param();
  892. if (!$param) {
  893. return new Response(Response::ERROR, "系统错误,请联系管理员");
  894. }
  895. $old = HouseApi::getInfoById($param["id"]);
  896. if ($old["publicState"] != 1) {
  897. return new Response(Response::ERROR, "当前记录不是待核查征信状态,无法核查");
  898. }
  899. $data["id"] = $param["id"];
  900. $data["checkState"] = HouseStateEnum::NOTPASS;
  901. $data["publicState"] = 2;
  902. $data["zxMsg"] = $param["outMsg"];
  903. $data["cashType"] = 2;
  904. $data["descideDesc"] = $old . "(1)核查征信结果:" . $param["outMsg"] . ";无法享受";
  905. //添加日志
  906. TalentChecklog::create([
  907. 'id' => getStringId(),
  908. 'mainId' => $param["id"],
  909. 'type' => intval(ProjectState::HOUSE),
  910. 'typeFileId' => null,
  911. 'active' => 1,
  912. 'state' => 2,
  913. 'step' => 4,
  914. 'stateChange' => HouseStateEnum::getStateName($old["checkState"]) . "->" . HouseStateEnum::getStateName($data["checkState"]) . "<br>公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  915. 'description' => $param["outMsg"],
  916. 'createTime' => date("Y-m-d H:i:s", time()),
  917. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  918. ]);
  919. houseModel::update($data);
  920. return new Response(Response::SUCCESS, "核查征信成功");
  921. }
  922. /**
  923. * 核查征信批量通过
  924. */
  925. public function hczxPass() {
  926. $ids = $this->request["ids"];
  927. if (\StrUtil::isEmpOrNull($ids)) {
  928. return new Response(Response::ERROR, "请选择核查征信通过的数据");
  929. }
  930. $where = [];
  931. $where[] = ["id", "in", $ids];
  932. $list = houseModel::where($where)->select()->toArray();
  933. $logList = [];
  934. $upds = [];
  935. $new_ids = [];
  936. foreach ($list as $obj) {
  937. if ($obj["checkState"] == HouseStateEnum::REVIEW_PASS && $obj["publicState"] == 1) {
  938. $new_ids[] = $obj["id"];
  939. $logList[] = [
  940. "id" => getStringId(),
  941. "type" => ProjectState::HOUSE,
  942. "mainId" => $obj["id"],
  943. "active" => 1,
  944. "state" => 3,
  945. "step" => 4,
  946. "stateChange" => "<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  947. "description" => "核查征信通过",
  948. "createTime" => date("Y-m-d H:i:s"),
  949. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  950. ];
  951. }
  952. }
  953. $upd = [
  954. "publicState" => 2,
  955. ];
  956. if ($new_ids) {
  957. $where = [];
  958. $where[] = ["id", "in", $new_ids];
  959. houseModel::where($where)->update($upd);
  960. Db::table("new_talent_checklog")->insertAll($logList);
  961. return new Response(Response::SUCCESS, "核查征信通过成功");
  962. }
  963. return new Response(Response::ERROR, "没有待核查的列表");
  964. }
  965. /**
  966. * 公示
  967. * */
  968. public function publicBatch() {
  969. $params = $this->request->param();
  970. $ids = $params["ids"];
  971. $ids = array_filter(explode(",", $ids));
  972. if (!$ids) {
  973. return new Response(Response::ERROR, "请至少选择一行数据");
  974. }
  975. $isMessage = $params["isMessage"] == 1 ? true : false;
  976. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  977. return new Response(Response::ERROR, "短信参数不能为空");
  978. }
  979. $where = [];
  980. $where[] = ["id", "in", $ids];
  981. $list = houseModel::where($where)->select()->toArray();
  982. Db::startTrans();
  983. try {
  984. $logList = [];
  985. $phones = [];
  986. $newIds = [];
  987. foreach ($list as $info) {
  988. if ($info["checkState"] == HouseStateEnum::REVIEW_PASS && $info["publicState"] == 2) {
  989. /* * 添加日志 */
  990. $newIds[] = $info["id"];
  991. $logList[] = [
  992. "id" => getStringId(),
  993. "type" => ProjectState::HOUSE,
  994. "mainId" => $info["id"],
  995. "active" => 1,
  996. "state" => 3,
  997. "step" => 5,
  998. "stateChange" => "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>",
  999. "description" => "批量公示",
  1000. "createTime" => date("Y-m-d H:i:s"),
  1001. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1002. ];
  1003. $phones[] = $info["phone"];
  1004. }
  1005. }
  1006. if ($newIds) {
  1007. $where = [];
  1008. $where[] = ["id", "in", $newIds];
  1009. $data["publicState"] = 3;
  1010. Db::table("un_housepurchase")->where($where)->update($data);
  1011. $effect = Db::table("new_talent_checklog")->insertAll($logList);
  1012. Db::commit();
  1013. if ($phones && $isMessage && $effect) {
  1014. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  1015. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  1016. $phones = array_filter($phones);
  1017. foreach ($phones as $phone) {
  1018. queue("app\job\Messenger", ["type" => 6, "userId" => 0, "phone" => $phone, "template" => $tpl_content, "processName" => "购房补贴-批量公示", "userType" => 3]);
  1019. }
  1020. }
  1021. return new Response(Response::SUCCESS, "公示成功");
  1022. }
  1023. return new Response(Response::ERROR, "没有待公示的列表");
  1024. } catch (\think\db\exception\DbException $e) {
  1025. Db::rollback();
  1026. return new Response(Response::SUCCESS, "公示失败:" . $e->getMessage());
  1027. }
  1028. }
  1029. /**
  1030. * @param obj
  1031. * @description 公示再审核修改住建局、自然资源局数据
  1032. * */
  1033. public function afterCheckEdit() {
  1034. $obj = [
  1035. "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
  1036. "checkIsTradeRecord" => \StrUtil::getRequestDecodeParam($this->request, "checkIsTradeRecord"),
  1037. "checkRecordTime" => \StrUtil::getRequestDecodeParam($this->request, "checkRecordTime"),
  1038. "mzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "mzjCheckDetail"),
  1039. "mzjSpouseList" => $this->request["mzjSpouseList"],
  1040. "zjjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zjjCheckDetail"),
  1041. "isHasBdcCard" => \StrUtil::getRequestDecodeParam($this->request, "isHasBdcCard"),
  1042. "bdcRegistTime" => \StrUtil::getRequestDecodeParam($this->request, "bdcRegistTime"),
  1043. "isOwner" => \StrUtil::getRequestDecodeParam($this->request, "isOwner"),
  1044. "transferMethod" => \StrUtil::getRequestDecodeParam($this->request, "transferMethod"),
  1045. "transferTime" => \StrUtil::getRequestDecodeParam($this->request, "transferTime"),
  1046. "zrzzjCheckDetail" => \StrUtil::getRequestDecodeParam($this->request, "zrzzjCheckDetail"),
  1047. "zjjHouseList" => $this->request["zjjHouseList"],
  1048. "zrzyjHouseList" => $this->request["zrzyjHouseList"],
  1049. "otherList" => $this->request["otherList"]
  1050. ];
  1051. if (!$obj) {
  1052. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1053. }
  1054. $old = HouseApi::getInfoById($obj["id"]);
  1055. if ($old["checkState"] != HouseStateEnum::REVIEW_PASS || $old["publicState"] != 3) {
  1056. return new Response(Response::ERROR, "不在审核范围内,无法操作");
  1057. }
  1058. if ($old["declareType"] == 1) {
  1059. if ($obj["isHasBdcCard"] == 1 && \StrUtil::isEmpOrNull($obj["bdcRegistTime"])) {
  1060. return new Response(Response::ERROR, "请填写不动产权证书登记时间");
  1061. }
  1062. if (!$obj["isOwner"]) {
  1063. return new Response(Response::ERROR, "请选择其购置的房屋是否还在名下");
  1064. }
  1065. if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferMethod"])) {
  1066. return new Response(Response::ERROR, "请填写过户方式");
  1067. }
  1068. if ($obj["isOwner"] == 2 && \StrUtil::isEmpOrNull($obj["transferTime"])) {
  1069. return new Response(Response::ERROR, "请填写过户时间");
  1070. }
  1071. if ($obj["checkIsTradeRecord"] == 1 && \StrUtil::isEmpOrNull($obj["checkRecordTime"])) {
  1072. return new Response(Response::ERROR, "请填写交易备案时间");
  1073. }
  1074. } else {
  1075. $obj["isHasBdcCard"] = null;
  1076. $obj["bdcRegistTime"] = "";
  1077. $obj["isOwner"] = null;
  1078. $obj["transferMethod"] = "";
  1079. $obj["transferTime"] = "";
  1080. $obj["checkIsTradeRecord"] = null;
  1081. $obj["checkRecordTime"] = "";
  1082. }
  1083. if ($obj["mzjSpouseList"] && count($obj["mzjSpouseList"]) > 0) {
  1084. foreach ($obj["mzjSpouseList"] as $spouse) {
  1085. if ($spouse["id"]) {
  1086. $spouse["updateTime"] = date("Y-m-d H:i:s");
  1087. $spouse["updateUser"] = $this->user["name"];
  1088. \app\common\model\HousePurchaseSpouse::update($spouse);
  1089. } else {
  1090. $spouse["id"] = getStringId();
  1091. $spouse["pId"] = $obj["id"];
  1092. $spouse["createTime"] = date("Y-m-d H:i:s");
  1093. $spouse["createUser"] = $this->user["name"];
  1094. \app\common\model\HousePurchaseSpouse::insert($spouse);
  1095. }
  1096. }
  1097. }
  1098. if ($obj["zrzyjHouseList"] && count($obj["zrzyjHouseList"]) > 0) {
  1099. foreach ($obj["zrzyjHouseList"] as $other) {
  1100. if ($other["id"]) {
  1101. $other["updateTime"] = date("Y-m-d H:i:s");
  1102. $other["updateUser"] = $this->user["name"];
  1103. \app\common\model\HousePurchaseOtherHouse::update($other);
  1104. } else {
  1105. $other["id"] = getStringId();
  1106. $other["pId"] = $obj["id"];
  1107. $other["createTime"] = date("Y-m-d H:i:s");
  1108. $other["createUser"] = $this->user["name"];
  1109. \app\common\model\HousePurchaseOtherHouse::insert($other);
  1110. }
  1111. }
  1112. }
  1113. if ($obj["otherList"] && count($obj["otherList"]) > 0) {
  1114. foreach ($obj["otherList"] as $other) {
  1115. if ($other["id"]) {
  1116. $other["updateTime"] = date("Y-m-d H:i:s");
  1117. $other["updateUser"] = $this->user["name"];
  1118. \app\common\model\HousePurchaseEnjoyOther::update($other);
  1119. } else {
  1120. $other["id"] = getStringId();
  1121. $other["pId"] = $obj["id"];
  1122. $other["createTime"] = date("Y-m-d H:i:s");
  1123. $other["createUser"] = $this->user["name"];
  1124. \app\common\model\HousePurchaseEnjoyOther::insert($other);
  1125. }
  1126. }
  1127. }
  1128. if ($obj["zjjHouseList"] && count($obj["zjjHouseList"]) > 0) {
  1129. foreach ($obj["zjjHouseList"] as $other) {
  1130. if ($other["id"]) {
  1131. $other["updateTime"] = date("Y-m-d H:i:s");
  1132. $other["updateUser"] = $this->user["name"];
  1133. \app\common\model\HousePurchaseOtherHouse::update($other);
  1134. } else {
  1135. $other["id"] = getStringId();
  1136. $other["pId"] = $obj["id"];
  1137. $other["createTime"] = date("Y-m-d H:i:s");
  1138. $other["createUser"] = $this->user["name"];
  1139. \app\common\model\HousePurchaseOtherHouse::insert($other);
  1140. }
  1141. }
  1142. }
  1143. houseModel::update($obj);
  1144. return new Response(Response::SUCCESS, "审核成功", $obj);
  1145. }
  1146. /**
  1147. * 公示后审核
  1148. */
  1149. public function afterCheck() {
  1150. try {
  1151. $data = [
  1152. "id" => \StrUtil::getRequestDecodeParam($this->request, "id"),
  1153. "checkState" => \StrUtil::getRequestDecodeParam($this->request, "checkState"),
  1154. "checkMsg" => \StrUtil::getRequestDecodeParam($this->request, "checkMsg"),
  1155. "cashType" => \StrUtil::getRequestDecodeParam($this->request, "cashType"),
  1156. "decideMoneyDetail" => \StrUtil::getRequestDecodeParam($this->request, "decideMoneyDetail"),
  1157. "shouldEnjoyMoney" => \StrUtil::getRequestDecodeParam($this->request, "shouldEnjoyMoney"),
  1158. ];
  1159. $old = HouseApi::getInfoById($data["id"]);
  1160. if (!$old) {
  1161. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1162. }
  1163. if ($old["publicState"] != 3) {
  1164. return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
  1165. }
  1166. if ($data["checkState"] == 3) {
  1167. $data["checkState"] = HouseStateEnum::REVIEW_PASS;
  1168. if ($data["cashType"] == 1 && $old["declareType"] == 1) {
  1169. $maxMoney = $old["talentArrangeMoney"];
  1170. if ($data["shouldEnjoyMoney"] > $maxMoney) {
  1171. return new Response(Response::ERROR, "当前申报的最高可享受金额为:" . $maxMoney . "元!请重新计算并填写");
  1172. }
  1173. $result = $this->calculate($old, $data, $decideDetail, 2);
  1174. if ($result->code == 500) {
  1175. return $result;
  1176. }
  1177. }
  1178. if ($data["cashType"] != 1) {
  1179. $data["shouldEnjoyMoney"] = 0;
  1180. $data["nowSubOtherMoney"] = 0;
  1181. }
  1182. } else if ($data["checkState"] == -1) {
  1183. $data["isRecover"] = 2;
  1184. $data["shouldEnjoyMoney"] = null;
  1185. $data["realEnjoyMoney"] = null;
  1186. $data["decideMoneyDetail"] = null;
  1187. $data["decideDetail"] = null;
  1188. }
  1189. $data["publicState"] = 4;
  1190. houseModel::update($data);
  1191. //添加日志
  1192. TalentChecklog::create([
  1193. 'id' => getStringId(),
  1194. 'mainId' => $data['id'],
  1195. 'type' => intval(ProjectState::HOUSE),
  1196. 'typeFileId' => null,
  1197. 'active' => 1,
  1198. 'state' => $old["checkState"],
  1199. 'step' => 6,
  1200. 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
  1201. 'description' => "公示再审核",
  1202. 'createTime' => date("Y-m-d H:i:s", time()),
  1203. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1204. ]);
  1205. return new Response(Response::SUCCESS, "审核成功");
  1206. } catch (\think\Exception $e) {
  1207. return new Response(Response::ERROR, "系统异常,请联系管理员");
  1208. }
  1209. }
  1210. /**
  1211. * 批量公示通过
  1212. */
  1213. public function publicPass() {
  1214. $ids = $this->request["ids"];
  1215. $ids = explode(",", $ids);
  1216. if (!$ids) {
  1217. return new Response(Response::ERROR, "请至少选择一行数据");
  1218. }
  1219. $where = [];
  1220. $where[] = ["id", "in", $ids];
  1221. $list = houseModel::where($where)->select()->toArray();
  1222. $houseInfoList = houseInfoModel::where(null)->select()->toArray();
  1223. $houseInfoMap = [];
  1224. foreach ($houseInfoList as $houseInfo) {
  1225. $houseInfoMap[$houseInfo["idCard"]] = $houseInfo;
  1226. }
  1227. $logList = [];
  1228. $insertHouseInfoList = [];
  1229. try {
  1230. Db::startTrans();
  1231. for ($i = 0; $i < count($list); $i++) {
  1232. $obj = $list[$i];
  1233. if ($obj["cashType"] == 1 && $obj["declareType"] == 1) {
  1234. $houseInfo = $houseInfoMap[$obj["idCard"]];
  1235. $spouseHouseInfo = $houseInfoMap[$obj["spouseIdcard"]];
  1236. if (!$houseInfo) {
  1237. $houseInfo = [
  1238. "idCard" => $obj["idCard"],
  1239. "spouseIdCard" => null,
  1240. "houseAddress" => $obj["houseAddress"],
  1241. "houseArea" => $obj["houseArea"],
  1242. "houseMoney" => $obj["houseMoney"],
  1243. "recordTime" => $obj["recordTime"],
  1244. "realEstateNo" => $obj["realEstateNo"],
  1245. "recordNo" => $obj["recordNo"],
  1246. "balanceMoney" => $obj["houseMoney"],
  1247. "count" => 0,
  1248. "lastYearArrears" => 0,
  1249. ];
  1250. }
  1251. $houseInfo["count"] = $houseInfo["count"] + 1;
  1252. $houseInfo["balanceMoney"] = $houseInfo["balanceMoney"] - $obj["shouldEnjoyMoney"];
  1253. $houseInfo["lastYearArrears"] = $obj["nowNotSubOtherMoney"];
  1254. if (\StrUtil::isNotEmpAndNull($obj["spouseIdcard"])) {
  1255. if (!$spouseHouseInfo) {
  1256. $spouseHouseInfo = [
  1257. "idCard" => $obj["spouseIdcard"],
  1258. "spouseIdCard" => null,
  1259. "houseAddress" => $obj["houseAddress"],
  1260. "houseArea" => $obj["houseArea"],
  1261. "houseMoney" => $obj["houseMoney"],
  1262. "recordTime" => $obj["recordTime"],
  1263. "realEstateNo" => $obj["realEstateNo"],
  1264. "recordNo" => $obj["recordNo"],
  1265. "balanceMoney" => $houseInfo["balanceMoney"],
  1266. "count" => $houseInfo["count"],
  1267. "lastYearArrears" => $houseInfo["lastYearArrears"],
  1268. ];
  1269. } else {
  1270. $spouseHouseInfo["count"] = $spouseHouseInfo["count"] + 1;
  1271. $spouseHouseInfo["lastYearArrears"] = $houseInfo["lastYearArrears"];
  1272. $spouseHouseInfo["balanceMoney"] = $spouseHouseInfo["balanceMoney"] - $obj["shouldEnjoyMoney"];
  1273. }
  1274. if ($spouseHouseInfo["id"]) {
  1275. $spouseHouseInfo["updateTime"] = date("Y-m-d H:i:s");
  1276. $spouseHouseInfo["updateUser"] = $this->user["uid"];
  1277. Db::table("un_housepurchase_house_info")->update($spouseHouseInfo);
  1278. } else {
  1279. $spouseHouseInfo["id"] = getStringId();
  1280. $spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
  1281. $spouseHouseInfo["createUser"] = $this->user["uid"];
  1282. $insertHouseInfoList[] = $spouseHouseInfo;
  1283. }
  1284. }
  1285. if ($houseInfo["id"]) {
  1286. $houseInfo["updateTime"] = date("Y-m-d H:i:s");
  1287. $houseInfo["updateUser"] = $this->user["uid"];
  1288. Db::table("un_housepurchase_house_info")->update($houseInfo);
  1289. } else {
  1290. $houseInfo["id"] = getStringId();
  1291. $houseInfo["createTime"] = date("Y-m-d H:i:s");
  1292. $houseInfo["createUser"] = $this->user["uid"];
  1293. $insertHouseInfoList[] = $houseInfo;
  1294. }
  1295. }
  1296. //添加日志
  1297. $logList[] = [
  1298. "id" => getStringId(),
  1299. "type" => ProjectState::HOUSE,
  1300. "mainId" => $obj["id"],
  1301. "active" => 1,
  1302. "state" => 3,
  1303. "step" => 6,
  1304. "stateChange" => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待公布</span>;",
  1305. "description" => "批量公示通过",
  1306. "createTime" => date("Y-m-d H:i:s"),
  1307. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1308. ];
  1309. }
  1310. $upd["publicState"] = 4;
  1311. Db::table("un_housepurchase")->where($where)->update($upd);
  1312. if ($insertHouseInfoList) {
  1313. Db::table("un_housepurchase_house_info")->insertAll($insertHouseInfoList);
  1314. }
  1315. Db::table("new_talent_checklog")->insertAll($logList);
  1316. Db::commit();
  1317. return new Response(Response::SUCCESS, "批量公示通过成功");
  1318. } catch (\think\db\exception\DbException $e) {
  1319. Db::rollback();
  1320. return new Response(Response::ERROR, "批量公示失败:" . $e->getCode());
  1321. }
  1322. }
  1323. /**
  1324. * 兑现
  1325. */
  1326. public function cash() {
  1327. $ids = $this->request["ids"];
  1328. $ids = array_filter(explode(",", $ids));
  1329. if (!$ids) {
  1330. return new Response(Response::ERROR, "请至少选择一行数据");
  1331. }
  1332. $where = [];
  1333. $where[] = ["id", "in", $ids];
  1334. $list = houseModel::where($where)->select()->toArray();
  1335. //添加日志
  1336. $logList = [];
  1337. try {
  1338. Db::startTrans();
  1339. for ($i = 0; $i < count($list); $i++) {
  1340. $obj = $list[$i];
  1341. $logList[] = [
  1342. "id" => getStringId(),
  1343. "type" => ProjectState::HOUSE,
  1344. "mainId" => $obj["id"],
  1345. "active" => 1,
  1346. "state" => 3,
  1347. "step" => 50,
  1348. "stateChange" => "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>;",
  1349. "description" => "批量兑现",
  1350. "createTime" => date("Y-m-d H:i:s"),
  1351. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1352. ];
  1353. }
  1354. $upd["publicState"] = 5;
  1355. Db::table("un_housepurchase")->where($where)->update($upd);
  1356. Db::table("new_talent_checklog")->insertAll($logList);
  1357. Db::commit();
  1358. return new Response(Response::SUCCESS, "批量兑现成功");
  1359. } catch (\think\db\exception\DbException $e) {
  1360. Db::rollback();
  1361. return new Response(Response::ERROR, "批量兑现失败:" . $e->getCode());
  1362. }
  1363. }
  1364. /**
  1365. * 公示预览(不予兑现)
  1366. */
  1367. public function exportPublicNotCash() {
  1368. $response = new \stdClass();
  1369. $response->code = 500;
  1370. //获取字典表人才层次+
  1371. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1372. $streetMap = DictApi::selectByParentCode("street");
  1373. //查询企业信息
  1374. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1375. //查询所有
  1376. $where = [];
  1377. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  1378. $list = TaModel::where($where)->select()->toArray();
  1379. $rows = [];
  1380. for ($i = 0; $i < count($list); $i++) {
  1381. $item = $list[$i];
  1382. $rows[] = [
  1383. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  1384. ];
  1385. }
  1386. $filename = CommonConst::getTypeName($this->user["type"]) . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
  1387. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  1388. if ($rows) {
  1389. export($columns, $rows, $filename);
  1390. exit();
  1391. } else {
  1392. $response->msg = "没有选择导出的名单";
  1393. return \StrUtil::back($response, "Housepurchase.callBack");
  1394. }
  1395. }
  1396. /**
  1397. * @param ids
  1398. * @param type 1-需要兑现,2-不予兑现
  1399. * @description 公示预览
  1400. * */
  1401. public function exportPublic() {
  1402. /* * 查询需要公示的数据 */
  1403. $ids = array_filter(explode(",", $this->request["ids"]));
  1404. if (!$ids) {
  1405. return new Response(Response::ERROR, "请至少选择一行数据");
  1406. }
  1407. $type = $this->request["type"];
  1408. $where = [];
  1409. $where[] = ["id", "in", $ids];
  1410. $list = houseModel::where($where)->select()->toArray();
  1411. $where = [];
  1412. $where[] = ["pId", "in", $ids];
  1413. $otherList = \app\common\model\HousePurchaseEnjoyOther::where($where)->select()->toArray();
  1414. $otherMap = [];
  1415. foreach ($otherList as $ol) {
  1416. $otherMap[$ol["pId"]][] = $ol;
  1417. }
  1418. //查询企业信息
  1419. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1420. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1421. $year = $list[0]["year"];
  1422. foreach ($list as $key => &$obj) {
  1423. $obj["talentArrangeName"] = $levelMap[$obj["talentArrange"]];
  1424. $obj["enterpriseName"] = $enterpriseMap[$obj["enterpriseId"]];
  1425. $obj["sn"] = $key + 1;
  1426. if ($obj["declareType"] == 1) {
  1427. $obj["declareTypeName"] = "购房补贴";
  1428. $otherHouses = $otherMap[$obj["id"]];
  1429. $desc = [];
  1430. if ($otherHouses) {
  1431. foreach ($otherHouses as $house) {
  1432. $desc[] = $house["enjoyPolicyName"];
  1433. }
  1434. }
  1435. $obj["description"] = $desc ? "扣除已享受" . implode(";\n", $desc) . "部分" : "";
  1436. } else if ($obj["declareType"] == 2) {
  1437. $obj["declareTypeName"] = "免租入住";
  1438. $obj["description"] = $year . "年度取得免租入住资格";
  1439. }
  1440. }unset($obj);
  1441. $userTypeName = CommonConst::getTypeName($this->user["type"]);
  1442. if ($type == 1) {
  1443. //兑现
  1444. $title = ["序号", "申报类型", "姓名", "工作单位", "人才层次", $year . "年度拟发放购房补贴金额(元)", "备注"];
  1445. $value = ["sn", "declareTypeName", "name", "enterpriseName", "talentArrangeName", "realEnjoyMoney", "description"];
  1446. $fileName = sprintf("%s%s年度购房补贴拟发放对象名单", $userTypeName, $year);
  1447. } else {
  1448. //不予兑现
  1449. $title = ["序号", "申报类型", "姓名", "工作单位", "人才层次", "备注"];
  1450. $value = ["sn", "declareTypeName", "name", "enterpriseName", "talentArrangeName", "description"];
  1451. $fileName = sprintf("%s%s年度购房补贴不予兑现对象名单", $userTypeName, $year);
  1452. }
  1453. $rows = [];
  1454. foreach ($list as $row) {
  1455. $newRow = [];
  1456. for ($i = 0; $i < count($value); $i++) {
  1457. $newRow[] = $row[$value[$i]];
  1458. }
  1459. $rows[] = $newRow;
  1460. }
  1461. export($title, $rows, $fileName);
  1462. }
  1463. /**
  1464. * 导出基本信息
  1465. */
  1466. public function exportBasicInfo() {
  1467. $obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
  1468. $obj["enterpriseName"] = \StrUtil::getRequestDecodeParam($this->request, "enterpriseName");
  1469. $obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
  1470. $obj["idCard"] = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1471. $obj["talentType"] = \StrUtil::getRequestDecodeParam($this->request, "talentType");
  1472. $obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
  1473. $obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
  1474. $obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
  1475. $obj["isSupple"] = \StrUtil::getRequestDecodeParam($this->request, "isSupple");
  1476. $obj["checkState"] = \StrUtil::getRequestDecodeParam($this->request, "checkState");
  1477. $obj["publicState"] = \StrUtil::getRequestDecodeParam($this->request, "publicState");
  1478. $obj["companyName"] = \StrUtil::getRequestDecodeParam($this->request, "companyName");
  1479. $obj["allowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "allowanceType");
  1480. $obj["recommendAllowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "recommendAllowanceType");
  1481. $obj["introductionMode"] = \StrUtil::getRequestDecodeParam($this->request, "introductionMode");
  1482. $obj["firstJJStartTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJStartTime");
  1483. $obj["firstJJEndTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJEndTime");
  1484. $obj["process"] = intval(\StrUtil::getRequestDecodeParam($this->request, "process"));
  1485. $obj["type"] = $this->user["type"];
  1486. $where = [];
  1487. $where[] = ["ta.delete", "=", 0];
  1488. $where[] = ["ta.type", "=", $this->user["type"]];
  1489. $this->setTalentAllowanceInfoForExport($where, $obj, $obj["process"]);
  1490. switch ($obj["process"]) {
  1491. case 1:
  1492. $where[] = ["ta.checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  1493. break;
  1494. case 2:
  1495. $where[] = ["ta.firstPassTime", "EXP", Db::raw("is not null")];
  1496. break;
  1497. case 3:
  1498. $where[] = ["ta.visitPassTime", "EXP", Db::raw("is not null")];
  1499. break;
  1500. case 4:
  1501. if ($obj["publicState"]) {
  1502. $where[] = ["publicState", "=", $obj["publicState"]];
  1503. }
  1504. $where[] = ["ta.checkState", "in", [-1, 30]];
  1505. break;
  1506. }
  1507. $projects = [
  1508. AllowanceProjectEnum::PROJECT_TAX,
  1509. AllowanceProjectEnum::PROJECT_WAGES,
  1510. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1511. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1512. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1513. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1514. ];
  1515. $months = [];
  1516. for ($m = 1; $m <= 12; $m++) {
  1517. $months[] = $m . "月";
  1518. }
  1519. $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]]];
  1520. $infoCols = count($columns);
  1521. for ($i = 0; $i < count($projects); $i++) {
  1522. $columns[] = [AllowanceProjectEnum::getProjectName($projects[$i]), $months];
  1523. }
  1524. $list = \app\common\model\TalentAllowanceProject::alias("pro")
  1525. ->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")
  1526. ->leftJoin("un_talent_allowance_info ta", "ta.id=pro.mainId")
  1527. ->leftJoin("un_talent_allowancecontract_detail con", "pro.baseId=con.id")
  1528. ->where($where)
  1529. ->order("ta.year desc,ta.createTime desc,pro.project asc")
  1530. ->select()->toArray();
  1531. $tmpList = [];
  1532. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1533. $streetMap = DictApi::selectByParentCode("street");
  1534. $where = [];
  1535. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1536. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1537. $where = [];
  1538. $where[] = ["id", "in", array_column($list, "enterpriseId")];
  1539. $enterpriseMap = \app\common\model\Enterprise::where($where)->column("name", "id");
  1540. foreach ($list as $item) {
  1541. //组装数据
  1542. if (!$tmpList[$item["id"]]) {
  1543. $tmpList[$item["id"]]["curEnterpriseId"] = $item["curEnterpriseId"];
  1544. $tmpList[$item["id"]]["info"] = [$item["year"], $streetMap[$item["address"]], $item["name"], $item["sex"] == 1 ? "男" : "女", $item["idCard"], $levelMap[$item["talentArrange"]],
  1545. $icmap[$item["identifyCondition"]], $item["identifyGetTime"], $item["identifyConditionName"], $item["identifyMonth"], AllowanceTypeEnum::getTypeName($item["recommendAllowanceType"]), $item["recommendMonths"], $item["recommendMoney"],
  1546. $item["recommendMoneyDesc"], AllowanceTypeEnum::getTypeName($item["allowanceType"]), $item["months"], $item["money"],
  1547. $item["moneyDesc"], $this->getCheckStateName($item["checkState"], $item["publicState"], $item["allowanceType"])];
  1548. }
  1549. if (!$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]) {
  1550. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]] = [
  1551. "startTime" => $item["startTime"],
  1552. "endTime" => $item["endTime"],
  1553. "entryTime" => $item["entryTime"],
  1554. "isQuit" => $item["isQuit"]
  1555. ];
  1556. }
  1557. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]["projects"][$item["project"]] = $item["pre_months"];
  1558. }
  1559. $rows = [];
  1560. $colorset = [];
  1561. foreach ($tmpList as $id => $item) {
  1562. foreach ($item["enterprise"] as $enterpriseId => $enterprise) {
  1563. $row = $item["info"];
  1564. $row[] = $this->user["uid"] == $enterpriseId ? "本单位" : $enterpriseMap[$enterpriseId];
  1565. for ($i = 0; $i < count($projects); $i++) {
  1566. if (strpos($enterprise["projects"][$projects[$i]], "=") === false) {
  1567. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1568. for ($m = 1; $m <= 12; $m++) {
  1569. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1570. if (in_array($_month, $months)) {
  1571. $row[] = "✔";
  1572. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1573. } else {
  1574. $row[] = "";
  1575. }
  1576. }
  1577. } else {
  1578. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1579. $_months = [];
  1580. foreach ($months as $month) {
  1581. $kv = explode("=", $month);
  1582. $_months[$kv[0]] = $kv[1];
  1583. }
  1584. for ($m = 1; $m <= 12; $m++) {
  1585. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1586. $days = $_months[$_month];
  1587. if ($days && $days > 0) {
  1588. $row[] = $days . "天";
  1589. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1590. } else {
  1591. $row[] = "";
  1592. }
  1593. }
  1594. }
  1595. }
  1596. $rows[] = $row;
  1597. }
  1598. }
  1599. $cols = $infoCols + count($projects) * 12 - 1;
  1600. $settings = [
  1601. "width" => [["A", 8], ["C", 12], ["D", 6], ["E", 20], ["F", 12], ["G", 70], ["H", 12], ["I", 15], ["J", 12], ["K", 12], ["P", 30]],
  1602. "height" => [18],
  1603. "freeze" => "D3",
  1604. "color" => $colorset
  1605. ];
  1606. for ($i = 0; $i < count($projects) * 12; $i++) {
  1607. $settings["width"][] = [getExcelColumnByIndex($infoCols + $i), 6]; //批设置项目的宽度
  1608. }
  1609. $settings["background-color"][] = [sprintf("%s2:%s2", getExcelColumnByIndex($infoCols), getExcelColumnByIndex($cols)), "E1F1DE"];
  1610. export($columns, $rows, "津补贴申报名单", $settings);
  1611. }
  1612. /**
  1613. * 校验是否在审核范围内
  1614. */
  1615. public function validateIsCheck() {
  1616. $id = $this->request["id"];
  1617. $process = $this->request["process"];
  1618. $compnayId = $this->request["companyId"];
  1619. $old = HouseApi::getInfoById($id);
  1620. $checkState = $old["checkState"];
  1621. $res = null;
  1622. switch ($process) {
  1623. case 1:
  1624. if ($checkState != HouseStateEnum::NEED_CHECK && $checkState != HouseStateEnum::REJECT_TO_FIRST && $checkState != HouseStateEnum::DEP_REJECT) {
  1625. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1626. } else {
  1627. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1628. if ($log) {
  1629. $old["checkState"] = $log["state"];
  1630. $old["checkMsg"] = $log["description"];
  1631. } else {
  1632. $old["checkState"] = null;
  1633. $old["checkMsg"] = "";
  1634. }
  1635. }
  1636. break;
  1637. case 2:
  1638. if ($checkState != HouseStateEnum::NEED_DEP_CHECK && $checkState != HouseStateEnum::REJECT_TO_DEP) {
  1639. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1640. } else {
  1641. $where = [];
  1642. $where[] = ["mainId", "=", $id];
  1643. $where[] = ["companyId", "=", $compnayId];
  1644. $where[] = ["type", "=", ProjectState::HOUSE];
  1645. $depcheckstate = Db::table("un_talent_depcheckstate")->where($where)->find();
  1646. if ($depcheckstate["state"] != 1 && $depcheckstate["state"] != 4 && $depcheckstate["state"] != 9) {
  1647. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1648. } else {
  1649. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2, $compnayId);
  1650. if ($log) {
  1651. $old["checkState"] = $log["state"];
  1652. $old["checkMsg"] = $log["description"];
  1653. } else {
  1654. $old["checkState"] = null;
  1655. $old["checkMsg"] = "";
  1656. }
  1657. $res["company"] = getCacheById("Company", $compnayId);
  1658. }
  1659. }
  1660. break;
  1661. case 3:
  1662. if ($checkState != HouseStateEnum::NEED_REVIEW_CHECK && $checkState != HouseStateEnum::REJECT_TO_REVIEW) {
  1663. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1664. } else {
  1665. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1666. if ($log) {
  1667. $old["checkState"] = $log["state"];
  1668. $old["checkMsg"] = $log["description"];
  1669. } else {
  1670. $old["checkState"] = null;
  1671. $old["checkMsg"] = "";
  1672. }
  1673. }
  1674. break;
  1675. case 4:
  1676. if ($checkState != HouseStateEnum::REVIEW_PASS && $checkState != HouseStateEnum::NOTPASS) {
  1677. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1678. } else if ($old["publicState"] != 3) {
  1679. return new Response(Response::ERROR, "该申报不在审核范围内,无法审核");
  1680. } else {
  1681. $log = TalentLogApi::getLastLogByStep($id, ProjectState::HOUSE, $process, 2);
  1682. if ($log) {
  1683. $old["checkState"] = $log["state"];
  1684. $old["checkMsg"] = $log["description"];
  1685. } else {
  1686. $old["checkState"] = null;
  1687. $old["checkMsg"] = "";
  1688. }
  1689. $housepurchase = [];
  1690. $result = $this->calculate($old, $housepurchase, $decideDesc, 1);
  1691. if ($result->code == 500) {
  1692. return $result;
  1693. }
  1694. $res["housepurchase"] = $housepurchase;
  1695. }
  1696. break;
  1697. }
  1698. $where = [];
  1699. $where[] = ["type", "=", $old["type"]];
  1700. $where[] = ["project", "=", ProjectState::HOUSE];
  1701. $where[] = ["active", "=", 1];
  1702. $where[] = ["delete", "=", 0];
  1703. $filetypeList = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1704. /* * 查询之前是否享受过 */
  1705. $count = HouseApi::getEnjoyTimesByIdCard($old["idCard"]);
  1706. $res["number"] = $count;
  1707. $res["obj"] = $old;
  1708. $res["fileTypeList"] = $filetypeList;
  1709. return new Response(Response::SUCCESS, "", $res);
  1710. }
  1711. /**
  1712. * 初始化可修改的项目/附件/合同
  1713. * */
  1714. public function findFieldsAndFiles() {
  1715. $id = $this->request["id"];
  1716. if (\StrUtil::isEmpOrNull($id)) {
  1717. return new Response(Response::ERROR, "请选择需要修改的对象");
  1718. }
  1719. $info = HouseApi::getInfoById($id);
  1720. if (!$info) {
  1721. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1722. }
  1723. if ($info["checkState"] != HouseStateEnum::FIRST_REJECT) {
  1724. return new Response(Response::ERROR, "只能修改初审驳回的数据");
  1725. }
  1726. $res = [];
  1727. $where = [];
  1728. $where[] = ["type", "=", $info["type"]];
  1729. $where[] = ["project", "=", ProjectState::HOUSE];
  1730. $where[] = ["active", "=", 1];
  1731. $where[] = ["delete", "=", 0];
  1732. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1733. $res["files"] = $filetypes;
  1734. $res["obj"] = $info;
  1735. return new Response(Response::SUCCESS, "", $res);
  1736. }
  1737. /**
  1738. * 修改驳回项目/附件/合同
  1739. * */
  1740. public function updateFieldsAndFiles() {
  1741. $data = $this->request->param();
  1742. if (!$data["id"]) {
  1743. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1744. }
  1745. houseModel::update($data);
  1746. return new Response(Response::SUCCESS, "修改成功");
  1747. }
  1748. public function basicDataExport() {
  1749. $names = \StrUtil::getRequestDecodeParam($this->request, "names");
  1750. $values = \StrUtil::getRequestDecodeParam($this->request, "values");
  1751. $process = \StrUtil::getRequestDecodeParam($this->request, "process");
  1752. $where = [];
  1753. $obj = $this->setHousepurchase($this->request);
  1754. $obj["process"] = $process;
  1755. $obj["type"] = $this->user["type"];
  1756. $this->setCondition($where, $obj);
  1757. switch ($process) {
  1758. case 1:
  1759. break;
  1760. case 2:
  1761. break;
  1762. case 3:
  1763. $where[] = ["depPassTime", "EXP", Db::raw("is not null")];
  1764. break;
  1765. case 4:
  1766. $where[] = ["checkState", "in", [HouseStateEnum::NOTPASS, HouseStateEnum::REVIEW_PASS]];
  1767. $where[] = ["reviewPassTime", "EXP", Db::raw("is not null")];
  1768. break;
  1769. }
  1770. if (in_array($process, [1, 3, 4])) {
  1771. $list = houseModel::where($where)->order($order)->select()->toArray();
  1772. } else {
  1773. $company = getCacheById("Company", $this->user["companyId"]);
  1774. $result = HouseApi::selectForHousePurchase($obj, $company, ProjectState::HOUSE, 0, 99999);
  1775. $list = $result["rows"];
  1776. }
  1777. $list = $this->translateChinese($list, $process);
  1778. if ($list) {
  1779. $filename = "购房补贴导出";
  1780. $columns = array_filter(explode(",", $names));
  1781. $keys = array_filter(explode(",", $values));
  1782. $rows = [];
  1783. foreach ($list as $item) {
  1784. $row = [];
  1785. foreach ($keys as $key) {
  1786. $row[] = $item[$key];
  1787. }
  1788. $rows[] = $row;
  1789. }
  1790. export($columns, $rows, $filename);
  1791. exit();
  1792. } else {
  1793. $response = new Response(Response::ERROR, "没有可导出的内容");
  1794. return \StrUtil::back($response, "Housepurchase.callBack");
  1795. }
  1796. }
  1797. private function setCondition(&$where, &$query) {
  1798. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1799. $where[] = ["year", "=", $query["year"]];
  1800. }
  1801. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1802. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1803. }
  1804. if (\StrUtil::isNotEmpAndNull($query["idCard"])) {
  1805. $where[] = ["idCard", "like", "%" . $query["idCard"] . "%"];
  1806. }
  1807. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1808. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1809. }
  1810. if (\StrUtil::isNotEmpAndNull($query["spouseName"])) {
  1811. $where[] = ["spouseName", "like", "%" . $query["spouseName"] . "%"];
  1812. }
  1813. if (\StrUtil::isNotEmpAndNull($query["spouseIdcard"])) {
  1814. $where[] = ["spouseIdcard", "like", "%" . $query["spouseIdcard"] . "%"];
  1815. }
  1816. if (\StrUtil::isNotEmpAndNull($query["childName"])) {
  1817. $where[] = ["childName", "like", "%" . $query["childName"] . "%"];
  1818. }
  1819. if (\StrUtil::isNotEmpAndNull($query["childIdCard"])) {
  1820. $where[] = ["childIdCard", "like", "%" . $query["childIdCard"] . "%"];
  1821. }
  1822. if (\StrUtil::isNotEmpAndNull($query["marryStatus"])) {
  1823. $where[] = ["marryStatus", "=", $query["marryStatus"]];
  1824. }
  1825. if ($query["isConflict"]) {
  1826. $where[] = ["isConflict", "=", $query["isConflict"]];
  1827. }
  1828. if ($query["isRecover"]) {
  1829. $where[] = ["isRecover", "=", $query["isRecover"]];
  1830. }
  1831. if ($query["checkState"]) {
  1832. switch ($query["checkState"]) {
  1833. case -1:
  1834. $where[] = ["checkState", "=", HouseStateEnum::NOTPASS];
  1835. break;
  1836. case 1:
  1837. $where[] = ["checkState", "=", HouseStateEnum::SAVE];
  1838. break;
  1839. case 2:
  1840. switch ($query["process"]) {
  1841. case 1:
  1842. $where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
  1843. $where[] = ["highProcess", "<", $query["process"]];
  1844. break;
  1845. case 2:
  1846. $query["state"] = 1;
  1847. break;
  1848. case 3:
  1849. $where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
  1850. $where[] = ["highProcess", "<", $query["process"]];
  1851. break;
  1852. }
  1853. break;
  1854. case 3:
  1855. switch ($query["process"]) {
  1856. case 1:
  1857. $where[] = ["checkState", "=", HouseStateEnum::FIRST_REJECT];
  1858. break;
  1859. case 2:
  1860. $query["state"] = 2;
  1861. break;
  1862. case 3:
  1863. $where[] = ["checkState", "<=", HouseStateEnum::REJECT_TO_DEP];
  1864. break;
  1865. }
  1866. break;
  1867. case 4:
  1868. switch ($query["process"]) {
  1869. case 1:
  1870. $where[] = ["checkState", "in", [HouseStateEnum::NEED_DEP_CHECK, HouseStateEnum::REJECT_TO_DEP, HouseStateEnum::NEED_REVIEW_CHECK, HouseStateEnum::REVIEW_PASS]];
  1871. break;
  1872. case 2:
  1873. $query["state"] = 3;
  1874. break;
  1875. case 3:
  1876. case 4:
  1877. $where[] = ["checkState", "=", HouseStateEnum::REVIEW_PASS];
  1878. break;
  1879. }
  1880. break;
  1881. case 5:
  1882. switch ($query["process"]) {
  1883. case 1:
  1884. $where[] = ["checkState", "in", [HouseStateEnum::REJECT_TO_FIRST, HouseStateEnum::DEP_REJECT]];
  1885. break;
  1886. case 2:
  1887. $query["state"] = 4;
  1888. break;
  1889. case 3:
  1890. $where[] = ["checkState", "=", HouseStateEnum::REJECT_TO_REVIEW];
  1891. break;
  1892. }
  1893. break;
  1894. case 6:
  1895. switch ($query["process"]) {
  1896. case 1:
  1897. $where[] = ["checkState", "=", HouseStateEnum::NEED_CHECK];
  1898. $where[] = ["highProcess", ">=", $query["process"]];
  1899. break;
  1900. case 2:
  1901. $query["state"] = 9;
  1902. break;
  1903. case 3:
  1904. $where[] = ["checkState", "=", HouseStateEnum::NEED_REVIEW_CHECK];
  1905. $where[] = ["highProcess", ">=", $query["process"]];
  1906. break;
  1907. }
  1908. break;
  1909. }
  1910. }
  1911. }
  1912. private function translateToChinese(&$obj) {
  1913. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  1914. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  1915. }
  1916. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  1917. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  1918. }
  1919. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  1920. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  1921. }
  1922. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  1923. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  1924. }
  1925. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  1926. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  1927. }
  1928. }
  1929. private function translateChinese($list, $process) {
  1930. //获取字典表
  1931. $marryMap = DictApi::selectByParentCode("marry_status");
  1932. $cardTypeMap = DictApi::selectByParentCode("card_type");
  1933. $streetMap = DictApi::selectByParentCode("street");
  1934. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1935. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1936. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1937. $where = [];
  1938. $where[] = ["type", "=", $this->user["type"]];
  1939. $conditionMap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1940. $where = [];
  1941. $where[] = ["pId", "in", array_column($list, "id")];
  1942. $childrens = \app\common\model\HousePurchaseChildren::where($where)->select()->toArray();
  1943. $childMap = [];
  1944. foreach ($childrens as $child) {
  1945. $childMap[$child["pId"]][] = $child;
  1946. }
  1947. foreach ($list as &$info) {
  1948. $info["marryStatusName"] = $marryMap[$info["marryStatus"]];
  1949. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  1950. $info["spouseCardTypeName"] = $cardTypeMap[$info["spouseCardType"]];
  1951. $info["childCardTypeName"] = $cardTypeMap[$info["childCardType"]];
  1952. $info["streetName"] = $streetMap[$info["street"]];
  1953. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  1954. $info["identifyConditionCH"] = $conditionMap[$info["identifyCondition"]];
  1955. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  1956. $info["declareTypeName"] = $info["declareType"] == 1 ? "购房补贴" : "免租入住";
  1957. $info["enterpriseName"] = $enterpriseMap[$info["enterpriseId"]];
  1958. $info["isEnjoyOtherName"] = $info["isEnjoyOther"] == 1 ? "是" : "否";
  1959. $info["spouseIsLibraryName"] = $info["spouseIsLibrary"] == 1 ? "是" : "否";
  1960. $childs = $childMap[$info["id"]];
  1961. $childStr = "";
  1962. if ($childs) {
  1963. for ($i = 0; $i < count($childs); $i++) {
  1964. $childStr .= $childs[$i]["name"] . "-" . $childs[$i]["idCard"] . ";";
  1965. }
  1966. }
  1967. $info["childs"] = $childStr;
  1968. switch ($process) {
  1969. case 1:
  1970. if ($info["checkState"] == HouseStateEnum::NOTPASS) {
  1971. $info["checkStateName"] = "审核不通过";
  1972. }
  1973. if ($info["checkState"] == HouseStateEnum::SAVE) {
  1974. $info["checkStateName"] = "待提交";
  1975. }
  1976. if ($info["checkState"] == HouseStateEnum::NEED_CHECK) {
  1977. $info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
  1978. }
  1979. if ($info["checkState"] == HouseStateEnum::FIRST_REJECT) {
  1980. $info["checkStateName"] = "已驳回";
  1981. }
  1982. if ($info["checkState"] == HouseStateEnum::REJECT_TO_FIRST || $info["checkState"] == HouseStateEnum::DEP_REJECT) {
  1983. $info["checkStateName"] = "上级驳回";
  1984. }
  1985. if ($info["checkState"] == HouseStateEnum::NEED_DEP_CHECK || $info["checkState"] >= HouseStateEnum::REJECT_TO_DEP) {
  1986. $info["checkStateName"] = "已通过";
  1987. }
  1988. break;
  1989. case 2:
  1990. if ($info["state"] == 1) {
  1991. $info["checkStateName"] = "待审核";
  1992. }
  1993. if ($info["state"] == 2) {
  1994. $info["checkStateName"] = "已驳回";
  1995. }
  1996. if ($info["state"] == 3) {
  1997. $info["checkStateName"] = "已通过";
  1998. }
  1999. if ($info["state"] == 4) {
  2000. $info["checkStateName"] = "上级驳回";
  2001. }
  2002. if ($info["state"] == 9) {
  2003. $info["checkStateName"] = "重新提交";
  2004. }
  2005. break;
  2006. case 3:
  2007. if ($info["checkState"] <= HouseStateEnum::REJECT_TO_DEP) {
  2008. $info["checkStateName"] = "已驳回";
  2009. } else if ($info["checkState"] == HouseStateEnum::NEED_REVIEW_CHECK) {
  2010. $info["checkStateName"] = $info["highProcess"] != null && $info["highProcess"] >= $process ? "重新提交" : "待审核";
  2011. } else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
  2012. $info["checkStateName"] = "已通过";
  2013. }
  2014. break;
  2015. case 4:
  2016. if ($info["checkState"] == HouseStateEnum::NOTPASS) {
  2017. $info["checkStateName"] = "审核不通过";
  2018. } else if ($info["checkState"] == HouseStateEnum::REVIEW_PASS) {
  2019. $info["checkStateName"] = "已通过";
  2020. }
  2021. break;
  2022. }
  2023. }unset($info);
  2024. return $list;
  2025. }
  2026. private function getCheckStateName($checkState, $publicState, $allowanceType) {
  2027. switch ($checkState) {
  2028. case 1:
  2029. return "待提交";
  2030. case 5:
  2031. case 13:
  2032. case 15:
  2033. case 20:
  2034. case 25:
  2035. case 35:
  2036. return "审核中";
  2037. case 10:
  2038. return "已驳回";
  2039. case - 1:
  2040. if ($publicState >= 3) {
  2041. return "审核不通过";
  2042. } else {
  2043. return "审核中";
  2044. }
  2045. break;
  2046. case 30:
  2047. if ($publicState == 1) {
  2048. return "待核查征信";
  2049. } else if ($publicState == 2) {
  2050. return "待公示";
  2051. } else if ($publicState == 3) {
  2052. return "公示中";
  2053. } else if ($publicState == 4) {
  2054. return $allowanceType != 3 ? "待兑现" : "不予兑现";
  2055. } else if ($publicState == 5) {
  2056. return "已兑现";
  2057. }
  2058. default:
  2059. return "未知状态";
  2060. }
  2061. }
  2062. /**
  2063. * @param $old 原来的记录
  2064. * @param $housepurchase 新的记录
  2065. * @param $descideDesc 记录文本
  2066. * @param $type 1-复核阶段,不生成享受人的剩余享受金额记录,2-公示再审核阶段,生成享受记录
  2067. * @description 计算购房补贴金额
  2068. * */
  2069. private function calculate($old, &$housepurchase = [], &$descideDesc = [], $type = 1) {
  2070. /* * 1、查询申报人和配偶的房产信息 */
  2071. $houseInfo = HouseApi::getHouseInfo($old["idCard"]);
  2072. $spouseHouseInfo = HouseApi::getHouseInfo($old["spouseIdCard"]);
  2073. if (!$houseInfo) {
  2074. $houseInfo = [
  2075. "idCard" => $old["idCard"],
  2076. "spouseIdCard" => null,
  2077. "houseAddress" => $old["houseAddress"],
  2078. "houseArea" => $old["houseArea"],
  2079. "houseMoney" => $old["houseMoney"],
  2080. "recordTime" => $old["recordTime"],
  2081. "realEstateNo" => $old["realEstateNo"],
  2082. "recordNo" => $old["recordNo"],
  2083. "balanceMoney" => $old["houseMoney"],
  2084. "count" => 0,
  2085. "lastYearArrears" => 0
  2086. ];
  2087. }
  2088. //判断是否超过五次申报
  2089. if ($houseInfo["balanceMoney"] <= 0) {
  2090. return new Response(Response::ERROR, "申报房产可享受余额不足,无法享受");
  2091. }
  2092. /* * 2.查询购房补贴费用标准,根据人才层次计算可享受金额 */
  2093. $amountStandard = \app\common\api\AmountStandardApi::getStandard($this->user["type"], 3, $old["talentArrange"]);
  2094. if (!$amountStandard)
  2095. return new Response(Response::ERROR, "系统暂未设置该人才层次的购房补贴享受金额,请设置后再提交");
  2096. $code = "housepurchase_percentage_";
  2097. switch ($old["type"]) {
  2098. case CommonConst::ENTERPRISE_NORMAL:
  2099. $code .= "normal";
  2100. break;
  2101. case CommonConst::ENTERPRISE_JC:
  2102. $code .= "ic";
  2103. break;
  2104. case CommonConst::ENTERPRISE_WJ:
  2105. $code .= "wj";
  2106. break;
  2107. case CommonConst::ENTERPRISE_GJ:
  2108. $code .= "gj";
  2109. break;
  2110. }
  2111. $dicts = DictApi::findChildDictByCode($code);
  2112. if (!$dicts)
  2113. return new Response(Response::ERROR, "系统字典中暂未设置购房补贴年度比例,请设置后再提交。");
  2114. $dicts = bubbleSort($dicts, "code");
  2115. $count = count($dicts);
  2116. if ($houseInfo["count"] >= $count) {
  2117. return new Response(Response::ERROR, "申报人已享受{$count}次购房补贴,无法再次享受");
  2118. }
  2119. $dic = $dicts[$houseInfo["count"]];
  2120. if ($houseInfo["count"] > 0 && $count > 1) {
  2121. if (!is_numeric($dic["code"]) || ceil($dic["code"]) != $dic["code"]) {
  2122. return new Response(Response::ERROR, "系统字典中设置的购房补贴年度应该是整数,例如第一年应为1,第四年应为4");
  2123. }
  2124. $firstInfo = HouseApi::getFstInfoById($old["idCard"]);
  2125. $firstYear = substr($firstInfo["year"], 0, 4);
  2126. $nextApplyYear = date("Y", strtotime(sprintf("%d +%d years", $firstYear, $dic["code"] - $dicts[0]["code"])));
  2127. if (substr($old["year"], 0, 4) != $nextApplyYear) {
  2128. return new Response(Response::ERROR, "未到申报年度,下次申报年度为" . $nextApplyYear);
  2129. }
  2130. }
  2131. if (!is_numeric($dic["name"]) || $dic["name"] > 1 || $dic["name"] < 0)
  2132. return new Response(Response::ERROR, "系统字典中设置的购房补贴年度比例应该是介于0~1之间的数字");
  2133. $housepurchase["talentArrangeMoney"] = round($dic["name"] * $amountStandard["money"], 2);
  2134. /* * 3.计算当年度录入享受其他政策的金额 */
  2135. $otherList = HouseApi::getEnjoyOtherList($old["id"]);
  2136. $housepurchase["nowOtherMoney"] = 0;
  2137. foreach ($otherList as $other) {
  2138. $housepurchase["nowOtherMoney"] += $other["money"];
  2139. }
  2140. $lastOtherMoney = $spouseHouseInfo ? $houseInfo["lastYearArrears"] + $spouseHouseInfo["lastYearArrears"] : $houseInfo["lastYearArrears"];
  2141. $housepurchase["lastOtherMoney"] = round($lastOtherMoney, 2);
  2142. $totalOtherMoney = round($housepurchase["nowOtherMoney"] + $housepurchase["lastOtherMoney"], 2);
  2143. /* * 计算当前人才层次可享受金额 */
  2144. $balanceMoney = round($amountStandard["money"] - ($houseInfo["houseMoney"] - $houseInfo["balanceMoney"]), 2);
  2145. /* * 判断余额 */
  2146. $balanceMoney = $balanceMoney >= $houseInfo["balanceMoney"] ? $houseInfo["balanceMoney"] : $balanceMoney;
  2147. if ($balanceMoney <= 0) {
  2148. $descideDesc[] = "可享受余额为:" . $balanceMoney . "元;";
  2149. /* * 判断享受其他政策是否大于0 */
  2150. if ($totalOtherMoney > 0) {
  2151. $housepurchase["isRecover"] = 1;
  2152. $descideDesc[] = "需要追讨金额为:" . $totalOtherMoney . "元;";
  2153. }
  2154. $housepurchase["shouldEnjoyMoney"] = 0;
  2155. $housepurchase["realEnjoyMoney"] = 0;
  2156. $housepurchase["nowSubOtherMoney"] = 0;
  2157. $housepurchase["nowNotSubOtherMoney"] = $totalOtherMoney;
  2158. } else {
  2159. /* * 比较余额和人才层次金额 */
  2160. $housepurchase["shouldEnjoyMoney"] = $balanceMoney >= $housepurchase["talentArrangeMoney"] ? $housepurchase["talentArrangeMoney"] : $balanceMoney;
  2161. /* * 计算可享受金额 */
  2162. $realEnjoyMoney = $housepurchase["shouldEnjoyMoney"] - $totalOtherMoney;
  2163. if ($realEnjoyMoney == 0) {
  2164. $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
  2165. $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
  2166. $housepurchase["nowNotSubOtherMoney"] = $realEnjoyMoney;
  2167. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
  2168. } else if ($realEnjoyMoney > 0) {
  2169. $housepurchase["realEnjoyMoney"] = $realEnjoyMoney;
  2170. $housepurchase["nowSubOtherMoney"] = $totalOtherMoney;
  2171. $housepurchase["nowNotSubOtherMoney"] = 0;
  2172. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录(因为本次已扣完) */
  2173. } else if ($realEnjoyMoney < 0) {
  2174. $housepurchase["isRecover"] = 1;
  2175. $descideDesc[] = "需要追讨金额为:" . abs($realEnjoyMoney) . "元;";
  2176. $housepurchase["realEnjoyMoney"] = 0;
  2177. $housepurchase["nowSubOtherMoney"] = $housepurchase["shouldEnjoyMoney"];
  2178. $housepurchase["nowNotSubOtherMoney"] = abs($realEnjoyMoney);
  2179. /* * 扣除个人剩余金额 ,扣除房产享受金额 ,删除申报人为扣除其他政策记录并生成新的未扣除记录 */
  2180. }
  2181. if ($type == 2) {
  2182. $houseInfo["count"] = $houseInfo["count"] + 1;
  2183. $houseInfo["balanceMoney"] = round($houseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"], 2);
  2184. $houseInfo["lastYearArrears"] = $housepurchase["nowSubOtherMoney"];
  2185. if (\StrUtil::isNotEmpAndNull($housepurchase["spouseIdcard"])) {
  2186. if (!$spouseHouseInfo) {
  2187. $spouseHouseInfo = [
  2188. "idCard" => $old["spouseIdcard"],
  2189. "spouseIdCard" => null,
  2190. "houseAddress" => $old["houseAddress"],
  2191. "houseArea" => $old["houseArea"],
  2192. "houseMoney" => $old["houseMoney"],
  2193. "recordTime" => $old["recordTime"],
  2194. "realEstateNo" => $old["realEstateNo"],
  2195. "recordNo" => $old["recordNo"],
  2196. "balanceMoney" => $houseInfo["balanceMoney"],
  2197. "count" => $houseInfo["count"],
  2198. "lastYearArrears" => $houseInfo["lastYearArrears"]
  2199. ];
  2200. } else {
  2201. $spouseHouseInfo["count"] = $spouseHouseInfo["count"] + 1;
  2202. $spouseHouseInfo["lastYearArrears"] = $houseInfo["lastYearArrears"];
  2203. $spouseHouseInfo["balanceMoney"] = $spouseHouseInfo["balanceMoney"] - $housepurchase["shouldEnjoyMoney"];
  2204. }
  2205. if ($spouseHouseInfo["id"]) {
  2206. $spouseHouseInfo["updateTime"] = date("Y-m-d H:i:s");
  2207. $spouseHouseInfo["updateUser"] = $this->user["uid"];
  2208. houseInfoModel::update($spouseHouseInfo);
  2209. } else {
  2210. $spouseHouseInfo["id"] = getStringId();
  2211. $spouseHouseInfo["createTime"] = date("Y-m-d H:i:s");
  2212. $spouseHouseInfo["createUser"] = $this->user["uid"];
  2213. houseInfoModel::insert($spouseHouseInfo);
  2214. }
  2215. }
  2216. if ($houseInfo["id"]) {
  2217. $houseInfo["updateTime"] = date("Y-m-d H:i:s");
  2218. $houseInfo["updateUser"] = $this->user["uid"];
  2219. houseInfoModel::update($houseInfo);
  2220. } else {
  2221. $houseInfo["id"] = getStringId();
  2222. $houseInfo["createTime"] = date("Y-m-d H:i:s");
  2223. $houseInfo["createUser"] = $this->user["uid"];
  2224. houseInfoModel::insert($houseInfo);
  2225. }
  2226. }
  2227. }
  2228. $housepurchase["decideDetail"] = $old["decideDetail"] . ($descideDesc ? implode("", $descideDesc) : "");
  2229. return new Response(Response:: SUCCESS, "", $housepurchase);
  2230. }
  2231. private function setHousepurchase($request) {
  2232. $name = \StrUtil::getRequestDecodeParam($request, "name");
  2233. $idCard = \StrUtil::getRequestDecodeParam($request, "idCard");
  2234. $yearStr = \StrUtil::getRequestDecodeParam($request, "year");
  2235. $talentArrangeStr = \StrUtil::getRequestDecodeParam($request, "talentArrange");
  2236. $spouseName = \StrUtil::getRequestDecodeParam($request, "spouseName");
  2237. $spouseIdcard = \StrUtil::getRequestDecodeParam($request, "spouseIdcard");
  2238. $childName = \StrUtil::getRequestDecodeParam($request, "childName");
  2239. $childIdCard = \StrUtil::getRequestDecodeParam($request, "childIdCard");
  2240. $marryStatus = \StrUtil::getRequestDecodeParam($request, "marryStatus");
  2241. $checkStateStr = \StrUtil::getRequestDecodeParam($request, "checkState");
  2242. $isConflictStr = \StrUtil::getRequestDecodeParam($request, "isConflict");
  2243. $isRecoverStr = \StrUtil::getRequestDecodeParam($request, "isRecover");
  2244. $talentArrange = null;
  2245. $year = null;
  2246. $checkState = null;
  2247. $isRecover = null;
  2248. $isConflict = null;
  2249. if (\StrUtil::isNotEmpAndNull($talentArrangeStr)) {
  2250. $talentArrange = intval($talentArrangeStr);
  2251. }
  2252. if (\StrUtil::isNotEmpAndNull($yearStr)) {
  2253. $year = intval($yearStr);
  2254. }
  2255. if (\StrUtil::isNotEmpAndNull($checkStateStr)) {
  2256. $checkState = intval($checkStateStr);
  2257. }
  2258. if (\StrUtil::isNotEmpAndNull($isConflictStr)) {
  2259. $isConflict = intval($isConflictStr);
  2260. }
  2261. if (\StrUtil::isNotEmpAndNull($isRecoverStr)) {
  2262. $isRecover = intval($isRecoverStr);
  2263. }
  2264. $obj = ["year" => $year,
  2265. "name" => $name, "cardType" => null, "idCard" => $idCard, "talentArrange" => $talentArrange,
  2266. "spouseName" => $spouseName, "spouseIdcard" => $spouseIdcard, "childName" => $childName, "childIdCard" => $childIdCard,
  2267. "marryStatus" => $marryStatus, "checkState" => $checkState, "publicState" => null, "cashType" => null, "isRecover" => $isRecover, "isConflict" => $isConflict];
  2268. return $obj;
  2269. }
  2270. }