zhwl/zhwl-business/zhwl-prepaid-card/target/classes/mapper/prepaidCard/PrepaidCardMapper.xml

164 lines
6.7 KiB
XML
Raw Normal View History

2025-07-01 17:54:58 +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.zhwl.prepaidCard.mapper.PrepaidCardMapper">
<resultMap type="PrepaidCard" id="PrepaidCardResult">
<result property="id" column="id"/>
<result property="accountNo" column="account_no"/>
<result property="type" column="type"/>
<result property="name" column="name"/>
<result property="phone" column="phone"/>
<result property="balance" column="balance"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateTime" column="update_time"/>
<result property="updateBy" column="update_by"/>
</resultMap>
<sql id="selectPrepaidCardVo">
select id, account_no, type, name, phone, balance, status, create_time, create_by,update_by, update_time
from zdy_prepaid_card
</sql>
<select id="selectPrepaidCardList" parameterType="PrepaidCard" resultMap="PrepaidCardResult">
<include refid="selectPrepaidCardVo"/>
<where>
<if test="accountNo != null and accountNo != ''">
and account_no like concat('%', #{accountNo}, '%')
</if>
<if test="type != null and type != ''">
and type = #{type}
</if>
<if test="name != null and name != ''">
and name like concat('%', #{name}, '%')
</if>
<if test="phone != null and phone != ''">
and phone = #{phone}
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
</if>
</where>
order by id desc
</select>
<select id="selectPrepaidCardById" parameterType="Long"
resultMap="PrepaidCardResult">
<include refid="selectPrepaidCardVo"/>
where id = #{id}
</select>
<select id="selectPrepaidCardByAccountNo" parameterType="String"
resultMap="PrepaidCardResult">
<include refid="selectPrepaidCardVo"/>
where account_no = #{accountNo} and (status = '1' or status='2') limit 1
</select>
<select id="selectPrepaidCardByCreateBy" parameterType="String"
resultMap="PrepaidCardResult">
<include refid="selectPrepaidCardVo"/>
where create_by = #{createBy} and `type` = #{type} and `status` = '1'
</select>
<select id="selectPrepaidCardByPhone" parameterType="String"
resultMap="PrepaidCardResult">
<include refid="selectPrepaidCardVo"/>
where phone = #{phone} and (status = '1' or status='2') limit 1
</select>
<insert id="insertPrepaidCard" parameterType="PrepaidCard" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_prepaid_card
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="accountNo != null and accountNo != ''">account_no,
</if>
<if test="type != null">type,
</if>
<if test="name != null and name != ''">name,
</if>
<if test="phone != null and phone != ''">phone,
</if>
<if test="balance != null">balance,
</if>
<if test="status != null">status,
</if>
<if test="createTime != null">create_time,
</if>
<if test="createBy != null">create_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="accountNo != null and accountNo != ''">#{accountNo},
</if>
<if test="type != null">#{type},
</if>
<if test="name != null and name != ''">#{name},
</if>
<if test="phone != null and phone != ''">#{phone},
</if>
<if test="balance != null">#{balance},
</if>
<if test="status != null">#{status},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="createBy != null">#{createBy},
</if>
</trim>
</insert>
<update id="updatePrepaidCard" parameterType="PrepaidCard">
update zdy_prepaid_card
<trim prefix="SET" suffixOverrides=",">
<if test="accountNo != null and accountNo != ''">account_no =
#{accountNo},
</if>
<if test="type != null">type =
#{type},
</if>
<if test="name != null and name != ''">name =
#{name},
</if>
<if test="phone != null and phone != ''">phone =
#{phone},
</if>
<if test="balance != null">balance =
#{balance},
</if>
<if test="status != null">status =
#{status},
</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>
</trim>
where id = #{id}
</update>
<update id="updatePrepaidCardBalance">
update zdy_prepaid_card set balance = balance + #{amount} where id = #{id}
</update>
<delete id="deletePrepaidCardById" parameterType="Long">
delete from zdy_prepaid_card where id = #{id}
</delete>
<delete id="deletePrepaidCardByIds" parameterType="String">
delete from zdy_prepaid_card where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>