| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace App\Task;
- use App\Model\UserRebateLevelModel;
- use Hyperf\Crontab\Annotation\Crontab;
- use Hyperf\Di\Annotation\Inject;
- /**
- * 每天凌晨五分计算
- *
- * @Crontab(name="rebateListInit", rule="5 0 * * *", callback="execute", memo="返佣榜单初始化")
- */
- class RebateListInit
- {
- use \Hyperf\Di\Aop\ProxyTrait;
- use \Hyperf\Di\Aop\PropertyHandlerTrait;
- function __construct()
- {
- $this->__handlePropertyHandler(__CLASS__);
- }
- /**
- * @Inject()
- * @var \Hyperf\Contract\StdoutLoggerInterface
- */
- private $logger;
- public function execute()
- {
- $monthDay = date('d');
- $weekDaty = $this->getWeek();
- if ($monthDay == 1 || $monthDay == 01) {
- UserRebateLevelModel::query()->update(['moon_amount' => 0]);
- }
- if ($weekDaty == 1) {
- UserRebateLevelModel::query()->update(['week_amount' => 0]);
- }
- }
- //php获取今天是星期几
- function getWeek($unixTime = '')
- {
- $unixTime = is_numeric($unixTime) ? $unixTime : time();
- return date('w', $unixTime);
- }
- }
|