LivingAllowance.php 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  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. * @auth {{/talentInfo/exportHczx}}
  460. */
  461. public function exportHczx() {
  462. $response = new \stdClass();
  463. $response->code = 500;
  464. $user = $this->user;
  465. if (!in_array($user["type"], [1, 2])) {
  466. $response->msg = "当前账号类型没有操作权限";
  467. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  468. }
  469. $where = [];
  470. $ids = array_filter(explode(",", $this->request->param("ids")));
  471. $where[] = ["id", "in", $ids];
  472. $list = LaModel::where($where)->select()->toArray();
  473. $nationalitys = DictApi::selectByParentCode("nationality"); //查询国籍字典表
  474. if (!$list) {
  475. $response->msg = "暂无可核查征信的数据";
  476. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  477. }
  478. $title = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
  479. $exportList = [];
  480. for ($i = 0; $i < count($list); $i++) {
  481. $tmp = $list[$i];
  482. $exportList[] = [
  483. $i + 1, $tmp["name"], $nationalitys[$tmp["nationality"]], $tmp["idCard"], $tmp["enterpriseName"], $tmp["outMsg"], $tmp["actualSocialSecurity"], $tmp["actualTax"], $tmp["actualBusinessRegistration"]
  484. ];
  485. }
  486. $fileName = "硕博人才生活补贴核查征信名单导出";
  487. export($title, $exportList, $fileName);
  488. }
  489. /**
  490. * 导入征信核查结果
  491. * @auth {{/talentInfo/importProject}}
  492. */
  493. public function importProject(\think\Request $request) {
  494. $response = new \stdClass();
  495. $response->code = 500;
  496. if (!$request->file()) {
  497. $response->msg = "没有导入文件";
  498. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  499. }
  500. $file = $request->file("file");
  501. if (!isExcelFile($file->getMime())) {
  502. $response->msg = "不是正确的Excel文件";
  503. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  504. }
  505. $path = $file->getRealPath();
  506. $rows = getExcelDatas($path);
  507. $titleRow = array_shift($rows); //去标题
  508. $titles = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
  509. Db::startTrans();
  510. try {
  511. for ($i = 0; $i < count($titles); $i++) {
  512. if ($titles[$i] != $titleRow[$i]) {
  513. $response->msg = "模板错误";
  514. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  515. }
  516. }
  517. $total = count($rows);
  518. if ($total == 0) {
  519. $response->msg = "没有数据";
  520. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  521. }
  522. //------------行数据校验------------------------------------------------------//
  523. $idCards = [];
  524. $sbf = [];
  525. for ($i = 0; $i < $total; $i++) {
  526. $row = $rows[$i];
  527. $name = trim($row[1]);
  528. $idCard = trim($row[3]);
  529. $creditStatus = trim($row[5]);
  530. $socialSecurity = trim($row[6]);
  531. $personalTax = trim($row[7]);
  532. $businessRegistration = trim($row[8]);
  533. if (\StrUtil::isEmpOrNull($name)) {
  534. $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
  535. }
  536. if (\StrUtil::isEmpOrNull($idCard)) {
  537. $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
  538. }
  539. if (\StrUtil::isEmpOrNull($creditStatus) || !in_array($creditStatus, ["无", "在逃人员", "失信被执行人", "意识形态存在问题"])) {
  540. $sbf[] = sprintf("第 %d 行征信格式错误,请根据核查情况填写[ 无 | 在逃人员 | 失信被执行人 | 意识形态存在问题 ]", $i + 1);
  541. }
  542. //如2022-01,2022-02,2022-03,2022-04
  543. $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})*$/";
  544. if ($socialSecurity && !preg_match($datesRegexp, $socialSecurity)) {
  545. $sbf[] = sprintf("第 %d 行社保核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  546. }
  547. if ($personalTax && !preg_match($datesRegexp, $personalTax)) {
  548. $sbf[] = sprintf("第 %d 行个税核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  549. }
  550. if ($businessRegistration && !preg_match($datesRegexp, $businessRegistration)) {
  551. $sbf[] = sprintf("第 %d 行工商注册情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  552. }
  553. $idCards[] = $idCard;
  554. }
  555. if ($sbf) {//如果校验 通不过
  556. $resultStr = implode("<br>", $sbf);
  557. if (mb_strlen($resultStr) > 200) {
  558. $resultStr = mb_substr($resultStr, 0, 200) . "...";
  559. }
  560. $response->msg = $resultStr;
  561. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  562. }
  563. $where = [];
  564. $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
  565. $where[] = ["isPublic", "=", 1];
  566. $where[] = ["idCard", "in", $idCards];
  567. $list = Db::table("md_living_allowance_info")->where($where)->column("*", "idCard");
  568. for ($i = 0; $i < $total; $i++) {
  569. $row = $rows[$i];
  570. $idCard = trim($row[3]);
  571. $outMsg = trim($row[5]);
  572. $sbDetail = trim($row[6]);
  573. $taxDetail = trim($row[7]);
  574. $gsRegistDetail = trim($row[8]);
  575. $info = $list[$idCard];
  576. if ($info) {
  577. $info["outMsg"] = $outMsg;
  578. $info["actualSocialSecurity"] = $sbDetail;
  579. $info["actualTax"] = $taxDetail;
  580. $info["actualBusinessRegistration"] = $gsRegistDetail;
  581. $info = $this->vailIsCash($info);
  582. $info["creditStatus"] = $outMsg != "无" ? 3 : 2;
  583. Db::table("md_living_allowance_info")->save($info);
  584. }
  585. }
  586. $response->code = 200;
  587. $response->msg = "导入成功";
  588. Db::commit();
  589. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  590. } catch (\Exception $e) {
  591. Db::rollback();
  592. $response->msg = "导入失败,系统错误:" . $e->getMessage();
  593. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  594. }
  595. }
  596. /**
  597. * 公示
  598. */
  599. public function publicBatch() {
  600. $response = new \stdClass();
  601. $response->code = 200;
  602. //查询需要公示的数据(勾选)
  603. $request = $this->request;
  604. $batch = \StrUtil::getRequestDecodeParam($request, "batch");
  605. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "ids")));
  606. $where = [];
  607. $where[] = ["id", "in", $ids];
  608. $list = LaModel::where($where)->select()->toArray();
  609. $recordList = [];
  610. $sb = [];
  611. $newLogs = [];
  612. //MessageRecord sendRecord = new MessageRecord(null, 2, 2, null, null, null, SmsProperties . CHECK_PUBLIC);
  613. //sendRecord . setId(IdWorker . getIdStr());
  614. Db::startTrans();
  615. try {
  616. for ($i = 0; $i < count($list); $i++) {
  617. $obj = $list[$i];
  618. $obj["publicBatch"] = $batch;
  619. $obj["isPublic"] = 3;
  620. Db::table("md_living_allowance_info")->save($obj);
  621. //添加日志
  622. $newLog["id"] = getStringId();
  623. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  624. $newLog["mainId"] = $obj["id"];
  625. $newLog["active"] = 1;
  626. $newLog["state"] = 3;
  627. $newLog["step"] = 5;
  628. $newLog["stateChange"] = "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>";
  629. $newLog["createTime"] = date("Y-m-d H:i:s");
  630. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  631. $newLogs[] = $newLog;
  632. //sb . append(obj . getPhone() + "," + typeName + "," + address + "," + publicStartTime + "," + publicEndTime + "," + dep + "," + phone + "," + email + ";");
  633. /* * 短信参数 */
  634. //String param = obj . getPhone() + "," + typeName + "," + address + "," + publicStartTime + "," + publicEndTime + "," + dep + "," + phone + "," + email + ";";
  635. //sb . append(param);
  636. //MessageRecord record = new MessageRecord(null, 2, 2, obj . getName(), obj . getPhone(), param . substring(0, param . length() - 1), SmsProperties . CHECK_PUBLIC);
  637. //record . setState(1);
  638. //record . setBizId(sendRecord . getId());
  639. //record . setSendingDate(DateUtil . getTime());
  640. //record . setCreateTime(DateUtil . getTime());
  641. //recordList . add(record);
  642. }
  643. /* if (isMessage != null && isMessage == 1) {
  644. if (list.size() > 1000) {
  645. return new ResponseObj(ResponseObj . FAILD, "需要发送短信时公示量不能超过1000个");
  646. }
  647. //发送短信
  648. Map map = new HashMap();
  649. map . put("account", smsProperties . getAccount());
  650. map . put("password", smsProperties . getPassword());
  651. map . put("msg", sendRecord . getTemplateCode());
  652. map . put("params", sb . substring(0, sb . length() - 1));
  653. map . put("report", "true");
  654. map . put("uid", sendRecord . getId());
  655. String sendUrl = smsProperties . getBaseUrl() + "variable/json";
  656. JSONObject js = (JSONObject) JSONObject . toJSON(map);
  657. String res = HttpUtil . sendSmsByPost(sendUrl, js . toString());
  658. JSONObject jsonObject = JSONObject . parseObject(res);
  659. String code = jsonObject . getString("code");
  660. String errorMsg = jsonObject . getString("errorMsg");
  661. if (!"0" . equals(code)) {
  662. return new ResponseObj(ResponseObj . FAILD, "短信发送失败,原因为:" + errorMsg);
  663. }
  664. this . messageRecordService . insertBatch(recordList);
  665. } */
  666. Db::table("new_talent_checklog")->insertAll($newLogs);
  667. Db::commit();
  668. $response->msg = "公示成功";
  669. $response->code = 200;
  670. return json($response);
  671. } catch (\Exception $e) {
  672. Db::rollback();
  673. $response->msg = $e->getMessage();
  674. return json($response);
  675. }
  676. }
  677. public function afterCheck() {
  678. $response = new \stdClass();
  679. $response->code = 500;
  680. $id = $this->request->param("id");
  681. $checkState = $this->request->param("checkState");
  682. $checkMsg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
  683. if (!$id) {
  684. $response->msg = "系统错误,请联系管理员";
  685. return json($response);
  686. }
  687. $old = LivingAllowanceApi::getInfoById($id);
  688. if ($old["isPublic"] != 3) {
  689. $response->msg = "当前记录不是公示中状态,无法审核";
  690. return json($response);
  691. }
  692. $desc = "";
  693. $data = [];
  694. $data["id"] = $id;
  695. if ($checkState == 2) {
  696. $data["checkState"] = LaState::LA_DEP_REJECT;
  697. $data["isPublic"] = 1;
  698. $data["outMsg"] = "";
  699. $data["creditStatus"] = 1;
  700. $data["recommendAmount"] = null;
  701. $data["recommendIsPay"] = 0;
  702. $data["recommendAmountDesc"] = "";
  703. $data["recommendJudgmentDetails"] = "";
  704. $desc = "(公示再审核驳回)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  705. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待核查征信</span>";
  706. } else if (obj . getCheckState() == StateConst . RCRD_NOTPASS) {
  707. $data["isPublic"] = 4;
  708. $data["recommendIsPay"] = -1;
  709. $data["recommendAmount"] = 0;
  710. $data["recommendAmountDesc"] = $old["recommendAmountDesc"] . ";公示再审核不通过,不予兑现;";
  711. $data["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . ";公示再审核不通过,不予兑现;";
  712. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  713. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  714. } else {
  715. $data["isPublic"] = 4;
  716. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  717. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  718. }
  719. $data["amount"] = $data["recommendAmount"];
  720. $data["isPay"] = $data["recommendIsPay"];
  721. $data["amountDesc"] = $data["recommendAmountDesc"];
  722. $data["judgmentDetails"] = $data["recommendJudgmentDetails"];
  723. //添加日志
  724. $newLog["id"] = getStringId();
  725. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  726. $newLog["mainId"] = $id;
  727. $newLog["active"] = 1;
  728. $newLog["state"] = $checkState;
  729. $newLog["step"] = 6;
  730. $newLog["stateChange"] = $desc;
  731. $newLog["description"] = $checkMsg;
  732. $newLog["createTime"] = date("Y-m-d H:i:s");
  733. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  734. Db::startTrans();
  735. try {
  736. Db::table("new_talent_checklog")->insert($newLog);
  737. Db::table("new_talent_checklog")->save($data);
  738. Db::commit();
  739. $response->code = 200;
  740. $response->msg = "审核成功";
  741. return json($response);
  742. } catch (\Exception $e) {
  743. Db::callback();
  744. $response->msg = $e->getMessage();
  745. return json($response);
  746. }
  747. }
  748. /**
  749. * 计算兑现额度
  750. * @param type $oldInfo
  751. * @return string
  752. */
  753. private function calculateAmount($oldInfo) {
  754. $return = [];
  755. /* * 硕士研究生补贴 */
  756. if ($oldInfo["declareType"] == 1) {
  757. //硕士 master_living_allowance_ss_money
  758. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_ss_money", $oldInfo["applyCount"]);
  759. } else {
  760. //博士 master_living_allowance_bs_money
  761. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_bs_money", $oldInfo["applyCount"]);
  762. }
  763. $moneyStanard = $moneyInfo ? $moneyInfo["name"] : 0;
  764. $return["recommendAmount"] = $moneyStanard;
  765. $where = [];
  766. $where[] = ["cardType", "=", $oldInfo["cardType"]];
  767. $where[] = ["idCard", "=", $oldInfo["idCard"]];
  768. $where[] = ["year", "=", substr($oldInfo["year"], 0, 4)];
  769. $where[] = ["checkState", "=", 30];
  770. $where[] = ["publicState", ">=", 4];
  771. $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty()->toArray();
  772. if ($talentAllowanceInfo) {
  773. $balanceMoney = $oldInfo["amount"] - $talentAllowanceInfo["money"];
  774. if (round($balanceMoney, 2) == round(0, 2)) {
  775. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",根据就高原则生活补贴享受额度为0元,因此不予兑现;\n";
  776. $return["recommendAmount"] = 0;
  777. $return["recommendIsPay"] = -1;
  778. } else {
  779. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",需要补充生活补贴额度为:" . round($balanceMoney, 2) . "元,予以兑现;\n";
  780. $return["recommendAmount"] = $balanceMoney;
  781. }
  782. } else {
  783. $return["recommendAmountDesc"] = "当年度无享受津补贴的记录,可全额享受,予以兑现;\n";
  784. }
  785. return $return;
  786. }
  787. /**
  788. * 判断申报人是否满足兑现条件
  789. */
  790. private function vailIsCash($old) {
  791. /* * 对申报人的信息进行校验是否满足补贴条件:
  792. * 第一年:合同需要在3年以上、缴纳社保3个月及以上
  793. * 第二、三年:社保和个税均在9个月以上
  794. * */
  795. if ($old["outMsg"] != "无") {
  796. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ",征信失信,不予兑现;";
  797. $old["recommendIsPay"] = -1;
  798. $old["recommendAmount"] = 0;
  799. return $old;
  800. }
  801. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ";";
  802. if ($old["introductionMethod"] == 2) {
  803. $backJJBusinessStartTime = strtotime("2021-11-16 00:00:00");
  804. $backJJBusinessEndTime = strtotime("2022-11-16 00:00:00");
  805. $backJJBusinessTime = strtotime($old["backJJBusinessTime"]);
  806. if ($backJJBusinessTime < $backJJBusinessStartTime || $backJJBusinessTime > $backJJBusinessEndTime) {
  807. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间不在2021-11-16至2022-11-15之间;\n";
  808. $old["recommendIsPay"] = -1;
  809. $old["recommendAmount"] = 0;
  810. return $old;
  811. }
  812. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间在2021-11-16至2022-11-15之间;\n";
  813. }
  814. if ($old["applyCount"] == 1) {
  815. $endTime = strtotime($old["endTime"]);
  816. $after3YearsTime = strtotime("+3 years -1 days {$old['startTime']}");
  817. if ($endTime < $after3YearsTime) {
  818. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同不足3年,不予兑现;";
  819. $old["recommendIsPay"] = -1;
  820. $old["recommendAmount"] = 0;
  821. return $old;
  822. }
  823. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 3) {
  824. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:社保缴纳时间不足3个月,不予兑现;";
  825. $old["recommendIsPay"] = -1;
  826. $old["recommendAmount"] = 0;
  827. return $old;
  828. }
  829. $old["recommendIsPay"] = 1;
  830. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保缴纳时间满足3个月及以上,予以兑现;\n";
  831. $_old = $this->calculateAmount($old);
  832. $old = array_merge($old, $_old);
  833. } else {
  834. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 9) {
  835. $old["recommendJudgmentDetails"] = $old["recommendAmountDesc"] . "非首年申报:社保缴纳时间不足9个月,不予兑现";
  836. $old["recommendIsPay"] = -1;
  837. $old["recommendAmount"] = 0;
  838. return $old;
  839. }
  840. if (!$old["actualTax"] || $this->countByDates($old["actualTax"]) < 9) {
  841. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:个税缴纳时间不足9个月,不予兑现";
  842. $old["recommendIsPay"] = -1;
  843. $old["recommendAmount"] = 0;
  844. return $old;
  845. }
  846. $old["recommendIsPay"] = 1;
  847. $old["recommendJudgmentDetails"] = "非首年申报:社保缴纳时间满足9个月及以上,个税缴纳时间满足9个月及以上,予以兑现;\n";
  848. $_old = $this->calculateAmount($old);
  849. $old = array_merge($old, $_old);
  850. }
  851. return $old;
  852. }
  853. /**
  854. * 计算月份数
  855. * @param type $dates
  856. * @return type
  857. */
  858. private function countByDates($dates) {
  859. $dateArr = explode(",", $dates);
  860. $count = 0;
  861. for ($i = 0; $i < count($dateArr); $i++) {
  862. $date = $dateArr[$i];
  863. if ($date) {
  864. if (strpos($date, "-") !== false) {
  865. $cDateArr = explode("-", $date);
  866. $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
  867. $month1 = date("n", strtotime($cDateArr[0] . "01"));
  868. $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
  869. $month2 = date("n", strtotime($cDateArr[1] . "01"));
  870. // 方法返回为相差月份
  871. $date1 = date_create($_date1);
  872. $date2 = date_create($_date2);
  873. $diff = date_diff($date1, $date2);
  874. if ($diff->invert != 1) {
  875. $count += $diff->y * 12 + ($month2 - $month1) + 1;
  876. }
  877. } else {
  878. $count++;
  879. }
  880. }
  881. }
  882. return $count;
  883. }
  884. }