Api.php 52 KB

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