Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
15 个修改的文件
包含
65 行增加
和
42 行删除
| @@ -85,16 +85,14 @@ class Count extends Command | @@ -85,16 +85,14 @@ class Count extends Command | ||
| 85 | if($arr === false){ | 85 | if($arr === false){ |
| 86 | $data[] = $v['test_domain']; | 86 | $data[] = $v['test_domain']; |
| 87 | } | 87 | } |
| 88 | - //判断数据是否存在 | ||
| 89 | DB::table('gl_count')->insert($arr); | 88 | DB::table('gl_count')->insert($arr); |
| 89 | + Log::channel('day_count')->error('日期:'.$arr['created_at'].'success: ' .$v['test_domain']); | ||
| 90 | } | 90 | } |
| 91 | } | 91 | } |
| 92 | }catch (\Exception $e){ | 92 | }catch (\Exception $e){ |
| 93 | - echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL; | ||
| 94 | - Log::channel('day_count')->error('day_count:失败 ' . $e->getMessage()); | 93 | + Log::channel('day_count')->error('day_count:->error ' . $e->getMessage()); |
| 95 | } | 94 | } |
| 96 | - Log::channel('day_count')->error('day_count:失败的域名 ' .json_encode($data)); | ||
| 97 | - echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL; | 95 | + Log::channel('day_count')->error('success:end'); |
| 98 | echo $this->error; | 96 | echo $this->error; |
| 99 | } | 97 | } |
| 100 | 98 |
| @@ -6,6 +6,7 @@ use App\Models\Inquiry\InquiryCount as InquiryCountModel; | @@ -6,6 +6,7 @@ use App\Models\Inquiry\InquiryCount as InquiryCountModel; | ||
| 6 | use App\Models\Inquiry\InquiryInfo; | 6 | use App\Models\Inquiry\InquiryInfo; |
| 7 | use Carbon\Carbon; | 7 | use Carbon\Carbon; |
| 8 | use Illuminate\Console\Command; | 8 | use Illuminate\Console\Command; |
| 9 | +use Illuminate\Support\Facades\Log; | ||
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| 11 | * @remark : | 12 | * @remark : |
| @@ -62,20 +63,24 @@ class InquiryCount extends Command | @@ -62,20 +63,24 @@ class InquiryCount extends Command | ||
| 62 | //获取昨天的时间 | 63 | //获取昨天的时间 |
| 63 | $yesterday = Carbon::yesterday()->toDateString(); | 64 | $yesterday = Carbon::yesterday()->toDateString(); |
| 64 | $inquiryInfoModel = new InquiryInfo(); | 65 | $inquiryInfoModel = new InquiryInfo(); |
| 65 | - foreach ($this->status as $k=>$v){ | ||
| 66 | - $total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count(); | ||
| 67 | - $untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count(); | ||
| 68 | - $invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count(); | ||
| 69 | - $data[] = [ | ||
| 70 | - 'type'=>$k, | ||
| 71 | - 'day'=>$yesterday, | ||
| 72 | - 'total'=>$total ?? 0, | ||
| 73 | - 'untreated'=>$untreated ?? 0, | ||
| 74 | - 'invalid'=>$invalid ?? 0 | ||
| 75 | - ]; | 66 | + try { |
| 67 | + foreach ($this->status as $k=>$v){ | ||
| 68 | + $total = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']]])->count(); | ||
| 69 | + $untreated = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>1])->count(); | ||
| 70 | + $invalid = $inquiryInfoModel->formatQuery(['created_at'=>['between',[$yesterday.' 00:00:00',$yesterday.' 23:59:59']],'status'=>0])->count(); | ||
| 71 | + $data[] = [ | ||
| 72 | + 'type'=>$k, | ||
| 73 | + 'day'=>$yesterday, | ||
| 74 | + 'total'=>$total ?? 0, | ||
| 75 | + 'untreated'=>$untreated ?? 0, | ||
| 76 | + 'invalid'=>$invalid ?? 0 | ||
| 77 | + ]; | ||
| 78 | + } | ||
| 79 | + $inquiryCount = new InquiryCountModel(); | ||
| 80 | + $inquiryCount->insert($data); | ||
| 81 | + }catch (\Exception $e){ | ||
| 82 | + Log::error('inquiry_count : error'); | ||
| 76 | } | 83 | } |
| 77 | - $inquiryCount = new InquiryCountModel(); | ||
| 78 | - $inquiryCount->insert($data); | ||
| 79 | return true; | 84 | return true; |
| 80 | } | 85 | } |
| 81 | } | 86 | } |
| @@ -81,7 +81,7 @@ class DeleteBlogCategory extends Command | @@ -81,7 +81,7 @@ class DeleteBlogCategory extends Command | ||
| 81 | echo 'success:' . $item['id'] . PHP_EOL; | 81 | echo 'success:' . $item['id'] . PHP_EOL; |
| 82 | }catch (\Exception $e){ | 82 | }catch (\Exception $e){ |
| 83 | echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; | 83 | echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; |
| 84 | - errorLog('项目初始化失败', $item, $e); | 84 | + errorLog('delete_blog_category删除失败', $item, $e); |
| 85 | } | 85 | } |
| 86 | } | 86 | } |
| 87 | return true; | 87 | return true; |
| @@ -81,7 +81,7 @@ class DeleteCustomCategory extends Command | @@ -81,7 +81,7 @@ class DeleteCustomCategory extends Command | ||
| 81 | echo 'success:' . $item['id'] . PHP_EOL; | 81 | echo 'success:' . $item['id'] . PHP_EOL; |
| 82 | }catch (\Exception $e){ | 82 | }catch (\Exception $e){ |
| 83 | echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; | 83 | echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; |
| 84 | - errorLog('项目初始化失败', $item, $e); | 84 | + errorLog('delete_custom_category删除失败', $item, $e); |
| 85 | } | 85 | } |
| 86 | } | 86 | } |
| 87 | return true; | 87 | return true; |
| @@ -68,7 +68,7 @@ class DeleteNewsCategory extends Command | @@ -68,7 +68,7 @@ class DeleteNewsCategory extends Command | ||
| 68 | } | 68 | } |
| 69 | foreach ($list as $item){ | 69 | foreach ($list as $item){ |
| 70 | echo 'start:' . $item['id'] . PHP_EOL; | 70 | echo 'start:' . $item['id'] . PHP_EOL; |
| 71 | -// try { | 71 | + try { |
| 72 | $projectModel = new Project(); | 72 | $projectModel = new Project(); |
| 73 | $projectInfo = $projectModel->read(['id'=>$item['data']['project_id']]); | 73 | $projectInfo = $projectModel->read(['id'=>$item['data']['project_id']]); |
| 74 | if($projectInfo === false){ | 74 | if($projectInfo === false){ |
| @@ -79,10 +79,10 @@ class DeleteNewsCategory extends Command | @@ -79,10 +79,10 @@ class DeleteNewsCategory extends Command | ||
| 79 | DB::disconnect('custom_mysql'); | 79 | DB::disconnect('custom_mysql'); |
| 80 | $noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]); | 80 | $noticeLogModel->edit(['status'=>NoticeLog::STATUS_SUCCESS],['id'=>$item['id']]); |
| 81 | echo 'success:' . $item['id'] . PHP_EOL; | 81 | echo 'success:' . $item['id'] . PHP_EOL; |
| 82 | -// }catch (\Exception $e){ | ||
| 83 | -// echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; | ||
| 84 | -// errorLog('项目初始化失败', $item, $e); | ||
| 85 | -// } | 82 | + }catch (\Exception $e){ |
| 83 | + echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; | ||
| 84 | + errorLog('delete_news_category删除失败', $item, $e); | ||
| 85 | + } | ||
| 86 | } | 86 | } |
| 87 | return true; | 87 | return true; |
| 88 | } | 88 | } |
| @@ -82,7 +82,7 @@ class DeleteProductCategory extends Command | @@ -82,7 +82,7 @@ class DeleteProductCategory extends Command | ||
| 82 | echo 'success:' . $item['id'] . PHP_EOL; | 82 | echo 'success:' . $item['id'] . PHP_EOL; |
| 83 | }catch (\Exception $e){ | 83 | }catch (\Exception $e){ |
| 84 | echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; | 84 | echo 'error:' . $item['id'] . $e->getMessage() . PHP_EOL; |
| 85 | - errorLog('项目初始化失败', $item, $e); | 85 | + errorLog('delete_product_category删除失败', $item, $e); |
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | return true; | 88 | return true; |
| @@ -72,7 +72,6 @@ class DomainInfo extends Command | @@ -72,7 +72,6 @@ class DomainInfo extends Command | ||
| 72 | 'domain_start_time' => $time['start'], | 72 | 'domain_start_time' => $time['start'], |
| 73 | 'domain_end_time' => $time['end'] | 73 | 'domain_end_time' => $time['end'] |
| 74 | ]; | 74 | ]; |
| 75 | - | ||
| 76 | $domainModel->edit($data, ['id' => $v['id']]); | 75 | $domainModel->edit($data, ['id' => $v['id']]); |
| 77 | } | 76 | } |
| 78 | } | 77 | } |
| @@ -47,8 +47,6 @@ class RemainDay extends Command | @@ -47,8 +47,6 @@ class RemainDay extends Command | ||
| 47 | $list = Project::whereIn('type', [2,3,4])->get(); | 47 | $list = Project::whereIn('type', [2,3,4])->get(); |
| 48 | foreach ($list as $item){ | 48 | foreach ($list as $item){ |
| 49 | if($item['type'] == Project::TYPE_TWO){ | 49 | if($item['type'] == Project::TYPE_TWO){ |
| 50 | - //排名达标天数 | ||
| 51 | -// $compliance_day = GoogleRankModel::where(['project_id' => $item['id'], 'lang' => ''])->value('compliance_day') ?: 0; | ||
| 52 | //获取当前项目的达标天数 | 50 | //获取当前项目的达标天数 |
| 53 | $compliance_day = Project::where(['id' => $item['id']])->value('finish_remain_day') ?: 0; | 51 | $compliance_day = Project::where(['id' => $item['id']])->value('finish_remain_day') ?: 0; |
| 54 | $remain_day = $item['deploy_build']['service_duration'] - $compliance_day; | 52 | $remain_day = $item['deploy_build']['service_duration'] - $compliance_day; |
| @@ -73,8 +73,9 @@ class InquiryMonthlyCount extends Command | @@ -73,8 +73,9 @@ class InquiryMonthlyCount extends Command | ||
| 73 | $arr['month'] = Carbon::now()->subMonth()->format('Y-m'); | 73 | $arr['month'] = Carbon::now()->subMonth()->format('Y-m'); |
| 74 | try { | 74 | try { |
| 75 | DB::table('gl_month_count')->insert($arr); | 75 | DB::table('gl_month_count')->insert($arr); |
| 76 | + Log::channel('month_count')->error('success:project_id .'.$arr['project_id']); | ||
| 76 | }catch (\Exception $e){ | 77 | }catch (\Exception $e){ |
| 77 | - Log::channel('month_count')->error('month_count:失败 ' . $e->getMessage()); | 78 | + Log::channel('month_count')->error('month_count:error ' . $e->getMessage()); |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| 80 | return true; | 81 | return true; |
| @@ -207,7 +207,7 @@ class ReplaceHtml extends Command | @@ -207,7 +207,7 @@ class ReplaceHtml extends Command | ||
| 207 | return $this->getCustomName($source,$source_id,$is_list); | 207 | return $this->getCustomName($source,$source_id,$is_list); |
| 208 | } | 208 | } |
| 209 | if($source == BTemplate::SOURCE_HOME){ | 209 | if($source == BTemplate::SOURCE_HOME){ |
| 210 | - return ['name'=>'','route'=>''];; | 210 | + return ['name'=>'','route'=>'']; |
| 211 | }elseif ($source == BTemplate::SOURCE_PRODUCT){ | 211 | }elseif ($source == BTemplate::SOURCE_PRODUCT){ |
| 212 | return $this->getProductName($source_id,$is_list); | 212 | return $this->getProductName($source_id,$is_list); |
| 213 | }elseif ($source == BTemplate::SOURCE_BLOG){ | 213 | }elseif ($source == BTemplate::SOURCE_BLOG){ |
| @@ -173,7 +173,7 @@ class KeywordVideoController extends BaseController | @@ -173,7 +173,7 @@ class KeywordVideoController extends BaseController | ||
| 173 | $keywordModel = new KeywordVideoTask(); | 173 | $keywordModel = new KeywordVideoTask(); |
| 174 | $data['total'] = $keywordModel->count(); | 174 | $data['total'] = $keywordModel->count(); |
| 175 | $data['start_total'] = $keywordModel->formatQuery(['status'=>0])->count(); | 175 | $data['start_total'] = $keywordModel->formatQuery(['status'=>0])->count(); |
| 176 | - $data['end_total'] = $keywordModel->formatQuery(['status'=>2])->count(); | 176 | + $data['end_total'] = $keywordModel->formatQuery(['status'=>1])->count(); |
| 177 | $this->response('success',Code::SUCCESS,$data); | 177 | $this->response('success',Code::SUCCESS,$data); |
| 178 | } | 178 | } |
| 179 | } | 179 | } |
| @@ -45,8 +45,8 @@ class NewsCategoryLogic extends BaseLogic | @@ -45,8 +45,8 @@ class NewsCategoryLogic extends BaseLogic | ||
| 45 | public function newsCategorySave(){ | 45 | public function newsCategorySave(){ |
| 46 | //验证名称是否存在 | 46 | //验证名称是否存在 |
| 47 | $this->verifyParamName($this->param['name']); | 47 | $this->verifyParamName($this->param['name']); |
| 48 | - DB::beginTransaction(); | ||
| 49 | - try { | 48 | +// DB::beginTransaction(); |
| 49 | +// try { | ||
| 50 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 50 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 51 | $id = $this->param['id']; | 51 | $id = $this->param['id']; |
| 52 | $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); | 52 | $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 | @@ -62,11 +62,11 @@ class NewsCategoryLogic extends BaseLogic | ||
| 62 | $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); | 62 | $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); |
| 63 | $this->model->edit(['alias'=>$route],['id'=>$id]); | 63 | $this->model->edit(['alias'=>$route],['id'=>$id]); |
| 64 | } | 64 | } |
| 65 | - DB::commit(); | ||
| 66 | - }catch (\Exception $e){ | ||
| 67 | - DB::rollBack(); | ||
| 68 | - $this->fail('系统错误,请联系管理员'); | ||
| 69 | - } | 65 | +// DB::commit(); |
| 66 | +// }catch (\Exception $e){ | ||
| 67 | +// DB::rollBack(); | ||
| 68 | +// $this->fail('系统错误,请联系管理员'); | ||
| 69 | +// } | ||
| 70 | $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route); | 70 | $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route); |
| 71 | $this->curlDelRoute(['new_route'=>$route]); | 71 | $this->curlDelRoute(['new_route'=>$route]); |
| 72 | return $this->success(['id'=>$id]); | 72 | return $this->success(['id'=>$id]); |
| @@ -317,7 +317,8 @@ class CategoryLogic extends BaseLogic | @@ -317,7 +317,8 @@ class CategoryLogic extends BaseLogic | ||
| 317 | */ | 317 | */ |
| 318 | public function copyTemplate($id,$project_id,$save_id){ | 318 | public function copyTemplate($id,$project_id,$save_id){ |
| 319 | $BTemplateModel = new BTemplate(); | 319 | $BTemplateModel = new BTemplate(); |
| 320 | - $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]); | 320 | + $list = $BTemplateModel->list(['source'=>BTemplate::SOURCE_PRODUCT,'is_list'=>BTemplate::IS_LIST, |
| 321 | + 'is_custom'=>BTemplate::IS_NO_CUSTOM,'source_id'=>$id,'project_id'=>$project_id]); | ||
| 321 | if(!empty($list)){ | 322 | if(!empty($list)){ |
| 322 | $data = []; | 323 | $data = []; |
| 323 | foreach ($list as $v){ | 324 | foreach ($list as $v){ |
| @@ -4,6 +4,7 @@ namespace App\Models; | @@ -4,6 +4,7 @@ namespace App\Models; | ||
| 4 | 4 | ||
| 5 | use Illuminate\Database\Eloquent\Model; | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | use Illuminate\Support\Facades\DB; | 6 | use Illuminate\Support\Facades\DB; |
| 7 | +use Illuminate\Support\Facades\Schema; | ||
| 7 | 8 | ||
| 8 | class Base extends Model | 9 | class Base extends Model |
| 9 | { | 10 | { |
| @@ -94,6 +95,7 @@ class Base extends Model | @@ -94,6 +95,7 @@ class Base extends Model | ||
| 94 | * @time :2023/8/21 17:18 | 95 | * @time :2023/8/21 17:18 |
| 95 | */ | 96 | */ |
| 96 | public function add($data){ | 97 | public function add($data){ |
| 98 | + $data = $this->filterRequestData($data,$this->table); | ||
| 97 | $data['created_at'] = date('Y-m-d H:i:s'); | 99 | $data['created_at'] = date('Y-m-d H:i:s'); |
| 98 | $data['updated_at'] = $data['created_at']; | 100 | $data['updated_at'] = $data['created_at']; |
| 99 | return $this->insert($data); | 101 | return $this->insert($data); |
| @@ -107,6 +109,7 @@ class Base extends Model | @@ -107,6 +109,7 @@ class Base extends Model | ||
| 107 | * @time :2023/8/21 17:17 | 109 | * @time :2023/8/21 17:17 |
| 108 | */ | 110 | */ |
| 109 | public function addReturnId($data){ | 111 | public function addReturnId($data){ |
| 112 | + $data = $this->filterRequestData($data,$this->table); | ||
| 110 | $data['created_at'] = date('Y-m-d H:i:s'); | 113 | $data['created_at'] = date('Y-m-d H:i:s'); |
| 111 | $data['updated_at'] = $data['created_at']; | 114 | $data['updated_at'] = $data['created_at']; |
| 112 | return $this->insertGetId($data); | 115 | return $this->insertGetId($data); |
| @@ -123,6 +126,7 @@ class Base extends Model | @@ -123,6 +126,7 @@ class Base extends Model | ||
| 123 | if(isset($data['id']) && !empty($data['id'])){ | 126 | if(isset($data['id']) && !empty($data['id'])){ |
| 124 | unset($data['id']); | 127 | unset($data['id']); |
| 125 | } | 128 | } |
| 129 | + $data = $this->filterRequestData($data,$this->table); | ||
| 126 | $query = $this->formatQuery($condition); | 130 | $query = $this->formatQuery($condition); |
| 127 | $data['updated_at'] = date('Y-m-d H:i:s'); | 131 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 128 | return $query->update($data); | 132 | return $query->update($data); |
| @@ -140,6 +144,7 @@ class Base extends Model | @@ -140,6 +144,7 @@ class Base extends Model | ||
| 140 | $query = $this->formatQuery($condition); | 144 | $query = $this->formatQuery($condition); |
| 141 | return $query->delete(); | 145 | return $query->delete(); |
| 142 | } | 146 | } |
| 147 | + | ||
| 143 | /** | 148 | /** |
| 144 | * @name :参数处理查询 | 149 | * @name :参数处理查询 |
| 145 | * @param $map = ['$k'=>['like',$v],$k1] | 150 | * @param $map = ['$k'=>['like',$v],$k1] |
| @@ -226,8 +231,6 @@ class Base extends Model | @@ -226,8 +231,6 @@ class Base extends Model | ||
| 226 | */ | 231 | */ |
| 227 | protected static function booted() | 232 | protected static function booted() |
| 228 | { | 233 | { |
| 229 | - //保存前数据 $row->original['xx'] | ||
| 230 | - //保存后数据 $row->xx | ||
| 231 | static::saved(function ($row) { | 234 | static::saved(function ($row) { |
| 232 | //删除缓存 | 235 | //删除缓存 |
| 233 | $row->original && static::clearCache($row); | 236 | $row->original && static::clearCache($row); |
| @@ -251,4 +254,21 @@ class Base extends Model | @@ -251,4 +254,21 @@ class Base extends Model | ||
| 251 | return true; | 254 | return true; |
| 252 | } | 255 | } |
| 253 | 256 | ||
| 257 | + /** | ||
| 258 | + * @remark :过滤掉请求数据中不存在于数据库表中的字段 | ||
| 259 | + * @name :filterRequestData | ||
| 260 | + * @author :lyh | ||
| 261 | + * @method :post | ||
| 262 | + * @time :2024/6/14 10:49 | ||
| 263 | + */ | ||
| 264 | + public function filterRequestData(array $data, $table) | ||
| 265 | + { | ||
| 266 | + // 获取表的字段列表 | ||
| 267 | + $columns = Schema::connection($this->connection)->getColumnListing($table); | ||
| 268 | + // 过滤数据 | ||
| 269 | + return array_filter($data, function ($key) use ($columns) { | ||
| 270 | + return in_array($key, $columns); | ||
| 271 | + }, ARRAY_FILTER_USE_KEY); | ||
| 272 | + } | ||
| 273 | + | ||
| 254 | } | 274 | } |
-
请 注册 或 登录 后发表评论