作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -58,9 +58,31 @@ class lyhDemo extends Command
protected $description = '更新路由';
public function handle(){
return $this->_actionRoute();
return $this->_actionAiBolog();
}
/**
* @remark :修改ai_blog
* @name :_actionAiBolog
* @author :lyh
* @method :post
* @time :2025/11/21 13:52
*/
public function _actionAiBolog()
{
$projectModel = new Project();
$lists = $projectModel->list(['delete_status' => 0,'id'=>1,'project_type'=>0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
foreach ($lists as $item) {
echo date('Y-m-d H:i:s') . '开始--项目的id:' . $item['id'] . PHP_EOL;
ProjectServer::useProject($item['project_id']);
$aiblog = new AiBlog();
$task_ids = $aiblog->selectField(['image'=>'','created_at'=>['>=','2025-11-17 00:00:00']],'691b5b8a9632e');
dd($task_ids);
DB::disconnect('custom_mysql');
}
}
public function _actionDa()
{
$geoLinkModel = new GeoLink();
... ...
... ... @@ -1642,5 +1642,16 @@ if (!function_exists('httpGetSsl')) {
return $truncated;
}
/**
* @remark :写入日志
* @name :outMessage
* @author :lyh
* @method :post
* @time :2025/11/20 16:04
*/
function outMessage($filename = 'lyh_info',$message = '')
{
@file_put_contents(storage_path('logs/'.$filename.'.log'), "错误信息: " . $message . PHP_EOL, FILE_APPEND);
return true;
}
}
... ...
... ... @@ -8,9 +8,12 @@
namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Models\Geo\GeoConf;
use App\Models\Geo\GeoConfirm;
use App\Models\Geo\GeoWritings;
use App\Models\Manage\ManageHr;
use App\Models\Project\Project;
use App\Services\DingService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
... ... @@ -89,11 +92,28 @@ class GeoController extends BaseController
if ($info['status'] == GeoWritings::STATUS_FINISH){
return $this->response('当前文章已确认,不可再次确认',Code::SYSTEM_ERROR);
}
try {
$this->param['confirm_ip'] = $this->request->ip();
$this->param['confirm_at'] = date('Y-m-d H:i:s');
$this->param['content_length'] = strlen($this->param['content']);
$this->param['status'] = GeoWritings::STATUS_FINISH;
$geoWritingsModel->edit($this->param,['uniqid' => $token]);
$geoConfModel = new GeoConf();
$confInfo = $geoConfModel->read(['project_id'=>$info['project_id']]);
$hrModel = new ManageHr();
$manage_name = $hrModel->getName($confInfo['manager_id'] ??'');
$dingService = new DingService();
$dingService->handle([
'keyword' => '项目数据确认',
'msg' =>
'cm:文章确认完成' . PHP_EOL .
'项目名称:'.$confInfo['company'] ?? '' . PHP_EOL .
'负责人:'.$manage_name . PHP_EOL,
'isAtAll' => false, // 是否@所有人
], 'https://oapi.dingtalk.com/robot/send?access_token=4effe85882009a8a1617dbeadc38c350f832deef7431ce10f5fda751b4c82fb9');
}catch (\Exception $e){
$this->response('非法请求',Code::SYSTEM_ERROR);
}
$this->response('success',Code::SUCCESS);
}
... ... @@ -138,10 +158,31 @@ class GeoController extends BaseController
'confirm_num.max' => '客户确认数量不能为空',
]);
$geoConfirmModel = new GeoConfirm();
$info = $geoConfirmModel->read(['uniqid'=>$this->param['uniqid']]);
if ($info === false){
$this->response('当前数据不存在已被删除',Code::SYSTEM_ERROR);
}
try {
$this->param['status'] = $geoConfirmModel::STATUS_FINISH;
$this->param['confirm_ip'] = $this->request->ip();
$this->param['confirm_at'] = date('Y-m-d H:i:s');
$result = $geoConfirmModel->edit($this->param,['uniqid'=>$this->param['uniqid']]);
$result = $geoConfirmModel->edit($this->param,['id'=>$info['$info']]);
$geoConfModel = new GeoConf();
$confInfo = $geoConfModel->read(['project_id'=>$info['project_id']]);
$hrModel = new ManageHr();
$manage_name = $hrModel->getName($confInfo['manager_id'] ??'');
$dingService = new DingService();
$dingService->handle([
'keyword' => '项目数据确认',
'msg' =>
'cm:'.(($info['type'] == 1) ? '标题确认' : '关键词确认'). PHP_EOL .
'项目名称:'.$confInfo['company'] ?? '' . PHP_EOL .
'负责人:'.$manage_name . PHP_EOL,
'isAtAll' => false, // 是否@所有人
], 'https://oapi.dingtalk.com/robot/send?access_token=4effe85882009a8a1617dbeadc38c350f832deef7431ce10f5fda751b4c82fb9');
}catch (\Exception $e){
$this->response('非法请求',Code::SYSTEM_ERROR);
}
$this->response('success',Code::SUCCESS,$result);
}
}
... ...
... ... @@ -231,11 +231,22 @@ class IndexController extends BaseController
*/
public function prInfoDownload()
{
$url = 'http://crawl.scraper.waimaoq.com/export/issuewire?token=MT0CM7y4tdFTFTm';
$response = Http::get($url);
$url = 'http://crawl.scraper.waimaoq.com/export/issuewire';
$param = [
'page' => $this->page,
'page_size' => $this->row,
'token' => 'MT0CM7y4tdFTFTm',
'pr_id' => $this->param['pr_id'] ?? '',
'release_time_start'=>$this->param['release_time_start'] ?? '',
'release_time_end'=>$this->param['release_time_end'] ?? '',
];
$param = array_filter($param);
$response = Http::withHeaders(['Accept' => 'application/json',])->get($url, $param);
if ($response->successful()) {
$result = $response->json();
$this->response('success', Code::SUCCESS, ['url' => $url, 'list' => $result, 'page' => $this->page, 'page_size' => $this->row]);
} else {
$this->response('请求失败', Code::SYSTEM_ERROR, ['status_code' => $response->status(), 'error' => $response->body()]);
}
$this->response('success', Code::SUCCESS, ['url'=>$url,'list'=>$result ?? []]);
}
}
... ...
... ... @@ -375,6 +375,8 @@ class AsideTicketController extends BaseController
}
if ($project->wechat_switch)
$project->pushWechatGroupMsg();
else
$this->response('请先点击开关,打开微信推送', Code::USER_MODEL_NOTFOUND_ERROE);
$this->response('success', Code::SUCCESS);
}
}
... ...
... ... @@ -9,17 +9,101 @@
namespace App\Http\Controllers\Bside\ExtensionModule;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\ExtentModule\ExtensionModuleField;
use App\Models\ExtentModule\ExtensionModuleValue;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class Extension3915ModuleController extends BaseController
{
public function __construct(Request $request)
/**
* @remark :获取列表数据
* @name :lists
* @author :lyh
* @method :post
* @time :2025/11/20 14:38
*/
public function lists(){
$this->request->validate([
'module_id'=>'required',
],[
'module_id.required' => '模块id不能为空',
]);
$searchParam = [
'module_id'=>$this->param['module_id'],
];
$resultData = Cache::get('extension_module_list_3915_'.$this->param['module_id']);
if(empty($resultData)){
$data = [];
$moduleValueModel = new ExtensionModuleValue();
if(isset($this->param['field_id']) && ($this->param['field_id'] != 0) && isset($this->param['value'])){
$uuidArr = $moduleValueModel->formatQuery(['field_id'=>$this->param['field_id'],'value'=>$this->param['value'],'module_id'=>$this->param['module_id']])->distinct()->pluck('uuid')->toArray();
if(!empty($uuidArr)){
$searchParam['uuid'] = ['in',$uuidArr];
}
}
if(isset($this->param['start_time']) && !empty($this->param['start_time']) && isset($this->param['end_time']) && !empty($this->param['end_time'])){
$searchParam['created_at'] = ['between',[$this->param['start_time'],$this->param['end_time']]];
}
$lists = $moduleValueModel->list($searchParam);
if(!empty($lists)){
foreach ($lists as $k => $v){
$data[$v['uuid']][$v['field_id']] = $v['value'];
$data[$v['uuid']]['created_at'] = $v['created_at'];
}
}
$resultData = [];
foreach ($data as $k => $v){
$v['uuid'] = $k;
$resultData[] = $v;
}
Cache::add('extension_module_list_3915_'.$this->param['module_id'],$resultData);
}
$resultData = $this->formatPaginate($resultData,$this->row,$this->page);
//执行分页
$this->response('success',Code::SUCCESS,$resultData);
}
/**
* @remark :分页
* @name :simplePaginate
* @author :lyh
* @method :post
* @time :2025/11/20 14:50
*/
public function formatPaginate($data, $size = 20, $page = 1)
{
$collection = collect($data);
$total = $collection->count();
$totalPage = max(1, ceil($total / $size));
// 确保页码在有效范围内
$page = max(1, min($page, $totalPage));
$list = $collection->forPage($page, $size)->values()->toArray();
return [
'list' => $list,
'page' => (int)$page,
'size' => (string)$size,
'total' => $total,
'total_page' => $totalPage
];
}
/**
* @remark :导入数据
* @name :importData
* @author :lyh
* @method :post
* @time :2025/11/20 14:40
*/
public function importData()
{
Parent::__construct($request);
$this->valueModel = new ExtensionModuleValue();
$this->filedModel = new ExtensionModuleField();
$data = $this->param;
//todo::优先截断表
$resultData = [];
foreach ($data as $k => $v){
}
return $data;
}
}
... ...
... ... @@ -207,11 +207,14 @@ class ImageController extends Controller
if($this->upload_location == 0){
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
$cosService = new CosService();
$cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions);
$res = $cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions);
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($files,$this->path,$fileName);
$res = $amazonS3Service->uploadFiles($files,$this->path,$fileName);
}
if($res === false){
$this->response('上传失败,请重新上传',Code::SYSTEM_ERROR);
}
$this->saveMysql($imageModel,$files->getSize(),$image_type,$fileName,$hash,$this->upload_location,$files->getMimeType(), $name);
$this->synchronizationImage($fileName,$this->upload_location);
... ... @@ -354,11 +357,15 @@ class ImageController extends Controller
if($this->upload_location == 0){
$watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
$cosService = new CosService();
$cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions);
$res = $cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions);
}else{
//TODO::上传亚马逊
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($file,$this->path,$fileName);
$res = $amazonS3Service->uploadFiles($file,$this->path,$fileName);
}
if($res === false){
outMessage('upload_images','图片上传失败'.$name);
continue;
}
$this->synchronizationImage($fileName,$this->upload_location);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
... ... @@ -700,6 +707,9 @@ class ImageController extends Controller
$info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
$domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名
if($is_image){
if(empty($data['image'])){
$this->response('开启图片水印需要先关闭水印功能,重新上传水印图片'.Code::SYSTEM_ERROR);
}
$param = [
'image/'.$domain.($data['image'] ?? ''),//图片
'gravity/'.($data['gravity'] ?? 'SouthEast'),
... ...
... ... @@ -92,12 +92,15 @@ class GeoArticleLogic extends BaseLogic
if(!empty($this->param['data'])){
$data = [];
foreach ($this->param['data'] as $item){
$info = $this->model->read(['url'=>$item['url'],'filename'=>$item['filename']],['id','url']);
if($info === false){
$data[] = [
'filename' => $item['filename'],
'url'=> $item['url'],
'project_id'=>$this->param['project_id']
];
}
}
$this->model->insertAll($data);
}
}catch (\Exception $e){
... ...
... ... @@ -41,6 +41,7 @@ class APublicModel extends Base
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
$newsNumber = DB::connection('custom_mysql')->table('gl_news')
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
$aiBlogNumber = DB::connection('custom_mysql')->table('gl_ai_blog')->where('project_id', $project_id)->count();
$keyNumber = DB::connection('custom_mysql')->table('gl_product_keyword')
->where('project_id', $project_id)->where('status', self::STATUS_ON)->count();
//获取项目的询盘数量
... ... @@ -49,7 +50,7 @@ class APublicModel extends Base
if(!empty($countInfo)){
$inquiryNumber = $countInfo->inquiry_num ?? 0;
}
$data = ['product'=>$productNumber,'blog'=>$blogNumber,'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber];
$data = ['product'=>$productNumber,'blog'=>($blogNumber + $aiBlogNumber),'news'=>$newsNumber,'key'=>$keyNumber,'inquiry'=>$inquiryNumber];
Cache::add('product_blog_news_'.$project_id,$data,30 * 60);
}
}catch (\Exception $e){
... ...
... ... @@ -24,7 +24,7 @@ class CosService
* @method :post
* @time :2023/7/19 15:28
*/
public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = '')
public function uploadFile(&$files, $path, $filename, $binary = false, $watermarkOptions = '')
{
$cos = config('filesystems.disks.cos');
$cosClient = new Client([
... ... @@ -34,7 +34,9 @@ class CosService
'secretKey' => $cos['credentials']['secretKey'],
],
]);
$key = $path.'/'.$filename;
$key = $path . '/' . $filename;
// 判断是否为 Base64 编码的图片流文件
if (Str::startsWith($files, 'data:image')) {
// 分离 Base64 头部和数据部分
... ... @@ -42,18 +44,30 @@ class CosService
// 解码 Base64 数据
$Body = base64_decode($base64Data);
if ($Body === false) {
throw new \Exception("Base64 数据解码失败");
outMessage('upload_images',"解码失败");
return false;
}
} else {
// 如果不是 Base64 流文件,处理为普通文件上传
try {
$Body = $binary ? $files : fopen($files->getRealPath(), 'r');
// 检查文件是否有效
if (!$Body) {
outMessage('upload_images',"文件打开失败");
return false;
}
} catch (\Exception $e) {
outMessage('upload_images',"文件处理失败: " . $e->getMessage());
return false;
}
}
try {
$options = [
'Bucket' => $cos['bucket'],
'Key' => $key,
'Body' => $Body,
];
//水印
// 水印处理
if ($watermarkOptions) {
$options['PicOperations'] = json_encode([
'is_pic_info' => 1,
... ... @@ -65,10 +79,21 @@ class CosService
]
], true);
}
$res = $cosClient->putObject($options);
$cosClient->putObject($options);
} catch (\Exception $e) {
// 记录上传失败日志
outMessage('upload_images',$e->getMessage());
return false;
} finally {
// 确保非二进制模式下关闭文件资源
if (!$binary && is_resource($Body)) {
fclose($Body);
}
}
return $key;
}
/**
* @param $image_name
* @remark :获取图片访问链接
... ...