| | |
| | | import com.ruoyi.account.bean.dto.purchase.AccountPurchasePaymentDto; |
| | | import com.ruoyi.account.bean.vo.purchase.AccountPurchasePaymentVo; |
| | | import com.ruoyi.account.mapper.AccountStatementDetailsMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPaymentApplicationMapper; |
| | | import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper; |
| | | import com.ruoyi.account.pojo.AccountStatementDetails; |
| | | import com.ruoyi.account.pojo.purchase.AccountPaymentApplication; |
| | | import com.ruoyi.account.pojo.purchase.AccountPurchasePayment; |
| | | import com.ruoyi.account.service.purchase.AccountPurchasePaymentService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | |
| | | private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss"); |
| | | private final AccountPurchasePaymentMapper accountPurchasePaymentMapper; |
| | | private final AccountStatementDetailsMapper accountStatementDetailsMapper; |
| | | private final AccountPaymentApplicationMapper accountPaymentApplicationMapper; |
| | | |
| | | @Override |
| | | public IPage<AccountPurchasePaymentVo> listPageAccountPurchasePayment(Page page, AccountPurchasePaymentDto accountPurchasePaymentDto) { |
| | |
| | | if (StringUtils.isEmpty(accountPurchasePayment.getPaymentNumber())) { |
| | | accountPurchasePayment.setPaymentNumber(genAccountPurchasePaymentNo()); |
| | | } |
| | | //校验累计付款金额不能超过申请金额 |
| | | AccountPaymentApplication accountPaymentApplication = accountPaymentApplicationMapper.selectById(accountPurchasePayment.getAccountPaymentApplicationId()); |
| | | List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery().eq(AccountPurchasePayment::getAccountPaymentApplicationId, accountPurchasePayment.getAccountPaymentApplicationId())); |
| | | BigDecimal totalPaymentAmount = accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (accountPaymentApplication.getPaymentAmount().compareTo(totalPaymentAmount) < 0) { |
| | | throw new ServiceException("累计付款金额不能超过申请金额"); |
| | | } |
| | | return save(accountPurchasePayment); |
| | | } |
| | | |