LivingAllowance.php 71 KB

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