Commit 91c884c6 authored by liwei's avatar liwei

修改了互换微信bug

parent 170f687c
...@@ -882,8 +882,6 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -882,8 +882,6 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
DictData dictData2 = userLikeConfig.stream().filter(item -> item.getDictLabel().equals("accept_exchange_wechat")).findFirst().orElse(null); DictData dictData2 = userLikeConfig.stream().filter(item -> item.getDictLabel().equals("accept_exchange_wechat")).findFirst().orElse(null);
Integer requestGoldCoinCount = Integer.valueOf(dictData1.getDictValue());//发起请求需消耗的金币数 Integer requestGoldCoinCount = Integer.valueOf(dictData1.getDictValue());//发起请求需消耗的金币数
Integer acceptGoldCoinCount = Integer.valueOf(dictData2.getDictValue());//接收需消耗的金币数 Integer acceptGoldCoinCount = Integer.valueOf(dictData2.getDictValue());//接收需消耗的金币数
// Integer requestGoldCoinCount = Integer.valueOf('1');//发起请求需消耗的金币数
// Integer acceptGoldCoinCount = Integer.valueOf('1');//接收需消耗的金币数
if (memUserTaskDTO.getType().equals("1")){ if (memUserTaskDTO.getType().equals("1")){
//发起请求 //发起请求
//扣除该用户的金币数量 //扣除该用户的金币数量
...@@ -894,17 +892,27 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -894,17 +892,27 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
isGetLock = lock.tryLock(Long.parseLong(MemberInfoRedisBean.USER_WECHAT_TASK_LOCK_WAIT_TIME), isGetLock = lock.tryLock(Long.parseLong(MemberInfoRedisBean.USER_WECHAT_TASK_LOCK_WAIT_TIME),
Long.parseLong(MemberInfoRedisBean.USER_WECHAT_LOCK_LEASE_TIME), TimeUnit.SECONDS); Long.parseLong(MemberInfoRedisBean.USER_WECHAT_LOCK_LEASE_TIME), TimeUnit.SECONDS);
if (isGetLock) { if (isGetLock) {
//查询用户信息
MemInfo memInfo = memInfoRepository.selectByOpenId(memUserTaskDTO.getWxOpenid()); MemInfo memInfo = memInfoRepository.selectByOpenId(memUserTaskDTO.getWxOpenid());
if (memInfo.getGoldCoinsCount() - acceptGoldCoinCount < 0){ if (memInfo.getGoldCoinsCount() - acceptGoldCoinCount < 0){
throw new CyServiceException(1003,"金币余额不足,请先充值"); throw new CyServiceException(1003,"金币余额不足,请先充值");
} }
memInfo.setGoldCoinsCount(memInfo.getGoldCoinsCount() - acceptGoldCoinCount);
memInfoRepository.updateById(memInfo);
//添加索要微信任务 //添加索要微信任务
memUserTaskDTO.setStatus("0"); memUserTaskDTO.setStatus("0");
line = baseMapper.addWeChatTask(memUserTaskDTO); line = baseMapper.addWeChatTask(memUserTaskDTO);
//增加金币流水记录
MemGoldCoinFlow memGoldCoinFlow = new MemGoldCoinFlow();
memGoldCoinFlow.setUpdateBy(String.valueOf(createBy));
memGoldCoinFlow.setCount(acceptGoldCoinCount);
memGoldCoinFlow.setEndCount(memInfo.getGoldCoinsCount() - acceptGoldCoinCount);
memGoldCoinFlow.setType("2");
memGoldCoinFlow.setActionType("24");
memGoldCoinFlowRepository.insert(memGoldCoinFlow);
//修改用户金币数量
memInfo.setGoldCoinsCount(memInfo.getGoldCoinsCount() - acceptGoldCoinCount);
memInfoRepository.updateById(memInfo);
lock.unlock();
} }
lock.unlock();
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
lock.unlock(); lock.unlock();
...@@ -927,14 +935,24 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo> ...@@ -927,14 +935,24 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
isGetLock = lock.tryLock(Long.parseLong(MemberInfoRedisBean.USER_WECHAT_TASK_LOCK_WAIT_TIME), isGetLock = lock.tryLock(Long.parseLong(MemberInfoRedisBean.USER_WECHAT_TASK_LOCK_WAIT_TIME),
Long.parseLong(MemberInfoRedisBean.USER_WECHAT_LOCK_LEASE_TIME), TimeUnit.SECONDS); Long.parseLong(MemberInfoRedisBean.USER_WECHAT_LOCK_LEASE_TIME), TimeUnit.SECONDS);
if (isGetLock) { if (isGetLock) {
//查询用户信息
MemInfo memInfo = memInfoRepository.selectByOpenId(memUserTaskDTO.getWxOpenid()); MemInfo memInfo = memInfoRepository.selectByOpenId(memUserTaskDTO.getWxOpenid());
if (memInfo.getGoldCoinsCount() - requestGoldCoinCount < 0){ if (memInfo.getGoldCoinsCount() - requestGoldCoinCount < 0){
throw new CyServiceException(1003,"金币余额不足,请先充值"); throw new CyServiceException(1003,"金币余额不足,请先充值");
} }
memInfo.setGoldCoinsCount(memInfo.getGoldCoinsCount() - requestGoldCoinCount);
memInfoRepository.updateById(memInfo);
//修改微信任务 //修改微信任务
line = baseMapper.updateWeChatTask(memUserTaskDTO); line = baseMapper.updateWeChatTask(memUserTaskDTO);
//添加金币流水记录
MemGoldCoinFlow memGoldCoinFlow = new MemGoldCoinFlow();
memGoldCoinFlow.setUpdateBy(String.valueOf(createBy));
memGoldCoinFlow.setCount(requestGoldCoinCount);
memGoldCoinFlow.setEndCount(memInfo.getGoldCoinsCount() - requestGoldCoinCount);
memGoldCoinFlow.setType("2");
memGoldCoinFlow.setActionType("23");
memGoldCoinFlowRepository.insert(memGoldCoinFlow);
//修改用户金币数量
memInfo.setGoldCoinsCount(memInfo.getGoldCoinsCount() - requestGoldCoinCount);
memInfoRepository.updateById(memInfo);
lock.unlock(); lock.unlock();
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment