LivingAllowance.php 66 KB

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