Merge branch 'master' of http://192.168.0.75:3000/bonus/Bonus-Cloud-JYY-Canteen
This commit is contained in:
commit
31ef454db0
|
|
@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
|
||||||
import com.bonus.canteen.core.account.mapper.AccWalletInfoMapper;
|
import com.bonus.canteen.core.account.mapper.AccWalletInfoMapper;
|
||||||
import com.bonus.canteen.core.account.domain.AccWalletInfo;
|
import com.bonus.canteen.core.account.domain.AccWalletInfo;
|
||||||
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
|
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
|
@ -194,57 +195,63 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
|
||||||
// SecurityUtils.getUserId().toString(), DateUtils.toLocalDateTime(new Date()));
|
// SecurityUtils.getUserId().toString(), DateUtils.toLocalDateTime(new Date()));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void acWalletBalanceOperation(WalletBalanceOperation operation) {
|
public void acWalletBalanceOperation(WalletBalanceOperation operation) {
|
||||||
switch (WalletBalanceOperationEnum.getEnum(operation.getOperationType())) {
|
try{
|
||||||
case ADD_BAL:
|
switch (WalletBalanceOperationEnum.getEnum(operation.getOperationType())) {
|
||||||
addAccWalletInfo(operation);
|
case ADD_BAL:
|
||||||
break;
|
addAccWalletInfo(operation);
|
||||||
case REDUCE_BAL:
|
break;
|
||||||
reduceAccWalletInfo(operation);
|
case REDUCE_BAL:
|
||||||
break;
|
reduceAccWalletInfo(operation);
|
||||||
default:
|
break;
|
||||||
throw new ServiceException("钱包操作类型错误");
|
default:
|
||||||
}
|
throw new ServiceException("钱包操作类型错误");
|
||||||
List<AccWalletInfo> walletInfoList = selectAccWalletInfoByUserId(operation.getUserId());
|
}
|
||||||
BigDecimal accBalTotal = walletInfoList.stream().map(AccWalletInfo::getWalletBal)
|
List<AccWalletInfo> walletInfoList = selectAccWalletInfoByUserId(operation.getUserId());
|
||||||
.filter(ObjectUtil::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
BigDecimal accBalTotal = walletInfoList.stream().map(AccWalletInfo::getWalletBal)
|
||||||
AjaxResult userResult = remoteUserService.getInfo(operation.getUserId() , SecurityConstants.INNER);
|
.filter(ObjectUtil::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
SysUser sysUser = null;
|
AjaxResult userResult = remoteUserService.getInfo(operation.getUserId() , SecurityConstants.INNER);
|
||||||
if(Objects.nonNull(userResult)) {
|
SysUser sysUser = null;
|
||||||
sysUser = JSONObject.parseObject(JSON.toJSONString(userResult.get(AjaxResult.DATA_TAG)), SysUser.class);
|
if(Objects.nonNull(userResult)) {
|
||||||
}
|
sysUser = JSONObject.parseObject(JSON.toJSONString(userResult.get(AjaxResult.DATA_TAG)), SysUser.class);
|
||||||
long tradeId = Id.next();
|
}
|
||||||
LocalDateTime tradeTime = LocalDateTime.now();
|
long tradeId = Id.next();
|
||||||
AccTrade accTrade = new AccTrade();
|
LocalDateTime tradeTime = LocalDateTime.now();
|
||||||
accTrade.setTradeId(tradeId);
|
AccTrade accTrade = new AccTrade();
|
||||||
accTrade.setTradeTime(tradeTime);
|
accTrade.setTradeId(tradeId);
|
||||||
accTrade.setTradeType(operation.getTradeType());
|
accTrade.setTradeTime(tradeTime);
|
||||||
accTrade.setAmount(operation.getAmount());
|
accTrade.setTradeType(operation.getTradeType());
|
||||||
accTrade.setActualAmount(operation.getAmount());
|
accTrade.setAmount(operation.getAmount());
|
||||||
accTrade.setWalletBalTotal(accBalTotal);
|
accTrade.setActualAmount(operation.getAmount());
|
||||||
accTrade.setAccAllBal(accBalTotal);
|
accTrade.setWalletBalTotal(accBalTotal);
|
||||||
accTrade.setPayState(PayStateEnum.PAY_SUCC.getKey());
|
accTrade.setAccAllBal(accBalTotal);
|
||||||
accTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey());
|
accTrade.setPayState(PayStateEnum.PAY_SUCC.getKey());
|
||||||
accTrade.setUserId(operation.getUserId());
|
accTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey());
|
||||||
accTrade.setPayChannel(operation.getPayChannel());
|
accTrade.setUserId(operation.getUserId());
|
||||||
accTrade.setPayType(operation.getPayType());
|
accTrade.setPayChannel(operation.getPayChannel());
|
||||||
accTrade.setCreateBy(SecurityUtils.getUsername());
|
accTrade.setPayType(operation.getPayType());
|
||||||
if(Objects.nonNull(sysUser)) {
|
accTrade.setCreateBy(SecurityUtils.getUsername());
|
||||||
accTrade.setDeptId(sysUser.getDeptId());
|
if(Objects.nonNull(sysUser)) {
|
||||||
}
|
accTrade.setDeptId(sysUser.getDeptId());
|
||||||
this.accTradeService.insertAccTrade(accTrade);
|
}
|
||||||
|
this.accTradeService.insertAccTrade(accTrade);
|
||||||
|
|
||||||
AccTradeWalletDetail accTradeWalletDetail = new AccTradeWalletDetail();
|
AccTradeWalletDetail accTradeWalletDetail = new AccTradeWalletDetail();
|
||||||
accTradeWalletDetail.setTradeId(tradeId);
|
accTradeWalletDetail.setTradeId(tradeId);
|
||||||
accTradeWalletDetail.setUserId(operation.getUserId());
|
accTradeWalletDetail.setUserId(operation.getUserId());
|
||||||
accTradeWalletDetail.setTradeType(operation.getTradeType());
|
accTradeWalletDetail.setTradeType(operation.getTradeType());
|
||||||
accTradeWalletDetail.setAmount(operation.getAmount());
|
accTradeWalletDetail.setAmount(operation.getAmount());
|
||||||
BigDecimal walletBalByWalletId = walletInfoList.stream().filter((item) -> {
|
BigDecimal walletBalByWalletId = walletInfoList.stream().filter((item) -> {
|
||||||
return item.getWalletId().equals(operation.getWalletId());
|
return item.getWalletId().equals(operation.getWalletId());
|
||||||
}).map(AccWalletInfo::getWalletBal).filter(ObjectUtil::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
}).map(AccWalletInfo::getWalletBal).filter(ObjectUtil::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
accTradeWalletDetail.setWalletBal(walletBalByWalletId);
|
accTradeWalletDetail.setWalletBal(walletBalByWalletId);
|
||||||
accTradeWalletDetail.setTradeTime(DateUtils.getNowDate());
|
accTradeWalletDetail.setTradeTime(DateUtils.getNowDate());
|
||||||
accTradeWalletDetail.setCreateBy(SecurityUtils.getUsername());
|
accTradeWalletDetail.setCreateBy(SecurityUtils.getUsername());
|
||||||
this.accTradeWalletDetailService.insertAccTradeWalletDetail(accTradeWalletDetail);
|
this.accTradeWalletDetailService.insertAccTradeWalletDetail(accTradeWalletDetail);
|
||||||
|
}catch (Exception ex) {
|
||||||
|
log.error("修改钱包失败", ex);
|
||||||
|
throw new ServiceException("修改钱包失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue