<?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.fjhx.customer.mapper.customer.CustomerMapper">
    <update id="customerAllocation">
        update customer set user_id = #{userId},update_time = now() where id = #{id}
    </update>
    <select id="getList" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
        select
            c.id,
            c.customer_code,
            c.code,
            c.country_id,
            c.province_id,
            c.city_id,
            c.address,
            c.zip_code,
            c.name,
            c.status,
            c.source,
            c.user_id,
            c.create_user,
            c.create_time,
            c.update_user,
            c.update_time,
            c.tag
        from customer c
            ${ew.customSqlSegment}
    </select>

    <select id="getPage" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
        select
            c.id,
            c.customer_code,
            c.code,
            c.country_id,
            c.province_id,
            c.city_id,
            c.address,
            c.zip_code,
            c.name,
            c.status,
            c.source,
            c.user_id,
            c.create_user,
            c.create_time,
            c.update_user,
            c.update_time,
            c.tag
        from customer c
            ${ew.customSqlSegment}
    </select>


    <select id="sourceStock" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
        SELECT
            COUNT(*) count,
	        ifnull(c.source,-1) source,
            ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
        FROM
            customer c
            ${ew.customSqlSegment}
    </select>

    <select id="sourceIncrement" resultType="com.fjhx.customer.entity.customer.vo.CustomerVo">
        SELECT
            COUNT(*) count,
	        ifnull(c.source,-1) source,
            ifnull(DATE_FORMAT(c.create_time,'%Y-%m'),-1) time
        FROM
            customer c
            ${ew.customSqlSegment}
    </select>

</mapper>
