<?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.czg.service.account.mapper.ShopPushOpenIdMapper">

    <select id="pageInfo" resultType="com.czg.account.vo.ShopPushOpenIdVO">
        select
        nickname, avatar,
        SUM(IF(type = 0, `status`, 0)) AS proState,
        SUM(IF(type = 1, `status`, 0)) AS conState,
        SUM(IF(type = 2, `status`, 0)) AS opeState,
        SUM(IF(type = -1, `status`, 0)) AS allState
        from tb_shop_push_open_id where shop_id=#{shopId}
        <if test="nickName !=null and nickName != ''">
            and nickname like concat('%', #{nickName} '%')
        </if>
        <if test="openId !=null and openId != ''">
            and open_id like concat('%', #{openId} '%')
        </if>
        group by shop_id, open_id
    </select>
</mapper>
