|
|
@@ -0,0 +1,151 @@
|
|
|
+<?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.fs.his.mapper.FsUserRewardsMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.fs.his.domain.FsUserRewards" id="FsUserRewardsResult">
|
|
|
+ <id property="id" column="id"/>
|
|
|
+ <result property="fsUserId" column="fs_user_id"/>
|
|
|
+ <result property="activityType" column="activity_type"/>
|
|
|
+ <result property="rewardType" column="reward_type"/>
|
|
|
+ <result property="status" column="status"/>
|
|
|
+ <result property="orderCode" column="order_code"/>
|
|
|
+ <result property="goodsId" column="goods_id"/>
|
|
|
+ <result property="productType" column="product_type"/>
|
|
|
+ <result property="grantTime" column="grant_time"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectFsUserRewardsVo">
|
|
|
+ select id, fs_user_id, activity_type, reward_type, status,
|
|
|
+ order_code, goods_id, product_type, grant_time, create_time, update_time
|
|
|
+ from fs_user_rewards
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 根据ID查询 -->
|
|
|
+ <select id="selectFsUserRewardsById" parameterType="Long" resultMap="FsUserRewardsResult">
|
|
|
+ <include refid="selectFsUserRewardsVo"/>
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据用户ID和活动类型查询 -->
|
|
|
+ <select id="selectByUserIdAndActivityType" resultMap="FsUserRewardsResult">
|
|
|
+ <include refid="selectFsUserRewardsVo"/>
|
|
|
+ where fs_user_id = #{fsUserId} and activity_type = #{activityType}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据用户ID和奖品id查询 -->
|
|
|
+ <select id="selectByUserIdAndRewardsId" resultMap="FsUserRewardsResult">
|
|
|
+ <include refid="selectFsUserRewardsVo"/>
|
|
|
+ where id = #{rewardsId} and fs_user_id = #{fsUserId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询用户的所有活动记录 -->
|
|
|
+ <select id="selectByUserId" parameterType="Long" resultMap="FsUserRewardsResult">
|
|
|
+ <include refid="selectFsUserRewardsVo"/>
|
|
|
+ where fs_user_id = #{fsUserId}
|
|
|
+ order by create_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询指定活动的所有用户记录 -->
|
|
|
+ <select id="selectByActivityType" parameterType="String" resultMap="FsUserRewardsResult">
|
|
|
+ <include refid="selectFsUserRewardsVo"/>
|
|
|
+ where activity_type = #{activityType}
|
|
|
+ order by create_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询待领取的记录 -->
|
|
|
+ <select id="selectPendingRewards" resultMap="FsUserRewardsResult">
|
|
|
+ <include refid="selectFsUserRewardsVo"/>
|
|
|
+ where status = 0
|
|
|
+ order by create_time asc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 更新条件查询列表 -->
|
|
|
+ <select id="selectFsUserRewardsList" parameterType="com.fs.his.domain.FsUserRewards" resultMap="FsUserRewardsResult">
|
|
|
+ <include refid="selectFsUserRewardsVo"/>
|
|
|
+ <where>
|
|
|
+ <if test="fsUserId != null"> and fs_user_id = #{fsUserId}</if>
|
|
|
+ <if test="activityType != null and activityType != ''"> and activity_type = #{activityType}</if>
|
|
|
+ <if test="rewardType != null"> and reward_type = #{rewardType}</if>
|
|
|
+ <if test="status != null"> and status = #{status}</if>
|
|
|
+ <if test="orderCode != null and orderCode != ''"> and order_code = #{orderCode}</if>
|
|
|
+ <if test="goodsId != null"> and goods_id = #{goodsId}</if>
|
|
|
+ <if test="productType != null"> and product_type = #{productType}</if>
|
|
|
+ <if test="grantTime != null"> and grant_time = #{grantTime}</if>
|
|
|
+ <if test="createTime != null"> and create_time = #{createTime}</if>
|
|
|
+ <if test="updateTime != null"> and update_time = #{updateTime}</if>
|
|
|
+ </where>
|
|
|
+ order by create_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 更新新增记录 -->
|
|
|
+ <insert id="insertFsUserRewards" parameterType="com.fs.his.domain.FsUserRewards" useGeneratedKeys="true" keyProperty="id">
|
|
|
+ insert into fs_user_rewards
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="fsUserId != null">fs_user_id,</if>
|
|
|
+ <if test="activityType != null">activity_type,</if>
|
|
|
+ <if test="rewardType != null">reward_type,</if>
|
|
|
+ <if test="status != null">status,</if>
|
|
|
+ <if test="orderCode != null">order_code,</if>
|
|
|
+ <if test="goodsId != null">goods_id,</if>
|
|
|
+ <if test="productType != null">product_type,</if>
|
|
|
+ <if test="grantTime != null">grant_time,</if>
|
|
|
+ create_time,
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="fsUserId != null">#{fsUserId},</if>
|
|
|
+ <if test="activityType != null">#{activityType},</if>
|
|
|
+ <if test="rewardType != null">#{rewardType},</if>
|
|
|
+ <if test="status != null">#{status},</if>
|
|
|
+ <if test="orderCode != null">#{orderCode},</if>
|
|
|
+ <if test="goodsId != null">#{goodsId},</if>
|
|
|
+ <if test="productType != null">#{productType},</if>
|
|
|
+ <if test="grantTime != null">#{grantTime},</if>
|
|
|
+ sysdate(),
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 更新修改记录 -->
|
|
|
+ <update id="updateFsUserRewards" parameterType="com.fs.his.domain.FsUserRewards">
|
|
|
+ update fs_user_rewards
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="fsUserId != null">fs_user_id = #{fsUserId},</if>
|
|
|
+ <if test="activityType != null">activity_type = #{activityType},</if>
|
|
|
+ <if test="rewardType != null">reward_type = #{rewardType},</if>
|
|
|
+ <if test="status != null">status = #{status},</if>
|
|
|
+ <if test="orderCode != null">order_code = #{orderCode},</if>
|
|
|
+ <if test="goodsId != null">goods_id = #{goodsId},</if>
|
|
|
+ <if test="productType != null">product_type = #{productType},</if>
|
|
|
+ <if test="grantTime != null">grant_time = #{grantTime},</if>
|
|
|
+ update_time = sysdate()
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 更新状态方法 -->
|
|
|
+ <update id="updateStatus">
|
|
|
+ update fs_user_rewards
|
|
|
+ set status = #{status},
|
|
|
+ order_code = #{orderCode},
|
|
|
+ grant_time = #{grantTime},
|
|
|
+ update_time = sysdate()
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 删除记录 -->
|
|
|
+ <delete id="deleteFsUserRewardsById" parameterType="Long">
|
|
|
+ delete from fs_user_rewards where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 批量删除-->
|
|
|
+ <delete id="deleteFsUserRewardsByIds" parameterType="String">
|
|
|
+ delete from fs_user_rewards where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+</mapper>
|