Browse Source

公司名称修改

linwu 2 years ago
parent
commit
216fa40963

+ 100 - 27
app/admin/controller/Comjobs.php

@@ -312,6 +312,12 @@ class Comjobs extends BaseController
         $list  = ComjobsModel::with(['worker', 'comjobsCate'])->withCount(['comjobsLog'])->where($map)->order(['priority' => 'desc', 'id' => 'desc',])->limit($limit)->page($page)->append(['wtype_text', 'status_text'])->select();
         $count = ComjobsModel::where($map)->count();
 
+        foreach ($list as $v) {
+            if (!empty($v['company_name'])) {
+                $v['worker']['title'] = $v['company_name'];
+            }
+        }
+
         if ($count == 0) {
             exit(json_encode([
                 'code' => 1,
@@ -515,38 +521,40 @@ class Comjobs extends BaseController
             }])->find($id);
 
         //数据重组
-        $list            = $item = [];
-        $item['baz367']  = $info['id'];
+        $list           = $item = [];
+        $item['baz367'] = $info['id'];
         if (!empty($info['comjobsCate']['code'])) {
-            $item['aca111']  = $info['comjobsCate']['code'];
+            $item['aca111'] = $info['comjobsCate']['code'];
         }
-        $item['aca112']  = $info['title'];
-        $item['bcz002']  = $info['wtype'];
-        $item['bcz017']  = $info['zwagall'];
-        $item['cae006']  = $info['community'];
-        $item['cae007']  = $info['province'] . $info['city'] . $info['district'] . $info['address'];
+        $item['aca112'] = $info['title'];
+        $item['bcz002'] = $info['wtype'];
+        $item['bcz017'] = $info['zwagall'];
+        $item['cae006'] = $info['community'];
+        $item['cae007'] = $info['province'] . $info['city'] . $info['district'] . $info['address'];
         if (!empty($info['educationCode']['code'])) {
-            $item['aac011']  = $info['educationCode']['code'];
+            $item['aac011'] = $info['educationCode']['code'];
         }
         if (!empty($info['ageCode']['code'])) {
-            $item['bcz006']  = $info['ageCode']['code'];
-        }
-        $item['caa004s'] = $info['tags_code'];
-        $item['bcz007']  = $info['comdetails'];
-        $item['bcz008']  = $info['requirement'];
-        $item['bcz009']  = $info['worker']['wtype'];
-        $item['aab069']  = $info['worker']['title'];
-        $item['aae005']  = $info['telephone'];
-        $item['aae004']  = $info['worker']['realname'];
-        $item['aae006']  = $info['worker']['province'] . $info['worker']['city'] . $info['worker']['district'] . $info['worker']['address'];
-        $item['bcz018']  = $info['emp_code'];
-        $item['bcz011']  = $info['is_worry'];
-        $item['aae100']  = $info['status'] == 3 ? 1 : 0;
-        $item['bcz015']  = $info['longitude'];
-        $item['bcz016']  = $info['latitude'];
-        $item['bye002']  = $info['updatetime'];
-        $list[]          = array_filter($item);
-        $send['list']    = $list;
+            $item['bcz006'] = $info['ageCode']['code'];
+        }
+        $item['bcz019'] = implode(',', $info['tags']);
+//        $item['caa004s'] = $info['tags_code'];
+        $item['bcz007'] = $info['comdetails'];
+        $item['bcz008'] = $info['requirement'];
+        $item['bcz009'] = $info['worker']['wtype'];
+        $item['aab069'] = $info['worker']['title'];
+        $item['aae005'] = $info['telephone'];
+        $item['aae004'] = $info['worker']['realname'];
+        $item['aae006'] = $info['worker']['province'] . $info['worker']['city'] . $info['worker']['district'] . $info['worker']['address'];
+        $item['bcz018'] = $info['emp_code'];
+        $item['bcz011'] = $info['is_worry'];
+        $item['bcz015'] = $info['longitude'];
+        $item['bcz016'] = $info['latitude'];
+        $item['bye002'] = $info['updatetime'];
+        $item           = array_filter($item);
+        $item['aae100'] = $info['status'] == 3 ? 1 : 0;
+        $list[]         = $item;
+        $send['list']   = $list;
 
         //发送数据
         Log::info('同步人社数据:' . json_encode($send));
