From e77ab14af1a0fd0be1e0cc2a32b49f6d975622c3 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Thu, 6 Jul 2023 18:09:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=93=E5=8D=B0sql?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/common.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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); + }); + } +} From f0389d734807bd75c81069c369ac10e670ae095c Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Thu, 6 Jul 2023 18:11:00 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=E6=80=BB?= =?UTF-8?q?=E6=95=B0=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/dao/activity/coupon/StoreCouponIssueDao.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 From 5dc72970ee0a162ba58f8724f68cec8181b2025c Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Thu, 6 Jul 2023 18:11:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=A7=92=E6=9D=80=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=B8=8B=E5=8D=95=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/app/dao/activity/seckill/StoreSeckillDao.php | 3 ++- .../app/services/activity/coupon/StoreCouponIssueServices.php | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) 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'); } From 02716e02278e607088e9e4e7c47b5ad253603835 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Thu, 6 Jul 2023 18:12:03 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=AE=A1=E7=90=86=E7=9A=84=E7=BC=93=E5=AD=98=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../easywechat/orderShipping/OrderClient.php | 42 ++++++------------- 1 file changed, 12 insertions(+), 30 deletions(-) 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; }