TalentAllowance.php 104 KB

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