zouyu
19 小时以前 75b7a414ef821a07426790cb79c37811ae2f07ac
src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -99,13 +99,12 @@
    /**
     * 新增付款登记
     *
     * @param paymentRegistrationList 付款登记
     * @param paymentRegistration 付款登记
     * @return 结果
     */
    @Override
    public int insertPaymentRegistration(List<PaymentRegistration> paymentRegistrationList) {
    public int insertPaymentRegistration(PaymentRegistration paymentRegistration) {
        LoginUser userId = SecurityUtils.getLoginUser();
        for (PaymentRegistration paymentRegistration : paymentRegistrationList) {
            PaymentRegistration byId = paymentRegistration;
            if (!ObjectUtils.isEmpty(paymentRegistration.getId())){
                paymentRegistration = this.getById(paymentRegistration.getId());
@@ -113,18 +112,18 @@
            PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId());
            if(null==purchaseLedger) throw new RuntimeException("未找到采购单");
            // 已回款金额
            SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSalesLedgerProductId());
            if(null==salesLedgerProduct) throw new RuntimeException("未找到采购单产品");
            if (salesLedgerProduct.getPendingTicketsTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){
                throw new RuntimeException("本次回款金额不能大于待回款金额");
            }
//            SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(paymentRegistration.getSalesLedgerProductId());
//            if(null==salesLedgerProduct) throw new RuntimeException("未找到采购单产品");
//            if (salesLedgerProduct.getPendingTicketsTotal().compareTo(paymentRegistration.getCurrentPaymentAmount())<0){
//                throw new RuntimeException("本次回款金额不能大于待回款金额");
//            }
            paymentRegistration.setCreateTime(DateUtils.getNowDate());
            paymentRegistration.setUpdateTime(DateUtils.getNowDate());
            paymentRegistration.setRegistrantId(userId.getUserId());
            salesLedgerProduct.setTicketsTotal(salesLedgerProduct.getTicketsTotal().add(paymentRegistration.getCurrentPaymentAmount()));
            salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal()));
//            salesLedgerProduct.setTicketsTotal(salesLedgerProduct.getTicketsTotal().add(paymentRegistration.getCurrentPaymentAmount()));
//            salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal()));
            paymentRegistrationMapper.insert(paymentRegistration);
            salesLedgerProductMapper.updateById(salesLedgerProduct);
//            salesLedgerProductMapper.updateById(salesLedgerProduct);
            // 2. 处理账户支出
            AccountExpense accountExpense = new AccountExpense();
            accountExpense.setExpenseDate(purchaseLedger.getEntryDate());
@@ -138,7 +137,6 @@
            accountExpense.setInputTime(new Date());
            accountExpense.setInputUser(userId.getNickName());
            accountExpenseService.save(accountExpense);
        }
        return 1;
    }