|
@@ -152,33 +152,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
|
|
|
|
<select id="selectCustomerManage" parameterType="CustomerManage" resultMap="CustomerManageResult">
|
|
|
- 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,
|
|
|
+ SELECT b.union_id,b.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,c.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
|
|
|
+ FROM (
|
|
|
+ SELECT max( created_date ) created_date, po.consumer_id FROM pay_order po
|
|
|
<where>
|
|
|
<if test="stationIdList != null ">
|
|
|
- and station_id in
|
|
|
+ and po.station_id in
|
|
|
<foreach item="item" index="index" collection="stationIdList"
|
|
|
open="(" separator="," close=")">
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
<if test="stationId != null ">
|
|
|
- and station_id = #{stationId}
|
|
|
+ and po.station_id = #{stationId}
|
|
|
+ </if>
|
|
|
+ and status ="1"
|
|
|
+ </where>
|
|
|
+ GROUP BY po.consumer_id order by created_date desc ) p
|
|
|
+ INNER JOIN customer_manage m ON m.mina_user_id = p.consumer_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 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,
|
|
|
+ limit #{pageNumLimit},#{pageSizeLimit}
|
|
|
+ ) 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,
|
|
@@ -199,11 +210,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</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
|
|
|
+ LEFT JOIN customer_points c ON b.union_id = c.union_id AND b.station_id = c.station_id
|
|
|
+ <if test="stationIdList != null ">
|
|
|
+ and c.station_id in
|
|
|
+ <foreach item="item" index="index" collection="stationIdList"
|
|
|
+ open="(" separator="," close=")">
|
|
|
+ #{item}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="stationId != null ">
|
|
|
+ and c.station_id = #{stationId}
|
|
|
+ </if>
|
|
|
+ LEFT JOIN sys_dept d ON b.station_id = d.dept_id
|
|
|
+ </select>
|
|
|
+ <select id="selectCustomerManagePage" parameterType="CustomerManage" resultMap="CustomerManageResult">
|
|
|
+ SELECT customer_name,mina_user_id
|
|
|
+ FROM (SELECT max( created_date ) created_date, po.consumer_id FROM pay_order po
|
|
|
<where>
|
|
|
<if test="stationIdList != null ">
|
|
|
and po.station_id in
|
|
@@ -215,8 +237,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="stationId != null ">
|
|
|
and po.station_id = #{stationId}
|
|
|
</if>
|
|
|
+ and status ="1"
|
|
|
+ </where>
|
|
|
+ GROUP BY po.consumer_id order by created_date desc ) p
|
|
|
+ INNER JOIN customer_manage m ON m.mina_user_id = p.consumer_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>
|
|
|
</where>
|
|
|
- GROUP BY po.consumer_id ) px ON b.mina_user_id = px.consumer_id
|
|
|
- ORDER BY px.pay_date DESC
|
|
|
+ GROUP BY customer_name, mina_user_id, phone_number, member_id
|
|
|
</select>
|
|
|
</mapper>
|