死锁问题
This commit is contained in:
parent
cbdf804c9c
commit
e00d6f413e
@ -53,6 +53,8 @@ import java.util.*;
|
|||||||
@Service
|
@Service
|
||||||
public class AccountRechargeServiceImpl extends DefaultBaseService implements IAccountRechargeService {
|
public class AccountRechargeServiceImpl extends DefaultBaseService implements IAccountRechargeService {
|
||||||
|
|
||||||
|
private final Object lock = new Object();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IAccountRechargeDao accountRechargeDao;
|
private IAccountRechargeDao accountRechargeDao;
|
||||||
|
|
||||||
@ -277,64 +279,67 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountRechargePayDTO saveAccount(String thirdParty, AccountRechargeVO accountRechargeVO) {
|
public AccountRechargePayDTO saveAccount(String thirdParty, AccountRechargeVO accountRechargeVO) {
|
||||||
String userId = StringUtils.isEmpty(accountRechargeVO.getUserId()) ? userUtil.getUserId(null) : accountRechargeVO.getUserId();
|
AccountRechargePayDTO payDTO = new AccountRechargePayDTO();
|
||||||
// 查看该用户今日的记录, 超过50条不能再创建
|
synchronized (lock) {
|
||||||
Integer count = accountRechargeDao.getTodayByAccountId(userId);
|
String userId = StringUtils.isEmpty(accountRechargeVO.getUserId()) ? userUtil.getUserId(null) : accountRechargeVO.getUserId();
|
||||||
if (count > 50) {
|
// 查看该用户今日的记录, 超过50条不能再创建
|
||||||
throw new SaveException("禁止操作");
|
Integer count = accountRechargeDao.getTodayByAccountId(userId);
|
||||||
}
|
if (count > 50) {
|
||||||
accountRechargeVO.setThirdParty(thirdParty);
|
throw new SaveException("禁止操作");
|
||||||
accountRechargeVO.setAccountId(userId);
|
}
|
||||||
accountRechargeVO.setRechargeCheck("0");
|
accountRechargeVO.setThirdParty(thirdParty);
|
||||||
accountRechargeVO.setReconciliationStatus("0");
|
accountRechargeVO.setAccountId(userId);
|
||||||
Integer totalMoney = PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney());
|
accountRechargeVO.setRechargeCheck("0");
|
||||||
|
accountRechargeVO.setReconciliationStatus("0");
|
||||||
|
Integer totalMoney = PayUtil.buiderMoney(accountRechargeVO.getRechargeMoney());
|
||||||
/* if (totalMoney < 10 || totalMoney > 200000) { // 最大2000块,最小1毛
|
/* if (totalMoney < 10 || totalMoney > 200000) { // 最大2000块,最小1毛
|
||||||
throw new SaveException("金额输入错误");
|
throw new SaveException("金额输入错误");
|
||||||
}*/
|
}*/
|
||||||
AccountRechargePayDTO payDTO = new AccountRechargePayDTO();
|
|
||||||
Map<String, Object> params = HashMapUtil.beanToMap(accountRechargeVO);
|
|
||||||
if ("微信".equals(thirdParty)) {
|
|
||||||
|
|
||||||
String accountRechargeId = getUUID("wx");
|
Map<String, Object> params = HashMapUtil.beanToMap(accountRechargeVO);
|
||||||
params.put("rechargeType", "2");
|
if ("微信".equals(thirdParty)) {
|
||||||
params.put("accountRechargeId", accountRechargeId);
|
|
||||||
params.put("rechargeFinalTime", DateUtil.getTime());
|
|
||||||
|
|
||||||
String brcode = WXPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle"));
|
String accountRechargeId = getUUID("wx");
|
||||||
|
params.put("rechargeType", "2");
|
||||||
|
params.put("accountRechargeId", accountRechargeId);
|
||||||
|
params.put("rechargeFinalTime", DateUtil.getTime());
|
||||||
|
|
||||||
payDTO.setAccountRechargeId(accountRechargeId);
|
String brcode = WXPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle"));
|
||||||
payDTO.setThirdParty(thirdParty);
|
|
||||||
payDTO.setThirdPartyPayUrl(brcode);
|
payDTO.setAccountRechargeId(accountRechargeId);
|
||||||
|
payDTO.setThirdParty(thirdParty);
|
||||||
|
payDTO.setThirdPartyPayUrl(brcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("支付宝".equals(thirdParty)) {
|
||||||
|
|
||||||
|
String accountRechargeId = getUUID("zfb");
|
||||||
|
params.put("rechargeType", "2");
|
||||||
|
params.put("accountRechargeId", accountRechargeId);
|
||||||
|
params.put("rechargeFinalTime", DateUtil.getTime());
|
||||||
|
|
||||||
|
String brcode = ALiPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle"));
|
||||||
|
|
||||||
|
payDTO.setAccountRechargeId(accountRechargeId);
|
||||||
|
payDTO.setThirdParty(thirdParty);
|
||||||
|
payDTO.setThirdPartyPayUrl(brcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("对公转账".equals(thirdParty)) {
|
||||||
|
String accountRechargeId = getUUID("oto");
|
||||||
|
params.put("rechargeType", "1");
|
||||||
|
params.put("accountRechargeId", accountRechargeId);
|
||||||
|
|
||||||
|
payDTO.setAccountRechargeId(accountRechargeId);
|
||||||
|
}
|
||||||
|
String currentDate = DateUtil.getTime();
|
||||||
|
params.put("creator", userId);
|
||||||
|
params.put("gmtCreate", currentDate);
|
||||||
|
params.put("modifier", userId);
|
||||||
|
params.put("gmtModified", currentDate);
|
||||||
|
params.put("isDelete", 0);
|
||||||
|
accountRechargeDao.save(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("支付宝".equals(thirdParty)) {
|
|
||||||
|
|
||||||
String accountRechargeId = getUUID("zfb");
|
|
||||||
params.put("rechargeType", "2");
|
|
||||||
params.put("accountRechargeId", accountRechargeId);
|
|
||||||
params.put("rechargeFinalTime", DateUtil.getTime());
|
|
||||||
|
|
||||||
String brcode = ALiPay.createPay(accountRechargeId, totalMoney, ProjectConfigUtil.getText("RechargePayTitle"));
|
|
||||||
|
|
||||||
payDTO.setAccountRechargeId(accountRechargeId);
|
|
||||||
payDTO.setThirdParty(thirdParty);
|
|
||||||
payDTO.setThirdPartyPayUrl(brcode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("对公转账".equals(thirdParty)) {
|
|
||||||
String accountRechargeId = getUUID("oto");
|
|
||||||
params.put("rechargeType", "1");
|
|
||||||
params.put("accountRechargeId", accountRechargeId);
|
|
||||||
|
|
||||||
payDTO.setAccountRechargeId(accountRechargeId);
|
|
||||||
}
|
|
||||||
String currentDate = DateUtil.getTime();
|
|
||||||
params.put("creator", userId);
|
|
||||||
params.put("gmtCreate", currentDate);
|
|
||||||
params.put("modifier", userId);
|
|
||||||
params.put("gmtModified", currentDate);
|
|
||||||
params.put("isDelete", 0);
|
|
||||||
accountRechargeDao.save(params);
|
|
||||||
return payDTO;
|
return payDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user