作者 刘锟

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

... ... @@ -81,14 +81,16 @@ class Count extends Command
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain']);
echo date('Y-m-d H:i:s') . json_encode($arr) . '->' . PHP_EOL;
$data[] = $arr;
}
//判断数据是否存在
DB::table('gl_count')->insert($data);
}
}catch (\Exception $e){
Log::error('同步数据执行失败');
echo date('Y-m-d H:i:s') . ' error: ' . $v['test_domain'] . '->' . $e->getMessage() . PHP_EOL;
}
echo date('Y-m-d H:i:s') . ' end: ' . $v['test_domain'] . PHP_EOL;
echo $this->error;
}
... ... @@ -126,6 +128,7 @@ class Count extends Command
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
if($inquiry_list['status'] == self::STATUS_ERROR){
$arr['inquiry_num'] = 0;
$arr['country'] = json_encode([]);
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
//询盘国家统计
... ...
... ... @@ -40,12 +40,8 @@ class UpdateProgress extends Command
*/
public function handle()
{
while (true){
$project_id = Redis::rpop('updateProgress');
if(!$project_id){
sleep(2);
continue;
}
$project_id = Redis::rpop('updateProgress');
while ($project_id){
echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL;
try {
ProjectServer::useProject($project_id);
... ...
... ... @@ -152,20 +152,27 @@ class UpdateSeoTdk extends Command
public function seo_tdk($project_id)
{
$data = [];
$update = [];//更新统计
$update = [
'created_at'=>date('Y-m-d H:i:s'),
'updated_at'=>date('Y-m-d H:i:s'),
'project_id'=>$project_id,
];//更新统计
$ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray();
$ai_commands = Arr::setValueToKey($ai_commands, 'key');
foreach ($this->maps as $table => $map) {
$update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0];
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table($table)->get()->toArray();
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL . json_encode($update[$table]);
$list = DB::connection('custom_mysql')->table($table)->get();
if (!empty($list)) {
$list = $list->toArray();
foreach ($list as $v) {
echo '打印数据:'.date('Y-m-d H:i:s') . $update[$table]['total_page'].PHP_EOL;
$update[$table]['total_page']++;
$v = (array)$v;
echo date('Y-m-d H:i:s') . '更新--' . $table . ':id' . $v['id'] . PHP_EOL;
$data = [];
$json_field = '';
echo date('Y-m-d H:i:s') . json_encode($map) . PHP_EOL;
foreach ($map as $ai_key => $field) {
$field_arr = explode('.', $field);
if (count($field_arr) > 1) {
... ... @@ -185,7 +192,6 @@ class UpdateSeoTdk extends Command
if(!$prompt){
continue;
}
if (count($field_arr) > 1) {
if($field_arr[1] == 'title'){
$update[$table]['title']++;
... ... @@ -202,7 +208,7 @@ class UpdateSeoTdk extends Command
if($field == 'keywords' || $field == 'seo_keywords'){
$update[$table]['keyword']++;
}
if($field == 'seo_description' || $field == 'description'){
if($field == 'seo_description' || $field == 'description' || $field == 'seo_des'){
$update[$table]['des']++;
}
$data[$field] = $this->ai_send($prompt);
... ... @@ -229,14 +235,14 @@ class UpdateSeoTdk extends Command
//使用核心关键词
if(in_array($ai_key, array_keys($this->core_keyword_keys))){
$data[$field] = $this->mainKeywords($project_id, $this->core_keyword_keys[$ai_key]);
if(!empty($data[$field_arr[0]][$field_arr[1]])){
if(!empty($data[$field])){
if($field == 'title' || $field == 'seo_title'){
$update[$table]['title']++;
}
if($field == 'keywords' || $field == 'seo_keywords'){
$update[$table]['keyword']++;
}
if($field == 'seo_description' || $field == 'description'){
if($field == 'seo_description' || $field == 'description' || $field == 'seo_des'){
$update[$table]['des']++;
}
}
... ... @@ -254,11 +260,12 @@ class UpdateSeoTdk extends Command
}
$data[$json_field] = json_encode($data[$json_field]);
}
$update[$table] = json_encode($update[$table]);
DB::connection('custom_mysql')->table($table)->where(['id' => $v['id']])->update($data);
}
$update[$table] = json_encode($update[$table]);
}
}
DB::table('gl_project_update_tdk')->insert($update);
}
public function getPrompt($project_id, $prompt, $table, $data){
... ...
... ... @@ -25,7 +25,7 @@ class Kernel extends ConsoleKernel
$schedule->command('rank_data_recomm_domain')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据-引荐域名,每周一凌晨执行一次
$schedule->command('rank_data_week')->weeklyOn(1, '01:00')->withoutOverlapping(1); // 排名数据,每周一凌晨执行一次
// $schedule->command('share_user')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); // 清除用户ayr_share数据,每天凌晨1点执行一次
$schedule->command('count')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次
$schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次
$schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次
$schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次
... ... @@ -36,6 +36,7 @@ class Kernel extends ConsoleKernel
$schedule->command('inquiry_count')->dailyAt('01:00')->withoutOverlapping(1); // 询盘统计数据,每天凌晨执行一次
$schedule->command('domain_info')->dailyAt('01:00')->withoutOverlapping(1);// 更新域名|证书结束时间,每天凌晨1点执行一次
$schedule->command('last_inquiry')->dailyAt('04:00')->withoutOverlapping(1);// 最近一次询盘信息
$schedule->command('update_progress')->everyThirtyMinutes()->withoutOverlapping(1);//监控更新
}
/**
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Aside\Project;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\ManageLogic;
... ... @@ -25,6 +26,7 @@ use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Payment;
use App\Models\Project\Project;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\Project\RenewLog;
use App\Models\RankData\RankData;
use App\Models\Task\Task;
... ... @@ -701,5 +703,68 @@ class ProjectController extends BaseController
$this->response('success',Code::SUCCESS,$lists);
}
/**
* @remark :tdk更新记录
* @name :tdkList
* @author :lyh
* @method :post
* @time :2023/11/8 11:17
*/
public function tdkList(){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => '项目ID不能为空',
]);
$tdkModel = new ProjectUpdateTdk();
$list = $tdkModel->list(['project_id'=>$this->map['project_id']],'id',['*'],'desc',5);
if(!empty($list)){
foreach ($list as $k => $v){
$list[$k] = $this->handleTdk($v);
}
}
$this->response('success',Code::SUCCESS,$list);
}
public function handleTdk($item){
$data = [
'gl_product'=>'产品',
'gl_product_category'=>'产品分类',
'gl_product_keyword'=>'产品关键字',
'gl_news'=>'新闻',
'gl_news_category'=>'新闻分类',
'gl_blog'=>'博客',
'gl_blog_category'=>'博客分类',
'gl_web_custom_template'=>'自定义页面',
];
foreach ($data as $k => $v){
if(isset($item[$k])){
$item[$k] = Arr::s2a($item[$k]);
$item[$k] = $v.'总条数:'.$item[$k]['total_page'].
', title更新数:'.$item[$k]['title'].
',keyword更新数据:'.$item[$k]['keyword'].
',des更新数据:'.$item[$k]['des'];
}
}
return $item;
}
/**
* @remark :复制项目
* @name :copyProject
* @author :lyh
* @method :post
* @time :2023/11/8 14:17
*/
public function copyProject(ProjectLogic $logic){
$this->request->validate([
'project_id'=>'required',
],[
'project_id.required' => 'project_id不能为空',
]);
$data = $logic->copyProject();
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -513,4 +513,29 @@ class ProjectLogic extends BaseLogic
}
}
}
/**
* @remark :复制项目
* @name :copyProject
* @author :lyh
* @method :post
* @time :2023/11/8 14:23
*/
public function copyProject(){
//复制初始项目
$data = $this->model::where('id', $this->param['project_id'])->first();
$data = $data->getAttributes();
unset($data['id']);
$project_id = $this->model->insertGetId($data);
//复制部署表
$buildModel = new DeployBuild();
$buildData = $buildModel::where('id', $this->param['project_id'])->first();
$buildData = $buildData->getAttributes();
$buildData['project_id'] = $project_id;
unset($buildData['id']);
$buildModel->insert($buildData);
//复制优化表
$optimizeModel = new DeployOptimize();
return $this->success($data);
}
}
... ...
... ... @@ -63,11 +63,14 @@ class CustomTemplateLogic extends BaseLogic
try {
$this->param['url'] = str_replace_url($this->param['url']);
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->editCustomRoute($this->param['id'],$this->param['url']);
$id = $this->param['id'];
$this->param['url'] = $this->editCustomRoute($this->param['url']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
$this->fail('404页面已存在');
}else{
$this->param['url'] = $this->param['url'].'-tag';
}
$this->param['project_id'] = $this->user['project_id'];
$id = $this->model->addReturnId($this->param);
... ... @@ -166,7 +169,7 @@ class CustomTemplateLogic extends BaseLogic
* @method :post
* @time :2023/9/7 10:02
*/
public function editCustomRoute($id,$route){
public function editCustomRoute($route){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['url'] == $this->model::NOT_FOUND_PAGE_URL && $route['url'] != '404'){
$this->fail('404页面链接不可修改');
... ... @@ -178,8 +181,12 @@ class CustomTemplateLogic extends BaseLogic
'route'=>$info['url'],
];
$this->setRouteDeleteSave($data);
//"字符串以\"-product\"结尾"
if (!endsWith($route, "-tag")) {
$route = $route."-tag";
}
}
return $id;
return $route;
}
/**
... ...
... ... @@ -2,6 +2,7 @@
namespace App\Http\Logic\Bside\Blog;
use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\Blog as BlogModel;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
... ... @@ -32,19 +33,23 @@ class BlogCategoryLogic extends BaseLogic
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//查看路由是否更新
$id = $this->editCategoryRoute($this->param['id'], $this->param['alias']);
$id = $this->param['id'];
$this->editCategoryRoute($this->param['id'], $this->param['alias']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
//路由拼接
if(!isset($this->param['alias']) || empty($this->param['alias'])){
$this->param['alias'] = Translate::tran($this->param['name'], 'en');
}
//拼接参数
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
//处理子集
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$this->edit(['alias'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
... ... @@ -115,7 +120,7 @@ class BlogCategoryLogic extends BaseLogic
];
$this->setRouteDeleteSave($data);
}
return $this->success($id);
return true;
}
/**
... ...
... ... @@ -35,7 +35,8 @@ class BlogLogic extends BaseLogic
$this->param = $this->paramProcessing($this->param);
if(isset($this->param['id']) && !empty($this->param['id'])){
//是否更新路由
$id = $this->editNewsRoute($this->param['id'],$this->param['url']);
$id = $this->param['id'];
$this->editNewsRoute($this->param['id'],$this->param['url']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['url'] = $this->param['url'].'-'.RouteMap::SOURCE_BLOG;
... ... @@ -70,7 +71,7 @@ class BlogLogic extends BaseLogic
];
$this->setRouteDeleteSave($data);
}
return $id;
return true;
}
/**
... ...
... ... @@ -46,16 +46,20 @@ class NewsCategoryLogic extends BaseLogic
if(isset($this->param['id']) && !empty($this->param['id'])){
$this->param['operator_id'] = $this->user['id'];
//查看路由是否更新
$id = $this->editCategoryRoute($this->param['id'],$this->param['alias']);
$id = $this->param['id'];
$this->editCategoryRoute($this->param['id'],$this->param['alias']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
if(!isset($this->param['alias']) || empty($this->param['alias'])){
$this->param['alias'] = Translate::tran($this->param['name'], 'en');
}
$this->param = $this->addParamProcessing($this->param);
$id = $this->model->addReturnId($this->param);
//当父级分类拥有产品时,处理子集
$this->addProcessingSon($id);
}
$route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$this->model->edit(['alias'=>$route],['id'=>$id]);
DB::commit();
}catch (\Exception $e){
... ... @@ -126,7 +130,7 @@ class NewsCategoryLogic extends BaseLogic
];
$this->setRouteDeleteSave($data);
}
return $id;
return true;
}
... ...
... ... @@ -64,7 +64,8 @@ class NewsLogic extends BaseLogic
$this->param = $this->paramProcessing($this->param);
if (isset($this->param['id']) && !empty($this->param['id'])) {
//是否更新路由
$id = $this->editNewsRoute($this->param['id'], $this->param['url']);
$this->editNewsRoute($this->param['id'], $this->param['url']);
$id = $this->param['id'];
$this->edit($this->param, ['id' => $this->param['id']]);
} else {
$this->param['url'] = $this->param['url'].'-'.RouteMap::SOURCE_NEWS;
... ... @@ -101,7 +102,7 @@ class NewsLogic extends BaseLogic
];
$this->setRouteDeleteSave($data);
}
return $id;
return true;
}
... ...
... ... @@ -115,6 +115,7 @@ class CategoryLogic extends BaseLogic
if(isset($this->param['id']) && !empty($this->param['id'])){
//是否编辑路由
$id = $this->editCategoryRoute($this->param['id'],$this->param['route']);
//处理子集
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
... ... @@ -154,7 +155,6 @@ class CategoryLogic extends BaseLogic
//查看当前上级分类下是否有其他子分类
$cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]);
if ($cate_info === false) {
//查看当前上一级分类下是否有新闻
$productModel = new Product();
$blog_count = $productModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
if ($blog_count > 0) {
... ... @@ -163,6 +163,9 @@ class CategoryLogic extends BaseLogic
//更新所有商品到当前分类
$productModel->where('category_id', 'like', '%' . $old . '%')
->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
//同步更新关联表
$categoryRelatedModel = new CategoryRelated();
$categoryRelatedModel->edit(['category_id'=>$cate_id],['category_id'=>$this->param['pid']]);
}
}
}
... ... @@ -190,6 +193,15 @@ class CategoryLogic extends BaseLogic
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',')")]);
$productModel->where('category_id', 'like', '%,' . $pid . ',%')
->update(['category_id' => DB::raw("REPLACE(category_id, ',$pid,', ',$replacement,')")]);
//同步更新关联表
$categoryRelatedModel = new CategoryRelated();
$cateRelateList = $categoryRelatedModel->list(['category_id'=>$pid]);
if(!empty($cateRelateList)){
foreach ($cateRelateList as $v){
$categoryRelatedModel->del(['category_id'=>$replacement,'product_id'=>$v['product_id']]);
}
}
$categoryRelatedModel->edit(['category_id'=>$replacement],['category_id'=>$pid]);
}
}
return $this->success();
... ...
... ... @@ -60,9 +60,10 @@ class KeywordLogic extends BaseLogic
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
$this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT;
$id = $this->model->insertGetId($this->param);
//路由映射
$route = RouteMap::setRoute($this->param['title'].'-tag', RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$route = RouteMap::setRoute($this->param['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
}
//清除缓存
... ... @@ -200,7 +201,6 @@ class KeywordLogic extends BaseLogic
//清除缓存
Common::del_user_cache('product_keyword',$project_id);
return ','.implode(',',$return).',';
}
}
... ...
... ... @@ -37,26 +37,31 @@ class ProductLogic extends BaseLogic
* @time :2023/8/21 18:35
*/
public function productSave(){
//参数处理
$this->param = $this->handleSaveParam($this->param);
//单独处理分类
$category_ids = [];
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
$category_ids = $this->getLastCategoryArr($this->param['category_id']);
$this->param['category_id'] = ','.implode(',',$category_ids).',';
}
DB::connection('custom_mysql')->beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
//查看路由是否更新
$id = $this->editProductRoute($this->param['id'],$this->param['route']);
$this->param['route'] = $this->editProductRoute($this->param['route']);
$this->model->edit($this->param,['id'=>$this->param['id']]);
}else{
$this->param['project_id'] = $this->user['project_id'];
$this->param['created_at'] = date('Y-m-d H:i:s');
$this->param['updated_at'] = $this->param['created_at'];
//路由映射
$this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT;
$id = $this->model->addReturnId($this->param);
}
$route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$id]);
//产品分类关联
// CategoryRelated::saveRelated($id, $category_ids);
CategoryRelated::saveRelated($id, $category_ids);
DB::connection('custom_mysql')->commit();
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
... ... @@ -135,9 +140,6 @@ class ProductLogic extends BaseLogic
}
$param['attrs'] = Arr::a2s($param['attrs'] ?? '');
$param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
if(isset($param['category_id']) && !empty($param['category_id'])) {
$param['category_id'] = $this->getLastCategory($param['category_id']);
}
if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
$param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
}
... ... @@ -156,7 +158,7 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :获取最后一级分类id
* @remark :获取最后一级分类id(字符串)
* @name :getLastCategory
* @author :lyh
* @method :post
... ... @@ -177,13 +179,34 @@ class ProductLogic extends BaseLogic
}
/**
* @remark :获取最后一级分类id(数组)
* @name :getLastCategory
* @author :lyh
* @method :post
* @time :2023/10/20 9:02
*/
public function getLastCategoryArr($category){
$arr = [];
if(isset($category) && !empty($category)){
$cateModel = new Category();
foreach ($category as $v){
$info = $cateModel->read(['pid'=>$v]);
if($info === false){
$arr[] = $v;
}
}
}
return $arr;
}
/**
* @remark :编辑产品
* @name :editProduct
* @author :lyh
* @method :post
* @time :2023/9/7 10:02
*/
public function editProductRoute($id,$route){
public function editProductRoute($route){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info['route'] != $route){
//生成一条删除路由记录
... ... @@ -192,8 +215,12 @@ class ProductLogic extends BaseLogic
'route'=>$route,
];
$this->setRouteDeleteSave($data);
//"字符串以\"-product\"结尾"
if (!endsWith($route, "-product")) {
$route = $route."-product";
}
}
return $id;
return $route;
}
/**
... ... @@ -410,23 +437,27 @@ class ProductLogic extends BaseLogic
* @time :2023/8/15 17:53
*/
public function batchSetCategory(){
DB::connection('custom_mysql')->beginTransaction();
try {
//批量
$param = [
'category_id'=>','.Arr::arrToSet($this->param['category_id']).',',
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
//分类关联
foreach ($this->param['id'] as $id){
CategoryRelated::saveRelated($id, $this->param['category_id']);
}
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
DB::connection('custom_mysql')->beginTransaction();
$category_ids = $this->getLastCategoryArr($this->param['category_id']);
$this->param['category_id'] = ','.implode(',',$category_ids).',';
try {
//批量
$param = [
'category_id'=>$this->param['category_id'],
'status'=>$this->param['status']
];
$this->model->edit($param,['id'=>['in',$this->param['id']]]);
//分类关联
foreach ($this->param['id'] as $id){
CategoryRelated::saveRelated($id, $category_ids);
}
DB::connection('custom_mysql')->commit();
//对应添加关联表
}catch (\Exception $e){
DB::connection('custom_mysql')->rollBack();
$this->fail('系统错误,请联系管理员');
}
}
return $this->success();
}
... ...
... ... @@ -3,6 +3,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class Base extends Model
{
protected $table = '';
... ... @@ -51,9 +53,12 @@ class Base extends Model
* @author :liyuhang
* @method
*/
public function list($map = [],$order = 'id',$fields = ['*'],$sort = 'desc'): array
public function list($map = [],$order = 'id',$fields = ['*'],$sort = 'desc',$row = 0): array
{
$query = $this->formatQuery($map);
if($row != 0){
$query = $query->limit($row);
}
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->get();
if (empty($lists)) {
... ...
... ... @@ -32,15 +32,17 @@ class CategoryRelated extends Base
}
//先删除
self::where('product_id', $product_id)->delete();
//批量保存
$data = [];
foreach ($cate_ids as $cate_id){
$data[] = [
'product_id' => $product_id,
'cate_id' => $cate_id
];
if(!empty($cate_ids)){
foreach ($cate_ids as $cate_id){
$data[] = [
'product_id' => $product_id,
'cate_id' => $cate_id
];
}
self::insert($data);
}
self::insert($data);
return true;
}
}
... ...
<?php
/**
* @remark :
* @name :ProjectUpdateTdk.php
* @author :lyh
* @method :post
* @time :2023/11/8 11:18
*/
namespace App\Models\Project;
use App\Models\Base;
class ProjectUpdateTdk extends Base
{
//设置关联表名
protected $table = 'gl_project_update_tdk';
}
... ...
... ... @@ -109,6 +109,15 @@ class RouteMap extends Base
if(!$route_map){
$route_map = new self();
$route_map->source = $source;
if($source == self::SOURCE_NEWS){
$route_map->path = self::SOURCE_NEWS;
}elseif($source == self::SOURCE_NEWS_CATE){
$route_map->path = self::PATH_NEWS_CATE;
}elseif ($source == self::SOURCE_BLOG){
$route_map->path = self::SOURCE_BLOG;
}elseif ($source == self::SOURCE_BLOG_CATE){
$route_map->path = self::PATH_BLOG_CATE;
}
$route_map->source_id = $source_id;
$route_map->project_id = $project_id;
}
... ...
... ... @@ -168,6 +168,8 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/getDomain', [Aside\Project\ProjectController::class, 'getDomain'])->name('admin.project_getDomain');//获取域名列表
Route::any('/del', [Aside\Project\ProjectController::class, 'del'])->name('admin.project_del');
Route::any('/getRenewLog', [Aside\Project\ProjectController::class, 'getRenewLog'])->name('admin.project_getRenewLog');
Route::any('/tdkList', [Aside\Project\ProjectController::class, 'tdkList'])->name('admin.project_tdkList');
Route::any('/copyProject', [Aside\Project\ProjectController::class, 'copyProject'])->name('admin.project_copyProject');
//获取关键词前缀和后缀
Route::prefix('keyword')->group(function () {
Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix');
... ...