作者 刘锟

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

@@ -143,6 +143,7 @@ class VideoTask extends Command @@ -143,6 +143,7 @@ class VideoTask extends Command
143 ], 143 ],
144 'task_id' => $task_id, 144 'task_id' => $task_id,
145 'callback_url' => env('APP_URL') . '/api/video_task_callback', 145 'callback_url' => env('APP_URL') . '/api/video_task_callback',
  146 + 'is_ytb'=>true
146 ]; 147 ];
147 $result = Http::post('http://216.250.255.116:7866/create_task', $data); 148 $result = Http::post('http://216.250.255.116:7866/create_task', $data);
148 $val->task_id = $task_id; 149 $val->task_id = $task_id;
@@ -215,28 +216,33 @@ class VideoTask extends Command @@ -215,28 +216,33 @@ class VideoTask extends Command
215 $productIds[] = $item->id; 216 $productIds[] = $item->id;
216 } 217 }
217 if (count($productIds)<7){ 218 if (count($productIds)<7){
218 - $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray();  
219 - $product_id = array_rand($product_all_id, 13-count($productIds)); 219 + $product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
  220 + $number = 40;
  221 + $product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));
220 $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 222 $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
221 $products = $productsQuery->merge($randomData); 223 $products = $productsQuery->merge($randomData);
222 }else{ 224 }else{
223 $products = $productsQuery; 225 $products = $productsQuery;
224 } 226 }
225 }else{ 227 }else{
226 - $product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray();  
227 - $product_id = array_rand($product_all_id, 13); 228 + $product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
  229 + $product_id = array_rand($product_all_id, 40);
228 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 230 $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
229 } 231 }
230 } 232 }
231 $data = []; 233 $data = [];
232 if (!empty($products)){ 234 if (!empty($products)){
233 foreach ($products as $item){ 235 foreach ($products as $item){
234 - $data[] = !empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : ""; 236 + if(empty($item->thumb) || ($item->thumb['url'] == "")){
  237 + continue;
  238 + }
  239 + if(count($data) > 13){
  240 + break;
  241 + }
  242 + $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
235 } 243 }
236 } 244 }
237 return $data; 245 return $data;
238 } 246 }
239 247
240 -  
241 -  
242 } 248 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Notice.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/3/6 16:01
  8 + */
  9 +
  10 +namespace App\Console\Commands\Notice;
  11 +
  12 +use App\Models\Com\KeywordVideoTaskLog;
  13 +use App\Models\Domain\DomainInfo;
  14 +use Illuminate\Console\Command;
  15 +use Illuminate\Support\Facades\DB;
  16 +
  17 +/**
  18 + * @remark :通知C端生成界面
  19 + * @name :Notice
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2024/3/6 16:01
  23 + */
  24 +class Notice extends Command
  25 +{
  26 + /**
  27 + * The name and signature of the console command.
  28 + *
  29 + * @var string
  30 + */
  31 + protected $signature = 'notice_c';
  32 +
  33 + /**
  34 + * The console command description.
  35 + *
  36 + * @var string
  37 + */
  38 + protected $description = '通知C端生成界面';
  39 +
  40 + /**
  41 + * @remark :通知C端生成界面
  42 + * @name :handle
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/11/20 15:13
  46 + */
  47 + public function handle(){
  48 + $yesterday = date('Y-m-d', strtotime('yesterday'));
  49 + $keywordVideoModel = new KeywordVideoTaskLog();
  50 + $list = $keywordVideoModel->select('project_id')
  51 + ->groupBy('project_id')->whereBetween('created_at', [$yesterday.' 00:00:00',$yesterday.' 23:59:59'])->get()->toArray();
  52 + $project_arr = [];
  53 + if(empty($list)){
  54 + echo date('Y-m-d H:i:s') . '无需通知' . PHP_EOL;
  55 + return false;
  56 + }
  57 + foreach ($list as $k => $v){
  58 + $project_arr[] = $v['project_id'];
  59 + }
  60 + $domainModel = new DomainInfo();
  61 + $domainList = $domainModel->formatQuery(['project_id'=>['in',$project_arr]])->get()->toArray();
  62 + if(empty($domainList)){
  63 + echo date('Y-m-d H:i:s') . '无域名:'.json_encode($domainList) . PHP_EOL;
  64 + return false;
  65 + }
  66 + foreach ($domainList as $v1){
  67 + //TODO::通知C端
  68 + $this->curlDelRoute($v1['domain'],$v1['project_id']);
  69 + }
  70 + return true;
  71 + }
  72 +
  73 + /**
  74 + * @remark :删除路由通知C端
  75 + * @name :curlDelRoute
  76 + * @author :lyh
  77 + * @method :post
  78 + * @time :2023/11/30 14:43
  79 + */
  80 + public function curlDelRoute($domain,$project_id){
  81 + if (strpos($domain, 'https://') === false) {
  82 + $domain = 'https://' . $domain . '/';
  83 + }
  84 + $url = $domain.'api/update_page/?project_id='.$project_id.'&route=6';
  85 + shell_exec('curl -k "'.$url.'"');
  86 + return true;
  87 + }
  88 +}
