diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index 8bfa340e..7195fd67 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -29,6 +29,8 @@ use app\common\repositories\system\merchant\MerchantRepository as repository; use think\facade\Db; use think\facade\Queue; use app\common\model\system\merchant\Merchant as MerchantModel; +use crmeb\services\QrcodeService; +use app\common\repositories\system\attachment\AttachmentRepository; class Merchant extends BaseController { @@ -124,7 +126,27 @@ class Merchant extends BaseController { if(!$this->repository->merExists($id)) return app('json')->fail('店铺已打烊'); - $url = $this->request->param('type') == 'routine' ? $this->repository->routineQrcode(intval($id)) : $this->repository->wxQrcode(intval($id)); + if ($this->request->param('type') == 'routine') { + $url= $this->repository->routineQrcode(intval($id)); + }elseif($this->request->param('type') == 'app'){ + $attachmentRepository = app()->make(AttachmentRepository::class); + $name='merchant_code_'.$id.'.png'; + $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]); + if($imageInfo){ + $url=$imageInfo['attachment_src']; + }else{ + $info = app()->make(QrcodeService::class)->getQRCodePath(systemConfig('site_url').'pages/store/home/index&id=' . $id, $name); + $attachmentRepository->create(systemConfig('upload_type') ?: 1, -2, $id, [ + 'attachment_category_id' => 0, + 'attachment_name' => $info['name'], + 'attachment_src' => $info['dir'] + ]); + $url=$info['dir']; + } + } + else{ + $url= $this->repository->wxQrcode(intval($id)); + } return app('json')->success(compact('url')); } diff --git a/crmeb/services/QrcodeService.php b/crmeb/services/QrcodeService.php index cd850cc1..f07ffab7 100644 --- a/crmeb/services/QrcodeService.php +++ b/crmeb/services/QrcodeService.php @@ -159,7 +159,6 @@ class QrcodeService */ public function getRoutineQrcodePath($namePath, $page, $data) { - try { $imageInfo = app()->make(AttachmentRepository::class)->getWhere(['attachment_name' => $namePath]); if (!$imageInfo) { @@ -182,7 +181,9 @@ class QrcodeService 'attachment_src' => $imageInfo['dir'] ]); $url = $imageInfo['dir']; - } else $url = $imageInfo['attachment_src']; + }else{ + $url = $imageInfo['attachment_src']; + } return $url; } catch (\Throwable $e) { return false;