House.php 111 KB

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