TalentAllowance.php 108 KB

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