House.php 96 KB

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