fix : coupon
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user