diff --git a/crmeb/app/common.php b/crmeb/app/common.php index 8d8575b0d..fb9968911 100644 --- a/crmeb/app/common.php +++ b/crmeb/app/common.php @@ -23,6 +23,7 @@ use app\services\system\lang\LangCodeServices; use app\services\system\lang\LangCountryServices; use think\facade\Config; use think\facade\Log; +use think\facade\Db; if (!function_exists('crmebLog')) { /** @@ -1090,3 +1091,19 @@ if (!function_exists('out_push')) { return true; } } + +if (!function_exists('dump_sql')) { + /** + * 默认数据推送 + * @param string $pushUrl + * @param array $data + * @param string $tip + * @return bool + */ + function dump_sql() + { + Db::listen(function ($sql) { + var_dump($sql); + }); + } +} diff --git a/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php b/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php index dd06cd2e0..6dac47ece 100644 --- a/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php +++ b/crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php @@ -72,6 +72,17 @@ class StoreCouponIssueDao extends BaseDao ->page($page, $limit)->order('id desc')->select()->toArray(); } + /** + * 优惠券数量 + * @param $where + * @return int + * @throws \ReflectionException + */ + public function couponCount($where): int + { + return $this->search($where)->count(); + } + /** * 获取优惠券列表 * @param int $uid 用户ID diff --git a/crmeb/app/dao/activity/seckill/StoreSeckillDao.php b/crmeb/app/dao/activity/seckill/StoreSeckillDao.php index 7034905d1..efcb6cbbe 100644 --- a/crmeb/app/dao/activity/seckill/StoreSeckillDao.php +++ b/crmeb/app/dao/activity/seckill/StoreSeckillDao.php @@ -41,7 +41,7 @@ class StoreSeckillDao extends BaseDao */ public function search(array $where = [], bool $search = false) { - return parent::search($where, $search)->when(isset($where['seckllTime']), function ($query) use ($where) { + return parent::search($where)->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) { @@ -67,6 +67,7 @@ class StoreSeckillDao extends BaseDao * 条件获取数量 * @param array $where * @return int + * @throws \ReflectionException */ public function getCount(array $where) { diff --git a/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php b/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php index bb667dabc..6c88aff60 100644 --- a/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php +++ b/crmeb/app/services/activity/coupon/StoreCouponIssueServices.php @@ -65,8 +65,7 @@ class StoreCouponIssueServices extends BaseServices foreach ($list as &$item) { $item['use_time'] = date('Y-m-d', $item['start_use_time']) . ' ~ ' . date('Y-m-d', $item['end_use_time']); } -// unset($where['type'], $where['receive_type']); - $count = $this->dao->count($where); + $count = $this->dao->couponCount($where); return compact('list', 'count'); } diff --git a/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php b/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php index a5910585b..f888d2c48 100644 --- a/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php +++ b/crmeb/crmeb/services/easywechat/orderShipping/OrderClient.php @@ -4,36 +4,19 @@ namespace crmeb\services\easywechat\orderShipping; use crmeb\exceptions\AdminException; use crmeb\services\CacheService; -use EasyWeChat\Core\AccessToken; use EasyWeChat\Core\Exceptions\HttpException; -use think\facade\Cache; class OrderClient extends BaseOrder { - const redis_prefix = 'mini_order'; + const cache_prefix = 'mini_order'; const express_company = 'ZTO'; // 默认发货快递公司为(中通快递) - /** - * @var \Redis + * @var */ - protected $redis; - - /** - * @return object|\Redis|null - * - * @date 2023/05/10 - * @author yyw - */ - protected function getRedis() - { - if (empty($this->redis)) { - $this->redis = Cache::store('redis')->handler(); - } - return $this->redis; - } + protected $cache; /** * 处理联系人 @@ -214,8 +197,8 @@ class OrderClient extends BaseOrder { $res = $this->isManaged(); if ($res['is_trade_managed']) { - $key = self::redis_prefix . '_is_trade_managed'; - $this->getRedis()->set($key, $res['is_trade_managed']); + $key = self::cache_prefix . '_is_trade_managed'; + CacheService::set($key, $res['is_trade_managed']); return true; } else { return false; @@ -232,8 +215,8 @@ class OrderClient extends BaseOrder */ public function checkManaged() { - $key = self::redis_prefix . '_is_trade_managed'; - if ($this->getRedis()->exists($key)) { + $key = self::cache_prefix . '_is_trade_managed'; + if (CacheService::get($key)) { return true; } else { return $this->setManaged(); @@ -252,10 +235,10 @@ class OrderClient extends BaseOrder { $list = $this->getDeliveryList(); if ($list) { - $key = self::redis_prefix . '_delivery_list'; + $key = self::cache_prefix . '_delivery_list'; $date = array_column($list['delivery_list'], 'delivery_id', 'delivery_name'); // 创建缓存 - $this->getRedis()->hMSet($key, $date); + CacheService::set($key, json_encode($date)); return $date; } else { @@ -274,15 +257,14 @@ class OrderClient extends BaseOrder */ public function getDelivery($company_name) { - $key = self::redis_prefix . '_delivery_list'; - if (!$this->getRedis()->exists($key)) { + $key = self::cache_prefix . '_delivery_list'; + if (!CacheService::get($key)) { $date = $this->setDeliveryList(); $express_company = $date[$company_name] ?? ''; } else { - $express_company = $this->getRedis()->hMGet($key, [$company_name])[$company_name] ?? ''; + $express_company = json_decode(CacheService::get($key), true)[$company_name] ?? ''; } if (empty($express_company)) { -// throw new AdminException('物流公司异常2'); $express_company = self::express_company; }