<?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.gxwebsoft.shop.mapper.ShopUserMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM shop_user a
        <where>
            <if test="param.id != null">
              AND a.id = #{param.id}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.type != null">
                AND a.type = #{param.type}
            </if>
            <if test="param.username != null">
                AND a.username LIKE CONCAT('%', #{param.username}, '%')
            </if>
            <if test="param.password != null">
                AND a.password LIKE CONCAT('%', #{param.password}, '%')
            </if>
            <if test="param.nickname != null">
                AND a.nickname LIKE CONCAT('%', #{param.nickname}, '%')
            </if>
            <if test="param.phone != null">
                AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
            </if>
            <if test="param.sex != null">
                AND a.sex = #{param.sex}
            </if>
            <if test="param.position != null">
                AND a.position LIKE CONCAT('%', #{param.position}, '%')
            </if>
            <if test="param.platform != null">
                AND a.platform LIKE CONCAT('%', #{param.platform}, '%')
            </if>
            <if test="param.email != null">
                AND a.email LIKE CONCAT('%', #{param.email}, '%')
            </if>
            <if test="param.emailVerified != null">
                AND a.email_verified = #{param.emailVerified}
            </if>
            <if test="param.alias != null">
                AND a.alias LIKE CONCAT('%', #{param.alias}, '%')
            </if>
            <if test="param.realName != null">
                AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
            </if>
            <if test="param.idCard != null">
                AND a.id_card LIKE CONCAT('%', #{param.idCard}, '%')
            </if>
            <if test="param.birthday != null">
                AND a.birthday LIKE CONCAT('%', #{param.birthday}, '%')
            </if>
            <if test="param.country != null">
                AND a.country LIKE CONCAT('%', #{param.country}, '%')
            </if>
            <if test="param.province != null">
                AND a.province LIKE CONCAT('%', #{param.province}, '%')
            </if>
            <if test="param.city != null">
                AND a.city LIKE CONCAT('%', #{param.city}, '%')
            </if>
            <if test="param.region != null">
                AND a.region LIKE CONCAT('%', #{param.region}, '%')
            </if>
            <if test="param.address != null">
                AND a.address LIKE CONCAT('%', #{param.address}, '%')
            </if>
            <if test="param.longitude != null">
                AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
            </if>
            <if test="param.latitude != null">
                AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
            </if>
            <if test="param.balance != null">
                AND a.balance = #{param.balance}
            </if>
            <if test="param.cashedMoney != null">
                AND a.cashed_money = #{param.cashedMoney}
            </if>
            <if test="param.points != null">
                AND a.points = #{param.points}
            </if>
            <if test="param.payMoney != null">
                AND a.pay_money = #{param.payMoney}
            </if>
            <if test="param.expendMoney != null">
                AND a.expend_money = #{param.expendMoney}
            </if>
            <if test="param.payPassword != null">
                AND a.pay_password LIKE CONCAT('%', #{param.payPassword}, '%')
            </if>
            <if test="param.gradeId != null">
                AND a.grade_id = #{param.gradeId}
            </if>
            <if test="param.category != null">
                AND a.category LIKE CONCAT('%', #{param.category}, '%')
            </if>
            <if test="param.introduction != null">
                AND a.introduction LIKE CONCAT('%', #{param.introduction}, '%')
            </if>
            <if test="param.organizationId != null">
                AND a.organization_id = #{param.organizationId}
            </if>
            <if test="param.groupId != null">
                AND a.group_id = #{param.groupId}
            </if>
            <if test="param.avatar != null">
                AND a.avatar LIKE CONCAT('%', #{param.avatar}, '%')
            </if>
            <if test="param.bgImage != null">
                AND a.bg_image LIKE CONCAT('%', #{param.bgImage}, '%')
            </if>
            <if test="param.userCode != null">
                AND a.user_code LIKE CONCAT('%', #{param.userCode}, '%')
            </if>
            <if test="param.certification != null">
                AND a.certification = #{param.certification}
            </if>
            <if test="param.age != null">
                AND a.age = #{param.age}
            </if>
            <if test="param.offline != null">
                AND a.offline = #{param.offline}
            </if>
            <if test="param.followers != null">
                AND a.followers = #{param.followers}
            </if>
            <if test="param.fans != null">
                AND a.fans = #{param.fans}
            </if>
            <if test="param.likes != null">
                AND a.likes = #{param.likes}
            </if>
            <if test="param.commentNumbers != null">
                AND a.comment_numbers = #{param.commentNumbers}
            </if>
            <if test="param.recommend != null">
                AND a.recommend = #{param.recommend}
            </if>
            <if test="param.openid != null">
                AND a.openid LIKE CONCAT('%', #{param.openid}, '%')
            </if>
            <if test="param.officeOpenid != null">
                AND a.office_openid LIKE CONCAT('%', #{param.officeOpenid}, '%')
            </if>
            <if test="param.unionid != null">
                AND a.unionid LIKE CONCAT('%', #{param.unionid}, '%')
            </if>
            <if test="param.clientId != null">
                AND a.client_id LIKE CONCAT('%', #{param.clientId}, '%')
            </if>
            <if test="param.notAllowVip != null">
                AND a.not_allow_vip = #{param.notAllowVip}
            </if>
            <if test="param.isAdmin != null">
                AND a.is_admin = #{param.isAdmin}
            </if>
            <if test="param.isOrganizationAdmin != null">
                AND a.is_organization_admin = #{param.isOrganizationAdmin}
            </if>
            <if test="param.loginNum != null">
                AND a.login_num = #{param.loginNum}
            </if>
            <if test="param.companyId != null">
                AND a.company_id = #{param.companyId}
            </if>
            <if test="param.merchants != null">
                AND a.merchants LIKE CONCAT('%', #{param.merchants}, '%')
            </if>
            <if test="param.merchantId != null">
                AND a.merchant_id = #{param.merchantId}
            </if>
            <if test="param.merchantName != null">
                AND a.merchant_name LIKE CONCAT('%', #{param.merchantName}, '%')
            </if>
            <if test="param.merchantAvatar != null">
                AND a.merchant_avatar LIKE CONCAT('%', #{param.merchantAvatar}, '%')
            </if>
            <if test="param.uid != null">
                AND a.uid = #{param.uid}
            </if>
            <if test="param.expertType != null">
                AND a.expert_type = #{param.expertType}
            </if>
            <if test="param.expireTime != null">
                AND a.expire_time = #{param.expireTime}
            </if>
            <if test="param.settlementTime != null">
                AND a.settlement_time LIKE CONCAT('%', #{param.settlementTime}, '%')
            </if>
            <if test="param.aptitude != null">
                AND a.aptitude LIKE CONCAT('%', #{param.aptitude}, '%')
            </if>
            <if test="param.industryParent != null">
                AND a.industry_parent LIKE CONCAT('%', #{param.industryParent}, '%')
            </if>
            <if test="param.industryChild != null">
                AND a.industry_child LIKE CONCAT('%', #{param.industryChild}, '%')
            </if>
            <if test="param.title != null">
                AND a.title LIKE CONCAT('%', #{param.title}, '%')
            </if>
            <if test="param.templateId != null">
                AND a.template_id = #{param.templateId}
            </if>
            <if test="param.installed != null">
                AND a.installed = #{param.installed}
            </if>
            <if test="param.speciality != null">
                AND a.speciality LIKE CONCAT('%', #{param.speciality}, '%')
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
            <if test="param.keywords != null">
                AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
                )
              </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopUser">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopUser">
        <include refid="selectSql"></include>
    </select>

</mapper>
