作者 刘锟

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

... ... @@ -143,6 +143,7 @@ class VideoTask extends Command
],
'task_id' => $task_id,
'callback_url' => env('APP_URL') . '/api/video_task_callback',
'is_ytb'=>true
];
$result = Http::post('http://216.250.255.116:7866/create_task', $data);
$val->task_id = $task_id;
... ... @@ -215,28 +216,33 @@ class VideoTask extends Command
$productIds[] = $item->id;
}
if (count($productIds)<7){
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",1)->pluck('id')->toArray();
$product_id = array_rand($product_all_id, 13-count($productIds));
$product_all_id = Product::where("project_id", $project_id)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$number = 40;
$product_id = array_rand($product_all_id, min(count($product_all_id, $number-count($productIds))));
$randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
$products = $productsQuery->merge($randomData);
}else{
$products = $productsQuery;
}
}else{
$product_all_id = Product::where("project_id", $project_id)->where("status",1)->pluck('id')->toArray();
$product_id = array_rand($product_all_id, 13);
$product_all_id = Product::where("project_id", $project_id)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
$product_id = array_rand($product_all_id, 40);
$products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get();
}
}
$data = [];
if (!empty($products)){
foreach ($products as $item){
$data[] = !empty($item->thumb) && $item->thumb['url'] != "" ? getImageUrl($item->thumb['url']) : "";
if(empty($item->thumb) || ($item->thumb['url'] == "")){
continue;
}
if(count($data) > 13){
break;
}
$data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
}
}
return $data;
}
}
... ...
<?php
/**
* @remark :
* @name :Notice.php
* @author :lyh
* @method :post
* @time :2024/3/6 16:01
*/
namespace App\Console\Commands\Notice;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\Domain\DomainInfo;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* @remark :通知C端生成界面
* @name :Notice
* @author :lyh
* @method :post
* @time :2024/3/6 16:01
*/
class Notice extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'notice_c';
/**
* The console command description.
*
* @var string
*/
protected $description = '通知C端生成界面';
/**
* @remark :通知C端生成界面
* @name :handle
* @author :lyh
* @method :post
* @time :2023/11/20 15:13
*/
public function handle(){
$yesterday = date('Y-m-d', strtotime('yesterday'));
$keywordVideoModel = new KeywordVideoTaskLog();
$list = $keywordVideoModel->select('project_id')
->groupBy('project_id')->whereBetween('created_at', [$yesterday.' 00:00:00',$yesterday.' 23:59:59'])->get()->toArray();
$project_arr = [];
if(empty($list)){
echo date('Y-m-d H:i:s') . '无需通知' . PHP_EOL;
return false;
}
foreach ($list as $k => $v){
$project_arr[] = $v['project_id'];
}
$domainModel = new DomainInfo();
$domainList = $domainModel->formatQuery(['project_id'=>['in',$project_arr]])->get()->toArray();
if(empty($domainList)){
echo date('Y-m-d H:i:s') . '无域名:'.json_encode($domainList) . PHP_EOL;
return false;
}
foreach ($domainList as $v1){
//TODO::通知C端
$this->curlDelRoute($v1['domain'],$v1['project_id']);
}
return true;
}
/**
* @remark :删除路由通知C端
* @name :curlDelRoute
* @author :lyh
* @method :post
* @time :2023/11/30 14:43
*/
public function curlDelRoute($domain,$project_id){
if (strpos($domain, 'https://') === false) {
$domain = 'https://' . $domain . '/';
}
$url = $domain.'api/update_page/?project_id='.$project_id.'&route=6';
shell_exec('curl -k "'.$url.'"');
return true;
}
}
... ...
... ... @@ -44,6 +44,7 @@ class Kernel extends ConsoleKernel
$schedule->command('sync_manager')->dailyAt('01:00')->withoutOverlapping(1); //TODO::手机号码同步 每天执行一次
$schedule->command('recommended_suppliers')->dailyAt('01:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
$schedule->command('notice_c')->dailyAt('02:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商
}
/**
... ...
... ... @@ -211,7 +211,7 @@ class OptimizeController extends BaseController
$query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
}
if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
$query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']);
$query = $query->whereBetween('gl_project_deploy_optimize.start_date', $this->map['online_updated_at']);
}
if(isset($this->map['special'])){
$query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]);
... ...
... ... @@ -328,25 +328,5 @@ class ComController extends BaseController
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :推荐采购商
* @name :recommendedPurchaser
* @author :lyh
* @method :post
* @time :2024/3/4 10:10
*/
public function recommendedPurchaser(){
$purchaserModel = new Purchaser();
$data = [];
$lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]);
if(!empty($lists)){
foreach ($lists as $v){
$resultData = json_decode($v['data']);
foreach ($resultData as $value){
$data[] = $value;
}
}
}
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
<?php
/**
* @remark :
* @name :SuppliersController.php
* @author :lyh
* @method :post
* @time :2024/3/7 9:23
*/
namespace App\Http\Controllers\Bside\Suppliers;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\Com\Purchaser;
/**
* @remark :推荐采购商
* @name :SuppliersController
* @author :lyh
* @method :post
* @time :2024/3/7 9:23
*/
class SuppliersController extends BaseController
{
public $domain = 'https://admin.hagro.cn/';
/**
* @remark :推荐采购商
* @name :recommendedPurchaser
* @author :lyh
* @method :post
* @time :2024/3/4 10:10
*/
public function recommendedPurchaser(){
$purchaserModel = new Purchaser();
$data = [];
$lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]);
if(!empty($lists)){
foreach ($lists as $v){
$resultData = json_decode($v['data']);
foreach ($resultData as $value){
$data[] = $value;
}
}
}
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :请求黑格公共方法
* @name :_action
* @author :lyh
* @method :post
* @time :2024/3/7 9:30
*/
public function _action($api_url,$action_name,$param){
$url = $this->domain.$api_url;
ksort($param);
$token = $action_name. '+' .date('Y-m-d'). '+' .http_build_query($param);
$param['token'] = md5($token);
$res = http_post($url,json_encode($param));
return $this->success($res);
}
/**
* @remark :按名字搜索公司
* @name :company_domain
* @author :lyh
* @method :post
* @time :2024/3/7 9:27
*/
public function company_domain(){
$api_url = 'api/company_domain';
$action_name = 'company_domain';
$param = [
'search'=>$this->param['search'],
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :通过域名获取公司信息
* @name :company_detail
* @author :lyh
* @method :post
* @time :2024/3/7 9:46
*/
public function company_detail(){
$api_url = 'api/company_detail';
$action_name = 'company_detail';
$param = [
'domain'=>$this->param['domain'],
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :领英决策人员
* @name :company_linked
* @author :lyh
* @method :post
* @time :2024/3/7 9:48
*/
public function company_linked(){
$api_url = 'api/company_linked';
$action_name = 'company_linked';
$param = [
'domain'=>$this->param['domain'],
'keyword'=>$this->param['keyword'],
'position'=>$this->param['position'],
'page'=>$this->page,
'page_size'=>$this->row,
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :海关数据信息
* @name :trade_trend
* @author :lyh
* @method :post
* @time :2024/3/7 9:51
*/
public function trade_trend(){
$api_url = 'api/trade_trend';
$action_name = 'trade_trend';
$param = [
'prod_desc'=>$this->param['prod_desc'],
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :供应商区域分布
* @name :supplier_area
* @author :lyh
* @method :post
* @time :2024/3/7 9:52
*/
public function supplier_area(){
$api_url = 'api/supplier_area';
$action_name = 'supplier_area';
$param = [
'prod_desc'=>$this->param['prod_desc'],
'start_date'=>$this->param['start_date'],
'end_date'=>$this->param['end_date'],
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :贸易伙伴
* @name :trade_partner
* @author :lyh
* @method :post
* @time :2024/3/7 9:54
*/
public function trade_partner(){
$api_url = 'api/trade_partner';
$action_name = 'trade_partner';
$param = [
'com_id'=>$this->param['com_id'],
'com_role'=>$this->param['com_role'],
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :贸易明细
* @name :trade_detail
* @author :lyh
* @method :post
* @time :2024/3/7 9:55
*/
public function trade_detail(){
$api_url = 'api/trade_detail';
$action_name = 'trade_detail';
$param = [
'prod_desc'=>$this->param['prod_desc'],
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :提单详情
* @name :bill_detail
* @author :lyh
* @method :post
* @time :2024/3/7 9:56
*/
public function bill_detail(){
$api_url = 'api/bill_detail';
$action_name = 'bill_detail';
$param = [
'prod_desc'=>$this->param['prod_desc'],
'page'=>$this->page,
'page_size'=>$this->row,
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
/**
* @remark :进口产品信息
* @name :import_product
* @author :lyh
* @method :post
* @time :2024/3/7 9:59
*/
public function import_product(){
$api_url = 'api/import_product';
$action_name = 'import_product';
$param = [
'com_id'=>$this->param['com_id'],
'com_role'=>$this->param['com_role'],
];
$res = $this->_action($api_url,$action_name,$param);
$this->response('success',Code::SUCCESS,$res);
}
}
... ...
... ... @@ -20,7 +20,19 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
Route::any('/recommendedPurchaser', [\App\Http\Controllers\Bside\BCom\ComController::class, 'recommendedPurchaser'])->name('recommendedPurchaser');
//黑格数据
Route::prefix('suppliers')->group(function () {
Route::any('/recommendedPurchaser', [\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'recommendedPurchaser'])->name('suppliers_recommendedPurchaser');
Route::any('/company_domain',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_domain'])->name('suppliers_company_domain');
Route::any('/company_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_detail'])->name('suppliers_company_detail');
Route::any('/company_linked',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'company_linked'])->name('suppliers_company_linked');
Route::any('/trade_trend',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_trend'])->name('suppliers_trade_trend');
Route::any('/supplier_area',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'supplier_area'])->name('suppliers_supplier_area');
Route::any('/trade_partner',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_partner'])->name('suppliers_trade_partner');
Route::any('/trade_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_detail'])->name('suppliers_trade_detail');
Route::any('/bill_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'bill_detail'])->name('suppliers_bill_detail');
Route::any('/import_product',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'import_product'])->name('suppliers_import_product');
});
//用户相关路由
Route::prefix('user')->group(function () {
Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');
... ...