<?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.mall.member.mapper.MemberStatisticsInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.mall.member.domain.entity.MemberStatisticsInfo">
            <id column="id" property="id"/>
            <id column="member_id" property="memberId"/>
            <id column="consume_amount" property="consumeAmount"/>
            <id column="coupon_amount" property="couponAmount"/>
            <id column="order_count" property="orderCount"/>
            <id column="coupon_count" property="couponCount"/>
            <id column="comment_count" property="commentCount"/>
            <id column="return_order_count" property="returnOrderCount"/>
            <id column="login_count" property="loginCount"/>
            <id column="attend_count" property="attendCount"/>
            <id column="fans_count" property="fansCount"/>
            <id column="collect_product_count" property="collectProductCount"/>
            <id column="collect_subject_count" property="collectSubjectCount"/>
            <id column="collect_comment_count" property="collectCommentCount"/>
            <id column="invite_friend_count" property="inviteFriendCount"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,member_id,consume_amount,coupon_amount,order_count,coupon_count,comment_count,return_order_count,login_count,attend_count,fans_count,collect_product_count,collect_subject_count,collect_comment_count,invite_friend_count
    </sql>

    <!-- 分页查询会员统计信息内容 -->
    <select id="selectListByPage" resultType="com.mall.member.domain.vo.MemberStatisticsInfoVo">
        select
        <include refid="Base_Column_List"/>
        from ums_member_statistics_info
        <where>
                <if test="dto.id != null and dto.id != ''">
                    and id like CONCAT('%',#{dto.id},'%')
                </if>
                <if test="dto.memberId != null and dto.memberId != ''">
                    and member_id like CONCAT('%',#{dto.memberId},'%')
                </if>
                <if test="dto.consumeAmount != null and dto.consumeAmount != ''">
                    and consume_amount like CONCAT('%',#{dto.consumeAmount},'%')
                </if>
                <if test="dto.couponAmount != null and dto.couponAmount != ''">
                    and coupon_amount like CONCAT('%',#{dto.couponAmount},'%')
                </if>
                <if test="dto.orderCount != null and dto.orderCount != ''">
                    and order_count like CONCAT('%',#{dto.orderCount},'%')
                </if>
                <if test="dto.couponCount != null and dto.couponCount != ''">
                    and coupon_count like CONCAT('%',#{dto.couponCount},'%')
                </if>
                <if test="dto.commentCount != null and dto.commentCount != ''">
                    and comment_count like CONCAT('%',#{dto.commentCount},'%')
                </if>
                <if test="dto.returnOrderCount != null and dto.returnOrderCount != ''">
                    and return_order_count like CONCAT('%',#{dto.returnOrderCount},'%')
                </if>
                <if test="dto.loginCount != null and dto.loginCount != ''">
                    and login_count like CONCAT('%',#{dto.loginCount},'%')
                </if>
                <if test="dto.attendCount != null and dto.attendCount != ''">
                    and attend_count like CONCAT('%',#{dto.attendCount},'%')
                </if>
                <if test="dto.fansCount != null and dto.fansCount != ''">
                    and fans_count like CONCAT('%',#{dto.fansCount},'%')
                </if>
                <if test="dto.collectProductCount != null and dto.collectProductCount != ''">
                    and collect_product_count like CONCAT('%',#{dto.collectProductCount},'%')
                </if>
                <if test="dto.collectSubjectCount != null and dto.collectSubjectCount != ''">
                    and collect_subject_count like CONCAT('%',#{dto.collectSubjectCount},'%')
                </if>
                <if test="dto.collectCommentCount != null and dto.collectCommentCount != ''">
                    and collect_comment_count like CONCAT('%',#{dto.collectCommentCount},'%')
                </if>
                <if test="dto.inviteFriendCount != null and dto.inviteFriendCount != ''">
                    and invite_friend_count like CONCAT('%',#{dto.inviteFriendCount},'%')
                </if>
        </where>
    </select>

</mapper>
