Compare commits
1 Commits
20250806-1
...
20250806-1
| Author | SHA1 | Date | |
|---|---|---|---|
| ed4ce5bebe |
@@ -12,6 +12,7 @@ use App\Service\Api\System\GetLeaderboardService;
|
|||||||
use App\Service\Api\System\MiniWxConfigService;
|
use App\Service\Api\System\MiniWxConfigService;
|
||||||
use App\Service\Api\System\SiteListService;
|
use App\Service\Api\System\SiteListService;
|
||||||
use App\Service\Api\System\SystemConfigService;
|
use App\Service\Api\System\SystemConfigService;
|
||||||
|
use App\Service\Api\System\TestService;
|
||||||
use App\Service\Api\User\IndexService;
|
use App\Service\Api\User\IndexService;
|
||||||
use DateMalformedStringException;
|
use DateMalformedStringException;
|
||||||
use Hyperf\HttpServer\Annotation\Controller;
|
use Hyperf\HttpServer\Annotation\Controller;
|
||||||
@@ -87,4 +88,10 @@ class SystemController extends AbstractController
|
|||||||
{
|
{
|
||||||
return (new GetLeaderboardService)->handle();
|
return (new GetLeaderboardService)->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[RequestMapping(path: "test", methods: "GET")]
|
||||||
|
public function test()
|
||||||
|
{
|
||||||
|
return (new TestService)->handle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ use App\Model\UserCoupon;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use Hyperf\Crontab\Annotation\Crontab;
|
use Hyperf\Crontab\Annotation\Crontab;
|
||||||
use Hyperf\Di\Annotation\Inject;
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
|
||||||
#[Crontab(rule: "* * * * *", name: "UserCouponTask", singleton: true , callback: "execute", memo: "每秒执行优惠券过期")]
|
#[Crontab(rule: "* * * * *", name: "UserCouponTask", singleton: true , callback: "execute", memo: "每秒执行优惠券过期")]
|
||||||
class UserCouponTask
|
class UserCouponTask
|
||||||
@@ -32,12 +34,17 @@ class UserCouponTask
|
|||||||
#[Inject]
|
#[Inject]
|
||||||
protected UserCoupon $userCouponModel;
|
protected UserCoupon $userCouponModel;
|
||||||
|
|
||||||
public function execute()
|
/**
|
||||||
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function execute(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->userCouponModel
|
$this->userCouponModel
|
||||||
->whereTime('validity_end_time', '>', date('Y-m-d H:i:s'))
|
|
||||||
->where('status', CouponCode::COUPON_STATUS_UNUSED)
|
->where('status', CouponCode::COUPON_STATUS_UNUSED)
|
||||||
|
->where('validity_end_time', '<', date('Y-m-d H:i:s'))
|
||||||
->update(['status' => CouponCode::COUPON_STATUS_EXPIRE]);
|
->update(['status' => CouponCode::COUPON_STATUS_EXPIRE]);
|
||||||
}catch (Exception $e){
|
}catch (Exception $e){
|
||||||
$this->log->error(__CLASS__.$e->getMessage());
|
$this->log->error(__CLASS__.$e->getMessage());
|
||||||
|
|||||||
39
app/Service/Api/System/TestService.php
Normal file
39
app/Service/Api/System/TestService.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This service file is part of item.
|
||||||
|
*
|
||||||
|
* @author ctexthuang
|
||||||
|
* @contact ctexthuang@qq.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Service\Api\System;
|
||||||
|
|
||||||
|
use App\Constants\Common\CouponCode;
|
||||||
|
use App\Model\UserCoupon;
|
||||||
|
use App\Service\Api\BaseService;
|
||||||
|
use Hyperf\Di\Annotation\Inject;
|
||||||
|
|
||||||
|
class TestService extends BaseService
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var UserCoupon
|
||||||
|
*/
|
||||||
|
#[Inject]
|
||||||
|
protected UserCoupon $userCouponModel;
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
var_dump(date('Y-m-d H:i:s'));
|
||||||
|
$data = $this->userCouponModel
|
||||||
|
->where('status', CouponCode::COUPON_STATUS_UNUSED)
|
||||||
|
->where('validity_end_time', '<', date('Y-m-d H:i:s'))
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$data = $data->toArray();
|
||||||
|
|
||||||
|
var_dump($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user