LivingAllowance.php 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\EnterpriseApi;
  6. use app\common\api\LivingAllowanceApi;
  7. use app\common\state\LivingAllowanceState as LaState;
  8. use app\common\state\CommonConst;
  9. use app\common\model\TalentLog;
  10. use app\common\state\ProjectState;
  11. use app\common\model\LivingAllowance as LaModel;
  12. use app\common\api\DictApi;
  13. use think\facade\Db;
  14. /**
  15. * Description of LivingAllowance
  16. *
  17. * @author sgq
  18. */
  19. class LivingAllowance extends AdminController {
  20. public function index() {
  21. $enterpriseList = EnterpriseApi::getSimpleList();
  22. $provinceList = \app\common\api\LocationApi::findProvinceSelect();
  23. $process = $this->request->param("process");
  24. $message = [];
  25. if ($this->user["type"] == 1) {
  26. $message["typeName"] = "晋江市硕博人才生活补贴申报";
  27. $message["address"] = "聚才网/人才晋江微信公众号";
  28. $message["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  29. $message["phone"] = "0595-85633128";
  30. $message["email"] = "jjrc85661234@163.com";
  31. } else if ($this->user["type"] == 2) {
  32. $message["typeName"] = "晋江市硕博人才生活补贴申报";
  33. $message["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  34. $message["dep"] = "集成电路产业园区";
  35. $message["phone"] = "0595-82250007、0595-82250001";
  36. $message["email"] = "jjjcdr@163.com";
  37. }
  38. return view("", ["enterpriseList" => $enterpriseList, "provinceList" => $provinceList, "process" => $process, "message" => $message]);
  39. }
  40. public function list() {
  41. $res = LivingAllowanceApi::getList($this->request->param());
  42. return json($res);
  43. }
  44. public function detail() {
  45. $id = $this->request->param("id");
  46. $process = $this->request->param("process");
  47. $info = LivingAllowanceApi::getInfoById($id);
  48. $info = $this->translateToChinese($info);
  49. return view("", ["row" => $info, "process" => $process]);
  50. }
  51. private function translateToChinese($obj) {
  52. if ($obj["industryFieldNew"]) {
  53. $obj["industryFieldNewName"] = DictApi::findByParentCodeAndCode("industry_field", $obj["industryFieldNew"])["name"];
  54. }
  55. if ($obj["industryField"]) {
  56. $industry_field_type = $obj["industryFieldNew"] ? $obj["industryFieldNew"] . "_field" : "un_industryField";
  57. $obj["industryFieldName"] = DictApi::findByParentCodeAndCode($industry_field_type, $obj["industryField"])["name"];
  58. }
  59. if ($obj["address"]) {
  60. $obj["streetName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  61. }
  62. if ($obj["nationality"]) {
  63. $obj["nationalityName"] = DictApi::findByParentCodeAndCode("nationality", $obj["nationality"])["name"];
  64. }
  65. if ($obj["nation"]) {
  66. $obj["nationName"] = DictApi::findByParentCodeAndCode("nation", $obj["nation"])["name"];
  67. }
  68. if ($obj["politics"]) {
  69. $obj["politicsName"] = DictApi::findByParentCodeAndCode("politics", $obj["politics"])["name"];
  70. }
  71. if ($obj["highEducation"]) {
  72. $obj["educationName"] = DictApi::findByParentCodeAndCode("highest_degree", $obj["highEducation"])["name"];
  73. }
  74. if ($obj["introductionMode"]) {
  75. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("un_introduction_mode", $obj["introductionMode"])["name"];
  76. }
  77. if ($obj["declareType"]) {
  78. $obj["declareTypeName"] = DictApi::findByParentCodeAndCode("un_master_education", $obj["declareType"])["name"];
  79. }
  80. if ($obj["cardType"] == 1) {
  81. $obj["cardTypeName"] = "身份证";
  82. } else if ($obj["cardType"] == 2) {
  83. $obj["cardTypeName"] = "通行证";
  84. } else if ($obj["cardType"] == 3) {
  85. $obj["cardTypeName"] = "护照";
  86. } else {
  87. $obj["cardTypeName"] = "未知";
  88. }
  89. return $obj;
  90. }
  91. /**
  92. * 校验是否在审核范围内
  93. * @param type $id
  94. * @param type $process
  95. * @return type
  96. */
  97. public function validateIsCheck($id, $process) {
  98. $oldInfo = \app\common\api\LivingAllowanceApi::getInfoById($id);
  99. $responseObj = new \stdClass();
  100. $responseObj->code = 500;
  101. switch ($process) {
  102. case 1:
  103. if ($oldInfo["checkState"] != LaState::LA_NEED_FIRST_CHECK && $oldInfo["checkState"] != LaState::LA_DEP_REJECT) {
  104. $responseObj->msg = "该申报不在审核范围内,无法审核";
  105. } else {
  106. $responseObj->code = 200;
  107. $responseObj->msg = "";
  108. }
  109. break;
  110. case 2:
  111. $company = getCacheById("Company", $this->user["companyId"]);
  112. if ($oldInfo["checkState"] != LaState::LA_NEED_DEP_CHECK && $oldInfo["checkState"] != LaState::LA_THIRD_REJECT) {
  113. $responseObj->msg = "该申报不在审核范围内,无法审核";
  114. } else if ($company["code"] != CommonConst::JYJ) {
  115. $responseObj->msg = "部门审核仅教育局能够审核!";
  116. } else {
  117. $responseObj->code = 200;
  118. $responseObj->msg = "";
  119. }
  120. break;
  121. case 3:
  122. if ($oldInfo["checkState"] != LaState::LA_NEED_THIRD) {
  123. $responseObj->msg = "该申报不在审核范围内,无法审核";
  124. } else if ($oldInfo["creditStatus"] == 1) {
  125. $responseObj->msg = "当前申报数据未导入核查数据,无法审核";
  126. } else {
  127. $responseObj->code = 200;
  128. $responseObj->msg = "";
  129. }
  130. break;
  131. case 4:
  132. break;
  133. }
  134. if ($responseObj->code == 500) {
  135. return json($responseObj);
  136. }
  137. $where = [];
  138. $where[] = ["mainId", "=", $id];
  139. $where[] = ["active", "=", 2];
  140. $where[] = ["step", "=", $process];
  141. $log = TalentLog::where($where)->order("createTime desc")->find();
  142. if ($log) {
  143. $oldInfo["checkState"] = $log["state"];
  144. $oldInfo["checkMsg"] = $log["description"];
  145. } else {
  146. $oldInfo["checkState"] = null;
  147. $oldInfo["checkMsg"] = "";
  148. }
  149. $res = [];
  150. $res["obj"] = $oldInfo;
  151. if ($responseObj->code == 200) {
  152. $where = [];
  153. $where[] = ["project", "=", ProjectState::LIVINGALLOWANCE];
  154. $where[] = ["active", "=", 1];
  155. $where[] = ["type", "=", $oldInfo["type"]];
  156. $fileTypeList = \app\common\model\FileType::where($where)->order("sn")->select()->toArray();
  157. $res["fileList"] = $fileTypeList;
  158. }
  159. $responseObj->obj = $res;
  160. return json($responseObj);
  161. }
  162. /**
  163. * 审核
  164. * @return type
  165. */
  166. public function check() {
  167. $responseObj = new \stdClass();
  168. $responseObj->code = 500;
  169. $obj = $this->request->param();
  170. if (!$obj) {
  171. $responseObj->msg = "系统错误,请联系管理员";
  172. return json($responseObj);
  173. }
  174. if (!$obj["checkState"]) {
  175. $responseObj->msg = "请选择审核状态";
  176. return json($responseObj);
  177. }
  178. Db::startTrans();
  179. try {
  180. //保存驳回字段
  181. $updData["id"] = $obj["id"];
  182. $updData["fields"] = $obj["fields"];
  183. $updData["files"] = $obj["files"];
  184. Db::table("md_living_allowance_info")->save($updData);
  185. //加入日志
  186. $newLog["id"] = getStringId();
  187. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  188. $newLog["mainId"] = $obj["id"];
  189. $newLog["active"] = 2;
  190. $newLog["state"] = $obj["checkState"];
  191. $newLog["step"] = $obj["process"];
  192. $newLog["stateChange"] = "保存未提交";
  193. $newLog["description"] = $obj["checkMsg"];
  194. $newLog["createTime"] = date("Y-m-d H:i:s");
  195. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  196. Db::table("new_talent_checklog")->insert($newLog);
  197. $responseObj->code = 200;
  198. $responseObj->msg = "审核成功";
  199. Db::commit();
  200. return json($responseObj);
  201. } catch (\Exception $e) {
  202. Db::rollback();
  203. $responseObj->msg = $e->getMessage();
  204. return json($responseObj);
  205. }
  206. }
  207. /**
  208. * 审核不通过
  209. * @return type
  210. */
  211. public function setNotPass() {
  212. $responseObj = new \stdClass();
  213. $responseObj->code = 500;
  214. $ids = trim($this->request->param("ids"));
  215. $msg = trim($this->request->param("msg"));
  216. $ids = array_filter(explode(",", $ids));
  217. if (!$ids) {
  218. $responseObj->msg = "请选择需要设置审核不通过的数据";
  219. return json($responseObj);
  220. }
  221. if (!$msg) {
  222. $responseObj->msg = "请填写审核不通过的原因";
  223. return json($responseObj);
  224. }
  225. $where = [];
  226. $where[] = ["id", "in", $ids];
  227. $list = LaModel::where($where)->select()->toArray();
  228. $updates = [];
  229. $newLogs = [];
  230. $sb = [];
  231. Db::startTrans();
  232. try {
  233. foreach ($list as $obj) {
  234. if ($obj["checkState"] != LaState::LA_SAVE && $obj["checkState"] != LaState::LA_FIRST_REJECT) {
  235. $sb[] = $obj["name"];
  236. }
  237. $oldState = $obj["checkState"];
  238. $newState = LaState::LA_NOTPASS;
  239. $update = [
  240. "id" => $obj["id"],
  241. "checkState" => $newState,
  242. "checkMsg" => $msg
  243. ];
  244. $updates[] = $update;
  245. Db::table("md_living_allowance_info")->save($update);
  246. $newLog["id"] = getStringId();
  247. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  248. $newLog["mainId"] = $obj["id"];
  249. $newLog["active"] = 1;
  250. $newLog["state"] = $newState;
  251. $newLog["step"] = 70; //审核不通过
  252. $newLog["stateChange"] = LaState::getStateDesc($oldState) . "->" . LaState::getStateDesc($newState);
  253. $newLog["description"] = "原因:" . $msg;
  254. $newLog["createTime"] = date("Y-m-d H:i:s");
  255. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  256. $newLogs[] = $newLog;
  257. }
  258. if ($sb) {
  259. $responseObj->msg = implode(",", $sb) . "的审核状态既不是待提交,也不是初审驳回";
  260. return json($responseObj);
  261. }
  262. if (!$updates || !$newLogs) {
  263. $responseObj->msg = "没有待审核项";
  264. return json($responseObj);
  265. }
  266. Db::table("new_talent_checklog")->insertAll($newLogs);
  267. Db::commit();
  268. $responseObj->code = 200;
  269. $responseObj->msg = "设置审核不通过成功";
  270. return json($responseObj);
  271. } catch (\Exception $e) {
  272. Db::rollback();
  273. return json(["msg" => "设置审核不通过失败:" . $e->getMessage()]);
  274. }
  275. }
  276. public function submitCheck() {
  277. $id = $this->request->param("id");
  278. $process = $this->request->param("process");
  279. $responseObj = new \stdClass();
  280. $responseObj->code = 500;
  281. if (!$id) {
  282. $responseObj->msg = "系统错误,请联系管理员!";
  283. return json($responseObj);
  284. }
  285. $oldInfo = \app\common\api\LivingAllowanceApi::getInfoById($id);
  286. $oldState = $oldInfo["checkState"];
  287. $where = [];
  288. $where[] = ["mainId", "=", $id];
  289. $where[] = ["active", "=", 2];
  290. $where[] = ["step", "=", $process];
  291. $oldLog = TalentLog::where($where)->order("createTime desc")->find();
  292. if (!$oldLog) {
  293. $responseObj->msg = "请先审核后再提交";
  294. return json($responseObj);
  295. }
  296. $company = getCacheById("Company", $this->user["companyId"]);
  297. if ($process == 2 && $company["code"] != CommonConst::JYJ) {
  298. $responseObj->msg = "部门审核仅教育局能够审核!";
  299. return $responseObj;
  300. }
  301. $updData = [];
  302. $updData["id"] = $id;
  303. if (!$oldInfo["highProcess"]) {
  304. $updData["highProcess"] = $process;
  305. } else {
  306. $updData["highProcess"] = $oldInfo["process"] < $process ? $process : $oldInfo["highProcess"];
  307. }
  308. switch ($process) {
  309. case 1:
  310. if ($oldLog["state"] == -1) {
  311. $updData["checkState"] = LaState::LA_NOTPASS;
  312. $updData["recommendAmount"] = 0;
  313. $updData["isPay"] = -1;
  314. $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
  315. $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
  316. }
  317. if ($oldLog["state"] == 2) {
  318. $updData["checkState"] = LaState::LA_FIRST_REJECT;
  319. //MessageRecord record = new MessageRecord(old.getId(), 2, 2, old.getName(), old.getPhone(), null, SmsProperties.MASTER_ALLOWANCE_REJECT);
  320. //Sms253Util.sendMessage(record);
  321. }
  322. //审核通过
  323. if ($oldLog["state"] == 3) {
  324. $updData["checkState"] = LaState::LA_NEED_DEP_CHECK;
  325. $updData["firstPassTime"] = date("Y-m-d H:i:s");
  326. }
  327. break;
  328. case 2:
  329. if ($oldLog["state"] == -1) {
  330. $updData["checkState"] = LaState::LA_NOTPASS;
  331. $updData["recommendAmount"] = 0;
  332. $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
  333. $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
  334. $updData["recommendIsPay"] = -1;
  335. }
  336. if ($oldLog["state"] == 2) {
  337. $updData["checkState"] = LaState::LA_DEP_REJECT;
  338. $updData["creditStatus"] = 1;
  339. $updData["recommendAmount"] = null;
  340. $updData["recommendAmountDesc"] = "";
  341. $updData["recommendJudgmentDetails"] = "";
  342. $updData["recommendIsPay"] = 0;
  343. }
  344. if ($oldLog["state"] == 3) {
  345. $updData["checkState"] = LaState::LA_NEED_THIRD;
  346. $updData["firstDepPassTime"] = date("Y-m-d H:i:s");
  347. $_updData = $this->calculateAmount($oldInfo);
  348. $updData = array_merge($updData, $_updData);
  349. }
  350. break;
  351. case 3:
  352. if ($oldLog["state"] == -1) {
  353. $updData["checkState"] = LaState::LA_NOTPASS;
  354. $updData["recommendAmount"] = 0;
  355. $updData["recommendAmountDesc"] = "审核不通过,不予兑现";
  356. $updData["recommendJudgmentDetails"] = "审核不通过,不予兑现";
  357. $updData["recommendIsPay"] = -1;
  358. }
  359. if ($oldLog["state"] == 2) {
  360. $updData["checkState"] = LaState::LA_DEP_REJECT;
  361. $updData["creditStatus"] = 1;
  362. $updData["recommendAmount"] = null;
  363. $updData["recommendAmountDesc"] = "";
  364. $updData["recommendJudgmentDetails"] = "";
  365. $updData["recommendIsPay"] = 0;
  366. }
  367. if ($oldLog["state"] == 3) {
  368. $updData["checkState"] = LaState::LA_PASS;
  369. $updData["isPublic"] = 2;
  370. }
  371. break;
  372. }
  373. $newLog["id"] = getStringId();
  374. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  375. $newLog["mainId"] = $id;
  376. $newLog["active"] = 1;
  377. $newLog["state"] = $oldLog["state"];
  378. $newLog["step"] = $process;
  379. $newLog["stateChange"] = LaState::getStateDesc($oldState) . "->" . LaState::getStateDesc($updData["checkState"]);
  380. $newLog["description"] = $oldLog["description"];
  381. $newLog["createTime"] = date("Y-m-d H:i:s");
  382. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  383. Db::startTrans();
  384. try {
  385. $where = [];
  386. $where[] = ["mainId", "=", $id];
  387. $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
  388. $where[] = ["active", "=", 2];
  389. Db::table("new_talent_checklog")->where($where)->delete();
  390. Db::table("new_talent_checklog")->insert($newLog);
  391. Db::table("md_living_allowance_info")->save($updData);
  392. Db::commit();
  393. $responseObj->code = 200;
  394. $responseObj->msg = "提交审核成功";
  395. return json($responseObj);
  396. } catch (\think\db\exception\DbException $e) {
  397. Db::rollback();
  398. $responseObj->msg = $e->getMessage();
  399. return json($responseObj);
  400. }
  401. }
  402. /**
  403. * 查询需要处理的数据
  404. */
  405. public function selectNeedCheckData() {
  406. $response = new \stdClass();
  407. $response->code = 500;
  408. $user = $this->user;
  409. $type = $this->request->param("type");
  410. $id = $this->request->param("id");
  411. $name = \StrUtil::getRequestDecodeParam($this->request, "name");
  412. $sex = $this->request->param("sex");
  413. $checkState = $this->request->param("checkState");
  414. if (!in_array($user["type"], [1, 2])) {
  415. $response->msg = "当前账号类型没有操作权限";
  416. return json($response);
  417. }
  418. $where = [];
  419. $where[] = ["type", "=", $user["type"]];
  420. if ($name) {
  421. $where[] = ["name", "like", "%" . $name . "%"];
  422. }
  423. if ($sex) {
  424. $where[] = ["sex", "=", $sex];
  425. }
  426. if ($checkState) {
  427. $where[] = ["checkState", "=", $checkState];
  428. }
  429. switch ($type) {
  430. case 1:
  431. $where[] = ["isPublic", "=", 1];
  432. $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
  433. break;
  434. case 2:
  435. $where[] = ["isPublic", "=", 1];
  436. $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
  437. break;
  438. case 3: //公示
  439. case 7: //公示预览
  440. $where[] = ["isPublic", "=", 2];
  441. $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
  442. break;
  443. case 4:
  444. $where[] = ["isPublic", "=", 3];
  445. $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
  446. break;
  447. case 6:
  448. $where[] = ["isPublic", "=", 4];
  449. $where[] = ["checkState", "=", LaState::LA_PASS];
  450. break;
  451. }
  452. $list = Db::table("md_living_allowance_info")->field("id,idCard,name,enterpriseName,checkState")->where($where)->select()->toArray();
  453. $response->obj = ["rows" => $list, "total" => count($list)];
  454. $response->code = 200;
  455. return json($response);
  456. }
  457. /**
  458. * 通用导出
  459. * @return type
  460. */
  461. public function commonExport() {
  462. $response = new \stdClass();
  463. $response->code = 500;
  464. $request = $this->request;
  465. $user = $this->user;
  466. if (!in_array($user["type"], [1, 2])) {
  467. $response->msg = "当前账号类型没有操作权限";
  468. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  469. }
  470. $process = $request["process"];
  471. $names = \StrUtil::getRequestDecodeParam($request, "names");
  472. $values = \StrUtil::getRequestDecodeParam($request, "values");
  473. $title = array_filter(explode(",", $names)); //exce标题
  474. $keys = array_filter(explode(",", $values)); //标题对应的字段
  475. $where = [];
  476. $where[] = ["type", "=", $user["type"]];
  477. if ($_where = LivingAllowanceApi::setLivingAllowanceCheckStateCondition($request->param())) {
  478. $where = array_merge($where, $_where);
  479. }
  480. if ($_where2 = LivingAllowanceApi::getWhereByParams($request->param())) {
  481. $where = array_merge($where, $_where2);
  482. }
  483. if (in_array("declareTypeName", $keys)) {
  484. $declareTypeMap = DictApi::selectByParentCode("un_master_education");
  485. }
  486. if (in_array("nationalityName", $keys)) {
  487. $nationalityMap = DictApi::selectByParentCode("nationality");
  488. }
  489. if (in_array("nationName", $keys)) {
  490. $nationaMap = DictApi::selectByParentCode("nation");
  491. }
  492. if (in_array("industryFieldNewName", $keys)) {
  493. $industryFieldNewMap = DictApi::selectByParentCode("industry_field");
  494. }
  495. if (in_array("industryFieldName", $keys)) {
  496. $industryFieldMap = DictApi::selectByParentCode("un_industryField");
  497. }
  498. if (in_array("streetName", $keys)) {
  499. $streetMap = DictApi::selectByParentCode("street");
  500. }
  501. if (in_array("politicsName", $keys)) {
  502. $politicsMap = DictApi::selectByParentCode("politics");
  503. }
  504. if (in_array("educationName", $keys)) {
  505. $highEducationMap = DictApi::selectByParentCode("highest_degree");
  506. }
  507. if (in_array("introductionModeName", $keys)) {
  508. $introductionModeMap = DictApi::selectByParentCode("un_introduction_mode");
  509. }
  510. $list = LaModel::where($_where)->select()->toArray();
  511. $nationalityOldAndNew = [
  512. "01" => "cn",
  513. "02" => "cn_hk",
  514. "03" => "cn_mc",
  515. "04" => "cn_tw",
  516. "05" => "us",
  517. "06" => "en",
  518. "07" => "jp",
  519. "08" => "co",
  520. "09" => "nl",
  521. "10" => "sg",
  522. "11" => "other"
  523. ];
  524. foreach ($list as $key => $item) {
  525. if (in_array("declareTypeName", $keys)) {
  526. $list[$key]["declareTypeName"] = $declareTypeMap[$item["declareType"]];
  527. }
  528. if (in_array("nationalityName", $keys)) {
  529. $list[$key]["nationalityName"] = $nationalityMap[$item["nationality"]] ?: $nationalityMap[$nationalityOldAndNew[$item["nationality"]]];
  530. }
  531. if (in_array("nationName", $keys)) {
  532. $list[$key]["nationName"] = $nationaMap[$item["nation"]];
  533. }
  534. if (in_array("industryFieldNewName", $keys)) {
  535. $list[$key]["industryFieldNewName"] = $industryFieldNewMap[$item["industryFieldNew"]];
  536. }
  537. if (in_array("industryFieldName", $keys)) {
  538. if ($item["industryFieldNew"]) {
  539. $list[$key]["industryFieldName"] = DictApi::findByParentCodeAndCode($item["industryFieldNew"] . "_field", $item["industryField"])["name"];
  540. } else {
  541. $list[$key]["industryFieldName"] = $industryFieldMap[$item["industryField"]];
  542. }
  543. }
  544. if (in_array("streetName", $keys)) {
  545. $list[$key]["streetName"] = $streetMap[$item["address"]];
  546. }
  547. if (in_array("politicsName", $keys)) {
  548. $list[$key]["politicsName"] = $politicsMap[$item["politics"]];
  549. }
  550. if (in_array("educationName", $keys)) {
  551. $list[$key]["educationName"] = $highEducationMap[$item["highEducation"]];
  552. }
  553. if (in_array("introductionModeName", $keys)) {
  554. $list[$key]["introductionModeName"] = $introductionModeMap[$item["introductionMode"]];
  555. }
  556. if (in_array("introductionMethodName", $keys)) {
  557. $list[$key]["introductionMethodName"] = $item["introductionMethod"] == 1 ? "新引进" : "其他";
  558. }
  559. if (in_array("sexName", $keys)) {
  560. $list[$key]["sexName"] = $item["sex"] == 1 ? "男" : "女";
  561. }
  562. if (in_array("cardTypeName", $keys)) {
  563. switch ($item["cardType"]) {
  564. case 1:
  565. $list[$key]["cardTypeName"] = "身份证";
  566. break;
  567. case 2:
  568. $list[$key]["cardTypeName"] = "通行证";
  569. break;
  570. case 3:
  571. $list[$key]["cardTypeName"] = "护照";
  572. break;
  573. default:
  574. $list[$key]["cardTypeName"] = "未知";
  575. break;
  576. }
  577. }
  578. if (in_array("isPublicName", $keys)) {
  579. switch ($item["isPublic"]) {
  580. case 1:
  581. $list[$key]["isPublicName"] = "待核查征信";
  582. break;
  583. case 2:
  584. $list[$key]["isPublicName"] = "待公示";
  585. break;
  586. case 3:
  587. $list[$key]["isPublicName"] = "公示中";
  588. break;
  589. case 4:
  590. $list[$key]["isPublicName"] = "待兑现";
  591. break;
  592. case 5:
  593. $list[$key]["isPublicName"] = "已兑现";
  594. break;
  595. }
  596. }
  597. if (in_array("studyAbroadName", $keys)) {
  598. $list[$key]["studyAbroadName"] = $item["studyAbroad"] == 1 ? "是" : "否";
  599. }
  600. if (in_array("recommendIsPayName", $keys)) {
  601. if ($item["recommendIsPay"] == -1) {
  602. $list[$key]["recommendIsPayName"] = "不予兑现";
  603. }
  604. if ($item["recommendIsPay"] == 0) {
  605. $list[$key]["recommendIsPayName"] = "未知";
  606. }
  607. if ($item["recommendIsPay"] == 1) {
  608. $list[$key]["recommendIsPayName"] = "待兑现";
  609. }
  610. if ($item["recommendIsPay"] == 2) {
  611. $list[$key]["recommendIsPayName"] = "已兑现";
  612. }
  613. }
  614. if (in_array("isPayName", $keys)) {
  615. if ($item["isPay"] == -1) {
  616. $list[$key]["isPayName"] = "不予兑现";
  617. }
  618. if ($item["isPay"] == 0) {
  619. $list[$key]["isPayName"] = "未知";
  620. }
  621. if ($item["isPay"] == 1) {
  622. $list[$key]["isPayName"] = "待兑现";
  623. }
  624. if ($item["isPay"] == 2) {
  625. $list[$key]["isPayName"] = "已兑现";
  626. }
  627. }
  628. if (in_array("creditStatusName", $keys)) {
  629. if ($item["creditStatus"] == 1) {
  630. $list[$key]["creditStatusName"] = "待核查征信";
  631. }
  632. if ($item["creditStatus"] == 2) {
  633. $list[$key]["creditStatusName"] = "征信通过";
  634. }
  635. if ($item["creditStatus"] == 3) {
  636. $list[$key]["creditStatusName"] = "征信失信";
  637. }
  638. }
  639. if ($process && in_array("checkStateName", $keys)) {
  640. switch ($process) {
  641. case 1:
  642. if ($item["checkState"] == -1) {
  643. $list[$key]["checkStateName"] = "审核不通过";
  644. } else if ($item["checkState"] == 1) {
  645. $list[$key]["checkStateName"] = "待提交";
  646. } else if ($item["checkState"] == 10) {
  647. $list[$key]["checkStateName"] = "已驳回";
  648. } else if ($item["checkState"] == 15 || $item["checkState"] >= 25 || $item["checkState"] >= 35) {
  649. $list[$key]["checkStateName"] = "已通过";
  650. } else if ($item["checkState"] == 7) {
  651. $list[$key]["checkStateName"] = $item["highProcess"] >= 1 ? "重新提交" : "待审核";
  652. } else if ($item["checkState"] == 20) {
  653. $list[$key]["checkStateName"] = $item["highProcess"] >= 1 ? "上级驳回" : "待审核";
  654. }
  655. break;
  656. case 3:
  657. if ($item["checkState"] == -1) {
  658. $list[$key]["checkStateName"] = "审核不通过";
  659. } else if ($item["checkState"] == 25) {
  660. $list[$key]["checkStateName"] = $item["highProcess"] >= 3 ? "重新提交" : "待审核";
  661. } else if ($item["checkState"] == 30 || $item["checkState"] <= 20) {
  662. $list[$key]["checkStateName"] = "已驳回";
  663. } else if ($item["checkState"] == 35) {
  664. $list[$key]["checkStateName"] = "已通过";
  665. }
  666. break;
  667. case 4:
  668. if ($item["checkState"] == -1) {
  669. $list[$key]["checkStateName"] = "审核不通过";
  670. } else if ($item["checkState"] == 35) {
  671. $list[$key]["checkStateName"] = "已通过";
  672. }
  673. break;
  674. case 5:
  675. $list[$key]["checkStateName"] = "已通过";
  676. break;
  677. }
  678. }
  679. }
  680. $fileName = "硕博人才生活补贴申报导出";
  681. if ($process == 1) {
  682. $fileName = "硕博人才生活补贴初审导出";
  683. } else if ($process == 2) {
  684. $fileName = "硕博人才生活补贴部门审核导出";
  685. } else if ($process == 3) {
  686. $fileName = "硕博人才生活补贴复核导出";
  687. } else if ($process == 4) {
  688. $fileName = "硕博人才生活补贴兑现导出";
  689. }
  690. $rows = [];
  691. foreach ($list as $item) {
  692. $row = [];
  693. foreach ($keys as $k) {
  694. $row[] = $item[$k];
  695. }
  696. $rows[] = $row;
  697. }
  698. if (!$rows) {
  699. $response->msg = "没有可导出的内容";
  700. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  701. }
  702. export($title, $rows, $fileName);
  703. }
  704. /**
  705. * 导出核查征信名单
  706. * @auth {{/talentInfo/exportHczx}}
  707. */
  708. public function exportHczx() {
  709. $response = new \stdClass();
  710. $response->code = 500;
  711. $user = $this->user;
  712. if (!in_array($user["type"], [1, 2])) {
  713. $response->msg = "当前账号类型没有操作权限";
  714. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  715. }
  716. $where = [];
  717. $ids = array_filter(explode(",", $this->request->param("ids")));
  718. $where[] = ["id", "in", $ids];
  719. $list = LaModel::where($where)->select()->toArray();
  720. $nationalitys = DictApi::selectByParentCode("nationality"); //查询国籍字典表
  721. if (!$list) {
  722. $response->msg = "暂无可核查征信的数据";
  723. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  724. }
  725. $title = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
  726. $exportList = [];
  727. for ($i = 0; $i < count($list); $i++) {
  728. $tmp = $list[$i];
  729. $exportList[] = [
  730. $i + 1, $tmp["name"], $nationalitys[$tmp["nationality"]], $tmp["idCard"], $tmp["enterpriseName"], $tmp["outMsg"], $tmp["actualSocialSecurity"], $tmp["actualTax"], $tmp["actualBusinessRegistration"]
  731. ];
  732. }
  733. $fileName = "硕博人才生活补贴核查征信名单导出";
  734. export($title, $exportList, $fileName);
  735. }
  736. /**
  737. * 公示预览
  738. */
  739. public function exportPublic() {
  740. $response = new \stdClass();
  741. $response->code = 500;
  742. $user = $this->user;
  743. $ids = array_filter(explode(",", $this->request->param("ids")));
  744. $batch = date("Ym");
  745. //查询需要公示的数据(勾选)
  746. $where = [];
  747. $where[] = ["id", "in", $ids];
  748. $list = LaModel::where($where)->order("enterpriseId")->select()->toArray();
  749. $rows = [];
  750. for ($i = 0; $i < count($list); $i++) {
  751. $obj = $list[$i];
  752. $obj["sexName"] = $obj["sex"] == 1 ? "男" : "女";
  753. $obj["sn"] = $i + 1;
  754. if ($obj["checkState"] == LaState::LA_NOTPASS) {
  755. $where = [];
  756. $where[] = ["mainId", "=", $obj["id"]];
  757. $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
  758. $where[] = ["step", "=", 3];
  759. $where[] = ["state", "<>", 8];
  760. $log = TalentLog::where($where)->order("createTime desc")->find();
  761. if ($log && $log["state"] == -1) {
  762. $obj["description"] = $log["description"];
  763. }
  764. if ($obj["outMsg"]) {
  765. $obj["description"] = ($log["description"] ? $log["description"] : "") . $obj["outMsg"];
  766. }
  767. $obj["stateName"] = "审核不通过";
  768. }
  769. if ($obj["checkState"] == LaState::LA_PASS) {
  770. $obj["stateName"] = "审核通过";
  771. }
  772. $rows[] = [
  773. $obj["sn"], $obj["name"], $obj["sexName"], $obj["enterpriseName"], $obj["stateName"], $obj["description"]
  774. ];
  775. }
  776. $title = ["序号", "姓名", "性别", "工作单位", "审核状态", "备注"];
  777. $fileName = "硕博人才生活补贴申报第" . $batch . "批次公示导出";
  778. $titleName = "";
  779. if ($user["type"] == 1) {
  780. $titleName = substr($batch, 0, 4) . "年" . substr($batch, 4, 6) . "月硕博人才生活补贴申报对象公示名单";
  781. }
  782. if ($user["type"] == 2) {
  783. $titleName = substr($batch, 0, 4) . "年" . substr($batch, 4, 6) . "月硕博人才生活补贴申报对象公示名单";
  784. }
  785. export($title, $rows, $fileName, [], $titleName);
  786. }
  787. /**
  788. * 公示导出
  789. */
  790. public function publicExport() {
  791. $response = new \stdClass();
  792. $response->code = 500;
  793. $user = $this->user;
  794. if (!in_array($user["type"], [1, 2])) {
  795. $response->msg = "当前账号类型没有操作权限";
  796. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  797. }
  798. $startTime = $this->request["startTime"];
  799. $endTime = $this->request["endTime"];
  800. $where = [];
  801. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  802. $where[] = ["type", "=", $user["type"]];
  803. $list = LaModel::where($where)->order("publicBatch")->select()->toArray();
  804. if (!$list) {
  805. $response->msg = "所选时间段内无公示数据";
  806. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  807. }
  808. $rows = [];
  809. for ($i = 0; $i < count($list); $i++) {
  810. $obj = $list[$i];
  811. $obj["sexName"] = $obj["sex"] == 1 ? "男" : "女";
  812. $obj["sn"] = $i + 1;
  813. if ($obj["checkState"] == LaState::LA_NOTPASS) {
  814. $where = [];
  815. $where[] = ["mainId", "=", $obj["id"]];
  816. $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
  817. $where[] = ["step", "=", 3];
  818. $where[] = ["state", "<>", 8];
  819. $log = TalentLog::where($where)->order("createTime desc")->find();
  820. if ($log && $log["state"] == -1) {
  821. $obj["description"] = $log["description"];
  822. }
  823. if ($obj["outMsg"]) {
  824. $obj["description"] = ($log["description"] ? $log["description"] : "") . $obj["outMsg"];
  825. }
  826. $obj["stateName"] = "审核不通过";
  827. }
  828. if ($obj["checkState"] == LaState::LA_PASS) {
  829. $obj["stateName"] = "审核通过";
  830. }
  831. $rows[] = [
  832. $obj["sn"], $obj["publicBatch"], $obj["name"], $obj["sexName"], $obj["enterpriseName"], $obj["stateName"], $obj["description"]
  833. ];
  834. }
  835. $title = ["序号", "公示批次", "姓名", "性别", "工作单位", "审核状态", "备注"];
  836. $fileName = "硕博人才生活补贴公示导出";
  837. $titleName = "";
  838. if ($user["type"] == 1) {
  839. $titleName = $startTime . "至" . $endTime . "硕博人才生活补贴申报公示名单";
  840. }
  841. if ($user["type"] == 2) {
  842. $titleName = $startTime . "至" + $endTime . "硕博人才生活补贴申报公示名单";
  843. }
  844. export($title, $rows, $fileName, [], $titleName);
  845. }
  846. /**
  847. * 导入征信核查结果
  848. * @auth {{/talentInfo/importProject}}
  849. */
  850. public function importProject(\think\Request $request) {
  851. $response = new \stdClass();
  852. $response->code = 500;
  853. if (!$request->file()) {
  854. $response->msg = "没有导入文件";
  855. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  856. }
  857. $file = $request->file("file");
  858. if (!isExcelFile($file->getMime())) {
  859. $response->msg = "不是正确的Excel文件";
  860. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  861. }
  862. $path = $file->getRealPath();
  863. $rows = getExcelDatas($path);
  864. $titleRow = array_shift($rows); //去标题
  865. $titles = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
  866. Db::startTrans();
  867. try {
  868. for ($i = 0; $i < count($titles); $i++) {
  869. if ($titles[$i] != $titleRow[$i]) {
  870. $response->msg = "模板错误";
  871. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  872. }
  873. }
  874. $total = count($rows);
  875. if ($total == 0) {
  876. $response->msg = "没有数据";
  877. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  878. }
  879. //------------行数据校验------------------------------------------------------//
  880. $idCards = [];
  881. $sbf = [];
  882. for ($i = 0; $i < $total; $i++) {
  883. $row = $rows[$i];
  884. $name = trim($row[1]);
  885. $idCard = trim($row[3]);
  886. $creditStatus = trim($row[5]);
  887. $socialSecurity = trim($row[6]);
  888. $personalTax = trim($row[7]);
  889. $businessRegistration = trim($row[8]);
  890. if (\StrUtil::isEmpOrNull($name)) {
  891. $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
  892. }
  893. if (\StrUtil::isEmpOrNull($idCard)) {
  894. $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
  895. }
  896. if (\StrUtil::isEmpOrNull($creditStatus) || !in_array($creditStatus, ["无", "在逃人员", "失信被执行人", "意识形态存在问题"])) {
  897. $sbf[] = sprintf("第 %d 行征信格式错误,请根据核查情况填写[ 无 | 在逃人员 | 失信被执行人 | 意识形态存在问题 ]", $i + 1);
  898. }
  899. //如2022-01,2022-02,2022-03,2022-04
  900. $datesRegexp = "/^[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)(?:-[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)){0,1}(?:,[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)(?:-[1-9]{1}\d{3}(01|02|03|04|05|06|07|08|09|10|11|12)){0,1})*$/";
  901. if ($socialSecurity && !preg_match($datesRegexp, $socialSecurity)) {
  902. $sbf[] = sprintf("第 %d 行社保核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  903. }
  904. if ($personalTax && !preg_match($datesRegexp, $personalTax)) {
  905. $sbf[] = sprintf("第 %d 行个税核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  906. }
  907. if ($businessRegistration && !preg_match($datesRegexp, $businessRegistration)) {
  908. $sbf[] = sprintf("第 %d 行工商注册情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  909. }
  910. $idCards[] = $idCard;
  911. }
  912. if ($sbf) {//如果校验 通不过
  913. $resultStr = implode("<br>", $sbf);
  914. if (mb_strlen($resultStr) > 200) {
  915. $resultStr = mb_substr($resultStr, 0, 200) . "...";
  916. }
  917. $response->msg = $resultStr;
  918. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  919. }
  920. $where = [];
  921. $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
  922. $where[] = ["isPublic", "=", 1];
  923. $where[] = ["idCard", "in", $idCards];
  924. $list = Db::table("md_living_allowance_info")->where($where)->column("*", "idCard");
  925. for ($i = 0; $i < $total; $i++) {
  926. $row = $rows[$i];
  927. $idCard = trim($row[3]);
  928. $outMsg = trim($row[5]);
  929. $sbDetail = trim($row[6]);
  930. $taxDetail = trim($row[7]);
  931. $gsRegistDetail = trim($row[8]);
  932. $info = $list[$idCard];
  933. if ($info) {
  934. $info["outMsg"] = $outMsg;
  935. $info["actualSocialSecurity"] = $sbDetail;
  936. $info["actualTax"] = $taxDetail;
  937. $info["actualBusinessRegistration"] = $gsRegistDetail;
  938. $info = $this->vailIsCash($info);
  939. $info["creditStatus"] = $outMsg != "无" ? 3 : 2;
  940. Db::table("md_living_allowance_info")->save($info);
  941. }
  942. }
  943. $response->code = 200;
  944. $response->msg = "导入成功";
  945. Db::commit();
  946. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  947. } catch (\Exception $e) {
  948. Db::rollback();
  949. $response->msg = "导入失败,系统错误:" . $e->getMessage();
  950. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  951. }
  952. }
  953. /**
  954. * 公示
  955. */
  956. public function publicBatch() {
  957. $response = new \stdClass();
  958. $response->code = 200;
  959. //查询需要公示的数据(勾选)
  960. $request = $this->request;
  961. $batch = \StrUtil::getRequestDecodeParam($request, "batch");
  962. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "ids")));
  963. $where = [];
  964. $where[] = ["id", "in", $ids];
  965. $list = LaModel::where($where)->select()->toArray();
  966. $recordList = [];
  967. $sb = [];
  968. $newLogs = [];
  969. //MessageRecord sendRecord = new MessageRecord(null, 2, 2, null, null, null, SmsProperties . CHECK_PUBLIC);
  970. //sendRecord . setId(IdWorker . getIdStr());
  971. Db::startTrans();
  972. try {
  973. for ($i = 0; $i < count($list); $i++) {
  974. $obj = $list[$i];
  975. $obj["publicBatch"] = $batch;
  976. $obj["isPublic"] = 3;
  977. Db::table("md_living_allowance_info")->save($obj);
  978. //添加日志
  979. $newLog["id"] = getStringId();
  980. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  981. $newLog["mainId"] = $obj["id"];
  982. $newLog["active"] = 1;
  983. $newLog["state"] = 3;
  984. $newLog["step"] = 5;
  985. $newLog["stateChange"] = "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>";
  986. $newLog["createTime"] = date("Y-m-d H:i:s");
  987. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  988. $newLogs[] = $newLog;
  989. //sb . append(obj . getPhone() + "," + typeName + "," + address + "," + publicStartTime + "," + publicEndTime + "," + dep + "," + phone + "," + email + ";");
  990. /* * 短信参数 */
  991. //String param = obj . getPhone() + "," + typeName + "," + address + "," + publicStartTime + "," + publicEndTime + "," + dep + "," + phone + "," + email + ";";
  992. //sb . append(param);
  993. //MessageRecord record = new MessageRecord(null, 2, 2, obj . getName(), obj . getPhone(), param . substring(0, param . length() - 1), SmsProperties . CHECK_PUBLIC);
  994. //record . setState(1);
  995. //record . setBizId(sendRecord . getId());
  996. //record . setSendingDate(DateUtil . getTime());
  997. //record . setCreateTime(DateUtil . getTime());
  998. //recordList . add(record);
  999. }
  1000. /* if (isMessage != null && isMessage == 1) {
  1001. if (list.size() > 1000) {
  1002. return new ResponseObj(ResponseObj . FAILD, "需要发送短信时公示量不能超过1000个");
  1003. }
  1004. //发送短信
  1005. Map map = new HashMap();
  1006. map . put("account", smsProperties . getAccount());
  1007. map . put("password", smsProperties . getPassword());
  1008. map . put("msg", sendRecord . getTemplateCode());
  1009. map . put("params", sb . substring(0, sb . length() - 1));
  1010. map . put("report", "true");
  1011. map . put("uid", sendRecord . getId());
  1012. String sendUrl = smsProperties . getBaseUrl() + "variable/json";
  1013. JSONObject js = (JSONObject) JSONObject . toJSON(map);
  1014. String res = HttpUtil . sendSmsByPost(sendUrl, js . toString());
  1015. JSONObject jsonObject = JSONObject . parseObject(res);
  1016. String code = jsonObject . getString("code");
  1017. String errorMsg = jsonObject . getString("errorMsg");
  1018. if (!"0" . equals(code)) {
  1019. return new ResponseObj(ResponseObj . FAILD, "短信发送失败,原因为:" + errorMsg);
  1020. }
  1021. this . messageRecordService . insertBatch(recordList);
  1022. } */
  1023. Db::table("new_talent_checklog")->insertAll($newLogs);
  1024. Db::commit();
  1025. $response->msg = "公示成功";
  1026. $response->code = 200;
  1027. return json($response);
  1028. } catch (\Exception $e) {
  1029. Db::rollback();
  1030. $response->msg = $e->getMessage();
  1031. return json($response);
  1032. }
  1033. }
  1034. /**
  1035. * 公示再审核
  1036. * @return type
  1037. */
  1038. public function afterCheck() {
  1039. $response = new \stdClass();
  1040. $response->code = 500;
  1041. $id = $this->request->param("id");
  1042. $checkState = $this->request->param("checkState");
  1043. $checkMsg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
  1044. if (!$id) {
  1045. $response->msg = "系统错误,请联系管理员";
  1046. return json($response);
  1047. }
  1048. $old = LivingAllowanceApi::getInfoById($id);
  1049. if ($old["isPublic"] != 3) {
  1050. $response->msg = "当前记录不是公示中状态,无法审核";
  1051. return json($response);
  1052. }
  1053. $desc = "";
  1054. $data = [];
  1055. $data["id"] = $id;
  1056. if ($checkState == 2) {
  1057. $data["checkState"] = LaState::LA_DEP_REJECT;
  1058. $data["isPublic"] = 1;
  1059. $data["outMsg"] = "";
  1060. $data["creditStatus"] = 1;
  1061. $data["recommendAmount"] = null;
  1062. $data["recommendIsPay"] = 0;
  1063. $data["recommendAmountDesc"] = "";
  1064. $data["recommendJudgmentDetails"] = "";
  1065. $desc = "(公示再审核驳回)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1066. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待核查征信</span>";
  1067. } else if ($checkState == LaState::LA_NOTPASS) {
  1068. $data["isPublic"] = 4;
  1069. $data["recommendIsPay"] = -1;
  1070. $data["recommendAmount"] = 0;
  1071. $data["recommendAmountDesc"] = $old["recommendAmountDesc"] . ";公示再审核不通过,不予兑现;";
  1072. $data["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . ";公示再审核不通过,不予兑现;";
  1073. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1074. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1075. } else {
  1076. $data["isPublic"] = 4;
  1077. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1078. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1079. }
  1080. $data["amount"] = $data["recommendAmount"];
  1081. $data["isPay"] = $data["recommendIsPay"];
  1082. $data["amountDesc"] = $data["recommendAmountDesc"];
  1083. $data["judgmentDetails"] = $data["recommendJudgmentDetails"];
  1084. //添加日志
  1085. $newLog["id"] = getStringId();
  1086. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1087. $newLog["mainId"] = $id;
  1088. $newLog["active"] = 1;
  1089. $newLog["state"] = $checkState;
  1090. $newLog["step"] = 6;
  1091. $newLog["stateChange"] = $desc;
  1092. $newLog["description"] = $checkMsg;
  1093. $newLog["createTime"] = date("Y-m-d H:i:s");
  1094. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1095. Db::startTrans();
  1096. try {
  1097. Db::table("new_talent_checklog")->insert($newLog);
  1098. Db::table("md_living_allowance_info")->save($data);
  1099. Db::commit();
  1100. $response->code = 200;
  1101. $response->msg = "审核成功";
  1102. return json($response);
  1103. } catch (\Exception $e) {
  1104. Db::rollback();
  1105. $response->msg = $e->getMessage();
  1106. return json($response);
  1107. }
  1108. }
  1109. /**
  1110. * 公示通过
  1111. */
  1112. public function publicPass() {
  1113. $response = new \stdClass();
  1114. $response->code = 500;
  1115. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
  1116. $where = [];
  1117. $where[] = ["id", "in", $ids];
  1118. $upList = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
  1119. //添加日志
  1120. $newLogs = [];
  1121. Db::startTrans();
  1122. try {
  1123. for ($i = 0; $i < count($upList); $i++) {
  1124. $obj = $upList[$i];
  1125. if ($obj["isPublic"] != 3) {
  1126. $response->msg = sprintf("第%d条记录不是公示中状态,不能公示通过", $i + 1);
  1127. return json($response);
  1128. }
  1129. $obj["isPublic"] = 4;
  1130. $obj["amount"] = $obj["recommendAmount"];
  1131. $obj["isPay"] = $obj["recommendIsPay"];
  1132. $obj["amountDesc"] = $obj["recommendAmountDesc"];
  1133. $obj["judgmentDetails"] = $obj["recommendJudgmentDetails"];
  1134. Db::table("md_living_allowance_info")->save($obj);
  1135. //添加日志
  1136. $newLog["id"] = getStringId();
  1137. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1138. $newLog["mainId"] = $obj["id"];
  1139. $newLog["active"] = 1;
  1140. $newLog["state"] = 3;
  1141. $newLog["step"] = 6;
  1142. $newLog["stateChange"] = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1143. $newLog["description"] = "";
  1144. $newLog["createTime"] = date("Y-m-d H:i:s");
  1145. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1146. $newLogs[] = $newLog;
  1147. }
  1148. Db::table("new_talent_checklog")->insertAll($newLogs);
  1149. Db::commit();
  1150. $response->msg = "批量公示通过成功";
  1151. $response->code = 200;
  1152. return json($response);
  1153. } catch (\Exception $e) {
  1154. Db::rollback();
  1155. $response->msg = $e->getMessage();
  1156. return json($response);
  1157. }
  1158. }
  1159. /**
  1160. * 兑现
  1161. */
  1162. public function issue() {
  1163. $response = new \stdClass();
  1164. $response->code = 500;
  1165. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
  1166. $where = [];
  1167. $where[] = ["id", "in", $ids];
  1168. $list = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
  1169. $newLogs = [];
  1170. Db::startTrans();
  1171. try {
  1172. for ($i = 0; $i < count($list); $i++) {
  1173. $obj = $list[$i];
  1174. if ($obj["isPublic"] != 4) {
  1175. $response->msg = sprintf("第%d条记录不是公示通过状态,不能兑现", $i + 1);
  1176. return json($response);
  1177. }
  1178. $obj["isPublic"] = 5;
  1179. $obj["isPay"] = 2;
  1180. Db::table("md_living_allowance_info")->save($obj);
  1181. //添加日志
  1182. $newLog["id"] = getStringId();
  1183. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1184. $newLog["mainId"] = $obj["id"];
  1185. $newLog["active"] = 1;
  1186. $newLog["state"] = 3;
  1187. $newLog["step"] = 8;
  1188. $newLog["stateChange"] = "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>";
  1189. $newLog["description"] = "";
  1190. $newLog["createTime"] = date("Y-m-d H:i:s");
  1191. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1192. $newLogs[] = $newLog;
  1193. }
  1194. Db::table("new_talent_checklog")->insertAll($newLogs);
  1195. Db::commit();
  1196. $response->code = 200;
  1197. $response->msg = "兑现成功";
  1198. return json($response);
  1199. } catch (\Exception $e) {
  1200. Db::rollback();
  1201. $response->msg = $e->getMessage();
  1202. return json($response);
  1203. }
  1204. }
  1205. /**
  1206. * 计算兑现额度
  1207. * @param type $oldInfo
  1208. * @return string
  1209. */
  1210. private function calculateAmount($oldInfo) {
  1211. $return = [];
  1212. /* * 硕士研究生补贴 */
  1213. if ($oldInfo["declareType"] == 1) {
  1214. //硕士 master_living_allowance_ss_money
  1215. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_ss_money", $oldInfo["applyCount"]);
  1216. } else {
  1217. //博士 master_living_allowance_bs_money
  1218. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_bs_money", $oldInfo["applyCount"]);
  1219. }
  1220. $moneyStanard = $moneyInfo ? $moneyInfo["name"] : 0;
  1221. $return["recommendAmount"] = $moneyStanard;
  1222. $where = [];
  1223. $where[] = ["cardType", "=", $oldInfo["cardType"]];
  1224. $where[] = ["idCard", "=", $oldInfo["idCard"]];
  1225. $where[] = ["year", "=", substr($oldInfo["year"], 0, 4)];
  1226. $where[] = ["checkState", "=", 30];
  1227. $where[] = ["publicState", ">=", 4];
  1228. $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty()->toArray();
  1229. if ($talentAllowanceInfo) {
  1230. $balanceMoney = $oldInfo["amount"] - $talentAllowanceInfo["money"];
  1231. if (round($balanceMoney, 2) == round(0, 2)) {
  1232. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",根据就高原则生活补贴享受额度为0元,因此不予兑现;\n";
  1233. $return["recommendAmount"] = 0;
  1234. $return["recommendIsPay"] = -1;
  1235. } else {
  1236. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",需要补充生活补贴额度为:" . round($balanceMoney, 2) . "元,予以兑现;\n";
  1237. $return["recommendAmount"] = $balanceMoney;
  1238. }
  1239. } else {
  1240. $return["recommendAmountDesc"] = "当年度无享受津补贴的记录,可全额享受,予以兑现;\n";
  1241. }
  1242. return $return;
  1243. }
  1244. /**
  1245. * 判断申报人是否满足兑现条件
  1246. */
  1247. private function vailIsCash($old) {
  1248. /* * 对申报人的信息进行校验是否满足补贴条件:
  1249. * 第一年:合同需要在3年以上、缴纳社保3个月及以上
  1250. * 第二、三年:社保和个税均在9个月以上
  1251. * */
  1252. if ($old["outMsg"] != "无") {
  1253. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ",征信失信,不予兑现;";
  1254. $old["recommendIsPay"] = -1;
  1255. $old["recommendAmount"] = 0;
  1256. return $old;
  1257. }
  1258. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ";";
  1259. if ($old["introductionMethod"] == 2) {
  1260. $backJJBusinessStartTime = strtotime("2021-11-16 00:00:00");
  1261. $backJJBusinessEndTime = strtotime("2022-11-16 00:00:00");
  1262. $backJJBusinessTime = strtotime($old["backJJBusinessTime"]);
  1263. if ($backJJBusinessTime < $backJJBusinessStartTime || $backJJBusinessTime > $backJJBusinessEndTime) {
  1264. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间不在2021-11-16至2022-11-15之间;\n";
  1265. $old["recommendIsPay"] = -1;
  1266. $old["recommendAmount"] = 0;
  1267. return $old;
  1268. }
  1269. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间在2021-11-16至2022-11-15之间;\n";
  1270. }
  1271. if ($old["applyCount"] == 1) {
  1272. $endTime = strtotime($old["endTime"]);
  1273. $after3YearsTime = strtotime("+3 years -1 days {$old['startTime']}");
  1274. if ($endTime < $after3YearsTime) {
  1275. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同不足3年,不予兑现;";
  1276. $old["recommendIsPay"] = -1;
  1277. $old["recommendAmount"] = 0;
  1278. return $old;
  1279. }
  1280. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 3) {
  1281. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:社保缴纳时间不足3个月,不予兑现;";
  1282. $old["recommendIsPay"] = -1;
  1283. $old["recommendAmount"] = 0;
  1284. return $old;
  1285. }
  1286. $old["recommendIsPay"] = 1;
  1287. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保缴纳时间满足3个月及以上,予以兑现;\n";
  1288. $_old = $this->calculateAmount($old);
  1289. $old = array_merge($old, $_old);
  1290. } else {
  1291. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 9) {
  1292. $old["recommendJudgmentDetails"] = $old["recommendAmountDesc"] . "非首年申报:社保缴纳时间不足9个月,不予兑现";
  1293. $old["recommendIsPay"] = -1;
  1294. $old["recommendAmount"] = 0;
  1295. return $old;
  1296. }
  1297. if (!$old["actualTax"] || $this->countByDates($old["actualTax"]) < 9) {
  1298. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:个税缴纳时间不足9个月,不予兑现";
  1299. $old["recommendIsPay"] = -1;
  1300. $old["recommendAmount"] = 0;
  1301. return $old;
  1302. }
  1303. $old["recommendIsPay"] = 1;
  1304. $old["recommendJudgmentDetails"] = "非首年申报:社保缴纳时间满足9个月及以上,个税缴纳时间满足9个月及以上,予以兑现;\n";
  1305. $_old = $this->calculateAmount($old);
  1306. $old = array_merge($old, $_old);
  1307. }
  1308. return $old;
  1309. }
  1310. /**
  1311. * 计算月份数
  1312. * @param type $dates
  1313. * @return type
  1314. */
  1315. private function countByDates($dates) {
  1316. $dateArr = explode(",", $dates);
  1317. $count = 0;
  1318. for ($i = 0; $i < count($dateArr); $i++) {
  1319. $date = $dateArr[$i];
  1320. if ($date) {
  1321. if (strpos($date, "-") !== false) {
  1322. $cDateArr = explode("-", $date);
  1323. $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
  1324. $month1 = date("n", strtotime($cDateArr[0] . "01"));
  1325. $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
  1326. $month2 = date("n", strtotime($cDateArr[1] . "01"));
  1327. // 方法返回为相差月份
  1328. $date1 = date_create($_date1);
  1329. $date2 = date_create($_date2);
  1330. $diff = date_diff($date1, $date2);
  1331. if ($diff->invert != 1) {
  1332. $count += $diff->y * 12 + ($month2 - $month1) + 1;
  1333. }
  1334. } else {
  1335. $count++;
  1336. }
  1337. }
  1338. }
  1339. return $count;
  1340. }
  1341. }