Files
aida_back/src/main/resources/mapper/primary/PaymentInfoMapper.xml

135 lines
4.4 KiB
XML
Raw Normal View History

2024-12-16 10:26:02 +08:00
<?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.ai.da.mapper.primary.PaymentInfoMapper">
<select id="selectPageOrderList" resultType="com.ai.da.model.vo.OrderListVO">
SELECT
p.id AS id,
p.payer_total AS amount,
p.payment_type AS paymentMethod,
p.trade_state AS state,
o.title AS orderType,
p.hosted_invoice_url AS invoiceLink,
p.create_time
FROM
`t_payment_info` p
LEFT JOIN
`t_order_info` o
ON
p.order_no = o.order_no
WHERE
o.account_id = #{accountId}
2024-12-19 13:56:17 +08:00
<if test="id !=null and id gt 0">
AND p.id = #{id}
</if>
2024-12-16 10:26:02 +08:00
AND p.create_time BETWEEN #{startTime} AND #{endTime}
ORDER BY
p.id DESC
LIMIT #{pageSize} OFFSET #{offset};
</select>
<select id="queryOrderListTotalCount" parameterType="map" resultType="int">
SELECT
COUNT(*)
FROM
`t_payment_info` p
LEFT JOIN
`t_order_info` o
ON
p.order_no = o.order_no
WHERE
o.account_id = #{accountId}
2024-12-19 13:56:17 +08:00
<if test="id !=null and id gt 0">
AND p.id = #{id}
</if>
2024-12-16 10:26:02 +08:00
AND p.create_time BETWEEN #{startTime} AND #{endTime};
</select>
2025-01-10 13:27:27 +08:00
<select id="queryPaymentInfo" resultType="com.ai.da.model.vo.PaymentInfoVO">
SELECT
id,
payment_type platform,
payer_total,
type,
payment_method,
last4,
country,
city,
create_time,
CASE
WHEN trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') THEN 'Success'
WHEN trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') THEN 'Fail'
ELSE 'Pending'
END AS status
FROM
t_payment_info
WHERE
1 = 1
<if test="paymentType != null and paymentType != ''">
AND payment_type = #{paymentType}
</if>
<if test="payerTotal != null and payerTotal != ''">
AND payer_total = #{payerTotal}
</if>
<if test="type != null and type != ''">
AND type = #{type}
</if>
<if test="status != null and status != ''">
AND
CASE
WHEN trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') THEN 'Success'
WHEN trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') THEN 'Fail'
ELSE 'Pending'
END = #{status}
</if>
<if test="country != null and country != ''">
AND country = #{country}
</if>
<if test="city != null and city != ''">
AND city = #{city}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND create_time BETWEEN #{startTime} AND #{endTime}
</if>
ORDER BY
id DESC
LIMIT ${limit} OFFSET ${offset}
</select>
<select id="queryPaymentInfoCount" resultType="java.lang.Long">
SELECT
COUNT(*)
FROM
t_payment_info
WHERE
1 = 1
<if test="paymentType != null and paymentType != ''">
AND payment_type = #{paymentType}
</if>
<if test="payerTotal != null and payerTotal != ''">
AND payer_total = #{payerTotal}
</if>
<if test="type != null and type != ''">
AND type = #{type}
</if>
<if test="status != null and status != ''">
AND
CASE
WHEN trade_state IN ('paid', 'COMPLETED', 'complete', 'liquidated') THEN 'Success'
WHEN trade_state IN ('failed', 'expired', 'VOIDED', 'void', 'uncollectible') THEN 'Fail'
ELSE 'Pending'
END = #{status}
</if>
<if test="country != null and country != ''">
AND country = #{country}
</if>
<if test="city != null and city != ''">
AND city = #{city}
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND create_time BETWEEN #{startTime} AND #{endTime}
</if>
</select>
2024-12-16 10:26:02 +08:00
</mapper>