@@ -563,4 +571,69 @@ class Comjobs extends BaseController
             ]);
         }
     }
+
+    public function import()
+    {
+        $data       = ['cate', 'title', 'type', 'zwagall', 'community', 'province', 'city', 'district', 'education', 'agegroup', 'tags', 'comdetails', 'requirement',
+                       'worker', 'telephone', 'name', 'address', 'time', 'emp_time', 'is_worry'];
+        $list       = importExecl('21.xlsx', $data, 2);
+        $data       = [];
+        $wtype      = ['按月' => 1, '按时' => 2, '按件' => 3, '按项目' => 4, '面议' => 5];
+        $rensheCode = RensheCode::select();
+        $renshe     = [];
+        foreach ($rensheCode as $v) {
+            $renshe[$v['type']][$v['name']] = $v['code'];
+        }
+        $cateList = ComjobsCateModel::column('id', 'title');
+
+        foreach ($list as $v) {
+            if (empty($v['cate'])) {
+                continue;
+            }
+            $item = [];
+            if (empty($cateList[$v['cate']])) {
+                halt($cateList, $v);
+            }
+            $item['cateid']  = $cateList[$v['cate']];
+            $item['title']   = $v['title'];
+            $item['wtype']   = $wtype[$v['type']];
+            $item['zwagall'] = $v['zwagall'];
+            if (!empty($renshe['community'][$v['community']])) {
+                $item['community'] = $renshe['community'][$v['community']];
+            }
+            $item['province'] = $v['province'];
+            $item['city']     = $v['city'];
+            $item['district'] = $v['district'];
+            if (!empty($renshe['education'][$v['education']])) {
+                $item['education'] = $v['education'];
+            }
+            if (!empty($renshe['age'][$v['agegroup']])) {
+                $item['agegroup'] = $v['agegroup'];
+            }
+            $tags = explode(',', $v['tags']);
+            if (empty($tags[0])) {
+                $tags = [];
+            }
+            $item['tags']        = $tags;
+            $item['comdetails']  = $v['comdetails'];
+            $item['requirement'] = $v['requirement'];
+            $item['workerid']    = 8;
+            $item['telephone']   = (string)$v['telephone'];
+            $item['address']     = (string)$v['address'];
+            $emp_time            = explode(',', $v['emp_time']);
+            if (empty($emp_time[0])) {
+                $emp_time = [];
+            }
+            $item['emp_time']   = $emp_time;
+            $item['is_worry']   = $v['is_worry'] ? $v['is_worry'] : 0;
+            $item['priority']   = 0;
+            $item['status']     = 3;
+            $item['createtime'] = $item['updatetime'] = time();
+            $data[]             = $item;
+        }
+        foreach ($data as $v) {
+            ComjobsModel::create($v);
+        }
+
+    }
 }

+ 191 - 135
app/common.php

@@ -17,13 +17,13 @@ use think\facade\Db;
 define('AMAP_KEY', '937f431e40453c79c1c18af4a69c6b79');
 
 
-function page_result1($code=0, $msg='', $data=array())
+function page_result1($code = 0, $msg = '', $data = [])
 {
-    exit(json_encode(array(
-        'code' 	=> $code,
-        'msg'	=> $msg,
-        'data'  => $data
-    )));
+    exit(json_encode([
+        'code' => $code,
+        'msg'  => $msg,
+        'data' => $data,
+    ]));
 }
 
 
