|
|
@@ -1,49 +1,61 @@
|
|
|
<?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">
|
|
|
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="beilv.usermembershipcard.mapper.UserMembershipCardMapper">
|
|
|
|
|
|
<resultMap type="UserMembershipCard" id="UserMembershipCardResult">
|
|
|
- <result property="id" column="id" />
|
|
|
- <result property="userId" column="user_id" />
|
|
|
- <result property="recordId" column="record_id" />
|
|
|
- <result property="totalNumber" column="total_number" />
|
|
|
- <result property="remainingNumber" column="remaining_number" />
|
|
|
- <result property="version" column="version" />
|
|
|
- <result property="createBy" column="create_by" />
|
|
|
- <result property="createTime" column="create_time" />
|
|
|
- <result property="updateBy" column="update_by" />
|
|
|
- <result property="updateTime" column="update_time" />
|
|
|
- <result property="userName" column="username" />
|
|
|
- <result property="mobile" column="mobile" />
|
|
|
- <result property="cardName" column="cardName" />
|
|
|
- <result property="state" column="state" />
|
|
|
- <result property="cardType" column="card_type" />
|
|
|
+ <result property="id" column="id"/>
|
|
|
+ <result property="userId" column="user_id"/>
|
|
|
+ <result property="recordId" column="record_id"/>
|
|
|
+ <result property="totalNumber" column="total_number"/>
|
|
|
+ <result property="remainingNumber" column="remaining_number"/>
|
|
|
+ <result property="version" column="version"/>
|
|
|
+ <result property="createBy" column="create_by"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ <result property="updateBy" column="update_by"/>
|
|
|
+ <result property="updateTime" column="update_time"/>
|
|
|
+ <result property="userName" column="username"/>
|
|
|
+ <result property="mobile" column="mobile"/>
|
|
|
+ <result property="cardName" column="cardName"/>
|
|
|
+ <result property="state" column="state"/>
|
|
|
+ <result property="cardType" column="card_type"/>
|
|
|
+ <result property="cardInfoId" column="card_info_id"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectUserMembershipCardVo">
|
|
|
- select id, user_id, record_id, remaining_number, version, create_by, create_time, update_by, update_time from user_membership_card
|
|
|
+ select id,
|
|
|
+ user_id,
|
|
|
+ record_id,
|
|
|
+ remaining_number,
|
|
|
+ version,
|
|
|
+ create_by,
|
|
|
+ create_time,
|
|
|
+ update_by,
|
|
|
+ update_time,
|
|
|
+ card_info_id
|
|
|
+ from user_membership_card
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectUserMembershipCardList" parameterType="UserMembershipCard" resultMap="UserMembershipCardResult">
|
|
|
SELECT
|
|
|
- a.id,
|
|
|
- a.user_id,
|
|
|
- b.username,
|
|
|
- b.mobile,
|
|
|
- a.record_id,
|
|
|
- a.remaining_number,
|
|
|
- a.state
|
|
|
+ a.id,
|
|
|
+ a.user_id,
|
|
|
+ b.username,
|
|
|
+ b.mobile,
|
|
|
+ a.record_id,
|
|
|
+ a.remaining_number,
|
|
|
+ a.state,
|
|
|
+ a.card_info_id
|
|
|
FROM
|
|
|
- user_membership_card a
|
|
|
- left join sys_member b on a.user_id = b.id
|
|
|
+ user_membership_card a
|
|
|
+ left join sys_member b on a.user_id = b.id
|
|
|
<where>
|
|
|
- <if test="userId != null and userId != ''"> and a.user_id = #{userId}</if>
|
|
|
- <if test="recordId != null and recordId != ''"> and a.record_id = #{recordId}</if>
|
|
|
- <if test="remainingNumber != null "> and a.remaining_number = #{remainingNumber}</if>
|
|
|
- <if test="version != null and version != ''"> and a.version = #{version}</if>
|
|
|
- <if test="mobile != null and mobile != ''"> and b.mobile like concat('%', #{mobile}, '%')</if>
|
|
|
+ <if test="userId != null and userId != ''">and a.user_id = #{userId}</if>
|
|
|
+ <if test="recordId != null and recordId != ''">and a.record_id = #{recordId}</if>
|
|
|
+ <if test="remainingNumber != null ">and a.remaining_number = #{remainingNumber}</if>
|
|
|
+ <if test="version != null and version != ''">and a.version = #{version}</if>
|
|
|
+ <if test="mobile != null and mobile != ''">and b.mobile like concat('%', #{mobile}, '%')</if>
|
|
|
<if test="state != null and state != ''">
|
|
|
<choose>
|
|
|
<when test="state == 'hasClubCard'">
|
|
|
@@ -77,7 +89,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
<if test="state != null">state,</if>
|
|
|
- </trim>
|
|
|
+ <if test="cardInfoId != null">card_info_id,</if>
|
|
|
+ </trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="id != null">#{id},</if>
|
|
|
<if test="userId != null">#{userId},</if>
|
|
|
@@ -90,7 +103,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
<if test="state != null">#{state},</if>
|
|
|
- </trim>
|
|
|
+ <if test="cardInfoId != null">#{cardInfoId},</if>
|
|
|
+ </trim>
|
|
|
</insert>
|
|
|
|
|
|
<update id="updateUserMembershipCard" parameterType="UserMembershipCard">
|
|
|
@@ -106,12 +120,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
<if test="state != null">state = #{state},</if>
|
|
|
+ <if test="cardInfoId != null">card_info_id = #{cardInfoId},</if>
|
|
|
</trim>
|
|
|
where id = #{id}
|
|
|
</update>
|
|
|
|
|
|
<delete id="deleteUserMembershipCardById" parameterType="Long">
|
|
|
- delete from user_membership_card where id = #{id}
|
|
|
+ delete
|
|
|
+ from user_membership_card
|
|
|
+ where id = #{id}
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteUserMembershipCardByIds" parameterType="String">
|
|
|
@@ -122,19 +139,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
|
|
|
|
<select id="getStream" parameterType="Long" resultType="java.util.Map">
|
|
|
- SELECT
|
|
|
- a.id,
|
|
|
- a.type,
|
|
|
- d.username,
|
|
|
- d.mobile,
|
|
|
- c.card_name cardName,
|
|
|
- c.card_type cardType,
|
|
|
- DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') createTime
|
|
|
- FROM
|
|
|
- member_stream a
|
|
|
- left join user_membership_card b on a.user_card_id = b.id
|
|
|
- left join card_purchase_record c on b.record_id = c.id
|
|
|
- left join sys_member d on b.user_id = d.id
|
|
|
+ SELECT a.id,
|
|
|
+ a.type,
|
|
|
+ d.username,
|
|
|
+ d.mobile,
|
|
|
+ c.card_name cardName,
|
|
|
+ c.card_type cardType,
|
|
|
+ DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') createTime
|
|
|
+ FROM member_stream a
|
|
|
+ left join user_membership_card b on a.user_card_id = b.id
|
|
|
+ left join card_purchase_record c on b.record_id = c.id
|
|
|
+ left join sys_member d on b.user_id = d.id
|
|
|
WHERE a.user_card_id = #{id}
|
|
|
order by a.create_time desc
|
|
|
</select>
|