House.php 83 KB

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