jinch пре 1 недеља
родитељ
комит
f840465e61

+ 36 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/controller/admin/report/BankStatementReportController.java

@@ -7,10 +7,13 @@ import com.yc.ship.module.trade.controller.admin.report.vo.BankStatementReportPa
 import com.yc.ship.module.trade.controller.admin.report.vo.BankStatementReportRespVO;
 import com.yc.ship.module.trade.controller.admin.report.vo.BankTransactionDetailsPageReqVO;
 import com.yc.ship.module.trade.controller.admin.report.vo.BankTransactionDetailsRespVO;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditPageReqVO;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditRespVO;
 import com.yc.ship.module.trade.controller.admin.report.vo.IncomeOrderLedgerPageReqVO;
 import com.yc.ship.module.trade.controller.admin.report.vo.IncomeOrderLedgerRespVO;
 import com.yc.ship.module.trade.service.report.BankStatementReportService;
 import com.yc.ship.module.trade.service.report.BankTransactionDetailsService;
+import com.yc.ship.module.trade.service.report.IncomeAuditService;
 import com.yc.ship.module.trade.service.report.IncomeOrderLedgerService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -50,6 +53,9 @@ public class BankStatementReportController {
     @Resource
     private BankTransactionDetailsService bankTransactionDetailsService;
 
+    @Resource
+    private IncomeAuditService incomeAuditService;
+
     /**
      * 查询银行对账报表分页
      *
@@ -146,4 +152,34 @@ public class BankStatementReportController {
         bankTransactionDetailsService.exportBankTransactionDetailsExcel(pageReqVO, response);
     }
 
+    // ==================== 收入稽核表接口 ====================
+
+    /**
+     * 查询收入稽核表分页
+     *
+     * @param pageReqVO 分页查询条件
+     * @return 分页结果
+     */
+    @GetMapping("/income-audit/page")
+    @Operation(summary = "查询收入稽核表分页")
+    public CommonResult<PageResult<IncomeAuditRespVO>> getIncomeAuditPage(@Valid IncomeAuditPageReqVO pageReqVO) {
+        PageResult<IncomeAuditRespVO> pageResult = incomeAuditService.getIncomeAuditPage(pageReqVO);
+        return success(pageResult);
+    }
+
+    /**
+     * 导出收入稽核表 Excel(数字字段导出为数字格式)
+     *
+     * @param pageReqVO 查询条件
+     * @param response  HTTP响应
+     * @throws IOException IO异常
+     */
+    @GetMapping("/income-audit/export-excel")
+    @Operation(summary = "导出收入稽核表 Excel")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIncomeAuditExcel(@Valid IncomeAuditPageReqVO pageReqVO,
+                                       HttpServletResponse response) throws IOException {
+        incomeAuditService.exportIncomeAuditExcel(pageReqVO, response);
+    }
+
 }

+ 28 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/controller/admin/report/vo/IncomeAuditPageReqVO.java

@@ -0,0 +1,28 @@
+package com.yc.ship.module.trade.controller.admin.report.vo;
+
+import com.yc.ship.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+
+import java.util.List;
+
+/**
+ * 收入稽核表分页查询 Request VO
+ *
+ * @author auto-generated
+ */
+@Schema(description = "管理后台 - 收入稽核表分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IncomeAuditPageReqVO extends PageParam {
+
+    @Schema(description = "航次ID列表(多选)", example = "[1, 2, 3]")
+    private List<Long> voyageIds;
+
+    @Schema(description = "组团社", example = "长江国际旅行社")
+    private String travelAgency;
+
+}

+ 40 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/controller/admin/report/vo/IncomeAuditRespVO.java

