作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

... ... @@ -456,11 +456,11 @@ if (!function_exists('getImageUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getImageUrl($path,$location = 1){
function getImageUrl($path,$location = 1,$storage_type = 0){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = getImageUrl($v);
$url[] = getImageUrl($v,$location,$storage_type);
}
}else{
if(empty($path)){
... ... @@ -473,7 +473,7 @@ if (!function_exists('getImageUrl')) {
return 'https:'.$path;
}
if($location == 1){
$cos = config('filesystems.disks.cos');
$cos = ($storage_type == 0) ? config('filesystems.disks.cos') : config('filesystems.disks.cos1');
$cosCdn = $cos['cdn'];
$url = $cosCdn.$path;
}else{
... ... @@ -483,6 +483,7 @@ if (!function_exists('getImageUrl')) {
return $url;
}
}
if (!function_exists('getFileUrl')) {
/**
* @remark :获取文件链接
... ... @@ -491,11 +492,11 @@ if (!function_exists('getFileUrl')) {
* @method :post
* @time :2023/7/20 16:46
*/
function getFileUrl($path,$location = 1){
function getFileUrl($path,$location = 1,$storage_type = 0){
if(is_array($path)){
$url =[];
foreach ($path as $v){
$url[] = getFileUrl($v);
$url[] = getFileUrl($v,$location,$storage_type);
}
}else{
if(empty($path)){
... ... @@ -508,7 +509,7 @@ if (!function_exists('getFileUrl')) {
return 'https:'.$path;
}
if($location == 1){
$cos = config('filesystems.disks.cos');
$cos = ($storage_type == 0) ? config('filesystems.disks.cos') : config('filesystems.disks.cos1');
$cosCdn = $cos['cdn'];
$url = $cosCdn.$path;
}else{
... ...
... ... @@ -38,7 +38,7 @@ class BlogController extends BaseController
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
... ... @@ -186,10 +186,8 @@ class BlogController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $blogLogic->blogInfo();
$template_id = $this->getTemplateId(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL);
$info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id, $info['id']);
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -41,7 +41,7 @@ class NewsController extends BaseController
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
... ... @@ -175,10 +175,8 @@ class NewsController extends BaseController
'id.required' => 'ID不能为空',
]);
$info = $newsLogic->newsInfo();
$template_id = $this->getTemplateId(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL);//获取模版id
$info['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id, $info['id']);
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -41,7 +41,7 @@ class CategoryController extends BaseController
foreach ($list as $k =>$v){
$v['url'] = $this->user['domain'] . $v['route'].'/';
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$list[$k] = $v;
}
... ...
... ... @@ -56,11 +56,12 @@ class ProductController extends BaseController
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
$userModel = new User();
foreach ($lists['list'] as $k=>$v){
$v['url'] = $this->user['domain'].$v['route'].'/';
$v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
$v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
$v['created_uid_text'] = $userModel->getName($v['created_uid']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']);
$v['url'] = $this->user['domain'].$v['route'].'/';
$v = $this->getHandleFileImage($v);
$lists['list'][$k] = $v;
}
}
... ... @@ -68,7 +69,40 @@ class ProductController extends BaseController
}
/**
* @remark :处理列表返回参数
* @remark :获取时处理图片和文件
* @name :getHandleFileImage
* @author :lyh
* @method :post
* @time :2024/1/23 17:43
*/
public function getHandleFileImage($v){
//ToDo::处理图片及文件
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['project_location'],$this->user['storage_type']);
}
if(!empty($v['gallery'])){
foreach ($v['gallery'] as $gallery_k => $gallery_v){
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['project_location'],$this->user['storage_type']);
$v['gallery'][$gallery_k] = $gallery_v;
}
}
if(!empty($v['icon'])){
foreach ($v['icon'] as $icon_k => $icon_v){
$icon_v = getImageUrl($icon_v,$this->user['project_location'],$this->user['storage_type']);
$v['icon'][$icon_k] = $icon_v;
}
}
if(!empty($v['video']) && !empty($v['video']['url'])){
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['project_location'],$this->user['storage_type']);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['project_location'],$this->user['storage_type']);
}
return $this->success($v);
}
/**
* @remark :搜索参数处理
* @name :handleReturnParam
* @author :lyh
* @method :post
... ... @@ -243,6 +277,8 @@ class ProductController extends BaseController
}else{
$v['status_text'] = '';
}
//ToDo::处理图片及文件
$v = $this->getHandleFileImage($v);
$template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0);
$v['url'] = $this->user['domain'].$v['route'];
... ... @@ -251,6 +287,7 @@ class ProductController extends BaseController
return $v;
}
/**
* @remark :获取扩展字段详情
* @name :getExtendInfo
... ... @@ -293,7 +330,7 @@ class ProductController extends BaseController
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = (array)$v1;
$v1['url'] = getImageUrl($v1['url']);
$v1['url'] = getImageUrl($v1['url'],$this->user['project_location'],$this->user['storage_type']);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
... ... @@ -302,9 +339,9 @@ class ProductController extends BaseController
foreach ($arr1 as $k1=>$v1){
$v1 = (array)$v1;
if(isset($v1['url'])){
$v1['url'] = getFileUrl($v1['url']);
$v1['url'] = getFileUrl($v1['url'],$this->user['project_location'],$this->user['storage_type']);
}else{
$v1 = getFileUrl($v1);
$v1 = getFileUrl($v1,$this->user['project_location'],$this->user['storage_type']);
}
$arr1[$k1] = $v1;
}
... ...
... ... @@ -22,7 +22,7 @@ class BTemplateController extends BaseController
$lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => &$v){
$v['image_link'] = getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image'],$this->user['project_location'],$this->user['storage_type']);
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -335,7 +335,7 @@ class FileController
$fileModel = new File();
$lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']);
foreach ($lists as $k => $v){
$v['file_link'] = getFileUrl($v['path']);
$v['file_link'] = getFileUrl($v['path'],$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0);
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -351,7 +351,7 @@ class FileController
public function responseData($path, $name){
$data = [
'file'=>$path,
'file_link'=>getFileUrl($path,$this->upload_location),
'file_link'=>getFileUrl($path,$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0),
'name'=>$name,
'file_download'=>url('a/download_files?path='.$path)
];
... ...
... ... @@ -359,7 +359,7 @@ class ImageController extends Controller
$lists = $imageModel->lists($this->map,$this->page,$this->row);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image_link'] = getImageUrl($v['path']);
$v['image_link'] = getImageUrl($v['path'],$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0);
$lists['list'][$k] = $v;
}
}
... ... @@ -425,7 +425,7 @@ class ImageController extends Controller
public function responseData($path = '', $name = ''){
$data = [
'image'=>$path,
'image_link'=>getImageUrl($path),
'image_link'=>getImageUrl($path,$this->cache['project_location'] ?? 1,$this->cache['storage_type'] ?? 0),
'name'=>$name,
'image_download'=>url('a/download_images?path='.$path)
];
... ...
... ... @@ -101,7 +101,7 @@ class BlogLogic extends BaseLogic
//获取标签名称
$blogLabelLogic = new BlogLabelLogic();
$info['label_name'] = $blogLabelLogic->getLabelName($info['label_id']);
$info['image_link'] = getImageUrl($info['image']);
$info['image_link'] = getImageUrl($info['image'],$this->user['project_location'],$this->user['storage_type']);
return $this->success($info);
}
... ...
... ... @@ -147,7 +147,7 @@ class NewsLogic extends BaseLogic
$this->fail('error');
}
$info['category_id'] = explode(',',trim($info['category_id'],','));
$info['image_link'] = getImageUrl($info['image']);
$info['image_link'] = getImageUrl($info['image'],$this->user['project_location'],$this->user['storage_type']);
return $this->success($info);
}
... ...
... ... @@ -102,51 +102,9 @@ class Product extends Base
3=>'热销产品'
];
/**
* 产品列表
* @param $map
* @param $page
* @param $row
* @param string $order
* @param string[] $fields
* @param string $sort
* @return array
* @author zbj
* @date 2023/10/17
*/
public function product_lists($map, $page, $row, $order = 'id', $fields = ['*'], $sort = 'desc'): array
{
$category_id = $map['category_id'] ?? 0;
$query = $this->where(function ($query) use ($category_id) {
if ($category_id) {
$category_ids = Category::getChildIdsArr($category_id);
$query->whereIn('id', function ($subQuery) use ($category_ids) {
$subQuery->select('product_id')
->from('gl_product_category_related')
->whereIn('cate_id', $category_ids)
->groupBy('product_id');
});
}
});
unset($map['category_id']);
$query = $this->formatQuery($map, $query);
$query = $this->sortOrder($query,$order,$sort);
$lists = $query->select($fields)->paginate($row, ['*'], 'page', $page);
if (empty($lists)) {
return [];
}
$lists = $lists->toArray();
return $lists;
}
public function getThumbAttribute($value){
if(!empty($value)){
$value = json_decode($value,true);
if(!empty($value['url'])){
$value['url'] = getImageUrl($value['url']);
}
$value = Arr::s2a($value);
}
return $value;
}
... ... @@ -155,12 +113,6 @@ class Product extends Base
public function getGalleryAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
if(!empty($v['url'])){
$v['url'] = getImageUrl($v['url']);
}
$value[$k] = $v;
}
}
return $value;
}
... ... @@ -175,9 +127,6 @@ class Product extends Base
public function getFilesAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
if(!empty($value['url'])){
$value['url'] = getImageUrl($value['url']);
}
}
return $value;
}
... ... @@ -192,10 +141,6 @@ class Product extends Base
public function getVideoAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
$value = Arr::s2a($value);
if(!empty($value['url'])){
$value['url'] = getImageUrl($value['url']);
}
}
return $value;
}
... ... @@ -210,10 +155,6 @@ class Product extends Base
public function getIconAttribute($value){
if(!empty($value)){
$value = Arr::s2a($value);
foreach ($value as $k => $v){
$v = getImageUrl($v);
$value[$k] = $v;
}
}
return $value;
}
... ...