mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-08 19:01:09 +00:00
search 优化
This commit is contained in:
parent
3f3453b784
commit
f7387c7369
@ -8,7 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\dao\activity\advance;
|
||||
|
||||
@ -37,13 +37,17 @@ class StoreAdvanceDao extends BaseDao
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 吴汐
|
||||
* @email 442384644@qq.com
|
||||
* @date 2023/03/20
|
||||
*/
|
||||
public function getList(array $where, int $page = 0, int $limit = 0)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when($where['time_type'], function ($query) use ($where) {
|
||||
if ($where['time_type'] == 1) $query->whereTime('start_time', '>', time());
|
||||
if ($where['time_type'] == 2) $query->whereTime('start_time', '<=', time())->whereTime('stop_time', '>=', time());
|
||||
@ -57,10 +61,11 @@ class StoreAdvanceDao extends BaseDao
|
||||
/**
|
||||
* @param array $where
|
||||
* @return int
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getCount(array $where)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when($where['time_type'], function ($query) use ($where) {
|
||||
if ($where['time_type'] == 1) $query->whereTime('start_time', '>', time());
|
||||
if ($where['time_type'] == 2) $query->whereTime('start_time', '<=', time())->whereTime('stop_time', '>=', time());
|
||||
|
||||
@ -44,7 +44,7 @@ class StoreBargainDao extends BaseDao
|
||||
*/
|
||||
public function getList(array $where, int $page = 0, int $limit = 0)
|
||||
{
|
||||
return $this->search($where)->where('is_del', 0)
|
||||
return $this->search($where, false)->where('is_del', 0)
|
||||
->when(isset($where['start_status']) && $where['start_status'] !== '', function ($query) use ($where) {
|
||||
$time = time();
|
||||
switch ($where['start_status']) {
|
||||
@ -135,7 +135,7 @@ class StoreBargainDao extends BaseDao
|
||||
*/
|
||||
public function DiyBargainList(array $where, int $page, int $limit)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when(isset($where['sid']) && $where['sid'], function ($query) use ($where) {
|
||||
$query->whereIn('id', function ($query) use ($where) {
|
||||
$query->name('store_product_cate')->where('cate_id', $where['sid'])->field('product_id')->select();
|
||||
@ -165,7 +165,7 @@ class StoreBargainDao extends BaseDao
|
||||
*/
|
||||
public function getHomeList(array $where, int $page, int $limit)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when(isset($where['sid']) && $where['sid'], function ($query) use ($where) {
|
||||
$query->whereIn('id', function ($query) use ($where) {
|
||||
$query->name('store_product_cate')->where('cate_id', $where['sid'])->field('product_id')->select();
|
||||
@ -215,7 +215,7 @@ class StoreBargainDao extends BaseDao
|
||||
*/
|
||||
public function getCount(array $where)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when(isset($where['sid']) && $where['sid'], function ($query) use ($where) {
|
||||
$query->whereIn('product_id', function ($query) use ($where) {
|
||||
$query->name('store_product_cate')->where('cate_id', $where['sid'])->field('product_id')->select();
|
||||
|
||||
@ -66,6 +66,7 @@ class StoreCombinationDao extends BaseDao
|
||||
* 获取指定条件下的条数
|
||||
* @param array $where
|
||||
* @return int
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function count(array $where = []): int
|
||||
{
|
||||
@ -147,6 +148,7 @@ class StoreCombinationDao extends BaseDao
|
||||
* @param array $ids ids 为空返回所有
|
||||
* @param array $field
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getPinkIdsArray(array $ids = [], array $field = [])
|
||||
{
|
||||
@ -172,6 +174,7 @@ class StoreCombinationDao extends BaseDao
|
||||
* 条件获取数量
|
||||
* @param array $where
|
||||
* @return int
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getCount(array $where)
|
||||
{
|
||||
|
||||
@ -54,7 +54,7 @@ class StorePinkDao extends BaseDao
|
||||
*/
|
||||
public function getList(array $where, int $page = 0, int $limit = 0)
|
||||
{
|
||||
return $this->search($where)->when($where['k_id'] != 0, function ($query) use ($where) {
|
||||
return $this->search($where, false)->when($where['k_id'] != 0, function ($query) use ($where) {
|
||||
$query->whereOr('id', $where['k_id']);
|
||||
})->with('getProduct')->when($page != 0, function ($query) use ($page, $limit) {
|
||||
$query->page($page, $limit);
|
||||
|
||||
@ -308,13 +308,11 @@ class StoreCouponIssueDao extends BaseDao
|
||||
*/
|
||||
public function getTodayCoupon($uid)
|
||||
{
|
||||
// return $this->getModel()->where('receive_type', 1)->where('is_del', 0)->whereDay('add_time')->select()->toArray();
|
||||
return $this->getModel()->where('status', 1)
|
||||
->where('is_del', 0)
|
||||
->where('remain_count > 0 OR is_permanent = 1')
|
||||
->where(function ($query) {
|
||||
$query->where('receive_type', 1)->whereOr('receive_type', 4);
|
||||
// $query->where('receive_type', 1);
|
||||
})->where(function ($query) {
|
||||
$query->where(function ($query) {
|
||||
$query->where('start_time', '<', time())->where('end_time', '>', time());
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types = 1);
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\dao\activity\coupon;
|
||||
|
||||
@ -145,7 +145,7 @@ class StoreCouponUserDao extends BaseDao
|
||||
*/
|
||||
public function getCouponListByOrder(array $where, $order, int $page = 0, int $limit = 0)
|
||||
{
|
||||
return $this->search($where)->with('issue')->when($page > 0 && $limit > 0, function ($qeury) use ($page, $limit) {
|
||||
return $this->search($where, false)->with('issue')->when($page > 0 && $limit > 0, function ($qeury) use ($page, $limit) {
|
||||
$qeury->page($page, $limit);
|
||||
})->when($order != '', function ($query) use ($order) {
|
||||
$query->order($order);
|
||||
@ -172,7 +172,7 @@ class StoreCouponUserDao extends BaseDao
|
||||
*/
|
||||
public function memberCouponUserGroupBymonth(array $where)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->whereMonth('add_time')
|
||||
->whereIn('cid', $where['couponIds'])
|
||||
->field('count(id) as num,FROM_UNIXTIME(add_time, \'%Y-%m\') as time')
|
||||
|
||||
@ -31,9 +31,11 @@ class LiveGoodsDao extends BaseDao
|
||||
/**
|
||||
* @param array $where
|
||||
* @param string $field
|
||||
* @param array $with
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
* @throws \ReflectionException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
|
||||
@ -41,7 +41,7 @@ class DeliveryServiceDao extends BaseDao
|
||||
*/
|
||||
public function getServiceList(array $where, int $page, int $limit)
|
||||
{
|
||||
return $this->search($where)->when($page && $limit, function ($query) use ($page, $limit) {
|
||||
return $this->search($where, false)->when($page && $limit, function ($query) use ($page, $limit) {
|
||||
$query->page($page, $limit);
|
||||
})->when(isset($where['noId']), function ($query) use ($where) {
|
||||
$query->where('id', '<>', $where['noId']);
|
||||
|
||||
@ -39,7 +39,7 @@ class StoreProductDao extends BaseDao
|
||||
*/
|
||||
public function getCount(array $where)
|
||||
{
|
||||
return $this->search($where)->when(isset($where['sid']) && $where['sid'], function ($query) use ($where) {
|
||||
return $this->search($where, false)->when(isset($where['sid']) && $where['sid'], function ($query) use ($where) {
|
||||
$query->whereIn('id', function ($query) use ($where) {
|
||||
$query->name('store_product_cate')->where('cate_id', $where['sid'])->field('product_id')->select();
|
||||
});
|
||||
@ -112,7 +112,7 @@ class StoreProductDao extends BaseDao
|
||||
public function getSearchList(array $where, int $page = 0, int $limit = 0, array $field = ['*'], array $with = ['couponId', 'description'])
|
||||
{
|
||||
if (isset($where['star'])) $with[] = 'star';
|
||||
return $this->search($where)->with($with)->when($page != 0 && $limit != 0, function ($query) use ($page, $limit) {
|
||||
return $this->search($where, false)->with($with)->when($page != 0 && $limit != 0, function ($query) use ($page, $limit) {
|
||||
$query->page($page, $limit);
|
||||
})->when(isset($where['sid']) && $where['sid'], function ($query) use ($where) {
|
||||
$query->whereIn('id', function ($query) use ($where) {
|
||||
|
||||
@ -66,7 +66,7 @@ class CapitalFlowDao extends BaseDao
|
||||
$timeUnix = "%Y-%m";
|
||||
break;
|
||||
}
|
||||
$model = $this->search($where)
|
||||
$model = $this->search($where, false)
|
||||
->when(isset($where['type']) && $where['type'] !== '', function ($query) use ($where, $timeUnix) {
|
||||
$query->field("FROM_UNIXTIME(add_time,'$timeUnix') as day,sum(if(price >= 0,price,0)) as income_price,sum(if(price < 0,price,0)) as exp_price,add_time");
|
||||
$query->group("FROM_UNIXTIME(add_time, '$timeUnix')");
|
||||
|
||||
@ -81,7 +81,7 @@ class UserExtractDao extends BaseDao
|
||||
*/
|
||||
public function getWhereSumField(array $where, string $field)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when(isset($where['timeKey']), function ($query) use ($where) {
|
||||
$query->whereBetweenTime('add_time', $where['timeKey']['start_time'], $where['timeKey']['end_time']);
|
||||
})
|
||||
@ -96,7 +96,7 @@ class UserExtractDao extends BaseDao
|
||||
*/
|
||||
public function getGroupField(array $where, string $field, string $group)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when(isset($where['timeKey']), function ($query) use ($where, $field, $group) {
|
||||
$query->whereBetweenTime('add_time', $where['timeKey']['start_time'], $where['timeKey']['end_time']);
|
||||
$timeUinx = "%H";
|
||||
|
||||
@ -57,7 +57,7 @@ class UserRechargeDao extends BaseDao
|
||||
*/
|
||||
public function getWhereSumField(array $where, string $field)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when(isset($where['timeKey']), function ($query) use ($where) {
|
||||
$query->whereBetweenTime('pay_time', $where['timeKey']['start_time'], $where['timeKey']['end_time']);
|
||||
})
|
||||
@ -72,7 +72,7 @@ class UserRechargeDao extends BaseDao
|
||||
*/
|
||||
public function getGroupField(array $where, string $field, string $group)
|
||||
{
|
||||
return $this->search($where)
|
||||
return $this->search($where, false)
|
||||
->when(isset($where['timeKey']), function ($query) use ($where, $field, $group) {
|
||||
$query->whereBetweenTime('pay_time', $where['timeKey']['start_time'], $where['timeKey']['end_time']);
|
||||
$timeUinx = "%H";
|
||||
|
||||
@ -57,7 +57,7 @@ class StoreProductRelationServices extends BaseServices
|
||||
*/
|
||||
public function getUserCollectCount(int $uid)
|
||||
{
|
||||
return $this->dao->count(['uid' => $uid, 'tye' => 'collect']);
|
||||
return $this->dao->count(['uid' => $uid, 'type' => 'collect']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user