@@ -0,0 +1,40 @@
+package com.yc.ship.module.trade.controller.admin.report.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.format.NumberFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 收入稽核表 Response VO(同时用于 Excel 导出)
+ *
+ * @author auto-generated
+ */
+@Schema(description = "管理后台 - 收入稽核表 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IncomeAuditRespVO {
+
+    @Schema(description = "组团社", example = "长江国际旅行社")
+    @ExcelProperty("组团社")
+    private String travelAgency;
+
+    @Schema(description = "宜昌-重庆收入", example = "50000.00")
+    @NumberFormat("0.00")
+    @ExcelProperty("宜昌-重庆")
+    private BigDecimal yichangToChongqing;
+
+    @Schema(description = "重庆-宜昌收入", example = "30000.00")
+    @NumberFormat("0.00")
+    @ExcelProperty("重庆-宜昌")
+    private BigDecimal chongqingToYichang;
+
+    @Schema(description = "合计", example = "80000.00")
+    @NumberFormat("0.00")
+    @ExcelProperty("合计")
+    private BigDecimal totalAmount;
+
+}

+ 38 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/dal/mysql/report/IncomeAuditMapper.java

@@ -0,0 +1,38 @@
+package com.yc.ship.module.trade.dal.mysql.report;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditPageReqVO;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditRespVO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 收入稽核表 Mapper
+ *
+ * @author auto-generated
+ */
+@Mapper
+public interface IncomeAuditMapper extends BaseMapperX<IncomeAuditRespVO> {
+
+    /**
+     * 分页查询收入稽核表
+     *
+     * @param page 分页参数
+     * @param vo   查询条件
+     * @return 分页结果
+     */
+    IPage<IncomeAuditRespVO> selectIncomeAuditPage(
+            IPage<IncomeAuditRespVO> page, @Param("vo") IncomeAuditPageReqVO vo);
+
+    /**
+     * 导出查询收入稽核表(不分页,用于 Excel 导出)
+     *
+     * @param vo 查询条件
+     * @return 数据列表
+     */
+    List<IncomeAuditRespVO> selectIncomeAuditExportList(@Param("vo") IncomeAuditPageReqVO vo);
+
+}

+ 34 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/report/IncomeAuditService.java

@@ -0,0 +1,34 @@
+package com.yc.ship.module.trade.service.report;
+
+import com.yc.ship.framework.common.pojo.PageResult;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditPageReqVO;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditRespVO;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * 收入稽核表 Service 接口
+ *
+ * @author auto-generated
+ */
+public interface IncomeAuditService {
+
+    /**
+     * 查询收入稽核表分页
+     *
+     * @param pageReqVO 分页查询条件
+     * @return 分页结果
+     */
+    PageResult<IncomeAuditRespVO> getIncomeAuditPage(IncomeAuditPageReqVO pageReqVO);
+
+    /**
+     * 导出收入稽核表 Excel
+     *
+     * @param pageReqVO 查询条件
+     * @param response  HTTP响应
+     * @throws IOException IO异常
+     */
+    void exportIncomeAuditExcel(IncomeAuditPageReqVO pageReqVO, HttpServletResponse response) throws IOException;
+
+}

+ 99 - 0
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/report/impl/IncomeAuditServiceImpl.java

