zhwl/zhwl-business/zhwl-points-mall/target/classes/mapper/pointsMall/PointsMall​Mapper.xml
2025-07-01 17:54:58 +08:00

223 lines
7.8 KiB
XML

<?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.zhwl.pointsmall.mapper.PointsMallMapper">
<resultMap type="PointsMallVo" id="PointsMallResult">
<result property="id" column="id"/>
<result property="ticketId" column="ticket_id"/>
<result property="ticketType" column="ticket_type"/>
<result property="points" column="points"/>
<result property="status" column="status"/>
<result property="delistReasonType" column="delist_reason_type"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
<result property="delFlag" column="del_flag"/>
<result property="sort" column="sort"/>
<result property="ticketName" column="ticket_name"/>
<result property="salePrice" column="sales_rice"/>
<result property="inventory" column="inventory"/>
<result property="descr" column="descr"/>
</resultMap>
<sql id="selectPointsMallVo">
select pm.id,
pm.ticket_id,
pm.ticket_type,
pm.points,
pm.status,
pm.delist_reason_type,
pm.create_time,
pm.create_by,
pm.update_time,
pm.update_by,
pm.del_flag,
pm.sort,
pm.descr,
t.name as ticket_name,
t.sales_rice,
t.inventory
from zdy_points_mall pm left join zdy_ticket t on pm.ticket_id = t.id
</sql>
<select id="selectPointsMallList" parameterType="PointsMallVo" resultMap="PointsMallResult">
<include refid="selectPointsMallVo"/>
<where>
and pm.del_flag = '0'
<if test="ticketId != null ">
and pm.ticket_id = #{ticketId}
</if>
<if test="ticketId != null ">
and t.ticket_name like concat('%',#{ticketName},'%')
</if>
<if test="ticketType != null and ticketType != ''">
and pm.ticket_type = #{ticketType}
</if>
<if test="status != null ">
and pm.status = #{status}
</if>
</where>
order by pm.sort asc,pm.id desc
</select>
<select id="selectPointsMallById" parameterType="Long"
resultMap="PointsMallResult">
<include refid="selectPointsMallVo"/>
where pm.id = #{id}
</select>
<select id="selectPointsMallByTicketId" parameterType="Long"
resultMap="PointsMallResult">
<include refid="selectPointsMallVo"/>
where pm.ticket_id = #{ticketId}
</select>
<select id="selectPointsMallAppList" resultType="com.zhwl.pointsmall.domain.vo.PointsMallAppList">
SELECT
pm.id,
pm.ticket_id AS ticketId,
pm.ticket_type AS ticketType,
pm.points,
t.name AS ticketName,
t.image43 AS image43
FROM
zdy_points_mall pm
LEFT JOIN
zdy_ticket t ON pm.ticket_id = t.id
LEFT JOIN
zdy_vip_user vu ON vu.mini_program_user_id = #{userId}
WHERE
(#{userId} IS NULL OR pm.points >= vu.points)
</select>
<select id="selectPointsMallAppInfo" resultType="com.zhwl.pointsmall.domain.vo.PointsMallAppInfo">
select pm.id,
pm.points,
pm.descr,
vu.points AS userPoints
from zdy_points_mall pm
LEFT JOIN
zdy_vip_user vu ON vu.mini_program_user_id = #{userId}
</select>
<insert id="insertPointsMall" parameterType="PointsMall" useGeneratedKeys="true" keyProperty="id">
insert into zdy_points_mall
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,
</if>
<if test="ticketId != null">ticket_id,
</if>
<if test="ticketType != null and ticketType != ''">ticket_type,
</if>
<if test="points != null">points,
</if>
<if test="status != null">status,
</if>
<if test="delistReasonType != null">delist_reason_type,
</if>
<if test="createTime != null">create_time,
</if>
<if test="createBy != null">create_by,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="sort !=null">
sort,
</if>
<if test="descr != null">descr,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},
</if>
<if test="ticketId != null">#{ticketId},
</if>
<if test="ticketType != null and ticketType != ''">#{ticketType},
</if>
<if test="points != null">#{points},
</if>
<if test="status != null">#{status},
</if>
<if test="delistReasonType != null">#{delistReasonType},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="sort !=null">
#{sort},
</if>
<if test="descr != null">#{descr},
</if>
</trim>
</insert>
<sql id="updatePointsMallSql">
update zdy_points_mall
<trim prefix="SET" suffixOverrides=",">
<if test="ticketId != null">ticket_id =
#{ticketId},
</if>
<if test="ticketType != null and ticketType != ''">ticket_type =
#{ticketType},
</if>
<if test="points != null">points =
#{points},
</if>
<if test="status != null">status =
#{status},
</if>
<if test="delistReasonType != null">delist_reason_type =
#{delistReasonType},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="delFlag != null">del_flag =
#{delFlag},
</if>
<if test="sort !=null">
sort =#{sort},
</if>
<if test="descr != null">descr =
#{descr},
</if>
</trim>
</sql>
<update id="updatePointsMall" parameterType="PointsMall">
<include refid="updatePointsMallSql"/>
where id = #{id}
</update>
<update id="updatePointsMallByTicketId">
<include refid="updatePointsMallSql"/>
where ticket_id = #{ticketId}
</update>
<delete id="deletePointsMallById" parameterType="Long">
update zdy_points_mall set del_flag = '2'
where id = #{id}
</delete>
<delete id="deletePointsMallByIds" parameterType="String">
update zdy_points_mall set del_flag='2' where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>