TalentAllowance.php 98 KB

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