House.php 116 KB

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