<?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.xhpc.invoice.mapper.XhpcOperatorMapper">

    <resultMap type="com.xhpc.invoice.pojo.XhpcOperator" id="XhpcOperatorResult">
        <result column="operator_id" property="operatorId"/>
        <result column="name" property="name"/>
        <result column="contact_name" property="contactName"/>
        <result column="contact_phone" property="contactPhone"/>
        <result column="phone" property="phone"/>
        <result column="attribute" property="attribute"/>
        <result column="duty_paragraph" property="dutyParagraph"/>
        <result column="open_bank" property="openBank"/>
        <result column="card_number" property="cardNumber"/>
        <result column="area_code" property="areaCode"/>
        <result column="address" property="address"/>
        <result column="detailed_address" property="detailedAddress"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="email" property="email"/>
        <result column="commission_type" property="commissionType"/>
        <result column="platform_commission_rate" property="platformCommissionRate"/>
        <result column="maintenance_commission_rate" property="maintenanceCommissionRate"/>
        <result column="business_license_id" property="businessLicenseId"/>
        <result column="withdrawal_time" property="withdrawalTime"/>
        <result column="soc" property="soc"/>
        <result column="status" property="status"/>
        <result column="del_flag" property="delFlag"/>
        <result column="create_time" property="createTime"/>
        <result column="create_by" property="createBy"/>
        <result column="update_time" property="updateTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="remark" property="remark"/>
        <result column="operator_id_evcs" property="operatorIdEvcs"/>
    </resultMap>

    <sql id="Base_Column_List">
        xo
        .
        operator_id
        operatorId, xo.name, xo.contact_name contactName,  xo.contact_phone contactPhone,
                xo.phone, xo.attribute,xo.open_bank openBank,xo.card_number cardNumber, xo.area_code areaCode, xo.address,
                xo.detailed_address detailedAddress,   xo.duty_paragraph dutyParagraph,
                xo.longitude, xo.latitude, xo.email,  xo.commission_type commissionType,
                xo.platform_commission_rate platformCommissionRate,
                xo.maintenance_commission_rate maintenanceCommissionRate,
                xo.business_license_id businessLicenseId,  xo.withdrawal_time withdrawalTime, xo.soc,
                xo.status, xo.del_flag delFlag, xo.create_time createTime,
                xo.create_by createBy, xo.update_time updateTime,  xo.update_by updateBy, xo.remark,
    </sql>

    <select id="info" parameterType="java.lang.Long" resultType="java.util.Map">
        select
        <include refid="Base_Column_List"/>
        xo.operator_id_evcs operatorIdEvcs,
        xdb.dict_value attributenName,`xa`.merger_name mergerName,
        GROUP_CONCAT(DISTINCT xi.`url` ORDER BY xi.create_time DESC separator ',') businessLicenseUrl
        from xhpc_operator `xo`
        LEFT JOIN xhpc_dict_biz xdb on xdb.`code` = 'operator_attribute' and xdb.dict_key = xo.attribute
        LEFT JOIN xhpc_area `xa` on `xa`.`code` = xo.area_code
        LEFT JOIN xhpc_img xi on FIND_IN_SET(xi.img_id,xo.business_license_id )
        where xo.del_flag = 0 and xo.operator_id = #{operatorId}
    </select>

</mapper>
