增加缴费金额校验
This commit is contained in:
@@ -272,6 +272,7 @@ public enum ErrorCodeEnum {
|
|||||||
DELETE_ERROR(1511025,"删除信息失败",null),
|
DELETE_ERROR(1511025,"删除信息失败",null),
|
||||||
RECEIPT_NOT_EXIST(1511026,"收款单不存在或已被删除",null),
|
RECEIPT_NOT_EXIST(1511026,"收款单不存在或已被删除",null),
|
||||||
XGJ_COLLECTION_STATUS_COMPLETE(1511027,"新管家收费状态已完成,请确认!",null),
|
XGJ_COLLECTION_STATUS_COMPLETE(1511027,"新管家收费状态已完成,请确认!",null),
|
||||||
|
PAY_AMOUNT_ERROR(1511028,"缴费金额不能大于未缴金额",null),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -163,8 +163,24 @@ public class LinePayServiceImpl implements LinePayService {
|
|||||||
if (StringUtils.isBlank(userId)) {
|
if (StringUtils.isBlank(userId)) {
|
||||||
throw new ServiceException(ErrorCodeEnum.ACCESS_TOKEN_INVALID);
|
throw new ServiceException(ErrorCodeEnum.ACCESS_TOKEN_INVALID);
|
||||||
}
|
}
|
||||||
|
FranchiseFeeDO franchiseFeeDO = franchiseFeeMapper.selectByShopId(request.getShopId());
|
||||||
//判断付款人最多2人(可重复)
|
//判断付款人最多2人(可重复)
|
||||||
List<LinePayDO> list = linePayDAO.getFranchiseFeePayInfoByShopId(request.getShopId());
|
List<LinePayDO> list = linePayDAO.getFranchiseFeePayInfoByShopId(request.getShopId());
|
||||||
|
//判断缴费金额不能大于未缴费金额
|
||||||
|
BigDecimal total = list.stream()
|
||||||
|
.map(LinePayDO::getAmount)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
//应缴金额
|
||||||
|
BigDecimal amountDue = new BigDecimal(franchiseFeeDO.getYearFranchiseFee())
|
||||||
|
.add(new BigDecimal(franchiseFeeDO.getLoanMargin()))
|
||||||
|
.add(new BigDecimal(franchiseFeeDO.getFirstYearFee()))
|
||||||
|
.add(new BigDecimal(franchiseFeeDO.getFirstYearManageFee()))
|
||||||
|
.add(new BigDecimal(franchiseFeeDO.getPerformanceBond()));
|
||||||
|
//未缴费金额
|
||||||
|
BigDecimal amountUnpaid = amountDue.subtract(total);
|
||||||
|
if( request.getAmount().compareTo(amountUnpaid) > 0 ){
|
||||||
|
throw new ServiceException(ErrorCodeEnum.PAY_AMOUNT_ERROR);
|
||||||
|
}
|
||||||
Set<String> payUserList = list.stream().map(LinePayDO::getPayUserName).collect(Collectors.toSet());
|
Set<String> payUserList = list.stream().map(LinePayDO::getPayUserName).collect(Collectors.toSet());
|
||||||
if (!payUserList.contains(request.getPayUserName()) && payUserList.size() >= 2) {
|
if (!payUserList.contains(request.getPayUserName()) && payUserList.size() >= 2) {
|
||||||
throw new ServiceException(ErrorCodeEnum.PAY_USER_NAME_ERROR);
|
throw new ServiceException(ErrorCodeEnum.PAY_USER_NAME_ERROR);
|
||||||
|
|||||||
Reference in New Issue
Block a user