<?php
namespace app\smartbc\controller\home;
use app\common\controller\Home;
use app\smartbc\model\SmartbcConfig;
use app\smartbc\model\SmartbcCouponUser;

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