Timedtask.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 == 1 && $clean_set != date('Y-m-d')) {
  41. Db::name('system_config')->where(['name'=>'integral_clean'])->update(['value'=>date('Y-m-d')]);
  42. $user_list = Db::name('store_member')->field('id,integral')->where('integral','>',0)->select();
  43. foreach ($user_list as $v) {
  44. update_user_integral($v['id'],$v['integral']*-1,10,'积分清零');
  45. }
  46. }
  47. }
  48. }