|
@@ -0,0 +1,219 @@
|
|
|
|
+<?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.dayou.mapper.FinanceFineMapper">
|
|
|
|
+
|
|
|
|
+ <!-- 通用查询映射结果 -->
|
|
|
|
+ <resultMap id="BaseResultMap" type="com.dayou.entity.FinanceFine">
|
|
|
|
+ <result column="id" property="id" />
|
|
|
|
+ <result column="deleted" property="deleted" />
|
|
|
|
+ <result column="created" property="created" />
|
|
|
|
+ <result column="modified" property="modified" />
|
|
|
|
+ <result column="order_fund_id" property="orderFundId" />
|
|
|
|
+ <result column="production_fund_id" property="productionFundId" />
|
|
|
|
+ <result column="fine_amount" property="fineAmount" />
|
|
|
|
+ <result column="real_fine_amount" property="realFineAmount" />
|
|
|
|
+ <result column="explain" property="explain" />
|
|
|
|
+ <result column="remark" property="remark" />
|
|
|
|
+ <result column="status" property="status" />
|
|
|
|
+ <result column="leader_id" property="leaderId" />
|
|
|
|
+ <result column="confirm_date" property="confirmDate" />
|
|
|
|
+ </resultMap>
|
|
|
|
+
|
|
|
|
+ <!-- 通用查询结果列 -->
|
|
|
|
+ <sql id="Base_Column_List">
|
|
|
|
+ id,
|
|
|
|
+ deleted,
|
|
|
|
+ created,
|
|
|
|
+ modified,
|
|
|
|
+ order_fund_id, production_fund_id, fine_amount, real_fine_amount, explain, remark, status, leader_id, confirm_date
|
|
|
|
+ </sql>
|
|
|
|
+
|
|
|
|
+ <!--分页查询超期罚款-->
|
|
|
|
+ <select id="selectPage" resultType="com.dayou.vo.FinanceFineVO">
|
|
|
|
+ SELECT fine.id AS id,
|
|
|
|
+ oFund.business_type AS businessType,
|
|
|
|
+ oFund.order_id AS orderId,
|
|
|
|
+ oFund.order_name AS orderName,
|
|
|
|
+ (SELECT GROUP_CONCAT(ticket_no SEPARATOR ',')
|
|
|
|
+ FROM finance_invoice
|
|
|
|
+ WHERE finance_invoice.deleted = 0
|
|
|
|
+ AND finance_invoice.order_fund_id = fine.order_fund_id
|
|
|
|
+ AND IF(fine.production_fund_id IS NOT NULL, finance_invoice.production_fund_id = fine.production_fund_id, TRUE)
|
|
|
|
+ ) AS invoiceNo,
|
|
|
|
+ <if test="dto != null and dto.businessType == 'ASSET_BUSINESS' or dto.businessType == 'MAJOR_BUSINESS'">
|
|
|
|
+ pFund.production_no AS productionNo,
|
|
|
|
+ pFund.production_type AS productionType,
|
|
|
|
+ pFund.production_should_amount AS shouldAmount,
|
|
|
|
+ pFund.standard_amount AS standardAmount,
|
|
|
|
+ `order`.bailor AS bailor,
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
|
|
|
|
+ oFund.should_amount AS shouldAmount,
|
|
|
|
+ CONCAT(`order`.bailorA, IF(`order`.bailorB IS NOT NULL AND `order`.bailorB != '', ',', ''), `order`.bailorB) AS bailor,
|
|
|
|
+ </if>
|
|
|
|
+ user.name AS clientManagerName,
|
|
|
|
+ DATEDIFF(CURDATE(), DATE( pro.repertory_out_time )) AS overdueDay,
|
|
|
|
+ customer.name AS customerName,
|
|
|
|
+ subCustomer.name AS customerSubName,
|
|
|
|
+ fine.fine_amount AS fineAmount,
|
|
|
|
+ fine.real_fine_amount AS realFineAmount,
|
|
|
|
+ fine.status AS status,
|
|
|
|
+ fine.created AS punishDate,
|
|
|
|
+ fine.`explain` AS `explain`
|
|
|
|
+ FROM finance_fine AS fine
|
|
|
|
+ LEFT JOIN order_fund AS oFund ON oFund.deleted = 0 AND fine.order_fund_id = oFund.id
|
|
|
|
+ <if test="dto != null and dto.businessType == 'ASSET_BUSINESS'">
|
|
|
|
+ LEFT JOIN production_fund AS pFund ON pFund.deleted = 0 AND fine.production_fund_id = pFund.id
|
|
|
|
+ LEFT JOIN ( SELECT business_id, production_no, repertory_out_time FROM assets_production WHERE deleted = 0 AND repertory_out_time IS NOT NULL AND production_type != 'STATEMENT') AS pro
|
|
|
|
+ ON pFund.business_id = pro.business_id AND pFund.production_no = pro.production_no
|
|
|
|
+ LEFT JOIN assets AS `order` ON `order`.deleted = 0 AND `order`.id = pFund.business_id
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto != null and dto.businessType == 'MAJOR_BUSINESS'">
|
|
|
|
+ LEFT JOIN production_fund AS pFund ON pFund.deleted = 0 AND fine.production_fund_id = pFund.id
|
|
|
|
+ LEFT JOIN ( SELECT major_id AS business_id, report_no AS production_no, repertory_out_time, production FROM major_production WHERE deleted = 0 AND repertory_out_time IS NOT NULL) AS pro
|
|
|
|
+ ON pFund.business_id = pro.business_id AND pFund.production_no = pro.production_no AND production = pFund.production_type
|
|
|
|
+ LEFT JOIN major AS `order` ON `order`.deleted = 0 AND `order`.id = pFund.business_id
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto != null and dto.businessType == 'PERSONAL_BUSINESS'">
|
|
|
|
+ LEFT JOIN personal_target pt ON pt.personal_id = oFund.business_id
|
|
|
|
+ LEFT JOIN ( SELECT target_id,repertory_out_time, production FROM personal_production WHERE repertory_out_time IS NOT NULL GROUP BY target_id ) AS pro ON pro.target_id = pt.id
|
|
|
|
+ LEFT JOIN personal AS `order` ON `order`.deleted = 0 AND `order`.id = oFund.business_id
|
|
|
|
+ </if>
|
|
|
|
+ LEFT JOIN customer_company AS customer ON customer.id = `order`.clientele_id
|
|
|
|
+ LEFT JOIN customer_company AS subCustomer ON subCustomer.id = `order`.clientele_sub_id
|
|
|
|
+ LEFT JOIN user ON `order`.client_manager_id = user.id AND user.deleted = 0
|
|
|
|
+ WHERE oFund.business_type = #{dto.businessType}
|
|
|
|
+ <if test="dto != null and dto.keyWord != null and dto.keyWord != ''">
|
|
|
|
+ AND (`order`.order_id LIKE CONCAT('%', #{dto.keyWord},'%')
|
|
|
|
+ <if test="dto != null and dto.businessType == 'ASSET_BUSINESS' or dto.businessType == 'MAJOR_BUSINESS'">
|
|
|
|
+ OR pFund.production_no LIKE CONCAT('%', #{dto.keyWord},'%')
|
|
|
|
+ </if>
|
|
|
|
+ )
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto != null and dto.invoiceNo != null and dto.invoiceNo != ''">
|
|
|
|
+ AND (SELECT GROUP_CONCAT(ticket_no SEPARATOR ',')
|
|
|
|
+ FROM finance_invoice
|
|
|
|
+ WHERE finance_invoice.deleted = 0
|
|
|
|
+ AND finance_invoice.order_fund_id = fine.order_fund_id
|
|
|
|
+ AND ticket_no LIKE CONCAT('%', #{dto.invoiceNo} ,'%')
|
|
|
|
+ AND IF(fine.production_fund_id IS NOT NULL, finance_invoice.production_fund_id = fine.production_fund_id, TRUE)
|
|
|
|
+ ) IS NOT NULL
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto != null and dto.clientManagerName != null and dto.clientManagerName != ''">
|
|
|
|
+ AND user.name = #{dto.clientManagerName}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto != null and dto.status != null">
|
|
|
|
+ AND fine.status = #{dto.status}
|
|
|
|
+ </if>
|
|
|
|
+ <if test="dto != null and dto.startPunishDate != null and dto.endPunishDate!= null">
|
|
|
|
+ AND fine.created BETWEEN #{dto.startPunishDate} AND #{dto.endPunishDate}
|
|
|
|
+ </if>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <!--获取逾期资产产品款项信息-->
|
|
|
|
+ <select id="getAssetsOrder" resultType="com.dayou.vo.CompileFineAssetsOrder">
|
|
|
|
+ SELECT
|
|
|
|
+ `of`.id AS orderFundId,
|
|
|
|
+ pf.id AS productionFundId,
|
|
|
|
+ pf.production_should_amount,
|
|
|
|
+ pf.standard_amount
|
|
|
|
+ FROM
|
|
|
|
+ (
|
|
|
|
+ SELECT
|
|
|
|
+ id,
|
|
|
|
+ business_id,
|
|
|
|
+ production_no,
|
|
|
|
+ production_type,
|
|
|
|
+ evaluate_amount,
|
|
|
|
+ repertory_out_time
|
|
|
|
+ FROM
|
|
|
|
+ assets_production AS ap
|
|
|
|
+ WHERE
|
|
|
|
+ deleted = 0
|
|
|
|
+ AND repertory_out_time IS NOT NULL
|
|
|
|
+ AND production_type != 'STATEMENT'
|
|
|
|
+ ) AS ap
|
|
|
|
+ LEFT JOIN ( SELECT id, business_id, production_no, production_should_amount, real_amount, standard_amount FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) AS pf ON ( ap.business_id = pf.business_id AND ap.production_no = pf.production_no )
|
|
|
|
+ LEFT JOIN ( SELECT id, business_id, should_amount FROM order_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) AS `of` ON `of`.business_id = ap.business_id
|
|
|
|
+ LEFT JOIN assets AS a ON a.id = ap.business_id
|
|
|
|
+ LEFT JOIN finance_fine AS ff ON ff.deleted = 0 AND `of`.id = ff.order_fund_id AND pf.id = ff.production_fund_id
|
|
|
|
+ WHERE ( pf.production_no IS NULL OR pf.real_amount IS NULL )
|
|
|
|
+ AND ap.repertory_out_time > '2024-01-01 00:00:00'
|
|
|
|
+ AND DATEDIFF(CURDATE(), DATE( ap.repertory_out_time )) >= 90
|
|
|
|
+ AND ff.id IS NULL
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <!--获取逾期个贷产品款项信息-->
|
|
|
|
+ <select id="getPersonalOrder" resultType="java.lang.Long">
|
|
|
|
+ SELECT
|
|
|
|
+ ofu.id
|
|
|
|
+ FROM
|
|
|
|
+ ( SELECT id, order_id FROM personal WHERE deleted = 0 ) AS p
|
|
|
|
+ INNER JOIN personal_target pt ON pt.personal_id = p.id
|
|
|
|
+ INNER JOIN ( SELECT id, business_id FROM order_fund WHERE business_type = 'PERSONAL_BUSINESS' AND deleted = 0 AND real_amount IS NULL ) AS ofu ON ofu.business_id = p.id
|
|
|
|
+ INNER JOIN ( SELECT target_id,( repertory_out_time ) AS rot,production FROM personal_production WHERE repertory_out_time IS NOT NULL GROUP BY target_id ) AS pp ON pp.target_id = pt.id
|
|
|
|
+ LEFT JOIN finance_fine AS ff ON ff.deleted = 0 AND ofu.id = ff.order_fund_id
|
|
|
|
+ WHERE pp.rot > '2024-01-01 00:00:00'
|
|
|
|
+ AND DATEDIFF(CURDATE(), DATE( pp.rot )) >= 90
|
|
|
|
+ AND ff.id IS NULL
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <!--获取逾期大中型产品款项信息-->
|
|
|
|
+ <select id="getMajorOrder" resultType="com.dayou.vo.CompileFineMajorOrder">
|
|
|
|
+ SELECT
|
|
|
|
+ pf.id AS productionFundId,
|
|
|
|
+ pf.order_fund_id AS orderFundId,
|
|
|
|
+ pf.production_should_amount AS shouldAmount,
|
|
|
|
+ pf.standard_amount
|
|
|
|
+ FROM
|
|
|
|
+ (
|
|
|
|
+ SELECT
|
|
|
|
+ id,
|
|
|
|
+ business_id,
|
|
|
|
+ production_no,
|
|
|
|
+ production_type,
|
|
|
|
+ production_should_amount,
|
|
|
|
+ standard_amount,
|
|
|
|
+ order_fund_id
|
|
|
|
+ FROM
|
|
|
|
+ production_fund
|
|
|
|
+ WHERE
|
|
|
|
+ business_type = 'MAJOR_BUSINESS'
|
|
|
|
+ AND deleted = 0
|
|
|
|
+ AND production_should_amount IS NOT NULL
|
|
|
|
+ AND production_should_amount != 0
|
|
|
|
+ AND real_amount IS NULL
|
|
|
|
+ ) AS pf
|
|
|
|
+ INNER JOIN (
|
|
|
|
+ SELECT
|
|
|
|
+ id,
|
|
|
|
+ major_id,
|
|
|
|
+ report_no,
|
|
|
|
+ production AS productionType,
|
|
|
|
+ repertory_out_time
|
|
|
|
+ FROM
|
|
|
|
+ major_production mp
|
|
|
|
+ WHERE
|
|
|
|
+ deleted = 0
|
|
|
|
+ AND repertory_out_time IS NOT NULL
|
|
|
|
+ ) AS mp ON ( mp.major_id = pf.business_id AND mp.report_no = pf.production_no AND mp.productionType = pf.production_type )
|
|
|
|
+ LEFT JOIN major AS m ON m.id = mp.major_id
|
|
|
|
+ LEFT JOIN finance_fine AS ff ON ff.deleted = 0 AND pf.order_fund_id = ff.order_fund_id AND pf.id = ff.production_fund_id
|
|
|
|
+ WHERE mp.repertory_out_time > '2024-01-01 00:00:00'
|
|
|
|
+ AND DATEDIFF(CURDATE(), DATE( mp.repertory_out_time )) >= 90
|
|
|
|
+ AND ff.id IS NULL
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <!--根据收款信息获取符合条件的实际开票金额-->
|
|
|
|
+ <select id="getInvoiceByFundInfo" resultType="java.math.BigDecimal">
|
|
|
|
+ SELECT SUM(real_amount) * 0.05
|
|
|
|
+ FROM finance_invoice
|
|
|
|
+ WHERE deleted = 0
|
|
|
|
+ AND state = '已开票'
|
|
|
|
+ AND order_fund_id = #{orderFundId}
|
|
|
|
+ <if test="productionFundId != null">
|
|
|
|
+ AND production_fund_id = #{productionFundId}
|
|
|
|
+ </if>
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+</mapper>
|