| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.pojo.AccountIncome; |
| | | import com.ruoyi.account.service.AccountIncomeService; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.sales.dto.CustomerInteractionDto; |
| | |
| | | import com.ruoyi.sales.service.ReceiptPaymentService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | |
| | | private SalesLedgerMapper salesLedgerMapper; |
| | | @Autowired |
| | | private InvoiceLedgerMapper invoiceLedgerMapper; |
| | | @Autowired |
| | | private AccountIncomeService accountIncomeService; |
| | | |
| | | /** |
| | | * 回款登记新增 |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int receiptPaymentSaveOrUpdate(ReceiptPayment receiptPayment) { |
| | | ReceiptPayment byId = receiptPayment; |
| | | if (!ObjectUtils.isEmpty(receiptPayment.getId())){ |
| | |
| | | throw new RuntimeException("本次回款金额不能大于待回款金额"); |
| | | } |
| | | if(null==receiptPayment.getId()){ |
| | | |
| | | AccountIncome accountIncome = new AccountIncome(); |
| | | accountIncome.setIncomeDate(DateUtils.toDate(receiptPayment.getReceiptPaymentDate())); |
| | | accountIncome.setIncomeType("0"); |
| | | accountIncome.setCustomerName(receiptPaymentDto1.getCustomerName()); |
| | | accountIncome.setIncomeMoney(receiptPayment.getReceiptPaymentAmount()); |
| | | accountIncome.setIncomeMethod("0"); |
| | | accountIncome.setInputTime(new Date()); |
| | | accountIncome.setInputUser(receiptPayment.getRegistrant()); |
| | | accountIncome.setIncomeDescribed("回款登记:" + invoiceLedger.getInvoiceNo()); |
| | | accountIncome.setInvoiceNumber(invoiceLedger.getInvoiceNo()); |
| | | accountIncomeService.save(accountIncome); |
| | | return receiptPaymentMapper.insert(receiptPayment); |
| | | }else { |
| | | |
| | | AccountIncome salesLedgerDB = accountIncomeService.getByInvoiceNumber(invoiceLedger.getInvoiceNo()); |
| | | List<AccountIncome> accountIncomeDBs = accountIncomeService.getByInvoiceNumberList(salesLedgerDB.getInvoiceNumber()); |
| | | if (!org.springframework.util.CollectionUtils.isEmpty(accountIncomeDBs)) { |
| | | accountIncomeDBs.forEach(accountIncomeDB -> { |
| | | accountIncomeDB.setIncomeMoney(receiptPayment.getReceiptPaymentAmount()); |
| | | accountIncomeDB.setInputUser(receiptPayment.getRegistrant()); |
| | | accountIncomeService.updateById(accountIncomeDB); |
| | | }); |
| | | } |
| | | return receiptPaymentMapper.updateById(receiptPayment); |
| | | } |
| | | } |