Api.php 51 KB

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