@@ -41,57 +41,57 @@ function page_result1($code=0, $msg='', $data=array())
 function image_copy_image($bg_image, $sub_image, $add_x, $add_y, $add_w, $add_h, $out_image)
 {
     if ($sub_image) {
-        $bg_image_c = imagecreatefromstring(file_get_contents($bg_image));
+        $bg_image_c  = imagecreatefromstring(file_get_contents($bg_image));
         $sub_image_c = imagecreatefromstring(file_get_contents($sub_image));
         imagecopyresampled($bg_image_c, $sub_image_c, $add_x, $add_y, 0, 0, $add_w, $add_h, imagesx($sub_image_c), imagesy($sub_image_c));
         //保存到out_image
         imagejpeg($bg_image_c, $out_image, 80);
         imagedestroy($sub_image_c);
         imagedestroy($bg_image_c);
-		return true;
+        return true;
     }
 }
 
 
-function image_copy_text($dst_path, $text, $font, $size, $picwith, $x, $y, $red, $grn, $blu){
-	$dst = imagecreatefromstring(file_get_contents($dst_path));
-	$arr = imagettfbbox($size,0,$font,$text);
-	$text_width = $arr[2]-$arr[0];
-	$x = $picwith==0 ? $x : intval(($picwith - $text_width)/2);
-	//打上文字
-	$black = imagecolorallocate($dst, $red, $grn, $blu);//字体颜色0x00, 0x00, 0x00
-	imagefttext($dst, $size, 0,  $x, $y, $black, $font, $text);
-	//输出图片
-	list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
-	switch ($dst_type) {
-	    case 1://GIF
-	        header('Content-Type: image/gif');
-	        imagegif($dst, $dst_path);
-	        break;
-	    case 2://JPG
-	        header('Content-Type: image/jpeg');
-	        imagejpeg($dst, $dst_path);
-	        break;
-	    case 3://PNG
-	        header('Content-Type: image/png');
-	        imagepng($dst, $dst_path);
-	        break;
-	    default:
-	        break;
-	}
-	imagedestroy($dst);
+function image_copy_text($dst_path, $text, $font, $size, $picwith, $x, $y, $red, $grn, $blu)
+{
+    $dst        = imagecreatefromstring(file_get_contents($dst_path));
+    $arr        = imagettfbbox($size, 0, $font, $text);
+    $text_width = $arr[2] - $arr[0];
+    $x          = $picwith == 0 ? $x : intval(($picwith - $text_width) / 2);
+    //打上文字
+    $black = imagecolorallocate($dst, $red, $grn, $blu);//字体颜色0x00, 0x00, 0x00
+    imagefttext($dst, $size, 0, $x, $y, $black, $font, $text);
+    //输出图片
+    list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
+    switch ($dst_type) {
+        case 1://GIF
+            header('Content-Type: image/gif');
+            imagegif($dst, $dst_path);
+            break;
+        case 2://JPG
+            header('Content-Type: image/jpeg');
+            imagejpeg($dst, $dst_path);
+            break;
+        case 3://PNG
+            header('Content-Type: image/png');
+            imagepng($dst, $dst_path);
+            break;
+        default:
+            break;
+    }
+    imagedestroy($dst);
 }
 
 function subtext($text, $length)
 {
-    if(mb_strlen($text, 'utf8') > $length) {
-        return mb_substr($text, 0, $length, 'utf8').'...';
+    if (mb_strlen($text, 'utf8') > $length) {
+        return mb_substr($text, 0, $length, 'utf8') . '...';
     } else {
         return $text;
     }
- 
-}
 
+}
 
 
 /**
@@ -102,14 +102,14 @@ function subtext($text, $length)
  */
 function export_excel($expTitle, $expCellName, $expTableData)
 {
-    $xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称
-    $fileName = $expTitle . date('_Ymd');//or $xlsTitle 文件名称可根据自己情况设定
-    $cellNum = count($expCellName);
-    $dataNum = count($expTableData);
+    $xlsTitle    = iconv('utf-8', 'gb2312', $expTitle);//文件名称
+    $fileName    = $expTitle . date('_Ymd');//or $xlsTitle 文件名称可根据自己情况设定
+    $cellNum     = count($expCellName);
+    $dataNum     = count($expTableData);
     $objPHPExcel = new PHPExcel();//方法一
-    $cellName = array('A','B', 'C','D', 'E', 'F','G','H','I', 'J', 'K','L','M', 'N', 'O', 'P', 'Q','R','S', 'T','U','V', 'W', 'X','Y', 'Z', 'AA',
-    'AB', 'AC','AD','AE', 'AF','AG','AH','AI', 'AJ', 'AK', 'AL','AM','AN','AO','AP','AQ','AR', 'AS', 'AT','AU', 'AV','AW', 'AX',
-    'AY', 'AZ');
+    $cellName    = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA',
+                    'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX',
+                    'AY', 'AZ'];
     //设置头部导出时间备注
     $objPHPExcel->getActiveSheet(0)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1');//合并单元格
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $expTitle . ' 导出时间:' . date('Y-m-d H:i:s'));
@@ -121,8 +121,8 @@ function export_excel($expTitle, $expCellName, $expTableData)
     for ($i = 0; $i < $dataNum; $i++) {
         for ($j = 0; $j < $cellNum; $j++) {
             $keyarr = explode(".", $expCellName[$j][0]);
-            $value = $expTableData[$i];
-            foreach ($keyarr as $k=>$v) {
+            $value  = $expTableData[$i];
+            foreach ($keyarr as $k => $v) {
                 $value = $value[$v];
             }
             if (!empty($expCellName[$j][2])) {
@@ -155,7 +155,7 @@ function read_excel($filename)
 {
     //设置excel格式
     $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
-    if ($ext=='xlsx') {
+    if ($ext == 'xlsx') {
         $reader = PHPExcel_IOFactory::createReader('Excel2007');
     } else {
         $reader = PHPExcel_IOFactory::createReader('Excel5');
@@ -168,20 +168,21 @@ function read_excel($filename)
     $row_num = $sheet->getHighestRow();
     //获取总列数
     $col_num = $sheet->getHighestColumn();
-    $data = []; //数组形式获取表格数据
-    for ($col='A';$col<=$col_num;$col++) {
+    $data    = []; //数组形式获取表格数据
+    for ($col = 'A'; $col <= $col_num; $col++) {
         //从第二行开始,去除表头(若无表头则从第一行开始)
-        for ($row=2;$row<=$row_num;$row++) {
-            $data[$row-2][] = $sheet->getCell($col.$row)->getValue();
+        for ($row = 2; $row <= $row_num; $row++) {
+            $data[$row - 2][] = $sheet->getCell($col . $row)->getValue();
         }
     }
     return $data;
 }
 
 //二维数组去重
-function assoc_unique($arr, $key) {
+function assoc_unique($arr, $key)
+{
 
-    $tmp_arr = array();
+    $tmp_arr = [];
 
     foreach ($arr as $k => $v) {
 
@@ -209,87 +210,87 @@ function assoc_unique($arr, $key) {
  */
 function aliyun_ocr_idcard($file)
 {
-    $url = "https://dm-51.data.aliyun.com/rest/160601/ocr/ocr_idcard.json";
+    $url     = "https://dm-51.data.aliyun.com/rest/160601/ocr/ocr_idcard.json";
     $appcode = config('wxconfig.aliAppCode');
     // $file = "你的文件路径";
     //如果输入带有inputs, 设置为True,否则设为False
     $is_old_format = false;
     //如果没有configure字段,config设为空
-    $config = array(
-        "side" => "face"
-    );
+    $config = [
+        "side" => "face",
+    ];
     //$config = array()
     if ($fp = fopen($file, "rb", 0)) {
         $binary = fread($fp, filesize($file)); // 文件读取
         fclose($fp);
         $base64 = base64_encode($binary); // 转码
     }
-    $headers = array();
+    $headers = [];
     array_push($headers, "Authorization:APPCODE " . $appcode);
     //根据API的要求,定义相对应的Content-Type
-    array_push($headers, "Content-Type".":"."application/json; charset=UTF-8");
+    array_push($headers, "Content-Type" . ":" . "application/json; charset=UTF-8");
     $querys = "";
     if ($is_old_format == true) {
-        $request = array();
-        $request["image"] = array(
-                "dataType" => 50,
-                "dataValue" => "$base64"
-        );
+        $request          = [];
+        $request["image"] = [
+            "dataType"  => 50,
+            "dataValue" => "$base64",
+        ];
 
         if (count($config) > 0) {
-            $request["configure"] = array(
-                    "dataType" => 50,
-                    "dataValue" => json_encode($config)
-                );
+            $request["configure"] = [
+                "dataType"  => 50,
+                "dataValue" => json_encode($config),
+            ];
         }
-        $body = json_encode(array("inputs" => array($request)));
+        $body = json_encode(["inputs" => [$request]]);
     } else {
-        $request = array(
-            "image" => "$base64"
-        );
+        $request = [
+            "image" => "$base64",
+        ];
         if (count($config) > 0) {
             $request["configure"] = json_encode($config);
         }
         $body = json_encode($request);
     }
     $method = "POST";
-    $curl = curl_init();
+    $curl   = curl_init();
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($curl, CURLOPT_FAILONERROR, false);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_HEADER, true);
-    if (1 == strpos("$".$url, "https://")) {
+    if (1 == strpos("$" . $url, "https://")) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
     }
     curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
-    $result = curl_exec($curl);
+    $result      = curl_exec($curl);
     $header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
-    $rheader = substr($result, 0, $header_size);
-    $rbody = substr($result, $header_size);
-    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+    $rheader     = substr($result, 0, $header_size);
+    $rbody       = substr($result, $header_size);
+    $httpCode    = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     if ($httpCode == 200) {
         if ($is_old_format) {
-            $output = json_decode($rbody, true);
+            $output     = json_decode($rbody, true);
             $result_str = $output["outputs"][0]["outputValue"]["dataValue"];
         } else {
             $result_str = $rbody;
         }
         $result_arr = json_decode($result_str, true);
-        if ($result_arr['success']==false) {
+        if ($result_arr['success'] == false) {
             return false;
         } else {
-            return array(
-                "name"			=> $result_arr['name'],
-                "nationality"	=> $result_arr['nationality'],
-                "num"			=> $result_arr['num'],
-                "sex"			=> $result_arr['sex'],
-                "birth"			=> date('Y-m-d', strtotime($result_arr['birth'])),
-                "nationality"	=> $result_arr['nationality'],
-                "address"		=> $result_arr['address']
-            );
+            return [
+                "name"        => $result_arr['name'],
+                "nationality" => $result_arr['nationality'],
+                "num"         => $result_arr['num'],
+                "sex"         => $result_arr['sex'],
+                "birth"       => date('Y-m-d', strtotime($result_arr['birth'])),
+                "nationality" => $result_arr['nationality'],
+                "address"     => $result_arr['address'],
+            ];
         }
         return $result_str;
     } else {
@@ -298,16 +299,15 @@ function aliyun_ocr_idcard($file)
 }
 
 
-
 // 两个日期间数组
 function periodDate($start_time, $end_time)
 {
     $start_time = strtotime($start_time);
-    $end_time = strtotime($end_time);
-    $i=0;
-    while ($start_time<=$end_time) {
+    $end_time   = strtotime($end_time);
+    $i          = 0;
+    while ($start_time <= $end_time) {
         $arr[date('Y-m-d', $start_time)] = 0;
-        $start_time = strtotime('+1 day', $start_time);
+        $start_time                      = strtotime('+1 day', $start_time);
         $i++;
     }
     return $arr;
@@ -316,15 +316,15 @@ function periodDate($start_time, $end_time)
 // 数组键值分开
 function arrKeyVal($arr)
 {
-    $keyArr = array();
-    $valArr = array();
+    $keyArr = [];
+    $valArr = [];
     if (!empty($arr)) {
-        foreach ($arr as $k=>$v) {
+        foreach ($arr as $k => $v) {
             $keyArr[] = $k;
             $valArr[] = $v;
         }
     }
-    return array('keyarr'=>$keyArr, 'valarr'=>$valArr);
+    return ['keyarr' => $keyArr, 'valarr' => $valArr];
 }
 
 //获取ip
@@ -347,24 +347,23 @@ function arrKeyVal($arr)
 function is_released($workerid)
 {
     $comjobs_count = Db::name('comjobs')
-                ->where('workerid',$workerid)
-                ->count();
+        ->where('workerid', $workerid)
+        ->count();
 
     $demand_count = Db::name("demand")
-                  ->where('workerid',$workerid)
-                  ->count();
+        ->where('workerid', $workerid)
+        ->count();
 
     $supply_data = Db::name("supply")
-                 ->where('workerid',$workerid)
-                 ->count();
+        ->where('workerid', $workerid)
+        ->count();
 
     $count = $comjobs_count + $demand_count + $supply_data;
-    if($count >= 3)
-    {
+    if ($count >= 3) {
         $rtn['code'] = 1001;
-        $rtn['msg'] = "您的审核还未通过,最多只能发3条信息";
+        $rtn['msg']  = "您的审核还未通过,最多只能发3条信息";
         return $rtn;
-    }else{
+    } else {
 
         $rtn['code'] = 0;
 //        $rtn['code'] = 1001;
@@ -382,33 +381,34 @@ function is_released($workerid)
  * @return Array 范围数组
  */
 
-function calcScope($lat, $lng, $radius) {
-    $degree = (24901*1609)/360.0;
-    $dpmLat = 1/$degree;
-    $radiusLat = $dpmLat*$radius;
-    $minLat = $lat - $radiusLat;    // 最小纬度
-    $maxLat = $lat + $radiusLat;    // 最大纬度
-    $mpdLng = $degree*cos($lat * (PI/180));
-    $dpmLng = 1 / $mpdLng;
-    $radiusLng = $dpmLng*$radius;
-    $minLng = $lng - $radiusLng;   // 最小经度
-    $maxLng = $lng + $radiusLng;   // 最大经度
+function calcScope($lat, $lng, $radius)
+{
+    $degree    = (24901 * 1609) / 360.0;
+    $dpmLat    = 1 / $degree;
+    $radiusLat = $dpmLat * $radius;
+    $minLat    = $lat - $radiusLat;    // 最小纬度
+    $maxLat    = $lat + $radiusLat;    // 最大纬度
+    $mpdLng    = $degree * cos($lat * (PI / 180));
+    $dpmLng    = 1 / $mpdLng;
+    $radiusLng = $dpmLng * $radius;
+    $minLng    = $lng - $radiusLng;   // 最小经度
+    $maxLng    = $lng + $radiusLng;   // 最大经度
 
     /** 返回范围数组 */
-    $scope = array(
-        'minLat'  => $minLat,
-        'maxLat'  => $maxLat,
-        'minLng'  => $minLng,
-        'maxLng'  => $maxLng
-    );
+    $scope = [
+        'minLat' => $minLat,
+        'maxLat' => $maxLat,
+        'minLng' => $minLng,
+        'maxLng' => $maxLng,
+    ];
     return $scope;
 
 }
 
 /**
  * 根据经纬度和半径查询在此范围内的所有的对象
- * @param String $lat  纬度
- * @param String $lng  经度
+ * @param String $lat 纬度
+ * @param String $lng 经度
  * @param float $radius 半径
  * @return Array     计算出来的结果
  */
@@ -431,7 +431,8 @@ function calcScope($lat, $lng, $radius) {
  * @return float 返回两点之间的距离
  */
 
-function calcDistance($lat1, $lng1, $lat2, $lng2) {
+function calcDistance($lat1, $lng1, $lat2, $lng2)
+{
     /** 转换数据类型为 double */
     $lat1 = doubleval($lat1);
     $lng1 = doubleval($lng1);
@@ -439,15 +440,15 @@ function calcDistance($lat1, $lng1, $lat2, $lng2) {
     $lng2 = doubleval($lng2);
     /** 以下算法是 Google 出来的,与大多数经纬度计算工具结果一致 */
     $theta = $lng1 - $lng2;
-    $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
-    $dist = acos($dist);
-    $dist = rad2deg($dist);
+    $dist  = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
+    $dist  = acos($dist);
+    $dist  = rad2deg($dist);
     $miles = $dist * 60 * 1.1515;
     return ($miles * 1.609344);
 }
 
 //$lon1 用户当前经度  $lat1用户当前纬度  $lon2数据库经度的字段名  $lat2数据库纬度的字段名
-function distance_sql($lon1='116.434164',$lat1='39.909843',$lon2='longitude',$lat2='latitude')
+function distance_sql($lon1 = '116.434164', $lat1 = '39.909843', $lon2 = 'longitude', $lat2 = 'latitude')
 {
     $sql = "round(6378.138*2*asin(sqrt(pow(sin( ({$lat1}*pi()/180-{$lat2}*pi()/180)/2),2)+cos({$lat1}*pi()/180)*cos({$lat2}*pi()/180)* pow(sin( ({$lon1}*pi()/180-{$lon2}*pi()/180)/2),2)))*1000) ";
     return $sql;
@@ -495,8 +496,63 @@ function http_request($url, $method = "GET", $postfields = null, $headers = [])
     curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ci, CURLINFO_HEADER_OUT, true);
     /* curl_setopt($ci, CURLOPT_COOKIE, $Cookiestr); * *COOKIE带过去** */
-    $response    = curl_exec($ci);
+    $response = curl_exec($ci);
 
     curl_close($ci);
     return $response;
+}
+
+/**
+ *  数据导入
+ * @param string $file excel文件
+ * @param string $crop
+ * @param string $sheet
+ * @return string   返回解析数据
+ * @throws PHPExcel_Exception
+ * @throws PHPExcel_Reader_Exception
+ */
+
+function importExecl($file = '', $cell = [], $crop = 0, $sheet = 0)
+{
+    $file = iconv("utf-8", "gb2312", $file);   //转码
+    if (empty($file) OR !file_exists($file)) {
+        die('file not exists!');
+    }
+
+    $objRead = new PHPExcel_Reader_Excel2007();   //建立reader对象
+    if (!$objRead->canRead($file)) {
+        $objRead = new PHPExcel_Reader_Excel5();
+        if (!$objRead->canRead($file)) {
+            die('No Excel!');
+        }
+    }
+
+    $cellName  = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ'];
+    $obj       = $objRead->load($file);  //建立excel对象
+    $currSheet = $obj->getSheet($sheet);   //获取指定的sheet表
+    $columnH   = $currSheet->getHighestColumn();   //取得最大的列号
+    $columnCnt = array_search($columnH, $cellName);
+    $rowCnt    = $currSheet->getHighestRow();   //获取总行数
+
+    $data = [];
+    for ($_row = 1; $_row <= $rowCnt; $_row++) {  //读取内容
+        if ($_row > $crop) {
+            for ($_column = 0; $_column <= $columnCnt; $_column++) {
+                $cellId    = $cellName[$_column] . $_row;
+                $cellValue = $currSheet->getCell($cellId)->getValue();
+                //$cellValue = $currSheet->getCell($cellId)->getCalculatedValue();  #获取公式计算的值
+                if ($cellValue instanceof PHPExcel_RichText) {   //富文本转换字符串
+                    $cellValue = $cellValue->__toString();
+                }
+                if (!empty($cell[$_column])) {
+                    $data[$_row][$cell[$_column]] = $cellValue;
+                } else {
+                    $data[$_row][] = $cellValue;
+                }
+            }
+        }
+    }
+
+    return array_values($data);
+
 }

+ 8 - 6
app/common/model/Comjobs.php

@@ -49,6 +49,8 @@ class Comjobs extends Model
         'is_worry'         => 'tinyint',
         'education'        => 'string',
         'emp_time'         => 'string',
+        'company_name'     => 'string',
+        'contact'          => 'string',
     ];
 
     // 设置字段自动转换类型
@@ -111,37 +113,37 @@ class Comjobs extends Model
 
     public function getEmpCodeAttr($value, $data)
     {
-        $emp_time = json_decode($data['emp_time'],true);
+        $emp_time = json_decode($data['emp_time'], true);
         if (empty($emp_time)) {
             return '';
         }
 
         $emp_code = [];
-        $emp_list = RensheCode::where('type','emp_time')->column('code','name');
+        $emp_list = RensheCode::where('type', 'emp_time')->column('code', 'name');
         foreach ($emp_time as $v) {
             if (!empty($emp_list[$v])) {
                 $emp_code[] = $emp_list[$v];
             }
         }
 
-        return implode(',',$emp_code);
+        return implode(',', $emp_code);
     }
 
     public function getTagsCodeAttr($value, $data)
     {
-        $tags = json_decode($data['tags'],true);
+        $tags = json_decode($data['tags'], true);
         if (empty($tags)) {
             return '';
         }
 
         $tags_code = [];
-        $tags_list = RensheCode::where('type','welfare')->column('code','name');
+        $tags_list = RensheCode::where('type', 'welfare')->column('code', 'name');
         foreach ($tags as $v) {
             if (!empty($tags_list[$v])) {
                 $tags_code[] = $tags_list[$v];
             }
         }
 
-        return implode(',',$tags_code);
+        return implode(',', $tags_code);
     }
 }

+ 6 - 0
app/mainapp/controller/Comjobs.php

@@ -179,6 +179,12 @@ class Comjobs extends BaseController
 	{
 		$comjobsid = input('comjobsid/d', 0);
 		$comjobs = ComjobsModel::with('worker')->where('status','in','3,4')->where('id','=',$comjobsid)->findOrEmpty();
+		if (!empty($comjobs['company_name'])) {
+		    $comjobs['worker']['title'] = $comjobs['company_name'];
+		    $comjobs['worker']['city'] = $comjobs['city'];
+		    $comjobs['worker']['district'] = $comjobs['district'];
+		    $comjobs['worker']['address'] = $comjobs['address'];
+        }
 		if ($comjobs->isEmpty()){
 			page_result(1, "招聘信息不存在。");
 		}

+ 11 - 2
app/mainapp/controller/Index.php

@@ -55,6 +55,11 @@ class Index extends BaseController
 		$map[] = ['priority','>',0]; 
 		$map[] = ['status','in','3,4'];
 		$plist = ComjobsModel::with(['worker'])->where($map)->order(['status'=>'asc','priority'=>'desc','updatetime'=>'desc','id'=>'desc'])->page($ppage)->limit($psize)->select();
+		foreach ($plist as $v) {
+		    if (!empty($v['company_name'])) {
+                $v['worker']['title'] = $v['company_name'];
+            }
+        }
 		page_result(0, "", array(
 			'plist' => $plist,
 			'pstatus' => $psize > count($plist) ? 'noMore' : 'more'
@@ -90,8 +95,12 @@ class Index extends BaseController
         $Pages = ceil($count/$limit);
         foreach ($row as $k => $v){
             $row[$k]["tags"]=json_decode($v["tags"]);
-            $workerinfo=WorkerModel::find($v["workerid"]);
-            $row[$k]["worker"]["title"]=$workerinfo["title"];
+            if (!empty($v['company_name'])) {
+                $row[$k]["worker"]["title"]=$v["company_name"];
+            } else {
+                $workerinfo=WorkerModel::find($v["workerid"]);
+                $row[$k]["worker"]["title"]=$workerinfo["title"];
+            }
             $row[$k]["distance"]=round(calcDistance($lat,$lng,$v["latitude"],$v["longitude"]),2)."千米";
             //$row[$k]["distance"]=calcDistance($lat,$lng,$v["latitude"],$v["longitude"])/1000;
         }