LivingAllowance.php 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434
  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. if ($process == 1 && $oldLog["state"] == 2) {
  394. //驳回到用户发送短信通知
  395. $tpl_content = "【晋江市人才服务平台】您好!您提交申请的硕博人才生活补贴因信息填写错误或上传不完整已被退回,请及时联系人才联络员登录申报系统查看审核意见并重新提交。";
  396. $sms = new ChuanglanSmsApi();
  397. $result = $sms->sendSMS($oldInfo["phone"], $tpl_content, true);
  398. $result = json_decode($result, true);
  399. $record_data = [
  400. 'id' => getStringId(),
  401. 'userId' => $oldInfo["enterpriseId"],
  402. 'bizId' => $result["msgId"],
  403. 'type' => 2,
  404. 'smsType' => 2,
  405. 'phone' => $oldInfo["phone"],
  406. 'name' => $oldInfo["enterpriseName"],
  407. 'params' => '硕博人才生活补贴驳回',
  408. 'templateCode' => $tpl_content,
  409. 'state' => $result['code'] == 0 ? 2 : 3,
  410. 'sendingDate' => date("Y-m-d H:i:s", time()),
  411. 'createTime' => date("Y-m-d H:i:s", time()),
  412. 'msg' => $result['errorMsg']
  413. ];
  414. Db::table("new_message_record")->insert($record_data);
  415. }
  416. $responseObj->code = 200;
  417. $responseObj->msg = "提交审核成功";
  418. return json($responseObj);
  419. } catch (\think\db\exception\DbException $e) {
  420. Db::rollback();
  421. $responseObj->msg = $e->getMessage();
  422. return json($responseObj);
  423. }
  424. }
  425. /**
  426. * 查询需要处理的数据
  427. */
  428. public function selectNeedCheckData() {
  429. $response = new \stdClass();
  430. $response->code = 500;
  431. $user = $this->user;
  432. $type = $this->request->param("type");
  433. $id = $this->request->param("id");
  434. $name = \StrUtil::getRequestDecodeParam($this->request, "name");
  435. $sex = $this->request->param("sex");
  436. $checkState = $this->request->param("checkState");
  437. if (!in_array($user["type"], [1, 2])) {
  438. $response->msg = "当前账号类型没有操作权限";
  439. return json($response);
  440. }
  441. $where = [];
  442. $where[] = ["type", "=", $user["type"]];
  443. if ($name) {
  444. $where[] = ["name", "like", "%" . $name . "%"];
  445. }
  446. if ($sex) {
  447. $where[] = ["sex", "=", $sex];
  448. }
  449. if ($checkState) {
  450. $where[] = ["checkState", "=", $checkState];
  451. }
  452. switch ($type) {
  453. case 1:
  454. $where[] = ["isPublic", "=", 1];
  455. $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
  456. break;
  457. case 2:
  458. $where[] = ["isPublic", "=", 1];
  459. $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
  460. break;
  461. case 3: //公示
  462. case 7: //公示预览
  463. $where[] = ["isPublic", "=", 2];
  464. $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
  465. break;
  466. case 4:
  467. $where[] = ["isPublic", "=", 3];
  468. $where[] = ["checkState", "in", [LaState::LA_NOTPASS, LaState::LA_PASS]];
  469. break;
  470. case 6:
  471. $where[] = ["isPublic", "=", 4];
  472. $where[] = ["checkState", "=", LaState::LA_PASS];
  473. break;
  474. }
  475. $list = Db::table("md_living_allowance_info")->field("id,idCard,name,enterpriseName,checkState")->where($where)->select()->toArray();
  476. $response->obj = ["rows" => $list, "total" => count($list)];
  477. $response->code = 200;
  478. return json($response);
  479. }
  480. /**
  481. * 通用导出
  482. * @return type
  483. */
  484. public function commonExport() {
  485. $response = new \stdClass();
  486. $response->code = 500;
  487. $request = $this->request;
  488. $user = $this->user;
  489. if (!in_array($user["type"], [1, 2])) {
  490. $response->msg = "当前账号类型没有操作权限";
  491. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  492. }
  493. $process = $request["process"];
  494. $names = \StrUtil::getRequestDecodeParam($request, "names");
  495. $values = \StrUtil::getRequestDecodeParam($request, "values");
  496. $title = array_filter(explode(",", $names)); //exce标题
  497. $keys = array_filter(explode(",", $values)); //标题对应的字段
  498. $where = [];
  499. $where[] = ["type", "=", $user["type"]];
  500. if ($_where = LivingAllowanceApi::setLivingAllowanceCheckStateCondition($request->param())) {
  501. $where = array_merge($where, $_where);
  502. }
  503. if ($_where2 = LivingAllowanceApi::getWhereByParams($request->param())) {
  504. $where = array_merge($where, $_where2);
  505. }
  506. if (in_array("declareTypeName", $keys)) {
  507. $declareTypeMap = DictApi::selectByParentCode("un_master_education");
  508. }
  509. if (in_array("nationalityName", $keys)) {
  510. $nationalityMap = DictApi::selectByParentCode("nationality");
  511. }
  512. if (in_array("nationName", $keys)) {
  513. $nationaMap = DictApi::selectByParentCode("nation");
  514. }
  515. if (in_array("industryFieldNewName", $keys)) {
  516. $industryFieldNewMap = DictApi::selectByParentCode("industry_field");
  517. }
  518. if (in_array("industryFieldName", $keys)) {
  519. $industryFieldMap = DictApi::selectByParentCode("un_industryField");
  520. }
  521. if (in_array("streetName", $keys)) {
  522. $streetMap = DictApi::selectByParentCode("street");
  523. }
  524. if (in_array("politicsName", $keys)) {
  525. $politicsMap = DictApi::selectByParentCode("politics");
  526. }
  527. if (in_array("educationName", $keys)) {
  528. $highEducationMap = DictApi::selectByParentCode("highest_degree");
  529. }
  530. if (in_array("introductionModeName", $keys)) {
  531. $introductionModeMap = DictApi::selectByParentCode("un_introduction_mode");
  532. }
  533. $list = LaModel::where($where)->select()->toArray();
  534. $nationalityOldAndNew = [
  535. "01" => "cn",
  536. "02" => "cn_hk",
  537. "03" => "cn_mc",
  538. "04" => "cn_tw",
  539. "05" => "us",
  540. "06" => "en",
  541. "07" => "jp",
  542. "08" => "co",
  543. "09" => "nl",
  544. "10" => "sg",
  545. "11" => "other"
  546. ];
  547. foreach ($list as $key => $item) {
  548. if (in_array("declareTypeName", $keys)) {
  549. $list[$key]["declareTypeName"] = $declareTypeMap[$item["declareType"]];
  550. }
  551. if (in_array("nationalityName", $keys)) {
  552. $list[$key]["nationalityName"] = $nationalityMap[$item["nationality"]] ?: $nationalityMap[$nationalityOldAndNew[$item["nationality"]]];
  553. }
  554. if (in_array("nationName", $keys)) {
  555. $list[$key]["nationName"] = $nationaMap[$item["nation"]];
  556. }
  557. if (in_array("industryFieldNewName", $keys)) {
  558. $list[$key]["industryFieldNewName"] = $industryFieldNewMap[$item["industryFieldNew"]];
  559. }
  560. if (in_array("industryFieldName", $keys)) {
  561. if ($item["industryFieldNew"]) {
  562. $list[$key]["industryFieldName"] = DictApi::findByParentCodeAndCode($item["industryFieldNew"] . "_field", $item["industryField"])["name"];
  563. } else {
  564. $list[$key]["industryFieldName"] = $industryFieldMap[$item["industryField"]];
  565. }
  566. }
  567. if (in_array("streetName", $keys)) {
  568. $list[$key]["streetName"] = $streetMap[$item["address"]];
  569. }
  570. if (in_array("politicsName", $keys)) {
  571. $list[$key]["politicsName"] = $politicsMap[$item["politics"]];
  572. }
  573. if (in_array("educationName", $keys)) {
  574. $list[$key]["educationName"] = $highEducationMap[$item["highEducation"]];
  575. }
  576. if (in_array("introductionModeName", $keys)) {
  577. $list[$key]["introductionModeName"] = $introductionModeMap[$item["introductionMode"]];
  578. }
  579. if (in_array("introductionMethodName", $keys)) {
  580. $list[$key]["introductionMethodName"] = $item["introductionMethod"] == 1 ? "新引进" : "其他";
  581. }
  582. if (in_array("sexName", $keys)) {
  583. $list[$key]["sexName"] = $item["sex"] == 1 ? "男" : "女";
  584. }
  585. if (in_array("cardTypeName", $keys)) {
  586. switch ($item["cardType"]) {
  587. case 1:
  588. $list[$key]["cardTypeName"] = "身份证";
  589. break;
  590. case 2:
  591. $list[$key]["cardTypeName"] = "通行证";
  592. break;
  593. case 3:
  594. $list[$key]["cardTypeName"] = "护照";
  595. break;
  596. default:
  597. $list[$key]["cardTypeName"] = "未知";
  598. break;
  599. }
  600. }
  601. if (in_array("isPublicName", $keys)) {
  602. switch ($item["isPublic"]) {
  603. case 1:
  604. $list[$key]["isPublicName"] = "待核查征信";
  605. break;
  606. case 2:
  607. $list[$key]["isPublicName"] = "待公示";
  608. break;
  609. case 3:
  610. $list[$key]["isPublicName"] = "公示中";
  611. break;
  612. case 4:
  613. $list[$key]["isPublicName"] = "待兑现";
  614. break;
  615. case 5:
  616. $list[$key]["isPublicName"] = "已兑现";
  617. break;
  618. }
  619. }
  620. if (in_array("studyAbroadName", $keys)) {
  621. $list[$key]["studyAbroadName"] = $item["studyAbroad"] == 1 ? "是" : "否";
  622. }
  623. if (in_array("recommendIsPayName", $keys)) {
  624. if ($item["recommendIsPay"] == -1) {
  625. $list[$key]["recommendIsPayName"] = "不予兑现";
  626. }
  627. if ($item["recommendIsPay"] == 0) {
  628. $list[$key]["recommendIsPayName"] = "未知";
  629. }
  630. if ($item["recommendIsPay"] == 1) {
  631. $list[$key]["recommendIsPayName"] = "待兑现";
  632. }
  633. if ($item["recommendIsPay"] == 2) {
  634. $list[$key]["recommendIsPayName"] = "已兑现";
  635. }
  636. }
  637. if (in_array("isPayName", $keys)) {
  638. if ($item["isPay"] == -1) {
  639. $list[$key]["isPayName"] = "不予兑现";
  640. }
  641. if ($item["isPay"] == 0) {
  642. $list[$key]["isPayName"] = "未知";
  643. }
  644. if ($item["isPay"] == 1) {
  645. $list[$key]["isPayName"] = "待兑现";
  646. }
  647. if ($item["isPay"] == 2) {
  648. $list[$key]["isPayName"] = "已兑现";
  649. }
  650. }
  651. if (in_array("creditStatusName", $keys)) {
  652. if ($item["creditStatus"] == 1) {
  653. $list[$key]["creditStatusName"] = "待核查征信";
  654. }
  655. if ($item["creditStatus"] == 2) {
  656. $list[$key]["creditStatusName"] = "征信通过";
  657. }
  658. if ($item["creditStatus"] == 3) {
  659. $list[$key]["creditStatusName"] = "征信失信";
  660. }
  661. }
  662. if ($process && in_array("checkStateName", $keys)) {
  663. switch ($process) {
  664. case 1:
  665. if ($item["checkState"] == -1) {
  666. $list[$key]["checkStateName"] = "审核不通过";
  667. } else if ($item["checkState"] == 1) {
  668. $list[$key]["checkStateName"] = "待提交";
  669. } else if ($item["checkState"] == 10) {
  670. $list[$key]["checkStateName"] = "已驳回";
  671. } else if ($item["checkState"] == 15 || $item["checkState"] >= 25 || $item["checkState"] >= 35) {
  672. $list[$key]["checkStateName"] = "已通过";
  673. } else if ($item["checkState"] == 7) {
  674. $list[$key]["checkStateName"] = $item["highProcess"] >= 1 ? "重新提交" : "待审核";
  675. } else if ($item["checkState"] == 20) {
  676. $list[$key]["checkStateName"] = $item["highProcess"] >= 1 ? "上级驳回" : "待审核";
  677. }
  678. break;
  679. case 3:
  680. if ($item["checkState"] == -1) {
  681. $list[$key]["checkStateName"] = "审核不通过";
  682. } else if ($item["checkState"] == 25) {
  683. $list[$key]["checkStateName"] = $item["highProcess"] >= 3 ? "重新提交" : "待审核";
  684. } else if ($item["checkState"] == 30 || $item["checkState"] <= 20) {
  685. $list[$key]["checkStateName"] = "已驳回";
  686. } else if ($item["checkState"] == 35) {
  687. $list[$key]["checkStateName"] = "已通过";
  688. }
  689. break;
  690. case 4:
  691. if ($item["checkState"] == -1) {
  692. $list[$key]["checkStateName"] = "审核不通过";
  693. } else if ($item["checkState"] == 35) {
  694. $list[$key]["checkStateName"] = "已通过";
  695. }
  696. break;
  697. case 5:
  698. $list[$key]["checkStateName"] = "已通过";
  699. break;
  700. }
  701. }
  702. }
  703. $fileName = "硕博人才生活补贴申报导出";
  704. if ($process == 1) {
  705. $fileName = "硕博人才生活补贴初审导出";
  706. } else if ($process == 2) {
  707. $fileName = "硕博人才生活补贴部门审核导出";
  708. } else if ($process == 3) {
  709. $fileName = "硕博人才生活补贴复核导出";
  710. } else if ($process == 4) {
  711. $fileName = "硕博人才生活补贴兑现导出";
  712. }
  713. $rows = [];
  714. foreach ($list as $item) {
  715. $row = [];
  716. foreach ($keys as $k) {
  717. $row[] = $item[$k];
  718. }
  719. $rows[] = $row;
  720. }
  721. if (!$rows) {
  722. $response->msg = "没有可导出的内容";
  723. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  724. }
  725. export($title, $rows, $fileName);
  726. }
  727. /**
  728. * 导出核查征信名单
  729. * @auth {{/talentInfo/exportHczx}}
  730. */
  731. public function exportHczx() {
  732. $response = new \stdClass();
  733. $response->code = 500;
  734. $user = $this->user;
  735. if (!in_array($user["type"], [1, 2])) {
  736. $response->msg = "当前账号类型没有操作权限";
  737. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  738. }
  739. $where = [];
  740. $ids = array_filter(explode(",", $this->request->param("ids")));
  741. $where[] = ["id", "in", $ids];
  742. $list = LaModel::where($where)->select()->toArray();
  743. $nationalitys = DictApi::selectByParentCode("nationality"); //查询国籍字典表
  744. if (!$list) {
  745. $response->msg = "暂无可核查征信的数据";
  746. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  747. }
  748. $title = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
  749. $exportList = [];
  750. for ($i = 0; $i < count($list); $i++) {
  751. $tmp = $list[$i];
  752. $exportList[] = [
  753. $i + 1, $tmp["name"], $nationalitys[$tmp["nationality"]], $tmp["idCard"], $tmp["enterpriseName"], $tmp["outMsg"], $tmp["actualSocialSecurity"], $tmp["actualTax"], $tmp["actualBusinessRegistration"]
  754. ];
  755. }
  756. $fileName = "硕博人才生活补贴核查征信名单导出";
  757. export($title, $exportList, $fileName);
  758. }
  759. /**
  760. * 公示预览
  761. */
  762. public function exportPublic() {
  763. $response = new \stdClass();
  764. $response->code = 500;
  765. $user = $this->user;
  766. $ids = array_filter(explode(",", $this->request->param("ids")));
  767. $batch = date("Ym");
  768. //查询需要公示的数据(勾选)
  769. $where = [];
  770. $where[] = ["id", "in", $ids];
  771. $list = LaModel::where($where)->order("enterpriseId")->select()->toArray();
  772. $rows = [];
  773. for ($i = 0; $i < count($list); $i++) {
  774. $obj = $list[$i];
  775. $obj["sexName"] = $obj["sex"] == 1 ? "男" : "女";
  776. $obj["sn"] = $i + 1;
  777. if ($obj["checkState"] == LaState::LA_NOTPASS) {
  778. $where = [];
  779. $where[] = ["mainId", "=", $obj["id"]];
  780. $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
  781. $where[] = ["step", "=", 3];
  782. $where[] = ["state", "<>", 8];
  783. $log = TalentLog::where($where)->order("createTime desc")->find();
  784. if ($log && $log["state"] == -1) {
  785. $obj["description"] = $log["description"];
  786. }
  787. if ($obj["outMsg"]) {
  788. $obj["description"] = ($log["description"] ? $log["description"] : "") . $obj["outMsg"];
  789. }
  790. $obj["stateName"] = "审核不通过";
  791. }
  792. if ($obj["checkState"] == LaState::LA_PASS) {
  793. $obj["stateName"] = "审核通过";
  794. }
  795. $rows[] = [
  796. $obj["sn"], $obj["name"], $obj["sexName"], $obj["enterpriseName"], $obj["stateName"], $obj["description"]
  797. ];
  798. }
  799. $title = ["序号", "姓名", "性别", "工作单位", "审核状态", "备注"];
  800. $fileName = "硕博人才生活补贴申报第" . $batch . "批次公示导出";
  801. $titleName = "";
  802. if ($user["type"] == 1) {
  803. $titleName = substr($batch, 0, 4) . "年" . substr($batch, 4, 6) . "月硕博人才生活补贴申报对象公示名单";
  804. }
  805. if ($user["type"] == 2) {
  806. $titleName = substr($batch, 0, 4) . "年" . substr($batch, 4, 6) . "月硕博人才生活补贴申报对象公示名单";
  807. }
  808. export($title, $rows, $fileName, [], $titleName);
  809. }
  810. /**
  811. * 公示导出
  812. */
  813. public function publicExport() {
  814. $response = new \stdClass();
  815. $response->code = 500;
  816. $user = $this->user;
  817. if (!in_array($user["type"], [1, 2])) {
  818. $response->msg = "当前账号类型没有操作权限";
  819. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  820. }
  821. $startTime = $this->request["startTime"];
  822. $endTime = $this->request["endTime"];
  823. $where = [];
  824. $where[] = ["publicBatch", "between", [$startTime, $endTime]];
  825. $where[] = ["type", "=", $user["type"]];
  826. $list = LaModel::where($where)->order("publicBatch")->select()->toArray();
  827. if (!$list) {
  828. $response->msg = "所选时间段内无公示数据";
  829. return \StrUtil::back($response, "LivingAllowanceInfo.callBack");
  830. }
  831. $rows = [];
  832. for ($i = 0; $i < count($list); $i++) {
  833. $obj = $list[$i];
  834. $obj["sexName"] = $obj["sex"] == 1 ? "男" : "女";
  835. $obj["sn"] = $i + 1;
  836. if ($obj["checkState"] == LaState::LA_NOTPASS) {
  837. $where = [];
  838. $where[] = ["mainId", "=", $obj["id"]];
  839. $where[] = ["type", "=", ProjectState::LIVINGALLOWANCE];
  840. $where[] = ["step", "=", 3];
  841. $where[] = ["state", "<>", 8];
  842. $log = TalentLog::where($where)->order("createTime desc")->find();
  843. if ($log && $log["state"] == -1) {
  844. $obj["description"] = $log["description"];
  845. }
  846. if ($obj["outMsg"]) {
  847. $obj["description"] = ($log["description"] ? $log["description"] : "") . $obj["outMsg"];
  848. }
  849. $obj["stateName"] = "审核不通过";
  850. }
  851. if ($obj["checkState"] == LaState::LA_PASS) {
  852. $obj["stateName"] = "审核通过";
  853. }
  854. $rows[] = [
  855. $obj["sn"], $obj["publicBatch"], $obj["name"], $obj["sexName"], $obj["enterpriseName"], $obj["stateName"], $obj["description"]
  856. ];
  857. }
  858. $title = ["序号", "公示批次", "姓名", "性别", "工作单位", "审核状态", "备注"];
  859. $fileName = "硕博人才生活补贴公示导出";
  860. $titleName = "";
  861. if ($user["type"] == 1) {
  862. $titleName = $startTime . "至" . $endTime . "硕博人才生活补贴申报公示名单";
  863. }
  864. if ($user["type"] == 2) {
  865. $titleName = $startTime . "至" . $endTime . "硕博人才生活补贴申报公示名单";
  866. }
  867. export($title, $rows, $fileName, [], $titleName);
  868. }
  869. /**
  870. * 导入征信核查结果
  871. * @auth {{/talentInfo/importProject}}
  872. */
  873. public function importProject(\think\Request $request) {
  874. $response = new \stdClass();
  875. $response->code = 500;
  876. if (!$request->file()) {
  877. $response->msg = "没有导入文件";
  878. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  879. }
  880. $file = $request->file("file");
  881. if (!isExcelFile($file->getMime())) {
  882. $response->msg = "不是正确的Excel文件";
  883. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  884. }
  885. $path = $file->getRealPath();
  886. $rows = getExcelDatas($path);
  887. $titleRow = array_shift($rows); //去标题
  888. $titles = ["序号", "姓名", "国籍/地区", "证件号码", "工作单位", "征信情况", "社保缴纳情况", "个税缴纳情况", "工商注册情况"];
  889. Db::startTrans();
  890. try {
  891. for ($i = 0; $i < count($titles); $i++) {
  892. if ($titles[$i] != $titleRow[$i]) {
  893. $response->msg = "模板错误";
  894. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  895. }
  896. }
  897. $total = count($rows);
  898. if ($total == 0) {
  899. $response->msg = "没有数据";
  900. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  901. }
  902. //------------行数据校验------------------------------------------------------//
  903. $idCards = [];
  904. $sbf = [];
  905. for ($i = 0; $i < $total; $i++) {
  906. $row = $rows[$i];
  907. $name = trim($row[1]);
  908. $idCard = trim($row[3]);
  909. $creditStatus = trim($row[5]);
  910. $socialSecurity = trim($row[6]);
  911. $personalTax = trim($row[7]);
  912. $businessRegistration = trim($row[8]);
  913. if (\StrUtil::isEmpOrNull($name)) {
  914. $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
  915. }
  916. if (\StrUtil::isEmpOrNull($idCard)) {
  917. $sbf[] = sprintf("第 %d 行模板被修改", $i + 1);
  918. }
  919. if (\StrUtil::isEmpOrNull($creditStatus) || !in_array($creditStatus, ["无", "在逃人员", "失信被执行人", "意识形态存在问题"])) {
  920. $sbf[] = sprintf("第 %d 行征信格式错误,请根据核查情况填写[ 无 | 在逃人员 | 失信被执行人 | 意识形态存在问题 ]", $i + 1);
  921. }
  922. //如2022-01,2022-02,2022-03,2022-04
  923. $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})*$/";
  924. if ($socialSecurity && !preg_match($datesRegexp, $socialSecurity)) {
  925. $sbf[] = sprintf("第 %d 行社保核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  926. }
  927. if ($personalTax && !preg_match($datesRegexp, $personalTax)) {
  928. $sbf[] = sprintf("第 %d 行个税核实情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  929. }
  930. if ($businessRegistration && !preg_match($datesRegexp, $businessRegistration)) {
  931. $sbf[] = sprintf("第 %d 行工商注册情况格式不正确,格式例如[ 202202-202205,202207,202209-202212 ]", $i + 1);
  932. }
  933. $idCards[] = $idCard;
  934. }
  935. if ($sbf) {//如果校验 通不过
  936. $resultStr = implode("<br>", $sbf);
  937. if (mb_strlen($resultStr) > 200) {
  938. $resultStr = mb_substr($resultStr, 0, 200) . "...";
  939. }
  940. $response->msg = $resultStr;
  941. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  942. }
  943. $where = [];
  944. $where[] = ["checkState", "=", LaState::LA_NEED_THIRD];
  945. $where[] = ["isPublic", "=", 1];
  946. $where[] = ["idCard", "in", $idCards];
  947. $list = Db::table("md_living_allowance_info")->where($where)->column("*", "idCard");
  948. for ($i = 0; $i < $total; $i++) {
  949. $row = $rows[$i];
  950. $idCard = trim($row[3]);
  951. $outMsg = trim($row[5]);
  952. $sbDetail = trim($row[6]);
  953. $taxDetail = trim($row[7]);
  954. $gsRegistDetail = trim($row[8]);
  955. $info = $list[$idCard];
  956. if ($info) {
  957. $info["outMsg"] = $outMsg;
  958. $info["actualSocialSecurity"] = $sbDetail;
  959. $info["actualTax"] = $taxDetail;
  960. $info["actualBusinessRegistration"] = $gsRegistDetail;
  961. $info = $this->vailIsCash($info);
  962. $info["creditStatus"] = $outMsg != "无" ? 3 : 2;
  963. Db::table("md_living_allowance_info")->save($info);
  964. }
  965. }
  966. $response->code = 200;
  967. $response->msg = "导入成功";
  968. Db::commit();
  969. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  970. } catch (\Exception $e) {
  971. Db::rollback();
  972. $response->msg = "导入失败,系统错误:" . $e->getMessage();
  973. return \StrUtil::back($response, "LivingAllowanceInfo.importCallBack");
  974. }
  975. }
  976. /**
  977. * 公示
  978. */
  979. public function publicBatch() {
  980. $response = new \stdClass();
  981. $response->code = 200;
  982. //查询需要公示的数据(勾选)
  983. $request = $this->request;
  984. $typeName = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "typeName")));
  985. $address = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "address")));
  986. $publicStartTime = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "publicStartTime")));
  987. $publicEndTime = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "publicEndTime")));
  988. $dep = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "dep")));
  989. $phone = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "phone")));
  990. $email = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "email")));
  991. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  992. $typeName, $address, $publicStartTime, $publicEndTime, $dep, $phone, $sms); //短信内容
  993. $batch = \StrUtil::getRequestDecodeParam($request, "batch");
  994. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($request, "ids")));
  995. $where = [];
  996. $where[] = ["id", "in", $ids];
  997. $list = LaModel::where($where)->select()->toArray();
  998. if ($isMessage == 1 && count($list) > 1000) {
  999. $response->msg = "需要发送短信时公示量不能超过1000个";
  1000. return json($response);
  1001. }
  1002. $newLogs = [];
  1003. $recordList = [];
  1004. $phones = [];
  1005. Db::startTrans();
  1006. try {
  1007. for ($i = 0; $i < count($list); $i++) {
  1008. $obj = $list[$i];
  1009. $obj["publicBatch"] = $batch;
  1010. $obj["isPublic"] = 3;
  1011. Db::table("md_living_allowance_info")->save($obj);
  1012. //添加日志
  1013. $newLog["id"] = getStringId();
  1014. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1015. $newLog["mainId"] = $obj["id"];
  1016. $newLog["active"] = 1;
  1017. $newLog["state"] = 3;
  1018. $newLog["step"] = 5;
  1019. $newLog["stateChange"] = "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>";
  1020. $newLog["createTime"] = date("Y-m-d H:i:s");
  1021. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1022. $newLogs[] = $newLog;
  1023. $phones[] = $obj["phone"];
  1024. $record = [
  1025. 'id' => getStringId(),
  1026. 'bizId' => getStringId(),
  1027. 'userId' => $obj["enterpriseId"],
  1028. 'type' => 2,
  1029. 'smsType' => 2,
  1030. 'phone' => $obj["phone"],
  1031. 'name' => $obj["enterpriseName"],
  1032. 'params' => '公示',
  1033. 'templateCode' => $tpl_content,
  1034. 'state' => 3,
  1035. 'sendingDate' => date("Y-m-d H:i:s", time()),
  1036. 'createTime' => date("Y-m-d H:i:s", time())
  1037. ];
  1038. $recordList[] = $record;
  1039. }
  1040. Db::table("new_message_record")->insertAll($recordList);
  1041. Db::table("new_talent_checklog")->insertAll($newLogs);
  1042. Db::commit();
  1043. if ($isMessage == 1 && $phones) {
  1044. //批量发送短信
  1045. $sms = new ChuanglanSmsApi();
  1046. $result = $sms->sendSMS($phones, $tpl_content, true);
  1047. $result = json_decode($result, true);
  1048. }
  1049. $response->msg = "公示成功";
  1050. $response->code = 200;
  1051. return json($response);
  1052. } catch (\Exception $e) {
  1053. Db::rollback();
  1054. $response->msg = $e->getMessage();
  1055. return json($response);
  1056. }
  1057. }
  1058. /**
  1059. * 公示再审核
  1060. * @return type
  1061. */
  1062. public function afterCheck() {
  1063. $response = new \stdClass();
  1064. $response->code = 500;
  1065. $id = $this->request->param("id");
  1066. $checkState = $this->request->param("checkState");
  1067. $checkMsg = \StrUtil::getRequestDecodeParam($this->request, "checkMsg");
  1068. if (!$id) {
  1069. $response->msg = "系统错误,请联系管理员";
  1070. return json($response);
  1071. }
  1072. $old = LivingAllowanceApi::getInfoById($id);
  1073. if ($old["isPublic"] != 3) {
  1074. $response->msg = "当前记录不是公示中状态,无法审核";
  1075. return json($response);
  1076. }
  1077. $desc = "";
  1078. $data = [];
  1079. $data["id"] = $id;
  1080. if ($checkState == 2) {
  1081. $data["checkState"] = LaState::LA_DEP_REJECT;
  1082. $data["isPublic"] = 1;
  1083. $data["outMsg"] = "";
  1084. $data["creditStatus"] = 1;
  1085. $data["recommendAmount"] = null;
  1086. $data["recommendIsPay"] = 0;
  1087. $data["recommendAmountDesc"] = "";
  1088. $data["recommendJudgmentDetails"] = "";
  1089. $desc = "(公示再审核驳回)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1090. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待核查征信</span>";
  1091. } else if ($checkState == LaState::LA_NOTPASS) {
  1092. $data["isPublic"] = 4;
  1093. $data["recommendIsPay"] = -1;
  1094. $data["recommendAmount"] = 0;
  1095. $data["recommendAmountDesc"] = $old["recommendAmountDesc"] . ";公示再审核不通过,不予兑现;";
  1096. $data["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . ";公示再审核不通过,不予兑现;";
  1097. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1098. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1099. } else {
  1100. $data["isPublic"] = 4;
  1101. $desc = "(公示再审核通过)审核状态:" . LaState::getStateDesc($old["checkState"]) . "->" . LaState::getStateDesc($data["checkState"]) .
  1102. ";公示状态:<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1103. }
  1104. $data["amount"] = $data["recommendAmount"];
  1105. $data["isPay"] = $data["recommendIsPay"];
  1106. $data["amountDesc"] = $data["recommendAmountDesc"];
  1107. $data["judgmentDetails"] = $data["recommendJudgmentDetails"];
  1108. //添加日志
  1109. $newLog["id"] = getStringId();
  1110. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1111. $newLog["mainId"] = $id;
  1112. $newLog["active"] = 1;
  1113. $newLog["state"] = $checkState;
  1114. $newLog["step"] = 6;
  1115. $newLog["stateChange"] = $desc;
  1116. $newLog["description"] = $checkMsg;
  1117. $newLog["createTime"] = date("Y-m-d H:i:s");
  1118. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1119. Db::startTrans();
  1120. try {
  1121. Db::table("new_talent_checklog")->insert($newLog);
  1122. Db::table("md_living_allowance_info")->save($data);
  1123. Db::commit();
  1124. $response->code = 200;
  1125. $response->msg = "审核成功";
  1126. return json($response);
  1127. } catch (\Exception $e) {
  1128. Db::rollback();
  1129. $response->msg = $e->getMessage();
  1130. return json($response);
  1131. }
  1132. }
  1133. /**
  1134. * 公示通过
  1135. */
  1136. public function publicPass() {
  1137. $response = new \stdClass();
  1138. $response->code = 500;
  1139. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
  1140. $where = [];
  1141. $where[] = ["id", "in", $ids];
  1142. $upList = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
  1143. //添加日志
  1144. $newLogs = [];
  1145. Db::startTrans();
  1146. try {
  1147. for ($i = 0; $i < count($upList); $i++) {
  1148. $obj = $upList[$i];
  1149. if ($obj["isPublic"] != 3) {
  1150. $response->msg = sprintf("第%d条记录不是公示中状态,不能公示通过", $i + 1);
  1151. return json($response);
  1152. }
  1153. $obj["isPublic"] = 4;
  1154. $obj["amount"] = $obj["recommendAmount"];
  1155. $obj["isPay"] = $obj["recommendIsPay"];
  1156. $obj["amountDesc"] = $obj["recommendAmountDesc"];
  1157. $obj["judgmentDetails"] = $obj["recommendJudgmentDetails"];
  1158. Db::table("md_living_allowance_info")->save($obj);
  1159. //添加日志
  1160. $newLog["id"] = getStringId();
  1161. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1162. $newLog["mainId"] = $obj["id"];
  1163. $newLog["active"] = 1;
  1164. $newLog["state"] = 3;
  1165. $newLog["step"] = 6;
  1166. $newLog["stateChange"] = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  1167. $newLog["description"] = "";
  1168. $newLog["createTime"] = date("Y-m-d H:i:s");
  1169. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1170. $newLogs[] = $newLog;
  1171. }
  1172. Db::table("new_talent_checklog")->insertAll($newLogs);
  1173. Db::commit();
  1174. $response->msg = "批量公示通过成功";
  1175. $response->code = 200;
  1176. return json($response);
  1177. } catch (\Exception $e) {
  1178. Db::rollback();
  1179. $response->msg = $e->getMessage();
  1180. return json($response);
  1181. }
  1182. }
  1183. /**
  1184. * 兑现
  1185. */
  1186. public function issue() {
  1187. $response = new \stdClass();
  1188. $response->code = 500;
  1189. $ids = array_filter(explode(",", \StrUtil::getRequestDecodeParam($this->request, "ids")));
  1190. $where = [];
  1191. $where[] = ["id", "in", $ids];
  1192. $list = Db::table("md_living_allowance_info")->where($where)->select()->toArray();
  1193. $newLogs = [];
  1194. Db::startTrans();
  1195. try {
  1196. for ($i = 0; $i < count($list); $i++) {
  1197. $obj = $list[$i];
  1198. if ($obj["isPublic"] != 4) {
  1199. $response->msg = sprintf("第%d条记录不是公示通过状态,不能兑现", $i + 1);
  1200. return json($response);
  1201. }
  1202. $obj["isPublic"] = 5;
  1203. $obj["isPay"] = 2;
  1204. Db::table("md_living_allowance_info")->save($obj);
  1205. //添加日志
  1206. $newLog["id"] = getStringId();
  1207. $newLog["type"] = ProjectState::LIVINGALLOWANCE;
  1208. $newLog["mainId"] = $obj["id"];
  1209. $newLog["active"] = 1;
  1210. $newLog["state"] = 3;
  1211. $newLog["step"] = 8;
  1212. $newLog["stateChange"] = "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>";
  1213. $newLog["description"] = "";
  1214. $newLog["createTime"] = date("Y-m-d H:i:s");
  1215. $newLog["createUser"] = sprintf("%s(%s)", $this->user["account"], $this->user["companyName"]);
  1216. $newLogs[] = $newLog;
  1217. }
  1218. Db::table("new_talent_checklog")->insertAll($newLogs);
  1219. Db::commit();
  1220. $response->code = 200;
  1221. $response->msg = "兑现成功";
  1222. return json($response);
  1223. } catch (\Exception $e) {
  1224. Db::rollback();
  1225. $response->msg = $e->getMessage();
  1226. return json($response);
  1227. }
  1228. }
  1229. /**
  1230. * 计算兑现额度
  1231. * @param type $oldInfo
  1232. * @return string
  1233. */
  1234. private function calculateAmount($oldInfo) {
  1235. $return = [];
  1236. /* * 硕士研究生补贴 */
  1237. if ($oldInfo["declareType"] == 1) {
  1238. //硕士 master_living_allowance_ss_money
  1239. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_ss_money", $oldInfo["applyCount"]);
  1240. } else {
  1241. //博士 master_living_allowance_bs_money
  1242. $moneyInfo = DictApi::findByParentCodeAndCode("master_living_allowance_bs_money", $oldInfo["applyCount"]);
  1243. }
  1244. $moneyStanard = $moneyInfo ? $moneyInfo["name"] : 0;
  1245. $return["recommendAmount"] = $moneyStanard;
  1246. $where = [];
  1247. $where[] = ["cardType", "=", $oldInfo["cardType"]];
  1248. $where[] = ["idCard", "=", $oldInfo["idCard"]];
  1249. $where[] = ["year", "=", substr($oldInfo["year"], 0, 4)];
  1250. $where[] = ["checkState", "=", 30];
  1251. $where[] = ["publicState", ">=", 4];
  1252. $talentAllowanceInfo = \app\common\model\TalentAllowance::where($where)->findOrEmpty()->toArray();
  1253. if ($talentAllowanceInfo) {
  1254. $balanceMoney = $oldInfo["amount"] - $talentAllowanceInfo["money"];
  1255. if (round($balanceMoney, 2) == round(0, 2)) {
  1256. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",根据就高原则生活补贴享受额度为0元,因此不予兑现;\n";
  1257. $return["recommendAmount"] = 0;
  1258. $return["recommendIsPay"] = -1;
  1259. } else {
  1260. $return["recommendAmountDesc"] = "当年度存在享受津补贴的记录,津补贴额度为:" . $talentAllowanceInfo["money"] . ",生活补贴额度为:" . $oldInfo["amount"] . ",需要补充生活补贴额度为:" . round($balanceMoney, 2) . "元,予以兑现;\n";
  1261. $return["recommendAmount"] = $balanceMoney;
  1262. }
  1263. } else {
  1264. $return["recommendAmountDesc"] = "当年度无享受津补贴的记录,可全额享受,予以兑现;\n";
  1265. }
  1266. return $return;
  1267. }
  1268. /**
  1269. * 判断申报人是否满足兑现条件
  1270. */
  1271. private function vailIsCash($old) {
  1272. /* * 对申报人的信息进行校验是否满足补贴条件:
  1273. * 第一年:合同需要在3年以上、缴纳社保3个月及以上
  1274. * 第二、三年:社保和个税均在9个月以上
  1275. * */
  1276. if ($old["outMsg"] != "无") {
  1277. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ",征信失信,不予兑现;";
  1278. $old["recommendIsPay"] = -1;
  1279. $old["recommendAmount"] = 0;
  1280. return $old;
  1281. }
  1282. $old["recommendJudgmentDetails"] = "征信情况:" . $old["outMsg"] . ";";
  1283. if ($old["introductionMethod"] == 2) {
  1284. $backJJBusinessStartTime = strtotime("2021-11-16 00:00:00");
  1285. $backJJBusinessEndTime = strtotime("2022-11-16 00:00:00");
  1286. $backJJBusinessTime = strtotime($old["backJJBusinessTime"]);
  1287. if ($backJJBusinessTime < $backJJBusinessStartTime || $backJJBusinessTime > $backJJBusinessEndTime) {
  1288. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间不在2021-11-16至2022-11-15之间;\n";
  1289. $old["recommendIsPay"] = -1;
  1290. $old["recommendAmount"] = 0;
  1291. return $old;
  1292. }
  1293. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "引进方式(其他):返晋创业时间在2021-11-16至2022-11-15之间;\n";
  1294. }
  1295. if ($old["applyCount"] == 1) {
  1296. $endTime = strtotime($old["endTime"]);
  1297. $after3YearsTime = strtotime("+3 years -1 days {$old['startTime']}");
  1298. if ($endTime < $after3YearsTime) {
  1299. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同不足3年,不予兑现;";
  1300. $old["recommendIsPay"] = -1;
  1301. $old["recommendAmount"] = 0;
  1302. return $old;
  1303. }
  1304. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 3) {
  1305. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:社保缴纳时间不足3个月,不予兑现;";
  1306. $old["recommendIsPay"] = -1;
  1307. $old["recommendAmount"] = 0;
  1308. return $old;
  1309. }
  1310. $old["recommendIsPay"] = 1;
  1311. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "首年申报:合同满足3年及以上,社保缴纳时间满足3个月及以上,予以兑现;\n";
  1312. $_old = $this->calculateAmount($old);
  1313. $old = array_merge($old, $_old);
  1314. } else {
  1315. if (!$old["actualSocialSecurity"] || $this->countByDates($old["actualSocialSecurity"]) < 9) {
  1316. $old["recommendJudgmentDetails"] = $old["recommendAmountDesc"] . "非首年申报:社保缴纳时间不足9个月,不予兑现";
  1317. $old["recommendIsPay"] = -1;
  1318. $old["recommendAmount"] = 0;
  1319. return $old;
  1320. }
  1321. if (!$old["actualTax"] || $this->countByDates($old["actualTax"]) < 9) {
  1322. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:个税缴纳时间不足9个月,不予兑现";
  1323. $old["recommendIsPay"] = -1;
  1324. $old["recommendAmount"] = 0;
  1325. return $old;
  1326. }
  1327. $old["recommendIsPay"] = 1;
  1328. $old["recommendJudgmentDetails"] = "非首年申报:社保缴纳时间满足9个月及以上,个税缴纳时间满足9个月及以上,予以兑现;\n";
  1329. $_old = $this->calculateAmount($old);
  1330. $old = array_merge($old, $_old);
  1331. }
  1332. return $old;
  1333. }
  1334. /**
  1335. * 计算月份数
  1336. * @param type $dates
  1337. * @return type
  1338. */
  1339. private function countByDates($dates) {
  1340. $dateArr = explode(",", $dates);
  1341. $count = 0;
  1342. for ($i = 0; $i < count($dateArr); $i++) {
  1343. $date = $dateArr[$i];
  1344. if ($date) {
  1345. if (strpos($date, "-") !== false) {
  1346. $cDateArr = explode("-", $date);
  1347. $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
  1348. $month1 = date("n", strtotime($cDateArr[0] . "01"));
  1349. $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
  1350. $month2 = date("n", strtotime($cDateArr[1] . "01"));
  1351. // 方法返回为相差月份
  1352. $date1 = date_create($_date1);
  1353. $date2 = date_create($_date2);
  1354. $diff = date_diff($date1, $date2);
  1355. if ($diff->invert != 1) {
  1356. $count += $diff->y * 12 + ($month2 - $month1) + 1;
  1357. }
  1358. } else {
  1359. $count++;
  1360. }
  1361. }
  1362. }
  1363. return $count;
  1364. }
  1365. }