From f5c2dc7a5a0f067910d4270a212e04031db3863f Mon Sep 17 00:00:00 2001 From: chenrui <1187576398@qq.com> Date: 星期一, 19 五月 2025 11:31:04 +0800 Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/product-inventory-management-after --- src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java | 79 +++++++++++++++++++++++++++++++++++++++ src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java | 4 ++ src/main/java/com/ruoyi/purchase/dto/PaymentLedgerDto.java | 16 ++++++++ src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java | 10 +++++ 4 files changed, 108 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java b/src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java index d91f133..b8f233d 100644 --- a/src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java +++ b/src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java @@ -5,6 +5,7 @@ import com.ruoyi.framework.web.controller.BaseController; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.framework.web.page.TableDataInfo; +import com.ruoyi.purchase.dto.PaymentLedgerDto; import com.ruoyi.purchase.dto.PaymentRegistrationDto; import com.ruoyi.purchase.pojo.PaymentRegistration; import com.ruoyi.purchase.service.IPaymentRegistrationService; @@ -97,4 +98,13 @@ { return success(paymentRegistrationService.selectPaymentRegistrationByPurchaseId(id)); } + + /** + * 鑾峰彇浠樻鐧昏璇︾粏淇℃伅 + */ + @GetMapping(value = "/paymentLedgerList") + public AjaxResult paymentLedgerList(PaymentLedgerDto paymentLedgerDto) + { + return success(paymentRegistrationService.selectPaymentLedgerList(paymentLedgerDto)); + } } diff --git a/src/main/java/com/ruoyi/purchase/dto/PaymentLedgerDto.java b/src/main/java/com/ruoyi/purchase/dto/PaymentLedgerDto.java new file mode 100644 index 0000000..dc97a72 --- /dev/null +++ b/src/main/java/com/ruoyi/purchase/dto/PaymentLedgerDto.java @@ -0,0 +1,16 @@ +package com.ruoyi.purchase.dto; + +import lombok.Data; + +@Data +public class PaymentLedgerDto { + + // 渚涘簲鍟嗗悕绉� + private String supplierName; + + // 寮�濮嬫棩鏈� + private String startDate; + + // 缁撴潫鏃ユ湡 + private String endDate; +} diff --git a/src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java b/src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java index f652db5..cbf484f 100644 --- a/src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java +++ b/src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java @@ -1,10 +1,12 @@ package com.ruoyi.purchase.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.purchase.dto.PaymentLedgerDto; import com.ruoyi.purchase.dto.PaymentRegistrationDto; import com.ruoyi.purchase.pojo.PaymentRegistration; import java.util.List; +import java.util.Map; /** * 浠樻鐧昏Service鎺ュ彛 @@ -60,4 +62,6 @@ * @return 缁撴灉 */ PaymentRegistration selectPaymentRegistrationByPurchaseId(Long purchaseId); + + List<Map<String, Object>> selectPaymentLedgerList(PaymentLedgerDto paymentLedgerDto); } diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java index b14b4f2..e858038 100644 --- a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java +++ b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java @@ -1,11 +1,14 @@ package com.ruoyi.purchase.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.basic.mapper.SupplierManageMapper; +import com.ruoyi.basic.pojo.SupplierManage; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.framework.security.LoginUser; +import com.ruoyi.purchase.dto.PaymentLedgerDto; import com.ruoyi.purchase.dto.PaymentRegistrationDto; import com.ruoyi.purchase.mapper.InvoicePurchaseMapper; import com.ruoyi.purchase.mapper.PaymentRegistrationMapper; @@ -15,12 +18,17 @@ import com.ruoyi.purchase.pojo.PurchaseLedger; import com.ruoyi.purchase.service.IPaymentRegistrationService; import com.ruoyi.sales.mapper.SalesLedgerMapper; +import com.ruoyi.sales.mapper.SalesLedgerProductMapper; import com.ruoyi.sales.pojo.SalesLedger; +import com.ruoyi.sales.pojo.SalesLedgerProduct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; import java.math.BigDecimal; -import java.util.List; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; /** * 浠樻鐧昏Service涓氬姟灞傚鐞� @@ -44,6 +52,9 @@ @Autowired private SupplierManageMapper supplierManageMapper; + + @Autowired + private SalesLedgerProductMapper salesLedgerProductMapper; /** * 鏌ヨ浠樻鐧昏 @@ -166,4 +177,70 @@ } return paymentRegistrationDto; } + + @Override + public List<Map<String, Object>> selectPaymentLedgerList(PaymentLedgerDto paymentLedgerDto) { + List<Map<String, Object>> result = new ArrayList<>(); + LambdaQueryWrapper<SupplierManage> queryWrapper = new LambdaQueryWrapper<>(); + Optional.ofNullable(paymentLedgerDto) + .ifPresent(dto -> { + if (StringUtils.hasText(dto.getSupplierName())) { + queryWrapper.like(SupplierManage::getSupplierName, dto.getSupplierName()); + } + }); + + List<SupplierManage> supplierManages = supplierManageMapper.selectList(queryWrapper); + + for (SupplierManage supplierManage : supplierManages) { + Map<String, Object> res = new HashMap<>(); + res.put("supplierName", supplierManage.getSupplierName()); + + // 搴斾粯閲戦 + BigDecimal payableAmount = BigDecimal.ZERO; + List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(new QueryWrapper<SalesLedger>().eq("customer_id", supplierManage.getId())); + if (salesLedgers != null && salesLedgers.size() > 0) { + List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>() + .in("sales_ledger_id", salesLedgers.stream().map(SalesLedger::getId).collect(Collectors.toList()))); + // 搴斾粯閲戦 + payableAmount = salesLedgerProducts.stream().map(SalesLedgerProduct::getTaxInclusiveTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add); + + } + + // 寮�绁ㄩ噾棰� + BigDecimal invoiceAmount = salesLedgers.stream().map(SalesLedger::getContractAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + + // 浠樻閲戦 + List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>() + .eq("supplier_id", supplierManage.getId())); + + BigDecimal paymentAmount = BigDecimal.ZERO; + if (paymentRegistrations != null && paymentRegistrations.size() > 0) { + paymentAmount = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + } + + res.put("invoiceAmount", invoiceAmount); + res.put("payableAmount", payableAmount); + res.put("paymentAmount", paymentAmount); + + // 璇︽儏 + List<Map<String, Object>> details = new ArrayList<>(); + for (PaymentRegistration paymentRegistration : paymentRegistrations) { + Map<String, Object> detail = new HashMap<>(); + detail.put("voteCount", 1); // 绁ㄦ暟锛屾湭鐭ユ暟鎹簮锛屾殏鏃剁敤1 + detail.put("paymentAmount", paymentRegistration.getCurrentPaymentAmount()); // 浠樻閲戦 + InvoicePurchase invoicePurchase = invoicePurchaseMapper.selectById(paymentRegistration.getInvoicePurchaseId()); + detail.put("payableAmount", invoicePurchase.getInvoiceAmount()); // 搴斾粯閲戦 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + String formattedDate = sdf.format(paymentRegistration.getPaymentDate()); + detail.put("createTime", formattedDate); // 鍙戠敓鏃堕棿 + details.add(detail); + } + + res.put("details", paymentRegistrations); + + result.add(res); + } + + return result; + } } -- Gitblit v1.9.3