meisiyu | c98fc52 | 2025-06-02 20:33:40 +0800 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <!DOCTYPE mapper |
| 3 | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 4 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 5 | <mapper namespace="com.ruoyi.web.controller.post.mapper.PostPaymentMapper"> |
| 6 | |
| 7 | <resultMap type="com.ruoyi.web.controller.post.domain.PostPayment" id="PostPaymentResult"> |
| 8 | <id property="paymentId" column="payment_id" /> |
| 9 | <result property="postId" column="post_id" /> |
| 10 | <result property="planId" column="plan_id" /> |
| 11 | <result property="userId" column="user_id" /> |
| 12 | <result property="amount" column="amount" /> |
| 13 | <result property="paymentStatus" column="payment_status" /> |
| 14 | <result property="paymentTime" column="payment_time" /> |
| 15 | </resultMap> |
| 16 | |
| 17 | <sql id="selectPostPaymentVo"> |
| 18 | select payment_id, post_id, plan_id, user_id, amount, payment_status, payment_time |
| 19 | from post_payment |
| 20 | </sql> |
| 21 | |
| 22 | <select id="selectPostPaymentList" parameterType="com.ruoyi.web.controller.post.domain.PostPayment" resultMap="PostPaymentResult"> |
| 23 | <include refid="selectPostPaymentVo"/> |
| 24 | <where> |
| 25 | <if test="postId != null"> |
| 26 | AND post_id = #{postId} |
| 27 | </if> |
| 28 | <if test="planId != null"> |
| 29 | AND plan_id = #{planId} |
| 30 | </if> |
| 31 | <if test="userId != null"> |
| 32 | AND user_id = #{userId} |
| 33 | </if> |
| 34 | <if test="paymentStatus != null and paymentStatus != ''"> |
| 35 | AND payment_status = #{paymentStatus} |
| 36 | </if> |
| 37 | </where> |
| 38 | order by payment_time desc |
| 39 | </select> |
| 40 | |
| 41 | <select id="selectPostPaymentById" parameterType="Long" resultMap="PostPaymentResult"> |
| 42 | <include refid="selectPostPaymentVo"/> |
| 43 | where payment_id = #{paymentId} |
| 44 | </select> |
| 45 | |
| 46 | <select id="selectLatestPaymentByPostId" parameterType="Long" resultMap="PostPaymentResult"> |
| 47 | <include refid="selectPostPaymentVo"/> |
| 48 | where post_id = #{postId} and payment_status = 'paid' |
| 49 | order by payment_time desc |
| 50 | limit 1 |
| 51 | </select> |
| 52 | |
| 53 | <select id="selectExpiredPromotionPayments" resultMap="PostPaymentResult"> |
| 54 | <include refid="selectPostPaymentVo"/> |
| 55 | where payment_status = 'paid' |
| 56 | and post_id in ( |
| 57 | select post_id from post where promotion_plan_id is not null |
| 58 | ) |
| 59 | order by payment_time desc |
| 60 | </select> |
| 61 | |
| 62 | <insert id="insertPostPayment" parameterType="com.ruoyi.web.controller.post.domain.PostPayment" useGeneratedKeys="true" keyProperty="paymentId"> |
| 63 | insert into post_payment ( |
| 64 | post_id, |
| 65 | plan_id, |
| 66 | user_id, |
| 67 | amount, |
| 68 | payment_status, |
| 69 | payment_time |
| 70 | ) values ( |
| 71 | #{postId}, |
| 72 | #{planId}, |
| 73 | #{userId}, |
| 74 | #{amount}, |
| 75 | #{paymentStatus}, |
| 76 | #{paymentTime} |
| 77 | ) |
| 78 | </insert> |
| 79 | |
| 80 | <update id="updatePostPayment" parameterType="com.ruoyi.web.controller.post.domain.PostPayment"> |
| 81 | update post_payment |
| 82 | <set> |
| 83 | <if test="postId != null">post_id = #{postId},</if> |
| 84 | <if test="planId != null">plan_id = #{planId},</if> |
| 85 | <if test="userId != null">user_id = #{userId},</if> |
| 86 | <if test="amount != null">amount = #{amount},</if> |
| 87 | <if test="paymentStatus != null and paymentStatus != ''">payment_status = #{paymentStatus},</if> |
| 88 | <if test="paymentTime != null">payment_time = #{paymentTime},</if> |
| 89 | </set> |
| 90 | where payment_id = #{paymentId} |
| 91 | </update> |
| 92 | |
| 93 | <delete id="deletePostPaymentById" parameterType="Long"> |
| 94 | delete from post_payment where payment_id = #{paymentId} |
| 95 | </delete> |
| 96 | |
| 97 | <delete id="deletePostPaymentByIds" parameterType="Long"> |
| 98 | delete from post_payment where payment_id in |
| 99 | <foreach collection="array" item="paymentId" open="(" separator="," close=")"> |
| 100 | #{paymentId} |
| 101 | </foreach> |
| 102 | </delete> |
| 103 | |
meisiyu | 4fb2fb9 | 2025-06-05 22:53:26 +0800 | [diff] [blame^] | 104 | <delete id="deletePostPaymentByPostId" parameterType="Long"> |
| 105 | delete from post_payment where post_id = #{postId} |
| 106 | </delete> |
| 107 | |
meisiyu | c98fc52 | 2025-06-02 20:33:40 +0800 | [diff] [blame] | 108 | </mapper> |