LivingAllowance.php 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  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. $typeName = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "typeName")));
  962. $address = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "address")));
  963. $publicStartTime = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "publicStartTime")));
  964. $publicEndTime = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "publicEndTime")));
  965. $dep = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "dep")));
  966. $phone = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "phone")));
  967. $email = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "email")));
  968. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  969. $typeName, $address, $publicStartTime, $publicEndTime, $dep, $phone, $sms); //短信内容
  970. $batch = \StrUtil::getRequestDecodeParam($request, "batch");
  971. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "ids")));
  972. $where = [];
  973. $where[] = ["id", "in", $ids];
  974. $list = LaModel::where($where)->select()->toArray();
  975. if ($isMessage == 1 && count($list) > 1000) {
  976. $response->msg = "需要发送短信时公示量不能超过1000个";
  977. return json($response);
  978. }
  979. $newLogs = [];
  980. $recordList = [];
  981. $phones = [];
  982. Db::startTrans();
  983. try {
  984. for ($i = 0; $i < count($list); $i++) {
  985. $obj = $list[$i];
  986. $obj["publicBatch"] = $batch;
  987. $obj["isPublic"] = 3;
  988. Db::table("md_living_allowance_info")->save($obj);
  989. //添加日志
  990. $newLog["id"] = getStringId();
  991. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  992. $newLog["mainId"] = $obj["id"];
  993. $newLog["active"] = 1;
  994. $newLog["state"] = 3;
  995. $newLog["step"] = 5;
  996. $newLog["stateChange"] = "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>";
  997. $newLog["createTime"] = date("Y-m-d H:i:s");
  998. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  999. $newLogs[] = $newLog;
  1000. $phones[] = $obj["phone"];
  1001. $record = [
  1002. 'id' => getStringId(),
  1003. 'bizId' => getStringId(),
  1004. 'userId' => $obj["enterpriseId"],
  1005. 'type' => 2,
  1006. 'smsType' => 2,
  1007. 'phone' => $obj["phone"],
  1008. 'name' => $obj["enterpriseName"],
  1009. 'params' => '公示',
  1010. 'templateCode' => $tpl_content,
  1011. 'state' => 3,
  1012. 'sendingDate' => date("Y-m-d H:i:s", time()),
  1013. 'createTime' => date("Y-m-d H:i:s", time())
  1014. ];
  1015. $recordList[] = $record;
  1016. }
  1017. Db::table("new_message_record")->insertAll($recordList);
  1018. Db::table("new_talent_checklog")->insertAll($newLogs);
  1019. Db::commit();
  1020. if ($isMessage == 1 && $phones) {
  1021. //批量发送短信
  1022. $sms = new ChuanglanSmsApi();
  1023. $result = $sms->sendSMS($phones, $tpl_content, true);
  1024. $result = json_decode($result, true);
  1025. }
  1026. $response->msg = "公示成功";
  1027. $response->code = 200;
  1028. return json($response);
  1029. } catch (\Exception $e) {
  1030. Db::rollback();
  1031. $response->msg = $e->getMessage();
  1032. return json($response);
  1033. }
  1034. }
  1035. /**
  1036. * 公示再审核
  1037. * @return type
  1038. */
  1039. public function afterCheck() {
  1040. $response = new \stdClass();
  1041. $response->code = 500;
  1042. $id = $this->request->param("id");
  1043. $checkState = $this->request->param("checkState");
  1044. $checkMsg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
  1045. if (!$id) {
  1046. $response->msg = "系统错误,请联系管理员";
  1047. return json($response);
  1048. }
  1049. $old = LivingAllowanceApi::getInfoById($id);
  1050. if ($old["isPublic"] != 3) {
  1051. $response->msg = "当前记录不是公示中状态,无法审核";
  1052. return json($response);
  1053. }
  1054. $desc = "";
  1055. $data = [];
  1056. $data["id"] = $id;
  1057. if ($checkState == 2) {
  1058. $data["checkState"] = LaState::LA_DEP_REJECT;
  1059. $data["isPublic"] = 1;
  1060. $data["outMsg"] = "";
  1061. $data["creditStatus"] = 1;
  1062. $data["recommendAmount"] = null;
  1063. $data["recommendIsPay"] = 0;
  1064. $data["recommendAmountDesc"] = "";
  1065. $data["recommendJudgmentDetails"] = "";
  1066. $desc = "(公示再审核驳回)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1067. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待核查征信</span>";
  1068. } else if ($checkState == LaState::LA_NOTPASS) {
  1069. $data["isPublic"] = 4;
  1070. $data["recommendIsPay"] = -1;
  1071. $data["recommendAmount"] = 0;
  1072. $data["recommendAmountDesc"] = $old["recommendAmountDesc"] . ";公示再审核不通过,不予兑现;";
  1073. $data["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . ";公示再审核不通过,不予兑现;";
  1074. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1075. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1076. } else {
  1077. $data["isPublic"] = 4;
  1078. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1079. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1080. }
  1081. $data["amount"] = $data["recommendAmount"];
  1082. $data["isPay"] = $data["recommendIsPay"];
  1083. $data["amountDesc"] = $data["recommendAmountDesc"];
  1084. $data["judgmentDetails"] = $data["recommendJudgmentDetails"];
  1085. //添加日志
  1086. $newLog["id"] = getStringId();
  1087. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1088. $newLog["mainId"] = $id;
  1089. $newLog["active"] = 1;
  1090. $newLog["state"] = $checkState;
  1091. $newLog["step"] = 6;
  1092. $newLog["stateChange"] = $desc;
  1093. $newLog["description"] = $checkMsg;
  1094. $newLog["createTime"] = date("Y-m-d H:i:s");
  1095. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1096. Db::startTrans();
  1097. try {
  1098. Db::table("new_talent_checklog")->insert($newLog);
  1099. Db::table("md_living_allowance_info")->save($data);
  1100. Db::commit();
  1101. $response->code = 200;
  1102. $response->msg = "审核成功";
  1103. return json($response);
  1104. } catch (\Exception $e) {
  1105. Db::rollback();
  1106. $response->msg = $e->getMessage();
  1107. return json($response);
  1108. }
  1109. }
  1110. /**
  1111. * 公示通过
  1112. */
  1113. public function publicPass() {
  1114. $response = new \stdClass();
  1115. $response->code = 500;
  1116. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
  1117. $where = [];
  1118. $where[] = ["id", "in", $ids];
  1119. $upList = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
  1120. //添加日志
  1121. $newLogs = [];
  1122. Db::startTrans();
  1123. try {
  1124. for ($i = 0; $i < count($upList); $i++) {
  1125. $obj = $upList[$i];
  1126. if ($obj["isPublic"] != 3) {
  1127. $response->msg = sprintf("第%d条记录不是公示中状态,不能公示通过", $i + 1);
  1128. return json($response);
  1129. }
  1130. $obj["isPublic"] = 4;
  1131. $obj["amount"] = $obj["recommendAmount"];
  1132. $obj["isPay"] = $obj["recommendIsPay"];
  1133. $obj["amountDesc"] = $obj["recommendAmountDesc"];
  1134. $obj["judgmentDetails"] = $obj["recommendJudgmentDetails"];
  1135. Db::table("md_living_allowance_info")->save($obj);
  1136. //添加日志
  1137. $newLog["id"] = getStringId();
  1138. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1139. $newLog["mainId"] = $obj["id"];
  1140. $newLog["active"] = 1;
  1141. $newLog["state"] = 3;
  1142. $newLog["step"] = 6;
  1143. $newLog["stateChange"] = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1144. $newLog["description"] = "";
  1145. $newLog["createTime"] = date("Y-m-d H:i:s");
  1146. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1147. $newLogs[] = $newLog;
  1148. }
  1149. Db::table("new_talent_checklog")->insertAll($newLogs);
  1150. Db::commit();
  1151. $response->msg = "批量公示通过成功";
  1152. $response->code = 200;
  1153. return json($response);
  1154. } catch (\Exception $e) {
  1155. Db::rollback();
  1156. $response->msg = $e->getMessage();
  1157. return json($response);
  1158. }
  1159. }
  1160. /**
  1161. * 兑现
  1162. */
  1163. public function issue() {
  1164. $response = new \stdClass();
  1165. $response->code = 500;
  1166. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
  1167. $where = [];
  1168. $where[] = ["id", "in", $ids];
  1169. $list = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
  1170. $newLogs = [];
  1171. Db::startTrans();
  1172. try {
  1173. for ($i = 0; $i < count($list); $i++) {
  1174. $obj = $list[$i];
  1175. if ($obj["isPublic"] != 4) {
  1176. $response->msg = sprintf("第%d条记录不是公示通过状态,不能兑现", $i + 1);
  1177. return json($response);
  1178. }
  1179. $obj["isPublic"] = 5;
  1180. $obj["isPay"] = 2;
  1181. Db::table("md_living_allowance_info")->save($obj);
  1182. //添加日志
  1183. $newLog["id"] = getStringId();
  1184. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1185. $newLog["mainId"] = $obj["id"];
  1186. $newLog["active"] = 1;
  1187. $newLog["state"] = 3;
  1188. $newLog["step"] = 8;
  1189. $newLog["stateChange"] = "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>";
  1190. $newLog["description"] = "";
  1191. $newLog["createTime"] = date("Y-m-d H:i:s");
  1192. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1193. $newLogs[] = $newLog;
  1194. }
  1195. Db::table("new_talent_checklog")->insertAll($newLogs);
  1196. Db::commit();
  1197. $response->code = 200;
  1198. $response->msg = "兑现成功";
  1199. return json($response);
  1200. } catch (\Exception $e) {
  1201. Db::rollback();
  1202. $response->msg = $e->getMessage();
  1203. return json($response);
  1204. }
  1205. }
  1206. /**
  1207. * 计算兑现额度
  1208. * @param type $oldInfo
  1209. * @return string
  1210. */
  1211. private function calculateAmount($oldInfo) {
  1212. $return = [];
  1213. /* * 硕士研究生补贴 */
  1214. if ($oldInfo["declareType"] == 1) {
  1215. //硕士 master_living_allowance_ss_money
  1216. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_ss_money", $oldInfo["applyCount"]);
  1217. } else {
  1218. //博士 master_living_allowance_bs_money
  1219. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_bs_money", $oldInfo["applyCount"]);
  1220. }
  1221. $moneyStanard = $moneyInfo ? $moneyInfo["name"] : 0;
  1222. $return["recommendAmount"] = $moneyStanard;
  1223. $where = [];
  1224. $where[] = ["cardType", "=", $oldInfo["cardType"]];
  1225. $where[] = ["idCard", "=", $oldInfo["idCard"]];
  1226. $where[] = ["year", "=", substr($oldInfo["year"], 0, 4)];
  1227. $where[] = ["checkState", "=", 30];
  1228. $where[] = ["publicState", ">=", 4];
  1229. $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty()->toArray();
  1230. if ($talentAllowanceInfo) {
  1231. $balanceMoney = $oldInfo["amount"] - $talentAllowanceInfo["money"];
  1232. if (round($balanceMoney, 2) == round(0, 2)) {
  1233. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",根据就高原则生活补贴享受额度为0元,因此不予兑现;\n";
  1234. $return["recommendAmount"] = 0;
  1235. $return["recommendIsPay"] = -1;
  1236. } else {
  1237. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",需要补充生活补贴额度为:" . round($balanceMoney, 2) . "元,予以兑现;\n";
  1238. $return["recommendAmount"] = $balanceMoney;
  1239. }
  1240. } else {
  1241. $return["recommendAmountDesc"] = "当年度无享受津补贴的记录,可全额享受,予以兑现;\n";
  1242. }
  1243. return $return;
  1244. }
  1245. /**
  1246. * 判断申报人是否满足兑现条件
  1247. */
  1248. private function vailIsCash($old) {
  1249. /* * 对申报人的信息进行校验是否满足补贴条件:
  1250. * 第一年:合同需要在3年以上、缴纳社保3个月及以上
  1251. * 第二、三年:社保和个税均在9个月以上
  1252. * */
  1253. if ($old["outMsg"] != "无") {
  1254. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ",征信失信,不予兑现;";
  1255. $old["recommendIsPay"] = -1;
  1256. $old["recommendAmount"] = 0;
  1257. return $old;
  1258. }
  1259. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ";";
  1260. if ($old["introductionMethod"] == 2) {
  1261. $backJJBusinessStartTime = strtotime("2021-11-16 00:00:00");
  1262. $backJJBusinessEndTime = strtotime("2022-11-16 00:00:00");
  1263. $backJJBusinessTime = strtotime($old["backJJBusinessTime"]);
  1264. if ($backJJBusinessTime < $backJJBusinessStartTime || $backJJBusinessTime > $backJJBusinessEndTime) {
  1265. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间不在2021-11-16至2022-11-15之间;\n";
  1266. $old["recommendIsPay"] = -1;
  1267. $old["recommendAmount"] = 0;
  1268. return $old;
  1269. }
  1270. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间在2021-11-16至2022-11-15之间;\n";
  1271. }
  1272. if ($old["applyCount"] == 1) {
  1273. $endTime = strtotime($old["endTime"]);
  1274. $after3YearsTime = strtotime("+3 years -1 days {$old['startTime']}");
  1275. if ($endTime < $after3YearsTime) {
  1276. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同不足3年,不予兑现;";
  1277. $old["recommendIsPay"] = -1;
  1278. $old["recommendAmount"] = 0;
  1279. return $old;
  1280. }
  1281. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 3) {
  1282. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:社保缴纳时间不足3个月,不予兑现;";
  1283. $old["recommendIsPay"] = -1;
  1284. $old["recommendAmount"] = 0;
  1285. return $old;
  1286. }
  1287. $old["recommendIsPay"] = 1;
  1288. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保缴纳时间满足3个月及以上,予以兑现;\n";
  1289. $_old = $this->calculateAmount($old);
  1290. $old = array_merge($old, $_old);
  1291. } else {
  1292. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 9) {
  1293. $old["recommendJudgmentDetails"] = $old["recommendAmountDesc"] . "非首年申报:社保缴纳时间不足9个月,不予兑现";
  1294. $old["recommendIsPay"] = -1;
  1295. $old["recommendAmount"] = 0;
  1296. return $old;
  1297. }
  1298. if (!$old["actualTax"] || $this->countByDates($old["actualTax"]) < 9) {
  1299. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:个税缴纳时间不足9个月,不予兑现";
  1300. $old["recommendIsPay"] = -1;
  1301. $old["recommendAmount"] = 0;
  1302. return $old;
  1303. }
  1304. $old["recommendIsPay"] = 1;
  1305. $old["recommendJudgmentDetails"] = "非首年申报:社保缴纳时间满足9个月及以上,个税缴纳时间满足9个月及以上,予以兑现;\n";
  1306. $_old = $this->calculateAmount($old);
  1307. $old = array_merge($old, $_old);
  1308. }
  1309. return $old;
  1310. }
  1311. /**
  1312. * 计算月份数
  1313. * @param type $dates
  1314. * @return type
  1315. */
  1316. private function countByDates($dates) {
  1317. $dateArr = explode(",", $dates);
  1318. $count = 0;
  1319. for ($i = 0; $i < count($dateArr); $i++) {
  1320. $date = $dateArr[$i];
  1321. if ($date) {
  1322. if (strpos($date, "-") !== false) {
  1323. $cDateArr = explode("-", $date);
  1324. $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
  1325. $month1 = date("n", strtotime($cDateArr[0] . "01"));
  1326. $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
  1327. $month2 = date("n", strtotime($cDateArr[1] . "01"));
  1328. // 方法返回为相差月份
  1329. $date1 = date_create($_date1);
  1330. $date2 = date_create($_date2);
  1331. $diff = date_diff($date1, $date2);
  1332. if ($diff->invert != 1) {
  1333. $count += $diff->y * 12 + ($month2 - $month1) + 1;
  1334. }
  1335. } else {
  1336. $count++;
  1337. }
  1338. }
  1339. }
  1340. return $count;
  1341. }
  1342. }