<?php
namespace app\ais\controller\home;
use app\common\controller\Home;
use app\ais\model\AisConfig;
use app\ais\model\AisCouponUser;

class Task extends Home{
    //定时任务 更改优惠券过期
    public function index(){
        $configList = AisConfig::getAllConfig();
        foreach ($configList as $config){
            if(!empty($config->coupon_longtime)){
                AisCouponUser::where(['member_miniapp_id' => $config->member_miniapp_id,'is_end' => 0])->where('create_time','<=',(time() - $config->coupon_longtime * 60 * 60 ))->update(['is_end' => 1]);
            }
        }
    }
}