<?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.member.mapper.coupon.CouponTotalMapper">
|
|
<resultMap type="CouponTotal" id="CouponTotalResult">
|
<result property="couponId" column="coupon_id" />
|
<result property="sendCount" column="send_count" />
|
<result property="sendUserCount" column="send_user_count" />
|
</resultMap>
|
|
<sql id="selectCouponTotalVo">
|
select coupon_id, send_count, send_user_count from t_coupon_total
|
</sql>
|
|
<select id="selectCouponTotalList" parameterType="CouponTotal" resultMap="CouponTotalResult">
|
<include refid="selectCouponTotalVo"/>
|
<where>
|
<if test="sendCount != null "> and send_count = #{sendCount}</if>
|
<if test="sendUserCount != null "> and send_user_count = #{sendUserCount}</if>
|
</where>
|
</select>
|
|
<select id="selectCouponTotalByCouponId" parameterType="String" resultMap="CouponTotalResult">
|
<include refid="selectCouponTotalVo"/>
|
where coupon_id = #{couponId}
|
</select>
|
|
<insert id="insertCouponTotal" parameterType="CouponTotal">
|
insert into t_coupon_total
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="couponId != null">coupon_id,</if>
|
<if test="sendCount != null">send_count,</if>
|
<if test="sendUserCount != null">send_user_count,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="couponId != null">#{couponId},</if>
|
<if test="sendCount != null">#{sendCount},</if>
|
<if test="sendUserCount != null">#{sendUserCount},</if>
|
</trim>
|
</insert>
|
|
<update id="updateCouponTotal" parameterType="CouponTotal">
|
update t_coupon_total
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="sendCount != null">send_count = #{sendCount},</if>
|
<if test="sendUserCount != null">send_user_count = #{sendUserCount},</if>
|
</trim>
|
where coupon_id = #{couponId}
|
</update>
|
|
<delete id="deleteCouponTotalByCouponId" parameterType="String">
|
delete from t_coupon_total where coupon_id = #{couponId}
|
</delete>
|
|
<delete id="deleteCouponTotalByCouponIds" parameterType="String">
|
delete from t_coupon_total where coupon_id in
|
<foreach item="couponId" collection="array" open="(" separator="," close=")">
|
#{couponId}
|
</foreach>
|
</delete>
|
|
<update id="updateCouponTotal">
|
UPDATE t_coupon_total tct,t_coupon tc
|
SET tct.send_count = tct.send_count + #{sendCount},tct.send_user_count = tct.send_user_count + #{sendUserCount}
|
WHERE tct.coupon_id = #{couponId} AND tc.coupon_id = tct.coupon_id AND (tc.send_limit_flag = 0 OR (tc.send_limit_flag = 1 AND tct.send_count + #{sendCount} <= tc.send_limit_number))
|
</update>
|
</mapper>
|