|
- <?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="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">
- `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
- `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`final_tenant_id`,`name`,`nick_name`,
- `credit`,`active_time`,`login_count`,`act_record`
- ,(select level from wx_level_config
- where poins >= points and tenant_id=wcubi.tenant_id
- order by points desc limit 1 ) level,status
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and `id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != finalTenantId and '' != finalTenantId">
- and `final_tenant_id` = #{finalTenantId}
- </if>
-
- <if test=" null != phone ">
- and `phone` like concat('%', #{phone},'%')
- </if>
-
- <if test=" null != birthdate ">
- and `birthdate` = #{birthdate}
- </if>
-
- <if test=" null != education ">
- and `education` like concat('%', #{education},'%')
- </if>
-
- <if test=" null != sex ">
- and `sex` = #{sex}
- </if>
-
- <if test=" null != email ">
- and `email` like concat('%', #{email},'%')
- </if>
-
- <if test=" null != address ">
- and `address` like concat('%', #{address},'%')
- </if>
-
- <if test=" null != poins ">
- and `poins` = #{poins}
- </if>
-
- <if test=" null != credit ">
- and `credit` = #{credit}
- </if>
-
- <if test=" null != tagId ">
- and `tag_id` = #{tagId}
- </if>
-
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
-
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
-
- <if test=" null != actRecord ">
- and `act_record` = #{actRecord}
- </if>
-
- <if test=" null != name ">
- and `name` like concat('%', #{name},'%')
- </if>
- <if test=" null != startTime and null!=endTime">
- and `create_date` between #{startTime} and #{endTime}
- </if>
-
- <if test=" null != status ">
- and `status` = #{status}
- </if>
-
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <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="allUserColumns">
- c.`id`,c.`phone`,cb.`birthdate`,cb.`education`,cb.`sex`,cb.`email`,cb.`address`,cb.`poins`,cb.`tag_id`,
- cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.`level`,cb.`nick_name`,cb.`act_record`,cb.`parent_tenant_id`
- </sql>
-
- <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(id) from wx_c_user_basic_info
- where sex =#{sex}
- <if test=" null != startTime ">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date <= #{endTime}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
-
- <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(id) from wx_c_user_basic_info where 1=1
- <if test=" null != startTime ">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date <= #{endTime}
- </if>
-
- <if test=" null != birthStartTime ">
- and birthdate >= #{birthStartTime}
- </if>
-
- <if test=" null != birthEndTime">
- and birthdate <= #{birthEndTime}
- </if>
-
- <if test=" null == birthStartTime and null == birthEndTime">
- and birthdate is null
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- </select>
-
- <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(id) from wx_c_user_basic_info where 1=1
- <if test=" null != startTime ">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date <= #{endTime}
- </if>
-
- <if test=" null != levelStartScore ">
- and poins >= #{levelStartScore}
- </if>
-
- <if test=" null != levelEndScore">
- and poins < #{levelEndScore}
- </if>
-
- <if test=" null == levelStartScore and null == levelEndScore">
- and poins is null
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
-
- </select>
-
- <sql id="allColumnsOfScoreList">
- 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.tenant_id,cub.name,cub.level,cub.nick_name,cub.score_date,cub.parent_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
- inner join wx_c_user cu on cu.user_id = cub.id
-
- where 1=1 and cub.status=0
-
- <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>
-
- <if test=" null != tenantId and '' != tenantId">
- and cub.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cub.`parent_tenant_id` = #{parentTenantId}
- </if>
-
- </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 cu.phone is not null
- AND DATE_FORMAT(cub.birthdate,'%m-%d') >= #{begin}
- AND DATE_FORMAT(cub.birthdate,'%m-%d') <= #{end}
- <if test=" null != tenantId and '' != tenantId">
- and cub.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cub.`parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(id) from wx_c_user_basic_info where 1=1
- <if test=" null != startTime ">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date < #{endTime}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test="1 == queryImport">
- and 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(id) as incCount,
- <if test="1 == reportType ">
- date_format(create_date, '%Y-%m-%d') as reportTime,
- </if>
- <if test="2 == reportType ">
- date_format(create_date, '%Y-%m') as reportTime,
- </if>
- <if test="3 == reportType ">
- date_format(create_date, '%Y') as reportTime,
- </if>
-
- <if test="1 == reportType or 2 == reportType or 3 == reportType">
- (select count(id) from wx_c_user_basic_info
- where
- <if test="1 == reportType ">
- date_format(create_date, '%Y-%m-%d') <= reportTime
- </if>
- <if test="2 == reportType ">
- date_format(create_date, '%Y-%m') <= reportTime
- </if>
- <if test="3 == reportType ">
- date_format(create_date, '%Y') <= reportTime
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- ) as totalCount
- </if>
-
- from wx_c_user_basic_info where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != startTime ">
- and create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and create_date < #{endTime}
- </if>
- <if test="1 == reportType or 2 == reportType or 3 == 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="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">
- 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.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`,
- cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`parent_tenant_id`
- </sql>
-
- <sql id="dynamicVoWhereConditions">
- where 1 = 1
-
- <if test=" null != id ">
- and cu.`id` = #{id}
- </if>
-
- <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>
-
- <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 `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 id in
- <foreach collection="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="allVoColumns"/>
- from wx_c_user_basic_info cu
- left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- <include refid="dynamicVoWhereConditions"/>
- </select>
-
- <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer">
- select
- count(*)
- from wx_c_user_basic_info cu
- left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
- <include refid="dynamicVoWhereConditions"/>
- </select>
-
-
- <sql id="msgColumns">
- cu.`id`,cu.`phone`,cu.`email`
- </sql>
-
- <sql id="filterWhereConditions">
- where 1=1
- <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>
-
- <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>
-
- <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(*) 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="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="findImportUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- SELECT count(*) 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 cubi.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cubi.`parent_tenant_id` = #{parentTenantId}
- </if>
- </select>
-
- <select id="findGrowUserCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- SELECT count(*) 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 cubi.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and cubi.`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>
- </mapper>
|