TalentAllowance.php 96 KB

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