| 
														
															@@ -152,40 +152,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     </delete> 
														 | 
														
														 | 
														
															     </delete> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     <select id="selectCustomerManage" parameterType="CustomerManage" resultMap="CustomerManageResult"> 
														 | 
														
														 | 
														
															     <select id="selectCustomerManage" parameterType="CustomerManage" resultMap="CustomerManageResult"> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        SELECT sy.*,px.pay_date from ( 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        SELECT m.member_id,m.customer_name,m.phone_number,m.car_number,GROUP_CONCAT(DISTINCT(m.oil_name)) oil_name, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        GROUP_CONCAT(DISTINCT(m.grade)) as grade,m.union_id,p.points as integral, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        sum(CASE c.card_oils_type  WHEN '1' THEN  c.amt ELSE 0 END ) qy_amt, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        sum(CASE c.card_oils_type  WHEN '2' THEN  c.amt ELSE 0 END ) cy_amt, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        sum(CASE c.card_oils_type  WHEN '3' THEN  c.amt ELSE 0 END ) fy_amt, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        sum(CASE c.card_oils_type  WHEN '4' THEN  c.amt ELSE 0 END ) lng_amt, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        sum(CASE c.card_oils_type  WHEN '5' THEN  c.amt ELSE 0 END ) cng_amt, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        m.mina_user_id,m.station_id,d.dept_name as station_name 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            from customer_manage m 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            left join customer_points p on m.union_id = p.union_id and m.station_id = p.station_id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            left join customer_electronic_card c on c.union_id =m.union_id and c.station_id = m.station_id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            left join sys_dept d on m.station_id = d.dept_id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            <where> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                <if test="stationIdList != null "> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    and m.station_id in 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    <foreach item="item" index="index" collection="stationIdList" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                             open="(" separator="," close=")"> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                        #{item} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    </foreach> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                </if> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                <if test="stationId != null "> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    and m.station_id  = #{stationId} 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                </if> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                <if test="carNumber != null  and carNumber != ''"> and car_number like concat('%', #{carNumber}, '%')</if> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                <if test="oilName != null  and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                <if test="grade != null  and grade != ''"> and grade like concat('%', #{grade}, '%')</if> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                <if test="phoneNumber != null  and phoneNumber != ''"> and phone_number like concat('%', #{phoneNumber}, '%')</if> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                <if test="customerName != null  and customerName != ''"> and m.customer_name  like concat('%', #{customerName}, '%')</if> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            </where> 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            GROUP BY m.union_id,m.member_id,m.customer_name,m.phone_number,m.mina_user_id, m.car_number,p.points,m.station_id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        ) sy 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        LEFT JOIN (SELECT max(pay_date) pay_date ,po.consumer_id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        from pay_order po 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        SELECT a.union_id,a.customer_name,a.station_id,a.qy_amt,a.cy_amt,a.fy_amt,a.lng_amt, a.cng_amt, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        b.member_id, b.customer_name, b.phone_number,  b.car_number, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        b.mina_user_id,b.oil_name,b.grade,p.points AS integral,d.dept_name as station_name 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        FROM 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        (SELECT member_id,customer_name,phone_number,car_number, mina_user_id,station_id, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        union_id,GROUP_CONCAT(DISTINCT ( oil_name )) oil_name,GROUP_CONCAT(DISTINCT ( grade )) AS grade 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        FROM customer_manage 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        <where> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="stationIdList != null "> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                and station_id in 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                <foreach item="item" index="index" collection="stationIdList" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                         open="(" separator="," close=")"> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    #{item} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                </foreach> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            </if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="stationId != null "> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                and station_id  = #{stationId} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            </if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="carNumber != null  and carNumber != ''"> and car_number like concat('%', #{carNumber}, '%')</if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="oilName != null  and oilName != ''"> and oil_name like concat('%', #{oilName}, '%')</if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="grade != null  and grade != ''"> and grade like concat('%', #{grade}, '%')</if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="phoneNumber != null  and phoneNumber != ''"> and phone_number like concat('%', #{phoneNumber}, '%')</if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="customerName != null  and customerName != ''"> and customer_name  like concat('%', #{customerName}, '%')</if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        </where> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        GROUP BY member_id,customer_name, phone_number,car_number,  mina_user_id, station_id, union_id 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        ) b LEFT JOIN 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        (SELECT   union_id,  customer_name, station_id, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        sum( CASE card_oils_type WHEN '1' THEN amt ELSE 0 END ) qy_amt, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        sum( CASE card_oils_type WHEN '2' THEN amt ELSE 0 END ) cy_amt, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        sum( CASE card_oils_type WHEN '3' THEN amt ELSE 0 END ) fy_amt, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        sum( CASE card_oils_type WHEN '4' THEN amt ELSE 0 END ) lng_amt, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        sum( CASE card_oils_type WHEN '5' THEN amt ELSE 0 END ) cng_amt 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        FROM  customer_electronic_card 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        <where> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="stationIdList != null "> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                and station_id in 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                <foreach item="item" index="index" collection="stationIdList" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                         open="(" separator="," close=")"> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    #{item} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                </foreach> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            </if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            <if test="stationId != null "> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                and station_id  = #{stationId} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            </if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        </where> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        GROUP BY union_id, customer_name, station_id) a 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        ON a.union_id = b.union_id   AND a.station_id = b.station_id 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        LEFT JOIN customer_points p ON b.union_id = p.union_id 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        AND b.station_id = p.station_id 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        LEFT JOIN sys_dept d ON b.station_id = d.dept_id 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        LEFT JOIN ( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        SELECT max( pay_date ) pay_date, po.consumer_id FROM pay_order po 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         <where> 
														 | 
														
														 | 
														
															         <where> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             <if test="stationIdList != null "> 
														 | 
														
														 | 
														
															             <if test="stationIdList != null "> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 and po.station_id in 
														 | 
														
														 | 
														
															                 and po.station_id in 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -198,7 +216,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 and po.station_id  = #{stationId} 
														 | 
														
														 | 
														
															                 and po.station_id  = #{stationId} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             </if> 
														 | 
														
														 | 
														
															             </if> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         </where> 
														 | 
														
														 | 
														
															         </where> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        GROUP BY  po.consumer_id) px on sy.mina_user_id =  px.consumer_id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        order by px.pay_date desc 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        GROUP BY po.consumer_id ) px ON b.mina_user_id = px.consumer_id 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        ORDER BY   px.pay_date DESC 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     </select> 
														 | 
														
														 | 
														
															     </select> 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 </mapper> 
														 | 
														
														 | 
														
															 </mapper> 
														 |