|
@@ -114,26 +114,82 @@
|
|
|
print_count, car_no, customer_phone, customer_grade, oil_type
|
|
|
</sql>
|
|
|
<sql id="Base_Column_List_oilName">
|
|
|
- oil_name AS oilName,
|
|
|
- COUNT(order_no) AS orderSum,
|
|
|
- SUM(order_liters) AS orderLitersSum,
|
|
|
- SUM(amt) AS amtSum
|
|
|
+ SELECT
|
|
|
+ T1.oil_name AS oilName,
|
|
|
+ COUNT(T2.order_no) AS orderSum,
|
|
|
+ SUM(IFNULL(T2.order_liters,0)) AS orderLitersSum,
|
|
|
+ SUM(IFNULL(T2.receivable_amt,0)) AS receivableAmtSum,
|
|
|
+ SUM(IFNULL(T2.discount_amt,0)) AS discountAmtSum,
|
|
|
+ SUM(IFNULL(T2.amt,0)) AS amtSum
|
|
|
+ FROM sys_oil_type AS T1
|
|
|
+ LEFT JOIN pay_order AS T2 ON T1.oil_name = T2.oil_name
|
|
|
+ <if test="stationId !=null">
|
|
|
+ AND T2.station_id= #{stationId}
|
|
|
+ </if>
|
|
|
+ <if test="status !=null">
|
|
|
+ AND T2.status= #{status}
|
|
|
+ </if>
|
|
|
+ <if test="beginTime !=null">
|
|
|
+ AND T2.pay_date >= #{beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime !=null">
|
|
|
+ AND T2.pay_date < #{endTime}
|
|
|
+ </if>
|
|
|
+ GROUP BY T1.oil_name
|
|
|
+ ORDER BY amtSum DESC
|
|
|
</sql>
|
|
|
<sql id="Base_Column_List_payType">
|
|
|
- pay_type AS payType,
|
|
|
- COUNT(order_no) AS orderSum,
|
|
|
- SUM(order_liters) AS orderLitersSum,
|
|
|
- SUM(amt) AS amtSum
|
|
|
+ SELECT
|
|
|
+ T1.remark AS payType,
|
|
|
+ COUNT(T2.order_no) AS orderSum,
|
|
|
+ SUM(IFNULL(T2.order_liters,0)) AS orderLitersSum,
|
|
|
+ SUM(IFNULL(T2.receivable_amt,0)) AS receivableAmtSum,
|
|
|
+ SUM(IFNULL(T2.discount_amt,0)) AS discountAmtSum,
|
|
|
+ SUM(IFNULL(T2.amt,0)) AS amtSum
|
|
|
+ FROM sys_pay_type AS T1
|
|
|
+ LEFT JOIN pay_order AS T2 ON T1.pay_type_name = T2.pay_type
|
|
|
+ <if test="stationId !=null">
|
|
|
+ AND T2.station_id= #{stationId}
|
|
|
+ </if>
|
|
|
+ <if test="status !=null">
|
|
|
+ AND T2.status= #{status}
|
|
|
+ </if>
|
|
|
+ <if test="beginTime !=null">
|
|
|
+ AND T2.pay_date >= #{beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime !=null">
|
|
|
+ AND T2.pay_date < #{endTime}
|
|
|
+ </if>
|
|
|
+ GROUP BY T1.remark
|
|
|
+ ORDER BY amtSum DESC
|
|
|
</sql>
|
|
|
<sql id="Base_Column_List_NoGroupBy">
|
|
|
- COUNT(order_no) AS orderSum,
|
|
|
- SUM(order_liters) AS orderLitersSum,
|
|
|
- SUM(amt) AS amtSum
|
|
|
+ SELECT
|
|
|
+ COUNT(T2.order_no) AS orderSum,
|
|
|
+ SUM(IFNULL(T2.order_liters,0)) AS orderLitersSum,
|
|
|
+ SUM(IFNULL(T2.receivable_amt,0)) AS receivableAmtSum,
|
|
|
+ SUM(IFNULL(T2.discount_amt,0)) AS discountAmtSum,
|
|
|
+ SUM(IFNULL(T2.amt,0)) AS amtSum
|
|
|
+ FROM
|
|
|
+ pay_order AS T2
|
|
|
+ <where>
|
|
|
+ <if test="stationId !=null">
|
|
|
+ T2.station_id= #{stationId}
|
|
|
+ </if>
|
|
|
+ <if test="status !=null">
|
|
|
+ AND T2.status= #{status}
|
|
|
+ </if>
|
|
|
+ <if test="beginTime !=null">
|
|
|
+ AND T2.pay_date >= #{beginTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime !=null">
|
|
|
+ AND T2.pay_date < #{endTime}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
</sql>
|
|
|
|
|
|
<!--查询油品总和-->
|
|
|
<select id="selectSum" parameterType="com.platform.yijia.pojo.PayOrder" resultType="Map">
|
|
|
- SELECT
|
|
|
<if test="groupBy !=null and groupBy =='oilName'">
|
|
|
<include refid="Base_Column_List_oilName"/>
|
|
|
</if>
|
|
@@ -143,29 +199,6 @@
|
|
|
<if test="groupBy ==''">
|
|
|
<include refid="Base_Column_List_NoGroupBy"/>
|
|
|
</if>
|
|
|
- FROM
|
|
|
- pay_order
|
|
|
- <where>
|
|
|
- <if test="stationId !=null">
|
|
|
- station_id= #{stationId}
|
|
|
- </if>
|
|
|
- <if test="status !=null">
|
|
|
- AND status= #{status}
|
|
|
- </if>
|
|
|
- <if test="beginTime !=null">
|
|
|
- AND pay_date >= #{beginTime}
|
|
|
- </if>
|
|
|
- <if test="endTime !=null">
|
|
|
- AND pay_date < #{endTime}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- <if test="groupBy !=null and groupBy =='oilName'">
|
|
|
- GROUP BY oil_name
|
|
|
- </if>
|
|
|
- <if test="groupBy !=null and groupBy =='payType'">
|
|
|
- GROUP BY pay_type
|
|
|
- </if>
|
|
|
- ORDER BY amtSum DESC
|
|
|
</select>
|
|
|
|
|
|
|