|
- <?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.iformall.mapper.WxCUserBasicInfoMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserBasicInfo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="phone" jdbcType="VARCHAR" property="phone"/>
- <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
- <result column="education" jdbcType="VARCHAR" property="education"/>
- <result column="sex" jdbcType="INTEGER" property="sex"/>
- <result column="email" jdbcType="VARCHAR" property="email"/>
- <result column="address" jdbcType="VARCHAR" property="address"/>
- <result column="poins" jdbcType="INTEGER" property="poins"/>
- <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <!-- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>-->
- <result column="final_tenant_id" jdbcType="VARCHAR" property="finalTenantId"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="level" jdbcType="VARCHAR" property="level"/>
- <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
- <result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/>
- <result column="credit" jdbcType="INTEGER" property="credit"/>
- <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
- <result column="login_count" jdbcType="INTEGER" property="loginCount"/>
- <result column="act_record" jdbcType="INTEGER" property="actRecord"/>
- <result column="score_date" jdbcType="TIMESTAMP" property="scoreDate"/>
- <result column="status" jdbcType="INTEGER" property="status"/>
-
- </resultMap>
-
- <sql id="allColumns">
- distinct wcubi.`id`,wcubi.`phone`,wcubi.`birthdate`,wcubi.`education`,wcubi.`sex`,wcubi.`email`,
- wcubi.`address`,wcubi.`poins`,wcubi.`tag_id`,wcubi.`create_date`,wcubi.`update_date`,
- wcubi.`final_tenant_id`,wcubi.`name`,wcubi.`nick_name`,
- wcubi.`avatar_url`,wcubi.`credit`,wcubi.`active_time`,wcubi.`login_count`,wcubi.`act_record`
- ,(select level from wx_level_config
- where poins >= points and tenant_id=wcubi.final_tenant_id
- order by points desc limit 1 ) level,wcubi.status
- </sql>
-
- <sql id="allSimpleColumns">
- `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
- `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and wcubi.`id` = #{id}
- </if>
-
- <if test=" null != finalTenantId and '' != finalTenantId">
- and wcubi.`final_tenant_id` = #{finalTenantId}
- </if>
-
- <if test=" null != phone ">
- and wcubi.`phone` like concat('%', #{phone},'%')
- </if>
-
- <if test=" null != birthdate ">
- and wcubi.`birthdate` = #{birthdate}
- </if>
-
- <if test=" null != education ">
- and wcubi.`education` like concat('%', #{education},'%')
- </if>
-
- <if test=" null != sex ">
- and wcubi.`sex` = #{sex}
- </if>
-
- <if test=" null != email ">
- and wcubi.`email` like concat('%', #{email},'%')
- </if>
-
- <if test=" null != address ">
- and wcubi.`address` like concat('%', #{address},'%')
- </if>
-
- <if test=" null != poins ">
- and wcubi.`poins` = #{poins}
- </if>
-
- <if test=" null != credit ">
- and wcubi.`credit` = #{credit}
- </if>
-
- <if test=" null != tagId ">
- and wcubi.`tag_id` = #{tagId}
- </if>
-
- <if test=" null != createDate ">
- and wcubi.`create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and wcubi.`update_date` = #{updateDate}
- </if>
-
- <if test=" null != actRecord ">
- and wcubi.`act_record` = #{actRecord}
- </if>
-
- <if test=" null != name ">
- and wcubi.`name` like concat('%', #{name},'%')
- </if>
- <if test=" null != startTime and null!=endTime">
- and wcubi.`create_date` between #{startTime} and #{endTime}
- </if>
-
- <if test=" null != status ">
- and wcubi.`status` = #{status}
- </if>
-
- <if test=" null != ids ">
- and wcubi.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- order by wcubi.`active_time` DESC
- <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
-
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
- select r.* from (
- select
- <include refid="allColumns"/>
- from wx_c_user_basic_info wcubi
- <include refid="dynamicWhereConditions"/>
- ) r where 1=1
-
- <if test="null != level and '' != level">
- and r.level =#{level}
- </if>
- </select>
-
- <sql id="dynamicWhereConditions1">
- where 1 = 1
-
- <if test=" null != basicInfo.id ">
- and wcubi.`id` = #{basicInfo.id}
- </if>
-
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and wcu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and wcu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
-
- <if test=" null != basicInfo.phone ">
- and wcubi.`phone` like concat('%', #{basicInfo.phone},'%')
- </if>
-
- <if test=" null != basicInfo.birthdate ">
- and wcubi.`birthdate` = #{basicInfo.birthdate}
- </if>
-
- <if test=" null != basicInfo.education ">
- and wcubi.`education` like concat('%', #{basicInfo.education},'%')
- </if>
-
- <if test=" null != basicInfo.sex ">
- and wcubi.`sex` = #{basicInfo.sex}
- </if>
-
- <if test=" null != basicInfo.email ">
- and wcubi.`email` like concat('%', #{basicInfo.email},'%')
- </if>
-
- <if test=" null != basicInfo.address ">
- and wcubi.`address` like concat('%', #{basicInfo.address},'%')
- </if>
-
- <if test=" null != basicInfo.poins ">
- and wcubi.`poins` = #{basicInfo.poins}
- </if>
-
- <if test=" null != basicInfo.credit ">
- and wcubi.`credit` = #{basicInfo.credit}
- </if>
-
- <if test=" null != basicInfo.tagId ">
- and wcubi.`tag_id` = #{basicInfo.tagId}
- </if>
-
- <if test=" null != basicInfo.createDate ">
- and wcubi.`create_date` = #{basicInfo.createDate}
- </if>
-
- <if test=" null != basicInfo.updateDate ">
- and wcubi.`update_date` = #{basicInfo.updateDate}
- </if>
-
- <if test=" null != basicInfo.actRecord ">
- and wcubi.`act_record` = #{basicInfo.actRecord}
- </if>
-
- <if test=" null != basicInfo.name ">
- and wcubi.`name` like concat('%', #{basicInfo.name},'%')
- </if>
- <if test=" null != basicInfo.startTime and null != basicInfo.endTime">
- and wcubi.`create_date` between #{basicInfo.startTime} and #{basicInfo.endTime}
- </if>
-
- <if test=" null != basicInfo.status ">
- and wcubi.`status` = #{basicInfo.status}
- </if>
-
- <if test=" null != basicInfo.ids ">
- and wcubi.id in
- <foreach collection="basicInfo.ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- order by wcubi.`active_time` DESC
- <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
-
- </sql>
-
- <select id="findList1" resultMap="BaseResultMap">
- select r.* from (
- select
- <include refid="allColumns"/>
- from wx_c_user_basic_info wcubi
- left join wx_c_user wcu on wcu.user_id = wcubi.id
- <include refid="dynamicWhereConditions1"/>
- ) r where 1=1
-
- <if test="null != basicInfo.level and '' != basicInfo.level">
- and r.level =#{basicInfo.level}
- </if>
- </select>
-
- <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
- update wx_c_user_basic_info set poins=#{poins}
- where id=#{id}
- </update>
- <update id="updateUpScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
- update wx_c_user_basic_info set poins=poins+#{poins}
- where id=#{id}
- </update>
- <update id="updateDownScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
- update wx_c_user_basic_info set poins=poins-#{poins}
- where id=#{id}
- </update>
-
- <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserBaseVo">
- update wx_c_user_basic_info set id=#{newId} , credit=#{credit} , poins=#{poins}
- where id = #{id}
- </update>
-
- <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- where wcubi.sex =#{sex}
- <if test=" null != finalTenantId and '' != finalTenantId">
- and wcubi.`final_tenant_id` = #{finalTenantId}
- </if>
- <if test=" null != startTime ">
- and wcubi.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and wcubi.create_date <= #{endTime}
- </if>
- </select>
-
- <select id="findCountBySex1" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- left join wx_c_user wcu on wcu.user_id = wcubi.id
- where wcubi.sex =#{basicInfo.sex}
- <if test=" null != basicInfo.startTime ">
- and wcubi.create_date >= #{basicInfo.startTime}
- </if>
- <if test=" null != basicInfo.endTime">
- and wcubi.create_date <= #{basicInfo.endTime}
- </if>
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and wcu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and wcu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
- </select>
-
-
- <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- where 1=1
- <if test=" null != finalTenantId and '' != finalTenantId">
- and wcubi.`final_tenant_id` = #{finalTenantId}
- </if>
- <if test=" null != startTime ">
- and wcubi.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and wcubi.create_date <= #{endTime}
- </if>
-
- <if test=" null != birthStartTime ">
- and wcubi.birthdate >= #{birthStartTime}
- </if>
-
- <if test=" null != birthEndTime">
- and wcubi.birthdate <= #{birthEndTime}
- </if>
-
- <if test=" null == birthStartTime and null == birthEndTime">
- and wcubi.birthdate is null
- </if>
-
- </select>
-
- <select id="findCountByAge1" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- left join wx_c_user wcu on wcu.user_id = wcubi.id
- where 1=1
- <if test=" null != basicInfo.startTime ">
- and wcubi.create_date >= #{basicInfo.startTime}
- </if>
- <if test=" null != basicInfo.endTime">
- and wcubi.create_date <= #{basicInfo.endTime}
- </if>
-
- <if test=" null != basicInfo.birthStartTime ">
- and wcubi.birthdate >= #{basicInfo.birthStartTime}
- </if>
-
- <if test=" null != basicInfo.birthEndTime">
- and wcubi.birthdate <= #{basicInfo.birthEndTime}
- </if>
-
- <if test=" null == basicInfo.birthStartTime and null == basicInfo.birthEndTime">
- and wcubi.birthdate is null
- </if>
-
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and wcu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and wcu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
-
- </select>
-
- <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- where 1=1
- <if test=" null != finalTenantId and '' != finalTenantId">
- and wcubi.`final_tenant_id` = #{finalTenantId}
- </if>
- <if test=" null != startTime ">
- and wcubi.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and wcubi.create_date <= #{endTime}
- </if>
-
- <if test=" null != levelStartScore ">
- and wcubi.poins >= #{levelStartScore}
- </if>
-
- <if test=" null != levelEndScore">
- and wcubi.poins < #{levelEndScore}
- </if>
-
- <if test=" null == levelStartScore and null == levelEndScore">
- and wcubi.poins is null
- </if>
-
- </select>
-
- <select id="findCountByScore1" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- left join wx_c_user wcu on wcu.user_id = wcubi.id
- where 1=1
- <if test=" null != basicInfo.startTime ">
- and wcubi.create_date >= #{basicInfo.startTime}
- </if>
- <if test=" null != basicInfo.endTime">
- and wcubi.create_date <= #{basicInfo.endTime}
- </if>
-
- <if test=" null != basicInfo.levelStartScore ">
- and wcubi.poins >= #{basicInfo.levelStartScore}
- </if>
-
- <if test=" null != basicInfo.levelEndScore">
- and wcubi.poins < #{basicInfo.levelEndScore}
- </if>
-
- <if test=" null == basicInfo.levelStartScore and null == basicInfo.levelEndScore">
- and wcubi.poins is null
- </if>
-
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and wcu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and wcu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
-
- </select>
-
- <sql id="allColumnsOfScoreList">
- distinct cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id,
- cub.create_date,cub.update_date,cub.name,cub.level,cub.nick_name,cub.score_date,cub.final_tenant_id
- </sql>
-
- <select id="findListByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
- select <include refid="allColumnsOfScoreList"/>
- from wx_c_user_basic_info cub
- where cub.status=0
- <if test=" null != finalTenantId and '' != finalTenantId">
- and cub.`final_tenant_id` = #{finalTenantId}
- </if>
- <if test=" null != levelStartScore ">
- and cub.poins >= #{levelStartScore}
- </if>
-
- <if test=" null != levelEndScore">
- and cub.poins <= #{levelEndScore}
- </if>
-
- <if test=" null == levelStartScore and null == levelEndScore">
- and cub.poins is null
- </if>
- order by cub.`active_time` DESC
- </select>
-
- <select id="findListByScore1" resultMap="BaseResultMap">
- select <include refid="allColumnsOfScoreList"/>
- from wx_c_user_basic_info cub
- inner join wx_c_user cu on cu.user_id = cub.id
- where cub.status=0
- <if test=" null != basicInfo.levelStartScore ">
- and cub.poins >= #{basicInfo.levelStartScore}
- </if>
-
- <if test=" null != basicInfo.levelEndScore">
- and cub.poins <= #{basicInfo.levelEndScore}
- </if>
-
- <if test=" null == basicInfo.levelStartScore and null == basicInfo.levelEndScore">
- and cub.poins is null
- </if>
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and cu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and cu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
- order by cub.`active_time` DESC
- </select>
-
- <select id="findBirthdayList" resultMap="BaseResultMap">
- select <include refid="allColumnsOfScoreList"/>
- from wx_c_user_basic_info cub
- inner join wx_c_user cu on cu.user_id = cub.id
- where cub.status = 0
- AND DATE_FORMAT(cub.birthdate,'%m-%d') >= #{begin}
- AND DATE_FORMAT(cub.birthdate,'%m-%d') <= #{end}
- <if test=" null != finalTenantId and '' != finalTenantId">
- and cub.`final_tenant_id` = #{finalTenantId}
- </if>
- order by cub.`active_time` DESC
- </select>
-
- <select id="findBirthdayList1" resultMap="BaseResultMap">
- select <include refid="allColumnsOfScoreList"/>
- from wx_c_user_basic_info cub
- inner join wx_c_user cu on cu.user_id = cub.id
- where cub.status = 0
- AND DATE_FORMAT(cub.birthdate,'%m-%d') >= #{begin}
- AND DATE_FORMAT(cub.birthdate,'%m-%d') <= #{end}
- <if test=" null != tenantId and '' != tenantId">
- and cu.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cu.`parent_tenant_id` = #{parentTenantId}
- </if>
- order by cub.`active_time` DESC
- </select>
-
- <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- where 1=1
- <if test=" null != finalTenantId and '' != finalTenantId">
- and wcubi.`final_tenant_id` = #{finalTenantId}
- </if>
- <if test=" null != startTime ">
- and wcubi.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and wcubi.create_date < #{endTime}
- </if>
- <if test="1 == queryImport">
- and wcubi.create_date like '%00:00:00'
- </if>
- </select>
-
- <select id="findCount1" resultType="java.lang.Long">
- select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- left join wx_c_user wcu on wcu.user_id = wcubi.id
- where 1=1
- <if test=" null != basicInfo.startTime ">
- and wcubi.create_date >= #{basicInfo.startTime}
- </if>
- <if test=" null != basicInfo.endTime">
- and wcubi.create_date < #{basicInfo.endTime}
- </if>
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and wcu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and wcu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
- <if test="1 == basicInfo.queryImport">
- and wcubi.create_date like '%00:00:00'
- </if>
- </select>
-
- <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo">
- select count(distinct wcubi.id) as incCount,
- <if test="1 == reportType ">
- date_format(wcubi.create_date, '%Y-%m-%d') as reportTime,
- </if>
- <if test="2 == reportType ">
- date_format(wcubi.create_date, '%Y-%m') as reportTime,
- </if>
- <if test="3 == reportType ">
- date_format(wcubi.create_date, '%Y') as reportTime,
- </if>
-
- <if test="1 == reportType or 2 == reportType or 3 == reportType">
- (select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- where
- <if test="1 == reportType ">
- date_format(wcubi.create_date, '%Y-%m-%d') <= reportTime
- </if>
- <if test="2 == reportType ">
- date_format(wcubi.create_date, '%Y-%m') <= reportTime
- </if>
- <if test="3 == reportType ">
- date_format(wcubi.create_date, '%Y') <= reportTime
- </if>
- <if test=" null != finalTenantId and '' != finalTenantId">
- and wcubi.`final_tenant_id` = #{finalTenantId}
- </if>
- ) as totalCount
- </if>
- from wx_c_user_basic_info wcubi
- where 1=1
- <if test=" null != finalTenantId and '' != finalTenantId">
- and wcubi.`final_tenant_id` = #{finalTenantId}
- </if>
- <if test=" null != startTime ">
- and wcubi.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and wcubi.create_date < #{endTime}
- </if>
- <if test="1 == reportType or 2 == reportType or 3 == reportType">
- group by reportTime
- </if>
- </select>
-
- <select id="findCountHistory1" resultType="com.iformall.domain.vo.UserCountVo">
- select count(distinct wcubi.id) as incCount,
- <if test="1 == basicInfo.reportType ">
- date_format(wcubi.create_date, '%Y-%m-%d') as reportTime,
- </if>
- <if test="2 == basicInfo.reportType ">
- date_format(wcubi.create_date, '%Y-%m') as reportTime,
- </if>
- <if test="3 == basicInfo.reportType ">
- date_format(wcubi.create_date, '%Y') as reportTime,
- </if>
-
- <if test="1 == basicInfo.reportType or 2 == basicInfo.reportType or 3 == basicInfo.reportType">
- (select count(distinct wcubi.id) from wx_c_user_basic_info wcubi
- left join wx_c_user wcu on wcu.user_id = wcubi.id
- where
- <if test="1 == basicInfo.reportType ">
- date_format(wcubi.create_date, '%Y-%m-%d') <= reportTime
- </if>
- <if test="2 == basicInfo.reportType ">
- date_format(wcubi.create_date, '%Y-%m') <= reportTime
- </if>
- <if test="3 == basicInfo.reportType ">
- date_format(wcubi.create_date, '%Y') <= reportTime
- </if>
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and wcu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and wcu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
- ) as totalCount
- </if>
- from wx_c_user_basic_info wcubi
- left join wx_c_user wcu on wcu.user_id = wcubi.id
- where 1=1
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and wcu.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and wcu.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
- <if test=" null != basicInfo.startTime ">
- and wcubi.create_date >= #{basicInfo.startTime}
- </if>
- <if test=" null != basicInfo.endTime">
- and wcubi.create_date < #{basicInfo.endTime}
- </if>
- <if test="1 == basicInfo.reportType or 2 == basicInfo.reportType or 3 == basicInfo.reportType">
- group by reportTime
- </if>
- </select>
-
- <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxCUserBasicInfoVo">
- <id column="id" jdbcType="BIGINT" property="id"/>
- <result column="phone" jdbcType="VARCHAR" property="phone"/>
- <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
- <result column="education" jdbcType="VARCHAR" property="education"/>
- <result column="sex" jdbcType="INTEGER" property="sex"/>
- <result column="email" jdbcType="VARCHAR" property="email"/>
- <result column="address" jdbcType="VARCHAR" property="address"/>
- <result column="poins" jdbcType="INTEGER" property="poins"/>
- <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
- <!-- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>-->
- <!-- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>-->
- <result column="final_tenant_id" jdbcType="VARCHAR" property="finalTenantId"/>
- <result column="name" jdbcType="VARCHAR" property="name"/>
- <result column="level" jdbcType="VARCHAR" property="level"/>
- <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
- <result column="credit" jdbcType="INTEGER" property="credit"/>
- <result column="tags" jdbcType="VARCHAR" property="tags"/>
- <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
- </resultMap>
-
- <sql id="allVoColumns">
- distinct cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`,
- cu.`create_date`,cu.`update_date`,cu.`name`,cu.`level`,cu.`nick_name`,
- cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`final_tenant_id`
- </sql>
-
- <sql id="dynamicVoWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and cu.`id` = #{id}
- </if>
-
- <if test=" null != finalTenantId and '' != finalTenantId">
- and cu.`final_tenant_id` = #{finalTenantId}
- </if>
-
- <if test=" null != phone ">
- and cu.`phone` like concat('%', #{phone},'%')
- </if>
-
- <if test=" null != birthdate ">
- and cu.`birthdate` = #{birthdate}
- </if>
-
- <if test=" null != education ">
- and cu.`education` like concat('%', #{education},'%')
- </if>
-
- <if test=" null != sex ">
- and cu.`sex` = #{sex}
- </if>
-
- <if test=" null != email ">
- and cu.`email` like concat('%', #{email},'%')
- </if>
-
- <if test=" null != address ">
- and cu.`address` like concat('%', #{address},'%')
- </if>
-
- <if test=" null != poins ">
- and cu.`poins` = #{poins}
- </if>
-
- <if test=" null != tagId ">
- and cu.`tag_id` = #{tagId}
- </if>
-
- <if test=" null != createDate ">
- and cu.`create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and cu.`update_date` = #{updateDate}
- </if>
-
- <if test=" null != actRecord ">
- and cu.`act_record` = #{actRecord}
- </if>
-
- <if test=" null != name ">
- and cu.`name` like concat('%', #{name},'%')
- </if>
- <if test=" null != startTime and null!=endTime">
- and cu.`create_date` between #{startTime} and #{endTime}
- </if>
- <if test=" null != ids ">
- and cu.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <!--<if test=" null != sortColumns">order by ${sortColumns}</if>-->
- </sql>
-
- <sql id="dynamicVoWhereConditions1">
- where 1 = 1
-
- <if test=" null != basicInfo.id ">
- and cu.`id` = #{basicInfo.id}
- </if>
-
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and c.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and c.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
-
- <if test=" null != basicInfo.phone ">
- and cu.`phone` like concat('%', #{basicInfo.phone},'%')
- </if>
-
- <if test=" null != basicInfo.birthdate ">
- and cu.`birthdate` = #{basicInfo.birthdate}
- </if>
-
- <if test=" null != basicInfo.education ">
- and cu.`education` like concat('%', #{basicInfo.education},'%')
- </if>
-
- <if test=" null != basicInfo.sex ">
- and cu.`sex` = #{basicInfo.sex}
- </if>
-
- <if test=" null != basicInfo.email ">
- and cu.`email` like concat('%', #{basicInfo.email},'%')
- </if>
-
- <if test=" null != basicInfo.address ">
- and cu.`address` like concat('%', #{basicInfo.address},'%')
- </if>
-
- <if test=" null != basicInfo.poins ">
- and cu.`poins` = #{basicInfo.poins}
- </if>
-
- <if test=" null != basicInfo.tagId ">
- and cu.`tag_id` = #{basicInfo.tagId}
- </if>
-
- <if test=" null != basicInfo.createDate ">
- and cu.`create_date` = #{basicInfo.createDate}
- </if>
-
- <if test=" null != basicInfo.updateDate ">
- and cu.`update_date` = #{basicInfo.updateDate}
- </if>
-
- <if test=" null != basicInfo.actRecord ">
- and cu.`act_record` = #{basicInfo.actRecord}
- </if>
-
- <if test=" null != basicInfo.name ">
- and cu.`name` like concat('%', #{basicInfo.name},'%')
- </if>
- <if test=" null != basicInfo.startTime and null != basicInfo.endTime">
- and cu.`create_date` between #{basicInfo.startTime} and #{basicInfo.endTime}
- </if>
- <if test=" null != basicInfo.ids ">
- and cu.id in
- <foreach collection="basicInfo.ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
- </sql>
-
- <select id="findVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="VoBaseResultMap">
- select
- <include refid="allSimpleColumns"/>
- from wx_c_user_basic_info cu
- <include refid="dynamicVoWhereConditions"/>
- <if test=" null != begin ">
- limit #{begin}, #{limit}
- </if>
- order by cu.`active_time` DESC
- </select>
-
- <select id="findVoList1" resultMap="VoBaseResultMap">
- select
- <include refid="allVoColumns"/>
- from wx_c_user_basic_info cu
- left join wx_c_user c on c.user_id = cu.id
- left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- <include refid="dynamicVoWhereConditions1"/>
- <if test=" null != basicInfo.begin ">
- limit #{basicInfo.begin}, #{basicInfo.limit}
- </if>
- order by cu.`active_time` DESC
- </select>
-
- <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer">
- select
- count(distinct cu.id)
- from wx_c_user_basic_info cu
- <include refid="dynamicVoWhereConditions"/>
- </select>
-
- <select id="countVoList1" resultType="java.lang.Integer">
- select
- count(distinct cu.id)
- from wx_c_user_basic_info cu
- left join wx_c_user c on c.user_id = cu.id
- left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- <include refid="dynamicVoWhereConditions1"/>
- </select>
-
-
- <sql id="msgColumns">
- distinct cu.`id`,cu.`phone`,cu.`email`
- </sql>
-
- <sql id="filterWhereConditions">
- where 1=1
- <if test=" null != finalTenantId and '' != finalTenantId">
- and cu.`final_tenant_id` = #{finalTenantId}
- </if>
-
- <if test=" null != startTime ">
- and cu.create_date >= #{startTime}
- </if>
-
- <if test=" null != endTime">
- and cu.create_date <= #{endTime}
- </if>
-
- <if test=" null != birthStartTime ">
- and cu.birthdate >= #{birthStartTime}
- </if>
-
- <if test=" null != birthEndTime">
- and cu.birthdate < #{birthEndTime}
- </if>
-
- <if test=" null != loginStartTime ">
- and cu.active_time >= #{loginStartTime}
- </if>
-
- <if test=" null != loginEndTime">
- and cu.active_time <= #{loginEndTime}
- </if>
-
- <if test=" null != verifiedStartTime and null != verifiedEndTime ">
- and 0<
- (select count(*) from wx_coupon_order co
- where cu.id = co.c_user_id
- and co.coupon_order_status = 1
- and co.update_date >= #{verifiedStartTime}
- and co.update_date <= #{verifiedEndTime})
- </if>
-
- <if test=" null != phones">
- and cu.phone in (${phones})
- </if>
-
- <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore)">
- and cu.poins >= #{levelStartScore}
- <if test=" null != levelEndScore">
- and cu.poins < #{levelEndScore}
- </if>
- </if>
-
- <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore)">
- and (cu.poins is null or
- (cu.poins >= #{levelStartScore}
- <if test=" null != levelEndScore">
- and cu.poins < #{levelEndScore}
- </if>
- ))
- </if>
-
- <if test=" null != tagIds ">
- and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY
- <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- )
- </if>
- <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
- </sql>
-
- <sql id="filterWhereConditions1">
- where 1=1
- <if test=" null != tenantInfo.tenantId and '' != tenantInfo.tenantId">
- and c.`tenant_id` = #{tenantInfo.tenantId}
- </if>
- <if test=" null != tenantInfo.parentTenantId and '' != tenantInfo.parentTenantId">
- and c.`parent_tenant_id` = #{tenantInfo.parentTenantId}
- </if>
-
- <if test=" null != basicInfo.startTime ">
- and cu.create_date >= #{basicInfo.startTime}
- </if>
-
- <if test=" null != basicInfo.endTime">
- and cu.create_date <= #{basicInfo.endTime}
- </if>
-
- <if test=" null != basicInfo.birthStartTime ">
- and cu.birthdate >= #{basicInfo.birthStartTime}
- </if>
-
- <if test=" null != basicInfo.birthEndTime">
- and cu.birthdate < #{basicInfo.birthEndTime}
- </if>
-
- <if test=" null != basicInfo.loginStartTime ">
- and cu.active_time >= #{basicInfo.loginStartTime}
- </if>
-
- <if test=" null != basicInfo.loginEndTime">
- and cu.active_time <= #{basicInfo.loginEndTime}
- </if>
-
- <if test=" null != basicInfo.verifiedStartTime and null != basicInfo.verifiedEndTime ">
- and 0<
- (select count(*) from wx_coupon_order co
- where cu.id = co.c_user_id
- and co.coupon_order_status = 1
- and co.update_date >= #{basicInfo.verifiedStartTime}
- and co.update_date <= #{basicInfo.verifiedEndTime})
- </if>
-
- <if test=" null != basicInfo.phones">
- and cu.phone in (${basicInfo.phones})
- </if>
-
- <if test=" null != basicInfo.levelStartScore and (0 != basicInfo.levelStartScore and '' != basicInfo.levelStartScore)">
- and cu.poins >= #{basicInfo.levelStartScore}
- <if test=" null != basicInfo.levelEndScore">
- and cu.poins < #{basicInfo.levelEndScore}
- </if>
- </if>
-
- <if test=" null != basicInfo.levelStartScore and (0 == basicInfo.levelStartScore or '' == basicInfo.levelStartScore)">
- and (cu.poins is null or
- (cu.poins >= #{basicInfo.levelStartScore}
- <if test=" null != basicInfo.levelEndScore">
- and cu.poins < #{basicInfo.levelEndScore}
- </if>
- ))
- </if>
-
- <if test=" null != basicInfo.tagIds ">
- and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY
- <foreach collection="basicInfo.tagIds" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- )
- </if>
- <!-- <if test=" null != sortColumns">order by ${sortColumns}</if>-->
- </sql>
-
- <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(distinct cu.id) from wx_c_user_basic_info cu
- <if test=" null != tagIds ">
- join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- </if>
- <include refid="filterWhereConditions"/>
- </select>
-
- <select id="findCountByFilter1" resultType="java.lang.Long">
- select count(distinct cu.id) from wx_c_user_basic_info cu
- left join wx_c_user c on c.user_id = cu.id
- <if test=" null != basicInfo.tagIds ">
- join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- </if>
- <include refid="filterWhereConditions1"/>
- </select>
-
- <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
- select <include refid="msgColumns"/>
- from wx_c_user_basic_info cu
- <if test=" null != tagIds ">
- join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- </if>
- <include refid="filterWhereConditions"/>
- </select>
-
- <select id="findListByFilter1" resultMap="BaseResultMap">
- select <include refid="msgColumns"/>
- from wx_c_user_basic_info cu
- left join wx_c_user c on c.user_id = cu.id
- <if test=" null != basicInfo.tagIds ">
- join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- </if>
- <include refid="filterWhereConditions1"/>
- </select>
-
-
- <select id="findImportUserCount" resultType="java.lang.Long">
- SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
- left join wx_c_user cu on cubi.id=cu.user_id
- where cu.id is null
- <if test=" null != finalTenantId and '' != finalTenantId">
- and cubi.`final_tenant_id` = #{finalTenantId}
- </if>
- </select>
-
- <select id="findImportUserCount1" resultType="java.lang.Long">
- SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
- left join wx_c_user cu on cubi.id=cu.user_id
- where cu.id is null
- <if test=" null != tenantId and '' != tenantId">
- and cu.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cu.`parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <select id="findGrowUserCount" resultType="java.lang.Long">
- SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
- left join wx_c_user cu on cubi.id=cu.user_id
- where cu.id is not null
- <if test=" null != finalTenantId and '' != finalTenantId">
- and cubi.`final_tenant_id` = #{finalTenantId}
- </if>
- </select>
-
- <select id="findGrowUserCount1" resultType="java.lang.Long">
- SELECT count(distinct cubi.id) FROM wx_c_user_basic_info cubi
- left join wx_c_user cu on cubi.id=cu.user_id
- where cu.id is not null
- <if test=" null != tenantId and '' != tenantId">
- and cu.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cu.`parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <update id="incActRecordById" parameterType="java.lang.Long">
- UPDATE wx_c_user_basic_info set act_record = act_record +1 where id = #{id}
- </update>
-
- <select id="selectNotCUserList" resultMap="BaseResultMap">
- select id,credit from wx_c_user_basic_info cub where not exists (select * from wx_c_user c where c.user_id=cub.id) and cub.credit is null
- </select>
-
- <update id="cuserOldToNew" statementType="CALLABLE" >
- {call cuser_old_to_new(#{oldCuserId},#{newCuserId})}
- </update>
- </mapper>
|