diff --git a/app/common/dao/store/order/StoreOrderDao.php b/app/common/dao/store/order/StoreOrderDao.php index fabe6266..f142d227 100644 --- a/app/common/dao/store/order/StoreOrderDao.php +++ b/app/common/dao/store/order/StoreOrderDao.php @@ -212,6 +212,14 @@ class StoreOrderDao extends BaseDao $query->whereLike('StoreOrder.real_name|StoreOrder.user_phone|order_sn', "%" . $where['keywords'] . "%"); }); }) + ->when(isset($where['order_search']) && $where['order_search'] !== '', function ($query) use ($where) { + // 对 order_sn 进行模糊搜索 + $query->where(function ($q) use ($where) { + $q->whereLike('StoreOrder.order_sn', '%' . $where['order_search'] . '%') + ->whereOr('StoreOrder.user_phone', 'like', '%' . $where['order_search'] . '%'); + }); + + }) ->when(isset($where['filter_delivery']) && $where['filter_delivery'] !== '', function ($query) use ($where) { //1 快递 2 配送 3 虚拟 //按发货方式:1快递订单、2配送订单、4核销订单、3虚拟发货、6自动发货 @@ -252,6 +260,8 @@ class StoreOrderDao extends BaseDao }) ->order('StoreOrder.create_time DESC'); + + return $query; } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index 5f4a3971..ceeaafb4 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -15,6 +15,7 @@ namespace app\controller\api\store\merchant; use app\common\model\system\merchant\MerchantType; use app\common\repositories\store\MerchantTakeRepository; use app\common\repositories\store\product\ProductRepository; +use app\common\repositories\system\attachment\AttachmentRepository; use app\common\repositories\system\config\ConfigValueRepository; use app\common\repositories\system\financial\FinancialRepository; use app\common\repositories\system\merchant\MerchantRepository; @@ -24,6 +25,7 @@ use app\validate\merchant\MerchantFinancialAccountValidate; use app\validate\merchant\MerchantTakeValidate; use app\validate\merchant\MerchantUpdateValidate; use crmeb\jobs\ChangeMerchantStatusJob; +use crmeb\services\QrcodeService; use think\App; use crmeb\basic\BaseController; use app\common\repositories\system\merchant\MerchantRepository as repository; @@ -128,9 +130,28 @@ class Merchant extends BaseController public function qrcode($id) { - if(!$this->repository->merExists((int)$id)) + 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')); }