fix : coupon

This commit is contained in:
2025-03-31 16:55:21 +08:00
parent 775b4d8cb2
commit f26160d48d
2 changed files with 25 additions and 3 deletions

View File

@@ -10,6 +10,8 @@ declare(strict_types=1);
namespace App\Service\Api\Order;
use App\Cache\Redis\Api\ApiRedisKey;
use App\Cache\Redis\RedisCache;
use App\Constants\Common\OrderCode;
use App\Constants\Common\RefundCode;
use App\Exception\ErrException;
@@ -39,6 +41,12 @@ class RefundOrderService extends BaseService
#[Inject]
protected PayOrder $payOrderModel;
/**
* @var RedisCache
*/
#[Inject]
protected RedisCache $redis;
/**
* @return array
* @throws ContainerExceptionInterface
@@ -46,8 +54,12 @@ class RefundOrderService extends BaseService
*/
public function handle(): array
{
//todo 考虑是否枷锁
// 考虑是否枷锁
$orderId = (int)$this->request->input('order_id');
$refundLockKey = ApiRedisKey::refundLock($this->userId);
if (0 == ($this->redis->addLock($refundLockKey))){
throw new ErrException('请勿重复点击');
}
$orderInfo = $this->orderModel->getInfoById($orderId);
@@ -64,10 +76,11 @@ class RefundOrderService extends BaseService
$service->type = RefundCode::FULL_GOOD_REFUND;
$service->handle();
return $this->return->success();
}catch (Exception $e) {
throw new ErrException($e->getMessage());
}
$this->redis->delLock($refundLockKey);
return $this->return->success();
}
}