<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
		"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap namespace="com.house365.beans.entity.MarketCustomerEntity">

	<typeAlias alias="marketCustomerEntity" type="com.house365.beans.entity.MarketCustomerEntity" />

	<resultMap id="marketCustomer" class="com.house365.beans.entity.MarketCustomerEntity">
		<result property="id" column="id" />
		<result property="activeId" column="active_id" />
		<result property="isOvertime" column="is_overtime" />
		<result property="signupTime" column="signup_time" />
		<result property="name" column="name" />
		<result property="phone" column="phone" />
		<result property="bakPhone1" column="bak_phone1" />
		<result property="bakPhone2" column="bak_phone2" />
		<result property="bakPhone3" column="bak_phone3" />
		<result property="sex" column="sex" />
		<result property="customerType" column="customer_type" />
		<result property="actSource" column="act_source" />
		<result property="firstSource" column="first_source" />
		<result property="latestSource" column="latest_source" />
		<result property="crmLatestCall" column="crm_latest_call" />
		<result property="crmLatestCallResult" column="crm_latest_call_result" />
		<result property="status" column="status" />
		<result property="createSource" column="create_source" />
		<result property="createTime" column="create_time" />
		<result property="creater" column="creater" />
		<result property="buyIntention" column="buy_intention" />
		<result property="lastVisitTime" column="last_visit_time" />
		<result property="lastCallTime" column="last_call_time" />
		<result property="managerId" column="manager_id" />
		<result property="managerName" column="manager_name" />
		<result property="updateTime" column="update_time" />
		<result property="updater" column="updater" />
		<result property="cityCode" column="cityCode" />
		<result property="bizPort" column="biz_port" />
		<result property="crmId" column="crmId" />
		<result property="cityName" column="cityName" />
		<result property="actSourceId" column="act_source_id" />
		<result property="remark" column="remark" />
		<result property="traceStatus" column="trace_status" />
		<result property="crmSync" column="crm_sync" />
		<result property="hotlineCallTime" column="hotline_call_time" />
		<result property="hotlineCallSpend" column="hotline_call_spend" />
		<result property="oceanDate" column="ocean_date" />
		<result property="isDelete" column="is_delete" />
		<result property="lastManager" column="last_manager" />
		<result property="bindTime" column="bind_time" />
		<result property="signupHouseId" column="signupHouseId" />
		<result property="signupHouseName" column="signupHouseName" />
		<result property="signupSourceId" column="signupSourceId" />
		<result property="signupSourceName" column="signupSourceName" />
		<result property="customerId" column="customerId" />
		<result property="overTimeCount" column="over_time_count" />
		<result property="visitBackCount" column="visit_back_count" />
		<result property="waitVisitCount" column="wait_visit_count" />
		<result property="boughtCount" column="bought_count" />
		<result property="isabandon" column="isabandon" />
		<result property="abandonTime" column="abandon_time" />
		<result property="abandonLogID" column="abandonLogID" />
		<result property="isabandonother" column="isabandonother" />
	</resultMap>

	<!-- 用于select查询公用抽取的列 -->
	<sql id="marketCustomer.columns">
		<![CDATA[
        a.id, a.active_id, a.is_overtime, a.signup_time, a.name, a.phone, a.bak_phone1, a.bak_phone2, a.bak_phone3,
        a.sex, a.customer_type, a.act_source, a.first_source, a.latest_source, a.crm_latest_call, a.crm_latest_call_result,
        a.status, a.create_source, a.create_time, a.creater, a.buy_intention, a.last_visit_time, a.last_call_time, a.manager_id,
        a.manager_name, a.update_time, a.updater, a.cityCode, a.biz_port, a.crmId, a.cityName, a.act_source_id, a.remark,
        a.trace_status, a.crm_sync, a.hotline_call_time, a.hotline_call_spend, a.ocean_date,
        a.is_delete, a.last_manager, a.bind_time, a.signupHouseId, a.signupHouseName, a.signupSourceId, a.signupSourceName, a.customerId,
        a.over_time_count, a.visit_back_count,a.wait_visit_count, a.bought_count, a.abandon_time, a.isabandon, a.abandonLogID,
        (select count(0) from market_customer b where b.phone=a.phone and b.active_id!=a.active_id and b.isabandon=1
        and  TIMESTAMPDIFF(DAY,date_format(b.abandon_time,'%y-%m-%d'),date_format(CURDATE(),'%y-%m-%d'))=0
        ) isabandonother
	    ]]>
	</sql>

	<!-- 新增记录 -->
	<insert id="save" parameterClass="marketCustomerEntity">
		<![CDATA[
	        INSERT INTO market_customer (
	        	id,
	        	active_id,
	        	is_overtime,
	        	signup_time,
	        	name,
	        	phone,
	        	bak_phone1,
	        	bak_phone2,
	        	bak_phone3,
	        	sex,
	        	customer_type,
	        	act_source,
	        	first_source,
	        	latest_source,
	        	crm_latest_call,
	        	crm_latest_call_result,
	        	status,
	        	create_source,
	        	create_time,
	        	creater,
	        	buy_intention,
	        	last_visit_time,
	        	last_call_time,
	        	manager_id,
	        	manager_name,
	        	update_time,
	        	updater,
	        	cityCode,
	        	biz_port,
	        	crmId,
	        	cityName,
	        	act_source_id,
	        	remark,
	        	trace_status,
	        	crm_sync,
	        	hotline_call_time,
	        	hotline_call_spend,
	        	ocean_date,
	        	is_delete,
	        	last_manager,
	        	bind_time,
	        	signupHouseId, signupHouseName, signupSourceId, signupSourceName, customerId,
	        	over_time_count,
	        	visit_back_count,
	        	wait_visit_count,
	        	bought_count,
	        	abandon_time, isabandon, abandonLogID
	        ) VALUES (
	        	#id#,
	        	#activeId#,
	        	#isOvertime#,
	        	#signupTime#,
	        	#name#,
	        	#phone#,
	        	#bakPhone1#,
	        	#bakPhone2#,
	        	#bakPhone3#,
	        	#sex#,
	        	#customerType#,
	        	#actSource#,
	        	#firstSource#,
	        	#latestSource#,
	        	#crmLatestCall#,
	        	#crmLatestCallResult#,
	        	#status#,
	        	#createSource#,
	        	#createTime#,
	        	#creater#,
	        	#buyIntention#,
	        	#lastVisitTime#,
	        	#lastCallTime#,
	        	#managerId#,
	        	#managerName#,
	        	#updateTime#,
	        	#updater#,
	        	#cityCode#,
	        	#bizPort#,
	        	#crmId#,
	        	#cityName#,
	        	#actSourceId#,
	        	#remark#,
	        	#traceStatus#,
	        	#crmSync#,
	        	#hotlineCallTime#,
	        	#hotlineCallSpend#,
	        	#oceanDate#,
	        	#isDelete#,
	        	#lastManager#,
	        	#bindTime#,
	        	#signupHouseId#, #signupHouseName#, #signupSourceId#, #signupSourceName#, #customerId#,
	        	#overTimeCount#,
	        	#visitBackCount#,
	        	#waitVisitCount#,
	        	#boughtCount#,
	        	#abandonTime#, #isabandon#, #abandonLogID#
	        )
	    ]]>
		<selectKey resultClass="java.lang.Integer" type="post"
				   keyProperty="id">
			SELECT LAST_INSERT_ID()
		</selectKey>
	</insert>

	<update id="updateSignupSourceName">
		update market_customer a set a.signupSourceName = (select source_name from crm_source b where a.signupSourceId=b.source_id)
	</update>

	<!-- 通过ID修改 -->
	<update id="update" parameterClass="marketCustomerEntity">
		<![CDATA[
	        UPDATE market_customer SET
		        active_id = #activeId#,
		        is_overtime = #isOvertime#,
		        signup_time = #signupTime#,
		        name = #name#,
		        phone = #phone#,
		        bak_phone1 = #bakPhone1#,
		        bak_phone2 = #bakPhone2#,
		        bak_phone3 = #bakPhone3#,
		        sex = #sex#,
		        customer_type = #customerType#,
		        act_source = #actSource#,
		        first_source = #firstSource#,
		        latest_source = #latestSource#,
		        crm_latest_call = #crmLatestCall#,
		        crm_latest_call_result = #crmLatestCallResult#,
		        status = #status#,
		        create_source = #createSource#,
		        create_time = #createTime#,
		        creater = #creater#,
		        buy_intention = #buyIntention#,
		        last_visit_time = #lastVisitTime#,
		        last_call_time = #lastCallTime#,
		        manager_id = #managerId#,
		        manager_name = #managerName#,
		        update_time = #updateTime#,
		        updater = #updater#,
		        cityCode = #cityCode#,
		        biz_port = #bizPort#,
		        crmId = #crmId#,
		        cityName = #cityName#,
		        act_source_id = #actSourceId#,
		        remark = #remark#,
		        trace_status = #traceStatus#,
		        crm_sync = #crmSync#,
		        hotline_call_time = #hotlineCallTime#,
		        hotline_call_spend = #hotlineCallSpend#,
		        ocean_date = #oceanDate#,
		        is_delete = #isDelete#,
		        last_manager = #lastManager#,
		        bind_time = #bindTime#,
		        signupHouseId = #signupHouseId#,
		        signupHouseName = #signupHouseName#,
		        signupSourceId = #signupSourceId#,
		        signupSourceName = #signupSourceName#,
		        over_time_count = #overTimeCount#,
		        visit_back_count = #visitBackCount#,
		        wait_visit_count = #waitVisitCount#,
		        bought_count = #boughtCount#,
		        customerId = #customerId#,
		        abandon_time = #abandonTime#, isabandon=#isabandon#,abandonLogID=#abandonLogID#
	        WHERE
		        id = #id#
	    ]]>
	</update>

	<!-- 通过ID删除 -->
	<delete id="delete">
		<![CDATA[
	        DELETE FROM market_customer WHERE
	        id = #id#
	    ]]>
	</delete>

	<!-- 通过ID列表批量删除 -->
	<delete id="deleteByIds" parameterClass="java.lang.String">
		<![CDATA[
	        DELETE FROM market_customer WHERE
	        id IN ($ids$)
	    ]]>
	</delete>

	<!-- 通过ID查询 -->
	<select id="getById" resultMap="marketCustomer">
		SELECT
		<include refid="marketCustomer.columns" />
		<![CDATA[
	        FROM market_customer a
	        WHERE
		        a.id = #id#
	    ]]>
	</select>

	<select id="getUseMarketingActivity" parameterClass="marketCustomerEntity" resultMap="marketCustomer">
		SELECT
		<include refid="marketCustomer.columns" />
		<![CDATA[
	        FROM market_customer a
	        WHERE
		        active_id = #activeId#
	    ]]>
	</select>

	<!-- 用于分页查询抽取的公共的条件 -->
	<sql id="marketCustomer.queryPage">
		<dynamic prepend="WHERE">
			<!-- 默认不开启实体作为条件 -->
			<isNotNull property="searchFilters">
				<isNotEmpty prepend="AND" property="searchFilters.id">
					<![CDATA[
					a.id $searchFilters.id.operation$ #searchFilters.id.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.activeId">
					<![CDATA[
					a.active_id $searchFilters.activeId.operation$ #searchFilters.activeId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isOvertime">
					<![CDATA[
					a.is_overtime $searchFilters.isOvertime.operation$ #searchFilters.isOvertime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.signupTime">
					<![CDATA[
					a.signup_time $searchFilters.signupTime.operation$ #searchFilters.signupTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.name">
					<![CDATA[
					a.name $searchFilters.name.operation$ #searchFilters.name.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.phone">
					<![CDATA[
					a.phone $searchFilters.phone.operation$ #searchFilters.phone.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.bakPhone1">
					<![CDATA[
					a.bak_phone1 $searchFilters.bakPhone1.operation$ #searchFilters.bakPhone1.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.bakPhone2">
					<![CDATA[
					a.bak_phone2 $searchFilters.bakPhone2.operation$ #searchFilters.bakPhone2.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.bakPhone3">
					<![CDATA[
					a.bak_phone3 $searchFilters.bakPhone3.operation$ #searchFilters.bakPhone3.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.sex">
					<![CDATA[
					a.sex $searchFilters.sex.operation$ #searchFilters.sex.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.customerType">
					<![CDATA[
					a.customer_type $searchFilters.customerType.operation$ #searchFilters.customerType.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.actSource">
					<![CDATA[
					a.act_source $searchFilters.actSource.operation$ #searchFilters.actSource.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.firstSource">
					<![CDATA[
					a.first_source $searchFilters.firstSource.operation$ #searchFilters.firstSource.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.latestSource">
					<![CDATA[
					a.latest_source $searchFilters.latestSource.operation$ #searchFilters.latestSource.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.crmLatestCall">
					<![CDATA[
					a.crm_latest_call $searchFilters.crmLatestCall.operation$ #searchFilters.crmLatestCall.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.crmLatestCallResult">
					<![CDATA[
					a.crm_latest_call_result $searchFilters.crmLatestCallResult.operation$ #searchFilters.crmLatestCallResult.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.status">
					<![CDATA[
					a.status $searchFilters.status.operation$ #searchFilters.status.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.createSource">
					<![CDATA[
					a.create_source $searchFilters.createSource.operation$ #searchFilters.createSource.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.createTime">
					<![CDATA[
					a.create_time $searchFilters.createTime.operation$ #searchFilters.createTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.creater">
					<![CDATA[
					a.creater $searchFilters.creater.operation$ #searchFilters.creater.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.buyIntention">
					<![CDATA[
					a.buy_intention $searchFilters.buyIntention.operation$ #searchFilters.buyIntention.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.lastVisitTime">
					<![CDATA[
					a.last_visit_time $searchFilters.lastVisitTime.operation$ #searchFilters.lastVisitTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.lastCallTime">
					<![CDATA[
					a.last_call_time $searchFilters.lastCallTime.operation$ #searchFilters.lastCallTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.managerId">
					<![CDATA[
					a.manager_id $searchFilters.managerId.operation$ #searchFilters.managerId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.managerName">
					<![CDATA[
					a.manager_name $searchFilters.managerName.operation$ #searchFilters.managerName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.updateTime">
					<![CDATA[
					a.update_time $searchFilters.updateTime.operation$ #searchFilters.updateTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.updater">
					<![CDATA[
					a.updater $searchFilters.updater.operation$ #searchFilters.updater.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.cityCode">
					<![CDATA[
					a.cityCode $searchFilters.cityCode.operation$ #searchFilters.cityCode.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.bizPort">
					<![CDATA[
					a.biz_port $searchFilters.bizPort.operation$ #searchFilters.bizPort.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.crmId">
					<![CDATA[
					a.crmId $searchFilters.crmId.operation$ #searchFilters.crmId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.cityName">
					<![CDATA[
					a.cityName $searchFilters.cityName.operation$ #searchFilters.cityName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.actSourceId">
					<![CDATA[
					a.act_source_id $searchFilters.actSourceId.operation$ #searchFilters.actSourceId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.remark">
					<![CDATA[
					a.remark $searchFilters.remark.operation$ #searchFilters.remark.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.traceStatus">
					<![CDATA[
					a.trace_status $searchFilters.traceStatus.operation$ #searchFilters.traceStatus.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.crmSync">
					<![CDATA[
					a.crm_sync $searchFilters.crmSync.operation$ #searchFilters.crmSync.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.hotlineCallTime">
					<![CDATA[
					a.hotline_call_time $searchFilters.hotlineCallTime.operation$ #searchFilters.hotlineCallTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.hotlineCallSpend">
					<![CDATA[
					a.hotline_call_spend $searchFilters.hotlineCallSpend.operation$ #searchFilters.hotlineCallSpend.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.oceanDate">
					<![CDATA[
					a.ocean_date $searchFilters.oceanDate.operation$ #searchFilters.oceanDate.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isDelete">
					<![CDATA[
					a.is_delete $searchFilters.isDelete.operation$ #searchFilters.isDelete.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.lastManager">
					<![CDATA[
					a.last_manager $searchFilters.lastManager.operation$ #searchFilters.lastManager.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.bindTime">
					<![CDATA[
					a.bind_time $searchFilters.bindTime.operation$ #searchFilters.bindTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.signupHouseId">
					<![CDATA[
					a.signupHouseId $searchFilters.signupHouseId.operation$ #searchFilters.signupHouseId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.signupHouseName">
					<![CDATA[
					a.signupHouseName $searchFilters.signupHouseName.operation$ #searchFilters.signupHouseName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.signupSourceId">
					<![CDATA[
					a.signupSourceId $searchFilters.signupSourceId.operation$ #searchFilters.signupSourceId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.signupSourceName">
					<![CDATA[
					a.signupSourceName $searchFilters.signupSourceName.operation$ #searchFilters.signupSourceName.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.notassign">
					<![CDATA[
					(a.manager_id is null or a.manager_id = '')
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.notassignandovertime">
					<![CDATA[
					a.is_overtime = 1 and (a.manager_id is null or a.manager_id = '')
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.assigned">
					<![CDATA[
					a.manager_id is not null and a.manager_id != ''
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.customerId">
					<![CDATA[
					a.customerId $searchFilters.customerId.operation$ #searchFilters.customerId.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.abandonTime">
					<![CDATA[
					a.abandon_time $searchFilters.abandonTime.operation$ #searchFilters.abandonTime.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isabandon">
					<![CDATA[
					a.isabandon $searchFilters.isabandon.operation$ #searchFilters.isabandon.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.callAndAbandon">
					<![CDATA[
					a.isabandon=1 and  exists (
						select 1 from customer_callback_log b where a.customerId=b.customer_id
						)
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.abandonLogID">
					<![CDATA[
					a.abandonLogID $searchFilters.abandonLogID.operation$ #searchFilters.abandonLogID.value#
		            ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isBack">
					<![CDATA[
                    EXISTS (select b.customer_id from customer_callback_log b where a.customerId = b.customer_id)
                    ]]>
				</isNotEmpty>
				<isNotEmpty prepend="AND" property="searchFilters.isNotBack">
					<![CDATA[
                    NOT EXISTS (select b.customer_id from customer_callback_log b where a.customerId = b.customer_id)
                    ]]>
				</isNotEmpty>
			</isNotNull>
		</dynamic>
		<dynamic prepend="ORDER BY">
			<isNotNull property="orderColumn">
				<![CDATA[
				$orderColumn$
				]]>
				<isNotNull property="orderMode">
					$orderMode$
				</isNotNull>
			</isNotNull>
		</dynamic>
	</sql>

	<!-- 为分页查询符合条件的记录数 -->
	<select id="queryByPage_count" resultClass="int">
		SELECT count(*) FROM market_customer a
		<include refid="marketCustomer.queryPage" />
	</select>

	<!-- 分页查询指定页记录 -->
	<select id="queryByPage" resultMap="marketCustomer">
		SELECT
		<include refid="marketCustomer.columns" />
		<![CDATA[
	        FROM market_customer a
	    ]]>
		<include refid="marketCustomer.queryPage" />
		<![CDATA[
		    LIMIT #paging.startRecord#, #paging.pageSize#
        ]]>
	</select>

	<!-- 查询所有记录 -->
	<select id="queryAll" resultMap="marketCustomer">
		SELECT
		<include refid="marketCustomer.columns" />
		<![CDATA[
		    FROM market_customer a
	    ]]>
		<include refid="marketCustomer.queryPage" />
	</select>

	<delete id="clean">
		delete from market_customer
	</delete>

	<select id="getByActiveId" resultMap="marketCustomer">
		SELECT
		<include refid="marketCustomer.columns" />
		<![CDATA[
		    FROM market_customer a where active_id = $activeId$
	    ]]>
	</select>

	<select id="queryByIds" resultMap="marketCustomer">
		SELECT
		<include refid="marketCustomer.columns" />
		<![CDATA[
		    FROM market_customer a where a.id in ($activeId$)
	    ]]>
	</select>

	<select id="queryByCustomerid" resultMap="marketCustomer">
		SELECT
		<include refid="marketCustomer.columns" />
		<![CDATA[
		    FROM market_customer a where a.customerId = #custmerId#
	    ]]>
	</select>

	<select id="getOverTimeCustomers" resultMap="marketCustomer">
		SELECT
		 a.id,
        a.act_source,
         a.create_source,
         a.cityCode
		<![CDATA[
		    FROM market_customer a where 1=1 and create_time > (date_sub(now(), interval 1 hour)) and create_time < SYSDATE() and a.active_id in (select id from marketing_activity where finish_time < now())
		    and (a.manager_id is null or a.manager_id = '')
	    ]]>
	</select>

</sqlMap>
