From ffd0d1fde083d3094363c67e1236a2b3d6736e1c Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期四, 15 五月 2025 17:53:20 +0800
Subject: [PATCH] 付款登记

---
 src/main/java/com/ruoyi/purchase/mapper/PaymentRegistrationMapper.java            |   32 +++
 src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java |  169 ++++++++++++++++
 src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java         |   63 ++++++
 src/main/java/com/ruoyi/purchase/dto/PaymentRegistrationDto.java                  |   34 +++
 src/main/java/com/ruoyi/basic/service/ISupplierService.java                       |    3 
 src/main/java/com/ruoyi/purchase/pojo/PaymentRegistration.java                    |   83 ++++++++
 src/main/java/com/ruoyi/basic/controller/SupplierManageController.java            |    9 
 src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java    |  100 ++++++++++
 src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java                         |    2 
 src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml                  |   87 ++++++++
 10 files changed, 580 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/ruoyi/basic/controller/SupplierManageController.java b/src/main/java/com/ruoyi/basic/controller/SupplierManageController.java
index f75564e..123da95 100644
--- a/src/main/java/com/ruoyi/basic/controller/SupplierManageController.java
+++ b/src/main/java/com/ruoyi/basic/controller/SupplierManageController.java
@@ -85,4 +85,13 @@
     public void supplierExport(HttpServletResponse response,SupplierManageDto supplierManageDto) {
         supplierService.supplierExport(response, supplierManageDto);
     }
+
+    /**
+     * 渚涘簲鍟嗛�夐」鎺ュ彛
+     * @return
+     */
+    @GetMapping("/getOptions")
+    public AjaxResult getOptions() {
+        return AjaxResult.success(supplierService.list());
+    }
 }
diff --git a/src/main/java/com/ruoyi/basic/service/ISupplierService.java b/src/main/java/com/ruoyi/basic/service/ISupplierService.java
index 5055a34..d9dd829 100644
--- a/src/main/java/com/ruoyi/basic/service/ISupplierService.java
+++ b/src/main/java/com/ruoyi/basic/service/ISupplierService.java
@@ -2,13 +2,14 @@
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.basic.dto.SupplierManageDto;
 import com.ruoyi.basic.pojo.SupplierManage;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
