173 lines
6.5 KiB
XML
173 lines
6.5 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.chaozhanggui.system.cashierservice.dao.TbUserCouponsMapper">
|
|
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
|
|
<id column="id" jdbcType="INTEGER" property="id" />
|
|
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
|
<result column="detail" jdbcType="VARCHAR" property="detail" />
|
|
<result column="coupons_price" jdbcType="DECIMAL" property="couponsPrice" />
|
|
<result column="coupons_amount" jdbcType="DECIMAL" property="couponsAmount" />
|
|
<result column="status" jdbcType="VARCHAR" property="status" />
|
|
<result column="is_double" jdbcType="VARCHAR" property="isDouble" />
|
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
|
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
|
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
|
id, user_id, detail, coupons_price, coupons_amount, status, create_time, update_time, end_time,is_double
|
|
</sql>
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
|
select
|
|
<include refid="Base_Column_List" />
|
|
from tb_user_coupons
|
|
where id = #{id,jdbcType=INTEGER}
|
|
</select>
|
|
|
|
<select id="queryAllSelective" resultMap="BaseResultMap">
|
|
select
|
|
detail,coupons_price as couponsPrice,coupons_amount as couponsAmount,status,1 as num,0 as type
|
|
from tb_user_coupons
|
|
<where>
|
|
<if test="userId != null and userId != ''">
|
|
and user_id = #{userId}
|
|
</if>
|
|
<if test="status != null and status != ''">
|
|
and status = #{status}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectByUserId" resultType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
|
|
select * from tb_user_coupons where user_id = #{userId}
|
|
<if test="status != null and status != ''">
|
|
and status = #{status}
|
|
</if>
|
|
|
|
<if test="amount != null and amount != ''">
|
|
and coupons_amount <= #{amount}
|
|
</if>
|
|
|
|
|
|
</select>
|
|
<select id="selectByOrderId" resultType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
|
|
select * from tb_user_coupons where order_id = #{orderId}
|
|
</select>
|
|
<select id="selectByUserIdAndAmount" resultType="java.lang.Integer">
|
|
select ifnull(count(*),0) from tb_user_coupons where user_id = #{userId} and status = '0' and coupons_amount >= #{orderNum}
|
|
</select>
|
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
|
delete from tb_user_coupons
|
|
where id = #{id,jdbcType=INTEGER}
|
|
</delete>
|
|
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons" useGeneratedKeys="true" keyProperty="id">
|
|
insert into tb_user_coupons (id, user_id, detail, coupons_price,
|
|
coupons_amount, status, create_time,
|
|
update_time, end_time,is_double)
|
|
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, #{detail,jdbcType=VARCHAR}, #{couponsPrice,jdbcType=DECIMAL},
|
|
#{couponsAmount,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
|
|
#{updateTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{isDouble,jdbcType=VARCHAR})
|
|
</insert>
|
|
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
|
|
insert into tb_user_coupons
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">
|
|
id,
|
|
</if>
|
|
<if test="userId != null">
|
|
user_id,
|
|
</if>
|
|
<if test="detail != null">
|
|
detail,
|
|
</if>
|
|
<if test="couponsPrice != null">
|
|
coupons_price,
|
|
</if>
|
|
<if test="couponsAmount != null">
|
|
coupons_amount,
|
|
</if>
|
|
<if test="status != null">
|
|
status,
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time,
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time,
|
|
</if>
|
|
<if test="endTime != null">
|
|
end_time,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">
|
|
#{id,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="userId != null">
|
|
#{userId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="detail != null">
|
|
#{detail,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="couponsPrice != null">
|
|
#{couponsPrice,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="couponsAmount != null">
|
|
#{couponsAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="status != null">
|
|
#{status,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="createTime != null">
|
|
#{createTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
#{updateTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
<if test="endTime != null">
|
|
#{endTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
|
|
update tb_user_coupons
|
|
<set>
|
|
<if test="userId != null">
|
|
user_id = #{userId,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="detail != null">
|
|
detail = #{detail,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="couponsPrice != null">
|
|
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="couponsAmount != null">
|
|
coupons_amount = #{couponsAmount,jdbcType=DECIMAL},
|
|
</if>
|
|
<if test="status != null">
|
|
status = #{status,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
<if test="endTime != null">
|
|
end_time = #{endTime,jdbcType=TIMESTAMP},
|
|
</if>
|
|
</set>
|
|
where id = #{id,jdbcType=INTEGER}
|
|
</update>
|
|
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbUserCoupons">
|
|
update tb_user_coupons
|
|
set user_id = #{userId,jdbcType=VARCHAR},
|
|
coupons_price = #{couponsPrice,jdbcType=DECIMAL},
|
|
detail = #{detail,jdbcType=VARCHAR},
|
|
coupons_amount = #{couponsAmount,jdbcType=DECIMAL},
|
|
status = #{status,jdbcType=VARCHAR},
|
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
|
end_time = #{endTime,jdbcType=TIMESTAMP}
|
|
where id = #{id,jdbcType=INTEGER}
|
|
</update>
|
|
</mapper> |