Timedtask.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\api\controller;
  3. use AlibabaCloud\Client\AlibabaCloud;
  4. use AlibabaCloud\Client\Exception\ClientException;
  5. use AlibabaCloud\Client\Exception\ServerException;
  6. use think\Db;
  7. /**
  8. * @title 定时任务
  9. * Class Timedtask
  10. * @controller Timedtask
  11. * @group base
  12. */
  13. class Timedtask
  14. {
  15. /**
  16. * @title 会员优惠券过期
  17. * @desc 会员优惠券过期
  18. * @author qc
  19. * @url /api/Timedtask/userCouponOver
  20. * @method GET
  21. */
  22. public function userCouponOver()
  23. {
  24. Db::table('user_coupon_list')
  25. ->where('past_at','> time',date('Y-m-d H:i:s'))
  26. ->where('status','=',1)
  27. ->update(['status'=>3]);
  28. }
  29. /**
  30. * @title 积分清零
  31. * @desc 积分清零
  32. * @author qc
  33. * @url /api/Timedtask/integralClean
  34. * @method GET
  35. */
  36. public function integralClean()
  37. {
  38. $month = date('m');
  39. $clean_set = sysconf('integral_clean');
  40. if($month == 11 && $clean_set != date('Y-m-d'))
  41. {
  42. Db::name('system_config')->where(['value'=>'integral_clean'])->update(['integral_clean'=>date('Y-m-d')]);
  43. $user_list = Db::name('store_member')->field('id,integral')->where('integral','>',0)->select();
  44. foreach ($user_list as $v) {
  45. update_user_integral($v['id'],$v['integral']*-1,10,'积分清零');
  46. }
  47. }
  48. }
  49. }