RebateListInit.php 937 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Task;
  3. use App\Model\UserRebateLevelModel;
  4. use Hyperf\Crontab\Annotation\Crontab;
  5. use Hyperf\Di\Annotation\Inject;
  6. /**
  7. * 每天凌晨五分计算
  8. *
  9. * @Crontab(name="rebateListInit", rule="5 0 * * *", callback="execute", memo="返佣榜单初始化")
  10. */
  11. class RebateListInit
  12. {
  13. /**
  14. * @Inject()
  15. * @var \Hyperf\Contract\StdoutLoggerInterface
  16. */
  17. private $logger;
  18. public function execute()
  19. {
  20. $monthDay = date('d');
  21. $weekDaty = $this->getWeek();
  22. if ($monthDay == 1 || $monthDay == 01) {
  23. UserRebateLevelModel::query()->update(['moon_amount' => 0]);
  24. }
  25. if ($weekDaty == 1) {
  26. UserRebateLevelModel::query()->update(['week_amount' => 0]);
  27. }
  28. }
  29. //php获取今天是星期几
  30. function getWeek($unixTime=''){
  31. $unixTime=is_numeric($unixTime)?$unixTime:time();
  32. return date('w',$unixTime);
  33. }
  34. }