| 
					
				 | 
			
			
				@@ -0,0 +1,291 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<?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.yijia.label.mapper.CustomerLabelDemoMapper"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <resultMap type="CustomerLabelDemo" id="CustomerLabelDemoResult"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="id"    column="id"    /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="phone"    column="phone"    /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="stationId"    column="station_id"    /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="customerName"    column="customer_name"    /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="labelName"    column="label_name"    /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="labelId"    column="label_id"    /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <result property="createDate"    column="create_date"    /> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </resultMap> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="selectCustomerLabelDemoList" parameterType="CustomerLabelDemo" resultMap="CustomerLabelDemoResult"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT zq.*,r.label_name,r.id as label_id from ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT consumer_id,sum(order_liters) order_liters,sum(amt) as amt,count(1) count_num,p.station_id,max(created_date) as create_date, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        a.mobile_phone as phone,blog_nick_name as customer_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from pay_order p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        join app_user_info a on a.user_id = p.consumer_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where  p.status ="1" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="stationId != null "> and p.station_id = #{stationId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="oilName != null "> and oil_name = #{oilName} </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="beginDate != null and beginDate != ''"><!-- 开始时间检索 --> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND date_format(created_date,'%Y-%m-%d %H:%i:%s') >= date_format(#{beginDate},'%Y-%m-%d %H:%i:%s') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="endDate != null and endDate != ''"><!-- 结束时间检索 --> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND date_format(created_date,'%Y-%m-%d %H:%i:%s') <= date_format(#{endDate},'%Y-%m-%d %H:%i:%s') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        group by consumer_id,p.station_id,a.mobile_phone,blog_nick_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ORDER BY create_date desc) zq 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join customer_label l on zq.station_id = l.station_id and zq.phone = l.phone and l.del_flag ="0" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join label_rule r on r.id = l.label_id and r.del_flag ="0" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <where> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="labelId != null "> and l.label_id >= #{labelId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="startCountNum != null "> and zq.count_num >= #{startCountNum}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="endCountNum != null "> and zq.count_num <= #{endCountNum}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="amtFlag != null and amtFlag=='1' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       and (  zq.amt >= #{startAmt} and zq.amt <= #{endAmt}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.amt >= #{startAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endAmt != null and startAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.amt >= #{startAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="amtFlag != null and amtFlag=='2' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or (  zq.amt >= #{startAmt} and zq.amt <= #{endAmt}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.amt >= #{startAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endAmt != null and startAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.amt >= #{endAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="litersFlag != null and litersFlag=='1' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and (  zq.order_liters >= #{startLiters} and zq.order_liters <= #{endLiters}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.order_liters >= #{startLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endLiters != null and startLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.order_liters >= #{endLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="litersFlag != null and litersFlag=='2' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or (  zq.order_liters >= #{startLiters} and zq.order_liters <= #{endLiters}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.order_liters >= #{startLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endLiters != null and startLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.order_liters >= #{endLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </where> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="selectPhoneCustomerLabelList" parameterType="CustomerLabelDemo" resultMap="CustomerLabelDemoResult"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT id,phone,label_id,station_id	from customer_label 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <where> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="stationId != null "> and station_id = #{stationId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="labelId != null "> and label_id = #{labelId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="delFlag != null "> and del_flag = #{delFlag}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="phone != null  and phone != ''"> and phone like concat('%', #{phone}, '%')</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="phoneList != null "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                and phone in 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <foreach item="item" index="index" collection="phoneList" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                         open="(" separator="," close=")"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    #{item} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </foreach> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </where> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    <select id="secondCustomerLabelDemoList" parameterType="CustomerLabelDemo" resultMap="CustomerLabelDemoResult"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT  zh.*,r.label_name,r.id as label_id from ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT consumer_id,sum(order_liters) order_liters,count(1) count_num,p.station_id,max(created_date) as create_date, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        a.mobile_phone as phone,blog_nick_name as customer_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from pay_order p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        join app_user_info a on a.user_id = p.consumer_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where `status` = "1" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="stationId != null "> and p.station_id = #{stationId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="oilName != null "> and oil_name = #{oilName} </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondBeginDate != null and beginDate != ''"><!-- 开始时间检索 --> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND date_format(created_date,'%Y-%m-%d %H:%i:%s') >= date_format(#{secondBeginDate},'%Y-%m-%d %H:%i:%s') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondEndDate != null and secondEndDate != ''"><!-- 结束时间检索 --> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND date_format(created_date,'%Y-%m-%d %H:%i:%s') <= date_format(#{secondEndDate},'%Y-%m-%d %H:%i:%s') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        group by consumer_id,p.station_id,a.mobile_phone,blog_nick_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ORDER BY create_date desc) zh 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join customer_label l on zh.station_id = l.station_id and zh.phone = l.phone and l.del_flag ="0" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join label_rule r on r.id = l.label_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where 1=1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="labelId != null "> and l.label_id = #{labelId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="stationId != null "> and zh.station_id = #{stationId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondStartCountNum != null "> and zh.count_num >= #{secondStartCountNum}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondEndCountNum != null "> and  zh.count_num <=#{secondEndCountNum} </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="startCountNum != null "> and zq.count_num >= #{startCountNum}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="endCountNum != null "> and zq.count_num <= #{endCountNum}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondAmtFlag != null and secondAmtFlag=='1' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartAmt != null and secondEndAmt != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    and (  zh.amt >= #{secondStartAmt} and zh.amt <= #{secondEndAmt}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartAmt != null and secondEndAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    and  zh.amt >= #{secondStartAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondEndAmt != null and secondStartAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    and  zh.amt <= #{secondEndAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondAmtFlag != null and secondAmtFlag=='2' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartAmt != null and secondEndAmt != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    or (  zh.amt >= #{secondStartAmt} and zh.amt <=#{secondEndAmt}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartAmt != null and secondEndAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    or  zh.amt >= #{secondStartAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondEndAmt != null and startAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    or  zh.amt <= #{secondEndAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondLitersFlag != null and secondLitersFlag=='1' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartLiters != null and secondEndLiters != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    and (  zh.order_liters  >= #{secondStartLiters} and zh.order_liters  <= #{secondEndLiters}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartLiters != null and secondEndLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    and  zh.order_liters  >= #{secondStartLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondEndLiters != null and secondStartLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    and  zh.order_liters  <= #{secondEndLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="secondLitersFlag != null and secondLitersFlag=='2' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartLiters != null and secondEndLiters != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    or (  zh.order_liters  >= #{secondStartLiters} and zq.order_liters <= #{secondEndLiters}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondStartLiters != null and secondEndLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    or  zh.order_liters  >= #{secondStartLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <when test="secondEndLiters != null and secondStartLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    or  zh.order_liters <= #{secondEndLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        and zh.phone in ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT zq.phone from ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SELECT consumer_id,sum(order_liters) order_liters,count(1) count_num,sum(amt) as amt,p.station_id,max(created_date) created_date, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        a.mobile_phone as phone,blog_nick_name as customer_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        from pay_order p 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        join app_user_info a on a.user_id = p.consumer_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        where  p.status ="1" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="stationId != null "> and p.station_id = #{stationId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="oilName != null "> and oil_name = #{oilName} </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="beginDate != null and beginDate != ''"><!-- 开始时间检索 --> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND date_format(created_date,'%Y-%m-%d %H:%i:%s') >= date_format(#{beginDate},'%Y-%m-%d %H:%i:%s') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <if test="endDate != null and endDate != ''"><!-- 结束时间检索 --> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            AND date_format(created_date,'%Y-%m-%d %H:%i:%s') <= date_format(#{endDate},'%Y-%m-%d %H:%i:%s') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        group by consumer_id,p.station_id,a.mobile_phone,blog_nick_name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ORDER BY created_date desc) zq 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join customer_label l on zq.station_id = l.station_id and zq.phone = l.phone and l.del_flag ="0" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        left join label_rule r on r.id = l.label_id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <where> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="labelId != null "> and l.label_id = #{labelId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="stationId != null "> and zq.station_id = #{stationId}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="startCountNum != null "> and zq.count_num >= #{startCountNum}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="endCountNum != null "> and zq.count_num <= #{endCountNum}</if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="amtFlag != null and amtFlag=='1' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and (  zq.amt >= #{startAmt} and zq.amt <= #{endAmt}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.amt >= #{startAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endAmt != null and startAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.amt <= #{startAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="amtFlag != null and amtFlag=='2' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or (  zq.amt >= #{startAmt} and zq.amt <= #{endAmt}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startAmt != null and endAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.amt >= #{startAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endAmt != null and startAmt == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.amt <= #{endAmt} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="litersFlag != null and litersFlag=='1' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and (  zq.order_liters >= #{startLiters} and zq.order_liters <= #{endLiters}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.order_liters >= #{startLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endLiters != null and startLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        and  zq.order_liters <= #{endLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <if test="litersFlag != null and litersFlag=='2' "> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                <choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters != null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or (  zq.order_liters >= #{startLiters} and zq.order_liters <= #{endLiters}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="startLiters != null and endLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.order_liters >= #{startLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <when test="endLiters != null and startLiters == null"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        or  zq.order_liters <=#{endLiters} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </when> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    <otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    </otherwise> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                </choose> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            </if> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        </where> ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    </select> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+</mapper> 
			 |