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