<?php
declare (strict_types=1);

namespace app\subscribe;

use app\model\CouponMain;
use think\facade\Log;

class Coupon
{
    /**
     * 检查过期的优惠券修改状态
     * */
    public function onCouponStatusCheck()
    {
        $count = CouponMain::whereTime("end_time", "<", date("Y-m-d"))->where(["status" => CouponMain::status_on])->count();
        if ($count) {
            Log::info("修改了优惠券状态" . $count);
            CouponMain::whereTime("end_time", "<", date("Y-m-d"))->update(["status" => CouponMain::status_off]);
        }
    }
}
