VerifyApi.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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.agentName,e.type as enterprise_type,enterpriseTag")
  115. ->limit($offset, $limit)->order("ti.createTime " . $order)
  116. ->select()->toArray();
  117. foreach ($list as &$item) {
  118. $item["enterprise_name"] = $item["agentName"];
  119. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  120. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  121. }unset($item);
  122. return ["total" => $count, "rows" => $list];
  123. }
  124. public static function getPublicList($params) {
  125. $type = $params["type"];
  126. $where = [];
  127. switch ($type) {
  128. case 1:
  129. case 2:
  130. $where[] = ["isPublic", 1];
  131. $where[] = ["checkState", 11];
  132. break;
  133. case 3: //公示
  134. case 7: //公示预览
  135. $where[] = ["isPublic", 2];
  136. $where[] = ["checkState", 11];
  137. break;
  138. case 4:
  139. $where[] = ["isPublic", 3];
  140. $where[] = ["checkState", 11];
  141. break;
  142. case 5:
  143. case 8: //公布预览
  144. $where[] = ["isPublic", 4];
  145. $where[] = ["checkState", 11];
  146. break;
  147. case 6:
  148. $where[] = ["isPublic", 5];
  149. $where[] = ["checkState", 11];
  150. break;
  151. }
  152. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  153. $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  154. $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  155. ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.agentName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  156. foreach ($list as &$item) {
  157. $item["enterprise_name"] = $item["agentName"];
  158. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  159. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  160. }unset($item);
  161. return ["total" => $count, "rows" => $list];
  162. }
  163. public static function getList($request) {
  164. $where = [];
  165. $order = trim($request->param("order")) ?: "desc";
  166. $offset = trim($request->param("offset")) ?: 0;
  167. $limit = trim($request->param("limit")) ?: 10;
  168. $process = $request->param("process");
  169. if ($process == 3) {
  170. return self::getDeptList($request);
  171. }
  172. switch ($process) {
  173. case 1:
  174. $where[] = ["ti.checkState", "=", 2];
  175. break;
  176. case 2:
  177. $where[] = ["ti.checkState", "=", 6];
  178. break;
  179. case 3:
  180. $where[] = ["ti.checkState", "=", 7];
  181. break;
  182. case 4:
  183. $where[] = ["ti.checkState", "=", 9];
  184. break;
  185. case 5:
  186. $where[] = ["ti.checkState", "=", 11];
  187. break;
  188. }
  189. $talent_arrange_kvs = DictApi::selectByParentCode("talent_arrange");
  190. $enterprise_tag_kvs = DictApi::selectByParentCode("enterprise_tag");
  191. $count = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->where($where)->count();
  192. $list = Talent::alias("ti")->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")
  193. ->where($where)->limit($offset, $limit)->order("ti.createTime " . $order)->field("ti.*,e.agentName,e.type as enterprise_type,enterpriseTag")->select()->toArray();
  194. foreach ($list as &$item) {
  195. $item["enterprise_name"] = $item["agentName"];
  196. $item["talent_type"] = $item["enterprise_type"] == 1 ? "晋江优秀人才" : "集成电路优秀人才";
  197. $item["enterprise_tag"] = $enterprise_tag_kvs[$item["enterpriseTag"]];
  198. $item["talentArrangeName"] = $talent_arrange_kvs[$item["talent_arrange"]];
  199. $item["talentConditionName"] = TalentCondition::findOrEmpty($item["talent_condition"])["name"];
  200. }unset($item);
  201. return ["total" => $count, "rows" => $list];
  202. }
  203. public static function getExportDatas($params) {
  204. $where[] = [];
  205. //特殊字段处理
  206. $fields = [];
  207. foreach ($params as $param) {
  208. if (!in_array($param, ["industryFieldNew", "enterpriseName", "enterpriseTag", "street"])) {
  209. $fields[] = "ti." . $param;
  210. }
  211. }
  212. $fields[] = "e.name as enterpriseName";
  213. $fields[] = "e.industryFieldNew";
  214. $fields[] = "e.enterpriseTag";
  215. $fields[] = "e.street";
  216. if (in_array("card_type", $params)) {
  217. $cardTypes = DictApi::selectByParentCode("card_type");
  218. }
  219. if (in_array("industryFieldNew", $params)) {
  220. $industry_fields = DictApi::selectByParentCode("industry_field");
  221. }
  222. if (in_array("enterpriseTag", $params)) {
  223. $enterpriseTags = DictApi::selectByParentCode("enterprise_tag");
  224. }
  225. if (in_array("street", $params)) {
  226. $streets = DictApi::selectByParentCode("street");
  227. }
  228. if (in_array("nation", $params)) {
  229. $nations = DictApi::selectByParentCode("nation");
  230. }
  231. if (in_array("nationality", $params)) {
  232. $nationalitys = DictApi::selectByParentCode("nationality");
  233. }
  234. if (in_array("politics", $params)) {
  235. $politics = DictApi::selectByParentCode("politics");
  236. }
  237. if (in_array("talent_type", $params)) {
  238. $talentTypes = DictApi::selectByParentCode("talent_type");
  239. }
  240. $sex = [1 => "男", 2 => "女"];
  241. $list = Talent::alias("ti")->field($fields)->leftJoin("new_enterprise e", "e.id=ti.enterprise_id")->select()->toArray();
  242. foreach ($list as &$item) {
  243. $item["card_type"] = $cardTypes[$item["card_type"]];
  244. $item["industryFieldNew"] = $industry_fields[$item["industryFieldNew"]];
  245. $item["enterpriseTag"] = $enterpriseTags[$item["enterpriseTag"]];
  246. $item["street"] = $streets[$item["street"]];
  247. $item["nation"] = $nations[$item["nation"]];
  248. $item["nationality"] = $nationalitys[$item["nationality"]];
  249. $item["politics"] = $politics[$item["politics"]];
  250. $item["talent_type"] = $talentTypes[$item["talent_type"]];
  251. $item["sex"] = $sex[$item["sex"]];
  252. if (in_array("province", $params)) {
  253. $item["province"] = Db::table("un_common_location")->where("code", "=", $item["province"])->findOrEmpty()["name"];
  254. }
  255. if (in_array("city", $params)) {
  256. $item["city"] = Db::table("un_common_location")->where("code", "=", $item["city"])->findOrEmpty()["name"];
  257. }
  258. if (in_array("county", $params)) {
  259. $item["county"] = Db::table("un_common_location")->where("code", "=", $item["county"])->findOrEmpty()["name"];
  260. }
  261. }unset($item);
  262. return $list;
  263. }
  264. }