Commit d149b5c3 authored by yinxiaoling's avatar yinxiaoling

去掉url验证

parent b4ba53fa
......@@ -16,11 +16,11 @@ class LoginApiController extends BaseController
$url = $request->url;
Log::channel('api')->info(substr(md5(json_encode($param)),1,8));
Log::channel('api')->info($url);
/* Log::channel('api')->info($url);
if($url != substr(md5(json_encode($param)),1,8)){
return $this->errorWithInfo('url验证不通过', 401);
}
} */
if(empty($param['username']) || empty($param['password'] )){
return $this->errorWithInfo('参数验证不通过', 401);
}
......
......@@ -39,7 +39,7 @@ class StrategySetController extends Controller
return $this->errorWithInfo($excelData['msg'], 401);
}
//验证excel数据格式及不合格数据原因
$StrategyService->validExcelData($excelData, $request->day_type);
$excelDataValid = $StrategyService->validExcelData($excelData, $request->day_type);
}
dd($excelData);
dd('策略添加');
......
......@@ -25,7 +25,7 @@ class CheckApiKey
$api_key=$request->api_key;
$user_sn=$request->user_sn;
if (empty($url) || empty($api_key) || empty($user_sn)){
if (empty($api_key) || empty($user_sn)){
return $this->errorWithInfo('参数验证不通过', 401);
}
......@@ -33,7 +33,7 @@ class CheckApiKey
Log::channel('api')->info('API_PARAM:'.json_encode($param));
Log::channel('api')->info('API_SERVER_PARAM:'.substr(md5(json_encode($param)),1,8));
Log::channel('api')->info('API_CLIENT_PARAM:'.$url);
/* Log::channel('api')->info('API_CLIENT_PARAM:'.$url);
$md_url = substr(md5(json_encode($param)),1,8);
......@@ -41,7 +41,7 @@ class CheckApiKey
if($_SERVER['REQUEST_SCHEME'] == 'http'){
return $this->errorWithInfo('验证url失败', 401);
}
}
} */
$user = DB::table('users')->where('user_sn',$param['user_sn'])->first();
......@@ -51,7 +51,9 @@ class CheckApiKey
$puser = DB::table('users')->where('user_name',$user->parent_sn)->select('expired')->first();
$the_expired = $puser->expired;
}
if ($api_key != $user->api_key){
return $this->errorWithInfo('key验证失败', 401);
}
$todayDate = strtotime(date('y-m-d 00:00:00',time()));
$expiredDate =strtotime($the_expired. ' 00:00:00');
......
......@@ -2,6 +2,7 @@
namespace App\Service;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Log;
class StrategyService
{
......@@ -51,8 +52,6 @@ class StrategyService
}
//判断excel数据问题,$day_type//外呼日期类型 0每天 1日期前一天和当天 1需要验证值班日期必填
public function validExcelData($data,$day_type){
//$failDataTitle = ['姓名','*手机号码','值班日期','失败原因'];
//dump($data);
$failData = [];
foreach ($data as $k=>$v){
$dataLab = 1;
......@@ -88,11 +87,66 @@ class StrategyService
unset($data[$k]);
}
}
dump($failData, $data);
$failTotal = count($failData);
$successTotal = count($data);
dd('====================');
if ($failTotal > 0){//把导出错误数据存入excel表格中供下载
$failDataTitle = ['姓名','*手机号码','值班日期','失败原因'];
array_unshift($failData, $failDataTitle);
$failExcelName = "导入失败数据_".date('YmdHis');
$this->storeExcelStyle($failExcelName, $failData);
}
return compact('data','failData','failTotal','successTotal');
}
//保存内容到excel文件并下载
public function storeExcelStyle($excelName,$datas,$endLen='',$path=''){
try{
$arr = range('A','Z');
if (!empty($endLen)){
$endLen = $endLen - 1;
if(isset($arr[$endLen])){
$arr = range('A',$arr[$endLen]);
}
}
$e = Excel::create(iconv('UTF-8', 'GBK', $excelName),function($excel) use ($datas,$arr){
$excel->sheet('score', function($sheet) use ($datas,$arr){
$col =array();
$sheet->rows($datas);
foreach($arr as $v){
$col[$v]=12;
}
$sheet->setWidth($col);
foreach ($arr as $k=> $v){
$objRichText = new \PHPExcel_RichText();
if(!empty($datas[0][$k])){
if (strpos($datas[0][$k], '*') === 0){
$objPayable = $objRichText->createTextRun('*');
$objPayable->getFont()->setColor( new \PHPExcel_Style_Color( \PHPExcel_Style_Color::COLOR_RED ) );//设置颜色
}
$objRichText->createText(ltrim($datas[0][$k],'*'));
$sheet->setCellValue($arr[$k].'1',$objRichText);
}
}
});
});
if (empty($path)){//默认路径storage/exports
$e->store('xlsx');
}else{//自定义路径 storage/$path
$e->store('xlsx', storage_path($path));
}
return true;
}catch(\Exception $e){
Log::channel('api')->error($e->getFile().'-'.$e->getLine().'-'.$e->getMessage());
return false;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment