Task.php 621 B

1234567891011121314151617
  1. <?php
  2. namespace app\smartbc\controller\home;
  3. use app\common\controller\Home;
  4. use app\smartbc\model\SmartbcConfig;
  5. use app\smartbc\model\SmartbcCouponUser;
  6. class Task extends Home{
  7. //定时任务 更改优惠券过期
  8. public function index(){
  9. $configList = SmartbcConfig::getAllConfig();
  10. foreach ($configList as $config){
  11. if(!empty($config->end_time)){
  12. 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]);
  13. }
  14. }
  15. }
  16. }