163 lines
5.9 KiB
XML
163 lines
5.9 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.TbActivateMapper">
|
|
|
|
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivate" id="TbActivateMap">
|
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
|
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
|
<result property="amount" column="amount" jdbcType="INTEGER"/>
|
|
<result property="giftAmount" column="gift_amount" jdbcType="INTEGER"/>
|
|
<result property="giftPoints" column="gift_points" jdbcType="INTEGER"/>
|
|
<result property="isUseCoupon" column="is_use_coupon" jdbcType="INTEGER"/>
|
|
<result property="couponId" column="coupon_id" jdbcType="INTEGER"/>
|
|
<result property="num" column="num" jdbcType="INTEGER"/>
|
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
</resultMap>
|
|
|
|
<sql id="Base_Column_List">
|
|
id
|
|
, shop_id, amount, gift_amount, gift_points, is_use_coupon, coupon_id, num, create_time, update_time </sql>
|
|
|
|
|
|
<select id="selectByAmount" resultMap="TbActivateMap">
|
|
select *
|
|
from tb_activate
|
|
where shop_id = #{shopId}
|
|
and amount <= #{amount}
|
|
order by amount desc
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="selectByAmountScope" resultMap="TbActivateMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
from tb_activate
|
|
where shop_id = #{shopId}
|
|
<![CDATA[
|
|
and amount > 0
|
|
and amount <= #{amount}
|
|
]]>
|
|
order by amount desc,gift_points desc,id desc
|
|
limit 1
|
|
</select>
|
|
|
|
<select id="updateMemberPoints" resultType="integer">
|
|
update tb_shop_user set last_points_change_time = now(),last_float_points = #{points},account_points = account_points + ${points} where id = #{memberId}
|
|
</select>
|
|
|
|
<insert id="insertMemberPointsLog" keyProperty="id" useGeneratedKeys="true">
|
|
insert into tb_member_points_log(shop_id, member_id, member_name, avatar_url, content, order_no, mobile, float_type, float_points, create_time)
|
|
values (#{shopId}, #{memberId}, #{memberName}, #{avatarUrl}, #{content}, #{orderNo}, #{mobile}, #{floatType}, #{floatPoints}, now())
|
|
</insert>
|
|
|
|
<!--查询单个-->
|
|
<select id="queryById" resultMap="TbActivateMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_activate
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<!--查询指定行数据-->
|
|
<select id="queryAll" resultMap="TbActivateMap">
|
|
select
|
|
<include refid="Base_Column_List"/>
|
|
|
|
from tb_activate
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="shopId != null">
|
|
and shop_id = #{shopId}
|
|
</if>
|
|
<if test="amount != null">
|
|
and amount = #{amount}
|
|
</if>
|
|
<if test="giftAmount != null">
|
|
and gift_amount = #{giftAmount}
|
|
</if>
|
|
<if test="giftPoints != null">
|
|
and gift_points = #{giftPoints}
|
|
</if>
|
|
<if test="isUseCoupon != null">
|
|
and is_use_coupon = #{isUseCoupon}
|
|
</if>
|
|
<if test="couponId != null">
|
|
and coupon_id = #{couponId}
|
|
</if>
|
|
<if test="num != null">
|
|
and num = #{num}
|
|
</if>
|
|
<if test="createTime != null">
|
|
and create_time = #{createTime}
|
|
</if>
|
|
<if test="updateTime != null">
|
|
and update_time = #{updateTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
|
|
<!--新增所有列-->
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
insert into tb_activate(shop_id, amount, gift_amount, gift_points, is_use_coupon, coupon_id, num, create_time, update_time)
|
|
values (#{shopId}, #{amount}, #{giftAmount}, #{giftPoints}, #{isUseCoupon}, #{couponId}, #{num}, #{createTime}, #{updateTime})
|
|
</insert>
|
|
|
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
insert into tb_activate(shop_id, amount, gift_amount, gift_points, is_use_coupon, coupon_id, num, create_time, update_time)
|
|
values
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
(#{entity.shopId}, #{entity.amount}, #{entity.giftAmount}, #{entity.giftPoints}, #{entity.isUseCoupon}, #{entity.couponId},
|
|
#{entity.num}, #{entity.createTime}, #{entity.updateTime})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="update">
|
|
update tb_activate
|
|
<set>
|
|
<if test="shopId != null">
|
|
shop_id = #{shopId},
|
|
</if>
|
|
<if test="amount != null">
|
|
amount = #{amount},
|
|
</if>
|
|
<if test="giftAmount != null">
|
|
gift_amount = #{giftAmount},
|
|
</if>
|
|
<if test="giftPoints != null">
|
|
gift_points = #{giftPoints},
|
|
</if>
|
|
<if test="isUseCoupon != null">
|
|
is_use_coupon = #{isUseCoupon},
|
|
</if>
|
|
<if test="couponId != null">
|
|
coupon_id = #{couponId},
|
|
</if>
|
|
<if test="num != null">
|
|
num = #{num},
|
|
</if>
|
|
<if test="createTime != null">
|
|
create_time = #{createTime},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time = #{updateTime},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
delete
|
|
from tb_activate
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
</mapper>
|
|
|