<?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" />
|
<result property="memberNurse" column="member_nurse" />
|
</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,relation_shop_name,member_nurse 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="String" resultMap="MemberResult">
|
<include refid="selectMemberVo"/>
|
where mobile = #{mobile} AND del_flag = 0
|
</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.real_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,
|
tmt.useable_service_count surpNum,
|
tm.birthday birthday,
|
tm.user_tags userTags,
|
tm.goods_type goodsType,
|
tmt.last_service_time lastPayTime,
|
tm.memberNurse
|
FROM t_member tm
|
INNER JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.relation_shop_id = #{param.shopId} AND tm.binding_flag = 1
|
<if test="param.memberGender != null">
|
AND tm.gender = #{param.memberGender}
|
</if>
|
<if test="param.memberType != null and param.memberType != ''">
|
AND FIND_IN_SET(#{param.memberType},tm.goods_type) > 0
|
</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 Date(tm.create_time) >= #{param.startMemberDate}
|
</if>
|
<if test="param.endMemberDate!=null and param.endMemberDate!=''">
|
AND Date(tm.create_time) <= #{param.endMemberDate}
|
</if>
|
<if test="param.memberFrom != null and param.memberFrom != ''">
|
AND tm.customer_source = #{param.memberFrom}
|
</if>
|
<if test="param.memberLevel != null and param.memberLevel != ''">
|
AND tm.level = #{param.memberLevel}
|
</if>
|
<if test="param.taskStartDate!=null and param.taskStartDate!=''">
|
AND Date(tmt.next_task_time) >= #{param.taskStartDate}
|
</if>
|
<if test="param.taskEndDate!=null and param.taskEndDate!=''">
|
AND Date(tmt.next_task_time) <= #{param.taskEndDate}
|
</if>
|
<if test="param.surpStartNum != null and param.surpStartNum != ''">
|
AND tmt.useable_service_count >= #{param.surpStartNum}
|
</if>
|
<if test="param.surpEndNum != null and param.surpEndNum != ''">
|
AND tmt.useable_service_count < #{param.surpEndNum}
|
</if>
|
<if test="param.memberNurse != null and param.memberNurse != ''">
|
AND FIND_IN_SET(#{param.memberNurse},tm.member_nurse) > 0
|
</if>
|
<if test="param.actStartDate!=null and param.actStartDate!=''">
|
AND Date(tmt.last_service_time) >= #{param.actStartDate}
|
</if>
|
<if test="param.actEndDate!=null and param.actEndDate!=''">
|
AND Date(tmt.last_service_time) <= #{param.actEndDate}
|
</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.real_name nickName,
|
tm.mobile mobile
|
FROM t_member tm
|
WHERE tm.relation_shop_id = #{param.shopId} AND tm.binding_flag = 1
|
<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.member_id memberId,
|
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_id as relationShopId,
|
CASE binding_flag WHEN 1 THEN tm.relation_shop_name ELSE "" END relationShopName,
|
tm.binding_flag as bindingFlag,
|
tmt.total_integral integral,
|
tm.referrer referrer,
|
tm.customer_source memberFrom,
|
tmt.total_pay_money totalPayMoney,
|
tmt.total_activity_count activityTotal,
|
tm.avatar head,
|
tm.frozen_flag frozenFlag
|
FROM t_member tm
|
LEFT JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.del_flag = 0
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (tm.user_id 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 Date(tm.create_time) = #{param.createTime}
|
</if>
|
<if test="param.lastPayTime != null and param.lastPayTime != ''">
|
AND Date(tmt.last_pay_time) = #{param.lastPayTime}
|
</if>
|
<if test="param.memberFlag != null ">
|
AND tm.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} AND tm.binding_flag = 1
|
</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 LIKE CONCAT('%',#{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 Date(tmt.last_service_time) >= #{param.actStartDate}
|
</if>
|
<if test="param.actEndDate != null and param.actEndDate != ''">
|
AND Date(tmt.last_service_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.memberTags != null and param.memberTags != ''">
|
AND tm.user_tags REGEXP #{param.memberTags}
|
</if>
|
<if test="list != null and list.size()>0">
|
AND tm.relation_shop_id IN
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
AND tm.binding_flag = 1
|
</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>
|
|
<select id="listIdBySendType" resultType="java.lang.Long">
|
SELECT
|
tm.user_id
|
FROM t_member tm
|
WHERE tm.del_flag = 0
|
<if test="sendType != null and sendType == 3">
|
AND tm.binding_flag = 1
|
</if>
|
<if test="sendType != null and sendType == 4">
|
AND tm.binding_flag = 0
|
</if>
|
<if test="shopId != null and shopId != '' and sendType != null and sendType != 4">
|
AND tm.relation_shop_id = #{shopId}
|
</if>
|
</select>
|
|
|
<select id="listIdBySendType2" resultType="java.lang.Long">
|
SELECT
|
tm.user_id
|
FROM t_member tm
|
WHERE tm.del_flag = 0 AND (tm.binding_flag = 0 or (tm.binding_flag = 1 AND tm.relation_shop_id = #{shopId}))
|
</select>
|
|
|
|
<select id="listSimpleVoByIds" resultType="com.ruoyi.system.api.domain.vo.MgtSimpleMemberVo">
|
SELECT
|
tm.user_id userId,
|
tm.real_name realName,
|
tm.nick_name nickName,
|
tm.mobile userMobile
|
FROM t_member tm
|
WHERE tm.del_flag = 0 AND FIND_IN_SET(tm.user_id, #{userIds}) > 0
|
</select>
|
|
<select id="getUserIdByKeyword" resultType="java.lang.Long">
|
SELECT
|
tm.user_id
|
FROM t_member tm
|
WHERE tm.del_flag = 0
|
<if test="param.keyword != null and param.keyword != ''">
|
AND (tm.mobile LIKE CONCAT('%',#{param.keyword},'%') OR tm.real_name LIKE CONCAT('%',#{param.keyword},'%') OR tm.nick_name LIKE CONCAT('%',#{param.keyword},'%'))
|
</if>
|
</select>
|
|
<select id="memberTotal" resultType="java.lang.Integer">
|
SELECT COUNT(user_id) FROM t_member WHERE del_flag = 0
|
<if test="null != shopIds and shopIds.size() > 0">
|
and binding_flag = 1 and relation_shop_id in
|
<foreach collection="shopIds" separator="," index="index" item="item" open="(" close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="memberToday" resultType="java.lang.Integer">
|
SELECT COUNT(user_id) FROM t_member WHERE del_flag = 0 AND Date(create_time) = CURDATE()
|
<if test="null != shopIds and shopIds.size() > 0">
|
and binding_flag = 1 and relation_shop_id in
|
<foreach collection="shopIds" separator="," index="index" item="item" open="(" close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getTotalMemberTotal" resultType="com.ruoyi.member.domain.vo.MgtTotalMemberTotalVo">
|
SELECT
|
COUNT(member_id) memberTotal,
|
IFNULL(SUM(CASE WHEN customer_source = "小程序" THEN 1 ELSE 0 END),0) onlineTotal,
|
IFNULL(SUM(CASE WHEN customer_source = "小程序" THEN 0 ELSE 1 END),0) offlineTotal,
|
0 introduceTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%周期%" THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%体验%" THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%服务%" THEN 1 ELSE 0 END),0) serviceTotal
|
FROM t_member WHERE del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getTotalMemberTotal" resultType="com.ruoyi.member.domain.vo.MgtTotalMemberTotalVo">
|
SELECT
|
COUNT(member_id) memberTotal,
|
IFNULL(SUM(CASE WHEN customer_source = "小程序" THEN 1 ELSE 0 END),0) onlineTotal,
|
IFNULL(SUM(CASE WHEN customer_source = "小程序" THEN 0 ELSE 1 END),0) offlineTotal,
|
0 introduceTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%周期%" THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%体验%" THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%服务%" THEN 1 ELSE 0 END),0) serviceTotal
|
FROM t_member WHERE del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
</select>
|
|
<select id="getTotalMemberTotalAge" resultType="com.ruoyi.member.domain.vo.MgtAgeTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN gender = 0 THEN 1 ELSE 0 END),0) manTotal,
|
IFNULL(SUM(CASE WHEN gender = 1 THEN 1 ELSE 0 END),0) womenTotal,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) <= 20 THEN 1 ELSE 0 END),0) AS tenAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 21 AND 30 THEN 1 ELSE 0 END),0) AS twentyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 31 AND 40 THEN 1 ELSE 0 END),0) AS ThirtyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 41 AND 50 THEN 1 ELSE 0 END),0) AS fortyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) >= 51 THEN 1 ELSE 0 END),0) AS fiftyAge
|
FROM t_member WHERE del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getTotalMemberTotalNurse" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT member_nurse mapKey, COUNT(*) mapValue
|
FROM (
|
SELECT member_id, SUBSTRING_INDEX(SUBSTRING_INDEX(member_nurse, ',', numbers.n), ',', -1) member_nurse
|
FROM (SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23 UNION ALL SELECT 24 UNION ALL SELECT 25 UNION ALL SELECT 26 UNION ALL SELECT 27 UNION ALL SELECT 28 UNION ALL SELECT 29 UNION ALL SELECT 30 UNION ALL SELECT 31 UNION ALL SELECT 32 UNION ALL SELECT 33 UNION ALL SELECT 34 UNION ALL SELECT 35 UNION ALL SELECT 36 UNION ALL SELECT 37 UNION ALL SELECT 38 UNION ALL SELECT 39 UNION ALL SELECT 40) numbers
|
INNER JOIN t_member ON CHAR_LENGTH(member_nurse) - CHAR_LENGTH(REPLACE(member_nurse, ',', '')) >= numbers.n - 1 AND del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
) x
|
WHERE member_nurse IS NOT NULL OR member_nurse != ''
|
GROUP BY member_nurse
|
</select>
|
|
<select id="getTotalMemberTotalLevel" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT level mapKey, COUNT(*) mapValue
|
FROM t_member
|
WHERE (level IS NOT NULL OR level != '') AND del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY level
|
</select>
|
|
<select id="getTotalMemberTotalGoodsType" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT goods_type mapKey, COUNT(*) mapValue
|
FROM (
|
SELECT member_id, SUBSTRING_INDEX(SUBSTRING_INDEX(goods_type, ',', numbers.n), ',', -1) goods_type
|
FROM (SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5) numbers
|
INNER JOIN t_member ON CHAR_LENGTH(goods_type) - CHAR_LENGTH(REPLACE(goods_type, ',', '')) >= numbers.n - 1 AND del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
) x
|
WHERE goods_type IS NOT NULL OR goods_type != ''
|
GROUP BY goods_type
|
</select>
|
|
<select id="getTotalMemberTotalActiveness" resultType="java.lang.Integer">
|
SELECT
|
COUNT(tm.member_id)
|
FROM t_member tm
|
LEFT JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.del_Flag = 0 AND binding_flag = 1
|
<if test="shopId != null and shopId != ''">
|
AND tm.relation_shop_id = #{shopId}
|
</if>
|
<if test="actStartDate != null and actStartDate != ''">
|
AND Date(tmt.last_service_time) >= #{actStartDate}
|
</if>
|
<if test="actEndDate != null and actEndDate != ''">
|
AND Date(tmt.last_service_time) <= #{actEndDate}
|
</if>
|
</select>
|
|
<select id="getTotalMemberRankPay" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.real_name mapKey,
|
tmt.total_pay_count mapValue
|
FROM t_member tm
|
INNER JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND tm.relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
ORDER BY tmt.total_pay_count DESC LIMIT 15
|
</select>
|
|
<select id="getTotalMemberRankCustomerSource" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.customer_source mapKey,
|
COUNT(tm.user_id) mapValue
|
FROM t_member tm WHERE tm.del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND tm.relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tm.customer_source
|
ORDER BY COUNT(tm.user_id) DESC LIMIT 15
|
</select>
|
|
<select id="listUserIdByAge" resultType="java.lang.Long">
|
SELECT user_id
|
FROM t_member
|
WHERE del_flag = 0
|
<if test="param.ageType != null and param.ageType ==1">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 1 AND 20
|
</if>
|
<if test="param.ageType != null and param.ageType ==2">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 21 AND 30
|
</if>
|
<if test="param.ageType != null and param.ageType ==3">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 31 AND 40
|
</if>
|
<if test="param.ageType != null and param.ageType ==4">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 41 AND 50
|
</if>
|
<if test="param.ageType != null and param.ageType ==5">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 1 AND 20
|
</if>
|
<if test="param.userIds != null">
|
AND user_id IN
|
<foreach collection="param.userIds" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getPlTotalMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtPlTotalMemberTotalVo">
|
SELECT
|
COUNT(*) AS memberTotal,
|
COUNT(CASE WHEN DATE(create_time) = DATE_SUB(CURDATE(), INTERVAL 1 DAY) THEN 1 END) AS memberYesterday,
|
COUNT(CASE WHEN create_time BETWEEN DATE_SUB(CURDATE(), INTERVAL 6 DAY) AND DATE_SUB(CURDATE(), INTERVAL -1 DAY) THEN 1 END) AS memberSeven
|
FROM t_member WHERE del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getPlTotalMemberTotalAge" resultType="com.ruoyi.member.domain.vo.MgtAgeTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN gender = 0 THEN 1 ELSE 0 END),0) manTotal,
|
IFNULL(SUM(CASE WHEN gender = 1 THEN 1 ELSE 0 END),0) womenTotal,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) <= 20 THEN 1 ELSE 0 END),0) AS tenAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 21 AND 30 THEN 1 ELSE 0 END),0) AS twentyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 31 AND 40 THEN 1 ELSE 0 END),0) AS ThirtyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 41 AND 50 THEN 1 ELSE 0 END),0) AS fortyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) >= 51 THEN 1 ELSE 0 END),0) AS fiftyAge
|
FROM t_member WHERE del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getPlTotalMemberTotalNurse" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT member_nurse mapKey, COUNT(*) mapValue
|
FROM (
|
SELECT member_id, SUBSTRING_INDEX(SUBSTRING_INDEX(member_nurse, ',', numbers.n), ',', -1) member_nurse
|
FROM (SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23 UNION ALL SELECT 24 UNION ALL SELECT 25 UNION ALL SELECT 26 UNION ALL SELECT 27 UNION ALL SELECT 28 UNION ALL SELECT 29 UNION ALL SELECT 30 UNION ALL SELECT 31 UNION ALL SELECT 32 UNION ALL SELECT 33 UNION ALL SELECT 34 UNION ALL SELECT 35 UNION ALL SELECT 36 UNION ALL SELECT 37 UNION ALL SELECT 38 UNION ALL SELECT 39 UNION ALL SELECT 40) numbers
|
INNER JOIN t_member ON CHAR_LENGTH(member_nurse) - CHAR_LENGTH(REPLACE(member_nurse, ',', '')) >= numbers.n - 1 AND binding_flag = 1 AND del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
) x
|
WHERE member_nurse IS NOT NULL OR member_nurse != ''
|
GROUP BY member_nurse
|
</select>
|
|
<select id="getPlTotalMemberTotalLevel" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT level mapKey, COUNT(*) mapValue
|
FROM t_member
|
WHERE (level IS NOT NULL OR level != '') AND binding_flag = 1 AND del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY mapKey
|
ORDER BY mapValue DESC
|
</select>
|
|
<select id="getPlTotalMemberTotalGoodsType" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT goods_type mapKey, COUNT(*) mapValue
|
FROM (
|
SELECT member_id, SUBSTRING_INDEX(SUBSTRING_INDEX(goods_type, ',', numbers.n), ',', -1) goods_type
|
FROM (SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5) numbers
|
INNER JOIN t_member ON CHAR_LENGTH(goods_type) - CHAR_LENGTH(REPLACE(goods_type, ',', '')) >= numbers.n - 1 AND binding_flag = 1 AND del_flag = 0
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
) x
|
WHERE goods_type IS NOT NULL OR goods_type != ''
|
GROUP BY goods_type
|
</select>
|
|
<select id="getPlTotalMemberTotalActiveness" resultType="java.lang.Integer">
|
SELECT
|
COUNT(tm.member_id)
|
FROM t_member tm
|
INNER JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.del_Flag = 0 AND binding_flag = 1
|
<if test="shopIdList != null and shopIdList.size() > 0">
|
AND tm.relation_shop_id IN
|
<foreach collection="shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="actStartDate != null and actStartDate != ''">
|
AND Date(tmt.last_service_time) >= #{actStartDate}
|
</if>
|
<if test="actEndDate != null and actEndDate != ''">
|
AND Date(tmt.last_service_time) <= #{actEndDate}
|
</if>
|
</select>
|
|
<select id="getPlTotalMemberRankPay" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.real_name mapKey,
|
tmt.total_pay_count mapValue
|
FROM t_member tm
|
INNER JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.del_flag = 0 AND binding_flag = 1
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND tm.relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
ORDER BY tmt.total_pay_count DESC LIMIT 15
|
</select>
|
|
<select id="getPlTotalMemberRankCustomerSource" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.customer_source mapKey,
|
COUNT(tm.user_id) mapValue
|
FROM t_member tm WHERE tm.del_flag = 0 AND binding_flag = 1
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND tm.relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tm.customer_source
|
ORDER BY COUNT(tm.user_id) DESC LIMIT 15
|
</select>
|
|
<select id="getPlTotalMemberRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.relation_shop_name mapKey,
|
COUNT(tm.user_id) mapValue
|
FROM t_member tm WHERE tm.del_flag = 0 AND binding_flag = 1
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND tm.relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tm.relation_shop_name
|
ORDER BY COUNT(tm.user_id) DESC LIMIT 15
|
</select>
|
|
|
<select id="listUserIdByShopId" resultType="java.lang.Long">
|
SELECT user_id
|
FROM t_member
|
WHERE del_flag = 0
|
<if test="shopIdList != null">
|
AND relation_shop_id IN
|
<foreach collection="shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="getMerMemberTotal" resultType="com.ruoyi.member.domain.vo.MerMemberTotalVo">
|
SELECT
|
COUNT(member_id) memberTotal,
|
IFNULL(SUM(CASE WHEN customer_source = "小程序" THEN 1 ELSE 0 END),0) onlineTotal,
|
IFNULL(SUM(CASE WHEN customer_source = "小程序" THEN 0 ELSE 1 END),0) offlineTotal,
|
0 introduceTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%周期%" THEN 1 ELSE 0 END),0) cycleTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%体验%" THEN 1 ELSE 0 END),0) experienceTotal,
|
IFNULL(SUM(CASE WHEN goods_type LIKE "%服务%" THEN 1 ELSE 0 END),0) serviceTotal
|
FROM t_member WHERE del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getMerMemberTotalAge" resultType="com.ruoyi.member.domain.vo.MgtAgeTotalVo">
|
SELECT
|
IFNULL(SUM(CASE WHEN gender = 0 THEN 1 ELSE 0 END),0) manTotal,
|
IFNULL(SUM(CASE WHEN gender = 1 THEN 1 ELSE 0 END),0) womenTotal,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) <= 20 THEN 1 ELSE 0 END),0) AS tenAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 21 AND 30 THEN 1 ELSE 0 END),0) AS twentyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 31 AND 40 THEN 1 ELSE 0 END),0) AS ThirtyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 41 AND 50 THEN 1 ELSE 0 END),0) AS fortyAge,
|
IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) >= 51 THEN 1 ELSE 0 END),0) AS fiftyAge
|
FROM t_member WHERE del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getMerMemberTotalNurse" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT member_nurse mapKey, COUNT(*) mapValue
|
FROM (
|
SELECT member_id, SUBSTRING_INDEX(SUBSTRING_INDEX(member_nurse, ',', numbers.n), ',', -1) member_nurse
|
FROM (SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15 UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18 UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21 UNION ALL SELECT 22 UNION ALL SELECT 23 UNION ALL SELECT 24 UNION ALL SELECT 25 UNION ALL SELECT 26 UNION ALL SELECT 27 UNION ALL SELECT 28 UNION ALL SELECT 29 UNION ALL SELECT 30 UNION ALL SELECT 31 UNION ALL SELECT 32 UNION ALL SELECT 33 UNION ALL SELECT 34 UNION ALL SELECT 35 UNION ALL SELECT 36 UNION ALL SELECT 37 UNION ALL SELECT 38 UNION ALL SELECT 39 UNION ALL SELECT 40) numbers
|
INNER JOIN t_member ON CHAR_LENGTH(member_nurse) - CHAR_LENGTH(REPLACE(member_nurse, ',', '')) >= numbers.n - 1 AND del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND binding_flag = 1 AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
) x
|
WHERE member_nurse IS NOT NULL OR member_nurse != ''
|
GROUP BY member_nurse
|
</select>
|
|
<select id="getMerMemberTotalLevel" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT level mapKey, COUNT(*) mapValue
|
FROM t_member
|
WHERE (level IS NOT NULL OR level != '') AND del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND binding_flag = 1 AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
GROUP BY level
|
</select>
|
|
<select id="getMerMemberTotalGoodsType" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT goods_type mapKey, COUNT(*) mapValue
|
FROM (
|
SELECT member_id, SUBSTRING_INDEX(SUBSTRING_INDEX(goods_type, ',', numbers.n), ',', -1) goods_type
|
FROM (SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5) numbers
|
INNER JOIN t_member ON CHAR_LENGTH(goods_type) - CHAR_LENGTH(REPLACE(goods_type, ',', '')) >= numbers.n - 1 AND del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND binding_flag = 1 AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(create_time) <= #{param.endDate}
|
</if>
|
) x
|
WHERE goods_type IS NOT NULL OR goods_type != ''
|
GROUP BY goods_type
|
</select>
|
|
<select id="getMerMemberTotalActiveness" resultType="java.lang.Integer">
|
SELECT
|
COUNT(tm.member_id)
|
FROM t_member tm
|
LEFT JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.del_Flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND binding_flag = 1 AND tm.relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND tm.relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tmt.last_service_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tmt.last_service_time) <= #{param.endDate}
|
</if>
|
</select>
|
|
<select id="getMerMemberPayRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.real_name mapKey,
|
tmt.total_pay_count mapValue
|
FROM t_member tm
|
INNER JOIN t_member_total tmt ON tm.member_id = tmt.member_id
|
WHERE tm.del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND binding_flag = 1 AND tm.relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND tm.relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
ORDER BY tmt.total_pay_count DESC LIMIT 10
|
</select>
|
|
<select id="getMerMemberCustomerSourceRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.customer_source mapKey,
|
COUNT(tm.user_id) mapValue
|
FROM t_member tm WHERE tm.del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND binding_flag = 1 AND tm.relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND tm.relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tm.customer_source
|
ORDER BY mapValue DESC LIMIT 10
|
</select>
|
|
|
<select id="getMerMemberRecommendRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo">
|
SELECT
|
tm.referrer mapKey,
|
COUNT(tm.user_id) mapValue
|
FROM t_member tm WHERE tm.del_flag = 0
|
<if test="param.shopId != null and param.shopId != ''">
|
AND binding_flag = 1 AND tm.relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND binding_flag = 1 AND tm.relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.startDate!=null and param.startDate!=''">
|
AND Date(tm.create_time) >= #{param.startDate}
|
</if>
|
<if test="param.endDate!=null and param.endDate!=''">
|
AND Date(tm.create_time) <= #{param.endDate}
|
</if>
|
GROUP BY tm.referrer
|
ORDER BY COUNT(tm.user_id) DESC LIMIT 15
|
</select>
|
|
|
<select id="listOrderAgeUser" resultType="java.lang.Long">
|
SELECT
|
user_id
|
FROM t_member WHERE del_flag = 0 AND binding_flag = 1
|
<if test="param.shopId != null and param.shopId != ''">
|
AND relation_shop_id = #{param.shopId}
|
</if>
|
<if test="param.shopIdList != null and param.shopIdList.size() > 0">
|
AND relation_shop_id IN
|
<foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
<if test="param.ageType !=null and param.ageType == 1">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 0 AND 20
|
</if>
|
<if test="param.ageType !=null and param.ageType == 2">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 21 AND 30
|
</if>
|
<if test="param.ageType !=null and param.ageType == 3">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 31 AND 40
|
</if>
|
<if test="param.ageType !=null and param.ageType == 4">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 41 AND 50
|
</if>
|
<if test="param.ageType !=null and param.ageType == 5">
|
AND TIMESTAMPDIFF(YEAR, birthday, CURDATE()) >= 51
|
</if>
|
</select>
|
|
<select id="getAreaNewMember" resultType="java.lang.Integer">
|
SELECT COUNT(member_id)
|
FROM t_member
|
WHERE del_flag = 0 AND binding_flag = 1 AND DATE(binding_time) = CURDATE()
|
AND relation_shop_id IN
|
<foreach collection="shopIdList" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="listTodayBirthday" resultType="com.ruoyi.system.api.domain.poji.member.Member">
|
SELECT *
|
FROM t_member
|
WHERE del_flag = 0 AND DATE_FORMAT(birthday, '%m%d') = DATE_FORMAT(now(), '%m%d')
|
</select>
|
</mapper>
|