Api.php 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082
  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 1:
  381. case 8:
  382. //if (in_array($checkState, [TalentState::BASE_VERIFY_FAIL, 0, TalentState::FST_SAVE, TalentState::FST_SUBMIT, TalentState::BASE_VERIFY_PASS]) && $isMix != 1) {
  383. //$where[] = ["step", "=", 1]; //只查找人才第一步所需文件
  384. //} else {
  385. $where[] = ["isConditionFile", "<>", 1]; //排除人才条件上传文件
  386. //}
  387. if (($talent_condition && in_array($source, [3, 4, 5])) || $type == \app\common\state\CommonConst::ENTERPRISE_WJ || $type == \app\common\state\CommonConst::ENTERPRISE_GJ) {
  388. $condition_info = Db::table("new_talent_condition")->findOrEmpty($talent_condition);
  389. if ($condition_info["bindFileTypes"]) {
  390. $whr[] = ["id", "in", $condition_info["bindFileTypes"]];
  391. }
  392. }
  393. break;
  394. case 20:
  395. //积分申报的附件需要特殊处理
  396. $newList = [];
  397. $_where = $where;
  398. $_where[] = ["isConditionFile", "=", 1];
  399. $fileTypes = Db::table("new_common_filetype")->where($_where)->order("must asc")->order("sn " . $order)->select()->toArray();
  400. foreach ($fileTypes as $k => $ft) {
  401. $_whr = [];
  402. if ($id) {
  403. $_whr[] = ["mainId", "=", $id];
  404. } else {
  405. $_whr[] = ["description", "=", $token];
  406. }
  407. $_whr[] = ["relationId", "=", 0];
  408. $_whr[] = ["typeId", "=", $ft["id"]];
  409. $files = Db::table("new_talent_file")->where($_whr)->field("id,typeId,orignName,url,relationId")->order("sn asc")->select()->toArray();
  410. foreach ($files as $n => $file) {
  411. $files[$n]["ext"] = pathinfo($file["url"])["extension"];
  412. $files[$n]["url"] = getStoragePath($file["url"]);
  413. }
  414. $fileTypes[$k]["files"] = $files;
  415. }
  416. $newList[] = [
  417. "id" => 0,
  418. "name" => "公共附件",
  419. "fileTypes" => $fileTypes
  420. ];
  421. $itemIds = $param["itemId"];
  422. $redis = \app\common\Redis::instance(\think\facade\Config::get("cache.stores.redis.select"));
  423. if ($itemIds) {
  424. foreach ($itemIds as $key => $item_id) {
  425. $integral_item = json_decode($redis->hGet("IntegralItem", $item_id), true);
  426. if ($integral_item["fileTypeId"]) {
  427. $typeIds = array_filter(explode(",", $integral_item["fileTypeId"]));
  428. $whr = $where;
  429. $whr[] = ["id", "in", $typeIds];
  430. $whr[] = ["isConditionFile", "=", 0];
  431. $fileTypes = Db::table("new_common_filetype")->where($whr)->order("must asc")->order("sn " . $order)->select()->toArray();
  432. foreach ($fileTypes as $k => $ft) {
  433. $_whr = [];
  434. if ($id) {
  435. $_whr[] = ["mainId", "=", $id];
  436. } else {
  437. $_whr[] = ["description", "=", $token];
  438. }
  439. $_whr[] = ["relationId", "=", $item_id];
  440. $_whr[] = ["typeId", "=", $ft["id"]];
  441. $files = Db::table("new_talent_file")->where($_whr)->field("id,typeId,orignName,url,relationId")->order("sn asc")->select()->toArray();
  442. foreach ($files as $n => $file) {
  443. $files[$n]["ext"] = pathinfo($file["url"])["extension"];
  444. $files[$n]["url"] = getStoragePath($file["url"]);
  445. }
  446. $fileTypes[$k]["files"] = $files;
  447. }
  448. $newList[] = [
  449. "id" => $integral_item["id"],
  450. "name" => $integral_item["name"],
  451. "fileTypes" => $fileTypes
  452. ];
  453. }
  454. }
  455. }
  456. return json(["rows" => $newList]);
  457. break;
  458. }
  459. if ($whr) {
  460. $rows = Db::table("new_common_filetype")->whereOr([$where, $whr])->order("must asc")->order("sn " . $order)->select()->toArray();
  461. } else {
  462. $rows = Db::table("new_common_filetype")->where($where)->order("must asc")->order("sn " . $order)->select()->toArray();
  463. }
  464. if ($id) {
  465. foreach ($rows as $key => $row) {
  466. $where = [];
  467. $where[] = ["mainId", "=", $id];
  468. $where[] = ["typeId", "=", $row["id"]];
  469. $files = Db::table("new_talent_file")->where($where)->field("id,typeId,orignName,url")->order("sn asc")->select()->toArray();
  470. foreach ($files as &$file) {
  471. $file["ext"] = pathinfo($file["url"])["extension"];
  472. $file["url"] = getStoragePath($file["url"]);
  473. }
  474. $rows[$key]["files"] = $files;
  475. }
  476. }
  477. $old_types = [];
  478. if ($project == ProjectState::LEVELCHANGE) {
  479. $where = [];
  480. $where[] = ["type", "=", $type];
  481. $where[] = ["project", "=", $project];
  482. $where[] = ["active", "=", 1];
  483. //$old_types = Db::table("un_common_filetype")->where($where)->order("must")->order("sn")->select()->toArray();
  484. }
  485. if ($old_types) {
  486. $rows = array_merge($rows, $old_types);
  487. }
  488. return json(["rows" => $rows, "old_types" => $old_types]);
  489. }
  490. public function listTalentFile() {
  491. $param = $this->request->param();
  492. $mainId = $param["mainId"];
  493. $typeId = $param["fileTypeId"];
  494. $where = [["mainId", "=", $mainId], ["typeId", "=", $typeId]];
  495. $list = Db::table("new_talent_file")->where($where)->select()->toArray();
  496. $_where = [["mainId", "=", $mainId], ["fileTypeId", "=", $typeId]];
  497. $old_list = Db::table("un_talent_file")->where($_where)->select()->toArray();
  498. if ($old_list) {
  499. $list = array_merge($list, $old_list);
  500. }
  501. foreach ($list as $key => $item) {
  502. $list[$key]["ext"] = pathinfo($item["url"])["extension"];
  503. $list[$key]["url"] = getStoragePath($item["url"]);
  504. }
  505. return json($list);
  506. }
  507. public function listNonPredefinedFiles() {
  508. $param = $this->request->param();
  509. $memo = $param["batch"];
  510. $fileTag = $param["fileTag"];
  511. $where = [["fileTag", "=", $fileTag], ["memo", "=", $memo]];
  512. $list = Db::table("new_non_predefined_file")->where($where)->select()->toArray();
  513. foreach ($list as $key => $item) {
  514. $list[$key]["ext"] = pathinfo($item["url"])["extension"];
  515. $list[$key]["url"] = getStoragePath($item["url"]);
  516. }
  517. return json(["rows" => $list]);
  518. }
  519. public function addTalentFile() {
  520. $backName = $this->request->param("backName");
  521. $fileId = $this->request->param("fileId");
  522. $mainId = $this->request->param("mainId");
  523. $fileTypeId = $this->request->param("fileTypeId");
  524. $relationId = $this->request->param("relationId");
  525. $pageToken = $this->request->param("pageToken");
  526. $index = $this->request->param("index");
  527. $type = $this->request->param("type");
  528. $upload = new \app\common\api\UploadApi();
  529. $file = $this->request->file("fileUrl");
  530. $isFileEditable = false;
  531. switch ($type) {
  532. case ProjectState::INTEGRAL:
  533. $isFileEditable = \app\common\api\IntegralRecordApi::checkIsEditable($mainId);
  534. break;
  535. default:
  536. $isFileEditable = TalentApi::checkIsEditable($mainId);
  537. break;
  538. }
  539. if (!$isFileEditable) {
  540. $res = ["msg" => "当前状态不能修改附件", "obj" => $index];
  541. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  542. exit();
  543. }
  544. $mime = $file->getMime();
  545. switch ($mime) {
  546. case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"://xlsx
  547. case "application/pdf"://pdf
  548. case "application/vnd.ms-excel"://xls
  549. $filestd = $upload->uploadOne($file, "file", "talent_files");
  550. break;
  551. case "image/jpg":
  552. case "image/jpeg":
  553. case "image/png":
  554. case "image/gif":
  555. $filestd = $upload->uploadOne($file, "image", "talent_files");
  556. break;
  557. default:
  558. $res = ["msg" => "不支持的附件类型", "obj" => $index];
  559. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  560. exit();
  561. break;
  562. }
  563. $change = false;
  564. if ($fileId) {
  565. if (!$this->chkIsFileOwner($mainId, $type)) {
  566. $res = ["msg" => "删除失败", "obj" => $index];
  567. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  568. exit();
  569. }
  570. $old = Db::table("new_talent_file")->findOrEmpty($fileId);
  571. $old_filepath = "storage/" . $old["url"];
  572. if (file_exists($old_filepath))
  573. unlink($old_filepath);
  574. $data["id"] = $fileId;
  575. $change = true;
  576. }
  577. $data["mainId"] = $mainId;
  578. $data["relationId"] = $relationId;
  579. $data["description"] = $pageToken;
  580. $data["type"] = $type;
  581. $data["typeId"] = $fileTypeId;
  582. $data["orignName"] = $file->getOriginalName();
  583. $data["url"] = $filestd->filepath;
  584. $data["sn"] = $index;
  585. $data["createTime"] = date("Y-m-d H:i:s");
  586. if ($fileId) {
  587. Db::table("new_talent_file")->save($data);
  588. } else {
  589. $fileId = Db::table("new_talent_file")->insertGetId($data);
  590. }
  591. $ext = pathinfo($filestd->filepath)["extension"];
  592. TalentLogApi::write($type, $mainId, 0, sprintf("%s附件,附件名为:%s", $change ? "修改" : "添加", $data["orignName"]), 1, $fileTypeId, $fileId);
  593. $res = ["code" => 200, "msg" => "上传附件成功", "obj" => $index, "ext" => $ext, "info" => getStoragePath($filestd->filepath), "typeId" => $fileTypeId, "id" => $fileId, "orignName" => $data["orignName"]];
  594. echo sprintf("<script>parent.%s(%s);</script>", $backName, json_encode($res));
  595. }
  596. public function deleteFile() {
  597. $param = $this->request->param();
  598. $where = [["id", "=", $param["id"]]];
  599. $file = Db::table("new_talent_file")->where($where)->findOrEmpty();
  600. if (!TalentApi::checkIsEditable($file["mainId"]))
  601. return json(["msg" => "当前状态不能删除或者文件已删除,请刷新重试。"]);
  602. if ($this->chkIsFileOwner($file["mainId"], $file["type"])) {
  603. if (!empty($file["url"])) {
  604. $filepath = "storage/" . $file["url"];
  605. if (file_exists($filepath)) {
  606. unlink($filepath);
  607. }
  608. }
  609. Db::table("new_talent_file")->delete($file["id"]);
  610. TalentLogApi::write($file["type"], $file["mainId"], 0, sprintf("删除附件,附件名为:%s", $file["orignName"]), 1, $file["typeId"], $param["id"]);
  611. return json(["code" => 200, "msg" => "删除成功"]);
  612. }
  613. return json(["msg" => "不能删除"]);
  614. }
  615. public function deleteTalentCommonFile() {
  616. $param = $this->request->param();
  617. $where = [["id", "=", $param["id"]]];
  618. $file = Db::table("new_talent_common_file")->where($where)->findOrEmpty();
  619. $filepath = "storage/" . $file["url"];
  620. if (file_exists($filepath)) {
  621. unlink($filepath);
  622. }
  623. Db::table("new_talent_common_file")->delete($file["id"]);
  624. //TalentLogApi::write($file["type"], $file["mainId"], 0, sprintf("删除附件,附件名为:%s", $file["orignName"]), 1, $file["typeId"], $param["id"]);
  625. return json(["code" => 200, "msg" => "删除成功"]);
  626. return json(["msg" => "不能删除"]);
  627. }
  628. public function deleteNonPredefinedFile() {
  629. $param = $this->request->param();
  630. $where = [["id", "=", $param["id"]]];
  631. $file = Db::table("new_non_predefined_file")->where($where)->findOrEmpty();
  632. $filepath = "storage/" . $file["url"];
  633. if (file_exists($filepath) && $file["url"]) {
  634. @unlink($filepath);
  635. }
  636. Db::table("new_non_predefined_file")->delete($file["id"]);
  637. return json(["code" => 200, "msg" => "删除成功"]);
  638. }
  639. /**
  640. * 下载文件
  641. */
  642. public function downloadFile() {
  643. $param = $this->request->param();
  644. $type = $param["type"];
  645. $id = $param["id"];
  646. $where = [];
  647. $where[] = ["id", "=", $id];
  648. $url = "";
  649. switch ($type) {
  650. case 1:
  651. case 8:
  652. case 19:
  653. $fileinfo = Db::table("new_talent_file")->where($where)->findOrEmpty();
  654. $filename = $fileinfo["orignName"];
  655. $url = $fileinfo["url"];
  656. break;
  657. case 2:
  658. $fileinfo = Db::table("new_talent_common_file")->where($where)->findOrEmpty();
  659. $filename = $fileinfo["orignName"];
  660. $url = $fileinfo["url"];
  661. break;
  662. case 3:
  663. $fileinfo = Db::table("new_currency_filetype")->where($where)->findOrEmpty();
  664. $filename = $fileinfo["templateUrl"];
  665. $url = $fileinfo["templateUrl"];
  666. break;
  667. case 4:
  668. $fileinfo = Db::table("sys_common_file")->where($where)->findOrEmpty();
  669. $filename = $fileinfo["orignName"];
  670. $url = $fileinfo["url"];
  671. break;
  672. case 5:
  673. $fileinfo = Db::table("new_common_filetype")->where($where)->findOrEmpty();
  674. $filename = $fileinfo["templateUrl"];
  675. $url = $fileinfo["templateUrl"];
  676. break;
  677. case 6://预定义外的文件类型下载
  678. $fileinfo = Db::table("new_non_predefined_file")->where($where)->findOrEmpty();
  679. $filename = $fileinfo["originalName"];
  680. $url = $fileinfo["url"];
  681. break;
  682. }
  683. $filepath = "storage/" . $url; // 下载文件名
  684. if (!file_exists($filepath)) {
  685. header('HTTP/1.1 404 NOT FOUND');
  686. } else {
  687. $file = fopen($filepath, "rb");
  688. Header("Content-type: application/octet-stream");
  689. Header("Accept-Ranges: bytes");
  690. Header("Accept-Length: " . filesize($filepath));
  691. Header("Content-Disposition: attachment; filename=" . $filename);
  692. echo fread($file, filesize($filepath));
  693. fclose($file);
  694. exit();
  695. }
  696. }
  697. /**
  698. * 打包下载人才申请附件
  699. */
  700. public function downloadZip() {
  701. $table = "new_talent_file";
  702. $param = $this->request->param();
  703. $type = $param["type"];
  704. $id = $param["id"];
  705. $where = [];
  706. switch ($type) {
  707. case ProjectState::TALENT:
  708. $where[] = ["type", "=", $type];
  709. $talent_info = \app\enterprise\model\Talent::findOrEmpty($id);
  710. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($talent_info["enterprise_id"]);
  711. $zip_filename = sprintf("%s(%s)人才申报材料.zip", $talent_info["name"], $enterprise_info["name"]);
  712. break;
  713. case ProjectState::QUIT:
  714. $table = "new_talent_common_file";
  715. $info = \app\common\model\TalentQuit::findOrEmpty($id);
  716. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  717. $zip_filename = sprintf("%s(%s)离职材料.zip", $info["talentName"], $enterprise_info["name"]);
  718. break;
  719. case ProjectState::WORKCHANGE:
  720. $table = "new_talent_common_file";
  721. $info = \app\common\model\TalentWorkUnitChange::findOrEmpty($id);
  722. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  723. $zip_filename = sprintf("%s(%s)工作单位变更材料.zip", $info["talentName"], $enterprise_info["name"]);
  724. break;
  725. case ProjectState::LEVELCHANGE:
  726. $info = \app\enterprise\model\TalentTypeChange::findOrEmpty($id);
  727. $enterprise_info = \app\common\model\Enterprise::findOrEmpty($info["enterpriseId"]);
  728. $zip_filename = sprintf("%s(%s)人才层次变更材料.zip", $info["talentName"], $enterprise_info["name"]);
  729. break;
  730. case ProjectState::INTEGRAL:
  731. $where[] = ["type", "=", $type];
  732. $record = \app\common\api\IntegralRecordApi::getOne($id);
  733. $zip_filename = sprintf("%s(%s)积分申报材料.zip", $record["name"], $record["enterprise"]["name"]);
  734. break;
  735. case 109:
  736. $table = "un_enterpriseclose_record";
  737. $record = \app\common\model\EnterpriseCloseAccount::where("id", $id)->find();
  738. $zip_filename = sprintf("%s(%s)注销申请材料.zip", $record["name"], $record["username"]);
  739. $files = json_decode($record["files"], true);
  740. break;
  741. }
  742. $where[] = ["mainId", "=", $id];
  743. if (!$files)
  744. $files = Db::table($table)->where($where)->select()->toArray();
  745. if (!$files) {
  746. //die("没有附件不能打包下载");
  747. echo "<script>parent.layer.alert('没有附件不能打包下载');window.history.go(-1);</script>";
  748. }
  749. $tmp_path = "storage/temp/";
  750. $tmp_file_path = $tmp_path . $zip_filename;
  751. if (!file_exists($tmp_path)) {
  752. mkdir($tmp_path);
  753. }
  754. $zip = new \ZipArchive();
  755. if (!$zip->open($tmp_file_path, \ZipArchive::CREATE | \ZipArchive::OVERWRITE)) {
  756. header('HTTP/1.1 404 NOT FOUND');
  757. }
  758. foreach ($files as $file) {
  759. if (is_array($file)) {
  760. $filepath = "storage/" . $file["url"];
  761. $fileTypeInfo = Db::table("new_common_filetype")->where("id", $file["typeId"])->find();
  762. $filename = $fileTypeInfo["name"] . "/" . $file["orignName"];
  763. $zip->addFile($filepath, $filename);
  764. } else {
  765. $filepath = "storage/" . $file;
  766. $filename = basename($filepath);
  767. $zip->addFile($filepath, $filename);
  768. }
  769. }
  770. $zip->close();
  771. if (file_exists($tmp_file_path)) {
  772. header("Cache-Control: public");
  773. header("Content-Description: File Transfer");
  774. header('Content-disposition: attachment; filename=' . $zip_filename); //文件名
  775. header("Content-Type: application/octet-stream;charset=utf-8"); //zip格式的
  776. header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件
  777. header('Content-Length: ' . filesize($tmp_file_path)); //告诉浏览器,文件大小
  778. @readfile($tmp_file_path);
  779. }
  780. //删除临时文件
  781. @unlink($tmp_file_path);
  782. }
  783. private function chkIsFileOwner($mainId, $type) {
  784. if (!$mainId)
  785. return true;
  786. switch ($type) {
  787. case ProjectState::TALENT:
  788. if ($this->user["usertype"] == 2) {
  789. $user_id = $this->user["uid"];
  790. $talent_info = Db::table("new_talent_info")->findOrEmpty($mainId);
  791. if ($user_id == $talent_info["enterprise_id"])
  792. return true;
  793. }
  794. break;
  795. case ProjectState::JBT:
  796. if ($this->user["usertype"] == 2) {
  797. $user_id = $this->user["uid"];
  798. $talent_info = \app\common\model\TalentAllowance::findOrEmpty($mainId);
  799. if ($user_id == $talent_info["enterpriseId"])
  800. return true;
  801. }
  802. break;
  803. case ProjectState::EDUCATION:
  804. if ($this->user["usertype"] == 3) {
  805. $user_id = $this->user["uid"];
  806. $talent_info = \app\common\model\EducationSchool::findOrEmpty($mainId);
  807. if ($user_id == $talent_info["personId"])
  808. return true;
  809. }
  810. break;
  811. case ProjectState::LEVELCHANGE:
  812. if ($this->user["usertype"] == 2) {
  813. $user_id = $this->user["uid"];
  814. $talent_info = \app\enterprise\model\TalentTypeChange::findOrEmpty($mainId);
  815. if ($user_id == $talent_info["enterpriseId"])
  816. return true;
  817. }
  818. break;
  819. case ProjectState::LIVINGALLOWANCE:
  820. if ($this->user["usertype"] == 2) {
  821. $user_id = $this->user["uid"];
  822. $record = Db::table("md_living_allowance_info")->findOrEmpty($mainId);
  823. if ($user_id == $record["enterpriseId"])
  824. return true;
  825. }
  826. break;
  827. case ProjectState::INTEGRAL:
  828. if ($this->user["usertype"] == 2) {
  829. $user_id = $this->user["uid"];
  830. $record = Db::table("new_integral_record")->findOrEmpty($mainId);
  831. if ($user_id == $record["enterprise_id"])
  832. return true;
  833. }
  834. break;
  835. }
  836. return false;
  837. }
  838. public function getCompanyKvs() {
  839. $companys = \app\common\model\Company::field("name,id")->select();
  840. return json($companys);
  841. }
  842. public function getLayerCatsByLayer() {
  843. $lv = $this->request->param("level");
  844. return json(DictApi::getLayerCatsByLayer($lv));
  845. }
  846. /**
  847. * 通过人才类别查找人才认定第二步骤支持的所有文件类型
  848. * 默认人才认定第二步骤,当前只有人才认定分了两步,所以此方法目前默认参数高度匹配人才认定第二阶段附件的查找
  849. */
  850. public function getConditionFileTypesByType() {
  851. $params = $this->request->param();
  852. $type = $params["type"]; //人才类型不默认,需要传
  853. $declare_type = $params["project"] ?: 1; //默认人才认定
  854. $active = $params["active"] ?: 1; //默认查找启用的附件
  855. $where[] = ["type", "=", $type];
  856. $where[] = ["project", "=", $declare_type];
  857. $where[] = ["active", "=", $active];
  858. $where[] = ["delete", "=", 0];
  859. $where[] = ["isConditionFile", "=", 1];
  860. $list = Db::table("new_common_filetype")->where($where)->order("sn " . $order)->select()->toArray();
  861. return json($list);
  862. }
  863. public function listCurrencyFileType() {
  864. $where = [
  865. 'type' => $this->request['type'],
  866. 'active' => 1
  867. ];
  868. $rows = CurrentcyFileType::where($where)->select();
  869. return json(["rows" => $rows, 'total' => count($rows)]);
  870. }
  871. public function listTalentCommonFile() {
  872. $where = [];
  873. if (\StrUtil::isNotEmpAndNull($this->request['mainId'])) {
  874. $where[] = ['mainId', '=', $this->request['mainId']];
  875. }
  876. if (\StrUtil::isNotEmpAndNull($this->request['typeId'])) {
  877. $where[] = ['typeId', '=', $this->request['typeId']];
  878. }
  879. $res = TalentCommonFile::where($where)->order('sn')->select();
  880. if ($res) {
  881. foreach ($res as $k => &$v) {
  882. $v["ext"] = pathinfo($v["url"])["extension"];
  883. $v['url'] = getStoragePath($v['url']);
  884. }
  885. }
  886. return json($res);
  887. }
  888. public function addTalentCommonFile() {
  889. $backName = \StrUtil::getRequestDecodeParam($this->request, 'backName');
  890. $id = \StrUtil::getRequestDecodeParam($this->request, "fileId");
  891. $mainId = \StrUtil::getRequestDecodeParam($this->request, "mainId");
  892. $typeId = \StrUtil::getRequestDecodeParam($this->request, "typeId");
  893. $index = \StrUtil::getRequestDecodeParam($this->request, "index");
  894. if ($backName == "EpChangeEdit.callBack") {
  895. $type = 1;
  896. $error = "文件格式不正确,只能上传图片";
  897. } else {
  898. $type = 4;
  899. $error = "文件格式不正确,只能上传pdf和图片";
  900. }
  901. $uploadapi = new UploadApi();
  902. $file_check_res = $uploadapi->uploadOne($this->request->file('fileUrl'), 'system');
  903. if ($file_check_res->code == 500) {
  904. $file_check_res->obj = $index;
  905. return \StrUtil::back($file_check_res, $backName);
  906. }
  907. $file_data = [
  908. 'id' => getStringId(),
  909. 'mainId' => $mainId,
  910. 'typeId' => $typeId,
  911. 'orignName' => $this->request->file('fileUrl')->getOriginalName(),
  912. 'url' => $file_check_res->filepath
  913. ];
  914. if (\StrUtil::isEmpOrNull($id)) {
  915. $tc = TalentCommonFile::where('mainId', $mainId)->where('typeId', $typeId)->order('sn', 'desc')->findOrEmpty();
  916. if ($tc) {
  917. $file_data['sn'] = $tc['sn'] + 1;
  918. } else {
  919. $file_data['sn'] = 1;
  920. }
  921. $file_data['createTime'] = date("Y-m-d H:i:s");
  922. TalentCommonFile::create($file_data);
  923. $response_object = new \StdClass();
  924. $response_object->code = 200;
  925. $response_object->msg = "附件上传成功!";
  926. $response_object->obj = $index;
  927. return \StrUtil::back($response_object, $backName);
  928. } else {
  929. $tf = TalentCommonFile::findOrEmpty($id);
  930. $tf->originalName = $file_data['orignName'];
  931. $tf->updateTime = date("Y-m-d H:i:s");
  932. $tf->url = $file_check_res->filepath;
  933. $tf->save();
  934. $response_object = new \StdClass();
  935. $response_object->code = 200;
  936. $response_object->msg = "附件修改成功!";
  937. $response_object->obj = $index;
  938. return \StrUtil::back($response_object, $backName);
  939. }
  940. }
  941. public function changePwd() {
  942. $password = \StrUtil::getRequestDecodeParam($this->request, 'password');
  943. $newPassword = \StrUtil::getRequestDecodeParam($this->request, 'newPassword');
  944. //数据校验(原密码与新密码不能为空)
  945. if (\StrUtil::isEmpOrNull($password)) {
  946. return json(['code' => 500, 'msg' => "请填写原密码!"]);
  947. }
  948. if (\StrUtil::isEmpOrNull($newPassword)) {
  949. return json(['code' => 500, 'msg' => "请填写新密码!"]);
  950. }
  951. try {
  952. validate(Enterprise::class)->batch(true)->scene('changePwd')->check(['password' => $password, 'password' => $newPassword]);
  953. $ep = EnterpriseApi::getOne(session("user")['uid']);
  954. if (!$ep) {
  955. return json(['code' => 500, 'msg' => "请刷新页面后重试!"]);
  956. }
  957. if ($ep->password != hash('md5', $password)) {
  958. return json(['code' => 500, 'msg' => "旧密码不正确!"]);
  959. }
  960. $ep->password = hash('md5', $newPassword);
  961. $ep->updateUser = session("user")['uid'];
  962. $ep->updateTime = date("Y-m-d H:i:s");
  963. $ep->save();
  964. TalentChecklog::create([
  965. 'id' => getStringId(),
  966. 'category' => 'enterprise_change',
  967. 'mainId' => $ep->id,
  968. 'type' => 10,
  969. 'typeFileId' => null,
  970. 'active' => 1,
  971. 'state' => 1,
  972. 'step' => 100,
  973. 'stateChange' => null,
  974. 'description' => '用户修改密码',
  975. 'createTime' => date("Y-m-d H:i:s", time()),
  976. 'createUser' => '用户'
  977. ]);
  978. return json(['code' => 200, 'msg' => "修改成功!"]);
  979. } catch (ValidateException $e) {
  980. $error = $e->getError();
  981. return json(['code' => 500, 'msg' => array_pop($error)]);
  982. }
  983. }
  984. function getIntegralRecordByIdCard() {
  985. $cardType = $this->request->param("cardType");
  986. $cardNumber = $this->request->param("cardNumber");
  987. $tips = \app\common\api\IntegralRecordApi::getIntegralRecordByIdCard($cardType, $cardNumber);
  988. return json(["tips" => $tips]);
  989. }
  990. function getIntegralProjectsByType() {
  991. $projectType = $this->request->param("projectType") ?: 0;
  992. if (session("user")["usertype"] == 2) {
  993. $where[] = ["type", "=", 2];
  994. } else {
  995. $type = $this->request->param("type") ?: 0;
  996. $where[] = ["type", "=", $type];
  997. }
  998. $where[] = ["projectType", "=", $projectType];
  999. $where[] = ["active", "=", 1];
  1000. $list = \app\common\api\IntegralProjectApi::getAll($where);
  1001. return json($list);
  1002. }
  1003. public function getIntegralItemsByProject() {
  1004. $projectId = $this->request->param("projectId") ?: 0;
  1005. $where[] = ["projectId", "=", $projectId];
  1006. $where[] = ["active", "=", 1];
  1007. $list = \app\common\api\IntegralItemApi::getAll($where);
  1008. return json($list);
  1009. }
  1010. public function calIntegral() {
  1011. $params = $this->request->param();
  1012. $enterpriseId = $params["enterpriseId"];
  1013. $cardType = $params["cardType"];
  1014. $cardNumber = $params["cardNumber"];
  1015. $itemId = $params["itemId"];
  1016. $amount = $params["amount"];
  1017. if (session("user")["usertype"] == 2) {
  1018. //企业端只能通过企业自身id来查询积分
  1019. $enterpriseId = session("user")["uid"];
  1020. }
  1021. return json(\app\common\api\IntegralRecordApi::calIntegral($enterpriseId, $cardType, $cardNumber, $itemId, $amount));
  1022. }
  1023. public function imgViewer() {
  1024. $img = urldecode($this->request["picShow"]);
  1025. return view("", ["img" => $img]);
  1026. }
  1027. public function gotoFileShow() {
  1028. return view("admin@talent/filesShow");
  1029. }
  1030. }