blob: 5c93b35964a582efc2f32ff5f4f9ee53a3ccf089 [file] [log] [blame]
<?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.web.controller.post.mapper.PostPaymentMapper">
<resultMap type="com.ruoyi.web.controller.post.domain.PostPayment" id="PostPaymentResult">
<id property="paymentId" column="payment_id" />
<result property="postId" column="post_id" />
<result property="planId" column="plan_id" />
<result property="userId" column="user_id" />
<result property="amount" column="amount" />
<result property="paymentStatus" column="payment_status" />
<result property="paymentTime" column="payment_time" />
</resultMap>
<sql id="selectPostPaymentVo">
select payment_id, post_id, plan_id, user_id, amount, payment_status, payment_time
from post_payment
</sql>
<select id="selectPostPaymentList" parameterType="com.ruoyi.web.controller.post.domain.PostPayment" resultMap="PostPaymentResult">
<include refid="selectPostPaymentVo"/>
<where>
<if test="postId != null">
AND post_id = #{postId}
</if>
<if test="planId != null">
AND plan_id = #{planId}
</if>
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="paymentStatus != null and paymentStatus != ''">
AND payment_status = #{paymentStatus}
</if>
</where>
order by payment_time desc
</select>
<select id="selectPostPaymentById" parameterType="Long" resultMap="PostPaymentResult">
<include refid="selectPostPaymentVo"/>
where payment_id = #{paymentId}
</select>
<select id="selectLatestPaymentByPostId" parameterType="Long" resultMap="PostPaymentResult">
<include refid="selectPostPaymentVo"/>
where post_id = #{postId} and payment_status = 'paid'
order by payment_time desc
limit 1
</select>
<select id="selectExpiredPromotionPayments" resultMap="PostPaymentResult">
<include refid="selectPostPaymentVo"/>
where payment_status = 'paid'
and post_id in (
select post_id from post where promotion_plan_id is not null
)
order by payment_time desc
</select>
<insert id="insertPostPayment" parameterType="com.ruoyi.web.controller.post.domain.PostPayment" useGeneratedKeys="true" keyProperty="paymentId">
insert into post_payment (
post_id,
plan_id,
user_id,
amount,
payment_status,
payment_time
) values (
#{postId},
#{planId},
#{userId},
#{amount},
#{paymentStatus},
#{paymentTime}
)
</insert>
<update id="updatePostPayment" parameterType="com.ruoyi.web.controller.post.domain.PostPayment">
update post_payment
<set>
<if test="postId != null">post_id = #{postId},</if>
<if test="planId != null">plan_id = #{planId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="paymentStatus != null and paymentStatus != ''">payment_status = #{paymentStatus},</if>
<if test="paymentTime != null">payment_time = #{paymentTime},</if>
</set>
where payment_id = #{paymentId}
</update>
<delete id="deletePostPaymentById" parameterType="Long">
delete from post_payment where payment_id = #{paymentId}
</delete>
<delete id="deletePostPaymentByIds" parameterType="Long">
delete from post_payment where payment_id in
<foreach collection="array" item="paymentId" open="(" separator="," close=")">
#{paymentId}
</foreach>
</delete>
<delete id="deletePostPaymentByPostId" parameterType="Long">
delete from post_payment where post_id = #{postId}
</delete>
</mapper>