LivingAllowance.php 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607
  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", "like", 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. $year = substr($old["year"], 0, 4);
  1451. $isActualSocialSecurityBigger6Month = $this->countByDatesWithYear($old["actualSocialSecurity"], $year) < 6 ? false : true;
  1452. $isActualTaxBigger6Month = $this->countByDatesWithYear($old["actualTax"], $year) < 6 ? false : true;
  1453. if (!$isActualSocialSecurityBigger6Month && !$isActualTaxBigger6Month) {
  1454. $old["recommendJudgmentDetails"] = $old["recommendJudgmentDetails"] . "非首年申报:社保和个税当年度缴纳时间均不足6个月,不予兑现";
  1455. $old["recommendIsPay"] = -1;
  1456. $old["recommendAmount"] = 0;
  1457. return $old;
  1458. }
  1459. $old["recommendIsPay"] = 1;
  1460. if ($isActualSocialSecurityBigger6Month && $isActualTaxBigger6Month) {
  1461. $old["recommendJudgmentDetails"] = "非首年申报:个税当年度缴纳时间满足6个月及以上,个税当年度缴纳时间满足6个月及以上,予以兑现;\n";
  1462. } else if ($isActualSocialSecurityBigger6Month) {
  1463. $old["recommendJudgmentDetails"] = "非首年申报:社保当年度缴纳时间满足6个月及以上,予以兑现;\n";
  1464. } else {
  1465. $old["recommendJudgmentDetails"] = "非首年申报:个税当年度缴纳时间满足6个月及以上,予以兑现;\n";
  1466. }
  1467. $_old = $this->calculateAmount($old);
  1468. $old = array_merge($old, $_old);
  1469. }
  1470. return $old;
  1471. }
  1472. /**
  1473. * 计算月份数
  1474. * @param type $dates
  1475. * @return type
  1476. */
  1477. private function countByDates($dates) {
  1478. $dates = $dates ?: "";
  1479. $dateArr = array_filter(explode(",", $dates));
  1480. $count = 0;
  1481. for ($i = 0; $i < count($dateArr); $i++) {
  1482. $date = $dateArr[$i];
  1483. if ($date) {
  1484. if (strpos($date, "-") !== false) {
  1485. $cDateArr = explode("-", $date);
  1486. $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
  1487. $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
  1488. $currentDate = $_date1;
  1489. while ($currentDate <= $_date2) {
  1490. $count++;
  1491. $currentDate = date("Y-m-d", strtotime("+1 month", strtotime($currentDate)));
  1492. }
  1493. } else {
  1494. $count++;
  1495. }
  1496. }
  1497. }
  1498. return $count;
  1499. }
  1500. /**
  1501. * 计算月份数
  1502. * @param type $dates
  1503. * @return type
  1504. */
  1505. private function countByDatesWithYear($dates, $year) {
  1506. $dates = $dates ?: "";
  1507. $dateArr = array_filter(explode(",", $dates));
  1508. $count = 0;
  1509. for ($i = 0; $i < count($dateArr); $i++) {
  1510. $date = $dateArr[$i];
  1511. if ($date) {
  1512. if (strpos($date, "-") !== false) {
  1513. $cDateArr = explode("-", $date);
  1514. $_date1 = date("Y-m-d", strtotime($cDateArr[0] . "01"));
  1515. $_date2 = date("Y-m-d", strtotime($cDateArr[1] . "01"));
  1516. $currentDate = $_date1;
  1517. while ($currentDate <= $_date2) {
  1518. $currentYear = date("Y", strtotime($currentDate));
  1519. if ($currentYear == $year) {
  1520. $count++;
  1521. }
  1522. $currentDate = date("Y-m-d", strtotime("+1 month", strtotime($currentDate)));
  1523. }
  1524. } else {
  1525. // 处理单个日期
  1526. $_date = date("Y-m-01", strtotime($date . "01"));
  1527. if (date("Y", strtotime($_date)) == $year) {
  1528. $count++;
  1529. }
  1530. }
  1531. }
  1532. }
  1533. return $count;
  1534. }
  1535. }