Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
2 个修改的文件
包含
96 行增加
和
1 行删除
app/Console/Commands/Geo/GeoCount.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :GeoCount.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/10/13 16:05 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Geo; | ||
| 11 | + | ||
| 12 | +use App\Models\Geo\GeoQuestionLog; | ||
| 13 | +use App\Models\Geo\GeoQuestionResult; | ||
| 14 | +use Illuminate\Console\Command; | ||
| 15 | +use Illuminate\Support\Carbon; | ||
| 16 | + | ||
| 17 | +class GeoCount extends Command | ||
| 18 | +{ | ||
| 19 | + /** | ||
| 20 | + * The name and signature of the console command. | ||
| 21 | + * | ||
| 22 | + * @var string | ||
| 23 | + */ | ||
| 24 | + protected $signature = 'geo_count'; | ||
| 25 | + | ||
| 26 | + public $porject_id;//记录当时执行的project_id | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * The console command description. | ||
| 30 | + * | ||
| 31 | + * @var string | ||
| 32 | + */ | ||
| 33 | + protected $description = 'geo统计数据'; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + public function handle(){ | ||
| 38 | + $this->output('start'); | ||
| 39 | + $this->_action(); | ||
| 40 | + $this->output('end'); | ||
| 41 | + return true; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * @remark :方法 | ||
| 46 | + * @name :_action | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2025/10/13 16:20 | ||
| 50 | + */ | ||
| 51 | + public function _action() | ||
| 52 | + { | ||
| 53 | + //获取前一天的项目id | ||
| 54 | + $date = Carbon::yesterday()->format('Y-m-d'); | ||
| 55 | + $start = $date.' 00:00:00'; | ||
| 56 | + $end = $date.' 23:59:59'; | ||
| 57 | + $geoLogModel = new GeoQuestionLog(); | ||
| 58 | + $project_id = $geoLogModel->formatQuery(['created_at' => ['between',[$start,$end]]])->distinct()->pluck('project_id'); | ||
| 59 | + if(empty($project_id)){ | ||
| 60 | + return true; | ||
| 61 | + } | ||
| 62 | + $geoQuestionResModel = new GeoQuestionResult(); | ||
| 63 | + $platforms = ['gemini','openai','deepseek','poe','perplexity','google_ai_overview','openai-not-network','claude']; | ||
| 64 | + foreach ($project_id as $item){ | ||
| 65 | + $this->output('执行的项目ID----'.$item); | ||
| 66 | + //收录总数 | ||
| 67 | + $total = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]); | ||
| 68 | + $data = [ | ||
| 69 | + 'project_id' => $item, | ||
| 70 | + 'date' => $date, | ||
| 71 | + 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), | ||
| 72 | + 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), | ||
| 73 | + 'total'=>$total,//收录总数 | ||
| 74 | + ]; | ||
| 75 | + foreach ($platforms as $platform){ | ||
| 76 | + $data[$platform] = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'platform'=>$platform,'created_at' => ['between',[$start,$end]]]); | ||
| 77 | + } | ||
| 78 | + //新增一条数据 | ||
| 79 | + $geoQuestionResModel->addReturnId($data); | ||
| 80 | + } | ||
| 81 | + return true; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * 输出日志 | ||
| 86 | + * @param $message | ||
| 87 | + * @return bool | ||
| 88 | + */ | ||
| 89 | + public function output($message) | ||
| 90 | + { | ||
| 91 | + echo date('Y-m-d H:i:s') . ' ' . $message . PHP_EOL; | ||
| 92 | + return true; | ||
| 93 | + } | ||
| 94 | +} |
| @@ -93,8 +93,9 @@ class AsideTicketLogController extends BaseController | @@ -93,8 +93,9 @@ class AsideTicketLogController extends BaseController | ||
| 93 | $ticket->end_at = now(); | 93 | $ticket->end_at = now(); |
| 94 | $ticket->end_time = diffInHours($ticket->created_at,$ticket->end_at); | 94 | $ticket->end_time = diffInHours($ticket->created_at,$ticket->end_at); |
| 95 | $project = $ticket->project; | 95 | $project = $ticket->project; |
| 96 | - if ($project->wechat_switch && !$ticket->close_wechat) | 96 | + if ($project->wechat_switch && !$ticket->close_wechat){ |
| 97 | $project->pushWechatGroupMsg("工单(ID:{$ticket->id})已全部完成,请访问查看详情!"); | 97 | $project->pushWechatGroupMsg("工单(ID:{$ticket->id})已全部完成,请访问查看详情!"); |
| 98 | + } | ||
| 98 | $ticket->pushDing('finish'); | 99 | $ticket->pushDing('finish'); |
| 99 | }else{ | 100 | }else{ |
| 100 | $ticket->status = Tickets::STATUS_YANSHOU; | 101 | $ticket->status = Tickets::STATUS_YANSHOU; |
-
请 注册 或 登录 后发表评论