@@ -0,0 +1,99 @@
+package com.yc.ship.module.trade.service.report.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.yc.ship.framework.common.pojo.PageResult;
+import com.yc.ship.framework.excel.core.util.ExcelUtils;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditPageReqVO;
+import com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditRespVO;
+import com.yc.ship.module.trade.dal.mysql.report.IncomeAuditMapper;
+import com.yc.ship.module.trade.service.report.IncomeAuditService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 收入稽核表 Service 实现类
+ *
+ * @author auto-generated
+ */
+@Service
+@Slf4j
+public class IncomeAuditServiceImpl implements IncomeAuditService {
+
+    @Resource
+    private IncomeAuditMapper incomeAuditMapper;
+
+    /**
+     * 查询收入稽核表分页
+     *
+     * @param pageReqVO 分页查询条件
+     * @return 分页结果
+     */
+    @Override
+    public PageResult<IncomeAuditRespVO> getIncomeAuditPage(IncomeAuditPageReqVO pageReqVO) {
+        IPage<IncomeAuditRespVO> page = incomeAuditMapper.selectIncomeAuditPage(
+                new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
+        return new PageResult<>(page.getRecords(), page.getTotal());
+    }
+
+    /**
+     * 导出收入稽核表 Excel
+     * 数字字段导出为数字格式(通过 @NumberFormat 注解实现)
+     *
+     * @param pageReqVO 查询条件
+     * @param response  HTTP响应
+     * @throws IOException IO异常
+     */
+    @Override
+    public void exportIncomeAuditExcel(IncomeAuditPageReqVO pageReqVO,
+                                       HttpServletResponse response) throws IOException {
+        // 1. 查询所有数据(不分页)
+        List<IncomeAuditRespVO> list = incomeAuditMapper.selectIncomeAuditExportList(pageReqVO);
+        if (CollUtil.isEmpty(list)) {
+            log.warn("[exportIncomeAuditExcel] 无数据可导出");
+        } else {
+            // 2. 计算合计行并追加到列表末尾
+            IncomeAuditRespVO summary = calculateSummary(list);
+            list.add(summary);
+        }
+        // 3. 导出 Excel(数字字段使用 @NumberFormat 注解确保导出为数字格式)
+        ExcelUtils.write(response, "收入稽核表.xls", "收入稽核表", IncomeAuditRespVO.class, list);
+    }
+
+    /**
+     * 计算合计行数据
+     *
+     * @param list 数据列表
+     * @return 合计行
+     */
+    private IncomeAuditRespVO calculateSummary(List<IncomeAuditRespVO> list) {
+        IncomeAuditRespVO summary = new IncomeAuditRespVO();
+        summary.setTravelAgency("合计");
+
+        BigDecimal totalYichangToChongqing = BigDecimal.ZERO;
+        BigDecimal totalChongqingToYichang = BigDecimal.ZERO;
+        BigDecimal totalAmount = BigDecimal.ZERO;
+
+        for (IncomeAuditRespVO item : list) {
+            totalYichangToChongqing = totalYichangToChongqing.add(
+                    item.getYichangToChongqing() != null ? item.getYichangToChongqing() : BigDecimal.ZERO);
+            totalChongqingToYichang = totalChongqingToYichang.add(
+                    item.getChongqingToYichang() != null ? item.getChongqingToYichang() : BigDecimal.ZERO);
+            totalAmount = totalAmount.add(
+                    item.getTotalAmount() != null ? item.getTotalAmount() : BigDecimal.ZERO);
+        }
+
+        summary.setYichangToChongqing(totalYichangToChongqing);
+        summary.setChongqingToYichang(totalChongqingToYichang);
+        summary.setTotalAmount(totalAmount);
+        return summary;
+    }
+
+}

+ 81 - 0
ship-module-trade/ship-module-trade-biz/src/main/resources/mapper/report/IncomeAuditMapper.xml

@@ -0,0 +1,81 @@
+<?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.yc.ship.module.trade.dal.mysql.report.IncomeAuditMapper">
+
+    <!-- 分页查询收入稽核表(按组团社分组,统计不同航向的收入) -->
+    <select id="selectIncomeAuditPage"
+            resultType="com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditRespVO">
+        SELECT
+            t.travel_agency AS travelAgency,
+            IFNULL(SUM(CASE WHEN t.direction = 1 THEN t.income_amount ELSE 0 END), 0) AS yichangToChongqing,
+            IFNULL(SUM(CASE WHEN t.direction != 1 THEN t.income_amount ELSE 0 END), 0) AS chongqingToYichang,
+            IFNULL(SUM(t.income_amount), 0) AS totalAmount
+        FROM (
+            SELECT
+                o.source_name AS travel_agency,
+                r.direction,
+                (o.pay_amount - COALESCE(refund_fee_sum.refundFee, 0)) AS income_amount
+            FROM trade_order o
+            INNER JOIN product_voyage v ON o.voyage_id = v.id AND v.deleted = 0
+            INNER JOIN resource_route r ON v.route_id = r.id AND r.deleted = 0
+            LEFT JOIN (
+                SELECT order_id, SUM(fee) AS refundFee
+                FROM trade_refund
+                WHERE deleted = 0 AND refund_status = 6
+                GROUP BY order_id
+            ) refund_fee_sum ON o.id = refund_fee_sum.order_id
+            WHERE o.deleted = 0
+            <if test="vo.voyageIds != null and vo.voyageIds.size() > 0">
+                AND o.voyage_id IN
+                <foreach collection="vo.voyageIds" item="voyageId" open="(" separator="," close=")">
+                    #{voyageId}
+                </foreach>
+            </if>
+            <if test="vo.travelAgency != null and vo.travelAgency != ''">
+                AND o.source_name LIKE CONCAT('%', #{vo.travelAgency}, '%')
+            </if>
+        ) t
+        WHERE t.travel_agency IS NOT NULL AND t.travel_agency != ''
+        GROUP BY t.travel_agency
+        ORDER BY totalAmount DESC
+    </select>
+
+    <!-- 导出查询(与分页查询条件一致,不分页) -->
+    <select id="selectIncomeAuditExportList"
+            resultType="com.yc.ship.module.trade.controller.admin.report.vo.IncomeAuditRespVO">
+        SELECT
+            t.travel_agency AS travelAgency,
+            IFNULL(SUM(CASE WHEN t.direction = 1 THEN t.income_amount ELSE 0 END), 0) AS yichangToChongqing,
+            IFNULL(SUM(CASE WHEN t.direction != 1 THEN t.income_amount ELSE 0 END), 0) AS chongqingToYichang,
+            IFNULL(SUM(t.income_amount), 0) AS totalAmount
+        FROM (
+            SELECT
+                o.source_name AS travel_agency,
+                r.direction,
+                (o.pay_amount - COALESCE(refund_fee_sum.refundFee, 0)) AS income_amount
+            FROM trade_order o
+            INNER JOIN product_voyage v ON o.voyage_id = v.id AND v.deleted = 0
+            INNER JOIN resource_route r ON v.route_id = r.id AND r.deleted = 0
+            LEFT JOIN (
+                SELECT order_id, SUM(fee) AS refundFee
+                FROM trade_refund
+                WHERE deleted = 0 AND refund_status = 6
+                GROUP BY order_id
+            ) refund_fee_sum ON o.id = refund_fee_sum.order_id
+            WHERE o.deleted = 0
+            <if test="vo.voyageIds != null and vo.voyageIds.size() > 0">
+                AND o.voyage_id IN
+                <foreach collection="vo.voyageIds" item="voyageId" open="(" separator="," close=")">
+                    #{voyageId}
+                </foreach>
+            </if>
+            <if test="vo.travelAgency != null and vo.travelAgency != ''">
+                AND o.source_name LIKE CONCAT('%', #{vo.travelAgency}, '%')
+            </if>
+        ) t
+        WHERE t.travel_agency IS NOT NULL AND t.travel_agency != ''
+        GROUP BY t.travel_agency
+        ORDER BY totalAmount DESC
+    </select>
+
+</mapper>

+ 2 - 2
ship-module-trade/ship-module-trade-biz/src/main/resources/mapper/report/IncomeOrderLedgerMapper.xml

@@ -41,7 +41,7 @@
         LEFT JOIN (
             SELECT order_id, SUM(fee) AS refundFee
             FROM trade_refund
-            WHERE deleted = 0 AND refund_status IN (3)
+            WHERE deleted = 0 AND refund_status = 6
             GROUP BY order_id
         ) refund_fee_sum ON o.id = refund_fee_sum.order_id
         WHERE o.deleted = 0
@@ -115,7 +115,7 @@
         LEFT JOIN (
             SELECT order_id, SUM(fee) AS refundFee
             FROM trade_refund
-            WHERE deleted = 0 AND refund_status IN (3)
+            WHERE deleted = 0 AND refund_status = 6
             GROUP BY order_id
         ) refund_fee_sum ON o.id = refund_fee_sum.order_id
         WHERE o.deleted = 0