|
|
@@ -0,0 +1,173 @@
|
|
|
+<?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.PrepaidRechargeLedgerMapper">
|
|
|
+
|
|
|
+ <!-- 分页查询预存款充值流水 -->
|
|
|
+ <!-- 业务说明:
|
|
|
+ 1. 后台充值(recharge_mode=1): ota_distributor_recharge + ota_trade_log 关联,支付方式固定为"后台充值"
|
|
|
+ 2. 自助充值(在线支付): ota_distributor_self_recharge + ota_trade_log 关联,支付方式来自 pay_type 字段
|
|
|
+ 3. 使用 UNION ALL 合并两种充值类型,提升查询性能
|
|
|
+ 支付方式筛选值:1-后台充值 2-微信 3-支付宝 4-云闪付 5-银行卡
|
|
|
+ -->
|
|
|
+ <select id="selectPrepaidRechargeLedgerPage"
|
|
|
+ resultType="com.yc.ship.module.trade.controller.admin.report.vo.PrepaidRechargeLedgerRespVO">
|
|
|
+ <!-- 后台充值:recharge_mode=1,通过 ota_distributor_recharge.recharge_log_id 关联 ota_trade_log.id -->
|
|
|
+ SELECT
|
|
|
+ r.id,
|
|
|
+ DATE_FORMAT(tl.trade_time, '%Y/%m/%d %H:%i:%s') AS rechargeDate,
|
|
|
+ d.name AS travelAgency,
|
|
|
+ '后台充值' AS paymentTypeName,
|
|
|
+ r.money AS amount,
|
|
|
+ r.apply_remark AS remark,
|
|
|
+ tl.trade_time AS sort_time
|
|
|
+ FROM ota_distributor_recharge r
|
|
|
+ INNER JOIN ota_distributor d ON r.distributor_id = d.id AND d.deleted = 0
|
|
|
+ INNER JOIN ota_trade_log tl ON r.recharge_log_id = tl.id AND tl.deleted = 0 AND tl.trade_type = 1
|
|
|
+ WHERE r.deleted = 0
|
|
|
+ AND r.status = 1
|
|
|
+ <if test="vo.rechargeDateStart != null">
|
|
|
+ AND DATE(tl.trade_time) >= #{vo.rechargeDateStart}
|
|
|
+ </if>
|
|
|
+ <if test="vo.rechargeDateEnd != null">
|
|
|
+ AND DATE(tl.trade_time) <= #{vo.rechargeDateEnd}
|
|
|
+ </if>
|
|
|
+ <if test="vo.travelAgency != null and vo.travelAgency != ''">
|
|
|
+ AND d.name LIKE CONCAT('%', #{vo.travelAgency}, '%')
|
|
|
+ </if>
|
|
|
+ <!-- 支付方式筛选:1-后台充值 -->
|
|
|
+ <if test="vo.paymentType != null and vo.paymentType != 1">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ UNION ALL
|
|
|
+ <!-- 自助充值:通过 ota_distributor_self_recharge.id 关联 ota_trade_log.order_id -->
|
|
|
+ SELECT
|
|
|
+ sr.id,
|
|
|
+ DATE_FORMAT(tl.trade_time, '%Y/%m/%d %H:%i:%s') AS rechargeDate,
|
|
|
+ d.name AS travelAgency,
|
|
|
+ CASE sr.pay_type
|
|
|
+ WHEN 1 THEN '微信'
|
|
|
+ WHEN 2 THEN '支付宝'
|
|
|
+ WHEN 3 THEN '云闪付'
|
|
|
+ WHEN 9 THEN '对公转账'
|
|
|
+ ELSE '其他'
|
|
|
+ END AS paymentTypeName,
|
|
|
+ sr.money AS amount,
|
|
|
+ NULL AS remark,
|
|
|
+ tl.trade_time AS sort_time
|
|
|
+ FROM ota_distributor_self_recharge sr
|
|
|
+ INNER JOIN ota_distributor d ON sr.distributor_id = d.id AND d.deleted = 0
|
|
|
+ INNER JOIN ota_trade_log tl ON tl.order_id = CAST(sr.id AS CHAR) AND tl.deleted = 0 AND tl.trade_type = 11
|
|
|
+ WHERE sr.deleted = 0
|
|
|
+ AND sr.recharge_state = 1
|
|
|
+ <if test="vo.rechargeDateStart != null">
|
|
|
+ AND DATE(tl.trade_time) >= #{vo.rechargeDateStart}
|
|
|
+ </if>
|
|
|
+ <if test="vo.rechargeDateEnd != null">
|
|
|
+ AND DATE(tl.trade_time) <= #{vo.rechargeDateEnd}
|
|
|
+ </if>
|
|
|
+ <if test="vo.travelAgency != null and vo.travelAgency != ''">
|
|
|
+ AND d.name LIKE CONCAT('%', #{vo.travelAgency}, '%')
|
|
|
+ </if>
|
|
|
+ <!-- 支付方式筛选:2-微信 3-支付宝 4-云闪付 5-对公转账 -->
|
|
|
+ <if test="vo.paymentType != null">
|
|
|
+ <if test="vo.paymentType == 2">
|
|
|
+ AND sr.pay_type = 1
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 3">
|
|
|
+ AND sr.pay_type = 2
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 4">
|
|
|
+ AND sr.pay_type = 3
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 5">
|
|
|
+ AND sr.pay_type = 9
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 1">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ ORDER BY sort_time DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 导出查询(与分页查询条件一致,不分页) -->
|
|
|
+ <select id="selectPrepaidRechargeLedgerExportList"
|
|
|
+ resultType="com.yc.ship.module.trade.controller.admin.report.vo.PrepaidRechargeLedgerRespVO">
|
|
|
+ <!-- 后台充值:通过 ota_distributor_recharge.recharge_log_id 关联 ota_trade_log.id -->
|
|
|
+ SELECT
|
|
|
+ r.id,
|
|
|
+ DATE_FORMAT(tl.trade_time, '%Y/%m/%d %H:%i:%s') AS rechargeDate,
|
|
|
+ d.name AS travelAgency,
|
|
|
+ '后台充值' AS paymentTypeName,
|
|
|
+ r.money AS amount,
|
|
|
+ r.apply_remark AS remark,
|
|
|
+ tl.trade_time AS sort_time
|
|
|
+ FROM ota_distributor_recharge r
|
|
|
+ INNER JOIN ota_distributor d ON r.distributor_id = d.id AND d.deleted = 0
|
|
|
+ INNER JOIN ota_trade_log tl ON r.recharge_log_id = tl.id AND tl.deleted = 0 AND tl.trade_type = 1
|
|
|
+ WHERE r.deleted = 0
|
|
|
+ AND r.status = 1
|
|
|
+ <if test="vo.rechargeDateStart != null">
|
|
|
+ AND DATE(tl.trade_time) >= #{vo.rechargeDateStart}
|
|
|
+ </if>
|
|
|
+ <if test="vo.rechargeDateEnd != null">
|
|
|
+ AND DATE(tl.trade_time) <= #{vo.rechargeDateEnd}
|
|
|
+ </if>
|
|
|
+ <if test="vo.travelAgency != null and vo.travelAgency != ''">
|
|
|
+ AND d.name LIKE CONCAT('%', #{vo.travelAgency}, '%')
|
|
|
+ </if>
|
|
|
+ <!-- 支付方式筛选:1-后台充值 -->
|
|
|
+ <if test="vo.paymentType != null and vo.paymentType != 1">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ UNION ALL
|
|
|
+ <!-- 自助充值:通过 ota_distributor_self_recharge.id 关联 ota_trade_log.order_id -->
|
|
|
+ SELECT
|
|
|
+ sr.id,
|
|
|
+ DATE_FORMAT(tl.trade_time, '%Y/%m/%d %H:%i:%s') AS rechargeDate,
|
|
|
+ d.name AS travelAgency,
|
|
|
+ CASE sr.pay_type
|
|
|
+ WHEN 1 THEN '微信'
|
|
|
+ WHEN 2 THEN '支付宝'
|
|
|
+ WHEN 3 THEN '云闪付'
|
|
|
+ WHEN 9 THEN '对公转账'
|
|
|
+ ELSE '其他'
|
|
|
+ END AS paymentTypeName,
|
|
|
+ sr.money AS amount,
|
|
|
+ NULL AS remark,
|
|
|
+ tl.trade_time AS sort_time
|
|
|
+ FROM ota_distributor_self_recharge sr
|
|
|
+ INNER JOIN ota_distributor d ON sr.distributor_id = d.id AND d.deleted = 0
|
|
|
+ INNER JOIN ota_trade_log tl ON tl.order_id = CAST(sr.id AS CHAR) AND tl.deleted = 0 AND tl.trade_type = 11
|
|
|
+ WHERE sr.deleted = 0
|
|
|
+ AND sr.recharge_state = 1
|
|
|
+ <if test="vo.rechargeDateStart != null">
|
|
|
+ AND DATE(tl.trade_time) >= #{vo.rechargeDateStart}
|
|
|
+ </if>
|
|
|
+ <if test="vo.rechargeDateEnd != null">
|
|
|
+ AND DATE(tl.trade_time) <= #{vo.rechargeDateEnd}
|
|
|
+ </if>
|
|
|
+ <if test="vo.travelAgency != null and vo.travelAgency != ''">
|
|
|
+ AND d.name LIKE CONCAT('%', #{vo.travelAgency}, '%')
|
|
|
+ </if>
|
|
|
+ <!-- 支付方式筛选:2-微信 3-支付宝 4-云闪付 5-对公转账 -->
|
|
|
+ <if test="vo.paymentType != null">
|
|
|
+ <if test="vo.paymentType == 2">
|
|
|
+ AND sr.pay_type = 1
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 3">
|
|
|
+ AND sr.pay_type = 2
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 4">
|
|
|
+ AND sr.pay_type = 3
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 5">
|
|
|
+ AND sr.pay_type = 9
|
|
|
+ </if>
|
|
|
+ <if test="vo.paymentType == 1">
|
|
|
+ AND 1=0
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ ORDER BY sort_time DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|