解决预存款事务问题
This commit is contained in:
parent
64dbe6708a
commit
a4ee4df71b
@ -143,6 +143,12 @@
|
||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||
<version>${jasypt-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson</artifactId>
|
||||
<version>${redisson}</version>
|
||||
</dependency>
|
||||
<!-- 阿里云核心包-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
|
@ -19,6 +19,9 @@ import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
|
||||
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
|
||||
import cn.lili.modules.wallet.service.MemberWalletService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -57,9 +60,11 @@ public class WalletPlugin implements Payment {
|
||||
@Autowired
|
||||
private CashierSupport cashierSupport;
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redisson;
|
||||
|
||||
@Override
|
||||
public ResultMessage<Object> h5pay(HttpServletRequest request, HttpServletResponse response, PayParam payParam) {
|
||||
|
||||
savePaymentLog(payParam);
|
||||
return ResultUtil.success(ResultCode.PAY_SUCCESS);
|
||||
}
|
||||
@ -113,9 +118,18 @@ public class WalletPlugin implements Payment {
|
||||
* @param payParam 支付参数
|
||||
*/
|
||||
private void savePaymentLog(PayParam payParam) {
|
||||
//获取支付收银参数
|
||||
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
||||
this.callBack(payParam, cashierParam);
|
||||
//同一个会员如果在不同的客户端使用预存款支付,会存在同时支付,无法保证预存款的正确性,所以对会员加锁
|
||||
RLock lock = redisson.getLock(UserContext.getCurrentUser().getId() + "");
|
||||
lock.lock();
|
||||
try {
|
||||
//获取支付收银参数
|
||||
CashierParam cashierParam = cashierSupport.cashierParam(payParam);
|
||||
this.callBack(payParam, cashierParam);
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
1
pom.xml
1
pom.xml
@ -29,6 +29,7 @@
|
||||
<jasypt-version>3.0.0</jasypt-version>
|
||||
<neetl-version>2.9.10</neetl-version>
|
||||
<lombok-version>1.18.22</lombok-version>
|
||||
<redisson>3.5.5</redisson>
|
||||
<aliyun-version>4.5.18</aliyun-version>
|
||||
<aliyun-sdk-oss-version>3.11.1</aliyun-sdk-oss-version>
|
||||
<aliyun-sdk-dysms-version>2.0.8</aliyun-sdk-dysms-version>
|
||||
|
Loading…
x
Reference in New Issue
Block a user