<?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.ruoyi.member.mapper.member.MemberMapper">
|
|
<resultMap type="com.ruoyi.system.api.domain.poji.member.Member" id="MemberResult">
|
<result property="userId" column="user_id" />
|
<result property="delFlag" column="del_flag" />
|
<result property="memberId" column="member_id" />
|
<result property="memberNo" column="member_no" />
|
<result property="wxOpenid" column="wx_openid" />
|
<result property="miniOpenid" column="mini_openid" />
|
<result property="wxUnionid" column="wx_unionid" />
|
<result property="relationShopId" column="relation_shop_id" />
|
<result property="nickName" column="nick_name" />
|
<result property="realName" column="real_name" />
|
<result property="mobile" column="mobile" />
|
<result property="gender" column="gender" />
|
<result property="referrer" column="referrer" />
|
<result property="customerSource" column="customer_source" />
|
<result property="level" column="level" />
|
<result property="birthday" column="birthday" />
|
<result property="createTime" column="create_time" />
|
<result property="updateTime" column="update_time" />
|
<result property="updateUserId" column="update_user_id" />
|
<result property="userTags" column="user_tags" />
|
<result property="avatar" column="avatar" />
|
<result property="bindingFlag" column="binding_flag" />
|
<result property="goodsType" column="goods_type" />
|
<result property="relationShopName" column="relation_shop_name" />
|
</resultMap>
|
|
<sql id="selectMemberVo">
|
select user_id, del_flag, member_id, member_no, wx_openid, mini_openid, wx_unionid, relation_shop_id, nick_name, real_name, mobile, gender, referrer, customer_source, level, birthday, create_time, update_time, update_user_id, user_tags, avatar, binding_flag, goods_type from t_member
|
</sql>
|
|
<select id="selectMemberList" parameterType="com.ruoyi.system.api.domain.poji.member.Member" resultMap="MemberResult">
|
<include refid="selectMemberVo"/>
|
<where>
|
<if test="memberId != null and memberId != ''"> and member_id = #{memberId}</if>
|
<if test="memberNo != null and memberNo != ''"> and member_no = #{memberNo}</if>
|
<if test="wxOpenid != null and wxOpenid != ''"> and wx_openid = #{wxOpenid}</if>
|
<if test="miniOpenid != null and miniOpenid != ''"> and mini_openid = #{miniOpenid}</if>
|
<if test="wxUnionid != null and wxUnionid != ''"> and wx_unionid = #{wxUnionid}</if>
|
<if test="relationShopId != null "> and relation_shop_id = #{relationShopId}</if>
|
<if test="realName != null and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
|
<if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if>
|
<if test="gender != null "> and gender = #{gender}</if>
|
<if test="referrer != null and referrer != ''"> and referrer = #{referrer}</if>
|
<if test="customerSource != null and customerSource != ''"> and customer_source = #{customerSource}</if>
|
<if test="level != null and level != ''"> and level = #{level}</if>
|
<if test="birthday != null and birthday != ''"> and birthday = #{birthday}</if>
|
<if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
|
</where>
|
</select>
|
|
<select id="selectMemberByUserId" parameterType="Long" resultMap="MemberResult">
|
<include refid="selectMemberVo"/>
|
where user_id = #{userId}
|
</select>
|
|
<select id="selectMemberByMobile" parameterType="Long" resultMap="MemberResult">
|
<include refid="selectMemberVo"/>
|
where mobile = #{mobile}
|
</select>
|
|
<insert id="insertMember" parameterType="com.ruoyi.system.api.domain.poji.member.Member">
|
insert into t_member
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="userId != null">user_id,</if>
|
<if test="delFlag != null">del_flag,</if>
|
<if test="memberId != null">member_id,</if>
|
<if test="memberNo != null">member_no,</if>
|
<if test="wxOpenid != null">wx_openid,</if>
|
<if test="miniOpenid != null">mini_openid,</if>
|
<if test="wxUnionid != null">wx_unionid,</if>
|
<if test="relationShopId != null">relation_shop_id,</if>
|
<if test="realName != null">real_name,</if>
|
<if test="mobile != null">mobile,</if>
|
<if test="gender != null">gender,</if>
|
<if test="referrer != null">referrer,</if>
|
<if test="customerSource != null">customer_source,</if>
|
<if test="level != null">level,</if>
|
<if test="birthday != null">birthday,</if>
|
<if test="createTime != null">create_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
<if test="updateUserId != null">update_user_id,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="userId != null">#{userId},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
<if test="memberId != null">#{memberId},</if>
|
<if test="memberNo != null">#{memberNo},</if>
|
<if test="wxOpenid != null">#{wxOpenid},</if>
|
<if test="miniOpenid != null">#{miniOpenid},</if>
|
<if test="wxUnionid != null">#{wxUnionid},</if>
|
<if test="relationShopId != null">#{relationShopId},</if>
|
<if test="realName != null">#{realName},</if>
|
<if test="mobile != null">#{mobile},</if>
|
<if test="gender != null">#{gender},</if>
|
<if test="referrer != null">#{referrer},</if>
|
<if test="customerSource != null">#{customerSource},</if>
|
<if test="level != null">#{level},</if>
|
<if test="birthday != null">#{birthday},</if>
|
<if test="createTime != null">#{createTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateUserId != null">#{updateUserId},</if>
|
</trim>
|
</insert>
|
|
<update id="updateMember" parameterType="com.ruoyi.system.api.domain.poji.member.Member">
|
update t_member
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="memberId != null">member_id = #{memberId},</if>
|
<if test="memberNo != null">member_no = #{memberNo},</if>
|
<if test="wxOpenid != null">wx_openid = #{wxOpenid},</if>
|
<if test="miniOpenid != null">mini_openid = #{miniOpenid},</if>
|
<if test="wxUnionid != null">wx_unionid = #{wxUnionid},</if>
|
<if test="relationShopId != null">relation_shop_id = #{relationShopId},</if>
|
<if test="realName != null">real_name = #{realName},</if>
|
<if test="mobile != null">mobile = #{mobile},</if>
|
<if test="gender != null">gender = #{gender},</if>
|
<if test="referrer != null">referrer = #{referrer},</if>
|
<if test="customerSource != null">customer_source = #{customerSource},</if>
|
<if test="level != null">level = #{level},</if>
|
<if test="birthday != null">birthday = #{birthday},</if>
|
<if test="createTime != null">create_time = #{createTime},</if>
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
<if test="updateUserId != null">update_user_id = #{updateUserId},</if>
|
</trim>
|
where user_id = #{userId}
|
</update>
|
|
<delete id="deleteMemberByUserId" parameterType="Long">
|
delete from t_member where user_id = #{userId}
|
</delete>
|
|
<delete id="deleteMemberByUserIds" parameterType="String">
|
delete from t_member where user_id in
|
<foreach item="userId" collection="array" open="(" separator="," close=")">
|
#{userId}
|
</foreach>
|
</delete>
|
|
|
<select id="getOneByMiniOpenid" resultType="com.ruoyi.system.api.domain.poji.member.Member">
|
SELECT * FROM t_member WHERE del_flag = 0 AND mini_openid = #{miniOpenid}
|
</select>
|
|
<select id="pageMerMember" resultType="com.ruoyi.member.domain.vo.MerMemberPageVo">
|
SELECT
|
tm.user_id userId,
|
tm.nick_name nickName,
|
tm.avatar avatar,
|
CASE tm.gender WHEN 0 THEN '男' WHEN 1 THEN '女' ELSE '未知' END gender,
|
tm.mobile mobile,
|
tm.referrer referrer,
|
0 recommendNum,
|
0 surpNum,
|
tm.birthday birthday,
|
tm.user_tags userTags,
|
tm.goods_type goodsType
|
FROM t_member tm
|
WHERE tm.relation_shop_id = #{param.shopId}
|
<if test="param.memberGender != null and param.memberGender != ''">
|
AND tm.gender = #{param.memberGender}
|
</if>
|
<if test="param.memberTag != null and param.memberTag != ''">
|
AND FIND_IN_SET(#{param.memberTag},tm.user_tags) > 0
|
</if>
|
<if test="param.startMemberDate!=null and param.startMemberDate!=''">
|
AND tm.create_time >= #{param.startMemberDate}
|
</if>
|
<if test="param.endMemberDate!=null and param.endMemberDate!=''">
|
AND tm.create_time <= #{param.endMemberDate}
|
</if>
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (tm.real_name LIKE CONCAT('%',#{param.keyword},'%') OR tm.mobile LIKE CONCAT('%',#{param.keyword},'%') OR tm.referrer LIKE CONCAT('%',#{param.keyword},'%'))
|
</if>
|
ORDER BY tm.create_time DESC
|
</select>
|
|
<select id="pageMerCashMember" resultType="com.ruoyi.member.domain.vo.MerCashMemberPageVo">
|
SELECT
|
tm.user_id userId,
|
tm.nick_name nickName,
|
tm.mobile mobile
|
FROM t_member tm
|
WHERE tm.relation_shop_id = #{param.shopId}
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (tm.real_name LIKE CONCAT('%',#{param.keyword},'%') OR tm.mobile LIKE CONCAT('%',#{param.keyword},'%'))
|
</if>
|
ORDER BY tm.create_time DESC
|
</select>
|
|
<select id="pageMgtMember" resultType="com.ruoyi.member.domain.vo.MgtMemberPageVo">
|
SELECT
|
tm.user_id userId,
|
tm.relation_shop_id relationShopId,
|
tm.member_no memberNo,
|
tm.real_name realName,
|
tm.nick_name nickName,
|
tm.mobile mobile,
|
CASE tm.gender WHEN 0 THEN "男" WHEN 1 THEN "女" ELSE "未知" END gender,
|
(YEAR(CURRENT_DATE) - YEAR(tm.birthday)) - (RIGHT(CURRENT_DATE, 5) < RIGHT(tm.birthday, 5)) age,
|
tm.user_tags memberTags,
|
tm.belong_district belongDistrict,
|
CASE tm.binding_flag WHEN 0 THEN "否" WHEN 1 THEN "是" ELSE "否" END memberFlag,
|
tm.create_time createTime,
|
tmt.last_pay_time lastPayTime,
|
tm.goods_type goodsType,
|
tm.relation_shop_name relationShopName,
|
tmt.total_integral integral,
|
tm.referrer referrer,
|
tm.customer_source memberFrom,
|
tmt.total_pay_money totalPayMoney
|
FROM t_member tm
|
INNER JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE del_flag = 0
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (tm.member_no LIKE CONCAT('%',#{param.keyword},'%') OR tm.mobile LIKE CONCAT('%',#{param.keyword},'%') OR tm.real_name LIKE CONCAT('%',#{param.keyword},'%') OR tm.nick_name LIKE CONCAT('%',#{param.keyword},'%') OR FIND_IN_SET(#{param.keyword},tm.member_nurse) > 0)
|
</if>
|
<if test="param.belongDistrict != null and param.belongDistrict != ''">
|
AND tm.belong_district = #{param.belongDistrict}
|
</if>
|
<if test="param.createTime != null and param.createTime != ''">
|
AND tm.create_time = #{param.createTime}
|
</if>
|
<if test="param.lastPayTime != null and param.lastPayTime != ''">
|
AND tmt.last_pay_time = #{param.lastPayTime}
|
</if>
|
<if test="param.memberFlag != null and param.memberFlag != ''">
|
AND tmt.binding_flag = #{param.memberFlag}
|
</if>
|
<if test="param.goodsType != null and param.goodsType != ''">
|
AND FIND_IN_SET(#{param.goodsType},tm.goods_type) > 0
|
</if>
|
<if test="param.relationShopId != null and param.relationShopId != ''">
|
AND tm.relation_shop_id = #{param.relationShopId}
|
</if>
|
<if test="param.memberFrom != null and param.memberFrom != ''">
|
AND tm.customer_source = #{param.memberFrom}
|
</if>
|
<if test="param.referrer != null and param.referrer != ''">
|
AND tm.referrer = #{param.referrer}
|
</if>
|
<if test="param.gender != null">
|
AND tm.gender = #{param.gender}
|
</if>
|
<if test="param.startBirthday != null and param.startBirthday != ''">
|
AND tm.birthday >= #{param.startBirthday}
|
</if>
|
<if test="param.endBirthday != null and param.endBirthday != ''">
|
AND tm.birthday <= #{param.endBirthday}
|
</if>
|
<if test="param.startIntegral != null and param.startIntegral != ''">
|
AND tmt.total_integral >= #{param.startIntegral}
|
</if>
|
<if test="param.endIntegral != null and param.endIntegral != ''">
|
AND tmt.total_integral <= #{param.endIntegral}
|
</if>
|
<if test="param.actStartDate != null and param.actStartDate != ''">
|
AND tmt.last_pay_time >= #{param.actStartDate}
|
</if>
|
<if test="param.actEndDate != null and param.actEndDate != ''">
|
AND tmt.last_pay_time <= #{param.actEndDate}
|
</if>
|
<if test="param.startPayCount != null and param.startPayCount != ''">
|
AND tmt.total_pay_count >= #{param.startPayCount}
|
</if>
|
<if test="param.endPayCount != null and param.endPayCount != ''">
|
AND tmt.total_pay_count <= #{param.endPayCount}
|
</if>
|
<if test="param.memberTag != null and param.memberTag != ''">
|
AND FIND_IN_SET(#{param.memberTag},tm.user_tags) > 0
|
</if>
|
ORDER BY tm.create_time DESC
|
</select>
|
|
<update id="deleteMemberTag">
|
UPDATE t_member SET user_tags = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', user_tags, ','), CONCAT(',',#{memberTag},','), ','))
|
WHERE FIND_IN_SET(#{memberTag}, user_tags) > 0
|
</update>
|
</mapper>
|