Api.php 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257
  1. <?php
  2. namespace app\common\controller;
  3. use app\BaseController;
  4. use app\common\api\EnterpriseApi;
  5. use app\common\middleware\Auth;
  6. use app\common\model\TalentChecklog;
  7. use app\common\validate\Enterprise;
  8. use think\exception\ValidateException;
  9. use think\facade\Db;
  10. use app\enterprise\api\TalentApi;
  11. use app\common\api\TalentLogApi;
  12. use app\common\api\DictApi;
  13. use app\common\model\CurrentcyFileType;
  14. use app\common\model\TalentCommonFile;
  15. use app\common\api\UploadApi;
  16. use app\common\api\TalentConditionApi;
  17. use app\common\api\CompanyApi;
  18. use app\common\api\TalentState;
  19. use app\common\state\ProjectState;
  20. use app\common\state\IntegralState;
  21. /**
  22. * 需要权限的公共方法放这
  23. * Description of Tool
  24. *
  25. * @author sgq
  26. */
  27. class Api extends BaseController {
  28. protected $middleware = [Auth::class];
  29. protected $user;
  30. public function __construct(\think\App $app) {
  31. parent::__construct($app);
  32. $this->user = session("user");
  33. }
  34. public function findIdentifyConditionByLevel() {
  35. $params = $this->request->param();
  36. $id = $params["id"];
  37. $type = $this->user["type"];
  38. $showAll = $params["showAll"] == 1 ? true : false;
  39. if ($id) {
  40. $talentInfo = TalentApi::getOne($id);
  41. $enterprise = \app\common\model\Enterprise::findOrEmpty($talentInfo["enterprise_id"]);
  42. $type = $enterprise["type"];
  43. }
  44. $list = TalentConditionApi::getList($params["level"], $type, $params["cat"], $showAll);
  45. return json($list, 200);
  46. }
  47. public function getTalentCondtionUploadFile() {
  48. $param = $this->request->param();
  49. $id = $param["mainId"];
  50. $order = $param["order"];
  51. $project = $param["project"];
  52. $type = $param["type"];
  53. $talent_condition = $param["talent_condition"];
  54. $condition_info = Db::table("new_talent_condition")->findOrEmpty($talent_condition);
  55. if (!$condition_info["bindFileTypes"])
  56. return json(["rows" => null]);
  57. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  58. $whr[] = ["active", "=", 1];
  59. $whr[] = ["delete", "=", 0];
  60. $rows = Db::table("new_common_filetype")->where($whr)->order("sn " . $order)->select()->toArray();
  61. if ($id) {
  62. foreach ($rows as $key => $row) {
  63. $where = [];
  64. $where[] = ["mainId", "=", $id];
  65. $where[] = ["typeId", "=", $row["id"]];
  66. $files = Db::table("new_talent_file")->where($where)->field("id,typeId,orignName,url")->order("sn asc")->select()->toArray();
  67. foreach ($files as &$file) {
  68. $file["ext"] = pathinfo($file["url"])["extension"];
  69. $file["url"] = getStoragePath($file["url"]);
  70. }
  71. $rows[$key]["files"] = $files;
  72. }
  73. }
  74. return json(["rows" => $rows, "info" => $condition_info]);
  75. }
  76. public function getCheckLog() {
  77. $userType = session("user")["usertype"];
  78. $params = $this->request->param();
  79. $mainId = $params["mainId"];
  80. $enterpriseId = $params["enterpriseId"];
  81. $category = $params["category"];
  82. $type = $params["type"];
  83. $list = [];
  84. switch ($type) {
  85. case 1:
  86. $talentInfo = TalentApi::getOne($mainId);
  87. $talent_condition = TalentConditionApi::getOne($talentInfo["talent_condition"]);
  88. case 2:
  89. case 3:
  90. case 4:
  91. case 5:
  92. case 6:
  93. case 7:
  94. case 8:
  95. case 9:
  96. case 19:
  97. case 20:
  98. $list = TalentLogApi::getList($type, $mainId);
  99. break;
  100. case 10:
  101. if ($enterpriseId) {
  102. $where[] = ["mainId", "=", $enterpriseId];
  103. $ids = \app\enterprise\model\EnterpriseRecord::where($where)->column("id");
  104. $ids[] = $enterpriseId;
  105. $where = [];
  106. $where[] = ["type", "=", $type];
  107. $where[] = ["active", "=", 1];
  108. $where[] = ["mainId", "in", $ids];
  109. $list = TalentChecklog::where($where)->order("createTime desc")->select();
  110. } else {
  111. $list = TalentLogApi::getList($type, $mainId);
  112. }
  113. break;
  114. }
  115. $new_list = [];
  116. foreach ($list as $key => $item) {
  117. if (($item["createUser"] == "系统" || $item["updateUser"] == "系统") && $userType != 1)//非管理员用户不显示系统自动生成或修改的日志
  118. continue;
  119. $new_item["description"] = $item["description"];
  120. switch ($item['type']) {
  121. case 2:
  122. case 3:
  123. case 4:
  124. case 5:
  125. case 6:
  126. case 7:
  127. case 8:
  128. case 9:
  129. case 19:
  130. $new_item["stateName"] = \app\common\state\LivingAllowanceState::getStateName($item["state"]);
  131. $new_item["stepName"] = \app\common\state\LivingAllowanceState::getStepName($item["step"]);
  132. $new_item["stateChange"] = $item["stateChange"];
  133. break;
  134. case 20:
  135. $new_item["stepName"] = IntegralState::getLogStepName($item["state"]);
  136. $new_item["stateName"] = IntegralState::getLogStateName($item["state"], $item["last_state"]);
  137. if ($item["last_state"] && $item["new_state"]) {
  138. $new_item["stateChange"] = sprintf("%s -> %s", IntegralState::getLogChangeName($item["last_state"]), IntegralState::getLogChangeName($item["new_state"], $item["last_state"]));
  139. } else {
  140. $new_item["stateChange"] = "";
  141. }
  142. break;
  143. case 10:
  144. if ($item["category"] == "enterprise_change") {
  145. switch ($item['step']) {
  146. case 100:
  147. $new_item["stepName"] = "<span class='label'>用户操作</span>";
  148. break;
  149. case 101:
  150. $new_item["stepName"] = "<span class='label label-primary'>审核</span>";
  151. break;
  152. case 102:
  153. $new_item["stepName"] = "<span class='label label-danger'>设置冻结</span>";
  154. break;
  155. case 103:
  156. $new_item["stepName"] = "<span class='label label-info'>重置密码</span>";
  157. break;
  158. }
  159. if ($category == "close_account") {
  160. $new_item["stateName"] = \app\common\state\MainState::getStateName($item['state']);
  161. } else {
  162. switch ($item['state']) {
  163. case 1:
  164. if ($item["stateChange"]) {
  165. $new_item["stateName"] = "<span class='label label-success'>待提交</span>";
  166. } else {
  167. $item['stateChange'] = "修改密码";
  168. }
  169. break;
  170. case 2:
  171. $new_item["stateName"] = "<span class='label label-success'>待审核</span>";
  172. break;
  173. case 3:
  174. $new_item["stateName"] = "<span class='label label-danger'>审核驳回</span>";
  175. break;
  176. case 4:
  177. $new_item["stateName"] = "<span class='label label-primary'>审核通过</span>";
  178. break;
  179. case 5:
  180. $new_item["stateName"] = "<span class='label label-warm'>重新提交</span>";
  181. break;
  182. case 6:
  183. $new_item["stateName"] = "<span class='label label-danger'>初审驳回</span>";
  184. break;
  185. case 7:
  186. $new_item["stateName"] = "<span class='label label-primary'>初审通过</span>";
  187. break;
  188. }
  189. }
  190. $new_item["stateChange"] = $item['stateChange'];
  191. } else {
  192. switch ($item['step']) {
  193. case 100:
  194. $new_item["stepName"] = "<span class='label'>用户操作</span>";
  195. break;
  196. case 101:
  197. $new_item["stepName"] = "<span class='label label-primary'>注册审核</span>";
  198. break;
  199. case 102:
  200. $new_item["stepName"] = "<span class='label label-danger'>设置冻结</span>";
  201. break;
  202. case 103:
  203. $new_item["stepName"] = "<span class='label label-info'>重置密码</span>";
  204. break;
  205. }
  206. switch ($item['state']) {
  207. case 1:
  208. $new_item["stateName"] = "<span class='label label-success'>待审核</span>";
  209. break;
  210. case 2:
  211. $new_item["stateName"] = "<span class='label label-danger'>审核驳回</span>";
  212. break;
  213. case 3:
  214. $new_item["stateName"] = "<span class='label label-primary'>审核通过</span>";
  215. break;
  216. case 4:
  217. $new_item["stateName"] = "<span class='label label-primary'>重新提交</span>";
  218. break;
  219. case 5:
  220. $new_item["stateName"] = "<span class='label label-danger'>初审驳回</span>";
  221. break;
  222. case 6:
  223. $new_item["stateName"] = "<span class='label label-primary'>初审通过</span>";
  224. break;
  225. default:
  226. break;
  227. }
  228. $new_item["stateChange"] = $item['stateChange'];
  229. }
  230. break;
  231. case 1:
  232. if ($item["step"] && $item["step"] != 3) {
  233. $new_item["stepName"] = \app\common\state\LivingAllowanceState::getStepName($item["step"]);
  234. } else {
  235. $new_item["stepName"] = DictApi::getCheckLogStepName($item["state"], $item["step"]);
  236. }
  237. if (in_array($item["state"], [TalentState::REVERIFY_FAIL, TalentState::ZX_FAIL, TalentState::ANNOUNCED_REVERIFY_FAIL, TalentState::PUBLISH_FAIL])) {
  238. $new_item["stateName"] = '<span class="label label-danger">审核不通过</span>';
  239. } else if (in_array($item["state"], [TalentState::BASE_VERIFY_PASS, TalentState::BASE_REVERIFY_PASS, TalentState::FST_VERIFY_PASS, TalentState::DEPT_VERIFY_PASS, TalentState::REVERIFY_PASS])) {
  240. if ($item["step"] == 3) {
  241. if ($item["new_state"] == TalentState::SCND_SUBMIT) {
  242. $new_item["stateName"] = '<span class="label label-danger">审核驳回</span>';
  243. } else if ($item["new_state"] == TalentState::DEPT_VERIFY_PASS) {
  244. $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
  245. } else {
  246. $new_item["stateName"] = '<span class="label label-success">待审核</span>';
  247. }
  248. if ($item["active"] === 0 && !in_array($item["companyId"], explode(",", $talent_condition["companyIds"]))) {
  249. $new_item["stateName"] = '<span class="label">已废弃</span>';
  250. }
  251. } else {
  252. $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
  253. }
  254. } else if (in_array($item["state"], [TalentState::BASE_REJECT, TalentState::BASE_REVERIFY_REJECT, TalentState::FST_VERIFY_REJECT, TalentState::DEPT_VERIFY_REJECT, TalentState::REVERIFY_REJECT])) {
  255. $new_item["stateName"] = '<span class="label label-danger">审核驳回</span>';
  256. } else if (in_array($item["state"], [TalentState::ZX_PASS, TalentState::ANNOUNCED, TalentState::ANNOUNCED_REVERIFY_PASS, TalentState::PUBLISH_PASS, TalentState::CERTIFICATED])) {
  257. $new_item["stateName"] = '<span class="label label-primary">审核通过</span>';
  258. } else if (in_array($item["state"], [TalentState::FST_SAVE, TalentState::SCND_SAVE])) {
  259. $new_item["stateName"] = '<span class="label">保存未提交</span>';
  260. } else if (in_array($item["state"], [TalentState::REVERIFY_CANCEL])) {
  261. $new_item["stateName"] = '<span class="label label-primary">撤销审核</span>';
  262. } else if (!$item["state"]) {
  263. if ($item["typeFileId"]) {
  264. $new_item["stateName"] = '<span class="label">添加附件</span>';
  265. }
  266. } else {
  267. if (($item["last_state"] == TalentState::BASE_REJECT && $item["state"] == TalentState::FST_SUBMIT) || ($item["last_state"] == TalentState::FST_VERIFY_REJECT && $item["state"] == TalentState::SCND_SUBMIT)) {
  268. $new_item["stateName"] = '<span class="label label-success">待审核(重新提交)</span>';
  269. } else {
  270. $new_item["stateName"] = '<span class="label label-success">待审核</span>';
  271. }
  272. }
  273. if ($item["step"] == 3) {
  274. $company = CompanyApi::getOne($item["companyId"]);
  275. if ($item["active"] == 0) {
  276. $new_item["description"] = "等待部门审核";
  277. $new_item["stateChange"] = str_replace("部门", '"' . $company["name"] . '"', DictApi::getTalentInfoStateName($item["state"], $item["step"]));
  278. } else {
  279. $new_item["stateChange"] = sprintf("%s -> %s", str_replace("部门", '"' . $company["name"] . '"', DictApi::getTalentInfoStateName($item["state"], $item["step"])), DictApi::getTalentInfoStateName($item["new_state"], $item["step"]));
  280. }
  281. } else {
  282. if ($item["last_state"] && $item["new_state"]) {
  283. $new_item["stateChange"] = sprintf("%s -> %s", DictApi::getTalentInfoStateName($item["last_state"], $list[$key + 1]["step"]), DictApi::getTalentInfoStateName($item["new_state"], $list[$key - 1]["step"], $item["last_state"]));
  284. } else {
  285. $new_item["stateChange"] = $item["stateChange"] ?: "";
  286. }
  287. }
  288. break;
  289. }
  290. $new_item["createUser"] = $item["updateUser"] && strpos($item["updateUser"], "企业用户") === false ? $item["updateUser"] : $item["createUser"]; //$item["updateUser"] ?: $item["createUser"];
  291. if ($new_item["createUser"] != "用户") {
  292. list($name, $company) = explode("(", $new_item["createUser"]);
  293. $where = [];
  294. $where[] = ["name", "=", $name];
  295. $user = \app\admin\model\User::where($where)->find();
  296. if ($user) {
  297. $new_item["createUser"] = implode("(", [$user["account"], $company]);
  298. }
  299. }
  300. $new_item["createTime"] = $item["updateTime"] ?: $item["createTime"];
  301. $new_list[] = $new_item;
  302. }
  303. if ($type == ProjectState::TALENT) {
  304. if ($talentInfo["oldId"]) {
  305. $where = [];
  306. $where[] = ["mainId", "=", $talentInfo["oldId"]];
  307. $where[] = ["type", "=", ProjectState::TALENT];
  308. $before_list = Db::table("un_talent_checklog")->where($where)->order("createTime desc")->select();
  309. foreach ($before_list as $before_item) {
  310. $new_list[] = [
  311. "stepName" => DictApi::getOldStepNameByStep($before_item["step"]),
  312. "stateName" => DictApi::getOldStateNameByState($before_item["state"]),
  313. "stateChange" => $before_item["stateChange"],
  314. "description" => $before_item["description"],
  315. "createUser" => $before_item["createUser"],
  316. "createTime" => $before_item["createTime"]
  317. ];
  318. }
  319. }
  320. }
  321. if ($type == ProjectState::LEVELCHANGE) {
  322. $where = [];
  323. $where[] = ["mainId", "=", $mainId];
  324. $where[] = ["type", "=", ProjectState::LEVELCHANGE];
  325. $before_list = Db::table("un_talent_checklog")->where($where)->order("createTime desc")->select();
  326. foreach ($before_list as $before_item) {
  327. $new_list[] = [
  328. "stepName" => DictApi::getOldStepNameByStep($before_item["step"]),
  329. "stateName" => DictApi::getOldStateNameByState($before_item["state"]),
  330. "stateChange" => $before_item["stateChange"],
  331. "description" => $before_item["description"],
  332. "createUser" => $before_item["createUser"],
  333. "createTime" => $before_item["createTime"]
  334. ];
  335. }
  336. }
  337. return json(["rows" => $new_list]);
  338. }
  339. public function getJbtCheckLog() {
  340. $obj = $this->request->param();
  341. $where = [];
  342. if ($obj["type"] != null) {
  343. $where[] = ["type", "=", $obj["type"]];
  344. }if (\StrUtil::isNotEmpAndNull($obj["mainId"])) {
  345. $where[] = ["mainId", "=", $obj["mainId"]];
  346. }
  347. if (\StrUtil::isNotEmpAndNull($obj["typeFileId"])) {
  348. $where[] = ["typeFileId", "=", $obj["typeFileId"]];
  349. } else {
  350. $where[] = ["typeFileId", "EXP", Db::raw("is null")];
  351. }
  352. if ($obj["active"] != null) {
  353. $where[] = ["active", "=", $obj["active"]];
  354. }
  355. $list = TalentChecklog::where($where)->select()->order("createTime desc")->toArray();
  356. foreach ($list as &$log) {
  357. $log["stateName"] = \app\common\state\AllowanceStateEnum::getStateName($log["state"]);
  358. $log["stepName"] = \app\common\state\AllowanceStepEnum::getStepName($log["step"]);
  359. }unset($log);
  360. $res = [
  361. "rows" => $list,
  362. "total" => count($list)
  363. ];
  364. return json($res);
  365. }
  366. public function findCommonFileType() {
  367. $param = $this->request->param();
  368. $id = $param["mainId"];
  369. $source = $param["source"];
  370. $order = $param["order"];
  371. $project = $param["project"];
  372. $type = $param["type"];
  373. $checkState = $param["checkState"];
  374. $isMix = $param["isMix"] ?: 0;
  375. $talent_condition = $param["talent_condition"];
  376. $token = $param["pageToken"];
  377. $year = $param["year"];
  378. $showOldFile = $param["showOldFile"];
  379. $where[] = ["project", "=", $project];
  380. $where[] = ["active", "=", 1];
  381. $where[] = ["delete", "=", 0];
  382. $where[] = ["type", "=", $type];
  383. switch ($project) {
  384. case 2:
  385. $where[] = ["isConditionFile", "=", $param["allowanceType"]];
  386. break;
  387. case 1:
  388. case 8:
  389. //if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, 0, TalentState::FST_SAVE, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS]) && $isMix != 1) {
  390. //$where[] = ["step", "=", 1]; //只查找人才第一步所需文件
  391. //} else {
  392. $where[] = ["isConditionFile", "<>", 1]; //排除人才条件上传文件
  393. //}
  394. if (($talent_condition && in_array($source, [3, 4, 5])) || $type == \app\common\state\CommonConst::ENTERPRISE_WJ || $type == \app\common\state\CommonConst::ENTERPRISE_GJ) {
  395. $condition_info = Db::table("new_talent_condition")->findOrEmpty($talent_condition);
  396. if ($condition_info["bindFileTypes"]) {
  397. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  398. }
  399. }
  400. break;
  401. case 20:
  402. //积分申报的附件需要特殊处理
  403. $newList = [];
  404. $_where = $where;
  405. $_where[] = ["isConditionFile", "=", 1];
  406. $fileTypes = Db::table("new_common_filetype")->where($_where)->order("must asc")->order("sn " . $order)->select()->toArray();
  407. foreach ($fileTypes as $k => $ft) {
  408. $_whr = [];
  409. if ($id) {
  410. $_whr[] = ["mainId", "=", $id];
  411. } else {
  412. $_whr[] = ["description", "=", $token];
  413. }
  414. $_whr[] = ["relationId", "=", 0];
  415. $_whr[] = ["typeId", "=", $ft["id"]];
  416. $files = Db::table("new_talent_file")->where($_whr)->field("id,typeId,orignName,url,relationId")->order("sn asc")->select()->toArray();
  417. foreach ($files as $n => $file) {
  418. $files[$n]["ext"] = pathinfo($file["url"])["extension"];
  419. $files[$n]["url"] = getStoragePath($file["url"]);
  420. }
  421. $fileTypes[$k]["files"] = $files;
  422. }
  423. $newList[] = [
  424. "id" => 0,
  425. "name" => "公共附件",
  426. "fileTypes" => $fileTypes
  427. ];
  428. $itemIds = $param["itemId"];
  429. $redis = \app\common\Redis::instance(\think\facade\Config::get("cache.stores.redis.select"));
  430. if ($itemIds) {
  431. foreach ($itemIds as $key => $item_id) {
  432. $integral_item = json_decode($redis->hGet("IntegralItem", $item_id), true);
  433. if ($integral_item["fileTypeId"]) {
  434. $typeIds = array_filter(explode(",", $integral_item["fileTypeId"]));
  435. $whr = $where;
  436. $whr[] = ["id", "in", $typeIds];
  437. $whr[] = ["isConditionFile", "=", 0];
  438. $fileTypes = Db::table("new_common_filetype")->where($whr)->order("must asc")->order("sn " . $order)->select()->toArray();
  439. foreach ($fileTypes as $k => $ft) {
  440. $_whr = [];
  441. if ($id) {
  442. $_whr[] = ["mainId", "=", $id];
  443. } else {
  444. $_whr[] = ["description", "=", $token];
  445. }
  446. $_whr[] = ["relationId", "=", $item_id];
  447. $_whr[] = ["typeId", "=", $ft["id"]];
  448. $files = Db::table("new_talent_file")->where($_whr)->field("id,typeId,orignName,url,relationId")->order("sn asc")->select()->toArray();
  449. foreach ($files as $n => $file) {
  450. $files[$n]["ext"] = pathinfo($file["url"])["extension"];
  451. $files[$n]["url"] = getStoragePath($file["url"]);
  452. }
  453. $fileTypes[$k]["files"] = $files;
  454. }
  455. $newList[] = [
  456. "id" => $integral_item["id"],
  457. "name" => $integral_item["name"],
  458. "fileTypes" => $fileTypes
  459. ];
  460. }
  461. }
  462. }
  463. return json(["rows" => $newList]);
  464. break;
  465. }
  466. if ($whr) {
  467. $rows = Db::table("new_common_filetype")->whereOr([$where, $whr])->order("must asc")->order("sn " . $order)->select()->toArray();
  468. } else {
  469. $rows = Db::table("new_common_filetype")->where($where)->order("must asc")->order("sn " . $order)->select()->toArray();
  470. }
  471. if ($project == ProjectState::JBT) {
  472. $allowanceInfo = \app\common\api\TalentAllowanceApi::getInfoById($id);
  473. $where = [];
  474. $where[] = ["enterpriseId", "=", $allowanceInfo["enterpriseId"]];
  475. $where[] = ["batch", "=", $allowanceInfo["year"]];
  476. $commonFiles = Db::table("un_talent_allowance_common_file")->alias("f")->leftJoin("new_common_filetype ft", "ft.id=f.fileTypeId")->field("f.*,ft.relationIds")->where($where)->select()->toArray();
  477. $relationIds = [];
  478. foreach ($commonFiles as $key => $row) {
  479. $_relationIds = array_filter(explode(",", $row["relationIds"]));
  480. $relationIds = array_merge($relationIds, $_relationIds);
  481. }
  482. foreach ($rows as $key => $row) {
  483. if (in_array($row["id"], $relationIds)) {
  484. $rows[$key]["must"] = 2;
  485. }
  486. }
  487. $rows = bubbleSort($rows, "must");
  488. }
  489. if ($id) {
  490. foreach ($rows as $key => $row) {
  491. $where = [];
  492. $where[] = ["mainId", "=", $id];
  493. $where[] = ["typeId", "=", $row["id"]];
  494. $files = Db::table("new_talent_file")->where($where)->field("id,typeId,orignName,url")->order("sn asc")->select()->toArray();
  495. foreach ($files as &$file) {
  496. $file["ext"] = pathinfo($file["url"])["extension"];
  497. $file["url"] = getStoragePath($file["url"]);
  498. }
  499. $rows[$key]["files"] = $files;
  500. }
  501. }
  502. $old_types = [];
  503. if ($showOldFile == 1) {
  504. $where = [];
  505. $where[] = ["type", "=", $type];
  506. $where[] = ["project", "=", $project];
  507. $where[] = ["active", "=", 1];
  508. $old_types = Db::table("un_common_filetype")->where($where)->order("must")->order("sn")->select()->toArray();
  509. }
  510. if ($old_types) {
  511. $rows = array_merge($rows, $old_types);
  512. }
  513. return json(["rows" => $rows, "old_types" => $old_types]);
  514. }
  515. public function listTalentFile() {
  516. $param = $this->request->param();
  517. $mainId = $param["mainId"];
  518. $typeId = $param["fileTypeId"];
  519. $where = [["mainId", "=", $mainId], ["typeId", "=", $typeId]];
  520. $list = Db::table("new_talent_file")->where($where)->select()->toArray();
  521. $_where = [["mainId", "=", $mainId], ["fileTypeId", "=", $typeId]];
  522. $old_list = Db::table("un_talent_file")->where($_where)->select()->toArray();
  523. if ($old_list) {
  524. $list = array_merge($list, $old_list);
  525. }
  526. foreach ($list as $key => $item) {
  527. $list[$key]["ext"] = pathinfo($item["url"])["extension"];
  528. $list[$key]["url"] = getStoragePath($item["url"]);
  529. }
  530. return json($list);
  531. }
  532. public function listNonPredefinedFiles() {
  533. $param = $this->request->param();
  534. $memo = $param["batch"];
  535. $fileTag = $param["fileTag"];
  536. $where = [["fileTag", "=", $fileTag], ["memo", "=", $memo]];
  537. $list = Db::table("new_non_predefined_file")->where($where)->select()->toArray();
  538. foreach ($list as $key => $item) {
  539. $list[$key]["ext"] = pathinfo($item["url"])["extension"];
  540. $list[$key]["url"] = getStoragePath($item["url"]);
  541. }
  542. return json(["rows" => $list]);
  543. }
  544. public function listTalentAllowanceCommonFile() {
  545. $param = $this->request->param();
  546. $id = $param["id"];
  547. $info = \app\common\api\TalentAllowanceApi::getInfoById($id);
  548. $list = [];
  549. if ($info) {
  550. $where = [["batch", "=", $info["year"]], ["enterpriseId", "=", $info["enterpriseId"]], ["fileTypeId", "<>", 0]];
  551. $list = Db::table("un_talent_allowance_common_file")->alias("f")->leftJoin("new_common_filetype ft", "ft.id=f.fileTypeId")->where($where)->field("f.*,ft.name as fileTypeName")->select()->toArray();
  552. foreach ($list as $key => $item) {
  553. $list[$key]["ext"] = pathinfo($item["url"])["extension"];
  554. $list[$key]["url"] = getStoragePath($item["url"]);
  555. }
  556. }
  557. return json(["rows" => $list]);
  558. }
  559. public function addTalentFile() {
  560. $backName = $this->request->param("backName");
  561. $fileId = $this->request->param("fileId");
  562. $mainId = $this->request->param("mainId");
  563. $fileTypeId = $this->request->param("fileTypeId");
  564. $relationId = $this->request->param("relationId");
  565. $pageToken = $this->request->param("pageToken");
  566. $index = $this->request->param("index");
  567. $type = $this->request->param("type");
  568. $upload = new \app\common\api\UploadApi();
  569. $file = $this->request->file("fileUrl");
  570. $isFileEditable = false;
  571. switch ($type) {
  572. case ProjectState::INTEGRAL:
  573. $isFileEditable = \app\common\api\IntegralRecordApi::checkIsEditable($mainId);
  574. break;
  575. default:
  576. $isFileEditable = TalentApi::checkIsEditable($mainId);
  577. break;
  578. }
  579. if (!$isFileEditable) {
  580. $res = ["msg" => "当前状态不能修改附件", "obj" => $index];
  581. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  582. exit();
  583. }
  584. $mime = $file->getMime();
  585. switch ($mime) {
  586. case "application/msword"://word
  587. case "application/vnd.openxmlformats-officedocument.wordprocessingml.document"://word
  588. case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"://xlsx
  589. case "application/pdf"://pdf
  590. case "application/vnd.ms-excel"://xls
  591. case "application/CDFV2"://wps版word
  592. $filestd = $upload->uploadOne($file, "file", "talent_files");
  593. break;
  594. case "image/jpg":
  595. case "image/jpeg":
  596. case "image/png":
  597. case "image/gif":
  598. $filestd = $upload->uploadOne($file, "image", "talent_files");
  599. break;
  600. case "application/zip":
  601. case "application/x-rar-compressed":
  602. case "application/x-7z-compressed":
  603. if (in_array($type, [ProjectState::JBT])) {
  604. $filestd = $upload->uploadOne($file, "hybrid", "talent_files");
  605. } else {
  606. $res = ["msg" => "不支持的附件类型", "obj" => $index];
  607. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  608. exit();
  609. }
  610. break;
  611. default:
  612. $res = ["msg" => "不支持的附件类型", "obj" => $index];
  613. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  614. exit();
  615. break;
  616. }
  617. $change = false;
  618. if ($fileId) {
  619. if (!$this->chkIsFileOwner($mainId, $type)) {
  620. $res = ["msg" => "删除失败", "obj" => $index];
  621. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  622. exit();
  623. }
  624. $old = Db::table("new_talent_file")->findOrEmpty($fileId);
  625. $old_filepath = "storage/" . $old["url"];
  626. if (file_exists($old_filepath))
  627. unlink($old_filepath);
  628. $data["id"] = $fileId;
  629. $change = true;
  630. }
  631. $data["mainId"] = $mainId;
  632. $data["relationId"] = $relationId;
  633. $data["description"] = $pageToken;
  634. $data["type"] = $type;
  635. $data["typeId"] = $fileTypeId;
  636. $data["orignName"] = $file->getOriginalName();
  637. $data["url"] = $filestd->filepath;
  638. $data["sn"] = $index;
  639. $data["createTime"] = date("Y-m-d H:i:s");
  640. if ($fileId) {
  641. Db::table("new_talent_file")->save($data);
  642. } else {
  643. $fileId = Db::table("new_talent_file")->insertGetId($data);
  644. }
  645. $ext = pathinfo($filestd->filepath)["extension"];
  646. TalentLogApi::write($type, $mainId, 0, sprintf("%s附件,附件名为:%s", $change ? "修改" : "添加", $data["orignName"]), 1, $fileTypeId, $fileId);
  647. $res = ["code" => 200, "msg" => "上传附件成功", "obj" => $index, "ext" => $ext, "info" => getStoragePath($filestd->filepath), "typeId" => $fileTypeId, "id" => $fileId, "orignName" => $data["orignName"]];
  648. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  649. }
  650. public function deleteFile() {
  651. $param = $this->request->param();
  652. $where = [["id", "=", $param["id"]]];
  653. $file = Db::table("new_talent_file")->where($where)->findOrEmpty();
  654. if (!TalentApi::checkIsEditable($file["mainId"]))
  655. return json(["msg" => "当前状态不能删除或者文件已删除,请刷新重试。"]);
  656. if ($this->chkIsFileOwner($file["mainId"], $file["type"])) {
  657. if (!empty($file["url"])) {
  658. $filepath = "storage/" . $file["url"];
  659. if (file_exists($filepath)) {
  660. unlink($filepath);
  661. }
  662. }
  663. Db::table("new_talent_file")->delete($file["id"]);
  664. TalentLogApi::write($file["type"], $file["mainId"], 0, sprintf("删除附件,附件名为:%s", $file["orignName"]), 1, $file["typeId"], $param["id"]);
  665. return json(["code" => 200, "msg" => "删除成功"]);
  666. }
  667. return json(["msg" => "不能删除"]);
  668. }
  669. public function deleteTalentCommonFile() {
  670. $param = $this->request->param();
  671. $where = [["id", "=", $param["id"]]];
  672. $file = Db::table("new_talent_common_file")->where($where)->findOrEmpty();
  673. $filepath = "storage/" . $file["url"];
  674. if (file_exists($filepath)) {
  675. unlink($filepath);
  676. }
  677. Db::table("new_talent_common_file")->delete($file["id"]);
  678. //TalentLogApi::write($file["type"], $file["mainId"], 0, sprintf("删除附件,附件名为:%s", $file["orignName"]), 1, $file["typeId"], $param["id"]);
  679. return json(["code" => 200, "msg" => "删除成功"]);
  680. return json(["msg" => "不能删除"]);
  681. }
  682. public function deleteNonPredefinedFile() {
  683. $param = $this->request->param();
  684. $where = [["id", "=", $param["id"]]];
  685. $file = Db::table("new_non_predefined_file")->where($where)->findOrEmpty();
  686. $filepath = "storage/" . $file["url"];
  687. if (file_exists($filepath) && $file["url"]) {
  688. @unlink($filepath);
  689. }
  690. Db::table("new_non_predefined_file")->delete($file["id"]);
  691. return json(["code" => 200, "msg" => "删除成功"]);
  692. }
  693. /**
  694. * 下载文件
  695. */
  696. public function downloadFile() {
  697. $param = $this->request->param();
  698. $type = $param["type"];
  699. $id = $param["id"];
  700. $where = [];
  701. $where[] = ["id", "=", $id];
  702. $url = "";
  703. switch ($type) {
  704. case 1:
  705. case 2:
  706. case 8:
  707. case 19:
  708. $fileinfo = Db::table("new_talent_file")->where($where)->findOrEmpty();
  709. $filename = $fileinfo["orignName"];
  710. $url = $fileinfo["url"];
  711. break;
  712. case 3:
  713. $fileinfo = Db::table("new_currency_filetype")->where($where)->findOrEmpty();
  714. $filename = $fileinfo["templateUrl"];
  715. $url = $fileinfo["templateUrl"];
  716. break;
  717. case 4:
  718. $fileinfo = Db::table("sys_common_file")->where($where)->findOrEmpty();
  719. $filename = $fileinfo["orignName"];
  720. $url = $fileinfo["url"];
  721. break;
  722. case 5:
  723. $fileinfo = Db::table("new_common_filetype")->where($where)->findOrEmpty();
  724. $filename = $fileinfo["templateUrl"];
  725. $url = $fileinfo["templateUrl"];
  726. break;
  727. case 6://预定义外的文件类型下载
  728. $fileinfo = Db::table("new_non_predefined_file")->where($where)->findOrEmpty();
  729. $filename = $fileinfo["originalName"];
  730. $url = $fileinfo["url"];
  731. break;
  732. }
  733. $filepath = "storage/" . $url; // 下载文件名
  734. if (!file_exists($filepath)) {
  735. header('HTTP/1.1 404 NOT FOUND');
  736. } else {
  737. $file = fopen($filepath, "rb");
  738. Header("Content-type: application/octet-stream");
  739. Header("Accept-Ranges: bytes");
  740. Header("Accept-Length: " . filesize($filepath));
  741. Header("Content-Disposition: attachment; filename=" . $filename);
  742. echo fread($file, filesize($filepath));
  743. fclose($file);
  744. exit();
  745. }
  746. }
  747. /**
  748. * 打包下载人才申请附件
  749. */
  750. public function downloadZip() {
  751. $table = "new_talent_file";
  752. $param = $this->request->param();
  753. $type = $param["type"];
  754. $id = $param["id"];
  755. $where = [];
  756. switch ($type) {
  757. case ProjectState::TALENT:
  758. $where[] = ["type", "=", $type];
  759. $talent_info = \app\enterprise\model\Talent::findOrEmpty($id);
  760. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  761. $zip_filename = sprintf("%s(%s)人才申报材料.zip", $talent_info["name"], $enterprise_info["name"]);
  762. break;
  763. case ProjectState::JBT:
  764. $where[] = ["type", "=", $type];
  765. $info = \app\common\model\TalentAllowance::findOrEmpty($id);
  766. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  767. $zip_filename = sprintf("%s(%s)津补贴申报材料.zip", $info["talentName"], $enterprise_info["name"]);
  768. break;
  769. case ProjectState::QUIT:
  770. $table = "new_talent_common_file";
  771. $info = \app\common\model\TalentQuit::findOrEmpty($id);
  772. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  773. $zip_filename = sprintf("%s(%s)离职材料.zip", $info["talentName"], $enterprise_info["name"]);
  774. break;
  775. case ProjectState::WORKCHANGE:
  776. $table = "new_talent_common_file";
  777. $info = \app\common\model\TalentWorkUnitChange::findOrEmpty($id);
  778. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  779. $zip_filename = sprintf("%s(%s)工作单位变更材料.zip", $info["talentName"], $enterprise_info["name"]);
  780. break;
  781. case ProjectState::LEVELCHANGE:
  782. $info = \app\enterprise\model\TalentTypeChange::findOrEmpty($id);
  783. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  784. $zip_filename = sprintf("%s(%s)人才层次变更材料.zip", $info["talentName"], $enterprise_info["name"]);
  785. break;
  786. case ProjectState::INTEGRAL:
  787. $where[] = ["type", "=", $type];
  788. $record = \app\common\api\IntegralRecordApi::getOne($id);
  789. $zip_filename = sprintf("%s(%s)积分申报材料.zip", $record["name"], $record["enterprise"]["name"]);
  790. break;
  791. case 109:
  792. $table = "un_enterpriseclose_record";
  793. $record = \app\common\model\EnterpriseCloseAccount::where("id", $id)->find();
  794. $zip_filename = sprintf("%s(%s)注销申请材料.zip", $record["name"], $record["username"]);
  795. $files = json_decode($record["files"], true);
  796. break;
  797. }
  798. $where[] = ["mainId", "=", $id];
  799. if (!$files)
  800. $files = Db::table($table)->where($where)->select()->toArray();
  801. if (!$files) {
  802. //die("没有附件不能打包下载");
  803. echo "<script>parent.layer.alert('没有附件不能打包下载');window.history.go(-1);</script>";
  804. }
  805. $tmp_path = "storage/temp/";
  806. $tmp_file_path = $tmp_path . $zip_filename;
  807. if (!file_exists($tmp_path)) {
  808. mkdir($tmp_path);
  809. }
  810. $zip = new \ZipArchive();
  811. if (!$zip->open($tmp_file_path, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
  812. header('HTTP/1.1 404 NOT FOUND');
  813. }
  814. foreach ($files as $file) {
  815. if (is_array($file)) {
  816. $filepath = "storage/" . $file["url"];
  817. $fileTypeInfo = Db::table("new_common_filetype")->where("id", $file["typeId"])->find();
  818. $filename = $fileTypeInfo["name"] . "/" . $file["orignName"];
  819. $zip->addFile($filepath, $filename);
  820. } else {
  821. $filepath = "storage/" . $file;
  822. $filename = basename($filepath);
  823. $zip->addFile($filepath, $filename);
  824. }
  825. }
  826. $zip->close();
  827. if (file_exists($tmp_file_path)) {
  828. header("Cache-Control: public");
  829. header("Content-Description: File Transfer");
  830. header('Content-disposition: attachment; filename=' . $zip_filename); //文件名
  831. header("Content-Type: application/octet-stream;charset=utf-8"); //zip格式的
  832. header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件
  833. header('Content-Length: ' . filesize($tmp_file_path)); //告诉浏览器,文件大小
  834. @readfile($tmp_file_path);
  835. }
  836. //删除临时文件
  837. @unlink($tmp_file_path);
  838. }
  839. /**
  840. * 打包下载人才申请附件
  841. */
  842. public function downloadCommonZip() {
  843. $table = "un_talent_allowance_common_file";
  844. $param = $this->request->param();
  845. $id = $param["id"];
  846. $year = $param["year"];
  847. $info = \app\common\model\TalentAllowance::findOrEmpty($id);
  848. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  849. $zip_filename = sprintf("%s(%s)津补贴申报通用材料.zip", $info["talentName"], $enterprise_info["name"]);
  850. $where = [];
  851. $where[] = ["enterpriseId", "=", $info["enterpriseId"]];
  852. $where[] = ["batch", "=", $year];
  853. $files = Db::table($table)->where($where)->select()->toArray();
  854. if (!$files) {
  855. //die("没有附件不能打包下载");
  856. echo "<script>parent.layer.alert('没有附件不能打包下载');window.history.go(-1);</script>";
  857. }
  858. $tmp_path = "storage/temp/";
  859. $tmp_file_path = $tmp_path . $zip_filename;
  860. if (!file_exists($tmp_path)) {
  861. mkdir($tmp_path);
  862. }
  863. $zip = new \ZipArchive();
  864. if (!$zip->open($tmp_file_path, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
  865. header('HTTP/1.1 404 NOT FOUND');
  866. }
  867. foreach ($files as $file) {
  868. if (is_array($file)) {
  869. $filepath = "storage/" . $file["url"];
  870. $fileTypeInfo = Db::table("new_common_filetype")->where("id", $file["fileTypeId"])->find();
  871. $filename = $fileTypeInfo["name"] . "/" . $file["originalName"];
  872. $zip->addFile($filepath, $filename);
  873. } else {
  874. $filepath = "storage/" . $file;
  875. $filename = basename($filepath);
  876. $zip->addFile($filepath, $filename);
  877. }
  878. }
  879. $zip->close();
  880. if (file_exists($tmp_file_path)) {
  881. header("Cache-Control: public");
  882. header("Content-Description: File Transfer");
  883. header('Content-disposition: attachment; filename=' . $zip_filename); //文件名
  884. header("Content-Type: application/octet-stream;charset=utf-8"); //zip格式的
  885. header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件
  886. header('Content-Length: ' . filesize($tmp_file_path)); //告诉浏览器,文件大小
  887. @readfile($tmp_file_path);
  888. }
  889. //删除临时文件
  890. @unlink($tmp_file_path);
  891. }
  892. private function chkIsFileOwner($mainId, $type) {
  893. if (!$mainId)
  894. return true;
  895. switch ($type) {
  896. case ProjectState::TALENT:
  897. if ($this->user["usertype"] == 2) {
  898. $user_id = $this->user["uid"];
  899. $talent_info = Db::table("new_talent_info")->findOrEmpty($mainId);
  900. if ($user_id == $talent_info["enterprise_id"])
  901. return true;
  902. }
  903. break;
  904. case ProjectState::JBT:
  905. if ($this->user["usertype"] == 2) {
  906. $user_id = $this->user["uid"];
  907. $talent_info = \app\common\model\TalentAllowance::findOrEmpty($mainId);
  908. if ($user_id == $talent_info["enterpriseId"])
  909. return true;
  910. }
  911. if ($this->user["usertype"] == 1) {
  912. return true;
  913. }
  914. break;
  915. case ProjectState::EDUCATION:
  916. if ($this->user["usertype"] == 3) {
  917. $user_id = $this->user["uid"];
  918. $talent_info = \app\common\model\EducationSchool::findOrEmpty($mainId);
  919. if ($user_id == $talent_info["personId"])
  920. return true;
  921. }
  922. break;
  923. case ProjectState::LEVELCHANGE:
  924. if ($this->user["usertype"] == 2) {
  925. $user_id = $this->user["uid"];
  926. $talent_info = \app\enterprise\model\TalentTypeChange::findOrEmpty($mainId);
  927. if ($user_id == $talent_info["enterpriseId"])
  928. return true;
  929. }
  930. break;
  931. case ProjectState::LIVINGALLOWANCE:
  932. if ($this->user["usertype"] == 2) {
  933. $user_id = $this->user["uid"];
  934. $record = Db::table("md_living_allowance_info")->findOrEmpty($mainId);
  935. if ($user_id == $record["enterpriseId"])
  936. return true;
  937. }
  938. break;
  939. case ProjectState::INTEGRAL:
  940. if ($this->user["usertype"] == 2) {
  941. $user_id = $this->user["uid"];
  942. $record = Db::table("new_integral_record")->findOrEmpty($mainId);
  943. if ($user_id == $record["enterprise_id"])
  944. return true;
  945. }
  946. break;
  947. case ProjectState::BASICCHANGE:
  948. if ($this->user["usertype"] == 2) {
  949. $user_id = $this->user["uid"];
  950. $record = Db::table("un_talent_basic_change")->findOrEmpty($mainId);
  951. if ($user_id == $record["enterpriseId"])
  952. return true;
  953. }
  954. break;
  955. }
  956. return false;
  957. }
  958. public function getCompanyKvs() {
  959. $companys = \app\common\model\Company::field("name,id")->select();
  960. return json($companys);
  961. }
  962. public function getEnterpriseKvs() {
  963. $where[] = ["type", "=", $this->user["type"]];
  964. $enterprises = \app\common\model\Enterprise::field("name,id")->where($where)->select();
  965. return json($enterprises);
  966. }
  967. public function getLayerCatsByLayer() {
  968. $lv = $this->request->param("level");
  969. return json(DictApi::getLayerCatsByLayer($lv));
  970. }
  971. /**
  972. * 通过人才类别查找人才认定第二步骤支持的所有文件类型
  973. * 默认人才认定第二步骤,当前只有人才认定分了两步,所以此方法目前默认参数高度匹配人才认定第二阶段附件的查找
  974. */
  975. public function getConditionFileTypesByType() {
  976. $params = $this->request->param();
  977. $type = $params["type"]; //人才类型不默认,需要传
  978. $declare_type = $params["project"] ?: 1; //默认人才认定
  979. $active = $params["active"] ?: 1; //默认查找启用的附件
  980. $where[] = ["type", "=", $type];
  981. $where[] = ["project", "=", $declare_type];
  982. $where[] = ["active", "=", $active];
  983. $where[] = ["delete", "=", 0];
  984. $where[] = ["isConditionFile", "=", 1];
  985. $list = Db::table("new_common_filetype")->where($where)->order("sn " . $order)->select()->toArray();
  986. return json($list);
  987. }
  988. public function listCurrencyFileType() {
  989. $where = [
  990. 'type' => $this->request['type'],
  991. 'active' => 1
  992. ];
  993. $rows = CurrentcyFileType::where($where)->select();
  994. return json(["rows" => $rows, 'total' => count($rows)]);
  995. }
  996. public function listTalentCommonFile() {
  997. $where = [];
  998. if (\StrUtil::isNotEmpAndNull($this->request['mainId'])) {
  999. $where[] = ['mainId', '=', $this->request['mainId']];
  1000. }
  1001. if (\StrUtil::isNotEmpAndNull($this->request['typeId'])) {
  1002. $where[] = ['typeId', '=', $this->request['typeId']];
  1003. }
  1004. $res = TalentCommonFile::where($where)->order('sn')->select()->toArray();
  1005. if (\StrUtil::isNotEmpAndNull($this->request['mainId']) && \StrUtil::isNotEmpAndNull($this->request['typeId'])) {
  1006. $_where = [["mainId", "=", $this->request['mainId']], ["typeId", "=", $this->request['typeId']]];
  1007. $old_list = Db::table("un_talent_common_file")->where($_where)->select()->toArray();
  1008. }
  1009. if ($old_list) {
  1010. $res = array_merge($res, $old_list);
  1011. }
  1012. if ($res) {
  1013. foreach ($res as $k => &$v) {
  1014. $v["ext"] = pathinfo($v["url"])["extension"];
  1015. $v['url'] = getStoragePath($v['url']);
  1016. }
  1017. }
  1018. return json($res);
  1019. }
  1020. public function addTalentCommonFile() {
  1021. $backName = \StrUtil::getRequestDecodeParam($this->request, 'backName');
  1022. $id = \StrUtil::getRequestDecodeParam($this->request, "fileId");
  1023. $mainId = \StrUtil::getRequestDecodeParam($this->request, "mainId");
  1024. $typeId = \StrUtil::getRequestDecodeParam($this->request, "typeId");
  1025. $index = \StrUtil::getRequestDecodeParam($this->request, "index");
  1026. if ($backName == "EpChangeEdit.callBack") {
  1027. $type = 1;
  1028. $error = "文件格式不正确,只能上传图片";
  1029. } else {
  1030. $type = 4;
  1031. $error = "文件格式不正确,只能上传pdf和图片";
  1032. }
  1033. $uploadapi = new UploadApi();
  1034. $file_check_res = $uploadapi->uploadOne($this->request->file('fileUrl'), 'system');
  1035. if ($file_check_res->code == 500) {
  1036. $file_check_res->obj = $index;
  1037. return \StrUtil::back($file_check_res, $backName);
  1038. }
  1039. $file_data = [
  1040. 'id' => getStringId(),
  1041. 'mainId' => $mainId,
  1042. 'typeId' => $typeId,
  1043. 'orignName' => $this->request->file('fileUrl')->getOriginalName(),
  1044. 'url' => $file_check_res->filepath
  1045. ];
  1046. if (\StrUtil::isEmpOrNull($id)) {
  1047. $tc = TalentCommonFile::where('mainId', $mainId)->where('typeId', $typeId)->order('sn', 'desc')->findOrEmpty();
  1048. if ($tc) {
  1049. $file_data['sn'] = $tc['sn'] + 1;
  1050. } else {
  1051. $file_data['sn'] = 1;
  1052. }
  1053. $file_data['createTime'] = date("Y-m-d H:i:s");
  1054. TalentCommonFile::create($file_data);
  1055. $response_object = new \StdClass();
  1056. $response_object->code = 200;
  1057. $response_object->msg = "附件上传成功!";
  1058. $response_object->obj = $index;
  1059. return \StrUtil::back($response_object, $backName);
  1060. } else {
  1061. $tf = TalentCommonFile::findOrEmpty($id);
  1062. $tf->originalName = $file_data['orignName'];
  1063. $tf->updateTime = date("Y-m-d H:i:s");
  1064. $tf->url = $file_check_res->filepath;
  1065. $tf->save();
  1066. $response_object = new \StdClass();
  1067. $response_object->code = 200;
  1068. $response_object->msg = "附件修改成功!";
  1069. $response_object->obj = $index;
  1070. return \StrUtil::back($response_object, $backName);
  1071. }
  1072. }
  1073. public function changePwd() {
  1074. $password = \StrUtil::getRequestDecodeParam($this->request, 'password');
  1075. $newPassword = \StrUtil::getRequestDecodeParam($this->request, 'newPassword');
  1076. //数据校验(原密码与新密码不能为空)
  1077. if (\StrUtil::isEmpOrNull($password)) {
  1078. return json(['code' => 500, 'msg' => "请填写原密码!"]);
  1079. }
  1080. if (\StrUtil::isEmpOrNull($newPassword)) {
  1081. return json(['code' => 500, 'msg' => "请填写新密码!"]);
  1082. }
  1083. try {
  1084. validate(Enterprise::class)->batch(true)->scene('changePwd')->check(['password' => $password, 'password' => $newPassword]);
  1085. $ep = EnterpriseApi::getOne(session("user")['uid']);
  1086. if (!$ep) {
  1087. return json(['code' => 500, 'msg' => "请刷新页面后重试!"]);
  1088. }
  1089. if ($ep->password != hash('md5', $password)) {
  1090. return json(['code' => 500, 'msg' => "旧密码不正确!"]);
  1091. }
  1092. $ep->password = hash('md5', $newPassword);
  1093. $ep->updateUser = session("user")['uid'];
  1094. $ep->updateTime = date("Y-m-d H:i:s");
  1095. $ep->save();
  1096. TalentChecklog::create([
  1097. 'id' => getStringId(),
  1098. 'category' => 'enterprise_change',
  1099. 'mainId' => $ep->id,
  1100. 'type' => 10,
  1101. 'typeFileId' => null,
  1102. 'active' => 1,
  1103. 'state' => 1,
  1104. 'step' => 100,
  1105. 'stateChange' => null,
  1106. 'description' => '用户修改密码',
  1107. 'createTime' => date("Y-m-d H:i:s", time()),
  1108. 'createUser' => '用户'
  1109. ]);
  1110. return json(['code' => 200, 'msg' => "修改成功!"]);
  1111. } catch (ValidateException $e) {
  1112. $error = $e->getError();
  1113. return json(['code' => 500, 'msg' => array_pop($error)]);
  1114. }
  1115. }
  1116. function getIntegralRecordByIdCard() {
  1117. $cardType = $this->request->param("cardType");
  1118. $cardNumber = $this->request->param("cardNumber");
  1119. $tips = \app\common\api\IntegralRecordApi::getIntegralRecordByIdCard($cardType, $cardNumber);
  1120. return json(["tips" => $tips]);
  1121. }
  1122. function getIntegralProjectsByType() {
  1123. $projectType = $this->request->param("projectType") ?: 0;
  1124. if (session("user")["usertype"] == 2) {
  1125. $where[] = ["type", "=", 2];
  1126. } else {
  1127. $type = $this->request->param("type") ?: 0;
  1128. $where[] = ["type", "=", $type];
  1129. }
  1130. $where[] = ["projectType", "=", $projectType];
  1131. $where[] = ["active", "=", 1];
  1132. $list = \app\common\api\IntegralProjectApi::getAll($where);
  1133. return json($list);
  1134. }
  1135. public function getIntegralItemsByProject() {
  1136. $projectId = $this->request->param("projectId") ?: 0;
  1137. $where[] = ["projectId", "=", $projectId];
  1138. $where[] = ["active", "=", 1];
  1139. $list = \app\common\api\IntegralItemApi::getAll($where);
  1140. return json($list);
  1141. }
  1142. public function calIntegral() {
  1143. $params = $this->request->param();
  1144. $enterpriseId = $params["enterpriseId"];
  1145. $cardType = $params["cardType"];
  1146. $cardNumber = $params["cardNumber"];
  1147. $itemId = $params["itemId"];
  1148. $amount = $params["amount"];
  1149. if (session("user")["usertype"] == 2) {
  1150. //企业端只能通过企业自身id来查询积分
  1151. $enterpriseId = session("user")["uid"];
  1152. }
  1153. return json(\app\common\api\IntegralRecordApi::calIntegral($enterpriseId, $cardType, $cardNumber, $itemId, $amount));
  1154. }
  1155. public function imgViewer() {
  1156. $img = urldecode($this->request["picShow"]);
  1157. return view("", ["img" => $img]);
  1158. }
  1159. public function gotoFileShow() {
  1160. return view("admin@talent/filesShow");
  1161. }
  1162. public function getJbtFiletypesExceptCommon() {
  1163. $type = $this->user["type"];
  1164. $where[] = ["type", "=", $type];
  1165. $where[] = ["project", "=", 2];
  1166. $where[] = ["isConditionFile", "in", [1, 2]];
  1167. $fileTypes = \app\common\api\FileTypeApi::getAll($where);
  1168. foreach ($fileTypes as &$ft) {
  1169. $ft["name"] = sprintf("%s(%s)", $ft["name"], \app\common\state\AllowanceTypeEnum::getTypeName($ft["isConditionFile"]));
  1170. }
  1171. return json($fileTypes);
  1172. }
  1173. public function findContractFileType() {
  1174. $type = $this->request["type"];
  1175. $where[] = ["name", "like", "%工作%"];
  1176. $where[] = ["project", "=", 1];
  1177. $where[] = ["active", "=", 1];
  1178. $where[] = ["isConditionFile", "<>", 1];
  1179. $where[] = ["delete", "=", 0];
  1180. $where[] = ["type", "=", $type];
  1181. $rows = Db::table("new_common_filetype")->where($where)->order("must asc")->order("sn asc")->select()->toArray();
  1182. return json(["rows" => $rows]);
  1183. }
  1184. public function contractView() {
  1185. $id = $this->request["id"];
  1186. $talentInfo = \app\common\api\VerifyApi::getTalentInfoById($id);
  1187. $type = $talentInfo["enterpriseType"];
  1188. return view("", ["id" => $talentInfo["id"], "type" => $type]);
  1189. }
  1190. public function getEnterpriseData() {
  1191. }
  1192. }