House.php 96 KB

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