作者 Your Name
... ... @@ -85,16 +85,14 @@ class Count extends Command
if($arr === false){
$data[] = $v['test_domain'];
}
//判断数据是否存在
DB::table('gl_count')->insert($arr);
Log::channel('day_count')->error('日期:'.$arr['created_at'].'success: ' .$v['test_domain']);
}
}
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL;
Log::channel('day_count')->error('day_count:失败 ' . $e->getMessage());
Log::channel('day_count')->error('day_count:->error ' . $e->getMessage());
}
Log::channel('day_count')->error('day_count:失败的域名 ' .json_encode($data));
echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
Log::channel('day_count')->error('success:end');
echo $this->error;
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Models\Inquiry\InquiryCount as InquiryCountModel;
use App\Models\Inquiry\InquiryInfo;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
/**
* @remark :
... ... @@ -62,20 +63,24 @@ class InquiryCount extends Command
//获取昨天的时间
$yesterday = Carbon::yesterday()->toDateString();
$inquiryInfoModel = new InquiryInfo();
foreach ($this->status as $k=>$v){
$total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count();
$untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count();
$invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count();
$data[] = [
'type'=>$k,
'day'=>$yesterday,
'total'=>$total ?? 0,
'untreated'=>$untreated ?? 0,
'invalid'=>$invalid ?? 0
];
try {
foreach ($this->status as $k=>$v){
$total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count();
$untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count();
$invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count();
$data[] = [
'type'=>$k,
'day'=>$yesterday,
'total'=>$total ?? 0,
'untreated'=>$untreated ?? 0,
'invalid'=>$invalid ?? 0
];
}
$inquiryCount = new InquiryCountModel();
$inquiryCount->insert($data);
}catch (\Exception $e){
Log::error('inquiry_count : error');
}
$inquiryCount = new InquiryCountModel();
$inquiryCount->insert($data);
return true;
}
}
... ...
... ... @@ -81,7 +81,7 @@ class DeleteBlogCategory extends Command
echo 'success:' . $item['id'] . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('项目初始化失败', $item, $e);
errorLog('delete_blog_category删除失败', $item, $e);
}
}
return true;
... ...
... ... @@ -81,7 +81,7 @@ class DeleteCustomCategory extends Command
echo 'success:' . $item['id'] . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('项目初始化失败', $item, $e);
errorLog('delete_custom_category删除失败', $item, $e);
}
}
return true;
... ...
... ... @@ -68,7 +68,7 @@ class DeleteNewsCategory extends Command
}
foreach ($list as $item){
echo 'start:' . $item['id'] . PHP_EOL;
// try {
try {
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$item['data']['project_id']]);
if($projectInfo === false){
... ... @@ -79,10 +79,10 @@ class DeleteNewsCategory extends Command
DB::disconnect('custom_mysql');
$noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]);
echo 'success:' . $item['id'] . PHP_EOL;
// }catch (\Exception $e){
// echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
// errorLog('项目初始化失败', $item, $e);
// }
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('delete_news_category删除失败', $item, $e);
}
}
return true;
}
... ...
... ... @@ -82,7 +82,7 @@ class DeleteProductCategory extends Command
echo 'success:' . $item['id'] . PHP_EOL;
}catch (\Exception $e){
echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL;
errorLog('项目初始化失败', $item, $e);
errorLog('delete_product_category删除失败', $item, $e);
}
}
return true;
... ...
... ... @@ -72,7 +72,6 @@ class DomainInfo extends Command
'domain_start_time' => $time['start'],
'domain_end_time' => $time['end']
];
$domainModel->edit($data, ['id' => $v['id']]);
}
}
... ...
... ... @@ -47,8 +47,6 @@ class RemainDay extends Command
$list = Project::whereIn('type', [2,3,4])->get();
foreach ($list as $item){
if($item['type'] == Project::TYPE_TWO){
//排名达标天数
// $compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0;
//获取当前项目的达标天数
$compliance_day = Project::where(['id' => $item['id']])->value('finish_remain_day') ?: 0;
$remain_day = $item['deploy_build']['service_duration'] - $compliance_day;
... ...
... ... @@ -62,6 +62,7 @@ class ServiceCount extends Command
}
$model->edit(['count'=>$count],['id'=>$v['id']]);
}
return true;
}
}
... ...
... ... @@ -73,8 +73,9 @@ class InquiryMonthlyCount extends Command
$arr['month'] = Carbon::now()->subMonth()->format('Y-m');
try {
DB::table('gl_month_count')->insert($arr);
Log::channel('month_count')->error('success:project_id .'.$arr['project_id']);
}catch (\Exception $e){
Log::channel('month_count')->error('month_count:失败 ' . $e->getMessage());
Log::channel('month_count')->error('month_count:error ' . $e->getMessage());
}
}
return true;
... ...
... ... @@ -207,7 +207,7 @@ class ReplaceHtml extends Command
return $this->getCustomName($source,$source_id,$is_list);
}
if($source == BTemplate::SOURCE_HOME){
return ['name'=>'','route'=>''];;
return ['name'=>'','route'=>''];
}elseif ($source == BTemplate::SOURCE_PRODUCT){
return $this->getProductName($source_id,$is_list);
}elseif ($source == BTemplate::SOURCE_BLOG){
... ...
... ... @@ -173,7 +173,7 @@ class KeywordVideoController extends BaseController
$keywordModel = new KeywordVideoTask();
$data['total'] = $keywordModel->count();
$data['start_total'] = $keywordModel->formatQuery(['status'=>0])->count();
$data['end_total'] = $keywordModel->formatQuery(['status'=>2])->count();
$data['end_total'] = $keywordModel->formatQuery(['status'=>1])->count();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -45,8 +45,8 @@ class NewsCategoryLogic extends BaseLogic
public function newsCategorySave(){
//验证名称是否存在
$this->verifyParamName($this->param['name']);
DB::beginTransaction();
try {
// DB::beginTransaction();
// try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
... ... @@ -62,11 +62,11 @@ class NewsCategoryLogic extends BaseLogic
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理员');
}
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('系统错误,请联系管理员');
// }
$this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
$this->curlDelRoute(['new_route'=>$route]);
return $this->success(['id'=>$id]);
... ...
... ... @@ -317,7 +317,8 @@ class CategoryLogic extends BaseLogic
*/
public function copyTemplate($id,$project_id,$save_id){
$BTemplateModel = new BTemplate();
$list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_LIST,'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]);
$list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_LIST,
'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]);
if(!empty($list)){
$data = [];
foreach ($list as $v){
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class Base extends Model
{
... ... @@ -94,6 +95,7 @@ class Base extends Model
* @time :2023/8/21 17:18
*/
public function add($data){
$data = $this->filterRequestData($data,$this->table);
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = $data['created_at'];
return $this->insert($data);
... ... @@ -107,6 +109,7 @@ class Base extends Model
* @time :2023/8/21 17:17
*/
public function addReturnId($data){
$data = $this->filterRequestData($data,$this->table);
$data['created_at'] = date('Y-m-d H:i:s');
$data['updated_at'] = $data['created_at'];
return $this->insertGetId($data);
... ... @@ -123,6 +126,7 @@ class Base extends Model
if(isset($data['id']) && !empty($data['id'])){
unset($data['id']);
}
$data = $this->filterRequestData($data,$this->table);
$query = $this->formatQuery($condition);
$data['updated_at'] = date('Y-m-d H:i:s');
return $query->update($data);
... ... @@ -140,6 +144,7 @@ class Base extends Model
$query = $this->formatQuery($condition);
return $query->delete();
}
/**
* @name :参数处理查询
* @param $map = ['$k'=>['like',$v],$k1]
... ... @@ -226,8 +231,6 @@ class Base extends Model
*/
protected static function booted()
{
//保存前数据 $row->original['xx']
//保存后数据 $row->xx
static::saved(function ($row) {
//删除缓存
$row->original && static::clearCache($row);
... ... @@ -251,4 +254,21 @@ class Base extends Model
return true;
}
/**
* @remark :过滤掉请求数据中不存在于数据库表中的字段
* @name :filterRequestData
* @author :lyh
* @method :post
* @time :2024/6/14 10:49
*/
public function filterRequestData(array $data, $table)
{
// 获取表的字段列表
$columns = Schema::connection($this->connection)->getColumnListing($table);
// 过滤数据
return array_filter($data, function ($key) use ($columns) {
return in_array($key, $columns);
}, ARRAY_FILTER_USE_KEY);
}
}
... ...