Compare commits
5 Commits
20250806-0
...
20250806-1
| Author | SHA1 | Date | |
|---|---|---|---|
| 30bed90d27 | |||
| ed4ce5bebe | |||
| eb0ce8a347 | |||
| edf270a6ce | |||
| c4c154cbb9 |
@@ -349,7 +349,10 @@ class GoodCache
|
||||
*/
|
||||
private function buildStockData(&$data): mixed
|
||||
{
|
||||
if (empty($data)) return $data;
|
||||
|
||||
foreach ($data as &$spu) {
|
||||
if (empty($spu['sku_list'])) continue;
|
||||
foreach ($spu['sku_list'] as &$sku) {
|
||||
$sku['stock'] = $this->getStock($sku['id']);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Service\Api\System\GetLeaderboardService;
|
||||
use App\Service\Api\System\MiniWxConfigService;
|
||||
use App\Service\Api\System\SiteListService;
|
||||
use App\Service\Api\System\SystemConfigService;
|
||||
use App\Service\Api\System\TestService;
|
||||
use App\Service\Api\User\IndexService;
|
||||
use DateMalformedStringException;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
@@ -87,4 +88,10 @@ class SystemController extends AbstractController
|
||||
{
|
||||
return (new GetLeaderboardService)->handle();
|
||||
}
|
||||
|
||||
#[RequestMapping(path: "test", methods: "GET")]
|
||||
public function test()
|
||||
{
|
||||
return (new TestService)->handle();
|
||||
}
|
||||
}
|
||||
|
||||
53
app/Cron/Coupon/UserCouponTask.php
Normal file
53
app/Cron/Coupon/UserCouponTask.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* This crontab file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Cron\Coupon;
|
||||
|
||||
use App\Constants\Common\CouponCode;
|
||||
use App\Lib\Log;
|
||||
use App\Model\UserCoupon;
|
||||
use Exception;
|
||||
use Hyperf\Crontab\Annotation\Crontab;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
#[Crontab(rule: "* * * * *", name: "UserCouponTask", singleton: true , callback: "execute", memo: "每秒执行优惠券过期")]
|
||||
class UserCouponTask
|
||||
{
|
||||
/**
|
||||
* @var Log
|
||||
*/
|
||||
#[Inject]
|
||||
protected Log $log;
|
||||
|
||||
/**
|
||||
* @var UserCoupon
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserCoupon $userCouponModel;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
try {
|
||||
$this->userCouponModel
|
||||
->where('status', CouponCode::COUPON_STATUS_UNUSED)
|
||||
->where('validity_end_time', '<', date('Y-m-d H:i:s'))
|
||||
->update(['status' => CouponCode::COUPON_STATUS_EXPIRE]);
|
||||
}catch (Exception $e){
|
||||
$this->log->error(__CLASS__.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class YlyPrintService implements PrintOrderInterface
|
||||
* @var Log
|
||||
*/
|
||||
#[Inject]
|
||||
private Log $log;
|
||||
protected Log $log;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,10 @@ trait CouponTrait
|
||||
$couponInfo = $this->userCouponModel->where('id', $orderInfo->coupon_id)->where('user_id',$orderInfo->user_id)->first();
|
||||
|
||||
if (empty($couponInfo)) return;
|
||||
if ($couponInfo->status != CouponCode::COUPON_STATUS_USED) return;
|
||||
|
||||
$couponInfo->status = CouponCode::COUPON_STATUS_UNUSED;
|
||||
$couponInfo->use_time = null;
|
||||
|
||||
if (date('Y-m-d H:i:s') > $couponInfo->validity_end_time) $couponInfo->status = CouponCode::COUPON_STATUS_EXPIRE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user