作者 刘锟

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

... ... @@ -149,6 +149,7 @@ class CountProject extends Command
if($inquiry_list == false){
return false;
}
echo date('Y-m-d H:i:s') . '拉取询盘状态:' .json_encode($inquiry_list) . PHP_EOL;
if($inquiry_list['status'] == self::STATUS_ERROR){
$arr['inquiry_num'] = 0;
$countryArr = [];
... ...
... ... @@ -35,6 +35,7 @@ use App\Models\Template\BTemplateCom;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use App\Utils\EncryptUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
... ... @@ -56,6 +57,20 @@ class Demo extends Command
*/
protected $description = 'demo';
public function handle(){
$domain = "https://www.xawellauto.com/";
$token = md5($domain.date("Y-m-d"));
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
errorLog('提交询盘信息失败', $domain, $e);
return false;
}
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return true;
}
// public function handle(){
// $projectModel = new Project();
// $list = $projectModel->list(['id'=>503]);
... ... @@ -89,26 +104,26 @@ class Demo extends Command
// DB::disconnect('custom_mysql');
// }
// }
public function handle(){
ProjectServer::useProject(503);
$newsCate = new NewsCategory();
$newsList = $newsCate->list();
foreach ($newsList as $v){
$data = [
'name'=>$v['name'],
'status'=>0,
'sort'=>$v['sort'],
'pid'=>$v['pid'],
'route'=>$v['alias'],
'project_id'=>503,
'operator_id'=>$v['operator_id'],
'create_id'=>1101,
'module_id'=>10,
];
$moduleCateModel = new CustomModuleCategory();
$id = $moduleCateModel->addReturnId($data);
RouteMap::setRoute($v['alias'],RouteMap::SOURCE_MODULE_CATE,$id,503);
}
DB::disconnect('custom_mysql');
}
// public function handle(){
// ProjectServer::useProject(503);
// $newsCate = new NewsCategory();
// $newsList = $newsCate->list();
// foreach ($newsList as $v){
// $data = [
// 'name'=>$v['name'],
// 'status'=>0,
// 'sort'=>$v['sort'],
// 'pid'=>$v['pid'],
// 'route'=>$v['alias'],
// 'project_id'=>503,
// 'operator_id'=>$v['operator_id'],
// 'create_id'=>1101,
// 'module_id'=>10,
// ];
// $moduleCateModel = new CustomModuleCategory();
// $id = $moduleCateModel->addReturnId($data);
// RouteMap::setRoute($v['alias'],RouteMap::SOURCE_MODULE_CATE,$id,503);
// }
// DB::disconnect('custom_mysql');
// }
}
... ...
<?php
/**
* @remark :
* @name :SyncTimeFiles.php
* @author :lyh
* @method :post
* @time :2024/8/14 14:23
*/
namespace App\Console\Commands\Test;
use App\Models\File\ErrorFile;
use App\Models\File\File;
use Illuminate\Console\Command;
class SyncTimeFiles extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_videos';
/**
* The console command description.
*
* @var string
*/
protected $description = '按时间同步图片与文件';
public function handle()
{
$fileModel = new File();
$start = '2024-08-10 00:00:00';
$end = date('Y-m-d H:i:s');
$lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
foreach ($lists as $v){
$path = $v['path'];
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
if(200 != (int)$code){
echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
// $errorFileModel = new ErrorFile();
// $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
}
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
}
}
... ...
<?php
/**
* @remark :
* @name :SyncVideo.php
* @author :lyh
* @method :post
* @time :2024/8/14 13:50
*/
namespace App\Console\Commands\Test;
use App\Models\File\ErrorFile;
use Illuminate\Console\Command;
class SyncVideo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_video {path}';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步图片与文件';
public function handle()
{
$path = $this->argument('path');
$this->param['name'] = basename($path);
$this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
$file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
$cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
$code = shell_exec($cmd);
if(200 != (int)$code){
$errorFileModel = new ErrorFile();
$errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
}
return true;
}
/**
* @remark :获取图片文件链接
* @name :getUrl
* @author :lyh
* @method :post
* @time :2024/5/22 11:53
*/
public function getUrl($path,$storage_type,$location){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = $this->getUrl($v,$storage_type,$location);
}
}else{
if(empty($path)){
return '';
}
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
return $path;
}
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
$url = $cosCdn.$path;
}else{
$s3 = config('filesystems.disks.s3');
$cdn = $s3['cdn'];
$url = $cdn.$path;
}
}
return $url;
}
}
... ...
... ... @@ -15,6 +15,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('sync_file')->everyThirtyMinutes()->withoutOverlapping(1);//每半小时执行同步
// 每日更新最新模块
$schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
$schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
... ...
... ... @@ -32,8 +32,22 @@ class LogFormatterFactory
$path = date('Y-m', $time) . '/' . date('d', $time) . '_' . $suffix . '.log';
$path = 'logs/' . $config['prefix'] . '/' . $path;
$path = storage_path($path);
try {
if (!file_exists($path)) {
$directory = pathinfo($path, PATHINFO_DIRNAME);
if(!file_exists($directory)){
mkdir($directory, 0644, true);
chown($directory, 'www');
}
touch($path);
chown($path, 'www');
}
}catch (\Throwable $exception){}
$handler = new StreamHandler($path, $level, false);
$handler->setFormatter(new LineFormatter(null, 'Y-m-d H:i:s', false, true));
return $handler;
}
... ...
... ... @@ -70,7 +70,7 @@ class FormGlobalsoApi
$res = HttpUtils::get($api_url, $params);
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('询盘列表', $params, $e);
errorLog('询盘列表'.$api_url, $params, $e);
return false;
}
return $res;
... ... @@ -155,5 +155,24 @@ class FormGlobalsoApi
return $res;
}
/**
* @remark :获取当前项目所有询盘及询盘国家
* @name :getInquiryAll
* @author :lyh
* @method :post
* @time :2024/8/15 14:16
*/
public function getInquiryAll($domain){
$domain = 'https://'.$domain.'/';
$token = md5($domain.date("Y-m-d"));
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
errorLog('提交询盘信息失败', $domain, $e);
return false;
}
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
}
... ...
... ... @@ -88,9 +88,7 @@ class AyrReleaseController extends BaseController
}
//发送请求发布社交文章
$res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
if($res){
$ayrReleaseLogic->release_add($res);
}
$res = $ayrReleaseLogic->release_add($res);
//保存返回的内容
$this->response('success',Code::SUCCESS,json_decode($res));
}
... ...
... ... @@ -346,23 +346,43 @@ class ProductController extends BaseController
return [];
}
$extendInfoModel = new ExtendInfo();
$infoList = $extendInfoModel->list(['product_id'=>$product_id],'created_at');
foreach ($list as $k=>$v){
$info = $extendInfoModel->read(['key'=>$v['key'],'product_id'=>$product_id]);
if($info == false){
if($v['type'] == 3 || $v['type'] == 4){
$v['values'] = [];
}else{
$v['values'] = '';
foreach ($infoList as $values){
if($v['key'] == $values['key']){
$v = $this->setTypValues($v,$values);
break;
}
}else{
$v = $this->setTypValues($v,$info);
}
$list[$k] = $v;
}
$list = $this->handleExtentList($list);
return $list;
}
/**
* @remark :处理详情数据(初始化)
* @name :handleList
* @author :lyh
* @method :post
* @time :2024/8/14 18:26
*/
public function handleExtentList($list){
foreach ($list as $k => $v){
if($v['type'] == 3 || $v['type'] == 4){
if(!isset($v['values'])){
$v['values'] = [];
}
}else{
if(!isset($v['values'])){
$v['values'] = '';
}
}
$list[$k] = $v;
}
return $this->success($list);
}
/**
* @remark :扩展字段根据type返回类型
* @name :setTypValues
* @author :lyh
... ...
... ... @@ -50,11 +50,12 @@ class AyrReleaseLogic extends BaseLogic
$this->model->add($this->param);
}else{
$result_data = json_decode($this->param['result_data']);
if(isset($result_data['status']) && $result_data['status'] == 'success'){
if(isset($result_data->status) && $result_data->status == 'success'){
$this->model->edit($this->param,['id'=>$info['id']]);
return $this->param['result_data'];
}
}
return $this->success();
return $this->param['result_data'];
}
/**
* @name :(上传第三方图片参数处理)get_param
... ...
... ... @@ -261,6 +261,8 @@ class TranslateLogic extends BaseLogic
foreach ($this->param['data'] as $k => $v){
if(!empty($v) && is_array($v)){
foreach ($v as $text => $translate){
$text = str_replace(['%22', '%', '+'], ['"', '%', '+'], $text);
$translate = str_replace(['%22', '%', '+'], ['"', '%', '+'], $translate);
$data[$text] = $translate;
}
}
... ...
... ... @@ -109,6 +109,7 @@ class InquiryFormData extends Base
*/
public static function getCount($submit_at = []){
return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
->where('gl_inquiry_form.is_default', 0)
->when($submit_at, function ($query, $submit_at) {
$query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
})
... ... @@ -122,6 +123,7 @@ class InquiryFormData extends Base
*/
public static function getCountryCount($submit_at = []){
return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
->where('gl_inquiry_form.is_default', 0)
->when($submit_at, function ($query, $submit_at) {
$query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
})
... ...