TalentAllowanceApi.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <?php
  2. namespace app\common\api;
  3. use app\common\model\TalentAllowance as TaModel;
  4. use app\common\state\MainState;
  5. use think\facade\Db;
  6. use app\common\state\CommonConst;
  7. use app\common\state\AllowanceProjectEnum;
  8. use app\common\model\TalentAllowanceArrange;
  9. use app\common\model\AmountStandard as AsModel;
  10. use app\common\state\AllowanceStateEnum;
  11. /**
  12. * Description of TalentAllowanceApi
  13. *
  14. * @author sgq
  15. */
  16. class TalentAllowanceApi {
  17. public static function getList($params) {
  18. $user = session("user");
  19. $order = trim($params["order"]) ?: "desc";
  20. $offset = trim($params["offset"]) ?: 0;
  21. $limit = trim($params["limit"]) ?: 10;
  22. $where = [];
  23. $where[] = ["ta.delete", "=", 0];
  24. $where[] = ["ta.enterpriseId", "=", $user["uid"]];
  25. if ($_where = self::setTalentAllowanceInfo($params)) {
  26. $where = array_merge($where, $_where);
  27. }
  28. $whereRaw = "ta.id>0";
  29. if (\StrUtil::isNotEmpAndNull($params["checkState"])) {
  30. switch ($params["checkState"]) {
  31. case 1:
  32. $where[] = ["ta.checkState", "=", AllowanceStateEnum::SAVE];
  33. break;
  34. case 5:
  35. $where[] = ["ta.publicState", "<>", 5];
  36. $whereRaw = "ta.checkState=5 or ta.checkState >= 13";
  37. break;
  38. case 10:
  39. $where[] = ["ta.checkState", "=", AllowanceStateEnum::FIRST_REJECT];
  40. break;
  41. case 30:
  42. $where[] = ["ta.checkState", "=", AllowanceStateEnum::REVIEW_PASS];
  43. $where[] = ["ta.publicState", "=", 5];
  44. break;
  45. case -1:
  46. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NOTPASS];
  47. break;
  48. }
  49. }
  50. $count = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->count();
  51. $list = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->field("ta.*")->limit($offset, $limit)->order("year {$order},ta.createTime {$order}")->select()->toArray();
  52. $levelList = DictApi::selectByParentCode("talent_arrange");
  53. $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
  54. $streetList = DictApi::selectByParentCode("street");
  55. $identifyConditionIds = array_filter(array_unique(array_column($list, "identifyCondition")));
  56. $whr[] = ["id", "in", $identifyConditionIds];
  57. $whr[] = ["type", "=", $user["type"]];
  58. $identifyConditionKvList = TalentConditionApi::getKvList($whr);
  59. foreach ($list as $key => $item) {
  60. $list[$key]["talentArrangeName"] = $levelList[$item["talentArrange"]];
  61. $list[$key]["talentTypeName"] = $talentTypeList[$item["talentType"]];
  62. $list[$key]["addressName"] = $streetList[$item["address"]];
  63. $list[$key]["identifyConditionText"] = $identifyConditionKvList[$item["identifyCondition"]];
  64. }
  65. return ["total" => $count, "rows" => $list];
  66. }
  67. public static function getHospitalExamineList($params) {
  68. $user = session("user");
  69. $order = trim($params["order"]) ?: "desc";
  70. $offset = trim($params["offset"]) ?: 0;
  71. $limit = trim($params["limit"]) ?: 10;
  72. $where = [];
  73. $where[] = ["ta.delete", "=", 0];
  74. $where[] = ["ta.type", "=", 5];
  75. $where[] = ["e.medicalCommunityId", "=", $user["medicalCommunityId"]];
  76. $where[] = ["e.isGeneral", "=", 2];
  77. if ($_where = self::setTalentAllowanceInfo($params)) {
  78. $where = array_merge($where, $_where);
  79. }
  80. $whereRaw = "ta.id>0";
  81. if (\StrUtil::isNotEmpAndNull($params["checkState"])) {
  82. switch ($params["checkState"]) {
  83. case -1:
  84. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NOTPASS];
  85. break;
  86. case -2:
  87. $where[] = ["ta.checkState", "=", AllowanceStateEnum::SAVE];
  88. break;
  89. case 1:
  90. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NEED_GENERAL_CHECK];
  91. $whereRaw = "ta.highProcess is null or ta.highProcess < 1";
  92. break;
  93. case 2:
  94. $where[] = ["ta.checkState", "=", AllowanceStateEnum::GENERAL_REJECT];
  95. break;
  96. case 3:
  97. $where[] = ["ta.checkState", "=", AllowanceStateEnum::REVIEW_PASS];
  98. $where[] = ["ta.publicState", "=", 5];
  99. break;
  100. case 4:
  101. $where[] = ["ta.checkState", "=", AllowanceStateEnum::FIRST_REJECT];
  102. break;
  103. case 5:
  104. $where[] = ["ta.checkState", "=", AllowanceStateEnum::FIRST_REJECT_BRANCH];
  105. break;
  106. case 6:
  107. $where[] = ["ta.publicState", "<>", 5];
  108. $whereRaw = "ta.checkState=5 or ta.checkState >= 13";
  109. break;
  110. case 9:
  111. $where[] = ["ta.checkState", "=", AllowanceStateEnum::NEED_GENERAL_CHECK];
  112. $whereRaw = "ta.highProcess is not null and ta.highProcess >= 1";
  113. break;
  114. }
  115. }
  116. $count = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->count();
  117. $list = TaModel::where($where)->whereRaw($whereRaw)->alias("ta")->leftJoin("un_enterprise e", "e.id=ta.enterpriseId")->field("ta.*")->limit($offset, $limit)->order("year {$order},ta.createTime {$order}")->select()->toArray();
  118. $levelList = DictApi::selectByParentCode("talent_arrange");
  119. $talentTypeList = DictApi::selectByParentCode("enterprise_tag");
  120. $streetList = DictApi::selectByParentCode("street");
  121. $identifyConditionIds = array_filter(array_unique(array_column($list, "identifyCondition")));
  122. $whr[] = ["id", "in", $identifyConditionIds];
  123. $whr[] = ["type", "=", $user["type"]];
  124. $identifyConditionKvList = TalentConditionApi::getKvList($whr);
  125. foreach ($list as $key => $item) {
  126. $list[$key]["talentArrangeName"] = $levelList[$item["talentArrange"]];
  127. $list[$key]["talentTypeName"] = $talentTypeList[$item["talentType"]];
  128. $list[$key]["addressName"] = $streetList[$item["address"]];
  129. $list[$key]["identifyConditionText"] = $identifyConditionKvList[$item["identifyCondition"]];
  130. }
  131. return ["total" => $count, "rows" => $list];
  132. }
  133. public static function setTalentAllowanceInfo($params) {
  134. $where = [];
  135. if (\StrUtil::isNotEmpAndNull($params["year"])) {
  136. $where[] = ["ta.year", "like", $params["year"] . "%"];
  137. }
  138. if (\StrUtil::isNotEmpAndNull($params["enterpriseName"])) {
  139. $where[] = ["ta.enterpriseName", "like", "%" . $params["enterpriseName"] . "%"];
  140. }
  141. if (\StrUtil::isNotEmpAndNull($params["name"])) {
  142. $where[] = ["ta.name", "like", "%" . $params["name"] . "%"];
  143. }
  144. if (\StrUtil::isNotEmpAndNull($params["talentType"])) {
  145. $where[] = ["ta.talentType", "=", $params["talentType"]];
  146. }
  147. if (\StrUtil::isNotEmpAndNull($params["talentArrange"])) {
  148. $where[] = ["ta.talentArrange", "=", $params["talentArrange"]];
  149. }
  150. if (\StrUtil::isNotEmpAndNull($params["identiryCondition"])) {
  151. $where[] = ["ta.identifyCondition", "=", $params["identifyCondition"]];
  152. }
  153. if (\StrUtil::isNotEmpAndNull($params["allowanceType"])) {
  154. $where[] = ["ta.allowanceType", "=", $params["allowanceType"]];
  155. }
  156. if (\StrUtil::isNotEmpAndNull($params["address"])) {
  157. $where[] = ["ta.address", "=", $params["address"]];
  158. }
  159. return $where;
  160. }
  161. public static function getInfoById($id) {
  162. return TaModel::findOrEmpty($id)->toArray();
  163. }
  164. public static function getApplyCountByIdCard($idCard) {
  165. $where = [];
  166. $where[] = ["idCard", "=", $idCard];
  167. $where[] = ["checkState", "<>", MainState::NOTPASS];
  168. $list = TaModel::where($where)->distinct(true)->field("substr(year,1,4) as year")->select()->toArray();
  169. $years = array_column($list, "year");
  170. return $years;
  171. }
  172. public static function getPassYearsByIdCard($idCard) {
  173. $where = [];
  174. $where[] = ["idCard", "=", $idCard];
  175. $where[] = ["checkState", "=", MainState::PASS];
  176. $list = TaModel::where($where)->distinct(true)->field("substr(year,1,4) as year")->select()->toArray();
  177. $passYears = array_column($list, "year");
  178. return $passYears;
  179. }
  180. public static function validateAllowanceType($id) {
  181. $info = ["id" => $id];
  182. $old = self::getInfoById($id);
  183. $info["type"] = $old["type"];
  184. $info["backWork"] = $old["backWork"];
  185. $info["allowanceType"] = $old["allowanceType"];
  186. $info["otherEnjoyedMoney"] = $old["otherEnjoyedMoney"];
  187. $info["otherEnjoyedDescription"] = $old["otherEnjoyedDescription"];
  188. $enterpriseMap = \app\common\model\Enterprise::where("type", $old["type"])->column("name", "id");
  189. /* * 查询工作单位记录 */
  190. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  191. $detaiPdList = []; //用于判定类型
  192. $detailMonthList = []; //用于计算月份
  193. foreach ($initDetailList as $detail) {
  194. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  195. $projectMap = [];
  196. foreach ($projectList as $project) {
  197. $projectMap[$project["project"]] = $project;
  198. }
  199. $detail["list"] = $projectList;
  200. $detail["projectMap"] = $projectMap;
  201. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  202. /* * 筛选符合条件的人才标签 */
  203. $detaiPdList[] = $detail;
  204. $detailMonthList[] = $detail;
  205. }
  206. $monthMap = self::mergeMonth($detailMonthList);
  207. $monthAndDayMap = self::mergeMonthNeedDay($detailMonthList);
  208. $info["recommendAllowanceType"] = $old["allowanceType"];
  209. $info["recommendAllowanceMsg"] = [];
  210. $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $id)->select()->toArray();
  211. $set = self::valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap);
  212. $info["recommendAllowanceMsg"][] = "综合以上所有判断得到最终补贴类型为:";
  213. if ($info["recommendAllowanceType"] == 1) {
  214. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>工作津贴</span>;";
  215. $info["recommendAllowanceMsg"][] = "可享受月份为:";
  216. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>" . implode(",", $set) . "</span>;";
  217. }
  218. if ($info["recommendAllowanceType"] == 2)
  219. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>一次性交通补贴</span>;";
  220. if ($info["recommendAllowanceType"] == 3)
  221. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>不予兑现</span>;";
  222. usort($set, function ($a, $b) {
  223. return (int) $a - (int) $b;
  224. });
  225. $info["recommendMonths"] = implode(",", $set);
  226. self::calculateAllowance($info, $set, $detailMonthList);
  227. return $info;
  228. }
  229. /**
  230. * 集成电路津补贴总校验
  231. * */
  232. private static function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) {
  233. $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  234. /* * 2.判定合同月份、工作月份、五险和个税是否满足重叠6个月要求* */
  235. $contractSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_CONTRACT], $info, "上年度合同月份", "①");
  236. $workdaySet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_ATTENDANCE], $info, "上年度工作月份", "②");
  237. $wageSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WAGES], $info, "上年度工资发放月份", "③");
  238. $pensionSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "④");
  239. $unemploymentSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "⑤");
  240. $medicaSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "⑥");
  241. $taxSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑦");
  242. $str = "工作合同月份、考勤月份、工资发放月份";
  243. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  244. $str = "工作合同月份、考勤月份";
  245. $set = array_intersect($set, $contractSet);
  246. $set = array_intersect($set, $workdaySet);
  247. $checkSet = $set;
  248. //$set = array_intersect($set, $pensionSet);
  249. //$set = array_intersect($set, $taxSet);
  250. } else if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  251. if ($info["backWork"] == 1) {
  252. //$set = array_intersect($set, $workdaySet);
  253. $set = array_intersect($set, $wageSet);
  254. } else {
  255. //$set = array_intersect($set, $workdaySet);
  256. $set = array_intersect($set, $wageSet);
  257. }
  258. } else {
  259. $set = array_intersect($set, $contractSet);
  260. $set = array_intersect($set, $workdaySet);
  261. $set = array_intersect($set, $wageSet);
  262. $checkSet = $set;
  263. $set = array_intersect($set, $pensionSet);
  264. $set = array_intersect($set, $unemploymentSet);
  265. $set = array_intersect($set, $medicaSet);
  266. $set = array_intersect($set, $taxSet);
  267. }
  268. usort($set, function ($a, $b) {
  269. return (int) $a - (int) $b;
  270. });
  271. if ($info["recommendAllowanceType"] == 1) {
  272. if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  273. //高教另外判断
  274. $taxCount = 1;
  275. foreach ($taxSet as $s) {
  276. $currentVal = intval($s);
  277. $nextVal = $currentVal + 1;
  278. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  279. if (in_array($nextKey, $taxSet)) {
  280. $taxCount++;
  281. if ($taxCount >= 2) {
  282. break;
  283. }
  284. } else {
  285. $taxCount = 1;
  286. }
  287. }
  288. if ($info["backWork"] == 1) {
  289. //需要判断缴税有没有连续两个月以上
  290. if ($taxCount < 2) {
  291. $info["recommendAllowanceType"] = 3;
  292. $info["recommendAllowanceMsg"][] = "上年度个税缴纳月份不满足连续缴纳2个月(" . implode(",", $taxSet) . "),无法享受工作津贴(×)";
  293. }
  294. } else {
  295. //需要判断缴税或者养老有没有连续两个月以上
  296. $pensionCount = 1;
  297. foreach ($pensionSet as $s) {
  298. $currentVal = intval($s);
  299. $nextVal = $currentVal + 1;
  300. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  301. if (in_array($nextKey, $pensionSet)) {
  302. $pensionCount++;
  303. if ($pensionCount >= 2) {
  304. break;
  305. }
  306. } else {
  307. $pensionCount = 1;
  308. }
  309. }
  310. if ($taxCount < 2 && $pensionCount < 2) {
  311. $info["recommendAllowanceType"] = 3;
  312. $info["recommendAllowanceMsg"][] = "上年度个税缴纳月份(" . implode(",", $taxSet) . ")与养老保险缴纳月份(" . implode(",", $pensionSet) . ")均不满足连续缴纳2个月,无法享受工作津贴(×)";
  313. }
  314. }
  315. } else {
  316. $checkDayCount = $info["type"] == CommonConst::ENTERPRISE_WJ ? 9 : 6; //卫健需要连续交集9个月
  317. if (count($checkSet) < $checkDayCount) {
  318. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  319. $info["recommendAllowanceType"] = 3;
  320. $info["recommendAllowanceMsg"][] = "上年度{$str}交集月份不满足{$checkDayCount}个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  321. }
  322. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  323. //检查连续缴纳月份是否满足9个月
  324. $count = 1;
  325. foreach ($checkSet as $s) {
  326. $currentVal = intval($s);
  327. $nextVal = $currentVal + 1;
  328. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  329. if (in_array($nextKey, $checkSet)) {
  330. $count++;
  331. if ($count >= $checkDayCount) {
  332. break;
  333. }
  334. } else {
  335. $count = 1;
  336. }
  337. }
  338. if ($count < $checkDayCount) {
  339. $info["recommendAllowanceType"] = 3;
  340. $info["recommendAllowanceMsg"][] = "上年度{$str}交集月份不满足连续缴纳{$checkDayCount}个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  341. }
  342. }
  343. }
  344. }
  345. if ($info["recommendAllowanceType"] == 2) {
  346. //判断境内工作时间是否大于30天
  347. if ($info["allowanceType"] == 2) {
  348. $totalDays = 0;
  349. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_ATTENDANCE];
  350. foreach ($workmonths as $days) {
  351. $totalDays += $days;
  352. }
  353. if ($totalDays < 30) {
  354. $info["recommendAllowanceType"] = 3;
  355. $info["recommendAllowanceMsg"][] = "全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  356. }
  357. } else {
  358. if (count($workdaySet) == 0) {
  359. $info["recommendAllowanceType"] = 3;
  360. $info["recommendAllowanceMsg"][] = "全年在我市工作未达到30天,无法享受一次性交通津贴(×)";
  361. } else {
  362. $info["recommendAllowanceType"] = 2;
  363. $info["recommendAllowanceMsg"][] = "*首选为工作津贴,未录入实际工作天数,需要进一步核实提交的相关附件是否满足全年在我市工作30天";
  364. }
  365. }
  366. }
  367. return $set;
  368. }
  369. /**
  370. * 计算津补贴
  371. */
  372. private static function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  373. /* * 查询人才层次变更记录 */
  374. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  375. foreach ($arrangeList as &$arrange) {
  376. $where = [];
  377. $where[] = ["type", "=", $info["type"]];
  378. $where[] = ["allowanceType", "in", [1, 2]];
  379. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  380. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  381. foreach ($list as $amount) {
  382. if ($amount["allowanceType"] == 1) {
  383. $arrange["jobMoney"] = $amount["money"];
  384. }
  385. if ($amount["allowanceType"] == 2) {
  386. $arrange["jtMoney"] = $amount["money"];
  387. }
  388. }
  389. }unset($arrange);
  390. /* * * 容器 */
  391. $jobMoney = 0.00; //计算所得工作津贴
  392. $jtMoney = 0.00; //计算所得一次性交通补贴
  393. $recommendMonths = []; //推荐月份
  394. $talentArrange = null;
  395. /* * *********计算************* */
  396. $msgBulider = [];
  397. $identifyExpiredName = "人才证书有效期";
  398. if ($info["type"] == CommonConst::ENTERPRISE_JC) {
  399. $identifyExpiredName = "认定条件有效期";
  400. }
  401. switch ($info["recommendAllowanceType"]) {
  402. case 1:
  403. foreach ($arrangeList as &$arrange) {
  404. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  405. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  406. $levelList = array_intersect($levelList, $retainMonths);
  407. $total = round($arrange["jobMoney"] * count($levelList), 2);
  408. $jobMoney += $total;
  409. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  410. $recommendMonths = array_merge($recommendMonths, $levelList);
  411. usort($recommendMonths, function ($a, $b) {
  412. return (int) $a - (int) $b;
  413. });
  414. $arrange["months"] = implode(",", $levelList);
  415. $arrange["count"] = count($levelList);
  416. $arrange["total"] = $total;
  417. } else {
  418. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  419. $arrange["count"] = 0;
  420. $arrange["total"] = 0.00;
  421. }
  422. }unset($arrange);
  423. $info["recommendMonths"] = implode(",", $recommendMonths);
  424. $info["recommendAllowanceMsg"][] = "通过与{$identifyExpiredName}取交集得到最终可享受月份:";
  425. $info["recommendAllowanceMsg"][] = "<span style='color:red;font-weight:bold;'>" . implode(",", $recommendMonths) . "</span>;";
  426. $info["recommendAllowanceMsg"][] = "经过计算:兑现月份" . count($recommendMonths) . "个月,人才津贴为<span style='color:red;font-weight:bold;'>" . $jobMoney . "</span>;";
  427. $finnalMoney = $jobMoney;
  428. if ($info["otherEnjoyedMoney"] > 0) {
  429. $finnalMoney = number_format($jobMoney - $info["otherEnjoyedMoney"], 2);
  430. $info["recommendAllowanceMsg"][] = "扣除其它已享受补贴金额" . $info["otherEnjoyedMoney"] . "元,最终可享受人才津贴为<span style='color:red;font-weight:bold;'>" . number_format($jobMoney - $info["otherEnjoyedMoney"], 2) . "</span>;";
  431. }
  432. $info["finnalMoney"] = $finnalMoney;
  433. $info["recommendMoney"] = $jobMoney;
  434. $info["recommendMoneyDesc"] = implode("+", $msgBulider);
  435. $updAllowance["id"] = $info["id"];
  436. $updAllowance["virtualAmount"] = $jobMoney;
  437. TaModel::update($updAllowance);
  438. break;
  439. case 2:
  440. foreach ($arrangeList as $arrange) {
  441. $jtMoney = $arrange["jtMoney"];
  442. $talentArrange = $arrange["talentArrange"];
  443. }
  444. $info["recommendMoney"] = $jtMoney;
  445. $info["recommendMonths"] = "";
  446. $info["recommendMoneyDesc"] = "一次性交通补贴";
  447. $info["workAllowanceMoney"] = 0.00;
  448. $info["developAllowanceMoney"] = 0.00;
  449. $info["recommendTalentArrange"] = $talentArrange;
  450. $updAllowance["id"] = $info["id"];
  451. $updAllowance["virtualAmount"] = $jtMoney;
  452. $finnalMoney = $jtMoney;
  453. if ($info["otherEnjoyedMoney"] > 0) {
  454. $finnalMoney = number_format($jobMoney - $info["otherEnjoyedMoney"], 2);
  455. $info["recommendAllowanceMsg"][] = "扣除其它已享受补贴金额" . $info["otherEnjoyedMoney"] . "元,最终可享受人才津贴为<span style='color:red;font-weight:bold;'>" . number_format($jtMoney - $info["otherEnjoyedMoney"], 2) . "</span>;";
  456. }
  457. $info["finnalMoney"] = $finnalMoney;
  458. TaModel::update($updAllowance);
  459. break;
  460. case 3:
  461. $info["recommendMoney"] = 0.00;
  462. $info["recommendMonths"] = "";
  463. $info["recommendMoneyDesc"] = "不予兑现";
  464. $info["workAllowanceMoney"] = 0.00;
  465. $info["developAllowanceMoney"] = 0.00;
  466. break;
  467. }
  468. return $arrangeList;
  469. }
  470. /**
  471. * 判定是否交足6个月(集成电路)
  472. * @param set
  473. * @param info
  474. * @param name
  475. */
  476. private static function chkMonths($set, &$info, $name, $sort) {
  477. if ($name == "上年度工作月份") {
  478. if ($info["allowanceType"] == 2) {
  479. $tmp = [];
  480. foreach ($set as $s) {
  481. $_s = explode("=", $s);
  482. $month = $_s[0];
  483. $days = $_s[1];
  484. if ($days > 0) {
  485. $tmp[] = $month;
  486. }
  487. }
  488. $set = $tmp;
  489. }
  490. }
  491. $preCheckProjects = ["①", "②", "③"];
  492. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  493. $preCheckProjects = ["①", "②"];
  494. }
  495. if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  496. if ($info["backWork"] == 1) {
  497. $preCheckProjects = ["②", "③"];
  498. } else {
  499. $preCheckProjects = ["②", "③"];
  500. }
  501. }
  502. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6) && in_array($sort, $preCheckProjects)) {
  503. $info["recommendAllowanceType"] = 3;
  504. $info["recommendAllowanceMsg"][] = $sort . $name . "不足6个月,无法享受工作津贴(×)";
  505. }
  506. return $set;
  507. }
  508. //合并所有项目的月份
  509. private static function mergeMonth($detailList) {
  510. $contractList = [];
  511. $taxList = [];
  512. $wagesList = [];
  513. $pensionList = [];
  514. $unemploymentList = [];
  515. $medicaList = [];
  516. $attendanceList = [];
  517. $workdayList = [];
  518. foreach ($detailList as $detail) {
  519. $projectMap = $detail["projectMap"];
  520. if ($detail["months"]) {
  521. $tmp = array_filter(explode(",", $detail["months"]));
  522. $contractList = array_merge($contractList, $tmp);
  523. }
  524. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  525. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  526. $taxList = array_merge($taxList, $tmp);
  527. }
  528. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  529. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  530. $wagesList = array_merge($wagesList, $tmp);
  531. }
  532. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  533. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  534. $pensionList = array_merge($pensionList, $tmp);
  535. }
  536. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  537. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  538. $unemploymentList = array_merge($unemploymentList, $tmp);
  539. }
  540. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  541. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  542. $medicaList = array_merge($medicaList, $tmp);
  543. }
  544. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  545. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  546. $attendanceList = array_merge($attendanceList, $tmp);
  547. }
  548. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  549. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  550. $workdayList = array_merge($workdayList, $tmp);
  551. }
  552. }
  553. $map = [
  554. AllowanceProjectEnum::PROJECT_CONTRACT => $contractList,
  555. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  556. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  557. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  558. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  559. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  560. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  561. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  562. ];
  563. return $map;
  564. }
  565. /**
  566. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  567. * */
  568. private static function mergeMonthNeedDay($detailList) {
  569. $attendMap = [];
  570. $workDayMap = [];
  571. foreach ($detailList as $detail) {
  572. $attendMap = self::getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  573. $workDayMap = self::getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  574. }
  575. $res = [
  576. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  577. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  578. ];
  579. return $res;
  580. }
  581. private static function getMergeMonthNeedDayMap($project, $map) {
  582. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  583. $monthAndDayList = array_filter(explode(",", $project["months"]));
  584. for ($i = 0; $i < count($monthAndDayList); $i++) {
  585. $obj = explode("=", $monthAndDayList[$i]);
  586. $month = $obj[0];
  587. $day = is_numeric($obj[1]) ? $obj[1] : 0;
  588. $count = $map[$month];
  589. if ($count == 0) {
  590. $map[$month] = $day;
  591. } else {
  592. $map[$month] = $day + $count;
  593. }
  594. }
  595. }
  596. return $map;
  597. }
  598. }