Merge remote-tracking branch 'origin/master' into akun
正在显示
9 个修改的文件
包含
128 行增加
和
12 行删除
| @@ -87,8 +87,13 @@ class ReplaceHtmlLog extends Command | @@ -87,8 +87,13 @@ class ReplaceHtmlLog extends Command | ||
| 87 | if($info['template_id'] == 0){ | 87 | if($info['template_id'] == 0){ |
| 88 | $bTemplateModel->formatQuery($condition)->update(['html' => DB::raw("REPLACE(html, '$old_html', '$html')")]); | 88 | $bTemplateModel->formatQuery($condition)->update(['html' => DB::raw("REPLACE(html, '$old_html', '$html')")]); |
| 89 | }else{ | 89 | }else{ |
| 90 | - $bTemplateModel->formatQuery($condition)->update(['main_html' => DB::raw("REPLACE(main_html, '$old_html', '$html')")]); | 90 | + $bTemplateModel->where($condition) |
| 91 | + ->update([ | ||
| 92 | + 'main_html' => DB::raw("REPLACE(main_html, '" . addslashes($old_html) . "', '" . addslashes($html) . "')"), | ||
| 93 | + 'updated_at' => now(), | ||
| 94 | + ]); | ||
| 91 | } | 95 | } |
| 92 | return true; | 96 | return true; |
| 93 | } | 97 | } |
| 98 | + | ||
| 94 | } | 99 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :UpdateHeartbeat.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/8/28 15:13 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Console\Commands\Update; | ||
| 11 | + | ||
| 12 | +use App\Models\Log\OperationHeartbeat; | ||
| 13 | +use App\Models\Project\Project; | ||
| 14 | +use App\Services\ProjectServer; | ||
| 15 | +use Illuminate\Console\Command; | ||
| 16 | +use Illuminate\Support\Facades\DB; | ||
| 17 | + | ||
| 18 | +class UpdateHeartbeat extends Command | ||
| 19 | +{ | ||
| 20 | + /** | ||
| 21 | + * The name and signature of the console command. | ||
| 22 | + * | ||
| 23 | + * @var string | ||
| 24 | + */ | ||
| 25 | + protected $signature = 'operation_heartbeat'; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * The console command description. | ||
| 29 | + * | ||
| 30 | + * @var string | ||
| 31 | + */ | ||
| 32 | + protected $description = '心跳半小时未操作更新为未操作'; | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * @remark :更新半小时未操作的界面 | ||
| 37 | + * @name :handle | ||
| 38 | + * @author :lyh | ||
| 39 | + * @method :post | ||
| 40 | + * @time :2024/8/28 15:25 | ||
| 41 | + */ | ||
| 42 | + public function handle(){ | ||
| 43 | + $date = date('Y-m-d H:i:s',time() - 30 * 60); | ||
| 44 | + $operationHeartbeatModel = new OperationHeartbeat(); | ||
| 45 | + $operationHeartbeatModel->edit(['status'=>0],['updated_at'=>['<=',$date]]); | ||
| 46 | + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | ||
| 47 | + } | ||
| 48 | +} |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | 3 | ||
| 4 | namespace App\Helper; | 4 | namespace App\Helper; |
| 5 | 5 | ||
| 6 | +use App\Models\RankData\RankDataLog; | ||
| 6 | use App\Utils\HttpUtils; | 7 | use App\Utils\HttpUtils; |
| 7 | use GuzzleHttp\Client; | 8 | use GuzzleHttp\Client; |
| 8 | use GuzzleHttp\Exception\GuzzleException; | 9 | use GuzzleHttp\Exception\GuzzleException; |
| @@ -75,6 +76,7 @@ class QuanqiusouApi | @@ -75,6 +76,7 @@ class QuanqiusouApi | ||
| 75 | 76 | ||
| 76 | /** | 77 | /** |
| 77 | * 获取谷歌排名数据 | 78 | * 获取谷歌排名数据 |
| 79 | + * @param $project_id | ||
| 78 | * @param $api_no | 80 | * @param $api_no |
| 79 | * @param string $lang | 81 | * @param string $lang |
| 80 | * @param int $day | 82 | * @param int $day |
| @@ -82,7 +84,7 @@ class QuanqiusouApi | @@ -82,7 +84,7 @@ class QuanqiusouApi | ||
| 82 | * @author zbj | 84 | * @author zbj |
| 83 | * @date 2023/5/11 | 85 | * @date 2023/5/11 |
| 84 | */ | 86 | */ |
| 85 | - public function getGoogleRank($api_no, string $lang = '', int $day = 7, $force = true) | 87 | + public function getGoogleRank($project_id, $api_no, string $lang = '', int $day = 7, $force = true) |
| 86 | { | 88 | { |
| 87 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); | 89 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); |
| 88 | $res = Cache::get($key); | 90 | $res = Cache::get($key); |
| @@ -105,6 +107,7 @@ class QuanqiusouApi | @@ -105,6 +107,7 @@ class QuanqiusouApi | ||
| 105 | if($res){ | 107 | if($res){ |
| 106 | $res = Arr::s2a($res); | 108 | $res = Arr::s2a($res); |
| 107 | Cache::put($key, $res, 2 * 3600); | 109 | Cache::put($key, $res, 2 * 3600); |
| 110 | + RankDataLog::addLog($project_id, $api_no, $lang, $endDay, $res); | ||
| 108 | } | 111 | } |
| 109 | } catch (\Exception | GuzzleException $e) { | 112 | } catch (\Exception | GuzzleException $e) { |
| 110 | errorLog('获取谷歌排名数据失败', [$api_no], $e); | 113 | errorLog('获取谷歌排名数据失败', [$api_no], $e); |
| @@ -25,22 +25,25 @@ class OperationHeartbeatController extends BaseController | @@ -25,22 +25,25 @@ class OperationHeartbeatController extends BaseController | ||
| 25 | public function saveHeartbeat(){ | 25 | public function saveHeartbeat(){ |
| 26 | $this->request->validate([ | 26 | $this->request->validate([ |
| 27 | 'source'=>'required', | 27 | 'source'=>'required', |
| 28 | + 'source_id'=>'required', | ||
| 28 | 'is_list' => 'required', | 29 | 'is_list' => 'required', |
| 29 | 'is_custom'=>'required', | 30 | 'is_custom'=>'required', |
| 30 | 'is_template'=>'required', | 31 | 'is_template'=>'required', |
| 31 | - 'operator_id'=>'required', | ||
| 32 | ], [ | 32 | ], [ |
| 33 | 'source.required' => '请选择页面', | 33 | 'source.required' => '请选择页面', |
| 34 | + 'source_id.required' => '请选择数据id', | ||
| 34 | 'is_list.required' => '列表页/详情页', | 35 | 'is_list.required' => '列表页/详情页', |
| 35 | 'is_custom.required' => '是否为扩展模版', | 36 | 'is_custom.required' => '是否为扩展模版', |
| 36 | 'is_template.required' => '详情页/可视化', | 37 | 'is_template.required' => '详情页/可视化', |
| 37 | - 'operator_id.required' => '操作人', | ||
| 38 | ]); | 38 | ]); |
| 39 | - $condition = ['source'=>$this->param['source'],'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']]; | 39 | + $condition = ['project_id'=>$this->user['project_id'],'source'=>$this->param['source'],'source_id'=>$this->param['source_id'], |
| 40 | + 'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']]; | ||
| 40 | $operationHeartbeatModel = new OperationHeartbeat(); | 41 | $operationHeartbeatModel = new OperationHeartbeat(); |
| 41 | $info = $operationHeartbeatModel->read($condition,['id','status']); | 42 | $info = $operationHeartbeatModel->read($condition,['id','status']); |
| 43 | + $condition['status'] = $condition['status'] ?? 0; | ||
| 42 | if($info === false){ | 44 | if($info === false){ |
| 43 | - $condition['status'] = 1; | 45 | + $condition['operator_id'] = $this->user['id']; |
| 46 | + $condition['project_id'] = $this->user['project_id']; | ||
| 44 | $operationHeartbeatModel->addReturnId($condition); | 47 | $operationHeartbeatModel->addReturnId($condition); |
| 45 | }else{ | 48 | }else{ |
| 46 | $operationHeartbeatModel->edit(['status'=>1],['id'=>$info['id']]); | 49 | $operationHeartbeatModel->edit(['status'=>1],['id'=>$info['id']]); |
| @@ -58,18 +61,19 @@ class OperationHeartbeatController extends BaseController | @@ -58,18 +61,19 @@ class OperationHeartbeatController extends BaseController | ||
| 58 | public function getInfo(){ | 61 | public function getInfo(){ |
| 59 | $this->request->validate([ | 62 | $this->request->validate([ |
| 60 | 'source'=>'required', | 63 | 'source'=>'required', |
| 64 | + 'source_id'=>'required', | ||
| 61 | 'is_list' => 'required', | 65 | 'is_list' => 'required', |
| 62 | 'is_custom'=>'required', | 66 | 'is_custom'=>'required', |
| 63 | 'is_template'=>'required', | 67 | 'is_template'=>'required', |
| 64 | - 'operator_id'=>'required', | ||
| 65 | ], [ | 68 | ], [ |
| 66 | 'source.required' => '请选择页面', | 69 | 'source.required' => '请选择页面', |
| 70 | + 'source_id.required' => '请选择数据id', | ||
| 67 | 'is_list.required' => '列表页/详情页', | 71 | 'is_list.required' => '列表页/详情页', |
| 68 | 'is_custom.required' => '是否为扩展模版', | 72 | 'is_custom.required' => '是否为扩展模版', |
| 69 | 'is_template.required' => '详情页/可视化', | 73 | 'is_template.required' => '详情页/可视化', |
| 70 | - 'operator_id.required' => '操作人', | ||
| 71 | ]); | 74 | ]); |
| 72 | - $condition = ['source'=>$this->param['source'],'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']]; | 75 | + $condition = ['project_id'=>$this->user['project_id'],'source'=>$this->param['source'],'source_id'=>$this->param['source_id'], |
| 76 | + 'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']]; | ||
| 73 | $operationHeartbeatModel = new OperationHeartbeat(); | 77 | $operationHeartbeatModel = new OperationHeartbeat(); |
| 74 | $info = $operationHeartbeatModel->read($condition,['id','status']); | 78 | $info = $operationHeartbeatModel->read($condition,['id','status']); |
| 75 | $this->response('success',Code::SUCCESS,$info); | 79 | $this->response('success',Code::SUCCESS,$info); |
| @@ -370,6 +370,10 @@ class ImageController extends Controller | @@ -370,6 +370,10 @@ class ImageController extends Controller | ||
| 370 | */ | 370 | */ |
| 371 | public function getProjectConfig($project_id = 0){ | 371 | public function getProjectConfig($project_id = 0){ |
| 372 | $str = ''; | 372 | $str = ''; |
| 373 | + $is_watermark = ($this->cache['is_watermark'] ?? 0); | ||
| 374 | + if($is_watermark != 1){ | ||
| 375 | + return $str; | ||
| 376 | + } | ||
| 373 | $imageSettingModel = new ImageSetting(); | 377 | $imageSettingModel = new ImageSetting(); |
| 374 | $settingInfo = $imageSettingModel->read(['project_id'=>$project_id]); | 378 | $settingInfo = $imageSettingModel->read(['project_id'=>$project_id]); |
| 375 | if($settingInfo !== false){ | 379 | if($settingInfo !== false){ |
| @@ -871,7 +871,7 @@ class ProjectLogic extends BaseLogic | @@ -871,7 +871,7 @@ class ProjectLogic extends BaseLogic | ||
| 871 | 'phone' => $data['principal_mobile'], | 871 | 'phone' => $data['principal_mobile'], |
| 872 | 'planday' => $data['exclusive_hagro_day'] ?: 1, | 872 | 'planday' => $data['exclusive_hagro_day'] ?: 1, |
| 873 | 'from_order_id' => $data['from_order_id'], | 873 | 'from_order_id' => $data['from_order_id'], |
| 874 | - 'agent_phone' => Channel::where('source_id', $data['company_id'])->value('contact_mobile') ?: '', | 874 | + 'agent_phone' => Channel::where('id', $data['company_id'])->value('contact_mobile') ?: '', |
| 875 | 'nickname' => $data['nickname'], | 875 | 'nickname' => $data['nickname'], |
| 876 | ]; | 876 | ]; |
| 877 | $common = new Common(); | 877 | $common = new Common(); |
| @@ -390,7 +390,7 @@ class RankDataLogic extends BaseLogic | @@ -390,7 +390,7 @@ class RankDataLogic extends BaseLogic | ||
| 390 | $api = new QuanqiusouApi(); | 390 | $api = new QuanqiusouApi(); |
| 391 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); | 391 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); |
| 392 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { | 392 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 393 | - $res = $api->getGoogleRank($api_no, '', 7, $force); | 393 | + $res = $api->getGoogleRank($project_id, $api_no, '', 7, $force); |
| 394 | if (!$res) { | 394 | if (!$res) { |
| 395 | throw new \Exception("接口数据获取失败,api_no:{$api_no}"); | 395 | throw new \Exception("接口数据获取失败,api_no:{$api_no}"); |
| 396 | } | 396 | } |
| @@ -416,7 +416,7 @@ class RankDataLogic extends BaseLogic | @@ -416,7 +416,7 @@ class RankDataLogic extends BaseLogic | ||
| 416 | } | 416 | } |
| 417 | $model = RankData::where('project_id', $project_id)->where('lang', $lang)->first(); | 417 | $model = RankData::where('project_id', $project_id)->where('lang', $lang)->first(); |
| 418 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { | 418 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 419 | - $res = $api->getGoogleRank($api_no, $lang, 7, $force); | 419 | + $res = $api->getGoogleRank($project_id, $api_no, $lang, 7, $force); |
| 420 | if (!$res) { | 420 | if (!$res) { |
| 421 | throw new \Exception("接口数据获取失败,api_no:{$api_no},lang"); | 421 | throw new \Exception("接口数据获取失败,api_no:{$api_no},lang"); |
| 422 | } | 422 | } |
app/Models/RankData/RankDataLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\RankData; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Helper\Arr; | ||
| 7 | +use App\Models\Base; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Class GoogleRank | ||
| 11 | + * @package App\Models | ||
| 12 | + * @author zbj | ||
| 13 | + * @date 2023/5/6 | ||
| 14 | + */ | ||
| 15 | +class RankDataLog extends Base | ||
| 16 | +{ | ||
| 17 | + //设置关联表名 | ||
| 18 | + protected $table = 'gl_rank_data_log'; | ||
| 19 | + | ||
| 20 | + public function setDataAttribute($value) | ||
| 21 | + { | ||
| 22 | + $this->attributes['data'] = Arr::a2s($value); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public function getDataAttribute($value) | ||
| 26 | + { | ||
| 27 | + return Arr::s2a($value); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public static function addLog($project_id, $api_no, $lang, $date, $res){ | ||
| 31 | + $data= []; | ||
| 32 | + foreach ($res as $key=>$item){ | ||
| 33 | + $data[$key] = $item[$date]; | ||
| 34 | + } | ||
| 35 | + $model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first(); | ||
| 36 | + if(!$model){ | ||
| 37 | + $model = new self(); | ||
| 38 | + } | ||
| 39 | + $model->project_id = $project_id; | ||
| 40 | + $model->api_no = $api_no; | ||
| 41 | + $model->lang = $lang; | ||
| 42 | + $model->date = $date; | ||
| 43 | + $model->data = $data; | ||
| 44 | + $model->save(); | ||
| 45 | + | ||
| 46 | + return true; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | +} |
| @@ -601,8 +601,11 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -601,8 +601,11 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 601 | Route::any('/del', [\App\Http\Controllers\Bside\Inquiry\InquiryFieldController::class, 'del'])->name('inquiry_field_del'); | 601 | Route::any('/del', [\App\Http\Controllers\Bside\Inquiry\InquiryFieldController::class, 'del'])->name('inquiry_field_del'); |
| 602 | }); | 602 | }); |
| 603 | 603 | ||
| 604 | + //获取心跳 | ||
| 604 | Route::prefix('operation_heartbeat')->group(function () { | 605 | Route::prefix('operation_heartbeat')->group(function () { |
| 605 | Route::any('/saveHeartbeat', [\App\Http\Controllers\Bside\BCom\OperationHeartbeatController::class, 'saveHeartbeat'])->name('operation_heartbeat_saveHeartbeat'); | 606 | Route::any('/saveHeartbeat', [\App\Http\Controllers\Bside\BCom\OperationHeartbeatController::class, 'saveHeartbeat'])->name('operation_heartbeat_saveHeartbeat'); |
| 607 | + Route::any('/getInfo', [\App\Http\Controllers\Bside\BCom\OperationHeartbeatController::class, 'getInfo'])->name('operation_heartbeat_getInfo'); | ||
| 608 | + | ||
| 606 | }); | 609 | }); |
| 607 | }); | 610 | }); |
| 608 | //无需登录验证的路由组 | 611 | //无需登录验证的路由组 |
-
请 注册 或 登录 后发表评论