v1.1 充值-支付锁boolean
This commit is contained in:
@@ -45,8 +45,13 @@ public class GooglePlayBillingService {
|
||||
public void verifyOrder(String chargeRecordId, String packageName, String googlePlayProdId, String purchaseToken) {
|
||||
String lockKey = RedisKey.lock_pay_callback_notify.getKey(chargeRecordId);
|
||||
RLock lock = redissonClient.getLock(lockKey);
|
||||
boolean isLocked = false;
|
||||
try {
|
||||
lock.tryLock(5L, TimeUnit.SECONDS);
|
||||
isLocked = lock.tryLock(5L, TimeUnit.SECONDS);
|
||||
if (!isLocked){
|
||||
log.error("[google play billing]加锁失败。chargeRecordId: {}", chargeRecordId);
|
||||
throw new ServiceException(BusiStatus.SERVER_BUSY);
|
||||
}
|
||||
|
||||
ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(chargeRecordId);
|
||||
if (chargeRecord == null) {
|
||||
@@ -95,7 +100,7 @@ public class GooglePlayBillingService {
|
||||
throw new ServiceException(BusiStatus.BUSIERROR);
|
||||
}
|
||||
} finally {
|
||||
if (lock.isLocked()){
|
||||
if (isLocked || lock.isLocked()){
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@ package com.accompany.business.controller.apppay;
|
||||
|
||||
import com.accompany.business.service.ChargeService;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.payment.constant.PayConstant;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
import com.accompany.payment.payermax.config.PayermaxConfig;
|
||||
@@ -80,9 +82,13 @@ public class PayermaxPayController {
|
||||
|
||||
String lockKey = RedisKey.lock_pay_callback_notify.getKey(chargeRecordId);
|
||||
RLock lock = redissonClient.getLock(lockKey);
|
||||
|
||||
boolean isLocked = false;
|
||||
try {
|
||||
lock.tryLock(5L, TimeUnit.SECONDS);
|
||||
isLocked = lock.tryLock(5L, TimeUnit.SECONDS);
|
||||
if (!isLocked){
|
||||
log.error("【payermax支付回调】加锁失败 chargeRecordId: {}", chargeRecordId);
|
||||
throw new ServiceException(BusiStatus.SERVER_BUSY);
|
||||
}
|
||||
|
||||
ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(chargeRecordId);
|
||||
if (chargeRecord == null) {
|
||||
@@ -127,7 +133,7 @@ public class PayermaxPayController {
|
||||
map.put("message", "Exception happened " + e.getMessage());
|
||||
return map;
|
||||
} finally {
|
||||
if (lock.isLocked()){
|
||||
if (isLocked || lock.isLocked()){
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user