WeFlowerCustomerRelMapper.xml 6.97 KB
<?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.linkwechat.wecom.mapper.WeFlowerCustomerRelMapper">
    
    <resultMap type="WeFlowerCustomerRel" id="WeFlowerCustomerRelResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="remark"    column="remark"    />
        <result property="description"    column="description"    />
        <result property="createTime"    column="create_time"    />
        <result property="remarkCorpName"    column="remark_corp_name"    />
<!--        <result property="remarkMobiles"    column="remark_mobiles"    />-->
        <result property="operUserid"    column="oper_userid"    />
        <result property="addWay"    column="add_way"    />
        <result property="state"    column="state"    />
        <result property="customerId"    column="customer_id"    />
    </resultMap>

    <sql id="selectWeFlowerCustomerRelVo">
        select id, user_id, remark, description, create_time, remark_corp_name, remark_mobiles, oper_userid, add_way, state, customer_id from we_flower_customer_rel
    </sql>

    <select id="selectWeFlowerCustomerRelList" parameterType="WeFlowerCustomerRel" resultMap="WeFlowerCustomerRelResult">
        <include refid="selectWeFlowerCustomerRelVo"/>
        <where>  
            <if test="userId != null  and userId != ''"> and user_id = #{userId}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="remarkCorpName != null  and remarkCorpName != ''"> and remark_corp_name like concat('%', #{remarkCorpName}, '%')</if>
            <if test="remarkMobiles != null  and remarkMobiles != ''"> and remark_mobiles = #{remarkMobiles}</if>
            <if test="operUserid != null  and operUserid != ''"> and oper_userid = #{operUserid}</if>
            <if test="addWay != null  and addWay != ''"> and add_way = #{addWay}</if>
            <if test="state != null  and state != ''"> and state = #{state}</if>
            <if test="customerId != null "> and customer_id = #{customerId}</if>
        </where>
    </select>
    
    <select id="selectWeFlowerCustomerRelById" parameterType="Long" resultMap="WeFlowerCustomerRelResult">
        <include refid="selectWeFlowerCustomerRelVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWeFlowerCustomerRel" parameterType="WeFlowerCustomerRel">
        insert into we_flower_customer_rel
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="userId != null">user_id,</if>
            <if test="remark != null">remark,</if>
            <if test="description != null">description,</if>
            <if test="createTime != null">create_time,</if>
            <if test="remarkCorpName != null">remark_corp_name,</if>
<!--            <if test="remarkMobiles != null">remark_mobiles,</if>-->
            <if test="operUserid != null">oper_userid,</if>
            <if test="addWay != null">add_way,</if>
            <if test="state != null">state,</if>
            <if test="customerId != null">customer_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="userId != null">#{userId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="description != null">#{description},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="remarkCorpName != null">#{remarkCorpName},</if>
<!--            <if test="remarkMobiles != null">#{remarkMobiles},</if>-->
            <if test="operUserid != null">#{operUserid},</if>
            <if test="addWay != null">#{addWay},</if>
            <if test="state != null">#{state},</if>
            <if test="customerId != null">#{customerId},</if>
         </trim>
    </insert>

    <update id="updateWeFlowerCustomerRel" parameterType="WeFlowerCustomerRel">
        update we_flower_customer_rel
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="description != null">description = #{description},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="remarkCorpName != null">remark_corp_name = #{remarkCorpName},</if>
<!--            <if test="remarkMobiles != null">remark_mobiles = #{remarkMobiles},</if>-->
            <if test="operUserid != null">oper_userid = #{operUserid},</if>
            <if test="addWay != null">add_way = #{addWay},</if>
            <if test="state != null">state = #{state},</if>
            <if test="customerId != null">customer_id = #{customerId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWeFlowerCustomerRelById" parameterType="Long">
        delete from we_flower_customer_rel where id = #{id}
    </delete>

    <delete id="deleteWeFlowerCustomerRelByIds" parameterType="String">
        delete from we_flower_customer_rel where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>



    <insert id="batchInsetWeFlowerCustomerRel" >
        insert into we_flower_customer_rel (id, user_id, remark, description, create_time, remark_corp_name, remark_mobiles, oper_userid, add_way, state, customer_id)
        values
        <foreach collection="weFlowerCustomerRels" item="tag" index="index" separator=",">
            (#{tag.id},#{tag.userId},#{tag.remark},#{tag.description},#{tag.createTime},#{tag.remarkCorpName},#{tag.remarkMobiles},#{tag.operUserid},#{tag.addWay},#{tag.state},#{tag.customerId})
        </foreach>
    </insert>


        <update id="batchLogicDeleteByIds" parameterType="String">
            update we_flower_customer_rel set del_flag=2
            where id in
            <foreach item="id" collection="ids" open="(" separator="," close=")">
                #{id}
            </foreach>
        </update>

    <select id="getUserAddCustomerStat" parameterType="WeFlowerCustomerRel" resultType="java.util.HashMap">
        select
		left(wfcr.create_time,10) as createTime , count(1) as total
	from
		we_flower_customer_rel wfcr
	<where>
        <if test="userId != null and userId != ''">and wfcr.user_id = #{userId}</if>
        <if test="addWay != null and addWay != ''">and wfcr.add_way = #{addWay}</if>
        <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
            AND date_format(wfcr.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
        </if>
        <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
            AND date_format(wfcr.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
        </if>
    </where>
	group by
		left(wfcr.create_time,10)
    </select>
</mapper>