Enterprise.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. use app\common\api\ChuanglanSmsApi;
  5. use app\common\api\DictApi;
  6. use app\common\api\EnterpriseApi;
  7. use app\common\model\MessageRecord;
  8. use app\common\model\TalentChecklog;
  9. use app\common\api\TalentState;
  10. use app\common\api\CompanyApi;
  11. use think\facade\Db;
  12. class Enterprise extends AdminController {
  13. public function gotoEnterprisePage(){
  14. return view("", []);
  15. }
  16. public function findEnterpriseByPage(){
  17. $res = EnterpriseApi::getList($this->request);
  18. return json($res);
  19. }
  20. public function gotoEnterpriseDetailPage(){
  21. $id = trim($this->request['id']);
  22. $ep = EnterpriseApi::getOne($id);
  23. if(!$ep){
  24. return "无此企业";
  25. }
  26. //--------设置 审核状态---------------------------------------------------
  27. switch ($ep['checkState']){
  28. case 1:
  29. $ep['checkStateName'] = "待审核";
  30. break;
  31. case 2:
  32. $ep['checkStateName'] = "审核驳回";
  33. break;
  34. case 3:
  35. $ep['checkStateName'] = "审核通过";
  36. break;
  37. case 4:
  38. $ep['checkStateName'] = "重新提交";
  39. break;
  40. }
  41. //-------设置账号状态----------------------------------------------------
  42. switch ($ep['active']){
  43. case 1:
  44. $ep['activeName'] = "账号有效";
  45. break;
  46. case 2:
  47. $ep['activeName'] = "冻结/拉黑";
  48. break;
  49. }
  50. //---------设置 街道-----------------------------------------------------
  51. if (\StrUtil::isNotEmpAndNull($ep['street'])) {
  52. $street_info = DictApi::findByParentCodeAndCode('street',$ep['street']);
  53. if ($street_info != null) {
  54. $ep['streetName'] = $street_info['name'];
  55. }
  56. }
  57. //---------设置产业领域 --------------------------------------------------
  58. if(\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])){
  59. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field',$ep['industryFieldNew']);
  60. if($industryFieldNew != null){
  61. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  62. }
  63. }
  64. //---------设置行业领域 --------------------------------------------------
  65. if(\StrUtil::isNotEmpAndNull($ep['industryFieldOld'])){
  66. $industryFieldOld = DictApi::findByParentCodeAndCode($ep['industryFieldNew'] . "_field",$ep['industryFieldOld']);
  67. if($industryFieldOld != null){
  68. $ep['industryFieldOldName'] = $industryFieldOld['name'];
  69. }
  70. }
  71. //---------设置单位标签 --------------------------------------------------
  72. if(\StrUtil::isNotEmpAndNull($ep['enterpriseTag'])){
  73. $enterpriseTag = DictApi::findByParentCodeAndCode("enterprise_tag",$ep['enterpriseTag']);
  74. if($enterpriseTag != null){
  75. $ep['enterpriseTagName'] = $enterpriseTag['name'];
  76. }
  77. }
  78. //---------设置单位类型 --------------------------------------------------
  79. if(\StrUtil::isNotEmpAndNull($ep['enterpriseType'])){
  80. $enterpriseType = DictApi::findByParentCodeAndCode("enterprise_type",$ep['enterpriseType']);
  81. if($enterpriseType != null){
  82. $ep['enterpriseTypeName'] = $enterpriseType['name'];
  83. }
  84. }
  85. $imgurl_info = pathinfo($ep['imgurl']);
  86. if(in_array($imgurl_info['extension'],["jpeg","jpg","png","gif"])){
  87. $ep['imgurl_is_img'] = 1;
  88. }else{
  89. $ep['imgurl_is_img'] = 0;
  90. }
  91. $bankImg_info = pathinfo($ep['bankImg']);
  92. if(in_array($bankImg_info['extension'],["jpeg","jpg","png","gif"])){
  93. $ep['bankImg_is_img'] = 1;
  94. }else{
  95. $ep['bankImg_is_img'] = 0;
  96. }
  97. $domainImg_info = pathinfo($ep['domainImg']);
  98. if(in_array($domainImg_info['extension'],["jpeg","jpg","png","gif"])){
  99. $ep['domainImg_is_img'] = 1;
  100. }else{
  101. $ep['domainImg_is_img'] = 0;
  102. }
  103. $typeImg_info = pathinfo($ep['typeImg']);
  104. if(in_array($typeImg_info['extension'],["jpeg","jpg","png","gif"])){
  105. $ep['typeImg_is_img'] = 1;
  106. }else{
  107. $ep['typeImg_is_img'] = 0;
  108. }
  109. $beian_info = pathinfo($ep['beian']);
  110. if(in_array($beian_info['extension'],["jpeg","jpg","png","gif"])){
  111. $ep['beian_is_img'] = 1;
  112. }else{
  113. $ep['beian_is_img'] = 0;
  114. }
  115. return view("", ['ep' => $ep]);
  116. }
  117. public function gotoExaminePage(){
  118. $id = trim($this->request['id']);
  119. $ep = EnterpriseApi::getOne($id);
  120. if(!$ep){
  121. return "无此企业";
  122. }
  123. //---------设置产业领域 --------------------------------------------------
  124. if(\StrUtil::isNotEmpAndNull($ep['industryFieldNew'])){
  125. $industryFieldNew = DictApi::findByParentCodeAndCode('industry_field',$ep['industryFieldNew']);
  126. if($industryFieldNew != null){
  127. $ep['industryFieldNewName'] = $industryFieldNew['name'];
  128. }
  129. }
  130. return view("", ['ep' => $ep, 'checkUser' => session('user')['name']]);
  131. }
  132. public function doExamine(){
  133. $id = trim($this->request['id']);
  134. if(!$id){
  135. return json(["msg" => 'ID不能为空!']);
  136. }
  137. $ep = EnterpriseApi::getOne($id);
  138. if(!$ep){
  139. return json(["msg" => '无此企业!']);
  140. }
  141. $checkState = $this->request['checkState'];
  142. if($checkState == null || ($checkState != 2 && $checkState != 3)){
  143. return json(["msg" => '请选择审核状态!']);
  144. }
  145. $checkMsg = $this->request['checkMsg'];
  146. if($checkState == 2){
  147. if (\StrUtil::isEmpOrNull($checkMsg)) {
  148. return json(["msg" => '请填写审核意见!']);
  149. }
  150. if (strlen($checkMsg) > 200) {
  151. return json(["msg" => '审核意见最多200个字符!']);
  152. }
  153. }
  154. try {
  155. $checkData = [
  156. 'id' => $id,
  157. 'checkState' => $checkState,
  158. 'checkMsg' => $checkMsg,
  159. 'checkUser' => session('user')['name'],
  160. 'updateUser' => session('user')['uid'],
  161. 'updateTime' => date("Y-m-d H:i:s")
  162. ];
  163. $res = EnterpriseApi::updateById($checkData);
  164. //短信入库数据
  165. $record_data = [
  166. 'id' => getStringId(),
  167. 'bizId' => getStringId(),
  168. 'userId' => $id,
  169. 'type' => 2,
  170. 'smsType' => 2,
  171. 'name' => $ep['name'],
  172. 'phone' => $ep['agentPhone'],
  173. 'params' => '机构注册信息',
  174. 'state' => 1,
  175. 'sendingDate' => date("Y-m-d H:i:s",time()),
  176. 'createTime' => date("Y-m-d H:i:s",time())
  177. ];
  178. if($checkState == 2){
  179. $record_data['templateCode'] = "【晋江市人才服务平台】您好!您提交申请的优秀人才机构注册信息因信息填写错误或上传不完整已被退回,请及时登录申报系统查看审核意见并重新提交。";
  180. }
  181. if($checkState == 3){
  182. $record_data['templateCode'] = "【晋江市人才服务平台】您好!您提交申请的优秀人才机构注册信息已审核通过,可登录申报系统做相关事宜申报。";
  183. }
  184. $smsapi = new ChuanglanSmsApi();
  185. $result = $smsapi->sendSMS($ep['agentPhone'],$record_data['templateCode']);
  186. MessageRecord::create($record_data);
  187. $company = CompanyApi::getOne(session('user')['companyId']);
  188. TalentChecklog::create([
  189. 'id' => getStringId(),
  190. 'mainId' => $id,
  191. 'type' => 10,
  192. 'typeField' => null,
  193. 'active' => 1,
  194. 'state' => $checkState,
  195. 'step' => 101,
  196. 'stateChange' => TalentState::stateEnum($checkState),
  197. 'description' => $checkMsg,
  198. 'createTime' => date("Y-m-d H:i:s",time()),
  199. 'createUser' => session('user')['name']."({$company['name']})"
  200. ]);
  201. return json(["msg" => '操作成功!',"code" => 200]);
  202. } catch (\Exception $e){
  203. return json(["msg" => $e->getMessage()]);
  204. }
  205. }
  206. public function GotoActivePage(){
  207. $id = trim($this->request['id']);
  208. $ep = EnterpriseApi::getOne($id);
  209. return view("", ['ep' => $ep]);
  210. }
  211. public function setActive(){
  212. if(!$id = trim($this->request['id'])){
  213. return json(["msg" => 'ID不能为空!',"code" => 500]);
  214. }
  215. $ep = EnterpriseApi::getOne($id);
  216. $active = $this->request['active'];
  217. if($ep['active'] == null || ($ep['active'] != 1 && $ep['active'] != 2)){
  218. return json(["msg" => '状态有误!',"code" => 500]);
  219. }
  220. if($ep['active'] == 2){
  221. $msg = trim($this->request['activeMsg']);
  222. if(empty($msg)){
  223. return json(["msg" => '请填写拉黑/冻结原因!',"code" => 500]);
  224. }
  225. if(strlen($msg) > 100){
  226. return json(["msg" => '拉黑/冻结原因 最多100个字符!',"code" => 500]);
  227. }
  228. }
  229. $company = CompanyApi::getOne(session('user')['companyId']);
  230. $ep->active = $active;
  231. $ep->activeMsg = $msg;
  232. $ep->updateUser = session('user')['uid'] . "";
  233. $ep->updateTime = date('y-m-d H:i:s');
  234. try {
  235. $ep->save();
  236. //添加日志
  237. TalentChecklog::create([
  238. 'id' => getStringId(),
  239. 'mainId' => $ep['id'],
  240. 'type' => 10,
  241. 'typeField' => null,
  242. 'active' => 1,
  243. 'state' => TalentState::RCRD_BASEIC_FROZEN,
  244. 'step' => 102,
  245. 'stateChange' => TalentState::stateEnum(10),
  246. 'description' => $msg,
  247. 'createTime' => date("Y-m-d H:i:s",time()),
  248. 'createUser' => session('user')['name']."({$company['name']})"
  249. ]);
  250. return json(["msg" => '操作成功!',"code" => 200]);
  251. } catch (\Exception $e) {
  252. return json(["msg" => $e->getMessage()]);
  253. }
  254. }
  255. public function resetPassword(){
  256. if(!$id = trim($this->request['id'])){
  257. return json(["msg" => 'ID不能为空!',"code" => 500]);
  258. }
  259. $ep = EnterpriseApi::getOne($id);
  260. if(!$ep){
  261. return json(["msg" => '找不到该用户!',"code" => 500]);
  262. }
  263. $ep->password = hash("md5", 'JJrc@123');//默认密码
  264. $ep->updateUser = session('user')['uid'] . "";
  265. $ep->updateTime = date("Y-m-d H:i:s");
  266. $ep->save();
  267. $company = CompanyApi::getOne(session('user')['companyId']);
  268. TalentChecklog::create([
  269. 'id' => getStringId(),
  270. 'mainId' => $ep['id'],
  271. 'type' => 10,
  272. 'typeField' => null,
  273. 'active' => 1,
  274. 'state' => null,
  275. 'step' => 103,
  276. 'stateChange' => '重置密码',
  277. 'description' => '重置密码',
  278. 'createTime' => date("Y-m-d H:i:s",time()),
  279. 'createUser' => session('user')['name']."({$company['name']})"
  280. ]);
  281. return json(["msg" => '重置密码成功!',"code" => 200]);
  282. }
  283. public function export(){
  284. $res = EnterpriseApi::getList($this->request);
  285. $objPHPExcel = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
  286. //创建人
  287. $objPHPExcel->getProperties()->setCreator("System");
  288. //最后修改人
  289. $objPHPExcel->getProperties()->setLastModifiedBy("System");
  290. //标题
  291. $objPHPExcel->getProperties()->settitle("企业用户信息".date("ymdHis"));
  292. $objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
  293. $objPHPExcel->getDefaultStyle()->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
  294. //设置当前的sheet
  295. $sheet = $objPHPExcel->getActiveSheet();
  296. //设置sheet的name
  297. $sheet->settitle('企业用户信息');
  298. // 所有单元格默认高度
  299. $sheet->getDefaultRowDimension()->setRowHeight(30);
  300. $sheet->getDefaultColumnDimension()->setWidth(30);
  301. $sheet->getstyle('A1:O1')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setRGB("87CEEB");
  302. $header = ["单位名称", " 统一社会信用代码","产业领域" ,"单位标签"," 所属街道", "单位地址", " 法人代表", " 单位电话", "人才联络员", "人才联络员电话", "人才联络员邮箱", "审核状态", "账号状态", "注册时间","备注"];
  303. foreach ($header as $key => $value) {
  304. $sheet->setCellValueByColumnAndRow($key+1, 1, $value);
  305. }
  306. if($res['total'] > 0){
  307. $row = 2;
  308. foreach ($res['rows'] as $k => $v){
  309. for ($i = 0; $i < count($header);$i++){
  310. switch ($i){
  311. case 0:
  312. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['name']);
  313. break;
  314. case 1:
  315. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['idCard']);
  316. break;
  317. case 2:
  318. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['industryFieldNewName']);
  319. break;
  320. case 3:
  321. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['enterpriseTagName']);
  322. break;
  323. case 4:
  324. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['streetName']);
  325. break;
  326. case 5:
  327. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['address']);
  328. break;
  329. case 6:
  330. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['legal']);
  331. break;
  332. case 7:
  333. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v['ephone'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  334. break;
  335. case 8:
  336. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['agentName']);
  337. break;
  338. case 9:
  339. $sheet->setCellValueExplicitByColumnAndRow($i+1, $row, $v['agentPhone'], \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
  340. break;
  341. case 10:
  342. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['agentEmail']);
  343. break;
  344. case 11:
  345. switch ($v['checkState']){
  346. case 1:
  347. $sheet->setCellValueByColumnAndRow($i+1, $row, "未审核");
  348. break;
  349. case 2:
  350. $sheet->setCellValueByColumnAndRow($i+1, $row, "审核驳回");
  351. break;
  352. case 3:
  353. $sheet->setCellValueByColumnAndRow($i+1, $row, "审核通过");
  354. break;
  355. case 4:
  356. $sheet->setCellValueByColumnAndRow($i+1, $row, "重新提交");
  357. break;
  358. default:
  359. $sheet->setCellValueByColumnAndRow($i+1, $row, "");
  360. break;
  361. }
  362. break;
  363. case 12:
  364. switch ($v['active']){
  365. case 1:
  366. $sheet->setCellValueByColumnAndRow($i+1, $row, "账号有效");
  367. break;
  368. case 2:
  369. $sheet->setCellValueByColumnAndRow($i+1, $row, "拉黑/冻结");
  370. break;
  371. default:
  372. $sheet->setCellValueByColumnAndRow($i+1, $row, "");
  373. break;
  374. }
  375. break;
  376. case 13:
  377. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['createTime']);
  378. break;
  379. case 14:
  380. $sheet->setCellValueByColumnAndRow($i+1, $row, $v['description']);
  381. break;
  382. }
  383. }
  384. $row++;
  385. }
  386. }
  387. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  388. header('Content-Disposition: attachment;filename="'."企业用户信息".date("ymdHis").'.xlsx"');
  389. header('Cache-Control: max-age=0');
  390. // If you're serving to IE 9, then the following may be needed
  391. header('Cache-Control: max-age=1');
  392. // If you're serving to IE over SSL, then the following may be needed
  393. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
  394. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
  395. header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
  396. header('Pragma: public'); // HTTP/1.0
  397. $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($objPHPExcel, 'Xlsx');
  398. $writer->save('php://output');
  399. }
  400. }