VerifyApi.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. namespace app\common\api;
  3. use app\enterprise\model\Talent;
  4. use app\common\api\DictApi;
  5. use app\admin\model\Enterprise;
  6. use think\facade\Db;
  7. use app\common\model\TalentCondition;
  8. /**
  9. * Description of VerifyApi
  10. *
  11. * @author sgq
  12. */
  13. class VerifyApi {
  14. public static function getTalentInfoById($id) {
  15. $where = [];
  16. $where[] = ["id", "=", $id];
  17. $info = Talent::findOrEmpty($id)->toArray();
  18. if ($info) {
  19. if ($info["talent_type"]) {
  20. $info["talentTypeName"] = DictApi::selectByParentCode("talent_type")[$info["talent_type"]];
  21. }
  22. if ($info["nationality"]) {
  23. $info["nationalityName"] = DictApi::selectByParentCode("nationality")[$info["nationality"]];
  24. }
  25. if ($info["nation"]) {
  26. $info["nationName"] = DictApi::selectByParentCode("nation")[$info["nation"]];
  27. }
  28. if ($info["politics"]) {
  29. $info["politicsName"] = DictApi::selectByParentCode("politics")[$info["politics"]];
  30. }
  31. if ($info["province"]) {
  32. $info["provinceName"] = Db::table("un_common_location")->where("code", "=", $info["province"])->findOrEmpty()["name"];
  33. }
  34. if ($info["city"]) {
  35. $info["cityName"] = Db::table("un_common_location")->where("code", "=", $info["city"])->findOrEmpty()["name"];
  36. }
  37. if ($info["county"]) {
  38. $info["countyName"] = Db::table("un_common_location")->where("code", "=", $info["county"])->findOrEmpty()["name"];
  39. }
  40. $enterprise = Enterprise::findOrEmpty($info["enterprise_id"])->toArray();
  41. $info["enterpriseName"] = $enterprise["name"];
  42. if ($enterprise["street"]) {
  43. $info["street"] = $enterprise["street"];
  44. $info["streetName"] = DictApi::selectByParentCode("street")[$enterprise["street"]];
  45. }
  46. if ($enterprise["industryFieldNew"]) {
  47. $info["industryFieldName"] = DictApi::selectByParentCode("industry_field")[$enterprise["industryFieldNew"]];
  48. }
  49. if ($enterprise["enterpriseTag"]) {
  50. $info["enterpriseTagName"] = DictApi::selectByParentCode("enterprise_tag")[$enterprise["enterpriseTag"]];
  51. }
  52. if ($info["headimgurl"]) {
  53. $info["headimgurl"] = "/storage/" . $info["headimgurl"];
  54. }
  55. if ($info["talent_arrange"]) {
  56. $info["talentArrangeName"] = DictApi::selectByParentCode("talent_arrange")[$info["talent_arrange"]];
  57. }
  58. if ($info["import_way"]) {
  59. $info["importWayName"] = DictApi::selectByParentCode("import_way")[$info["import_way"]];
  60. }
  61. if ($info["source"]) {
  62. $info["sourceName"] = DictApi::selectByParentCode("source")[$info["source"]];
  63. }
  64. if ($info["source_city"]) {
  65. $info["sourceCityName"] = Db::table("un_common_location")->where("code", "=", $info["source_city"])->findOrEmpty()["name"];
  66. }
  67. if ($info["source_county"]) {
  68. $info["sourceCountyName"] = Db::table("un_common_location")->where("code", "=", $info["source_county"])->findOrEmpty()["name"];
  69. }
  70. if ($info["highest_degree"]) {
  71. $info["highestDegreeName"] = DictApi::selectByParentCode("highest_degree")[$info["highest_degree"]];
  72. }
  73. if ($info["talent_condition"]) {
  74. $info["talentConditionName"] = \app\common\model\TalentCondition::findOrEmpty($info["talent_condition"])["name"];
  75. }
  76. }
  77. return $info;
  78. }
  79. public static function getOne($id) {
  80. return Talent::findOrEmpty($id);
  81. }
  82. public static function getDeptList($request) {
  83. $where = [];
  84. $order = trim($request->param("order")) ?: "desc";
  85. $offset = trim($request->param("offset")) ?: 0;
  86. $limit = trim($request->param("limit")) ?: 10;
  87. $process = $request->param("process");
  88. switch ($process) {
  89. case 1:
  90. $where[] = ["ti.checkState", "=", 2];
  91. break;
  92. case 2:
  93. $where[] = ["ti.checkState", "=", 6];
  94. break;
  95. case 3:
  96. $where[] = ["ti.checkState", "=", 7];
  97. break;
  98. case 4:
  99. $where[] = ["ti.checkState", "=", 9];
  100. break;
  101. }
  102. $companyId = session("user")["companyId"];
  103. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  104. $count = Talent::alias("ti")
  105. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  106. ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  107. ->where($where)
  108. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])->count();
  109. $list = Talent::alias("ti")
  110. ->leftJoin("new_talent_condition tc", "tc.id=ti.talent_condition")
  111. ->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  112. ->where($where)
  113. ->whereRaw("find_in_set(:companyId,companyIds)", ["companyId" => $companyId])
  114. ->field("ti.*,e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")
  115. ->limit($offset, $limit)->order("ti.createTime " . $order)
  116. ->select()->toArray();
  117. foreach ($list as &$item) {
  118. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  119. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  120. }unset($item);
  121. return ["total" => $count, "rows" => $list];
  122. }
  123. public static function getPublicList($params) {
  124. $type = $params["type"];
  125. $where = [];
  126. switch ($type) {
  127. case 1:
  128. case 2:
  129. $where[] = ["isPublic", 1];
  130. $where[] = ["checkState", 11];
  131. break;
  132. case 3: //公示
  133. case 7: //公示预览
  134. $where[] = ["isPublic", 2];
  135. $where[] = ["checkState", 11];
  136. break;
  137. case 4:
  138. $where[] = ["isPublic", 3];
  139. $where[] = ["checkState", 11];
  140. break;
  141. case 5:
  142. case 8: //公布预览
  143. $where[] = ["isPublic", 4];
  144. $where[] = ["checkState", 11];
  145. break;
  146. case 6:
  147. $where[] = ["isPublic", 5];
  148. $where[] = ["checkState", 11];
  149. break;
  150. }
  151. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  152. $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  153. $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  154. ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  155. foreach ($list as &$item) {
  156. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  157. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  158. }unset($item);
  159. return ["total" => $count, "rows" => $list];
  160. }
  161. public static function getList($request) {
  162. $where = [];
  163. $order = trim($request->param("order")) ?: "desc";
  164. $offset = trim($request->param("offset")) ?: 0;
  165. $limit = trim($request->param("limit")) ?: 10;
  166. $process = $request->param("process");
  167. if ($process == 3) {
  168. return self::getDeptList($request);
  169. }
  170. switch ($process) {
  171. case 1:
  172. $where[] = ["ti.checkState", "=", 2];
  173. break;
  174. case 2:
  175. $where[] = ["ti.checkState", "=", 6];
  176. break;
  177. case 3:
  178. $where[] = ["ti.checkState", "=", 7];
  179. break;
  180. case 4:
  181. $where[] = ["ti.checkState", "=", 9];
  182. break;
  183. case 5:
  184. $where[] = ["ti.checkState", "=", 11];
  185. break;
  186. }
  187. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  188. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  189. $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  190. $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  191. ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.name as enterprise_name,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  192. foreach ($list as &$item) {
  193. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  194. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  195. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  196. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  197. }unset($item);
  198. return ["total" => $count, "rows" => $list];
  199. }
  200. public static function getExportDatas($params) {
  201. $where[] = [];
  202. //特殊字段处理
  203. $fields = [];
  204. foreach ($params as $param) {
  205. if (!in_array($param, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street"])) {
  206. $fields[] = "ti." . $param;
  207. }
  208. }
  209. $fields[] = "e.name as enterpriseName";
  210. $fields[] = "e.industryFieldNew";
  211. $fields[] = "e.enterpriseTag";
  212. $fields[] = "e.street";
  213. if (in_array("card_type", $params)) {
  214. $cardTypes = DictApi::selectByParentCode("card_type");
  215. }
  216. if (in_array("industryFieldNew", $params)) {
  217. $industry_fields = DictApi::selectByParentCode("industry_field");
  218. }
  219. if (in_array("enterpriseTag", $params)) {
  220. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  221. }
  222. if (in_array("street", $params)) {
  223. $streets = DictApi::selectByParentCode("street");
  224. }
  225. if (in_array("nation", $params)) {
  226. $nations = DictApi::selectByParentCode("nation");
  227. }
  228. if (in_array("nationality", $params)) {
  229. $nationalitys = DictApi::selectByParentCode("nationality");
  230. }
  231. if (in_array("politics", $params)) {
  232. $politics = DictApi::selectByParentCode("politics");
  233. }
  234. if (in_array("talent_type", $params)) {
  235. $talentTypes = DictApi::selectByParentCode("talent_type");
  236. }
  237. $sex = [1 => "男", 2 => "女"];
  238. $list = Talent::alias("ti")->field($fields)->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->select()->toArray();
  239. foreach ($list as &$item) {
  240. $item["card_type"] = $cardTypes[$item["card_type"]];
  241. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  242. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  243. $item["street"] = $streets[$item["street"]];
  244. $item["nation"] = $nations[$item["nation"]];
  245. $item["nationality"] = $nationalitys[$item["nationality"]];
  246. $item["politics"] = $politics[$item["politics"]];
  247. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  248. $item["sex"] = $sex[$item["sex"]];
  249. if (in_array("province", $params)) {
  250. $item["province"] = Db::table("un_common_location")->where("code", "=", $item["province"])->findOrEmpty()["name"];
  251. }
  252. if (in_array("city", $params)) {
  253. $item["city"] = Db::table("un_common_location")->where("code", "=", $item["city"])->findOrEmpty()["name"];
  254. }
  255. if (in_array("county", $params)) {
  256. $item["county"] = Db::table("un_common_location")->where("code", "=", $item["county"])->findOrEmpty()["name"];
  257. }
  258. }unset($item);
  259. return $list;
  260. }
  261. }