|
@@ -13,6 +13,7 @@ import com.game.business.dto.AppUserTeamTranserDto;
|
|
import com.game.business.dto.AppUserTeamTranserRecordDto;
|
|
import com.game.business.dto.AppUserTeamTranserRecordDto;
|
|
import com.game.business.service.IAppUserService;
|
|
import com.game.business.service.IAppUserService;
|
|
import com.game.business.service.ICfgCommonService;
|
|
import com.game.business.service.ICfgCommonService;
|
|
|
|
+import com.game.business.util.Md5Utils;
|
|
import com.game.business.vo.AppUserTeamTranserRecordVo;
|
|
import com.game.business.vo.AppUserTeamTranserRecordVo;
|
|
import com.game.common.annotation.DataSource;
|
|
import com.game.common.annotation.DataSource;
|
|
import com.game.common.constant.AppSceneType;
|
|
import com.game.common.constant.AppSceneType;
|
|
@@ -150,16 +151,27 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @DataSource(DataSourceType.SLAVE)
|
|
|
|
@DSTransactional
|
|
@DSTransactional
|
|
|
|
+ @DataSource(DataSourceType.SLAVE)
|
|
public HttpRet<Boolean> transfer(AppUserTeamTranserDto transfer) {
|
|
public HttpRet<Boolean> transfer(AppUserTeamTranserDto transfer) {
|
|
AppUser toAppUser = appUserService.selectAppUserByUserid(transfer.getToUserId());
|
|
AppUser toAppUser = appUserService.selectAppUserByUserid(transfer.getToUserId());
|
|
AppUser appUser = appUserService.selectAppUserByUserid(SecurityUtils.getUserId());
|
|
AppUser appUser = appUserService.selectAppUserByUserid(SecurityUtils.getUserId());
|
|
if(null == toAppUser){
|
|
if(null == toAppUser){
|
|
return HttpRet.fail("受益用户不存在");
|
|
return HttpRet.fail("受益用户不存在");
|
|
}
|
|
}
|
|
- if(appUser.getDiamondCoin().longValue() < transfer.getMoney().longValue()){
|
|
|
|
- return HttpRet.fail("转账金额不足");
|
|
|
|
|
|
+ if(appUser.getDiamondCoinCash().longValue() < transfer.getMoney().longValue()){
|
|
|
|
+ return HttpRet.fail("可转账金额不足");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isBlank(appUser.getFundPassword())){
|
|
|
|
+ return HttpRet.fail("未设置支付密码");
|
|
|
|
+ }
|
|
|
|
+ if(!Md5Utils.md5(Md5Utils.md5(transfer.getFundPassword()) + appUser.getSalt()).equals(appUser.getFundPassword())){
|
|
|
|
+ return HttpRet.fail("支付密码错误");
|
|
|
|
+ }
|
|
|
|
+ //查询当笔限额
|
|
|
|
+ CfgCommon cfgSignleCommon = cfgCommonService.getCfg(1);
|
|
|
|
+ if(null != cfgSignleCommon && transfer.getMoney() > Double.parseDouble(cfgSignleCommon.getCfgValue())){
|
|
|
|
+ return HttpRet.fail("转账失败超出单笔最大限额");
|
|
}
|
|
}
|
|
//查询当日限额
|
|
//查询当日限额
|
|
CfgCommon cfgCommon = cfgCommonService.getCfg(0);
|
|
CfgCommon cfgCommon = cfgCommonService.getCfg(0);
|
|
@@ -170,7 +182,7 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
|
|
queryWrapper.eq(FinTranRecord::getFromUid,SecurityUtils.getUserId());
|
|
queryWrapper.eq(FinTranRecord::getFromUid,SecurityUtils.getUserId());
|
|
queryWrapper.eq(FinTranRecord::getTranType1,FinTranType1.U_Outcome_Coin.getType());
|
|
queryWrapper.eq(FinTranRecord::getTranType1,FinTranType1.U_Outcome_Coin.getType());
|
|
queryWrapper.eq(FinTranRecord::getTranType3,FinTranType3.TRANSFER_TO_TEAM_DiamondCoin.getType());
|
|
queryWrapper.eq(FinTranRecord::getTranType3,FinTranType3.TRANSFER_TO_TEAM_DiamondCoin.getType());
|
|
- List<FinTranRecord> finTranRecords = finTranRecordMapper.selectList(queryWrapper);
|
|
|
|
|
|
+ List<FinTranRecord> finTranRecords = finTranRecordService.selecListByWrapper(queryWrapper);
|
|
if(null != finTranRecords && finTranRecords.size()>0){
|
|
if(null != finTranRecords && finTranRecords.size()>0){
|
|
double curMoney = finTranRecords.stream().mapToDouble(FinTranRecord::getDiamondCoinChange).sum();
|
|
double curMoney = finTranRecords.stream().mapToDouble(FinTranRecord::getDiamondCoinChange).sum();
|
|
if(curMoney >= limit){
|
|
if(curMoney >= limit){
|
|
@@ -183,25 +195,26 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
|
|
updateAppUser.setUserid(appUser.getUserid());
|
|
updateAppUser.setUserid(appUser.getUserid());
|
|
updateAppUser.setDiamondCoin(appUser.getDiamondCoin() - transfer.getMoney());
|
|
updateAppUser.setDiamondCoin(appUser.getDiamondCoin() - transfer.getMoney());
|
|
updateAppUser.setDiamondCoinCash(appUser.getDiamondCoinCash() - transfer.getMoney());
|
|
updateAppUser.setDiamondCoinCash(appUser.getDiamondCoinCash() - transfer.getMoney());
|
|
- updateAppUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() + transfer.getMoney());
|
|
|
|
|
|
+ updateAppUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() - transfer.getMoney());
|
|
//扣减余额
|
|
//扣减余额
|
|
- appUserService.updateAppUser(appUser);
|
|
|
|
|
|
+ appUserService.updateAppUser(updateAppUser);
|
|
|
|
|
|
FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
FinTranAddedInfo addedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.TRANSFER_TO_TEAM_DiamondCoin, FinTranType1.U_Outcome_Balance, appUser);
|
|
FinTranRecord tran = FinTranRecord.initFinTranRecordSomeParams(addedInfo, FinTranType3.TRANSFER_TO_TEAM_DiamondCoin, FinTranType1.U_Outcome_Balance, appUser);
|
|
tran.setDiamondCoinChange(transfer.getMoney() * -1);
|
|
tran.setDiamondCoinChange(transfer.getMoney() * -1);
|
|
tran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
|
|
tran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
|
|
tran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
tran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
|
|
+ tran.setRemarks("团队转账");
|
|
finTranRecordService.insertFinTranRecord(tran);
|
|
finTranRecordService.insertFinTranRecord(tran);
|
|
|
|
|
|
//受益用户增加余额
|
|
//受益用户增加余额
|
|
AppUser toUpdateAppUser = new AppUser();
|
|
AppUser toUpdateAppUser = new AppUser();
|
|
- toUpdateAppUser.setUserid(appUser.getUserid());
|
|
|
|
- toUpdateAppUser.setDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
|
|
|
|
- toUpdateAppUser.setDiamondCoinCash(appUser.getDiamondCoinCash() + transfer.getMoney());
|
|
|
|
- updateAppUser.setDiamondCoinTotal(appUser.getDiamondCoinTotal() + transfer.getMoney());
|
|
|
|
|
|
+ toUpdateAppUser.setUserid(toAppUser.getUserid());
|
|
|
|
+ toUpdateAppUser.setDiamondCoin(toAppUser.getDiamondCoin() + transfer.getMoney());
|
|
|
|
+ toUpdateAppUser.setDiamondCoinCash(toAppUser.getDiamondCoinCash() + transfer.getMoney());
|
|
|
|
+ updateAppUser.setDiamondCoinTotal(toAppUser.getDiamondCoinTotal() + transfer.getMoney());
|
|
//增加余额
|
|
//增加余额
|
|
- appUserService.updateAppUser(appUser);
|
|
|
|
|
|
+ appUserService.updateAppUser(toUpdateAppUser);
|
|
|
|
|
|
FinTranAddedInfo toAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
FinTranAddedInfo toAddedInfo = FinTranAddedInfo.createTranInfo(appUser.getUserid(), 0, 0, AppSceneType.Scene_None, "");
|
|
FinTranRecord toTran = FinTranRecord.initFinTranRecordSomeParams(toAddedInfo, FinTranType3.TRANSFER_TO_TEAM_DiamondCoin, FinTranType1.U_Income_Coin_Balance, toAppUser);
|
|
FinTranRecord toTran = FinTranRecord.initFinTranRecordSomeParams(toAddedInfo, FinTranType3.TRANSFER_TO_TEAM_DiamondCoin, FinTranType1.U_Income_Coin_Balance, toAppUser);
|
|
@@ -209,33 +222,43 @@ public class FinTranRecordServiceImpl extends ServiceImpl<FinTranRecordMapper, F
|
|
toTran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
|
|
toTran.setAfterDiamondCoin(appUser.getDiamondCoin() + transfer.getMoney());
|
|
toTran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
toTran.setCurrencyType(TranCurrencyType.Balance.getType());
|
|
toTran.setFromUid(appUser.getUserid());
|
|
toTran.setFromUid(appUser.getUserid());
|
|
|
|
+ tran.setRemarks("团队转账");
|
|
finTranRecordService.insertFinTranRecord(toTran);
|
|
finTranRecordService.insertFinTranRecord(toTran);
|
|
//清除用户缓存
|
|
//清除用户缓存
|
|
redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(appUser.getUserid())));
|
|
redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(appUser.getUserid())));
|
|
redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(toAppUser.getUserid())));
|
|
redisCache.deleteObject("U:UserInfo:".concat(String.valueOf(toAppUser.getUserid())));
|
|
- return HttpRet.success("转账成功");
|
|
|
|
|
|
+ return HttpRet.success("转账成功",true);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @DataSource(DataSourceType.SLAVE)
|
|
public List<FinTranRecord> transferRecord(AppUserTeamTranserRecordDto transerRecordDto) {
|
|
public List<FinTranRecord> transferRecord(AppUserTeamTranserRecordDto transerRecordDto) {
|
|
|
|
+ Long userId = SecurityUtils.getUserId();
|
|
LambdaQueryWrapper<FinTranRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<FinTranRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
- queryWrapper.between(FinTranRecord::getCreateTime,transerRecordDto.getBeginTime(),transerRecordDto.getEndTime());
|
|
|
|
|
|
+ queryWrapper.between(FinTranRecord::getCreateTime,transerRecordDto.getBeginTime().concat(" 00:00:00"),transerRecordDto.getEndTime().concat(" 23:59:59"));
|
|
queryWrapper.eq(FinTranRecord::getTranType3,FinTranType3.TRANSFER_TO_TEAM_DiamondCoin.getType());
|
|
queryWrapper.eq(FinTranRecord::getTranType3,FinTranType3.TRANSFER_TO_TEAM_DiamondCoin.getType());
|
|
- queryWrapper.eq(FinTranRecord::getTranType1,FinTranType1.U_Income_Coin_Balance);
|
|
|
|
|
|
+ queryWrapper.eq(FinTranRecord::getTranType1,FinTranType1.U_Income_Coin_Balance.getType());
|
|
if(transerRecordDto.getType() == 0){
|
|
if(transerRecordDto.getType() == 0){
|
|
//转出
|
|
//转出
|
|
- queryWrapper.eq(FinTranRecord::getFromUid,SecurityUtils.getUserId());
|
|
|
|
- if(null != transerRecordDto.getUserId()){
|
|
|
|
|
|
+ queryWrapper.eq(FinTranRecord::getFromUid,userId);
|
|
|
|
+ if(null != transerRecordDto.getUserId() && transerRecordDto.getUserId().longValue() > 0){
|
|
queryWrapper.eq(FinTranRecord::getToUid,transerRecordDto.getUserId());
|
|
queryWrapper.eq(FinTranRecord::getToUid,transerRecordDto.getUserId());
|
|
}
|
|
}
|
|
}else if(transerRecordDto.getType() == 1){
|
|
}else if(transerRecordDto.getType() == 1){
|
|
//转入
|
|
//转入
|
|
- queryWrapper.eq(FinTranRecord::getToUid,SecurityUtils.getUserId());
|
|
|
|
- if(null != transerRecordDto.getUserId()){
|
|
|
|
|
|
+ queryWrapper.eq(FinTranRecord::getToUid,userId);
|
|
|
|
+ if(null != transerRecordDto.getUserId() && transerRecordDto.getUserId().longValue() > 0){
|
|
queryWrapper.eq(FinTranRecord::getFromUid,transerRecordDto.getUserId());
|
|
queryWrapper.eq(FinTranRecord::getFromUid,transerRecordDto.getUserId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<FinTranRecord> list = finTranRecordMapper.selectList(queryWrapper);
|
|
List<FinTranRecord> list = finTranRecordMapper.selectList(queryWrapper);
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @DataSource(DataSourceType.SLAVE)
|
|
|
|
+ @Override
|
|
|
|
+ public List<FinTranRecord> selecListByWrapper(LambdaQueryWrapper<FinTranRecord> queryWrapper){
|
|
|
|
+ List<FinTranRecord> list = finTranRecordMapper.selectList(queryWrapper);
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
}
|
|
}
|