@@ -44,6 +44,7 @@ class Kernel extends ConsoleKernel @@ -44,6 +44,7 @@ class Kernel extends ConsoleKernel
44 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次 44 $schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
45 45
46 $schedule->command('recommended_suppliers')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 46 $schedule->command('recommended_suppliers')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
  47 + $schedule->command('notice_c')->dailyAt('02:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
47 } 48 }
48 49
49 /** 50 /**
@@ -211,7 +211,7 @@ class OptimizeController extends BaseController @@ -211,7 +211,7 @@ class OptimizeController extends BaseController
211 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]); 211 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
212 } 212 }
213 if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){ 213 if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
214 - $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']); 214 + $query = $query->whereBetween('gl_project_deploy_optimize.start_date', $this->map['online_updated_at']);
215 } 215 }
216 if(isset($this->map['special'])){ 216 if(isset($this->map['special'])){
217 $query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]); 217 $query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]);
@@ -328,25 +328,5 @@ class ComController extends BaseController @@ -328,25 +328,5 @@ class ComController extends BaseController
328 $this->response('success',Code::SUCCESS,$data); 328 $this->response('success',Code::SUCCESS,$data);
329 } 329 }
330 330
331 - /**  
332 - * @remark :推荐采购商  
333 - * @name :recommendedPurchaser  
334 - * @author :lyh  
335 - * @method :post  
336 - * @time :2024/3/4 10:10  
337 - */  
338 - public function recommendedPurchaser(){  
339 - $purchaserModel = new Purchaser();  
340 - $data = [];  
341 - $lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]);  
342 - if(!empty($lists)){  
343 - foreach ($lists as $v){  
344 - $resultData = json_decode($v['data']);  
345 - foreach ($resultData as $value){  
346 - $data[] = $value;  
347 - }  
348 - }  
349 - }  
350 - $this->response('success',Code::SUCCESS,$data);  
351 - } 331 +
352 } 332 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :SuppliersController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/3/7 9:23
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Suppliers;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Models\Com\Purchaser;
  15 +
  16 +/**
  17 + * @remark :推荐采购商
  18 + * @name :SuppliersController
  19 + * @author :lyh
  20 + * @method :post
  21 + * @time :2024/3/7 9:23
  22 + */
  23 +class SuppliersController extends BaseController
  24 +{
  25 + public $domain = 'https://admin.hagro.cn/';
  26 +
  27 + /**
  28 + * @remark :推荐采购商
  29 + * @name :recommendedPurchaser
  30 + * @author :lyh
  31 + * @method :post
  32 + * @time :2024/3/4 10:10
  33 + */
  34 + public function recommendedPurchaser(){
  35 + $purchaserModel = new Purchaser();
  36 + $data = [];
  37 + $lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]);
  38 + if(!empty($lists)){
  39 + foreach ($lists as $v){
  40 + $resultData = json_decode($v['data']);
  41 + foreach ($resultData as $value){
  42 + $data[] = $value;
  43 + }
  44 + }
  45 + }
  46 + $this->response('success',Code::SUCCESS,$data);
  47 + }
  48 +
  49 + /**
  50 + * @remark :请求黑格公共方法
  51 + * @name :_action
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2024/3/7 9:30
  55 + */
  56 + public function _action($api_url,$action_name,$param){
  57 + $url = $this->domain.$api_url;
  58 + ksort($param);
  59 + $token = $action_name. '+' .date('Y-m-d'). '+' .http_build_query($param);
  60 + $param['token'] = md5($token);
  61 + $res = http_post($url,json_encode($param));
  62 + return $this->success($res);
  63 + }
  64 + /**
  65 + * @remark :按名字搜索公司
  66 + * @name :company_domain
  67 + * @author :lyh
  68 + * @method :post
  69 + * @time :2024/3/7 9:27
  70 + */
  71 + public function company_domain(){
  72 + $api_url = 'api/company_domain';
  73 + $action_name = 'company_domain';
  74 + $param = [
  75 + 'search'=>$this->param['search'],
  76 + ];
  77 + $res = $this->_action($api_url,$action_name,$param);
  78 + $this->response('success',Code::SUCCESS,$res);
  79 + }
  80 +
  81 + /**
  82 + * @remark :通过域名获取公司信息
  83 + * @name :company_detail
  84 + * @author :lyh
  85 + * @method :post
  86 + * @time :2024/3/7 9:46
  87 + */
  88 + public function company_detail(){
  89 + $api_url = 'api/company_detail';
  90 + $action_name = 'company_detail';
  91 + $param = [
  92 + 'domain'=>$this->param['domain'],
  93 + ];
  94 + $res = $this->_action($api_url,$action_name,$param);
  95 + $this->response('success',Code::SUCCESS,$res);
  96 + }
  97 +
  98 + /**
  99 + * @remark :领英决策人员
  100 + * @name :company_linked
  101 + * @author :lyh
  102 + * @method :post
  103 + * @time :2024/3/7 9:48
  104 + */
  105 + public function company_linked(){
  106 + $api_url = 'api/company_linked';
  107 + $action_name = 'company_linked';
  108 + $param = [
  109 + 'domain'=>$this->param['domain'],
  110 + 'keyword'=>$this->param['keyword'],
  111 + 'position'=>$this->param['position'],
  112 + 'page'=>$this->page,
  113 + 'page_size'=>$this->row,
  114 + ];
  115 + $res = $this->_action($api_url,$action_name,$param);
  116 + $this->response('success',Code::SUCCESS,$res);
  117 + }
  118 +
  119 + /**
  120 + * @remark :海关数据信息
  121 + * @name :trade_trend
  122 + * @author :lyh
  123 + * @method :post
  124 + * @time :2024/3/7 9:51
  125 + */
  126 + public function trade_trend(){
  127 + $api_url = 'api/trade_trend';
  128 + $action_name = 'trade_trend';
  129 + $param = [
  130 + 'prod_desc'=>$this->param['prod_desc'],
  131 + ];
  132 + $res = $this->_action($api_url,$action_name,$param);
  133 + $this->response('success',Code::SUCCESS,$res);
  134 + }
  135 +
  136 + /**
  137 + * @remark :供应商区域分布
  138 + * @name :supplier_area
  139 + * @author :lyh
  140 + * @method :post
  141 + * @time :2024/3/7 9:52
  142 + */
  143 + public function supplier_area(){
  144 + $api_url = 'api/supplier_area';
  145 + $action_name = 'supplier_area';
  146 + $param = [
  147 + 'prod_desc'=>$this->param['prod_desc'],
  148 + 'start_date'=>$this->param['start_date'],
  149 + 'end_date'=>$this->param['end_date'],
  150 + ];
  151 + $res = $this->_action($api_url,$action_name,$param);
  152 + $this->response('success',Code::SUCCESS,$res);
  153 + }
  154 +
  155 + /**
  156 + * @remark :贸易伙伴
  157 + * @name :trade_partner
  158 + * @author :lyh
  159 + * @method :post
  160 + * @time :2024/3/7 9:54
  161 + */
  162 + public function trade_partner(){
  163 + $api_url = 'api/trade_partner';
  164 + $action_name = 'trade_partner';
  165 + $param = [
  166 + 'com_id'=>$this->param['com_id'],
  167 + 'com_role'=>$this->param['com_role'],
  168 + ];
  169 + $res = $this->_action($api_url,$action_name,$param);
  170 + $this->response('success',Code::SUCCESS,$res);
  171 + }
  172 +
  173 + /**
  174 + * @remark :贸易明细
  175 + * @name :trade_detail
  176 + * @author :lyh
  177 + * @method :post
  178 + * @time :2024/3/7 9:55
  179 + */
  180 + public function trade_detail(){
  181 + $api_url = 'api/trade_detail';
  182 + $action_name = 'trade_detail';
  183 + $param = [
  184 + 'prod_desc'=>$this->param['prod_desc'],
  185 + ];
  186 + $res = $this->_action($api_url,$action_name,$param);
  187 + $this->response('success',Code::SUCCESS,$res);
  188 + }
  189 +
  190 + /**
  191 + * @remark :提单详情
  192 + * @name :bill_detail
  193 + * @author :lyh
  194 + * @method :post
  195 + * @time :2024/3/7 9:56
  196 + */
  197 + public function bill_detail(){
  198 + $api_url = 'api/bill_detail';
  199 + $action_name = 'bill_detail';
  200 + $param = [
  201 + 'prod_desc'=>$this->param['prod_desc'],
  202 + 'page'=>$this->page,
  203 + 'page_size'=>$this->row,
  204 + ];
  205 + $res = $this->_action($api_url,$action_name,$param);
  206 + $this->response('success',Code::SUCCESS,$res);
  207 + }
  208 +
  209 + /**
  210 + * @remark :进口产品信息
  211 + * @name :import_product
  212 + * @author :lyh
  213 + * @method :post
  214 + * @time :2024/3/7 9:59
  215 + */
  216 + public function import_product(){
  217 + $api_url = 'api/import_product';
  218 + $action_name = 'import_product';
  219 + $param = [
  220 + 'com_id'=>$this->param['com_id'],
  221 + 'com_role'=>$this->param['com_role'],
  222 + ];
  223 + $res = $this->_action($api_url,$action_name,$param);
  224 + $this->response('success',Code::SUCCESS,$res);
  225 + }
  226 +}
@@ -20,7 +20,19 @@ Route::middleware(['bloginauth'])->group(function () { @@ -20,7 +20,19 @@ Route::middleware(['bloginauth'])->group(function () {
20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken'); 20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink'); 21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
22 Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject'); 22 Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
23 - Route::any('/recommendedPurchaser', [\App\Http\Controllers\Bside\BCom\ComController::class, 'recommendedPurchaser'])->name('recommendedPurchaser'); 23 + //黑格数据
  24 + Route::prefix('suppliers')->group(function () {
  25 + Route::any('/recommendedPurchaser', [\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'recommendedPurchaser'])->name('suppliers_recommendedPurchaser');
  26 + Route::any('/company_domain',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_domain'])->name('suppliers_company_domain');
  27 + Route::any('/company_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_detail'])->name('suppliers_company_detail');
  28 + Route::any('/company_linked',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_linked'])->name('suppliers_company_linked');
  29 + Route::any('/trade_trend',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_trend'])->name('suppliers_trade_trend');
  30 + Route::any('/supplier_area',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'supplier_area'])->name('suppliers_supplier_area');
  31 + Route::any('/trade_partner',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_partner'])->name('suppliers_trade_partner');
  32 + Route::any('/trade_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_detail'])->name('suppliers_trade_detail');
  33 + Route::any('/bill_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'bill_detail'])->name('suppliers_bill_detail');
  34 + Route::any('/import_product',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'import_product'])->name('suppliers_import_product');
  35 + });
24 //用户相关路由 36 //用户相关路由
25 Route::prefix('user')->group(function () { 37 Route::prefix('user')->group(function () {
26 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists'); 38 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');