TalentAllowance.php 110 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use think\facade\Db;
  5. use app\common\api\Response;
  6. use app\common\api\DictApi;
  7. use app\common\api\TalentAllowanceApi;
  8. use app\common\api\TalentLogApi;
  9. use app\common\model\TalentAllowance as TaModel;
  10. use app\common\model\TalentChecklog;
  11. use app\common\model\TalentAllowanceArrange;
  12. use app\common\state\ProjectState;
  13. use app\common\state\AllowanceStateEnum;
  14. use app\common\state\AllowanceProjectEnum;
  15. use app\common\state\AllowanceTypeEnum;
  16. use app\common\model\AmountStandard as AsModel;
  17. use app\common\state\CommonConst;
  18. /**
  19. * Description of TalentAllowance
  20. *
  21. * @author sgq
  22. */
  23. class TalentAllowance extends AdminController {
  24. public function index() {
  25. $process = $this->request["process"];
  26. $type = $this->user["type"];
  27. $assigns = ["process" => $process, "type" => $type];
  28. if ($process == 4) {
  29. if ($type == CommonConst::ENTERPRISE_NORMAL) {
  30. $msgBody["typeName"] = "晋江市现代产业体系人才津补贴申报";
  31. $msgBody["address"] = "聚才网/人才晋江微信公众号";
  32. $msgBody["dep"] = "中共晋江市委人才办、晋江市纪委监委驻市人力资源和社会保障局纪检监察组或晋江市公共就业和人才服务中心";
  33. $msgBody["phone"] = "0595-85633128";
  34. $msgBody["email"] = "jjrc85661234@163.com";
  35. }
  36. if ($type == CommonConst::ENTERPRISE_JC) {
  37. $msgBody["typeName"] = "晋江市集成电路产业优秀人才津补贴申报";
  38. $msgBody["address"] = "福建(晋江)集成电路产业园官方网站及微信公众号";
  39. $msgBody["dep"] = "集成电路产业园区";
  40. $msgBody["phone"] = "0595-82250007、0595-82250001";
  41. $msgBody["email"] = "jjjcdr@163.com";
  42. }
  43. if ($type == CommonConst::ENTERPRISE_WJ) {
  44. $msgBody["typeName"] = "晋江市医疗卫生人才津补贴申报";
  45. $msgBody["address"] = "“健康晋江”微信公众号";
  46. $msgBody["dep"] = "晋江市卫生健康局";
  47. $msgBody["phone"] = "0595-85636159";
  48. $msgBody["email"] = "jjswjjrsk@163.com";
  49. }
  50. if ($type == CommonConst::ENTERPRISE_GJ) {
  51. $msgBody["typeName"] = "晋江市高等教育人才津补贴申报";
  52. $msgBody["address"] = "“泉州市高教发展中心”微信公众号";
  53. $msgBody["dep"] = "泉州市高教发展中心";
  54. $msgBody["phone"] = "0595-85002588";
  55. $msgBody["email"] = "jjsgjrc@126.com";
  56. }
  57. $assigns["message"] = $msgBody;
  58. }
  59. return view("", $assigns);
  60. }
  61. /**
  62. * 获取优秀人才津补贴列表
  63. */
  64. public function list() {
  65. $param = $this->request->param();
  66. $offset = $param["offset"] ?: 0;
  67. $limit = $param["limit"] ?: 10;
  68. $process = $param["process"];
  69. $where = [];
  70. $where[] = ["type", "=", $this->user["type"]];
  71. $where[] = ["delete", "=", 0];
  72. $order = "newSubmitTime desc";
  73. $where = $this->setTalentAllowanceInfo($where, $param, $process);
  74. switch ($process) {
  75. case 1:
  76. $where[] = ["checkState", "in", [-1, 1, 5, 10, 13, 15, 20, 25, 30]];
  77. break;
  78. case 2:
  79. $where[] = ["firstPassTime", "EXP", Db::raw("is not null")];
  80. break;
  81. case 3:
  82. $where[] = ["visitPassTime", "EXP", Db::raw("is not null")];
  83. break;
  84. case 4:
  85. if ($param["publicState"]) {
  86. $where[] = ["publicState", "=", $param["publicState"]];
  87. }
  88. $where[] = ["checkState", "in", [-1, 30]];
  89. break;
  90. }
  91. $count = TaModel::where($where)->count();
  92. $list = TaModel::where($where)->limit($offset, $limit)->order($order)->select()->toArray();
  93. $list = $this->translateChinese($list);
  94. return json(["rows" => $list, "total" => $count]);
  95. }
  96. /**
  97. * 审核页面
  98. * @return type
  99. */
  100. public function toCheckPage() {
  101. $id = $this->request["id"];
  102. $process = $this->request["process"];
  103. $obj = TalentAllowanceApi::getInfoById($id);
  104. $this->translateToChinese($obj);
  105. if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  106. $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
  107. $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
  108. if ($need_choose_post_type[$obj["enterpriseId"]]) {
  109. $postTypes = DictApi::findChildDictByCode("PostType");
  110. foreach ($postTypes as $key => $pt) {
  111. if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
  112. unset($postTypes[$key]);
  113. }
  114. }
  115. }
  116. if (in_array($obj["enterpriseId"], $need_choose_institution)) {
  117. $institutions = DictApi::findChildDictByCode("Institution");
  118. }
  119. }
  120. return view("info", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
  121. }
  122. /**
  123. * 查看详情
  124. * @return type
  125. */
  126. public function toSelectPage() {
  127. $id = $this->request["id"];
  128. $process = $this->request["process"];
  129. $obj = TalentAllowanceApi::getInfoById($id);
  130. $this->translateToChinese($obj);
  131. if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  132. $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
  133. $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
  134. if ($need_choose_post_type[$obj["enterpriseId"]]) {
  135. $postTypes = DictApi::findChildDictByCode("PostType");
  136. foreach ($postTypes as $key => $pt) {
  137. if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
  138. unset($postTypes[$key]);
  139. }
  140. }
  141. }
  142. if (in_array($obj["enterpriseId"], $need_choose_institution)) {
  143. $institutions = DictApi::findChildDictByCode("Institution");
  144. }
  145. }
  146. return view("select", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
  147. }
  148. public function save() {
  149. $id = $this->request["id"];
  150. $allowanceType = $this->request["allowanceType"];
  151. $old = TalentAllowanceApi::getInfoById($id);
  152. if ($old["checkState"] != AllowanceStateEnum::NEED_CHECK && $old["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  153. return new Response(Response::ERROR, "不在审核范围内");
  154. }
  155. if ($allowanceType == $old["allowanceType"]) {
  156. return new Response(Response::ERROR, "没有更改不需要保存");
  157. }
  158. $upd["id"] = $id;
  159. $upd["allowanceType"] = $allowanceType;
  160. TaModel::update($upd);
  161. return new Response(Response::SUCCESS, "保存成功");
  162. }
  163. /**
  164. * 审核保存
  165. */
  166. public function check() {
  167. $obj = $this->request->param();
  168. if (!$obj["checkState"]) {
  169. return new Response(Response::ERROR, "请选择审核状态");
  170. }
  171. $oldObj = TalentAllowanceApi::getInfoById($obj["id"]);
  172. if (!$oldObj) {
  173. return new Response(Response::ERROR, "审核对象不存在");
  174. }
  175. $newObj = [];
  176. $newObj["id"] = $obj["id"];
  177. $projectList = [];
  178. $fileList = [];
  179. if ($obj["process"] == 1) {
  180. if (\StrUtil::isNotEmpAndNull($obj["projects"])) {
  181. $projectList = array_filter(explode(",", $obj["projects"]));
  182. $newObj["projects"] = implode(",", $projectList);
  183. }
  184. if (\StrUtil::isNotEmpAndNull($obj["files"])) {
  185. $fileList = array_filter(explode(",", $obj["files"]));
  186. $newObj["files"] = implode(",", $fileList);
  187. }
  188. //if (Const.RSJ.equals(checkCompany.getCode())) {
  189. $newObj["concats"] = $obj["concats"];
  190. $newObj["fields"] = $obj["fields"];
  191. //}
  192. }
  193. if ($obj["process"] == 3) {
  194. $newObj["toProcess"] = $obj["toProcess"];
  195. $newObj["toDep"] = $obj["toDep"];
  196. if ($oldObj["type"] == CommonConst::ENTERPRISE_GJ && $obj["checkState"] == 3) {
  197. $typeName = "";
  198. $old["recommendAllowanceMsg"] = "";
  199. if ($obj["source"] == 1) { //遵循系统结果
  200. $typeName = "系统判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["allowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  201. $newObj["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $newObj["recommendAllowanceMsg"] . ";";
  202. } else if ($obj["source"] == 2) {
  203. $detailIds = array_column($obj["details"], "id");
  204. $where = [];
  205. $where[] = ["id", "in", $detailIds];
  206. $detailList = \app\common\model\TalentAllowancecontractDetail::where($where)->select()->toArray();
  207. $newObj['allowanceType'] = $obj["resAllowanceType"];
  208. $newObj["recommendAllowanceType"] = $obj["resAllowanceType"];
  209. $set = [];
  210. if ($obj["resAllowanceType"] == 1) {
  211. $monthsMap = [];
  212. for ($i = 0; $i < count($obj["details"]); $i++) {
  213. $monthsMap[$obj["details"][$i]["id"]] = $obj["details"][$i]["months"];
  214. }
  215. foreach ($detailList as &$detail) {
  216. $months = $monthsMap[$detail["id"]];
  217. if (\StrUtil::isNotEmpAndNull($months)) {
  218. $detail["months"] = $months;
  219. $set = array_merge($set, explode(",", $months));
  220. }
  221. }unset($detail);
  222. $set = array_filter($set);
  223. usort($set, function ($a, $b) {
  224. return (int) $a - (int) $b;
  225. });
  226. $newObj["recommendMonths"] = implode(",", $set);
  227. $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($newObj["recommendAllowanceType"])) . ");享受月份:" . $newObj["recommendMonths"] . ";\n";
  228. }else{
  229. $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($newObj["recommendAllowanceType"])) . ");\n";
  230. }
  231. $newObj["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $obj["resAllowanceMsg"] . ";";
  232. $arrangeList = $this->calculateAllowance($newObj, $set, $detailList);
  233. $taaModel = new TalentAllowanceArrange();
  234. $taaModel->saveAll($arrangeList);
  235. }
  236. $newObj["otherEnjoyedMoney"] = $obj["otherEnjoyedMoney"];
  237. $newObj["otherEnjoyedDescription"] = $obj["otherEnjoyedDescription"];
  238. } else {
  239. //$newObj["otherEnjoyedMoney"] = 0.00;
  240. //$newObj["otherEnjoyedDescription"] = null;
  241. }
  242. }
  243. TaModel::update($newObj);
  244. //添加日志
  245. TalentChecklog::create([
  246. 'id' => getStringId(),
  247. 'mainId' => $obj['id'],
  248. 'type' => intval(ProjectState::JBT),
  249. 'typeFileId' => null,
  250. 'active' => 2,
  251. 'state' => $obj["checkState"],
  252. 'step' => $obj["process"],
  253. 'stateChange' => null,
  254. 'description' => $obj["checkMsg"],
  255. 'createTime' => date("Y-m-d H:i:s", time()),
  256. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  257. ]);
  258. return new Response(Response::SUCCESS, "审核成功");
  259. }
  260. /**
  261. * 提交审核
  262. * @return Response
  263. */
  264. public function submitCheck() {
  265. $id = $this->request["id"];
  266. $process = $this->request["process"];
  267. $old = TalentAllowanceApi::getInfoById($id);
  268. if (!$old) {
  269. return new Response(Response::ERROR, "审核对象不存在");
  270. }
  271. $updCheck = [];
  272. $updCheck["id"] = $id;
  273. $updCheck["type"] = $old["type"];
  274. /* * 查询审核日志 */
  275. $log = TalentLogApi::getLastLogByStep($id, ProjectState::JBT, $process);
  276. if (!$log) {
  277. return new Response(Response::ERROR, "请先审核后再提交");
  278. }
  279. $updCheck["checkMsg"] = $log["description"];
  280. /* * 判断到达的最高流程 */
  281. $updCheck["highProcess"] = !$old["highProcess"] || $old["highProcess"] < $process ? $process : $old["highProcess"];
  282. switch ($process) {
  283. case 1:
  284. switch ($log["state"]) {
  285. case 3:
  286. $updCheck["firstPassTime"] = $old["firstPassTime"];
  287. if (!$old["firstPassTime"]) {
  288. $updCheck["firstPassTime"] = date("Y-m-d H:i:s");
  289. }
  290. if (!$old["visitPassTime"]) {
  291. $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
  292. }
  293. $updCheck["submitTime"] = date("Y-m-d H:i:s");
  294. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  295. break;
  296. case 2:
  297. $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT;
  298. break;
  299. case -2:
  300. $updCheck["checkState"] = AllowanceStateEnum::FIRST_REJECT_BRANCH;
  301. break;
  302. case -1:
  303. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  304. $updCheck["recommendAllowanceType"] = 3;
  305. $updCheck["recommendMoney"] = 0;
  306. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  307. break;
  308. default:
  309. return new Response(Response::ERROR, "未知的审核状态");
  310. }
  311. //添加日志
  312. TalentChecklog::create([
  313. 'id' => getStringId(),
  314. 'mainId' => $id,
  315. 'type' => intval(ProjectState::JBT),
  316. 'typeFileId' => null,
  317. 'active' => 1,
  318. 'state' => $log["state"],
  319. 'step' => $process,
  320. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  321. 'description' => $log["description"],
  322. 'createTime' => date("Y-m-d H:i:s", time()),
  323. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  324. ]);
  325. break;
  326. case 2:
  327. if ($old["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $old["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  328. return new Response(Response::ERROR, "不在审核范围内");
  329. }
  330. $updCheck["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  331. $updCheck["visitPassTime"] = date("Y-m-d H:i:s");
  332. //添加日志
  333. TalentChecklog::create([
  334. 'id' => getStringId(),
  335. 'mainId' => $id,
  336. 'type' => intval(ProjectState::JBT),
  337. 'typeFileId' => null,
  338. 'active' => 1,
  339. 'state' => 3,
  340. 'step' => $process,
  341. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  342. 'description' => "走访核查提交审核",
  343. 'createTime' => date("Y-m-d H:i:s", time()),
  344. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  345. ]);
  346. break;
  347. case 3:
  348. switch ($log["state"]) {
  349. case 3:
  350. $updCheck["checkState"] = AllowanceStateEnum::REVIEW_PASS;
  351. $updCheck["reviewPassTime"] = date("Y-m-d H:i:s");
  352. $old = TalentAllowanceApi::getInfoById($id);//20240915增加判定是否人工认定,如果人工认定不再走系统计算
  353. if(strpos($old['recommendAllowanceMsg'],"人工判定") === false){
  354. /* * * 在此处需要判断津补贴类型 */
  355. $arrangeList = $this->validateAllowanceType($updCheck);
  356. $taaModel = new TalentAllowanceArrange();
  357. $taaModel->saveAll($arrangeList);
  358. }
  359. break;
  360. case 2:
  361. $updCheck["checkState"] = AllowanceStateEnum::REJECT_TO_FIRST;
  362. $updCheck["toProcess"] = null;
  363. $updCheck["toDep"] = "";
  364. break;
  365. case -1:
  366. $updCheck["checkState"] = AllowanceStateEnum::NOTPASS;
  367. $updCheck["recommendAllowanceType"] = 3;
  368. $updCheck["recommendMoney"] = 0;
  369. $updCheck["recommendAllowanceMsg"] = "审核不通过,不予兑现";
  370. break;
  371. default:
  372. return new Response(Response::ERROR, "未知的审核状态");
  373. }
  374. //添加日志
  375. TalentChecklog::create([
  376. 'id' => getStringId(),
  377. 'mainId' => $id,
  378. 'type' => intval(ProjectState::JBT),
  379. 'typeFileId' => null,
  380. 'active' => 1,
  381. 'state' => $log["state"],
  382. 'step' => $process,
  383. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($updCheck["checkState"]),
  384. 'description' => $log["description"],
  385. 'createTime' => date("Y-m-d H:i:s", time()),
  386. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  387. ]);
  388. break;
  389. }
  390. TalentChecklog::where("id", $log["id"])->delete();
  391. TaModel::update($updCheck);
  392. return new Response(Response::SUCCESS, "提交审核成功");
  393. }
  394. /**
  395. * 初审撤销
  396. * @return Response
  397. */
  398. public function cancleFirstCheck() {
  399. $obj = $this->request->param();
  400. $id = $obj["id"];
  401. $checkMsg = $obj["checkMsg"];
  402. if (!$id) {
  403. return new Response(Response::ERROR, "请选择需要撤销的对象");
  404. }
  405. $old = TalentAllowanceApi::getInfoById($id);
  406. if ($old["checkState"] != AllowanceStateEnum::NEED_REVIEW && $old["checkState"] != AllowanceStateEnum::NOTPASS) {
  407. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  408. }
  409. $data["id"] = $id;
  410. $data["checkMsg"] = $checkMsg;
  411. $data["checkState"] = AllowanceStateEnum::NEED_CHECK;
  412. //添加日志
  413. TalentChecklog::create([
  414. 'id' => getStringId(),
  415. 'mainId' => $id,
  416. 'type' => intval(ProjectState::JBT),
  417. 'typeFileId' => null,
  418. 'active' => 1,
  419. 'state' => 11, //撤销审核
  420. 'step' => 1,
  421. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  422. 'description' => "撤销原因:" . $checkMsg,
  423. 'createTime' => date("Y-m-d H:i:s", time()),
  424. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  425. ]);
  426. TaModel::update($data);
  427. return new Response(Response::SUCCESS, "撤销成功");
  428. }
  429. /**
  430. * 复核撤销
  431. * @return Response|\app\admin\controller\ResponseObj
  432. */
  433. public function reviewCancleCheck() {
  434. $obj = $this->request->param();
  435. $id = $obj["id"];
  436. $checkMsg = $obj["checkMsg"];
  437. if (!$id) {
  438. return new Response(Response::ERROR, "请选择需要撤销的对象");
  439. }
  440. $old = TalentAllowanceApi::getInfoById($id);
  441. if ($old["checkState"] != AllowanceStateEnum::REVIEW_PASS || $old["publicState"] != 1) {
  442. return new Response(Response::ERROR, "当前对象的审核无法撤销");
  443. }
  444. $data["id"] = $id;
  445. $data["checkMsg"] = $checkMsg;
  446. $data["checkState"] = AllowanceStateEnum::NEED_REVIEW;
  447. //添加日志
  448. TalentChecklog::create([
  449. 'id' => getStringId(),
  450. 'mainId' => $id,
  451. 'type' => intval(ProjectState::JBT),
  452. 'typeFileId' => null,
  453. 'active' => 1,
  454. 'state' => 11, //撤销审核
  455. 'step' => 3,
  456. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "->" . AllowanceStateEnum::getStateName($data["checkState"]),
  457. 'description' => "撤销原因:" . $checkMsg,
  458. 'createTime' => date("Y-m-d H:i:s", time()),
  459. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  460. ]);
  461. TaModel::update($data);
  462. return new Response(Response::SUCCESS, "撤销成功");
  463. }
  464. /**
  465. * 查询需要导出的数据
  466. *
  467. */
  468. public function findTalentAllowanceByPage() {
  469. $param = $this->request->param();
  470. $where = [];
  471. $where[] = ["type", "=", $this->user["type"]];
  472. if ($param != null) {
  473. if (\StrUtil::isNotEmpAndNull($param["name"])) {
  474. $where[] = ["name", "like", "%" . $param["name"] . "%"];
  475. }
  476. if (\StrUtil::isNotEmpAndNull($param["idCard"])) {
  477. $where[] = ["idCard", "like", "%" . $param["idCard"] . "%"];
  478. }
  479. }
  480. $error = null;
  481. switch ($param["type"]) {
  482. case 1:
  483. case 2:
  484. $where[] = ["publicState", "=", 1];
  485. $where[] = ["checkState", "in", [-1, 30]];
  486. $where[] = ['recommendAllowanceType',"in", [1, 2]];
  487. $error = "暂无可核查征信的数据";
  488. break;
  489. case 3:
  490. case 7:
  491. $where[] = ["publicState", "=", 2];
  492. $where[] = ["checkState", "in", [-1, 30]];
  493. $where[] = ["recommendAllowanceType", "=", 3];
  494. $error = "暂无可公示(不予兑现)的数据";
  495. break;
  496. case 4: //需要兑现
  497. case 8:
  498. $where[] = ["publicState", "=", 2];
  499. $where[] = ["checkState", "in", [30]];
  500. $where[] = ["recommendAllowanceType", "in", [1, 2]];
  501. $error = "暂无需要公示(兑现)的数据";
  502. break;
  503. case 5:
  504. $where[] = ["publicState", "=", 3];
  505. $where[] = ["checkState", "in", [-1, 30]];
  506. $error = "暂无可公示通过的数据";
  507. break;
  508. case 6:
  509. $where[] = ["publicState", "=", 4];
  510. $where[] = ["checkState", "in", [30]];
  511. $where[] = ["allowanceType", "in", [1, 2]];
  512. $error = "暂无可兑现的数据";
  513. break;
  514. }
  515. $list = TaModel::where($where)->select()->toArray();
  516. //查询企业信息
  517. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  518. foreach ($list as $key => $item) {
  519. $list[$key]["enterpriseName"] = $enterpriseMap[$item["enterpriseId"]];
  520. }
  521. $res = [
  522. "rows" => $list,
  523. "total" => count($list)
  524. ];
  525. return new Response(Response::SUCCESS, "", $res);
  526. }
  527. public function exportHczx() {
  528. $response = new \stdClass();
  529. $response->code = 500;
  530. $ids = $this->request->param("ids");
  531. $ids_arr = array_filter(explode(",", $ids));
  532. if (!$ids_arr) {
  533. $response->msg = "没有选择导出的名单";
  534. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  535. }
  536. $where = [];
  537. $where[] = ["id", "in", $ids_arr];
  538. $list = TaModel::field("id,cardType,idCard,name,enterpriseId,year")->where($where)->select()->toArray();
  539. if (!$list) {
  540. $response->msg = "暂无可核查征信的数据";
  541. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  542. }
  543. $columns = ["序号", "姓名", "证件类型", "证件号码", "工作单位", "年度"];
  544. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  545. $cardTypeName = DictApi::selectByParentCode("card_type");
  546. $rows = [];
  547. for ($i = 0; $i < count($list); $i++) {
  548. $item = $list[$i];
  549. $row = [
  550. $i + 1, $item["name"], $cardTypeName[$item["cardType"]], $item["idCard"], $enterpriseMap[$item["enterpriseId"]], $item["year"]
  551. ];
  552. $rows[] = $row;
  553. }
  554. $filename = "津补贴待核查征信名单导出";
  555. if ($rows) {
  556. export($columns, $rows, $filename);
  557. exit();
  558. } else {
  559. $response->msg = "没有选择导出的名单";
  560. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  561. }
  562. }
  563. /**
  564. * 核查征信驳回
  565. */
  566. public function hczxReject() {
  567. $param = $this->request->param();
  568. if (!$param) {
  569. return new Response(Response::ERROR, "系统错误,请联系管理员");
  570. }
  571. $old = TalentAllowanceApi::getInfoById($param["id"]);
  572. if ($old["publicState"] != 1) {
  573. return new Response(Response::ERROR, "当前记录不是待核查征信状态,无法核查");
  574. }
  575. $data["id"] = $param["id"];
  576. $data["publicState"] = 2;
  577. $data["checkState"] = AllowanceStateEnum::NOTPASS;
  578. $data["recommendAllowanceType"] = 3;
  579. $data["recommendAllowanceMsg"] = "征信失信,不予兑现,失信原因:" . $param["outMsg"];
  580. $data["recommendMonths"] = "";
  581. $data["recommendMoney"] = 0.00;
  582. $data["workAllowanceMoney"] = null;
  583. $data["developAllowanceMoney"] = null;
  584. //添加日志
  585. TalentChecklog::create([
  586. 'id' => getStringId(),
  587. 'mainId' => $param["id"],
  588. 'type' => intval(ProjectState::JBT),
  589. 'typeFileId' => null,
  590. 'active' => 1,
  591. 'state' => 2,
  592. 'step' => 4,
  593. 'stateChange' => AllowanceStateEnum::getStateName($old["checkState"]) . "-><span class='label label-primary'>审核不通过</span>" . "公示状态:<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  594. 'description' => $param["outMsg"],
  595. 'createTime' => date("Y-m-d H:i:s", time()),
  596. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  597. ]);
  598. TaModel::update($data);
  599. return new Response(Response::SUCCESS, "核查征信成功");
  600. }
  601. /**
  602. * 核查征信批量通过
  603. */
  604. public function hczxPass() {
  605. $ids = $this->request["ids"];
  606. if (\StrUtil::isEmpOrNull($ids)) {
  607. return new Response(Response::ERROR, "请选择核查征信通过的数据");
  608. }
  609. $where = [];
  610. $where[] = ["id", "in", $ids];
  611. $list = TaModel::where($where)->select()->toArray();
  612. $logList = [];
  613. $upds = [];
  614. foreach ($list as $obj) {
  615. $upds[] = [
  616. "id" => $obj["id"],
  617. "publicState" => 2,
  618. ];
  619. $logList[] = [
  620. "id" => getStringId(),
  621. "type" => ProjectState::JBT,
  622. "mainId" => $obj["id"],
  623. "active" => 1,
  624. "state" => 3,
  625. "step" => 4,
  626. "stateChange" => "<span class='label label-success'>待核查</span>-><span class='label label-primary'>待公示</span>",
  627. "description" => "核查征信通过",
  628. "createTime" => date("Y-m-d H:i:s"),
  629. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  630. ];
  631. }
  632. $taModel = new TaModel();
  633. $taModel->saveAll($upds);
  634. Db::table("new_talent_checklog")->insertAll($logList);
  635. return new Response(Response::SUCCESS, "核查征信通过成功");
  636. }
  637. /**
  638. * 公示
  639. * */
  640. public function publicBatch() {
  641. $params = $this->request->param();
  642. $ids = $params["ids"];
  643. $ids = array_filter(explode(",", $ids));
  644. if (!$ids) {
  645. return new Response(Response::ERROR, "请至少选择一行数据");
  646. }
  647. $isMessage = $params["isMessage"] == 1 ? true : false;
  648. if ($isMessage && (!$params["typeName"] || !$params["address"] || !$params["publicStartTime"] || !$params["publicEndTime"] || !$params["dep"] || !$params["phone"] || !$params["email"])) {
  649. return new Response(Response::ERROR, "短信参数不能为空");
  650. }
  651. $where = [];
  652. $where[] = ["id", "in", $ids];
  653. $list = TaModel::where($where)->select()->toArray();
  654. Db::startTrans();
  655. try {
  656. $logList = [];
  657. $phones = [];
  658. foreach ($list as $info) {
  659. $data["id"] = $info["id"];
  660. $data["publicState"] = 3;
  661. Db::table("un_talent_allowance_info")->update($data);
  662. /* * 添加日志 */
  663. $logList[] = [
  664. "id" => getStringId(),
  665. "type" => ProjectState::JBT,
  666. "mainId" => $info["id"],
  667. "active" => 1,
  668. "state" => 3,
  669. "step" => 5,
  670. "stateChange" => "<span class='label label-success'>待公示</span>-><span class='label label-primary'>公示中</span>",
  671. "description" => "批量公示",
  672. "createTime" => date("Y-m-d H:i:s"),
  673. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  674. ];
  675. $phones[] = $info["phone"];
  676. }
  677. $effect = Db::table("new_talent_checklog")->insertAll($logList);
  678. Db::commit();
  679. if ($phones && $isMessage && $effect) {
  680. $tpl_content = sprintf("【晋江市人才服务平台】您好!您提交申请的%s已完成初步审核,现通过%s将审核结果予以公示,公示时间%s至%s。公示期间如有异议,请及时向%s反映。电话%s,电子邮箱%s。",
  681. $params["typeName"], $params["address"], $params["publicStartTime"], $params["publicEndTime"], $params["dep"], $params["phone"], $params["email"]);
  682. $phones = array_filter($phones);
  683. foreach ($phones as $phone) {
  684. queue("app\job\Messenger", ["type" => 6, "userId" => 0, "phone" => $phone, "template" => $tpl_content, "processName" => "津补贴-批量公示", "userType" => 3]);
  685. }
  686. }
  687. return new Response(Response::SUCCESS, "公示成功");
  688. } catch (\think\db\exception\DbException $e) {
  689. Db::rollback();
  690. return new Response(Response::SUCCESS, "公示失败:" . $e->getMessage());
  691. }
  692. }
  693. /**
  694. * 跳转到公示再审核页面
  695. * */
  696. public function toSupplePage() {
  697. $id = $this->request["id"];
  698. $process = $this->request["process"];
  699. $obj = TalentAllowanceApi::getInfoById($id);
  700. $this->translateToChinese($obj);
  701. if ($this->user["type"] == CommonConst::ENTERPRISE_GJ) {
  702. $need_choose_post_type = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_post_type");
  703. $need_choose_institution = getJsonConfig("../sys_config.json", "talent_allowance_need_choose_institution");
  704. if ($need_choose_post_type[$obj["enterpriseId"]]) {
  705. $postTypes = DictApi::findChildDictByCode("PostType");
  706. foreach ($postTypes as $key => $pt) {
  707. if (!in_array($pt["code"], $need_choose_post_type[$obj["enterpriseId"]])) {
  708. unset($postTypes[$key]);
  709. }
  710. }
  711. }
  712. if (in_array($obj["enterpriseId"], $need_choose_institution)) {
  713. $institutions = DictApi::findChildDictByCode("Institution");
  714. }
  715. }
  716. return view("public_check", ["row" => $obj, "process" => $process, "postTypes" => $postTypes, "institutions" => $institutions]);
  717. }
  718. /**
  719. * 公示再审核计算津补贴
  720. * */
  721. public function suppleCheckCalculate() {
  722. $id = $this->request["id"];
  723. try {
  724. $info = TalentAllowanceApi::getInfoById($id);
  725. $arrangeList = $this->validateAllowanceType($info);
  726. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  727. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  728. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  729. foreach ($detailList as &$detail) {
  730. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  731. if (\StrUtil::isNotEmpAndNull($detail["talentType"])) {
  732. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  733. }
  734. }
  735. $res = [
  736. "info" => $info,
  737. "detailList" => $detailList
  738. ];
  739. return new Response(Response::SUCCESS, "计算成功", $res);
  740. } catch (\think\Exception $e) {
  741. return new Response(Response::ERROR, "系统异常,请联系管理员:" . $e->getMessage());
  742. }
  743. }
  744. /**
  745. * 公示后审核
  746. */
  747. public function afterCheck() {
  748. $param = $this->request->param();
  749. if (!$param["id"]) {
  750. return new Response(Response::ERROR, "系统错误,请联系管理员");
  751. }
  752. $old = TalentAllowanceApi::getInfoById($param["id"]);
  753. if ($old["publicState"] != 3) {
  754. return new Response(Response::ERROR, "当前记录不是公示中状态,无法审核");
  755. }
  756. try {
  757. $arrangeList = null;
  758. $desc = "审核意见:" . $param["checkMsg"] . ";\n";
  759. $desc .= "征信:" . ($param["zxState"] == 1 ? "征信通过" : $param["zxMsg"] . ";\n");
  760. $data["id"] = $param["id"];
  761. if ($param["checkState"] == -1) {
  762. $data["checkState"] = -1;
  763. $data["checkMsg"] = $param["checkMsg"];
  764. $data["allowanceType"] = 3;
  765. $data["allowanceMsg"] = "审核不通过,原因:" . $param["checkMsg"];
  766. $data["outMsg"] = $param["zxState"] == 1 ? "" : $param["zxMsg"];
  767. } else if ($param["checkState"] == 3) {
  768. if ($param["zxState"] == 1) {
  769. $typeName = "";
  770. $old["recommendAllowanceMsg"] = "";
  771. if ($param["source"] == 1) { //遵循系统结果
  772. $arrangeList = $this->validateAllowanceType($old);
  773. $typeName = "系统判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["allowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  774. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $old["recommendAllowanceMsg"] . ";";
  775. } else if ($param["source"] == 2) {
  776. $detailIds = array_column($param["details"], "id");
  777. $where = [];
  778. $where[] = ["id", "in", $detailIds];
  779. $detailList = \app\common\model\TalentAllowancecontractDetail::where($where)->select()->toArray();
  780. $set = [];
  781. if ($param["resAllowanceType"] == 1) {
  782. $monthsMap = [];
  783. for ($i = 0; $i < count($param["details"]); $i++) {
  784. $monthsMap[$param["details"][$i]["id"]] = $param["details"][$i]["months"];
  785. }
  786. foreach ($detailList as &$detail) {
  787. $months = $monthsMap[$detail["id"]];
  788. if (\StrUtil::isNotEmpAndNull($months)) {
  789. $detail["months"] = $months;
  790. $set = array_merge($set, explode(",", $months));
  791. }
  792. }unset($detail);
  793. }
  794. $set = array_filter($set);
  795. usort($set, function ($a, $b) {
  796. return (int) $a - (int) $b;
  797. });
  798. $old["recommendAllowanceType"] = $param["resAllowanceType"];
  799. $old["recommendMonths"] = implode(",", $set);
  800. $typeName = "人工判定:津补贴类型(" . (\app\common\state\AllowanceTypeEnum::getTypeName($old["recommendAllowanceType"])) . ");享受月份:" . $old["recommendMonths"] . ";\n";
  801. $old["recommendAllowanceMsg"] = $typeName . "判定说明:\n" . $param["resAllowanceMsg"] . ";";
  802. $arrangeList = $this->calculateAllowance($old, $set, $detailList);
  803. }
  804. $desc .= "判定结果:" . $typeName;
  805. $data["checkState"] = 30;
  806. $data["outMsg"] = "";
  807. $data["allowanceType"] = $old["recommendAllowanceType"];
  808. $data["allowanceMsg"] = $old["recommendAllowanceMsg"];
  809. $data["months"] = $old["recommendMonths"];
  810. $data["money"] = $old["recommendMoney"] - $old["otherEnjoyedMoney"];
  811. $data["moneyDesc"] = $old["recommendMoneyDesc"];
  812. $data["jtTalentArrange"] = $old["recommendTalentArrange"];
  813. $data["workAllowanceMoney"] = $old["workAllowanceMoney"];
  814. $data["developAllowanceMoney"] = $old["developAllowanceMoney"];
  815. } else {
  816. $data["checkState"] = -1;
  817. $data["outMsg"] = $param["zxMsg"];
  818. $data["allowanceType"] = 3;
  819. $data["allowanceMsg"] = "征信失信(不予兑现),原因:" . $param["zxMsg"];
  820. }
  821. }
  822. if ($param["allowanceType"] == 3) {
  823. $data["months"] = "";
  824. $data["money"] = 0;
  825. $data["moneyDesc"] = "";
  826. $data["jtTalentArrange"] = "";
  827. $data["workAllowanceMoney"] = null;
  828. $data["developAllowanceMoney"] = null;
  829. }
  830. $data["isPublicCheck"] = 1;
  831. $data["publicState"] = 4;
  832. //添加日志
  833. TalentChecklog::create([
  834. 'id' => getStringId(),
  835. 'mainId' => $old['id'],
  836. 'type' => intval(ProjectState::JBT),
  837. 'typeFileId' => null,
  838. 'active' => 1,
  839. 'state' => $param["checkState"] == AllowanceStateEnum::REVIEW_PASS ? 3 : $param["checkState"],
  840. 'step' => 6,
  841. 'stateChange' => "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>",
  842. 'description' => $desc,
  843. 'createTime' => date("Y-m-d H:i:s", time()),
  844. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  845. ]);
  846. TaModel::update($data);
  847. if ($arrangeList != null) {
  848. $taaModel = new TalentAllowanceArrange();
  849. $taaModel->saveAll($arrangeList);
  850. }
  851. return new Response(Response::SUCCESS, "审核成功");
  852. } catch (\think\Exception $e) {
  853. return new Response(Response::ERROR, "系统异常,请联系管理员");
  854. }
  855. }
  856. /**
  857. * 批量公示通过
  858. */
  859. public function publicPass() {
  860. $ids = $this->request["ids"];
  861. $ids = explode(",", $ids);
  862. if (!$ids) {
  863. return new Response(Response::ERROR, "请至少选择一行数据");
  864. }
  865. $where = [];
  866. $where[] = ["id", "in", $ids];
  867. $list = TaModel::where($where)->select()->toArray();
  868. $logList = [];
  869. try {
  870. Db::startTrans();
  871. for ($i = 0; $i < count($list); $i++) {
  872. $obj = $list[$i];
  873. $upd["id"] = $obj["id"];
  874. $upd["publicState"] = 4;
  875. $upd["allowanceType"] = $obj["recommendAllowanceType"];
  876. $upd["allowanceMsg"] = $obj["recommendAllowanceMsg"];
  877. if ($upd["allowanceType"] == 1) {
  878. $upd["months"] = $obj["recommendMonths"];
  879. $upd["money"] = $obj["recommendMoney"] - $obj["otherEnjoyedMoney"];
  880. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  881. } else if ($upd["allowanceType"] == 2) {
  882. $upd["months"] = "";
  883. $upd["jtTalentArrange"] = $obj["recommendTalentArrange"];
  884. $upd["money"] = $obj["recommendMoney"] - $obj["otherEnjoyedMoney"];
  885. $upd["moneyDesc"] = $obj["recommendMoneyDesc"];
  886. $upd["workAllowanceMoney"] = null;
  887. $upd["developAllowanceMoney"] = null;
  888. } else {
  889. $upd["months"] = "";
  890. $upd["money"] = 0.00;
  891. $upd["workAllowanceMoney"] = null;
  892. $upd["developAllowanceMoney"] = null;
  893. }
  894. Db::table("un_talent_allowance_info")->update($upd);
  895. //添加日志
  896. $stateChange = null;
  897. $desc = null;
  898. if ($obj["checkState"] == AllowanceStateEnum::NOTPASS) {
  899. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-danger'>审核不通过</span>";
  900. $desc = "审核不通过";
  901. } else {
  902. $stateChange = "<span class='label label-success'>公示中</span>-><span class='label label-primary'>待兑现</span>";
  903. $desc = "批量公示";
  904. }
  905. $logList[] = [
  906. "id" => getStringId(),
  907. "type" => ProjectState::JBT,
  908. "mainId" => $obj["id"],
  909. "active" => 1,
  910. "state" => 3,
  911. "step" => 6,
  912. "stateChange" => $stateChange,
  913. "description" => $desc,
  914. "createTime" => date("Y-m-d H:i:s"),
  915. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  916. ];
  917. }
  918. Db::table("new_talent_checklog")->insertAll($logList);
  919. Db::commit();
  920. return new Response(Response::SUCCESS, "批量公示通过成功");
  921. } catch (\think\db\exception\DbException $e) {
  922. Db::rollback();
  923. return new Response(Response::ERROR, "批量公示失败:" . $e->getCode());
  924. }
  925. }
  926. /**
  927. * 兑现
  928. */
  929. public function cash() {
  930. $ids = $this->request["ids"];
  931. $ids = array_filter(explode(",", $ids));
  932. if (!$ids) {
  933. return new Response(Response::ERROR, "请至少选择一行数据");
  934. }
  935. $where = [];
  936. $where[] = ["id", "in", $ids];
  937. $list = TaModel::where($where)->select()->toArray();
  938. //添加日志
  939. $logList = [];
  940. try {
  941. Db::startTrans();
  942. for ($i = 0; $i < count($list); $i++) {
  943. $obj = $list[$i];
  944. $upd["id"] = $obj["id"];
  945. $upd["publicState"] = 5;
  946. Db::table("un_talent_allowance_info")->update($upd);
  947. $logList[] = [
  948. "id" => getStringId(),
  949. "type" => ProjectState::JBT,
  950. "mainId" => $obj["id"],
  951. "active" => 1,
  952. "state" => 3,
  953. "step" => 50,
  954. "stateChange" => "<span class='label label-success'>待兑现</span>-><span class='label label-primary'>已兑现</span>;",
  955. "description" => "批量兑现",
  956. "createTime" => date("Y-m-d H:i:s"),
  957. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  958. ];
  959. }
  960. Db::table("new_talent_checklog")->insertAll($logList);
  961. Db::commit();
  962. return new Response(Response::SUCCESS, "批量兑现成功");
  963. } catch (\think\db\exception\DbException $e) {
  964. Db::rollback();
  965. return new Response(Response::ERROR, "批量兑现失败:" . $e->getCode());
  966. }
  967. }
  968. /**
  969. * 公示预览(不予兑现)
  970. */
  971. public function exportPublicNotCash() {
  972. $response = new \stdClass();
  973. $response->code = 500;
  974. //获取字典表人才层次+
  975. $levelMap = DictApi::selectByParentCode("talent_arrange");
  976. $streetMap = DictApi::selectByParentCode("street");
  977. //查询企业信息
  978. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  979. //查询所有
  980. $where = [];
  981. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  982. $list = TaModel::where($where)->select()->toArray();
  983. $rows = [];
  984. for ($i = 0; $i < count($list); $i++) {
  985. $item = $list[$i];
  986. $rows[] = [
  987. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  988. ];
  989. }
  990. $filename = CommonConst::getTypeName($this->user["type"]) . $allList[0]["year"] . "年度津补贴不予兑现对象名单";
  991. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  992. if ($rows) {
  993. export($columns, $rows, $filename);
  994. exit();
  995. } else {
  996. $response->msg = "没有选择导出的名单";
  997. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  998. }
  999. }
  1000. /**
  1001. * 导出公示名单(需要兑现)
  1002. */
  1003. public function exportPublic() {
  1004. //获取字典表人才层次+
  1005. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1006. $streetMap = DictApi::selectByParentCode("street");
  1007. //查询企业信息
  1008. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1009. /* * 查询需要公示的数据 */
  1010. $where = [];
  1011. $where[] = ["id", "in", explode(",", $this->request["ids"])];
  1012. $list = TaModel::where($where)->select()->toArray();
  1013. $rows = [];
  1014. for ($i = 0; $i < count($list); $i++) {
  1015. $item = $list[$i];
  1016. $rows[] = [
  1017. $i + 1, $item["name"], $enterpriseMap[$item["enterpriseId"]], $streetMap[$item["address"]], $levelMap[$item["talentArrange"]], $item["description"]
  1018. ];
  1019. }
  1020. $filename = CommonConst::getTypeName($this->user["type"]) . $allList[0]["year"] . "年度津补贴拟发放对象名单";
  1021. $columns = ["序号", "姓名", "工作单位", "镇(街道)", "人才层次", "备注"];
  1022. if ($rows) {
  1023. export($columns, $rows, $filename);
  1024. exit();
  1025. } else {
  1026. $response->msg = "没有选择导出的名单";
  1027. return \StrUtil::back($response, "TalentAllowanceInfo.hczxCallBack");
  1028. }
  1029. }
  1030. /**
  1031. * 导出基本信息
  1032. */
  1033. public function exportBasicInfo() {
  1034. $obj["year"] = \StrUtil::getRequestDecodeParam($this->request, "year");
  1035. $obj["enterpriseName"] = \StrUtil::getRequestDecodeParam($this->request, "enterpriseName");
  1036. $obj["name"] = \StrUtil::getRequestDecodeParam($this->request, "name");
  1037. $obj["idCard"] = \StrUtil::getRequestDecodeParam($this->request, "idCard");
  1038. $obj["talentType"] = \StrUtil::getRequestDecodeParam($this->request, "talentType");
  1039. $obj["talentArrange"] = \StrUtil::getRequestDecodeParam($this->request, "talentArrange");
  1040. $obj["address"] = \StrUtil::getRequestDecodeParam($this->request, "address");
  1041. $obj["identifyCondition"] = \StrUtil::getRequestDecodeParam($this->request, "identifyCondition");
  1042. $obj["isSupple"] = \StrUtil::getRequestDecodeParam($this->request, "isSupple");
  1043. $obj["checkState"] = \StrUtil::getRequestDecodeParam($this->request, "checkState");
  1044. $obj["publicState"] = \StrUtil::getRequestDecodeParam($this->request, "publicState");
  1045. $obj["companyName"] = \StrUtil::getRequestDecodeParam($this->request, "companyName");
  1046. $obj["allowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "allowanceType");
  1047. $obj["recommendAllowanceType"] = \StrUtil::getRequestDecodeParam($this->request, "recommendAllowanceType");
  1048. $obj["introductionMode"] = \StrUtil::getRequestDecodeParam($this->request, "introductionMode");
  1049. $obj["firstJJStartTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJStartTime");
  1050. $obj["firstJJEndTime"] = \StrUtil::getRequestDecodeParam($this->request, "firstJJEndTime");
  1051. $obj["process"] = intval(\StrUtil::getRequestDecodeParam($this->request, "process"));
  1052. $obj["type"] = $this->user["type"];
  1053. $where = [];
  1054. $where[] = ["ta.delete", "=", 0];
  1055. $where[] = ["ta.type", "=", $this->user["type"]];
  1056. $this->setTalentAllowanceInfoForExport($where, $obj, $obj["process"]);
  1057. switch ($obj["process"]) {
  1058. case 1:
  1059. $where[] = ["ta.checkState", "in", [1, 5, 10, 13, 15, 20, 25, 30]];
  1060. break;
  1061. case 2:
  1062. $where[] = ["ta.firstPassTime", "EXP", Db::raw("is not null")];
  1063. break;
  1064. case 3:
  1065. $where[] = ["ta.visitPassTime", "EXP", Db::raw("is not null")];
  1066. break;
  1067. case 4:
  1068. if ($obj["publicState"]) {
  1069. $where[] = ["publicState", "=", $param["publicState"]];
  1070. }
  1071. $where[] = ["ta.checkState", "in", [-1, 30]];
  1072. break;
  1073. }
  1074. $projects = [
  1075. AllowanceProjectEnum::PROJECT_TAX,
  1076. AllowanceProjectEnum::PROJECT_WAGES,
  1077. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1078. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1079. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1080. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1081. ];
  1082. $months = [];
  1083. for ($m = 1; $m <= 12; $m++) {
  1084. $months[] = $m . "月";
  1085. }
  1086. $columns = [["年度", [1, 2]], ["所属镇街", [1, 2]], ["姓名", [1, 2]], ["性别", [1, 2]], ["证件号码", [1, 2]], ["人才层次", [1, 2]], ["认定条件", [1, 2]], ["认定条件取得时间", [1, 2]], ["认定条件名称", [1, 2]], ["公布入选月份", [1, 2]], ["拟认定津补贴类型", [1, 2]], ["拟兑现月份", [1, 2]], ["拟兑现金额", [1, 2]], ["拟兑现金额说明", [1, 2]], ["其它补贴金额", [1, 2]], ["其它补贴说明", [1, 2]], ["津补贴类型", [1, 2]], ["兑现月份", [1, 2]], ["兑现金额", [1, 2]], ["金额说明", [1, 2]], ["审核状态", [1, 2]], ["审核意见", [1, 2]], ["缴纳单位", [1, 2]]];
  1087. $infoCols = count($columns);
  1088. for ($i = 0; $i < count($projects); $i++) {
  1089. $columns[] = [AllowanceProjectEnum::getProjectName($projects[$i]), $months];
  1090. }
  1091. $list = \app\common\model\TalentAllowanceProject::alias("pro")
  1092. ->field("ta.id,ta.year,ta.enterpriseId as curEnterpriseId,ta.address,ta.name,ta.sex,ta.idCard,ta.talentArrange,ta.identifyCondition,ta.identifyGetTime,ta.identifyConditionName,ta.identifyMonth,ta.recommendAllowanceType,ta.recommendMonths,ta.recommendMoney,ta.recommendMoneyDesc,ta.otherEnjoyedMoney,ta.otherEnjoyedDescription,ta.allowanceType,ta.months,ta.money,ta.moneyDesc,ta.checkState,ta.checkMsg,ta.publicState,pro.project,pro.months as pre_months,con.enterpriseId,con.startTime,con.endTime,con.entryTime,con.quitTime,con.isQuit")
  1093. ->leftJoin("un_talent_allowance_info ta", "ta.id=pro.mainId")
  1094. ->leftJoin("un_talent_allowancecontract_detail con", "pro.baseId=con.id")
  1095. ->where($where)
  1096. ->order("ta.year desc,ta.createTime desc,pro.project asc")
  1097. ->select()->toArray();
  1098. $tmpList = [];
  1099. $levelMap = DictApi::selectByParentCode("talent_arrange");
  1100. $streetMap = DictApi::selectByParentCode("street");
  1101. $where = [];
  1102. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  1103. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  1104. $where = [];
  1105. $where[] = ["id", "in", array_column($list, "enterpriseId")];
  1106. $enterpriseMap = \app\common\model\Enterprise::where($where)->column("name", "id");
  1107. foreach ($list as $item) {
  1108. //组装数据
  1109. if (!$tmpList[$item["id"]]) {
  1110. $tmpList[$item["id"]]["curEnterpriseId"] = $item["curEnterpriseId"];
  1111. $tmpList[$item["id"]]["info"] = [$item["year"], $streetMap[$item["address"]], $item["name"], $item["sex"] == 1 ? "男" : "女", $item["idCard"], $levelMap[$item["talentArrange"]],
  1112. $icmap[$item["identifyCondition"]], $item["identifyGetTime"], $item["identifyConditionName"], $item["identifyMonth"], AllowanceTypeEnum::getTypeName($item["recommendAllowanceType"]), $item["recommendMonths"], $item["recommendMoney"],
  1113. $item["recommendMoneyDesc"], $item["otherEnjoyedMoney"], $item["otherEnjoyedDescription"] ?: "", AllowanceTypeEnum::getTypeName($item["allowanceType"]), $item["months"], $item["money"],
  1114. $item["moneyDesc"], $this->getCheckStateName($item["checkState"], $item["publicState"], $item["allowanceType"]), $item["checkMsg"]];
  1115. }
  1116. if (!$tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]) {
  1117. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]] = [
  1118. "startTime" => $item["startTime"],
  1119. "endTime" => $item["endTime"],
  1120. "entryTime" => $item["entryTime"],
  1121. "isQuit" => $item["isQuit"]
  1122. ];
  1123. }
  1124. $tmpList[$item["id"]]["enterprise"][$item["enterpriseId"]]["projects"][$item["project"]] = $item["pre_months"];
  1125. }
  1126. $rows = [];
  1127. $colorset = [];
  1128. foreach ($tmpList as $id => $item) {
  1129. foreach ($item["enterprise"] as $enterpriseId => $enterprise) {
  1130. $row = $item["info"];
  1131. $row[] = $this->user["uid"] == $enterpriseId ? "本单位" : $enterpriseMap[$enterpriseId];
  1132. for ($i = 0; $i < count($projects); $i++) {
  1133. if (strpos($enterprise["projects"][$projects[$i]], "=") === false) {
  1134. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1135. for ($m = 1; $m <= 12; $m++) {
  1136. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1137. if (in_array($_month, $months)) {
  1138. $row[] = "✔";
  1139. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1140. } else {
  1141. $row[] = "";
  1142. }
  1143. }
  1144. } else {
  1145. $months = array_filter(explode(",", $enterprise["projects"][$projects[$i]]));
  1146. $_months = [];
  1147. foreach ($months as $month) {
  1148. $kv = explode("=", $month);
  1149. $_months[$kv[0]] = $kv[1];
  1150. }
  1151. for ($m = 1; $m <= 12; $m++) {
  1152. $_month = str_pad($m, 2, "0", STR_PAD_LEFT);
  1153. $days = $_months[$_month];
  1154. if ($days && $days > 0) {
  1155. $row[] = $days . "天";
  1156. $colorset[] = [sprintf("%s%d", getExcelColumnByIndex($infoCols + $i * 12 + $m - 1), count($rows) + 3), "29dd23"];
  1157. } else {
  1158. $row[] = "";
  1159. }
  1160. }
  1161. }
  1162. }
  1163. $rows[] = $row;
  1164. }
  1165. }
  1166. $cols = $infoCols + count($projects) * 12 - 1;
  1167. $settings = [
  1168. "width" => [["A", 8], ["C", 12], ["D", 6], ["E", 20], ["F", 12], ["G", 70], ["H", 12], ["I", 15], ["J", 12], ["K", 12], ["P", 30]],
  1169. "height" => [18],
  1170. "freeze" => "D3",
  1171. "color" => $colorset
  1172. ];
  1173. for ($i = 0; $i < count($projects) * 12; $i++) {
  1174. $settings["width"][] = [getExcelColumnByIndex($infoCols + $i), 6]; //批设置项目的宽度
  1175. }
  1176. $settings["background-color"][] = [sprintf("%s2:%s2", getExcelColumnByIndex($infoCols), getExcelColumnByIndex($cols)), "E1F1DE"];
  1177. export($columns, $rows, "津补贴申报名单", $settings);
  1178. }
  1179. private function validateAllowanceType(&$info) {
  1180. $old = TalentAllowanceApi::getInfoById($info["id"]);
  1181. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1182. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1183. /* * 查询工作单位记录 */
  1184. $initDetailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $info["id"])->select()->toArray();
  1185. $detaiPdList = []; //用于判定类型
  1186. $detailMonthList = []; //用于计算月份
  1187. $recommendAllowanceMsg = [];
  1188. foreach ($initDetailList as $detail) {
  1189. $projectList = \app\common\model\TalentAllowanceProject::where("baseId", $detail["id"])->select()->toArray();
  1190. $projectMap = [];
  1191. foreach ($projectList as $project) {
  1192. $projectMap[$project["project"]] = $project;
  1193. }
  1194. $detail["list"] = $projectList;
  1195. $detail["projectMap"] = $projectMap;
  1196. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  1197. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  1198. /* * 筛选符合条件的人才标签 */
  1199. $detaiPdList[] = $detail;
  1200. $detailMonthList[] = $detail;
  1201. }
  1202. /* * 集成电路优秀人才 */
  1203. //if ($this->user["type"] == 2) {
  1204. /* * 获取各个项目的综合月份 */
  1205. $monthMap = $this->mergeMonth($detailMonthList);
  1206. $monthAndDayMap = $this->mergeMonthNeedDay($detailMonthList);
  1207. $info["backWork"] = $old["backWork"];
  1208. $info["recommendAllowanceType"] = $old["allowanceType"];
  1209. $info["recommendAllowanceMsg"] = "";
  1210. $info["otherEnjoyedMoney"] = $old["otherEnjoyedMoney"];
  1211. $info["otherEnjoyedDescription"] = $old["otherEnjoyedDescription"];
  1212. $projectList = \app\common\model\TalentAllowanceProject::where("mainId", $info["id"])->select()->toArray();
  1213. $set = $this->valideAllowanceType($info, $projectList, $monthMap, $monthAndDayMap);
  1214. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n综合以上所有判断得到最终补贴类型为:";
  1215. if ($info["recommendAllowanceType"] == 1) {
  1216. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "工作津贴;可享受月份为:" . implode(",", $set) . "\n";
  1217. }
  1218. if ($info["recommendAllowanceType"] == 2)
  1219. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "一次性交通补贴;";
  1220. if ($info["recommendAllowanceType"] == 3)
  1221. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "不予兑现;";
  1222. usort($set, function ($a, $b) {
  1223. return (int) $a - (int) $b;
  1224. });
  1225. //}
  1226. $info["recommendMonths"] = implode(",", $set);
  1227. $arrangeList = $this->calculateAllowance($info, $set, $detailMonthList);
  1228. return $arrangeList;
  1229. }
  1230. /**
  1231. * 集成电路津补贴总校验
  1232. * */
  1233. private function valideAllowanceType(&$info, $projectList, $monthMap, $monthAndDayMap) {
  1234. $set = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
  1235. /* * 2.判定工作月份、五险和个税是否满足重叠6个月要求* */
  1236. $contractSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_CONTRACT], $info, "上年度合同月份", "①");
  1237. $workdaySet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_ATTENDANCE], $info, "上年度工作月份", "②");
  1238. $wageSet = self::chkMonths($monthMap[AllowanceProjectEnum::PROJECT_WAGES], $info, "上年度工资发放月份", "③");
  1239. $pensionSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_PENSION], $info, "养老保险", "④");
  1240. $unemploymentSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT], $info, "失业保险", "⑤");
  1241. $medicaSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_SB_MEDICA], $info, "医疗保险", "⑥");
  1242. $taxSet = $this->chkMonths($monthMap[AllowanceProjectEnum::PROJECT_TAX], $info, "个税", "⑦");
  1243. $str = "工作合同月份、考勤月份、工资发放月份";
  1244. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  1245. $str = "工作合同月份、考勤月份";
  1246. $set = array_intersect($set, $contractSet);
  1247. $set = array_intersect($set, $workdaySet);
  1248. $checkSet = $set;
  1249. //$set = array_intersect($set, $pensionSet);
  1250. //$set = array_intersect($set, $taxSet);
  1251. } else if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  1252. if ($info["backWork"] == 1) {
  1253. //$set = array_intersect($set, $workdaySet);
  1254. $set = array_intersect($set, $wageSet);
  1255. } else {
  1256. //$set = array_intersect($set, $workdaySet);
  1257. $set = array_intersect($set, $wageSet);
  1258. }
  1259. } else {
  1260. $set = array_intersect($set, $contractSet);
  1261. $set = array_intersect($set, $workdaySet);
  1262. $set = array_intersect($set, $wageSet);
  1263. $checkSet = $set;
  1264. $set = array_intersect($set, $pensionSet);
  1265. $set = array_intersect($set, $unemploymentSet);
  1266. $set = array_intersect($set, $medicaSet);
  1267. $set = array_intersect($set, $taxSet);
  1268. }
  1269. usort($set, function ($a, $b) {
  1270. return (int) $a - (int) $b;
  1271. });
  1272. if ($info["recommendAllowanceType"] == 1) {
  1273. if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  1274. //高教另外判断
  1275. $taxCount = 1;
  1276. foreach ($taxSet as $s) {
  1277. $currentVal = intval($s);
  1278. $nextVal = $currentVal + 1;
  1279. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  1280. if (in_array($nextKey, $taxSet)) {
  1281. $taxCount++;
  1282. if ($taxCount >= 2) {
  1283. break;
  1284. }
  1285. } else {
  1286. $taxCount = 1;
  1287. }
  1288. }
  1289. if ($info["backWork"] == 1) {
  1290. //需要判断缴税有没有连续两个月以上
  1291. if ($taxCount < 2) {
  1292. $info["recommendAllowanceType"] = 3;
  1293. $info["recommendAllowanceMsg"][] = "上年度个税缴纳月份不满足连续缴纳2个月(" . implode(",", $taxSet) . "),无法享受工作津贴(×)";
  1294. }
  1295. } else {
  1296. //需要判断缴税或者养老有没有连续两个月以上
  1297. $pensionCount = 1;
  1298. foreach ($pensionSet as $s) {
  1299. $currentVal = intval($s);
  1300. $nextVal = $currentVal + 1;
  1301. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  1302. if (in_array($nextKey, $pensionSet)) {
  1303. $pensionCount++;
  1304. if ($pensionCount >= 2) {
  1305. break;
  1306. }
  1307. } else {
  1308. $pensionCount = 1;
  1309. }
  1310. }
  1311. if ($taxCount < 2 && $pensionCount < 2) {
  1312. $info["recommendAllowanceType"] = 3;
  1313. $info["recommendAllowanceMsg"][] = "上年度个税缴纳月份(" . implode(",", $taxSet) . ")与养老保险缴纳月份(" . implode(",", $pensionSet) . ")均不满足连续缴纳2个月,无法享受工作津贴(×)";
  1314. }
  1315. }
  1316. } else {
  1317. if (count($checkSet) < 6) {
  1318. //如果全部满足6个月,但是重叠时间不满足6个月,开始检测是否符合交通补贴要求
  1319. $info["recommendAllowanceType"] = 3;
  1320. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n上年度{$str}交集月份不满足6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  1321. } else {
  1322. //检查连续缴纳月份是否满足6个月
  1323. $count = 1;
  1324. foreach ($checkSet as $s) {
  1325. $currentVal = intval($s);
  1326. $nextVal = $currentVal + 1;
  1327. $nextKey = str_pad($nextVal, 2, "0", STR_PAD_LEFT);
  1328. if (in_array($nextKey, $checkSet)) {
  1329. $count++;
  1330. if ($count >= 6) {
  1331. break;
  1332. }
  1333. } else {
  1334. $count = 1;
  1335. }
  1336. }
  1337. if ($count < 6) {
  1338. $info["recommendAllowanceType"] = 3;
  1339. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n上年度{$str}不满足连续缴纳6个月(" . implode(",", $checkSet) . "),无法享受工作津贴(×)";
  1340. }
  1341. }
  1342. }
  1343. }
  1344. if ($info["recommendAllowanceType"] == 2) {
  1345. //判断境内工作时间是否大于30天
  1346. if ($info["allowanceType"] == 2) {
  1347. $totalDays = 0;
  1348. $workmonths = $monthAndDayMap[AllowanceProjectEnum::PROJECT_ATTENDANCE];
  1349. foreach ($workmonths as $days) {
  1350. $totalDays += $days;
  1351. }
  1352. if ($totalDays < 30) {
  1353. $info["recommendAllowanceType"] = 3;
  1354. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作仅{$totalDays}天,未达到30天,无法享受一次性交通津贴(×)";
  1355. }
  1356. } else {
  1357. if (count($workdaySet) == 0) {
  1358. $info["recommendAllowanceType"] = 3;
  1359. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n全年在我市工作未达到30天,无法享受一次性交通津贴(×)";
  1360. } else {
  1361. $info["recommendAllowanceType"] = 2;
  1362. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n*首选为工作津贴,未录入实际工作天数,需要进一步核实提交的相关附件是否满足全年在我市工作30天";
  1363. }
  1364. }
  1365. }
  1366. return $set;
  1367. }
  1368. /**
  1369. * 计算津补贴
  1370. */
  1371. private function calculateAllowance(&$info, $retainMonths, $detailMonthList) {
  1372. /* * 查询人才层次变更记录 */
  1373. $arrangeList = TalentAllowanceArrange::where("mainId", $info["id"])->order("talentArrange")->select()->toArray();
  1374. foreach ($arrangeList as &$arrange) {
  1375. $where = [];
  1376. $where[] = ["type", "=", $this->user["type"]];
  1377. $where[] = ["allowanceType", "in", [1, 2]];
  1378. $where[] = ["talentArrange", "=", $arrange["talentArrange"]];
  1379. $list = AsModel::where($where)->field("money,allowanceType")->select()->toArray();
  1380. foreach ($list as $amount) {
  1381. if ($amount["allowanceType"] == 1) {
  1382. $arrange["jobMoney"] = $amount["money"];
  1383. }
  1384. if ($amount["allowanceType"] == 2) {
  1385. $arrange["jtMoney"] = $amount["money"];
  1386. }
  1387. }
  1388. }unset($arrange);
  1389. /* * * 容器 */
  1390. $jobMoney = 0.00; //计算所得工作津贴
  1391. $jtMoney = 0.00; //计算所得一次性交通补贴
  1392. $recommendMonths = []; //推荐月份
  1393. $talentArrange = null;
  1394. /* * *********计算************* */
  1395. $msgBulider = [];
  1396. $identifyExpiredName = "人才证书有效期";
  1397. if ($info["type"] == CommonConst::ENTERPRISE_JC) {
  1398. $identifyExpiredName = "认定条件有效期";
  1399. }
  1400. switch ($info["recommendAllowanceType"]) {
  1401. case 1:
  1402. foreach ($arrangeList as &$arrange) {
  1403. if (\StrUtil::isNotEmpAndNull($arrange["prepareMonths"])) {
  1404. $levelList = array_filter(explode(",", $arrange["prepareMonths"]));
  1405. $levelList = array_intersect($levelList, $retainMonths);
  1406. $total = round($arrange["jobMoney"] * count($levelList), 2);
  1407. $jobMoney += $total;
  1408. $msgBulider[] = sprintf("%d(%s)x%s(第%d层次)", count($levelList), $levelList ? implode(",", $levelList) : "", $arrange["jobMoney"], $arrange["talentArrange"]);
  1409. $recommendMonths = array_merge($recommendMonths, $levelList);
  1410. usort($recommendMonths, function ($a, $b) {
  1411. return (int) $a - (int) $b;
  1412. });
  1413. $arrange["months"] = implode(",", $levelList);
  1414. $arrange["count"] = count($levelList);
  1415. $arrange["total"] = $total;
  1416. } else {
  1417. $msgBulider[] = sprintf("0()x%s(第%d层次)", $arrange["jobMoney"], $arrange["talentArrange"]);
  1418. $arrange["count"] = 0;
  1419. $arrange["total"] = 0.00;
  1420. }
  1421. }unset($arrange);
  1422. $info["recommendMonths"] = implode(",", $recommendMonths);
  1423. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "通过与{$identifyExpiredName}取交集得到最终可享受月份:" . implode(",", $recommendMonths) . "\n经过计算:人才津贴为" . $jobMoney . ";";
  1424. if ($info["otherEnjoyedMoney"] != 0) {
  1425. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n" . "扣除其它补贴金额" . $info["otherEnjoyedMoney"] . "元,最终可享受人才津贴为" . number_format($jobMoney - $info["otherEnjoyedMoney"], 2) . "元";
  1426. }
  1427. $info["recommendMoney"] = $jobMoney;
  1428. $info["recommendMoneyDesc"] = implode("+", $msgBulider) . ($info["otherEnjoyedMoney"] != 0 ? sprintf("-%s(其它补贴金额)", number_format($info["otherEnjoyedMoney"], 2)) : "");
  1429. break;
  1430. case 2:
  1431. foreach ($arrangeList as $arrange) {
  1432. $jtMoney = $arrange["jtMoney"];
  1433. $talentArrange = $arrange["talentArrange"];
  1434. }
  1435. $info["recommendMoney"] = $jtMoney;
  1436. $info["recommendMonths"] = "";
  1437. $info["recommendMoneyDesc"] = "一次性交通补贴";
  1438. $info["workAllowanceMoney"] = 0.00;
  1439. $info["developAllowanceMoney"] = 0.00;
  1440. $info["recommendTalentArrange"] = $talentArrange;
  1441. if ($info["otherEnjoyedMoney"] != 0) {
  1442. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . "\n" . "扣除其它补贴金额" . $info["otherEnjoyedMoney"] . "元,最终可享受人才津贴为" . number_format($jtMoney - $info["otherEnjoyedMoney"], 2) . "元";
  1443. }
  1444. $info["recommendMoneyDesc"] = $info["otherEnjoyedMoney"] != 0 ? sprintf("-%s(其它补贴金额)", number_format($info["otherEnjoyedMoney"], 2)) : "";
  1445. break;
  1446. case 3:
  1447. $info["recommendMoney"] = 0.00;
  1448. $info["recommendMonths"] = "";
  1449. $info["recommendMoneyDesc"] = "不予兑现";
  1450. $info["workAllowanceMoney"] = 0.00;
  1451. $info["developAllowanceMoney"] = 0.00;
  1452. break;
  1453. }
  1454. return $arrangeList;
  1455. }
  1456. /**
  1457. * 判定是否交足6个月(集成电路)
  1458. * @param set
  1459. * @param info
  1460. * @param name
  1461. */
  1462. private function chkMonths($set, &$info, $name, $sort) {
  1463. if ($name == "上年度工作月份") {
  1464. if ($info["allowanceType"] == 2) {
  1465. $tmp = [];
  1466. foreach ($set as $s) {
  1467. $_s = explode("=", $s);
  1468. $month = $_s[0];
  1469. $days = $_s[1];
  1470. if ($days > 0) {
  1471. $tmp[] = $month;
  1472. }
  1473. }
  1474. $set = $tmp;
  1475. }
  1476. }
  1477. $preCheckProjects = ["①", "②", "③"];
  1478. if ($info["type"] == CommonConst::ENTERPRISE_WJ) {
  1479. $preCheckProjects = ["①", "②"];
  1480. }
  1481. if ($info["type"] == CommonConst::ENTERPRISE_GJ) {
  1482. if ($info["backWork"] == 1) {
  1483. $preCheckProjects = ["②", "③"];
  1484. } else {
  1485. $preCheckProjects = ["②", "③"];
  1486. }
  1487. }
  1488. if ($info["recommendAllowanceType"] == 1 && (!$set || count($set) < 6) && in_array($sort, $preCheckProjects)) {
  1489. $info["recommendAllowanceType"] = 3;
  1490. $info["recommendAllowanceMsg"] = $info["recommendAllowanceMsg"] . $sort . $name . "不足6个月,无法享受工作津贴(×)";
  1491. }
  1492. return $set;
  1493. }
  1494. //合并所有项目的月份
  1495. private function mergeMonth($detailList) {
  1496. $contractList = [];
  1497. $taxList = [];
  1498. $wagesList = [];
  1499. $pensionList = [];
  1500. $unemploymentList = [];
  1501. $medicaList = [];
  1502. $attendanceList = [];
  1503. $workdayList = [];
  1504. foreach ($detailList as $detail) {
  1505. $projectMap = $detail["projectMap"];
  1506. if ($detail["months"]) {
  1507. $tmp = array_filter(explode(",", $detail["months"]));
  1508. $contractList = array_merge($contractList, $tmp);
  1509. }
  1510. if ($projectMap[AllowanceProjectEnum::PROJECT_TAX] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"])) {
  1511. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_TAX]["months"]));
  1512. $taxList = array_merge($taxList, $tmp);
  1513. }
  1514. if ($projectMap[AllowanceProjectEnum::PROJECT_WAGES] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"])) {
  1515. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WAGES]["months"]));
  1516. $wagesList = array_merge($wagesList, $tmp);
  1517. }
  1518. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"])) {
  1519. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_PENSION]["months"]));
  1520. $pensionList = array_merge($pensionList, $tmp);
  1521. }
  1522. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"])) {
  1523. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT]["months"]));
  1524. $unemploymentList = array_merge($unemploymentList, $tmp);
  1525. }
  1526. if ($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"])) {
  1527. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_SB_MEDICA]["months"]));
  1528. $medicaList = array_merge($medicaList, $tmp);
  1529. }
  1530. if ($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"])) {
  1531. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_ATTENDANCE]["months"]));
  1532. $attendanceList = array_merge($attendanceList, $tmp);
  1533. }
  1534. if ($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY] && \StrUtil::isNotEmpAndNull($projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"])) {
  1535. $tmp = array_filter(explode(",", $projectMap[AllowanceProjectEnum::PROJECT_WORKDAY]["months"]));
  1536. $workdayList = array_merge($workdayList, $tmp);
  1537. }
  1538. }
  1539. $map = [
  1540. AllowanceProjectEnum::PROJECT_CONTRACT => $contractList,
  1541. AllowanceProjectEnum::PROJECT_TAX => $taxList,
  1542. AllowanceProjectEnum::PROJECT_WAGES => $wagesList,
  1543. AllowanceProjectEnum::PROJECT_SB_PENSION => $pensionList,
  1544. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT => $unemploymentList,
  1545. AllowanceProjectEnum::PROJECT_SB_MEDICA => $medicaList,
  1546. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendanceList,
  1547. AllowanceProjectEnum::PROJECT_WORKDAY => $workdayList,
  1548. ];
  1549. return $map;
  1550. }
  1551. /**
  1552. * 合并多个单位带有天数的项目的月份如考勤1月30天,
  1553. * */
  1554. private function mergeMonthNeedDay($detailList) {
  1555. $attendMap = [];
  1556. $workDayMap = [];
  1557. foreach ($detailList as $detail) {
  1558. $attendMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_ATTENDANCE], $attendMap);
  1559. $workDayMap = $this->getMergeMonthNeedDayMap($detail["projectMap"][AllowanceProjectEnum::PROJECT_WORKDAY], $workDayMap);
  1560. }
  1561. $res = [
  1562. AllowanceProjectEnum::PROJECT_ATTENDANCE => $attendMap,
  1563. AllowanceProjectEnum::PROJECT_WORKDAY => $workDayMap
  1564. ];
  1565. return $res;
  1566. }
  1567. private function getMergeMonthNeedDayMap($project, $map) {
  1568. if (\StrUtil::isNotEmpAndNull($project["months"])) {
  1569. $monthAndDayList = array_filter(explode(",", $project["months"]));
  1570. for ($i = 0; $i < count($monthAndDayList); $i++) {
  1571. $obj = explode("=", $monthAndDayList[$i]);
  1572. $month = $obj[0];
  1573. $day = is_numeric($obj[1]) ? $obj[1] : 0;
  1574. $count = $map[$month];
  1575. if ($count == 0) {
  1576. $map[$month] = $day;
  1577. } else {
  1578. $map[$month] = $day + $count;
  1579. }
  1580. }
  1581. }
  1582. return $map;
  1583. }
  1584. /**
  1585. * 校验是否在审核范围内
  1586. */
  1587. public function validateIsCheck() {
  1588. $id = $this->request["id"];
  1589. $type = $this->request["type"];
  1590. $process = $this->request["process"];
  1591. $info = null;
  1592. switch ($type) {
  1593. case 1: //编辑合同
  1594. $detail = \app\common\model\TalentAllowancecontractDetail::find($id);
  1595. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  1596. break;
  1597. case 2: //编辑项目
  1598. $project = \app\common\model\TalentAllowanceProject::find($id);
  1599. $info = TalentAllowanceApi::getInfoById($project["mainId"]);
  1600. break;
  1601. case 3:
  1602. $info = TalentAllowanceApi::getInfoById($id);
  1603. break;
  1604. }
  1605. if (!$info) {
  1606. return new Response(Response::ERROR, "校验不通过,无法操作");
  1607. }
  1608. $where = [];
  1609. $where[] = ["mainId", "=", $info["id"]];
  1610. $where[] = ["step", "=", $process];
  1611. $where[] = ["active", "=", 2];
  1612. $log = null;
  1613. switch ($process) {
  1614. case 1:
  1615. if ($info["checkState"] != AllowanceStateEnum::NEED_CHECK && $info["checkState"] != AllowanceStateEnum::REJECT_TO_FIRST) {
  1616. return new Response(Response::ERROR, "不在审核范围内");
  1617. }
  1618. //$where[] = ["companyId","=",$this->user["companyId"]];
  1619. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1620. break;
  1621. case 2:
  1622. if ($info["checkState"] != AllowanceStateEnum::NEED_VISIT_CHECK && $info["checkState"] != AllowanceStateEnum::REVIEW_REJECT) {
  1623. return new Response(Response::ERROR, "不在审核范围内");
  1624. }
  1625. break;
  1626. case 3:
  1627. if ($info["checkState"] != AllowanceStateEnum::NEED_REVIEW && $info["checkState"] != AllowanceStateEnum::PUBLIC_REJECT) {
  1628. return new Response(Response::ERROR, "不在审核范围内");
  1629. }
  1630. $log = TalentChecklog::where($where)->order("createTime desc")->find();
  1631. break;
  1632. }
  1633. if ($log != null) {
  1634. $info["checkState"] = $log["state"];
  1635. $info["checkMsg"] = $log["description"];
  1636. } else {
  1637. $info["checkState"] = null;
  1638. $info["checkMsg"] = "";
  1639. }
  1640. $res = [];
  1641. $res["info"] = $info;
  1642. if ($type == 3) {
  1643. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1644. $where = [];
  1645. $where[] = ["mainId", "=", $id];
  1646. $where[] = ["isLock", "=", 1];
  1647. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  1648. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1649. $detailMap = array_reduce($detailList, function ($result, $item) {
  1650. $key = $item["id"];
  1651. $result[$key] = $item;
  1652. return $result;
  1653. }, []);
  1654. foreach ($detailList as &$detail) {
  1655. $detail["enterpriseName"] = sprintf("%s(%s至%s)", $enterpriseMap[$detail["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1656. }unset($detail);
  1657. foreach ($projectList as &$project) {
  1658. $detail = $detailMap[$project["baseId"]];
  1659. $project["projectName"] = sprintf("%s(%s(%s至%s))", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]], $detail["startTime"], $detail["endTime"]);
  1660. }
  1661. $where = [];
  1662. $where[] = ["type", "=", $info["type"]];
  1663. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  1664. $where[] = ["active", "=", 1];
  1665. $where[] = ["isConditionFile", "=", $info["allowanceType"]];
  1666. $where[] = ["delete", "=", 0];
  1667. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1668. $res["files"] = $filetypes;
  1669. $res["projects"] = $projectList;
  1670. $res["concats"] = $detailList;
  1671. $res["calResult"] = TalentAllowanceApi::validateAllowanceType($id);
  1672. }
  1673. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1674. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  1675. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1676. foreach ($detailList as &$detail) {
  1677. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  1678. if (\StrUtil::isNotEmpAndNull($detail["talentType"])) {
  1679. $detail["talentTypeName"] = $talentTypeMap[$detail["talentType"]];
  1680. }
  1681. }
  1682. $res["detailList"] = $detailList;
  1683. return new Response(Response::SUCCESS, "不在审核范围内", $res);
  1684. }
  1685. /**
  1686. * 初始化可修改的项目/附件/合同
  1687. * */
  1688. public function findFieldsAndFiles() {
  1689. $id = $this->request["id"];
  1690. if (\StrUtil::isEmpOrNull($id)) {
  1691. return new Response(Response::ERROR, "请选择需要修改的对象");
  1692. }
  1693. $info = TalentAllowanceApi::getInfoById($id);
  1694. if (!$info) {
  1695. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1696. }
  1697. if ($info["checkState"] != AllowanceStateEnum::FIRST_REJECT) {
  1698. return new Response(Response::ERROR, "只能修改初审驳回的数据");
  1699. }
  1700. $res = [];
  1701. $enterpriseMap = \app\common\model\Enterprise::where("type", $this->user["type"])->column("name", "id");
  1702. $where = [];
  1703. $where[] = ["mainId", "=", $id];
  1704. $where[] = ["isLock", "=", 1];
  1705. $projectList = \app\common\model\TalentAllowanceProject::where($where)->select()->toArray();
  1706. $detailList = \app\common\model\TalentAllowancecontractDetail::where("mainId", $id)->select()->toArray();
  1707. foreach ($detailList as &$detail) {
  1708. $detail["enterpriseName"] = $enterpriseMap[$detail["enterpriseId"]];
  1709. }unset($detail);
  1710. foreach ($projectList as &$project) {
  1711. $detail = $detailMap[$project["baseId"]];
  1712. $project["projectName"] = sprintf("%s(%s)", AllowanceProjectEnum::getProjectName($project["project"]), $enterpriseMap[$project["enterpriseId"]]);
  1713. }unset($project);
  1714. $where = [];
  1715. $where[] = ["type", "=", $info["type"]];
  1716. $where[] = ["project", "=", \app\common\state\ProjectState::JBT];
  1717. $where[] = ["active", "=", 1];
  1718. $where[] = ["isConditionFile", "=", $info["allowanceType"]];
  1719. $where[] = ["delete", "=", 0];
  1720. $filetypes = Db::table("new_common_filetype")->where($where)->order("sn asc")->select()->toArray();
  1721. $res["files"] = $filetypes;
  1722. $res["projects"] = $projectList;
  1723. $res["concats"] = $detailList;
  1724. $res["info"] = $info;
  1725. return new Response(Response::SUCCESS, "", $res);
  1726. }
  1727. /**
  1728. * 修改驳回项目/附件/合同
  1729. * */
  1730. public function updateFieldsAndFiles() {
  1731. $data = $this->request->param();
  1732. if (!$data["id"]) {
  1733. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1734. }
  1735. TaModel::update($data);
  1736. return new Response(Response::SUCCESS, "修改成功");
  1737. }
  1738. /**
  1739. * 修改项目
  1740. */
  1741. public function editProject() {
  1742. $param = $this->request->param();
  1743. if (!$param["id"]) {
  1744. return new Response(Response::ERROR, "系统错误,请联系管理员");
  1745. }
  1746. $detail = \app\common\model\TalentAllowanceProject::find($param["id"]);
  1747. $info = TalentAllowanceApi::getInfoById($detail["mainId"]);
  1748. \app\common\model\TalentAllowanceProject::update($param);
  1749. //添加日志
  1750. TalentChecklog::create([
  1751. 'id' => getStringId(),
  1752. 'mainId' => $info['id'],
  1753. 'type' => intval(ProjectState::JBT),
  1754. 'typeFileId' => $param["id"],
  1755. 'active' => 1,
  1756. 'state' => null,
  1757. 'step' => $param["process"],
  1758. 'stateChange' => null,
  1759. 'description' => "修改项目名:" . AllowanceProjectEnum::getProjectName($detail["project"]) . "的值为:" . $param["months"] . ";备注为:" . $param["description"],
  1760. 'createTime' => date("Y-m-d H:i:s", time()),
  1761. 'createUser' => sprintf("%s(%s)", $this->user["account"], $this->user["companyName"])
  1762. ]);
  1763. return new Response(Response::SUCCESS, "修改成功");
  1764. }
  1765. /**
  1766. * 查询工作单位
  1767. */
  1768. public function findAllowanceContractDetail() {
  1769. $mainId = $this->request["mainId"];
  1770. $offset = $this->request["offset"] ?: 0;
  1771. $limit = $this->request["limit"] ?: 1000;
  1772. $count = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->count();
  1773. $list = \app\common\model\TalentAllowancecontractDetail::where("mainId", $mainId)->limit($offset, $limit)->select()->toArray();
  1774. $enterpriseMap = \app\common\model\Enterprise::column("name", "id");
  1775. foreach ($list as &$row) {
  1776. $row["enterpriseName"] = $enterpriseMap[$row["enterpriseId"]];
  1777. }unset($row);
  1778. return json(["rows" => $list, "total" => $count]);
  1779. }
  1780. /**
  1781. * 查询核查项目情况
  1782. */
  1783. public function findAllowanceProject() {
  1784. $mainId = $this->request["mainId"];
  1785. $baseId = $this->request["baseId"];
  1786. $offset = $this->request["offset"] ?: 0;
  1787. $limit = $this->request["limit"] ?: 1000;
  1788. $where = [];
  1789. $where[] = ["mainId", "=", $mainId];
  1790. $where[] = ["baseId", "=", $baseId];
  1791. $count = \app\common\model\TalentAllowanceProject::where($where)->count();
  1792. $list = \app\common\model\TalentAllowanceProject::where($where)->limit($offset, $limit)->select()->toArray();
  1793. $info = TalentAllowanceApi::getInfoById($mainId);
  1794. foreach ($list as &$project) {
  1795. $project["projectName"] = AllowanceProjectEnum::getProjectName($project["project"]);
  1796. if ($info["checkState"] == 1) {
  1797. $project["isEdit"] = in_array($project["project"], [
  1798. //AllowanceProjectEnum::PROJECT_CONTRACT,
  1799. AllowanceProjectEnum::PROJECT_TAX,
  1800. AllowanceProjectEnum::PROJECT_WAGES,
  1801. AllowanceProjectEnum::PROJECT_ATTENDANCE,
  1802. AllowanceProjectEnum::PROJECT_SB_PENSION,
  1803. AllowanceProjectEnum::PROJECT_SB_UNEMPLOYMENT,
  1804. AllowanceProjectEnum::PROJECT_SB_MEDICA,
  1805. AllowanceProjectEnum::PROJECT_TEACHING,
  1806. AllowanceProjectEnum::PROJECT_LESSON,
  1807. AllowanceProjectEnum::PROJECT_TRAINING_PROGRAM,
  1808. //AllowanceProjectEnum::PROJECT_WORKDAY
  1809. ]) ? 1 : 2;
  1810. } else if ($info["checkState"] == 10 || $info["checkState"] == 8) {
  1811. $projects = explode(",", $info["projects"]);
  1812. if (in_array($project["id"], $projects)) {
  1813. $project["isEdit"] = 1;
  1814. } else {
  1815. $project["isEdit"] = 2;
  1816. }
  1817. } else {
  1818. $project["isEdit"] = 2;
  1819. }
  1820. }unset($project);
  1821. return json(["rows" => $list, "total" => $count]);
  1822. }
  1823. /**
  1824. * 查询人才层次变更记录
  1825. */
  1826. public function findAllowanceArrange() {
  1827. $mainId = $this->request["mainId"];
  1828. $offset = $this->request["offset"] ?: 0;
  1829. $limit = $this->request["limit"] ?: 1000;
  1830. $where = [];
  1831. $where[] = ["mainId", "=", $mainId];
  1832. $count = \app\common\model\TalentAllowanceArrange::where($where)->count();
  1833. $list = \app\common\model\TalentAllowanceArrange::where($where)->limit($offset, $limit)->select()->toArray();
  1834. foreach ($list as &$arrange) {
  1835. $condition = \app\common\api\TalentConditionApi::getOne($arrange["identifyCondition"]);
  1836. $arrange["identifyConditionText"] = $condition["name"];
  1837. $arrange["talentArrangeName"] = CommonConst::getLayerNameByLayer($arrange["talentArrange"]);
  1838. }unset($arrange);
  1839. return json(["rows" => $list, "total" => $count]);
  1840. }
  1841. /**
  1842. * 试算
  1843. * @param type $id
  1844. * @return type
  1845. */
  1846. public function calculator($id) {
  1847. $cal = TalentAllowanceApi::validateAllowanceType($id);
  1848. return json($cal);
  1849. }
  1850. private function setTalentAllowanceInfo($where, $query, $process) {
  1851. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1852. $where[] = ["year", "like", $query["year"] . "%"];
  1853. }
  1854. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1855. $where[] = ["enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1856. }
  1857. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1858. $where[] = ["name", "like", "%" . $query["name"] . "%"];
  1859. }
  1860. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1861. $where[] = ["talentType", "=", $query["talentType"]];
  1862. }
  1863. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  1864. $where[] = ["talentArrange", "=", $query["talentArrange"]];
  1865. }
  1866. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  1867. $where[] = ["identifyCondition", "=", $query["identifyCondition"]];
  1868. }
  1869. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  1870. $where[] = ["address", "=", $query["address"]];
  1871. }
  1872. if ($query["allowanceType"]) {
  1873. $where[] = ["allowanceType", "=", $query["allowanceType"]];
  1874. }
  1875. if ($query["recommendAllowanceType"]) {
  1876. $where[] = ["recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  1877. }
  1878. if ($query["publicState"]) {
  1879. $where[] = ["publicState", "=", $query["publicState"]];
  1880. }
  1881. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  1882. $where[] = ["introductionMode", "=", $query["introductionMode"]];
  1883. }
  1884. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  1885. $where[] = ["firstInJJTime", ">=", $query["firstJJStartTime"]];
  1886. }
  1887. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  1888. $where[] = ["firstInJJTime", "<=", $query["firstJJEndTime"]];
  1889. }
  1890. if ($process == 4) {
  1891. if ($query["isSupple"]) {
  1892. $where[] = ["isSupple", "=", $query["isSupple"]];
  1893. }
  1894. if ($query["isPublicCheck"]) {
  1895. $where[] = ["isPublicCheck", "=", $query["isPublicCheck"]];
  1896. }
  1897. }
  1898. if ($query["checkState"]) {
  1899. if ($query["checkState"] == -1) {
  1900. $where[] = ["checkState", "=", $query["checkState"]];
  1901. } else {
  1902. if ($process == 1) {
  1903. switch ($query["checkState"]) {
  1904. case -2: //保存未提交
  1905. $where[] = ["checkState", "=", 1];
  1906. break;
  1907. case 1:
  1908. $where[] = ["checkState", "=", 5];
  1909. break;
  1910. case 2: //驳回
  1911. $where[] = ["checkState", "=", 10];
  1912. break;
  1913. case 3: //通过
  1914. $where[] = ["checkState", "in", [15, 20, 30, 25]];
  1915. break;
  1916. case 9: //重新提交
  1917. $where[] = ["checkState", "=", 5];
  1918. $where[] = ["highProcess", ">=", $process];
  1919. break;
  1920. case 4: //上级驳回
  1921. $where[] = ["checkState", "=", 13];
  1922. break;
  1923. }
  1924. }
  1925. if ($process == 2) {
  1926. switch ($query["checkState"]) {
  1927. case 1:
  1928. $where[] = ["checkState", "=", 15];
  1929. break;
  1930. case 2: //驳回
  1931. $where[] = ["checkState", "in", [1, 5, 10]];
  1932. $where[] = ["highProcess", ">=", $process];
  1933. break;
  1934. case 3: //通过
  1935. $where[] = ["checkState", "in", [20, 30]];
  1936. break;
  1937. case 9: //重新提交
  1938. $where[] = ["checkState", "=", 15];
  1939. $where[] = ["highProcess", ">=", $process];
  1940. break;
  1941. case 4: //上级驳回
  1942. $where[] = ["checkState", "=", 25];
  1943. break;
  1944. case -1:
  1945. $where[] = ["checkState", "=", -1];
  1946. break;
  1947. }
  1948. }
  1949. if ($process == 3) {
  1950. switch ($query["checkState"]) {
  1951. case -1:
  1952. $where[] = ["checkState", "=", -1];
  1953. break;
  1954. case 1:
  1955. $where[] = ["checkState", "=", 20];
  1956. break;
  1957. case 2: //驳回
  1958. $where[] = ["checkState", "in", [1, 5, 10, 15, 25]];
  1959. $where[] = ["highProcess", ">=", $process];
  1960. break;
  1961. case 3: //通过
  1962. $where[] = ["checkState", "=", 30];
  1963. break;
  1964. case 9: //重新提交
  1965. $where[] = ["checkState", "=", 20];
  1966. $where[] = ["highProcess", ">=", $process];
  1967. break;
  1968. case 4: //上级驳回
  1969. $where[] = ["checkState", "=", 35];
  1970. break;
  1971. }
  1972. }
  1973. if ($process == 4) {
  1974. switch ($query["checkState"]) {
  1975. case -1:
  1976. $where[] = ["checkState", "=", -1];
  1977. break;
  1978. case 3: //通过
  1979. $where[] = ["checkState", "=", 30];
  1980. break;
  1981. }
  1982. }
  1983. }
  1984. }
  1985. return $where;
  1986. }
  1987. private function setTalentAllowanceInfoForExport(&$where, $query, $process) {
  1988. if (\StrUtil::isNotEmpAndNull($query["year"])) {
  1989. $where[] = ["ta.year", "like", $query["year"] . "%"];
  1990. }
  1991. if (\StrUtil::isNotEmpAndNull($query["enterpriseName"])) {
  1992. $where[] = ["ta.enterpriseName", "like", "%" . $query["enterpriseName"] . "%"];
  1993. }
  1994. if (\StrUtil::isNotEmpAndNull($query["name"])) {
  1995. $where[] = ["ta.name", "like", "%" . $query["name"] . "%"];
  1996. }
  1997. if (\StrUtil::isNotEmpAndNull($query["talentType"])) {
  1998. $where[] = ["ta.talentType", "=", $query["talentType"]];
  1999. }
  2000. if (\StrUtil::isNotEmpAndNull($query["talentArrange"])) {
  2001. $where[] = ["ta.talentArrange", "=", $query["talentArrange"]];
  2002. }
  2003. if (\StrUtil::isNotEmpAndNull($query["identifyCondition"])) {
  2004. $where[] = ["ta.identifyCondition", "=", $query["identifyCondition"]];
  2005. }
  2006. if (\StrUtil::isNotEmpAndNull($query["address"])) {
  2007. $where[] = ["ta.address", "=", $query["address"]];
  2008. }
  2009. if (\StrUtil::isNotEmpAndNull($query["allowanceType"])) {
  2010. $where[] = ["ta.allowanceType", "=", $query["allowanceType"]];
  2011. }
  2012. if (\StrUtil::isNotEmpAndNull($query["recommendAllowanceType"])) {
  2013. $where[] = ["ta.recommendAllowanceType", "=", $query["recommendAllowanceType"]];
  2014. }
  2015. if (\StrUtil::isNotEmpAndNull($query["publicState"])) {
  2016. $where[] = ["ta.publicState", "=", $query["publicState"]];
  2017. }
  2018. if (\StrUtil::isNotEmpAndNull($query["introductionMode"])) {
  2019. $where[] = ["ta.introductionMode", "=", $query["introductionMode"]];
  2020. }
  2021. if (\StrUtil::isNotEmpAndNull($query["firstJJStartTime"])) {
  2022. $where[] = ["ta.firstInJJTime", ">=", $query["firstJJStartTime"]];
  2023. }
  2024. if (\StrUtil::isNotEmpAndNull($query["firstJJEndTime"])) {
  2025. $where[] = ["ta.firstInJJTime", "<=", $query["firstJJEndTime"]];
  2026. }
  2027. if ($process == 4) {
  2028. if ($query["isSupple"]) {
  2029. $where[] = ["ta.isSupple", "=", $query["isSupple"]];
  2030. }
  2031. if ($query["isPublicCheck"]) {
  2032. $where[] = ["ta.isPublicCheck", "=", $query["isPublicCheck"]];
  2033. }
  2034. }
  2035. if ($query["checkState"]) {
  2036. if ($query["checkState"] == -1) {
  2037. $where[] = ["ta.checkState", "=", $query["checkState"]];
  2038. } else {
  2039. if ($process == 1) {
  2040. switch ($query["checkState"]) {
  2041. case 0: //保存未提交
  2042. $where[] = ["ta.checkState", "=", 1];
  2043. break;
  2044. case 1:
  2045. $where[] = ["ta.checkState", "=", 5];
  2046. break;
  2047. case 2: //驳回
  2048. $where[] = ["ta.checkState", "=", 10];
  2049. break;
  2050. case 3: //通过
  2051. $where[] = ["ta.checkState", "in", [15, 20, 30, 25]];
  2052. break;
  2053. case 4: //重新提交
  2054. $where[] = ["ta.checkState", "=", 5];
  2055. $where[] = ["ta.highProcess", ">=", $process];
  2056. break;
  2057. case 5: //上级驳回
  2058. $where[] = ["ta.checkState", "=", 13];
  2059. break;
  2060. }
  2061. }
  2062. if ($process == 2) {
  2063. switch ($query["checkState"]) {
  2064. case 1:
  2065. $where[] = ["ta.checkState", "=", 15];
  2066. break;
  2067. case 2: //驳回
  2068. $where[] = ["ta.checkState", "in", [1, 5, 10]];
  2069. $where[] = ["ta.highProcess", ">=", $process];
  2070. break;
  2071. case 3: //通过
  2072. $where[] = ["ta.checkState", "in", [20, 30]];
  2073. break;
  2074. case 9: //重新提交
  2075. $where[] = ["ta.checkState", "=", 15];
  2076. $where[] = ["ta.highProcess", ">=", $process];
  2077. break;
  2078. case 4: //上级驳回
  2079. $where[] = ["ta.checkState", "=", 25];
  2080. break;
  2081. case -1:
  2082. $where[] = ["ta.checkState", "=", -1];
  2083. break;
  2084. }
  2085. }
  2086. if ($process == 3) {
  2087. switch ($query["checkState"]) {
  2088. case -1:
  2089. $where[] = ["ta.checkState", "=", -1];
  2090. break;
  2091. case 1:
  2092. $where[] = ["ta.checkState", "=", 20];
  2093. break;
  2094. case 2: //驳回
  2095. $where[] = ["ta.checkState", "in", [1, 5, 10, 15, 25]];
  2096. $where[] = ["ta.highProcess", ">=", $process];
  2097. break;
  2098. case 3: //通过
  2099. $where[] = ["ta.checkState", "=", 30];
  2100. break;
  2101. case 9: //重新提交
  2102. $where[] = ["ta.checkState", "=", 20];
  2103. $where[] = ["ta.highProcess", ">=", $process];
  2104. break;
  2105. case 4: //上级驳回
  2106. $where[] = ["ta.checkState", "=", 35];
  2107. break;
  2108. }
  2109. }
  2110. if ($process == 4) {
  2111. switch ($query["checkState"]) {
  2112. case -1:
  2113. $where[] = ["ta.checkState", "=", -1];
  2114. break;
  2115. case 3: //通过
  2116. $where[] = ["ta.checkState", "=", 30];
  2117. break;
  2118. }
  2119. }
  2120. }
  2121. }
  2122. }
  2123. private function translateToChinese(&$obj) {
  2124. if (\StrUtil::isNotEmpAndNull($obj["address"])) {
  2125. $obj["addressName"] = DictApi::findByParentCodeAndCode("street", $obj["address"])["name"];
  2126. }
  2127. if (\StrUtil::isNotEmpAndNull($obj["talentType"])) {
  2128. $obj["talentTypeName"] = DictApi::findByParentCodeAndCode("enterprise_tag", $obj["talentType"])["name"];
  2129. }
  2130. if (\StrUtil::isNotEmpAndNull($obj["talentArrange"])) {
  2131. $obj["talentArrangeName"] = DictApi::findByParentCodeAndCode("talent_arrange", $obj["talentArrange"])["name"];
  2132. }
  2133. if (\StrUtil::isNotEmpAndNull($obj["identifyCondition"])) {
  2134. $obj["identifyConditionText"] = \app\common\api\TalentConditionApi::getOne($obj["identifyCondition"])["name"];
  2135. }
  2136. if (\StrUtil::isNotEmpAndNull($obj["introductionMode"])) {
  2137. $obj["introductionModeName"] = DictApi::findByParentCodeAndCode("import_way", $obj["introductionMode"])["name"];
  2138. }
  2139. }
  2140. private function translateChinese($list) {
  2141. //获取字典表
  2142. $levelMap = DictApi::selectByParentCode("talent_arrange");
  2143. $talentTypeMap = DictApi::selectByParentCode("enterprise_tag");
  2144. $streetMap = DictApi::selectByParentCode("street");
  2145. $cardTypeMap = DictApi::selectByParentCode("card_type");
  2146. $modeMap = DictApi::selectByParentCode("import_way");
  2147. $where = [];
  2148. $where[] = ["type", "=", $this->user["type"]];
  2149. $where[] = ["id", "in", array_column($list, "identifyCondition")];
  2150. $icmap = \app\common\model\TalentCondition::where($where)->column("name", "id");
  2151. foreach ($list as &$info) {
  2152. if (\StrUtil::isNotEmpAndNull($info["talentArrange"])) {
  2153. $info["talentArrangeName"] = $levelMap[$info["talentArrange"]];
  2154. }
  2155. $info["talentTypeName"] = $talentTypeMap[$info["talentType"]];
  2156. if (\StrUtil::isNotEmpAndNull($info["identifyCondition"])) {
  2157. $info["identifyConditionText"] = $icmap[$info["identifyCondition"]];
  2158. }
  2159. $info["addressName"] = $streetMap[$info["address"]];
  2160. $info["sexName"] = $info["sex"] == 1 ? "男" : "女";
  2161. $info["checkStateName"] = AllowanceStateEnum::getStateName($info["checkState"]);
  2162. $info["cardTypeName"] = $cardTypeMap[$info["cardType"]];
  2163. $info["isSuppleName"] = $info["isSupple"] == 1 ? "是" : "否";
  2164. $info["isPublicCheckName"] = $info["isPublicCheckName"] == 1 ? "是" : "否";
  2165. $info["recomendAllowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["recommendAllowanceType"]);
  2166. $info["allowanceTypeName"] = \app\common\state\AllowanceTypeEnum::getTypeName($info["allowanceType"]);
  2167. $info["recommendTalentArrangeName"] = $levelMap[$info["recommendTalentArrange"]];
  2168. $info["jtTalentArrangeName"] = $levelMap[$info["jtTalentArrange"]];
  2169. $info["introductionModeName"] = $modeMap[$info["introductionMode"]];
  2170. }unset($info);
  2171. return $list;
  2172. }
  2173. private function getCheckStateName($checkState, $publicState, $allowanceType) {
  2174. switch ($checkState) {
  2175. case 1:
  2176. return "待提交";
  2177. case 5:
  2178. case 13:
  2179. case 15:
  2180. case 20:
  2181. case 25:
  2182. case 35:
  2183. return "审核中";
  2184. case 10:
  2185. return "已驳回";
  2186. case - 1:
  2187. if ($publicState >= 3) {
  2188. return "审核不通过";
  2189. } else {
  2190. return "审核中";
  2191. }
  2192. break;
  2193. case 30:
  2194. if ($publicState == 1) {
  2195. return "待核查征信";
  2196. } else if ($publicState == 2) {
  2197. return "待公示";
  2198. } else if ($publicState == 3) {
  2199. return "公示中";
  2200. } else if ($publicState == 4) {
  2201. return $allowanceType != 3 ? "待兑现" : "不予兑现";
  2202. } else if ($publicState == 5) {
  2203. return "已兑现";
  2204. }
  2205. default:
  2206. return "未知状态";
  2207. }
  2208. }
  2209. }