From d09f76ca1ffd2ab091c14327b8e50d92dfa1df7e Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期三, 27 八月 2025 09:49:50 +0800
Subject: [PATCH] 新增应收,台账,改变文件上传方式

---
 main-business/src/main/java/com/ruoyi/business/dto/ReceiptPaymentDto.java                  |   22 +++
 main-business/src/main/java/com/ruoyi/business/other/service/impl/TempFileServiceImpl.java |    4 
 main-business/src/main/java/com/ruoyi/business/entity/ReceiptPayment.java                  |   64 +++++++++
 main-business/src/main/java/com/ruoyi/business/controller/ReceiptPaymentController.java    |   83 +++++++++++
 main-business/src/main/resources/mapper/ReceiptPaymentMapper.xml                           |   61 ++++++++
 main-business/src/main/java/com/ruoyi/business/service/ReceiptPaymentService.java          |   54 +++++++
 main-business/src/main/java/com/ruoyi/business/service/impl/ReceiptPaymentServiceImpl.java |   87 ++++++++++++
 main-business/src/main/java/com/ruoyi/business/mapper/ReceiptPaymentMapper.java            |   39 +++++
 8 files changed, 412 insertions(+), 2 deletions(-)

diff --git a/main-business/src/main/java/com/ruoyi/business/controller/ReceiptPaymentController.java b/main-business/src/main/java/com/ruoyi/business/controller/ReceiptPaymentController.java
new file mode 100644
index 0000000..da6322b
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/controller/ReceiptPaymentController.java
@@ -0,0 +1,83 @@
+package com.ruoyi.business.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import com.ruoyi.business.dto.ReceiptPaymentDto;
+import com.ruoyi.business.entity.ReceiptPayment;
+import com.ruoyi.business.service.ReceiptPaymentService;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@RestController
+@RequestMapping("/receiptPayment")
+public class ReceiptPaymentController extends BaseController {
+
+    @Autowired
+    private ReceiptPaymentService receiptPaymentService;
+
+    /**
+     * 搴旀敹鍙拌处鏂板
+     * @param receiptPayment
+     * @return
+     */
+    @PostMapping("/saveOrUpdate")
+    public AjaxResult receiptPaymentSaveOrUpdate (@RequestBody ReceiptPayment receiptPayment) {
+        receiptPaymentService.receiptPaymentSaveOrUpdate(receiptPayment);
+        return AjaxResult.success();
+    }
+
+    /**
+     * 搴旀敹鍙拌处淇敼
+     * @param receiptPayment
+     * @return
+     */
+    @PostMapping("/update")
+    public AjaxResult receiptPaymentUpdate (@RequestBody ReceiptPayment receiptPayment) {
+        return AjaxResult.success(receiptPaymentService.receiptPaymentUpdate(receiptPayment));
+    }
+
+    /**
+     * 搴旀敹鍙拌处鍒犻櫎
+     * @param ids
+     * @return
+     */
+    @DeleteMapping("/del")
+    public AjaxResult receiptPaymentDel (@RequestBody List<Integer> ids) {
+        return AjaxResult.success(receiptPaymentService.receiptPaymentDel(ids));
+    }
+
+    /**
+     * 搴旀敹鍙拌处璇︽儏
+     * @param id
+     * @return
+     */
+    @GetMapping("/invoiceInfo")
+    public AjaxResult invoiceInfo (Integer id) {
+        return AjaxResult.success(receiptPaymentService.invoiceInfo(id));
+    }
+
+    /**
+     * 鏌ヨ搴旀敹璁板綍
+     */
+    @GetMapping("/receiptPaymentHistoryListPage")
+    public IPage<ReceiptPaymentDto> receiptPaymentHistoryListPage(Page page, ReceiptPaymentDto receiptPaymentDto) {
+        return receiptPaymentService.receiptPaymentHistoryListPage(page,receiptPaymentDto);
+    }
+
+    /**
+     * 鏌ヨ搴旀敹璁板綍涓嶅垎椤�
+     */
+    @GetMapping("/receiptPaymentHistoryListNoPage")
+    public List<ReceiptPaymentDto> receiptPaymentHistoryListNoPage(ReceiptPaymentDto receiptPaymentDto) {
+        return receiptPaymentService.receiptPaymentHistoryListNoPage(receiptPaymentDto);
+    }
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/dto/ReceiptPaymentDto.java b/main-business/src/main/java/com/ruoyi/business/dto/ReceiptPaymentDto.java
new file mode 100644
index 0000000..f211c0c
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/dto/ReceiptPaymentDto.java
@@ -0,0 +1,22 @@
+package com.ruoyi.business.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.ruoyi.business.entity.ReceiptPayment;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class ReceiptPaymentDto extends ReceiptPayment {
+    @Excel(name = "瀹㈡埛")
+    private String customer;
+    @Excel(name = "鐓ょ")
+    private String coal;
+
+    @TableField(exist = false)
+    @Excel(isExport = false)
+    private String receiptPaymentDateStart;
+    @TableField(exist = false)
+    @Excel(isExport = false)
+    private String receiptPaymentDateEnd;
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/entity/ReceiptPayment.java b/main-business/src/main/java/com/ruoyi/business/entity/ReceiptPayment.java
new file mode 100644
index 0000000..4fcddae
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/entity/ReceiptPayment.java
@@ -0,0 +1,64 @@
+package com.ruoyi.business.entity;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+@TableName("receipt_payment")
+public class ReceiptPayment {
+
+    /**
+     * 搴忓彿
+     */
+    @TableId(type = IdType.AUTO)
+    private Integer id;
+
+    @ApiModelProperty(value = "鍥炴褰㈠紡 0鐢垫眹1鎵垮厬")
+    private String receiptPaymentType;
+
+    @ApiModelProperty(value = "搴旀敹閲戦")
+    private BigDecimal receiptPaymentAmount;
+
+    @ApiModelProperty(value = "鐧昏浜�")
+    private String registrant;
+
+    @ApiModelProperty(value = "閿�鍞褰曡〃涓婚敭ID")
+    private Integer salesRecordId;
+
+    @ApiModelProperty(value = "鏉ユ鏃ユ湡")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate receiptPaymentDate;
+
+    @ApiModelProperty(value = "鍒涘缓鏃堕棿")
+    @TableField(fill = FieldFill.INSERT)
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createTime;
+
+    @ApiModelProperty(value = "鍒涘缓鐢ㄦ埛")
+    @TableField(fill = FieldFill.INSERT)
+    private Integer createUser;
+
+    @ApiModelProperty(value = "淇敼鏃堕棿")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty(value = "淇敼鐢ㄦ埛")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Integer updateUser;
+
+    @ApiModelProperty(value = "绉熸埛ID")
+    @TableField(fill = FieldFill.INSERT)
+    private Long tenantId;
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/mapper/ReceiptPaymentMapper.java b/main-business/src/main/java/com/ruoyi/business/mapper/ReceiptPaymentMapper.java
new file mode 100644
index 0000000..e44fe20
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/mapper/ReceiptPaymentMapper.java
@@ -0,0 +1,39 @@
+package com.ruoyi.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import com.ruoyi.business.dto.ReceiptPaymentDto;
+import com.ruoyi.business.dto.SalesRecordDto;
+import com.ruoyi.business.entity.ReceiptPayment;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public interface ReceiptPaymentMapper extends BaseMapper<ReceiptPayment> {
+
+    /**
+     * 鏌ヨ宸茬粡缁戝畾鍙戠エ鐨勫紑绁ㄥ彴璐�
+     * @param page
+     * @param receiptPaymentDto
+     * @return
+     */
+    IPage<ReceiptPaymentDto> bindInvoiceNoRegPage(Page page, @Param("receiptPaymentDto") ReceiptPaymentDto receiptPaymentDto);
+
+    /**
+     * 寮�绁ㄥ彴璐﹁鎯�
+     * @param id
+     * @return
+     */
+    SalesRecordDto invoiceInfo(Integer id);
+
+
+
+    /**
+     * 鏌ヨ鍥炴璁板綍涓嶅垎椤�
+     */
+    List<ReceiptPaymentDto> receiptPaymentHistoryListNoPage( @Param("params") ReceiptPaymentDto receiptPaymentDto);
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/other/service/impl/TempFileServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/other/service/impl/TempFileServiceImpl.java
index b024478..4258116 100644
--- a/main-business/src/main/java/com/ruoyi/business/other/service/impl/TempFileServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/other/service/impl/TempFileServiceImpl.java
@@ -38,10 +38,10 @@
     @Autowired
     private CommonFileMapper commonFileMapper;
 
-    @Value("${file.upload-dir}")
+//    @Value("${file.upload-dir}")
     private String uploadDir;
 
-    @Value("${file.temp-dir}")
+//    @Value("${file.temp-dir}")
     private String tempDir;
 
     // 涓婁紶鍒颁复鏃剁洰褰�
diff --git a/main-business/src/main/java/com/ruoyi/business/service/ReceiptPaymentService.java b/main-business/src/main/java/com/ruoyi/business/service/ReceiptPaymentService.java
new file mode 100644
index 0000000..2637915
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/service/ReceiptPaymentService.java
@@ -0,0 +1,54 @@
+package com.ruoyi.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.business.dto.ReceiptPaymentDto;
+import com.ruoyi.business.dto.SalesRecordDto;
+import com.ruoyi.business.entity.ReceiptPayment;
+import jakarta.servlet.http.HttpServletResponse;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+public interface ReceiptPaymentService {
+
+    /**
+     * 鍥炴鐧昏鏂板
+     * @param receiptPayment
+     * @return
+     */
+    int receiptPaymentSaveOrUpdate(ReceiptPayment receiptPayment);
+
+    /**
+     * 鍥炴鐧昏淇敼
+     * @param receiptPayment
+     * @return
+     */
+    int receiptPaymentUpdate(ReceiptPayment receiptPayment);
+
+    /**
+     * 鍥炴鐧昏鍒犻櫎
+     * @param ids
+     * @return
+     */
+    int receiptPaymentDel(List<Integer> ids);
+
+    /**
+     * 寮�绁ㄥ彴璐﹁鎯�
+     * @param id
+     * @return
+     */
+    SalesRecordDto invoiceInfo(Integer id);
+
+    /**
+     * 鏌ヨ鍥炴璁板綍鍒嗛〉
+     */
+    IPage<ReceiptPaymentDto> receiptPaymentHistoryListPage(Page page, ReceiptPaymentDto receiptPaymentDto);
+
+    /**
+     * 鏌ヨ鍥炴璁板綍涓嶅垎椤�
+     */
+    List<ReceiptPaymentDto> receiptPaymentHistoryListNoPage(ReceiptPaymentDto receiptPaymentDto);
+
+}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/ReceiptPaymentServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/ReceiptPaymentServiceImpl.java
new file mode 100644
index 0000000..6fd62c3
--- /dev/null
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/ReceiptPaymentServiceImpl.java
@@ -0,0 +1,87 @@
+package com.ruoyi.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.business.dto.ReceiptPaymentDto;
+import com.ruoyi.business.dto.SalesRecordDto;
+import com.ruoyi.business.entity.ReceiptPayment;
+import com.ruoyi.business.entity.SalesRecord;
+import com.ruoyi.business.mapper.ReceiptPaymentMapper;
+import com.ruoyi.business.mapper.SalesRecordMapper;
+import com.ruoyi.business.service.ReceiptPaymentService;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.YearMonth;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+public class ReceiptPaymentServiceImpl extends ServiceImpl<ReceiptPaymentMapper, ReceiptPayment> implements ReceiptPaymentService {
+
+    @Autowired
+    private ReceiptPaymentMapper receiptPaymentMapper;
+    @Autowired
+    private SalesRecordMapper salesRecordMapper;
+
+    /**
+     * 鍥炴鐧昏鏂板
+     * @param receiptPayment
+     * @return
+     */
+    @Override
+    public int receiptPaymentSaveOrUpdate(ReceiptPayment receiptPayment) {
+        SalesRecord salesRecord = salesRecordMapper.selectById(receiptPayment.getSalesRecordId());
+        if (ObjectUtils.isEmpty(salesRecord)){
+            throw new RuntimeException("閿�鍞褰曚笉瀛樺湪");
+        }
+        return receiptPaymentMapper.insert(receiptPayment);
+    }
+
+    /**
+     * 鍥炴鐧昏淇敼
+     * @param receiptPayment
+     * @return
+     */
+    @Override
+    public int receiptPaymentUpdate(ReceiptPayment receiptPayment) {
+        return receiptPaymentMapper.updateById(receiptPayment);
+    }
+
+    /**
+     * 鍥炴鐧昏鍒犻櫎
+     * @param ids
+     * @return
+     */
+    @Override
+    public int receiptPaymentDel(List<Integer> ids) {
+        LambdaQueryWrapper<ReceiptPayment> delQuery = new LambdaQueryWrapper<>();
+        delQuery.in(ReceiptPayment::getId, ids);
+        return receiptPaymentMapper.delete(delQuery);
+    }
+
+    @Override
+    public SalesRecordDto invoiceInfo(Integer id) {
+        return receiptPaymentMapper.invoiceInfo(id);
+    }
+
+    @Override
+    public IPage<ReceiptPaymentDto> receiptPaymentHistoryListPage(Page page, ReceiptPaymentDto receiptPaymentDto) {
+        return receiptPaymentMapper.bindInvoiceNoRegPage(page, receiptPaymentDto);
+    }
+
+    @Override
+    public List<ReceiptPaymentDto> receiptPaymentHistoryListNoPage(ReceiptPaymentDto receiptPaymentDto) {
+        return receiptPaymentMapper.receiptPaymentHistoryListNoPage(receiptPaymentDto);
+    }
+
+}
diff --git a/main-business/src/main/resources/mapper/ReceiptPaymentMapper.xml b/main-business/src/main/resources/mapper/ReceiptPaymentMapper.xml
new file mode 100644
index 0000000..f2ce721
--- /dev/null
+++ b/main-business/src/main/resources/mapper/ReceiptPaymentMapper.xml
@@ -0,0 +1,61 @@
+<?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.business.mapper.ReceiptPaymentMapper">
+
+    <select id="invoiceInfo" resultType="com.ruoyi.business.dto.SalesRecordDto">
+        SELECT
+            T1.*,
+            T3.coal
+        FROM
+            sales_record T1
+        LEFT JOIN customer T2 ON T1.customer_id = T2.id
+        LEFT JOIN coal_info T3 ON T1.coal_id = T3.id
+        WHERE T1.id = #{id}
+    </select>
+    <select id="bindInvoiceNoRegPage" resultType="com.ruoyi.business.dto.ReceiptPaymentDto">
+        SELECT
+            T1.*,
+            T2.customer,
+            T3.coal
+        FROM
+            receipt_payment T1
+        LEFT JOIN sales_record T2 ON T1.sales_record_id = T2.id
+        LEFT JOIN coal_info T3 ON T2.coal_id = T3.id
+        where 1=1
+        <if test="receiptPaymentDto.customer != null and receiptPaymentDto.customer != ''">
+            and T2.customer like concat('%',#{receiptPaymentDto.customer},'%')
+        </if>
+        <if test="receiptPaymentDto.coal != null and receiptPaymentDto.coal != ''">
+            and T3.coal like concat('%',#{receiptPaymentDto.coal},'%')
+        </if>
+        <if test="receiptPaymentDto.receiptPaymentDateStart != null and receiptPaymentDto.receiptPaymentDateEnd != ''">
+            and T1.receipt_payment_date between to_timestamp(#{receiptPaymentDto.receiptPaymentDateStart}, 'yyyy-MM-dd HH24:mi:ss') AND
+            to_timestamp(#{receiptPaymentDto.receiptPaymentDateEnd}, 'yyyy-MM-dd HH24:mi:ss')
+        </if>
+    </select>
+    <select id="receiptPaymentHistoryListNoPage" resultType="com.ruoyi.business.dto.ReceiptPaymentDto">
+        SELECT
+            T1.*,
+            T2.customer,
+            T3.coal
+        FROM
+            receipt_payment T1
+                LEFT JOIN sales_record T2 ON T1.sales_record_id = T2.id
+                LEFT JOIN coal_info T3 ON T2.coal_id = T3.id
+        where 1=1
+        <if test="receiptPaymentDto.customer != null and receiptPaymentDto.customer != ''">
+            and T2.customer like concat('%',#{receiptPaymentDto.customer},'%')
+        </if>
+        <if test="receiptPaymentDto.coal != null and receiptPaymentDto.coal != ''">
+            and T3.coal like concat('%',#{receiptPaymentDto.coal},'%')
+        </if>
+        <if test="receiptPaymentDto.receiptPaymentDateStart != null and receiptPaymentDto.receiptPaymentDateEnd != ''">
+            and T1.receipt_payment_date between to_timestamp(#{receiptPaymentDto.receiptPaymentDateStart}, 'yyyy-MM-dd HH24:mi:ss') AND
+            to_timestamp(#{receiptPaymentDto.receiptPaymentDateEnd}, 'yyyy-MM-dd HH24:mi:ss')
+        </if>
+    </select>
+
+
+</mapper>
\ No newline at end of file

--
Gitblit v1.9.3