|
- <?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="height" jdbcType="VARCHAR" property="height"/>
- <result column="weight" jdbcType="VARCHAR" property="weight"/>
- <result column="id_card" jdbcType="VARCHAR" property="idCard"/>
- <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">
- wcubi.`id`,wcubi.`phone`,wcubi.`birthdate`,wcubi.`education`,wcubi.`sex`,wcubi.`height`,wcubi.`weight`,wcubi.`id_card`,wcubi.`email`,
- wcubi.`address`,wcubi.`poins`,wcubi.`tag_id`,wcubi.`create_date`,wcubi.`update_date`,
- wcubi.`final_tenant_id`,wcubi.`tenant_id`,wcubi.`parent_tenant_id`,wcubi.`name`,wcubi.`nick_name`,
- wcubi.`avatar_url`,wcubi.`credit`,wcubi.`active_time`,wcubi.`login_count`,wcubi.`act_record`,
- wcubi.score_date,wcubi.status
- </sql>
-
- <sql id="dynamicWhereConditions">
- where wcubi.`final_tenant_id` = #{finalTenantId}
-
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </if>
- <if test=" null != id ">
- and wcubi.`id` = #{id}
- </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 != levelStartScore ">
- and wcubi.poins >= #{levelStartScore}
- </if>
-
- <if test=" null != levelEndScore">
- and wcubi.poins < #{levelEndScore}
- </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 != activeStartTime and null != activeEndTime">
- and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime}
- </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>
-
- <if test=" null != sortColumns">order by ${sortColumns}</if>
-
- </sql>
-
-
- <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select <include refid="allColumns"/>
- from wx_c_user_basic_info wcubi
- where wcubi.id =#{id}
- and wcubi.final_tenant_id = #{finalTenantId}
- </select>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
- select
- <include refid="allColumns"/>
- from wx_c_user_basic_info wcubi
- <include refid="dynamicWhereConditions"/>
- </select>
-
- <select id="findListPhoneAndNameByIds" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="BaseResultMap">
- select id, phone, nick_name, name, sex
- from wx_c_user_basic_info wcubi
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != ids ">
- and wcubi.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
-
- <select id="findIdList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="Long">
- select id
- from wx_c_user_basic_info wcubi
- <include refid="dynamicWhereConditions"/>
- </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(wcubi.id)
- from wx_c_user_basic_info wcubi
- where wcubi.sex =#{sex}
- and wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </if>
- <if test=" null != startTime ">
- and wcubi.create_date >= #{startTime}
- </if>
- <if test=" null != endTime">
- and wcubi.create_date <= #{endTime}
- </if>
- </select>
-
-
- <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(wcubi.id) from wx_c_user_basic_info wcubi
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </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="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(wcubi.id)
- from wx_c_user_basic_info wcubi
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </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>
-
- <sql id="allColumnsOfScoreList">
- wcubi.id,wcubi.phone,wcubi.birthdate,wcubi.education,wcubi.sex,wcubi.`height`,wcubi.`weight`,wcubi.`id_card`,wcubi.email,wcubi.address,wcubi.poins,wcubi.tag_id,
- wcubi.create_date,wcubi.update_date,wcubi.name,wcubi.level,wcubi.nick_name,wcubi.score_date,wcubi.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 wcubi
- where wcubi.status=0
- and wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </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>
- order by wcubi.`active_time` DESC
- </select>
-
- <select id="findBirthdayList" resultMap="BaseResultMap">
- select <include refid="allColumnsOfScoreList"/>
- from wx_c_user_basic_info wcubi
- where wcubi.status = 0
- and wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </if>
- AND DATE_FORMAT(wcubi.birthdate,'%m-%d') >= #{begin}
- AND DATE_FORMAT(wcubi.birthdate,'%m-%d') <= #{end}
- order by wcubi.`active_time` DESC
- </select>
-
- <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select count(wcubi.id)
- from wx_c_user_basic_info wcubi
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </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>
- <if test=" null != ids ">
- and wcubi.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </select>
-
- <select id="findCountHistory" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="com.iformall.domain.vo.UserCountVo">
- select count(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>
- from wx_c_user_basic_info wcubi
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </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>
-
- <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="height" jdbcType="VARCHAR" property="height"/>
- <result column="weight" jdbcType="VARCHAR" property="weight"/>
- <result column="id_card" jdbcType="VARCHAR" property="idCard"/>
- <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="dynamicVoWhereConditions">
- where wcubi.`final_tenant_id` = #{finalTenantId}
-
- <if test=" null != id ">
- and wcubi.`id` = #{id}
- </if>
-
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </if>
-
- <if test=" null != phone and '' != phone">
- and wcubi.`phone` like concat('%', #{phone},'%')
- </if>
-
- <if test=" null != birthdate ">
- and wcubi.`birthdate` = #{birthdate}
- </if>
-
- <if test=" null != education and '' != education">
- and wcubi.`education` like concat('%', #{education},'%')
- </if>
-
- <if test=" null != sex ">
- and wcubi.`sex` = #{sex}
- </if>
-
- <if test=" null != email and '' != email">
- and wcubi.`email` like concat('%', #{email},'%')
- </if>
-
- <if test=" null != address and '' != address">
- and wcubi.`address` like concat('%', #{address},'%')
- </if>
-
- <if test=" null != poins ">
- and wcubi.`poins` = #{poins}
- </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 '' != 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 != activeStartTime and null!=activeEndTime">
- and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime}
- </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="findVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultMap="VoBaseResultMap">
- select
- wcubi.`id`,wcubi.`name`,wcubi.`sex`,wcubi.`height`,wcubi.`weight`,wcubi.`id_card`,wcubi.`phone`,wcubi.`nick_name`,wcubi.`education`,wcubi.`birthdate`,wcubi.`address`,
- wcubi.`active_time`,wcubi.`create_date`,wcubi.`poins`,wcubi.`credit`,wcubi.`tag_id`
- from wx_c_user_basic_info wcubi
- <include refid="dynamicVoWhereConditions"/>
- <if test=" null != begin ">
- limit #{begin}, #{limit}
- </if>
- </select>
-
-
- <select id="countVoList" parameterType="com.iformall.domain.po.WxCUserBasicInfo" resultType="java.lang.Integer">
- select
- count(wcubi.id)
- from wx_c_user_basic_info wcubi
- <include refid="dynamicVoWhereConditions"/>
- </select>
-
-
- <sql id="filterWhereConditions">
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </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 != loginStartTime ">
- and wcubi.active_time >= #{loginStartTime}
- </if>
-
- <if test=" null != loginEndTime">
- and wcubi.active_time <= #{loginEndTime}
- </if>
-
- <if test=" null != phones">
- and wcubi.phone in (${phones})
- </if>
-
- <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore)">
- and wcubi.poins >= #{levelStartScore}
- <if test=" null != levelEndScore">
- and wcubi.poins < #{levelEndScore}
- </if>
- </if>
-
- <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore)">
- and (wcubi.poins is null or
- (wcubi.poins >= #{levelStartScore}
- <if test=" null != levelEndScore">
- and wcubi.poins < #{levelEndScore}
- </if>
- ))
- </if>
-
- <if test=" null != ids ">
- and wcubi.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
-
- <if test=" null != tagIds ">
- and wcubi.`tag_id` in
- <foreach collection="tagIds" index="index" item="tagIdItem" open="(" separator="," close=")">
- #{tagIdItem}
- </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 wcubi.id)
- from wx_c_user_basic_info wcubi
- <include refid="filterWhereConditions"/>
- </select>
-
-
- <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
- select wcubi.`id`,wcubi.`phone`,wcubi.`email`
- from wx_c_user_basic_info wcubi
- <include refid="filterWhereConditions"/>
- </select>
-
- <select id="findIdByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
- select id
- from wx_c_user_basic_info wcubi
- <include refid="filterWhereConditions"/>
- </select>
-
- <select id="findGrowUserCount" resultType="java.lang.Long">
- SELECT count(wcubi.id)
- FROM wx_c_user_basic_info wcubi
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </if>
- </select>
-
- <select id="getTotalCreditAmount" resultType="java.lang.Long">
- SELECT IFNULL(SUM(wcubi.credit),0)
- FROM wx_c_user_basic_info wcubi
- where wcubi.`final_tenant_id` = #{finalTenantId}
- <if test=" null != tenantId and '' != tenantId">
- and wcubi.`tenant_id` like concat('%,', #{tenantId},',%')
- </if>
- </select>
-
-
- <update id="incActRecordById" parameterType="java.util.HashMap">
- UPDATE wx_c_user_basic_info set act_record = act_record +1 where id = #{id} and final_tenant_id = #{finalTenantId}
- </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},#{tableIndex},#{finalTableIndex})}
- </update>
- </mapper>
|