| | |
| | | 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.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; |
| | |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final TicketRegistrationMapper ticketRegistrationMapper; |
| | | private final ProductRecordMapper productRecordMapper; |
| | | private final AccountExpenseService accountExpenseService; |
| | | |
| | | /** |
| | | * 查询付款登记 |
| | |
| | | salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal())); |
| | | paymentRegistrationMapper.insert(paymentRegistration); |
| | | salesLedgerProductMapper.updateById(salesLedgerProduct); |
| | | // 2. 处理账户支出 |
| | | AccountExpense accountExpense = new AccountExpense(); |
| | | accountExpense.setExpenseDate(purchaseLedger.getEntryDate()); |
| | | accountExpense.setExpenseType("4"); |
| | | accountExpense.setSupplierName(purchaseLedger.getSupplierName()); |
| | | accountExpense.setExpenseMoney(paymentRegistration.getCurrentPaymentAmount()); |
| | | accountExpense.setExpenseDescribed("付款支出"); |
| | | |
| | | accountExpense.setExpenseMethod(paymentRegistration.getPaymentMethod()); |
| | | accountExpense.setBusinessId(paymentRegistration.getId()); |
| | | accountExpense.setBusinessType(1); |
| | | accountExpense.setInputTime(new Date()); |
| | | accountExpense.setInputUser(userId.getNickName()); |
| | | accountExpenseService.save(accountExpense); |
| | | } |
| | | return 1; |
| | | |
| | |
| | | throw new RuntimeException("付款金额超出待付款金额"); |
| | | } |
| | | paymentRegistration.setUpdateTime(DateUtils.getNowDate()); |
| | | // 同步修改账户支出 |
| | | LambdaQueryWrapper<AccountExpense> accountExpenseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | accountExpenseLambdaQueryWrapper.eq(AccountExpense::getBusinessId, paymentRegistration.getId()) |
| | | .eq(AccountExpense::getBusinessType, 1) |
| | | .last("limit 1"); |
| | | AccountExpense accountExpense = accountExpenseService.getOne(accountExpenseLambdaQueryWrapper); |
| | | if(null!=accountExpense){ |
| | | accountExpense.setExpenseMoney(paymentRegistration.getCurrentPaymentAmount()); |
| | | accountExpenseService.updateById(accountExpense); |
| | | } |
| | | // 修改采购产品付款金额 |
| | | salesLedgerProduct.setTicketsTotal(salesLedgerProduct.getTicketsTotal().add(subtract)); |
| | | salesLedgerProduct.setPendingTicketsTotal(salesLedgerProduct.getTaxInclusiveTotalPrice().subtract(salesLedgerProduct.getTicketsTotal())); |
| | |
| | | |
| | | @Override |
| | | public int delPaymentRegistration(List<Long> ids) { |
| | | LambdaQueryWrapper<AccountExpense> accountExpenseLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | accountExpenseLambdaQueryWrapper.in(AccountExpense::getBusinessId, ids) |
| | | .eq(AccountExpense::getBusinessType, 1); |
| | | accountExpenseService.remove(accountExpenseLambdaQueryWrapper); |
| | | // 修改采购产品的已付款金额,待付款金额 |
| | | List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectBatchIds(ids); |
| | | for (PaymentRegistration paymentRegistration : paymentRegistrations) { |