TalentAllowance.php 94 KB

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