From 820c38437d969c4045b9783e2da5c7cf6b6e6049 Mon Sep 17 00:00:00 2001 From: zwesy Date: Tue, 21 Dec 2021 15:01:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=A1=A5=E5=85=85=E6=9C=89=E6=95=88=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=8D=B7=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/traits/CouponMainTrait.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/traits/CouponMainTrait.php b/app/traits/CouponMainTrait.php index bfb8154..31c8a67 100644 --- a/app/traits/CouponMainTrait.php +++ b/app/traits/CouponMainTrait.php @@ -6,6 +6,7 @@ use app\exception\RepositoryException; use app\model\CouponMain; use app\model\UsingRule; use app\model\Coupon; +use think\facade\Db; trait CouponMainTrait { @@ -191,6 +192,10 @@ trait CouponMainTrait $q->whereTime('c.received_time', '>=', $startDay); }) ->count('c.id'); + $effectiveSize = CouponMain::where($whereMap) + ->whereTime('start_time', '<=', date('Y-m-d H:i:s')) + ->whereTime('end_time', '>=', date('Y-m-d H:i:s')) + ->sum(Db::Raw('(`count` - `received_count`)')); return [ // 发行总次数 @@ -203,6 +208,8 @@ trait CouponMainTrait 'unVerificationSize' => $unVerificationSize, // 最近($daySize + 1)天内的领取量 'lastReceivedSize' => $lastReceivedSize, + // 有效的(进行中且未被领取) + 'effectiveSize' => $effectiveSize, ]; } } \ No newline at end of file