From aeca0e3936e8ce7ea9d1767c6c9ecdc8b3b85b33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=98=8A=E5=A4=A9?= <442384644@qq.com> Date: Mon, 20 Mar 2023 11:36:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0search?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/dao/BaseDao.php | 11 ++++++++--- .../dao/activity/combination/StoreCombinationDao.php | 9 +++++++-- crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php | 2 +- .../dao/activity/integral/StoreIntegralOrderDao.php | 2 +- crmeb/app/dao/activity/lottery/LuckLotteryDao.php | 2 +- crmeb/app/dao/activity/seckill/StoreSeckillDao.php | 2 +- crmeb/app/dao/article/ArticleDao.php | 2 +- crmeb/app/dao/order/OtherOrderDao.php | 2 +- crmeb/app/dao/order/StoreCartDao.php | 2 +- crmeb/app/dao/order/StoreOrderDao.php | 3 ++- crmeb/app/dao/order/StoreOrderInvoiceDao.php | 2 +- crmeb/app/dao/order/StoreOrderRefundDao.php | 2 +- crmeb/app/dao/service/StoreServiceAuxiliaryDao.php | 2 +- .../system/attachment/SystemAttachmentCategoryDao.php | 2 +- crmeb/app/dao/system/config/SystemStorageDao.php | 2 +- crmeb/app/dao/user/UserBrokerageFrozenDao.php | 2 +- crmeb/app/dao/wechat/WechatKeyDao.php | 2 +- 17 files changed, 31 insertions(+), 20 deletions(-) diff --git a/crmeb/app/dao/BaseDao.php b/crmeb/app/dao/BaseDao.php index 7061af2b0..89e7a01cf 100644 --- a/crmeb/app/dao/BaseDao.php +++ b/crmeb/app/dao/BaseDao.php @@ -318,31 +318,36 @@ abstract class BaseDao /** * 根据搜索器获取搜索内容 * @param $where + * @param $search * @return BaseModel * @throws \ReflectionException * @author 吴汐 * @email 442384644@qq.com * @date 2023/03/18 */ - protected function withSearchSelect($where) + protected function withSearchSelect($where, $search) { [$with, $otherWhere] = $this->getSearchData($where); + if (!$search) { + $otherWhere = []; + } return $this->getModel()->withSearch($with, $where)->where($otherWhere); } /** * 搜索 * @param array $where + * @param bool $search * @return BaseModel * @throws \ReflectionException * @author 吴汐 * @email 442384644@qq.com * @date 2023/03/18 */ - protected function search(array $where = []) + protected function search(array $where = [], $search = true) { if ($where) { - return $this->withSearchSelect($where); + return $this->withSearchSelect($where, $search); } else { return $this->getModel(); } diff --git a/crmeb/app/dao/activity/combination/StoreCombinationDao.php b/crmeb/app/dao/activity/combination/StoreCombinationDao.php index b5de5a3b1..6f514f735 100644 --- a/crmeb/app/dao/activity/combination/StoreCombinationDao.php +++ b/crmeb/app/dao/activity/combination/StoreCombinationDao.php @@ -39,7 +39,7 @@ class StoreCombinationDao extends BaseDao */ public function search(array $where = []) { - return parent::search($where)->when(isset($where['pinkIngTime']), function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['pinkIngTime']), function ($query) use ($where) { $time = time(); [$startTime, $stopTime] = is_array($where['pinkIngTime']) ? $where['pinkIngTime'] : [$time, $time]; $query->where('start_time', '<=', $startTime)->where('stop_time', '>=', $stopTime); @@ -100,6 +100,7 @@ class StoreCombinationDao extends BaseDao $query->page($page, $limit); })->order('sort desc,id desc')->select()->toArray(); } + /**获取列表 * @param array $where * @param int $page @@ -164,6 +165,7 @@ class StoreCombinationDao extends BaseDao { return $this->search($where)->with('getPrice')->page($page, $limit)->order('sort desc,id desc')->select()->toArray(); } + /** * 条件获取数量 * @param array $where @@ -173,6 +175,7 @@ class StoreCombinationDao extends BaseDao { return $this->search($where)->count(); } + /** * 页面设计获取商拼团列表 * @param array $where @@ -183,9 +186,11 @@ class StoreCombinationDao extends BaseDao * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function diyCombinationList(array $where, int $page, int $limit){ + public function diyCombinationList(array $where, int $page, int $limit) + { return $this->search($where)->with('getCategory')->page($page, $limit)->order('sort desc,id desc')->select()->toArray(); } + /** * 根据id获取拼团数据 * @param array $ids diff --git a/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php b/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php index 911ddf959..e117f5a92 100644 --- a/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php +++ b/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php @@ -38,7 +38,7 @@ class StoreCouponIssueDao extends BaseDao */ public function search(array $where = []) { - return parent::search($where)->when(isset($where['type']) && $where['type'] != '', function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['type']) && $where['type'] != '', function ($query) use ($where) { if ($where['type'] == 'send') { $query->where('receive_type', 3)->where(function ($query1) { $query1->where(function ($query2) { diff --git a/crmeb/app/dao/activity/integral/StoreIntegralOrderDao.php b/crmeb/app/dao/activity/integral/StoreIntegralOrderDao.php index 4f40242c4..ba63ad6ec 100644 --- a/crmeb/app/dao/activity/integral/StoreIntegralOrderDao.php +++ b/crmeb/app/dao/activity/integral/StoreIntegralOrderDao.php @@ -48,7 +48,7 @@ class StoreIntegralOrderDao extends BaseDao $realName = $where['real_name'] ?? ''; $fieldKey = $where['field_key'] ?? ''; $fieldKey = $fieldKey == 'all' ? '' : $fieldKey; - return parent::search($where)->when($isDel, function ($query) use ($where) { + return parent::search($where, false)->when($isDel, function ($query) use ($where) { $query->where('is_del', $where['is_del']); })->when(isset($where['is_system_del']), function ($query) { $query->where('is_system_del', 0); diff --git a/crmeb/app/dao/activity/lottery/LuckLotteryDao.php b/crmeb/app/dao/activity/lottery/LuckLotteryDao.php index a523f0729..aa4b8b09f 100644 --- a/crmeb/app/dao/activity/lottery/LuckLotteryDao.php +++ b/crmeb/app/dao/activity/lottery/LuckLotteryDao.php @@ -34,7 +34,7 @@ class LuckLotteryDao extends BaseDao public function search(array $data = []) { - return parent::search($data)->when(isset($data['id']) && $data['id'], function ($query) use ($data) { + return parent::search($data, false)->when(isset($data['id']) && $data['id'], function ($query) use ($data) { $query->where('id', $data['id']); })->when(isset($data['start']) && $data['start'] !== '', function ($query) use ($data) { $time = time(); diff --git a/crmeb/app/dao/activity/seckill/StoreSeckillDao.php b/crmeb/app/dao/activity/seckill/StoreSeckillDao.php index 5dd67812c..52176a73c 100644 --- a/crmeb/app/dao/activity/seckill/StoreSeckillDao.php +++ b/crmeb/app/dao/activity/seckill/StoreSeckillDao.php @@ -39,7 +39,7 @@ class StoreSeckillDao extends BaseDao */ protected function search(array $where = []) { - return parent::search($where)->when(isset($where['seckllTime']), function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['seckllTime']), function ($query) use ($where) { [$startTime, $stopTime] = is_array($where['seckllTime']) ? $where['seckllTime'] : [time(), time() - 86400]; $query->where('start_time', '<=', $startTime)->where('stop_time', '>=', $stopTime); })->when(isset($where['sid']) && $where['sid'], function ($query) use ($where) { diff --git a/crmeb/app/dao/article/ArticleDao.php b/crmeb/app/dao/article/ArticleDao.php index 94d8e917f..7cc3115e6 100644 --- a/crmeb/app/dao/article/ArticleDao.php +++ b/crmeb/app/dao/article/ArticleDao.php @@ -32,7 +32,7 @@ class ArticleDao extends BaseDao public function search(array $where = []) { - return parent::search($where)->when(isset($where['ids']) && count($where['ids']), function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['ids']) && count($where['ids']), function ($query) use ($where) { $query->whereNotIn('id', $where['ids']); }); } diff --git a/crmeb/app/dao/order/OtherOrderDao.php b/crmeb/app/dao/order/OtherOrderDao.php index 60d76d6bd..8bf89a952 100644 --- a/crmeb/app/dao/order/OtherOrderDao.php +++ b/crmeb/app/dao/order/OtherOrderDao.php @@ -163,7 +163,7 @@ class OtherOrderDao extends BaseDao public function search(array $where = []) { - return parent::search($where)->when(isset($where['name']) && $where['name'], function ($query) use($where){ + return parent::search($where, false)->when(isset($where['name']) && $where['name'], function ($query) use($where){ $query->where('uid', 'in', function ($que) use($where){ $nickname = trim($where['name']); $que->name('user')->where('nickname', 'like', $nickname.'%')->field(['uid'])->select(); diff --git a/crmeb/app/dao/order/StoreCartDao.php b/crmeb/app/dao/order/StoreCartDao.php index 9529a1643..95bd2d5dc 100644 --- a/crmeb/app/dao/order/StoreCartDao.php +++ b/crmeb/app/dao/order/StoreCartDao.php @@ -49,7 +49,7 @@ class StoreCartDao extends BaseDao */ public function search(array $where = []) { - return parent::search($where)->when(isset($where['id']) && $where['id'], function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['id']) && $where['id'], function ($query) use ($where) { $query->whereIn('id', $where['id']); })->when(isset($where['status']), function ($query) use ($where) { //兼容之前老用户 数据库默认值null diff --git a/crmeb/app/dao/order/StoreOrderDao.php b/crmeb/app/dao/order/StoreOrderDao.php index d99febb71..d5d093789 100644 --- a/crmeb/app/dao/order/StoreOrderDao.php +++ b/crmeb/app/dao/order/StoreOrderDao.php @@ -41,6 +41,7 @@ class StoreOrderDao extends BaseDao * 订单搜索 * @param array $where * @return \crmeb\basic\BaseModel|mixed|\think\Model + * @throws \ReflectionException */ public function search(array $where = []) { @@ -48,7 +49,7 @@ class StoreOrderDao extends BaseDao $realName = $where['real_name'] ?? ''; $fieldKey = $where['field_key'] ?? ''; $fieldKey = $fieldKey == 'all' ? '' : $fieldKey; - return parent::search($where)->when($isDel, function ($query) use ($where) { + return parent::search($where, false)->when($isDel, function ($query) use ($where) { $query->where('is_del', $where['is_del']); })->when(isset($where['is_system_del']), function ($query) { $query->where('is_system_del', 0); diff --git a/crmeb/app/dao/order/StoreOrderInvoiceDao.php b/crmeb/app/dao/order/StoreOrderInvoiceDao.php index 75e8080ad..41b48a245 100644 --- a/crmeb/app/dao/order/StoreOrderInvoiceDao.php +++ b/crmeb/app/dao/order/StoreOrderInvoiceDao.php @@ -40,7 +40,7 @@ class StoreOrderInvoiceDao extends BaseDao $fieldKey = $fieldKey == 'all' ? '' : $fieldKey; $type = $where['type'] ?? ''; unset($where['type']); - return parent::search($where)->when($type, function ($query) use ($type) { + return parent::search($where, false)->when($type, function ($query) use ($type) { switch ($type) { case 1://待开 $query->where('is_invoice', 0)->where('invoice_time', 0)->where('is_refund', 0); diff --git a/crmeb/app/dao/order/StoreOrderRefundDao.php b/crmeb/app/dao/order/StoreOrderRefundDao.php index f043e0a94..215acf46c 100644 --- a/crmeb/app/dao/order/StoreOrderRefundDao.php +++ b/crmeb/app/dao/order/StoreOrderRefundDao.php @@ -26,7 +26,7 @@ class StoreOrderRefundDao extends BaseDao $realName = $where['real_name'] ?? ''; $fieldKey = $where['field_key'] ?? ''; $fieldKey = $fieldKey == 'all' ? '' : $fieldKey; - return parent::search($where)->when(isset($where['refund_type']) && $where['refund_type'] !== '', function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['refund_type']) && $where['refund_type'] !== '', function ($query) use ($where) { if ($where['refund_type'] == 0) { $query->where('refund_type', '>', 0); } else { diff --git a/crmeb/app/dao/service/StoreServiceAuxiliaryDao.php b/crmeb/app/dao/service/StoreServiceAuxiliaryDao.php index b0142bff3..15eab0457 100644 --- a/crmeb/app/dao/service/StoreServiceAuxiliaryDao.php +++ b/crmeb/app/dao/service/StoreServiceAuxiliaryDao.php @@ -29,7 +29,7 @@ class StoreServiceAuxiliaryDao extends AuxiliaryDao */ protected function search(array $where = []) { - return parent::search($where)->where('type', 0); + return parent::search($where, false)->where('type', 0); } } diff --git a/crmeb/app/dao/system/attachment/SystemAttachmentCategoryDao.php b/crmeb/app/dao/system/attachment/SystemAttachmentCategoryDao.php index 7afbffe02..c3d2a78e8 100644 --- a/crmeb/app/dao/system/attachment/SystemAttachmentCategoryDao.php +++ b/crmeb/app/dao/system/attachment/SystemAttachmentCategoryDao.php @@ -62,7 +62,7 @@ class SystemAttachmentCategoryDao extends BaseDao */ public function search(array $where = []) { - return parent::search($where)->when(isset($where['id']), function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['id']), function ($query) use ($where) { $query->whereIn('id', $where['id']); }); } diff --git a/crmeb/app/dao/system/config/SystemStorageDao.php b/crmeb/app/dao/system/config/SystemStorageDao.php index 0329e566b..a5e685b22 100644 --- a/crmeb/app/dao/system/config/SystemStorageDao.php +++ b/crmeb/app/dao/system/config/SystemStorageDao.php @@ -68,7 +68,7 @@ class SystemStorageDao extends BaseDao */ public function search(array $where = []) { - return parent::search($where)->when(isset($where['type']), function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['type']), function ($query) use ($where) { $query->where('type', $where['type']); })->where('is_delete', 0)->when(isset($where['access_key']), function ($query) use ($where) { $query->where('access_key', $where['access_key']); diff --git a/crmeb/app/dao/user/UserBrokerageFrozenDao.php b/crmeb/app/dao/user/UserBrokerageFrozenDao.php index 4ca41e05b..2135521bd 100644 --- a/crmeb/app/dao/user/UserBrokerageFrozenDao.php +++ b/crmeb/app/dao/user/UserBrokerageFrozenDao.php @@ -38,7 +38,7 @@ class UserBrokerageFrozenDao extends BaseDao */ public function search(array $where = []) { - return parent::search($where)->when(isset($where['isFrozen']), function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['isFrozen']), function ($query) use ($where) { if ($where['isFrozen']) { $query->where('frozen_time', '>', time()); } else { diff --git a/crmeb/app/dao/wechat/WechatKeyDao.php b/crmeb/app/dao/wechat/WechatKeyDao.php index 33fe3e8e3..4a8197b86 100644 --- a/crmeb/app/dao/wechat/WechatKeyDao.php +++ b/crmeb/app/dao/wechat/WechatKeyDao.php @@ -35,7 +35,7 @@ class WechatKeyDao extends BaseDao */ public function search(array $where = []) { - return parent::search($where)->when(isset($where['id']), function ($query) use ($where) { + return parent::search($where, false)->when(isset($where['id']), function ($query) use ($where) { $query->where('id', $where['id']); }); }