更新:商家信息补充有效优惠卷数量统计

master
zwesy 2021-12-21 15:01:21 +08:00
parent f4c9de618a
commit 820c38437d
1 changed files with 7 additions and 0 deletions

View File

@ -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,
];
}
}