From 0a7b59e9747d00b16c2fe8804da4f6e1e77cfcf3 Mon Sep 17 00:00:00 2001 From: weigang Date: Thu, 27 Aug 2020 11:08:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=AE=9A=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/AttachmentService.php | 13 +++++++++++++ app/Service/OrderService.php | 21 +++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/Service/AttachmentService.php b/app/Service/AttachmentService.php index 65ab9a4..a788e6c 100644 --- a/app/Service/AttachmentService.php +++ b/app/Service/AttachmentService.php @@ -70,4 +70,17 @@ class AttachmentService implements AttachmentServiceInterface $path .= '/'.date('Y').'/'.date('m').'/'.date('d'); return $baseDir.$path; } + + public function switchImgToAliOss($path, $bucket = 'thumbnail_q50') + { + if (strpos($path, 'http') === false || strpos($path, 'https') === false) { + $path = 'https://img.lanzulive.com/' . $path; + } else { + $temp = explode('//', $path); + $temp = explode('/', $temp[1]); + unset($temp[0]); + $path = 'https://img.lanzulive.com/' . implode('/', $temp); + } + return $path . '!' . $bucket; + } } \ No newline at end of file diff --git a/app/Service/OrderService.php b/app/Service/OrderService.php index bd6f500..daed1af 100644 --- a/app/Service/OrderService.php +++ b/app/Service/OrderService.php @@ -64,6 +64,12 @@ class OrderService implements OrderServiceInterface */ protected $financialService; + /** + * @Inject + * @var AttachmentServiceInterface + */ + protected $attachmentService; + /** * @inheritDoc */ @@ -972,22 +978,9 @@ class OrderService implements OrderServiceInterface $goods = OrderGoods::query()->whereIn('order_id', $orderChildIds)->select(['name', 'img'])->first(); $order['good_name'] = $goods->name; // TODO 临时写死oss压缩类型 - $order['img'] = $this->switchImgToAliOss($goods->img); + $order['img'] = $this->attachmentService->switchImgToAliOss($goods->img); } return $orders; } - - public function switchImgToAliOss($path, $bucket = 'thumbnail_q50') - { - if (strpos($path, 'http') === false || strpos($path, 'https') === false) { - $path = 'https://img.lanzulive.com/' . $path; - } else { - $temp = explode('//', $path); - $temp = explode('/', $temp[1]); - unset($temp[0]); - $path = 'https://img.lanzulive.com/' . implode('/', $temp); - } - return $path . '!' . $bucket; - } } \ No newline at end of file