-public interface ISupplierService {
+public interface ISupplierService extends IService<SupplierManage> {
 
     /**
      * 渚涘簲鍟嗘柊澧�
diff --git a/src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java b/src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java
new file mode 100644
index 0000000..d91f133
--- /dev/null
+++ b/src/main/java/com/ruoyi/purchase/controller/PaymentRegistrationController.java
@@ -0,0 +1,100 @@
+package com.ruoyi.purchase.controller;
+
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+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.PaymentRegistrationDto;
+import com.ruoyi.purchase.pojo.PaymentRegistration;
+import com.ruoyi.purchase.service.IPaymentRegistrationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 浠樻鐧昏Controller
+ * 
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+@RestController
+@RequestMapping("/purchase/paymentRegistration")
+public class PaymentRegistrationController extends BaseController
+{
+    @Autowired
+    private IPaymentRegistrationService paymentRegistrationService;
+
+    /**
+     * 鏌ヨ浠樻鐧昏鍒楄〃
+     */
+//    @PreAuthorize("@ss.hasPermi('system:registration:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(PaymentRegistrationDto paymentRegistrationDto)
+    {
+        startPage();
+        List<PaymentRegistrationDto> list = paymentRegistrationService.selectPaymentRegistrationList(paymentRegistrationDto);
+        return getDataTable(list);
+    }
+
+    /**
+     * 瀵煎嚭浠樻鐧昏鍒楄〃
+     */
+//    @Log(title = "浠樻鐧昏", businessType = BusinessType.EXPORT)
+//    @PostMapping("/export")
+//    public void export(HttpServletResponse response, PaymentRegistrationDto paymentRegistrationDto)
+//    {
+//        List<PaymentRegistrationDto> list = paymentRegistrationService.selectPaymentRegistrationList(paymentRegistrationDto);
+//        ExcelUtil<PaymentRegistration> util = new ExcelUtil<PaymentRegistration>(PaymentRegistration.class);
+//        util.exportExcel(response, list, "浠樻鐧昏鏁版嵁");
+//    }
+
+    /**
+     * 鑾峰彇浠樻鐧昏璇︾粏淇℃伅
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(paymentRegistrationService.selectPaymentRegistrationById(id));
+    }
+
+    /**
+     * 鏂板浠樻鐧昏
+     */
+    @Log(title = "浠樻鐧昏", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody PaymentRegistration paymentRegistration)
+    {
+        return toAjax(paymentRegistrationService.insertPaymentRegistration(paymentRegistration));
+    }
+
+    /**
+     * 淇敼浠樻鐧昏
+     */
+    @Log(title = "浠樻鐧昏", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody PaymentRegistration paymentRegistration)
+    {
+        return toAjax(paymentRegistrationService.updatePaymentRegistration(paymentRegistration));
+    }
+
+    /**
+     * 鍒犻櫎浠樻鐧昏
+     */
+    @Log(title = "浠樻鐧昏", businessType = BusinessType.DELETE)
+	@DeleteMapping("/del")
+    public AjaxResult remove(@RequestBody Long[] ids)
+    {
+        return toAjax(paymentRegistrationService.deletePaymentRegistrationByIds(ids));
+    }
+
+    /**
+     * 鑾峰彇浠樻鐧昏璇︾粏淇℃伅
+     */
+    @GetMapping(value = "/byPurchaseId/{id}")
+    public AjaxResult getPurchaseInfo(@PathVariable("id") Long id)
+    {
+        return success(paymentRegistrationService.selectPaymentRegistrationByPurchaseId(id));
+    }
+}
diff --git a/src/main/java/com/ruoyi/purchase/dto/PaymentRegistrationDto.java b/src/main/java/com/ruoyi/purchase/dto/PaymentRegistrationDto.java
new file mode 100644
index 0000000..b2db4f4
--- /dev/null
+++ b/src/main/java/com/ruoyi/purchase/dto/PaymentRegistrationDto.java
@@ -0,0 +1,34 @@
+package com.ruoyi.purchase.dto;
+
+import com.ruoyi.purchase.pojo.PaymentRegistration;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class PaymentRegistrationDto extends PaymentRegistration {
+
+    // 鏌ヨ鍒楄〃鏌ヨ鐢ㄤ緵搴斿晢鍙峰拰鍚堝悓鍙�
+    private String supplierNameOrContractNo;
+
+    // 閿�鍞悎鍚屽彿
+    private String salesContractNo;
+
+    // 閲囪喘鍚堝悓鍙�
+    private String purchaseContractNumber;
+
+    // 渚涘簲鍟嗗悕绉�
+    private String supplierName;
+
+    // 鍙戠エ鍙�
+    private String invoiceNumber;
+
+    // 鍙戠エ閲戦
+    private BigDecimal invoiceAmount;
+
+    // 寰呬粯娆鹃噾棰�
+    private BigDecimal unPaymentAmount;
+
+    // 绋庣巼
+    private BigDecimal taxRate;
+}
diff --git a/src/main/java/com/ruoyi/purchase/mapper/PaymentRegistrationMapper.java b/src/main/java/com/ruoyi/purchase/mapper/PaymentRegistrationMapper.java
new file mode 100644
index 0000000..52024bc
--- /dev/null
+++ b/src/main/java/com/ruoyi/purchase/mapper/PaymentRegistrationMapper.java
@@ -0,0 +1,32 @@
+package com.ruoyi.purchase.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.purchase.dto.PaymentRegistrationDto;
+import com.ruoyi.purchase.pojo.PaymentRegistration;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 浠樻鐧昏Mapper鎺ュ彛
+ *
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+public interface PaymentRegistrationMapper extends BaseMapper<PaymentRegistration> {
+    /**
+     * 鏌ヨ浠樻鐧昏
+     *
+     * @param id 浠樻鐧昏涓婚敭
+     * @return 浠樻鐧昏
+     */
+    public PaymentRegistrationDto selectPaymentRegistrationById(@Param("id") Long id);
+
+    /**
+     * 鏌ヨ浠樻鐧昏鍒楄〃
+     *
+     * @param paymentRegistrationDto 浠樻鐧昏
+     * @return 浠樻鐧昏闆嗗悎
+     */
+    public List<PaymentRegistrationDto> selectPaymentRegistrationList(PaymentRegistrationDto paymentRegistrationDto);
+}
diff --git a/src/main/java/com/ruoyi/purchase/pojo/PaymentRegistration.java b/src/main/java/com/ruoyi/purchase/pojo/PaymentRegistration.java
new file mode 100644
index 0000000..403c424
--- /dev/null
+++ b/src/main/java/com/ruoyi/purchase/pojo/PaymentRegistration.java
@@ -0,0 +1,83 @@
+package com.ruoyi.purchase.pojo;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 浠樻鐧昏瀵硅薄 payment_registration
+ *
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+
+@Data
+@TableName("payment_registration")
+public class PaymentRegistration {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 閿�鍞彴璐d
+     */
+    private Long saleLedgerId;
+
+    /**
+     * 閲囪喘鍙拌处id
+     */
+    private Long purchaseLedgerId;
+
+    /**
+     * 渚涘簲鍟唅d
+     */
+    private Long supplierId;
+
+    /**
+     * 鍙戠エid
+     */
+    private Long invoicePurchaseId;
+
+    /**
+     * 鏈浠樻閲戦
+     */
+    private BigDecimal currentPaymentAmount;
+
+    /**
+     * 浠樻褰㈠紡
+     */
+    private String paymentMethod;
+
+    /**
+     * 鐧昏浜�
+     */
+    private Long registrantId;
+
+    // 绉熸埛id
+    private Long tenantId;
+
+    /**
+     * 浠樻鏃ユ湡
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date paymentDate;
+
+    /**
+     * 鍒涘缓鏃ユ湡
+     */
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+
+    /**
+     * 淇敼鏃ユ湡
+     */
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Date updateTime;
+}
diff --git a/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java b/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java
index b88be60..d1734ce 100644
--- a/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java
+++ b/src/main/java/com/ruoyi/purchase/pojo/PurchaseLedger.java
@@ -34,7 +34,7 @@
     /**
      * 渚涘簲鍟嗗悕绉癷d
      */
-    private String supplierId;
+    private Long supplierId;
 
     /**
      * 渚涘簲鍟嗗悕绉�
diff --git a/src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java b/src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java
new file mode 100644
index 0000000..f652db5
--- /dev/null
+++ b/src/main/java/com/ruoyi/purchase/service/IPaymentRegistrationService.java
@@ -0,0 +1,63 @@
+package com.ruoyi.purchase.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ruoyi.purchase.dto.PaymentRegistrationDto;
+import com.ruoyi.purchase.pojo.PaymentRegistration;
+
+import java.util.List;
+
+/**
+ * 浠樻鐧昏Service鎺ュ彛
+ *
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+public interface IPaymentRegistrationService extends IService<PaymentRegistration> {
+    /**
+     * 鏌ヨ浠樻鐧昏
+     *
+     * @param id 浠樻鐧昏涓婚敭
+     * @return 浠樻鐧昏
+     */
+    public PaymentRegistration selectPaymentRegistrationById(Long id);
+
+    /**
+     * 鏌ヨ浠樻鐧昏鍒楄〃
+     *
+     * @param paymentRegistrationDto 浠樻鐧昏
+     * @return 浠樻鐧昏闆嗗悎
+     */
+    public List<PaymentRegistrationDto> selectPaymentRegistrationList(PaymentRegistrationDto paymentRegistrationDto);
+
+    /**
+     * 鏂板浠樻鐧昏
+     *
+     * @param paymentRegistration 浠樻鐧昏
+     * @return 缁撴灉
+     */
+    public int insertPaymentRegistration(PaymentRegistration paymentRegistration);
+
+    /**
+     * 淇敼浠樻鐧昏
+     *
+     * @param paymentRegistration 浠樻鐧昏
+     * @return 缁撴灉
+     */
+    public int updatePaymentRegistration(PaymentRegistration paymentRegistration);
+
+    /**
+     * 鎵归噺鍒犻櫎浠樻鐧昏
+     *
+     * @param ids 闇�瑕佸垹闄ょ殑浠樻鐧昏涓婚敭闆嗗悎
+     * @return 缁撴灉
+     */
+    public int deletePaymentRegistrationByIds(Long[] ids);
+
+    /**
+     * 閫氳繃閲囪喘鍚堝悓鍙锋煡璇㈤攢鍞悎鍚屽彿锛屼緵搴斿晢鍚嶇О锛屽彂绁ㄥ彿锛屽彂绁ㄩ噾棰濓紝绋庣巼
+     *
+     * @param purchaseId 閲囪喘鍚堝悓id
+     * @return 缁撴灉
+     */
+    PaymentRegistration selectPaymentRegistrationByPurchaseId(Long purchaseId);
+}
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
new file mode 100644
index 0000000..b14b4f2
--- /dev/null
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -0,0 +1,169 @@
+package com.ruoyi.purchase.service.impl;
+
+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.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.purchase.dto.PaymentRegistrationDto;
+import com.ruoyi.purchase.mapper.InvoicePurchaseMapper;
+import com.ruoyi.purchase.mapper.PaymentRegistrationMapper;
+import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
+import com.ruoyi.purchase.pojo.InvoicePurchase;
+import com.ruoyi.purchase.pojo.PaymentRegistration;
+import com.ruoyi.purchase.pojo.PurchaseLedger;
+import com.ruoyi.purchase.service.IPaymentRegistrationService;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.pojo.SalesLedger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 浠樻鐧昏Service涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+@Service
+public class PaymentRegistrationServiceImpl extends ServiceImpl<PaymentRegistrationMapper, PaymentRegistration> implements IPaymentRegistrationService {
+    @Autowired
+    private PaymentRegistrationMapper paymentRegistrationMapper;
+
+    @Autowired
+    private PurchaseLedgerMapper purchaseLedgerMapper;
+
+    @Autowired
+    private InvoicePurchaseMapper invoicePurchaseMapper;
+
+    @Autowired
+    private SalesLedgerMapper salesLedgerMapper;
+
+    @Autowired
+    private SupplierManageMapper supplierManageMapper;
+
+    /**
+     * 鏌ヨ浠樻鐧昏
+     *
+     * @param id 浠樻鐧昏涓婚敭
+     * @return 浠樻鐧昏
+     */
+    @Override
+    public PaymentRegistration selectPaymentRegistrationById(Long id) {
+        return paymentRegistrationMapper.selectPaymentRegistrationById(id);
+    }
+
+    /**
+     * 鏌ヨ浠樻鐧昏鍒楄〃
+     *
+     * @param paymentRegistrationDto 浠樻鐧昏
+     * @return 浠樻鐧昏
+     */
+    @Override
+    public List<PaymentRegistrationDto> selectPaymentRegistrationList(PaymentRegistrationDto paymentRegistrationDto) {
+        List<PaymentRegistrationDto> list = paymentRegistrationMapper.selectPaymentRegistrationList(paymentRegistrationDto);
+        for (PaymentRegistrationDto registrationDto : list) {
+            List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>()
+                    .eq("invoice_purchase_id", registrationDto.getInvoicePurchaseId()));
+            BigDecimal total = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+            registrationDto.setUnPaymentAmount(registrationDto.getInvoiceAmount().subtract(total));
+        }
+        return list;
+    }
+
+    /**
+     * 鏂板浠樻鐧昏
+     *
+     * @param paymentRegistration 浠樻鐧昏
+     * @return 缁撴灉
+     */
+    @Override
+    public int insertPaymentRegistration(PaymentRegistration paymentRegistration) {
+        PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(paymentRegistration.getPurchaseLedgerId());
+        SalesLedger salesLedger = salesLedgerMapper.selectOne(new QueryWrapper<SalesLedger>().
+                eq("sales_contract_no", purchaseLedger.getSalesContractNo()));
+        if (salesLedger == null) {
+            throw new RuntimeException("鍏宠仈閿�鍞悎鍚屽彿涓嶅瓨鍦�");
+        }
+
+        paymentRegistration.setSaleLedgerId(salesLedger.getId());
+        paymentRegistration.setSupplierId(purchaseLedger.getSupplierId());
+
+        List<InvoicePurchase> invoicePurchases = invoicePurchaseMapper.selectList(new QueryWrapper<InvoicePurchase>().
+                eq("purchase_contract_no", purchaseLedger.getPurchaseContractNumber()));
+        if (invoicePurchases == null || invoicePurchases.size() == 0) {
+            throw new RuntimeException("鍏宠仈鍙戠エ涓嶅瓨鍦�");
+        }
+        paymentRegistration.setInvoicePurchaseId(invoicePurchases.get(0).getId());
+
+        List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>()
+                .eq("invoice_purchase_id", invoicePurchases.get(0).getId()));
+        BigDecimal total = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        if (total.add(paymentRegistration.getCurrentPaymentAmount()).compareTo(invoicePurchases.get(0).getInvoiceAmount()) > 0) {
+            throw new RuntimeException("浠樻閲戦瓒呭嚭鍙戠エ閲戦");
+        }
+
+
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Integer tenantId = loginUser.getTenantId();
+        paymentRegistration.setTenantId(tenantId.longValue());
+        paymentRegistration.setCreateTime(DateUtils.getNowDate());
+        paymentRegistration.setUpdateTime(DateUtils.getNowDate());
+        return paymentRegistrationMapper.insert(paymentRegistration);
+    }
+
+    /**
+     * 淇敼浠樻鐧昏
+     *
+     * @param paymentRegistration 浠樻鐧昏
+     * @return 缁撴灉
+     */
+    @Override
+    public int updatePaymentRegistration(PaymentRegistration paymentRegistration) {
+        InvoicePurchase invoicePurchase = invoicePurchaseMapper.selectById(paymentRegistration.getInvoicePurchaseId());
+
+        List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>()
+                .eq("invoice_purchase_id", paymentRegistration.getInvoicePurchaseId()).ne("id", paymentRegistration.getId()));
+        BigDecimal total = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        if (total.add(paymentRegistration.getCurrentPaymentAmount()).compareTo(invoicePurchase.getInvoiceAmount()) > 0) {
+            throw new RuntimeException("浠樻閲戦瓒呭嚭鍙戠エ閲戦");
+        }
+
+        paymentRegistration.setUpdateTime(DateUtils.getNowDate());
+        return paymentRegistrationMapper.updateById(paymentRegistration);
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎浠樻鐧昏
+     *
+     * @param ids 闇�瑕佸垹闄ょ殑浠樻鐧昏涓婚敭
+     * @return 缁撴灉
+     */
+    @Override
+    public int deletePaymentRegistrationByIds(Long[] ids) {
+        return paymentRegistrationMapper.delete(new QueryWrapper<PaymentRegistration>().in("id", ids));
+    }
+
+    @Override
+    public PaymentRegistration selectPaymentRegistrationByPurchaseId(Long id) {
+        PaymentRegistrationDto paymentRegistrationDto = new PaymentRegistrationDto();
+        PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectById(id);
+        paymentRegistrationDto.setSalesContractNo(purchaseLedger.getSalesContractNo());
+        paymentRegistrationDto.setSupplierName(purchaseLedger.getSupplierName());
+        paymentRegistrationDto.setSupplierId(purchaseLedger.getSupplierId());
+
+        List<InvoicePurchase> invoicePurchaseList = invoicePurchaseMapper.selectList(new QueryWrapper<InvoicePurchase>()
+                .eq("purchase_contract_no", purchaseLedger.getPurchaseContractNumber()));
+        if (invoicePurchaseList != null && invoicePurchaseList.size() > 0) {
+            paymentRegistrationDto.setInvoiceNumber(invoicePurchaseList.get(0).getInvoiceNumber());
+            paymentRegistrationDto.setInvoiceAmount(invoicePurchaseList.get(0).getInvoiceAmount());
+            paymentRegistrationDto.setTaxRate(invoicePurchaseList.get(0).getTaxRate());
+        }
+        return paymentRegistrationDto;
+    }
+}
diff --git a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
new file mode 100644
index 0000000..9f21eff
--- /dev/null
+++ b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.purchase.mapper.PaymentRegistrationMapper">
+
+    <resultMap type="PaymentRegistration" id="PaymentRegistrationResult">
+        <result property="id" column="id"/>
+        <result property="saleLedgerId" column="sale_ledger_id"/>
+        <result property="purchaseLedgerId" column="purchase_ledger_id"/>
+        <result property="supplierId" column="supplier_id"/>
+        <result property="invoicePurchaseId" column="invoice_purchase_id"/>
+        <result property="currentPaymentAmount" column="current_payment_amount"/>
+        <result property="paymentMethod" column="payment_method"/>
+        <result property="registrantId" column="registrant_id"/>
+        <result property="paymentDate" column="payment_date"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="tenantId" column="tenant_id"/>
+    </resultMap>
+
+    <resultMap type="com.ruoyi.purchase.dto.PaymentRegistrationDto" id="PaymentRegistrationDtoResult">
+        <result property="id" column="id"/>
+        <result property="saleLedgerId" column="sale_ledger_id"/>
+        <result property="purchaseLedgerId" column="purchase_ledger_id"/>
+        <result property="supplierId" column="supplier_id"/>
+        <result property="invoicePurchaseId" column="invoice_purchase_id"/>
+        <result property="currentPaymentAmount" column="current_payment_amount"/>
+        <result property="paymentMethod" column="payment_method"/>
+        <result property="registrantId" column="registrant_id"/>
+        <result property="paymentDate" column="payment_date"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="salesContractNo" column="sales_contract_no"/>
+        <result property="purchaseContractNumber" column="purchase_contract_number"/>
+        <result property="supplierName" column="supplier_name"/>
+        <result property="invoiceNumber" column="invoice_number"/>
+        <result property="taxRate" column="tax_rate"/>
+        <result property="invoiceAmount" column="invoice_amount"/>
+        <result property="tenantId" column="tenant_id"/>
+    </resultMap>
+
+    <sql id="selectPaymentRegistrationVo">
+        select pr.id,
+               pr.sale_ledger_id,
+               pr.purchase_ledger_id,
+               pr.supplier_id,
+               pr.invoice_purchase_id,
+               pr.current_payment_amount,
+               pr.payment_method,
+               pr.registrant_id,
+               pr.payment_date,
+               pr.create_time,
+               pr.update_time,
+               pr.tenant_id,
+               sl.sales_contract_no as sales_contract_no,
+               pl.purchase_contract_number as purchase_contract_number,
+               sm.supplier_name as supplier_name,
+               ip.invoice_number as invoice_number,
+               ip.tax_rate as tax_rate,
+               ip.invoice_amount as invoice_amount
+        from payment_registration pr
+                 left join sales_ledger sl on pr.sale_ledger_id = sl.id
+                 left join purchase_ledger pl on pr.purchase_ledger_id = pl.id
+                 left join supplier_manage sm on pr.supplier_id = sm.id
+                 left join invoice_purchase ip on pr.invoice_purchase_id = ip.id
+                 left join sys_user su on pr.registrant_id = su.user_id
+    </sql>
+
+    <select id="selectPaymentRegistrationList" parameterType="com.ruoyi.purchase.dto.PaymentRegistrationDto"
+            resultMap="PaymentRegistrationDtoResult">
+        <include refid="selectPaymentRegistrationVo"/>
+        <where>
+            <if test="supplierNameOrContractNo != null  and supplierNameOrContractNo != ''">
+                and sm.supplier_name LIKE CONCAT('%', #{supplierNameOrContractNo}, '%') or sl.sales_contract_no LIKE
+                CONCAT('%', #{supplierNameOrContractNo}, '%')
+                or pl.purchase_contract_number LIKE CONCAT('%', #{supplierNameOrContractNo}, '%')
+            </if>
+        </where>
+    </select>
+
+    <select id="selectPaymentRegistrationById" parameterType="Long" resultMap="PaymentRegistrationDtoResult">
+        <include refid="selectPaymentRegistrationVo"/>
+        where pr.id = #{id}
+    </select>
+
+</mapper>
\ No newline at end of file

--
Gitblit v1.9.3