作者 zhl

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

... ... @@ -297,13 +297,16 @@ class VideoTask extends Command
break;
}
$keyword_ids = implode(',',$item->keyword_id);
$keyword_video_ids = implode(',',$item->keyword_video_id);
if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) {
if(strpos(','.$keyword_video_ids.',', ','.$keyword_id.',') === false){
//不包含
$productModel = new Product();
$keyword_ids = !empty($keyword_ids) ? ','.$keyword_ids.',' : ',' ;
$keyword_id_str = $keyword_ids . $keyword_id.',';
KeywordRelated::saveRelated($item->id,explode(',',trim($keyword_id_str,',')));
$productModel->edit(['keyword_id'=>$keyword_id_str],['id'=>$item->id]);
$keyword_video_ids = !empty($keyword_video_ids) ? ','.$keyword_video_ids.',' : ',' ;
$keyword_video_id_str = $keyword_video_ids . $keyword_id.',';
$productModel->edit(['keyword_video_id'=>$keyword_video_id_str],['id'=>$item->id]);
KeywordRelated::saveRelated($item->id,$keyword_video_ids,2);
}
}
$data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
}
... ...
... ... @@ -26,6 +26,7 @@ use App\Models\File\Image as ImageModel;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
... ... @@ -61,30 +62,56 @@ class Demo extends Command
protected $description = 'demo';
public function handle(){
// $projectModel = new Project();
// $list = $projectModel->list(['id'=>1659]);
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
// $this->getProduct();
// DB::disconnect('custom_mysql');
// }
return $this->savePurchaserInfo();
$keywordVideoModel = new KeywordVideoTask();
$list = $keywordVideoModel->list();
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['project_id'] . PHP_EOL;
ProjectServer::useProject($v['project_id']);
$this->getProduct();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :更新产品
* @name :getProduct
* @author :lyh
* @method :post
* @time :2024/11/27 15:40
*/
public function getProduct(){
$productModel = new Product();
$lists = $productModel->list(['status'=>['!=',2]]);
$lists = $productModel->list(['status'=>['!=',3]]);
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['route'])){
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
$productModel->edit(['route'=>$route],['id'=>$v['id']]);
if(!empty($v['keyword_video_id'])){
foreach ($v['keyword_video_id'] as $val){
$keywordRelaModel = new KeywordRelated();
echo date('Y-m-d H:i:s') . 'keyword_id :'.$val . 'product_id :'.$v['id'] . PHP_EOL;
$keywordRelaModel->edit(['type'=>2],['keyword_id'=>$val,'product_id'=>$v['id']]);
}
}
}
}
}
/**
* @remark :复制表及结构
* @name :copyProduct
* @author :lyh
* @method :post
* @time :2024/11/27 16:09
*/
public function copyProduct(){
$tableName = 'gl_product';
$copyTableName = 'gl_product_c';
if (Schema::connection('custom_mysql')->hasTable($copyTableName)) {
DB::connection('custom_mysql')->statement("DROP TABLE {$copyTableName}");
}
// 创建新表并复制数据
DB::connection('custom_mysql')->statement("CREATE TABLE {$copyTableName} LIKE {$tableName}");
DB::connection('custom_mysql')->statement("INSERT INTO {$copyTableName} SELECT * FROM {$tableName}");
}
/**
... ...
... ... @@ -37,7 +37,7 @@ class Temp extends Command
* @author Akun
* @date 2024/11/18 15:07
*/
public function handle()
public function handle5()
{
$projects = Project::select(['id'])->orderBy('id', 'asc')->get();
foreach ($projects as $project) {
... ... @@ -236,7 +236,7 @@ class Temp extends Command
* @author Akun
* @date 2024/09/26 10:48
*/
public function handle1()
public function handle()
{
$notify_model = new Notify();
$project_model = new Project();
... ... @@ -254,10 +254,12 @@ class Temp extends Command
$project_info = $project_model->read(['id' => $project_id], ['serve_id']);
if (!$project_info) {
$this->output('未查询到项目数据');
continue;
}
$serve_ip_info = $serve_ip_model->read(['id' => $project_info['serve_id']], ['servers_id']);
if (!$serve_ip_info) {
$this->output('未查询到服务器数据');
continue;
}
$servers_id = $serve_ip_info['servers_id'];
... ... @@ -290,9 +292,17 @@ class Temp extends Command
}
} else {
//其他服务器:请求对应C端接口
$c_url = $domain . '/api/update_page/?project_id=' . $project_id . '&type=3';
$re = http_get($c_url);
$this->output($re['message'] ?? '');
$c_url = $domain . '/api/update_page/';
$c_params = [
'project_id' => $project_id,
'type' => 3
];
$re = http_post($c_url, json_encode($c_params), [], true);
if (isset($re['status']) && $re['status'] == 200) {
$this->output($c_url . ' | 请求成功');
} else {
$this->output($c_url . ' | ' . ($re['message'] ?? '未返回失败原因'));
}
}
$this->output('项目id:' . $project_id . ',end');
}
... ... @@ -300,6 +310,6 @@ class Temp extends Command
public function output($msg)
{
echo $msg . PHP_EOL;
echo date('Y-m-d H:i:s') . ' | ' . $msg . PHP_EOL;
}
}
... ...
... ... @@ -106,11 +106,11 @@ class HtmlCustomCollect extends Command
// 'https://www.citymax-group.com/case/field-experiment-crop-lettuce/',
// ];
$project_id = 626;
$project_site = 'v6-m342g.globalso.site';
$pages = [
'https://a574.goodao.net/project_catalog/project/',
'https://a574.goodao.net/project_catalog/project/page/2/',
// $project_id = 626;
// $project_site = 'v6-m342g.globalso.site';
// $pages = [
// 'https://a574.goodao.net/project_catalog/project/',
// 'https://a574.goodao.net/project_catalog/project/page/2/',
// 'https://www.lecusostreetlight.com/project/560pcs-250w-smart-led-street-light-in-manila-city-philippines/',
// 'https://www.lecusostreetlight.com/project/3200pcs-8m-150w-solar-street-light-in-cebu-philippines/',
// 'https://lecusostreetlight.com/project/170pcs-100w-split-lithium-battery-solar-street-light-in-tanzania/',
... ... @@ -134,7 +134,7 @@ class HtmlCustomCollect extends Command
// 'https://www.lecusostreetlight.com/project/198pcs-8m-80w-zc-series-all-in-two-solar-light-in-philippines/',
// 'https://www.lecusostreetlight.com/project/5m-30w-morden-led-garden-light-in-russian/',
// 'https://www.lecusostreetlight.com/project/135pcs-all-in-one-solar-street-light-in-uae-dubai-park/'
];
// ];
// $project_id = 633;
// $project_site = 'v6-ke5nz.globalso.site';
... ... @@ -175,6 +175,19 @@ class HtmlCustomCollect extends Command
// 'https://www.mach-sales.com/case/cooperation-win-win-and-starting-anew-sumec-creates-a-new-sample-of-strong-enterprise-cooperation/'
// ];
$project_id = 549;
$project_site = 'v6-myz64.globalso.site';
$pages = [
'https://sryled.goodao.net/event-staging/page/2/',
'https://sryled.goodao.net/event-staging/page/3/',
'https://sryled.goodao.net/event-staging/page/4/',
'https://sryled.goodao.net/advertising-3/page/2/',
'https://sryled.goodao.net/advertising-3/page/3/',
'https://sryled.goodao.net/advertising-3/page/4/',
'https://sryled.goodao.net/indoor/page/2/',
'https://sryled.goodao.net/indoor/page/3/',
];
foreach ($pages as $page) {
$this->start_collect(urldecode($page), $project_id, $project_site);
}
... ... @@ -314,6 +327,14 @@ class HtmlCustomCollect extends Command
$source[] = $check_vv2;
}
}
preg_match_all('/<iframe\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_video_3);
$video_3 = $result_video_3[2] ?? [];
foreach ($video_3 as $vv3) {
$check_vv3 = $this->url_check($vv3, $project_id, $domain, $web_url_domain, $home_url);
if ($check_vv3 && (!in_array($check_vv3, $source))) {
$source[] = $check_vv3;
}
}
//css
preg_match_all('/<link\s+[^>]*?href\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $html, $result_css);
... ... @@ -401,7 +422,12 @@ class HtmlCustomCollect extends Command
foreach ($source as $vs) {
if ($vs['download']) {
if (in_array(substr($vs['url_complete'], -3), ['pdf', 'zip', 'rar', '.gz'])) {
//可下载类资源要保持原名称
$new_source = CosService::uploadRemote($project_id, 'source', $vs['url_complete'], '', '', 1);
} else {
$new_source = CosService::uploadRemote($project_id, 'source', $vs['url_complete']);
}
if ($new_source) {
CollectSource::insert([
'project_id' => $project_id,
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Console\Commands\Update;
use App\Models\Domain\DomainInfo;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordPage;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -106,4 +107,19 @@ class UpdateKeyword extends Command
shell_exec('curl -k "'.$url.'"');
return true;
}
/**
* @remark :更新产品关键词
* @name :updatedProductKeyword
* @author :lyh
* @method :post
* @time :2024/11/27 14:26
*/
public function updatedProductKeyword(){
$productModel = new Product();
$lists = $productModel->list();
foreach ($lists as $k => $v){
}
}
}
... ...
... ... @@ -230,7 +230,7 @@ class AdsController extends BaseController
public function fbInquiryChart(Request $request)
{
$start_date = $request->input('start_date', date('Y-m-d', strtotime('-1 month')));
$end_date = $request->input('end', date('Y-m-d'));
$end_date = $request->input('end_date', date('Y-m-d'));
$result = ReInquiryForm::select(DB::raw('DATE(inquiry_date) as date'), DB::raw('COUNT(*) as count'))
->whereBetween('inquiry_date', [$start_date, date('Y-m-d', strtotime($end_date . ' +1 day'))])
->groupBy(DB::raw('DATE(inquiry_date)'))
... ...
... ... @@ -25,6 +25,9 @@ class OperationHeartbeatController extends BaseController
* @time :2024/8/28 14:03
*/
public function saveHeartbeat(){
if($this->user['project_id'] == 1){
$this->response('success');
}
$this->request->validate([
'source'=>'required',
'source_id'=>'required',
... ... @@ -64,6 +67,10 @@ class OperationHeartbeatController extends BaseController
* @time :2024/8/28 14:29
*/
public function getInfo(){
if($this->user['project_id'] == 1){
$info['status'] = 0;
$this->response('success',Code::SUCCESS,$info);
}
$this->request->validate([
'source'=>'required',
'source_id'=>'required',
... ...
... ... @@ -31,7 +31,7 @@ class KeywordController extends BaseController
public function index(Keyword $keyword)
{
$this->map = $this->searchParam($this->map);
$filed = ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at','route','keyword_title'];
$filed = ['id', 'project_id', 'title', 'seo_title', 'seo_keywords', 'seo_description', 'status', 'created_at','route','keyword_title','is_video_keyword'];
$data = $keyword->lists($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($data)){
foreach ($data['list'] as &$v){
... ... @@ -257,4 +257,23 @@ class KeywordController extends BaseController
$id = $keywordPageModel->addReturnId($this->param);
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
/**
* @remark :删除关联关系
* @name :delRelated
* @author :lyh
* @method :post
* @time :2024/11/28 10:30
*/
public function delRelated(KeywordLogic $logic){
$this->request->validate([
'keyword_id'=>'required',
'product_id'=>'required',
],[
'keyword_id.required' => '关键词id不能为空',
'product_id.required' => '产品id不为空',
]);
$logic->delRelated($this->param['keyword_id'],$this->param['product_id']);
$this->response('success');
}
}
... ...
... ... @@ -391,17 +391,6 @@ class TranslateController extends BaseController
}
/**
* @remark :获取默认数据
* @name :getDefaultData
* @author :lyh
* @method :post
* @time :2024/7/16 15:28
*/
public function getDefaultData(){
}
/**
* @remark :
* @name :pageList
* @author :lyh
... ...
... ... @@ -69,13 +69,11 @@ class EmailController extends BaseController
public function set_smtp(Smtp $smtp)
{
$this->request->validate([
'project_id' => ['required'],
'email' => ['required', 'email', 'max:200'],
'password' => ['required', 'max:200'],
'host' => ['required', 'max:200', 'regex:/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/'],
'from_name' => ['required', 'max:200'],
], [
'project_id.required' => '参数异常',
'email.required' => '邮箱必须',
'email.email' => '邮箱格式错误',
'password.required' => '授权码/密码必须',
... ... @@ -83,15 +81,21 @@ class EmailController extends BaseController
'host.regex' => 'smtp格式错误',
'from_name.required' => '发信人昵称必须',
]);
$info = $smtp->read(['project_id' => $this->param['project_id']]);
$this->param['project_id'] = $this->project['id'];
$info = $smtp->read(['project_id' => $this->project['id']]);
if (!$info) {
$smtp->add($this->param);
} else {
$smtp->edit($this->param, ['project_id' => $this->param['project_id']]);
$smtp->edit($this->param, ['project_id' => $this->project['id']]);
}
$this->response('success');
}
public function get_smtp(Smtp $smtp){
$info = $smtp->read(['project_id' => $this->project['id']]);
$this->response($info??[]);
}
public function group_send(GroupSendTask $groupSendTask)
{
$this->request->validate([
... ...
... ... @@ -42,6 +42,7 @@ class KeywordLogic extends BaseLogic
if($info !== false){
$info['url'] = $this->user['domain'] . $info['route'];
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
$info['product_list'] = $this->getProduct($info['id']);
}
return $this->success($info);
}
... ... @@ -298,4 +299,41 @@ class KeywordLogic extends BaseLogic
}
return $this->success();
}
/**
* @remark :根据关键字获取产品
* @name :getProduct
* @author :lyh
* @method :post
* @time :2024/11/28 9:26
*/
public function getProduct($keyword_id){
$productList = [];
$keywordRelatedModel = new KeywordRelated();
$productIdArr = $keywordRelatedModel->selectField(['keyword_id'=>$keyword_id],'product_id');
if(!empty($productIdArr)){
$productModel = new Product();
$productList = $productModel->list(['id'=>['in',$productIdArr]],['id','title']);
}
return $this->success($productList);
}
/**
* @remark :对应删除关联关系
* @name :delRelated
* @author :lyh
* @method :post
* @time :2024/11/28 9:46
*/
public function delRelated($keyword_id,$product_id){
$productModel = new Product();
$productModel->where('id', $product_id)
->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',$keyword_id,' , ',')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',$keyword_id,' , ',')")]);
$productModel->where('id', $product_id)->where('keyword_id',',')->orWhere('keyword_video_id',',')
->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',' , '')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',' , '')")]);
$keywordRelatedModel = new KeywordRelated();
$keywordRelatedModel->del(['product_id'=>$product_id,'keyword_id'=>$keyword_id]);
return $this->success();
}
}
... ...
... ... @@ -43,6 +43,7 @@ class ProductLogic extends BaseLogic
$extend = $this->handleExtent();
//单独处理分类
$category_ids = $this->handleCategory();
$keyword_arr = $this->param['keyword_id'] ?? [];
//处理其他字段
$this->param = $this->handleSaveParam($this->param);
try {
... ... @@ -66,7 +67,7 @@ class ProductLogic extends BaseLogic
}
//产品分类关联
CategoryRelated::saveRelated($id, $category_ids);
KeywordRelated::saveRelated($id,$category_ids);
KeywordRelated::saveRelated($id,$keyword_arr);
//更新产品新描述
$detailLogic = new DetailLogic();
$detailLogic->saveDetail($id,$this->param['data'] ?? []);
... ...
... ... @@ -53,33 +53,6 @@ class QueryListener
$log = $log.' [ RunTime:'.$event->time.'ms ] ';
Log::debug($log);
}
//监听api_no是TM咋个被改的
if (Str::contains($event->sql, 'update') && Str::contains($event->sql, '`api_no` =')) {
//记录debug 根据这个溯源
$trace = debug_backtrace();
$traces = [];
foreach ($trace as $index => $caller) {
if ($index === 0) {
continue; // 跳过当前方法的调用信息
}
$file = $caller['file'];
$line = $caller['line'];
$class = $caller['class'];
$method = $caller['function'];
$traces[] = "Method $method called from $class in file $file at line $line\n";
}
//用户信息 哪个改的 还是脚本跑的
$token = request()->header('token');
Log::channel('test')->info('api_no updated', [
'sql' => $event->sql,
'bindings' => $event->bindings,
'route' => Route::current(),
'request' => request()->all(),
'a_info' => Cache::get(Common::MANAGE_TOKEN . $token),
'b_info' => Cache::get($token),
'trace' => $traces
]);
}
}catch (\Exception $exception){
Log::error('log sql error:'.$exception->getMessage());
}
... ...
... ... @@ -296,4 +296,5 @@ class Base extends Model
$data = $this->filterRequestData($data);
return $this->formatQuery($data)->pluck($filed)->toArray();
}
}
... ...
... ... @@ -24,19 +24,20 @@ class KeywordRelated extends Base
* @author zbj
* @date 2023/5/4
*/
public static function saveRelated($product_id, $keyword_ids)
public static function saveRelated($product_id, $keyword_ids,$type = 1)
{
if(!is_array($keyword_ids)){
$keyword_ids = array_filter(Arr::splitFilterToArray($keyword_ids), 'intval');
}
//先删除
self::where('product_id', $product_id)->delete();
self::where('product_id', $product_id)->where('type',$type)->delete();
//批量保存
$data = [];
if(!empty($keyword_ids)){
foreach ($keyword_ids as $keyword_id){
$data[] = [
'type' => $type,
'product_id' => $product_id,
'keyword_id' => $keyword_id,
'created_at'=>date('Y-m-d H:i:s'),
... ...
... ... @@ -196,7 +196,9 @@ class Product extends Base
public function getKeywordIdAttribute($value){
return Arr::setToArr(trim($value,','));
}
public function getKeywordVideoIdAttribute($value){
return Arr::setToArr(trim($value,','));
}
public function getRelatedProductIdAttribute($value){
return Arr::setToArr($value);
}
... ...
... ... @@ -310,13 +310,22 @@ class SyncSubmitTaskService
//过滤内容
if(!empty($data['data']['message'])) {
//过滤内容关键字
if (!empty($config['filter_contents'])){
if (!empty($config['filter_contents'])) {
foreach ($config['filter_contents'] as $filter_content) {
if (Str::contains(strtolower($data['data']['message']), strtolower($filter_content))) {
//中文直接包含
if (preg_match("/^[\x{4e00}-\x{9fa5}]+$/u", $filter_content)) {
if (Str::contains($data['data']['message'], $filter_content)) {
throw new InquiryFilterException('过滤内容:' . $filter_content);
}
} else {
//英文要指定词才过滤
if (preg_match("/\b" . preg_quote($filter_content, "/") . "\b/i", $data['data']['message'])) {
throw new InquiryFilterException('过滤内容:' . $filter_content);
}
}
}
}
//是否允许包含链接
if(isset($config['is_allow_link']) && !$config['is_allow_link']){
if (Str::contains(strtolower($data['data']['message']), ['http://', 'https://', 'www.'])) {
... ...
... ... @@ -281,6 +281,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
Route::any('keyword/delRelated', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delRelated'])->name('product_keyword_delRelated');
Route::any('keyword/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword');
Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
... ... @@ -632,6 +633,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/del', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'delete'])->name('subscribe_email_del');
Route::any('/export', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'export'])->name('subscribe_email_export');
Route::any('/set_smtp', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'set_smtp'])->name('subscribe_email_set_smtp');
Route::any('/get_smtp', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'get_smtp'])->name('subscribe_email_get_smtp');
Route::any('/group_send', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'group_send'])->name('subscribe_email_group_send');
});
... ...