maven
14 小时以前 30a4a720cfdd57248514f50d141dfd51519aa75d
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -6,6 +6,9 @@
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.mapper.AccountExpenseMapper;
import com.ruoyi.account.pojo.AccountExpense;
import com.ruoyi.account.service.AccountExpenseService;
import com.ruoyi.basic.mapper.SupplierManageMapper;
import com.ruoyi.basic.pojo.SupplierManage;
import com.ruoyi.common.utils.DateUtils;
@@ -60,6 +63,8 @@
    private ProductRecordMapper productRecordMapper;
    private AccountExpenseService accountExpenseService;
    /**
     * 查询付款登记
     *
@@ -98,6 +103,7 @@
     */
    @Override
    public int insertPaymentRegistration(List<PaymentRegistration> paymentRegistrationList) {
        LoginUser userId = SecurityUtils.getLoginUser();
        for (PaymentRegistration paymentRegistration : paymentRegistrationList) {
            PaymentRegistration byId = paymentRegistration;
            if (!ObjectUtils.isEmpty(paymentRegistration.getId())){
@@ -106,17 +112,31 @@
            PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId());
            if(null==purchaseLedger) throw new RuntimeException("未找到采购单");
            // 已回款金额
            SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSaleLedgerProductId());
            SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSalesLedgerProductId());
            if(null==salesLedgerProduct) throw new RuntimeException("未找到采购单产品");
            if (salesLedgerProduct.getPendingInvoiceTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){
            if (salesLedgerProduct.getPendingTicketsTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){
                throw new RuntimeException("本次回款金额不能大于待回款金额");
            }
            paymentRegistration.setCreateTime(DateUtils.getNowDate());
            paymentRegistration.setUpdateTime(DateUtils.getNowDate());
            salesLedgerProduct.setInvoiceTotal(salesLedgerProduct.getInvoiceTotal().add(paymentRegistration.getCurrentPaymentAmount()));
            salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getInvoiceTotal()));
            paymentRegistration.setRegistrantId(userId.getUserId());
            salesLedgerProduct.setTicketsTotal(salesLedgerProduct.getTicketsTotal().add(paymentRegistration.getCurrentPaymentAmount()));
            salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal()));
            paymentRegistrationMapper.insert(paymentRegistration);
            salesLedgerProductMapper.updateById(salesLedgerProduct);
            // 2. 处理账户收入
            AccountExpense accountExpense = new AccountExpense();
            accountExpense.setExpenseDate(purchaseLedger.getEntryDate());
            accountExpense.setExpenseType("0");
            accountExpense.setSupplierName(purchaseLedger.getSupplierName());
            accountExpense.setExpenseMoney(paymentRegistration.getCurrentPaymentAmount());
            accountExpense.setExpenseDescribed("付款支出");
            accountExpense.setExpenseMethod("0");
            accountExpense.setBusinessId(paymentRegistration.getId());
            accountExpense.setBusinessType(1);
            accountExpense.setInputTime(new Date());
            accountExpense.setInputUser(userId.getNickName());
            accountExpenseService.save(accountExpense);
        }
        return 1;
@@ -456,6 +476,16 @@
        return paymentRegistrationMapper.deleteById(id);
    }
    @Override
    public IPage<PaymentRegistrationDto> supplierNameListPage(Page page, PaymentLedgerDto paymentLedgerDto) {
        return paymentRegistrationMapper.supplierNameListPage(page, paymentLedgerDto);
    }
    @Override
    public List<PaymentRegistrationDto> supplierNameListPageDetails(PaymentLedgerDto paymentLedgerDto) {
        return paymentRegistrationMapper.supplierNameListPageDetails(paymentLedgerDto);
    }
    // 批量查询采购台账(当月)
    private Map<Long, List<PurchaseLedger>> batchQueryPurchaseLedgers(List<Long> supplierIds, LocalDate startDate, LocalDate endDate) {
        LambdaQueryWrapper<PurchaseLedger> query = new LambdaQueryWrapper<>();