|
|
@@ -181,4 +181,106 @@ public interface SummaryMapper extends BaseMapper<PosOrderGoodsPayment> {
|
|
|
"</script>")
|
|
|
public List<HashMap<String,Object>> roomFinancePage(Page<HashMap<String,Object>> page, @Param("hotelId") String hotelId, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
|
|
|
|
|
|
+ /**
|
|
|
+ * 按时间每天收入统计列表
|
|
|
+ * @param hotelId
|
|
|
+ * @param startTime
|
|
|
+ * @param endTime
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Select("<script>select time,sum(room_money) as room_money,sum(other_money) as other_money from \n" +
|
|
|
+ "(SELECT 'pos' as type, a.time\n" +
|
|
|
+ ",0 AS room_money,\n" +
|
|
|
+ "sum(ifnull(b.pay_money,0)) as other_money\n" +
|
|
|
+ "FROM (\n" +
|
|
|
+ "\tselect time from\n" +
|
|
|
+ "\t(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) AS time from\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v\n" +
|
|
|
+ "\twhere time between #{startTime} and #{endTime}\n" +
|
|
|
+ "\tORDER BY time\n" +
|
|
|
+ "\t) a\n" +
|
|
|
+ "\tLEFT JOIN \n" +
|
|
|
+ "\t( SELECT id,create_time,pay_money FROM pos_order_goods_payment where 1=1" +
|
|
|
+ "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = #{hotelId} </if>"+
|
|
|
+ ") b\n" +
|
|
|
+ "\tON a.time =date(b.create_time)\n" +
|
|
|
+ "GROUP BY a.time\t\n" +
|
|
|
+ "UNION All\n" +
|
|
|
+ "SELECT '客房' as type, a.time,\n" +
|
|
|
+ "sum(ifnull((case b.subject_type when 1 then b.money when 2 then b.money when 3 then b.money else 0 end),0)) AS room_money,\n" +
|
|
|
+ "sum(ifnull((case b.subject_type when 6 then b.money when 7 then b.money else 0 end),0)) AS other_money\n" +
|
|
|
+ "FROM (\n" +
|
|
|
+ "\tselect time from\n" +
|
|
|
+ "\t(select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) AS time from\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,\n" +
|
|
|
+ "\t (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v\n" +
|
|
|
+ "\twhere time between #{startTime} and #{endTime}\n" +
|
|
|
+ "\tORDER BY time\n" +
|
|
|
+ "\t) a\n" +
|
|
|
+ "\tLEFT JOIN \n" +
|
|
|
+ "\t( SELECT * FROM bus_order_fee where fee_type=1 and preferential_status=2" +
|
|
|
+ "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = #{hotelId} </if>"+
|
|
|
+ ") b\n" +
|
|
|
+ "\tON a.time =date(b.create_time)\n" +
|
|
|
+ "GROUP BY a.time)t\n" +
|
|
|
+ "group by time\t</script>")
|
|
|
+ public List<HashMap<String,Object>> dayShouRuStatList(@Param("hotelId") String hotelId, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按时间每月收入统计列表
|
|
|
+ * @param hotelId
|
|
|
+ * @param startTime
|
|
|
+ * @param endTime
|
|
|
+ * @param months
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Select("<script>select time,sum(room_money) as room_money,sum(other_money) as other_money from \n" +
|
|
|
+ "(SELECT 'pos' as type, a.time\n" +
|
|
|
+ ",0 AS room_money,\n" +
|
|
|
+ "sum(ifnull(b.pay_money,0)) as other_money\n" +
|
|
|
+ "FROM (\n" +
|
|
|
+ "\tselect DATE_FORMAT(time, '%Y-%m' ) as time from\n" +
|
|
|
+ "\t(select adddate('${startTime}',INTERVAL t0.i MONTH ) AS time from\n" +
|
|
|
+ "\t (select 0 i " +
|
|
|
+ "<foreach item='item' index='index' collection='months' open=' union ' separator=' union ' close=' '>"+
|
|
|
+ " select ${item}"+
|
|
|
+ "</foreach>"+
|
|
|
+ ") t0) v\n" +
|
|
|
+ "\tORDER BY time\n" +
|
|
|
+ "\t) a\n" +
|
|
|
+ "\tLEFT JOIN \n" +
|
|
|
+ "\t( SELECT id,create_time,pay_money FROM pos_order_goods_payment where 1=1" +
|
|
|
+ "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>"+
|
|
|
+ ") b\n" +
|
|
|
+ "\tON a.time =DATE_FORMAT(b.create_time, '%Y-%m' )\n" +
|
|
|
+ "GROUP BY a.time\t\n" +
|
|
|
+ "UNION ALL\n" +
|
|
|
+ "SELECT '客房' as type, a.time,\n" +
|
|
|
+ "sum(ifnull((case b.subject_type when 1 then b.money when 2 then b.money when 3 then b.money else 0 end),0)) AS room_money,\n" +
|
|
|
+ "sum(ifnull((case b.subject_type when 6 then b.money when 7 then b.money else 0 end),0)) AS other_money\n" +
|
|
|
+ "FROM (\n" +
|
|
|
+ "\tselect DATE_FORMAT(time, '%Y-%m' ) as time from\n" +
|
|
|
+ "\t(select adddate('${startTime}',INTERVAL t0.i MONTH ) AS time from\n" +
|
|
|
+ "\t (select 0 i " +
|
|
|
+ "<foreach item='item' index='index' collection='months' open=' union ' separator=' union ' close=' '>"+
|
|
|
+ " select ${item}"+
|
|
|
+ "</foreach>"+
|
|
|
+ ") t0) v\n" +
|
|
|
+ "\tORDER BY time\n" +
|
|
|
+ "\t) a\n" +
|
|
|
+ "\tLEFT JOIN \n" +
|
|
|
+ "\t( SELECT * FROM bus_order_fee where fee_type=1 and preferential_status=2\n" +
|
|
|
+ "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>"+
|
|
|
+ "\t) b ON a.time =DATE_FORMAT(b.create_time, '%Y-%m' )\n" +
|
|
|
+ "GROUP BY a.time)t\n" +
|
|
|
+ "group by time\t</script>")
|
|
|
+ public List<HashMap<String,Object>> monthShouRuStatList(@Param("hotelId") String hotelId, @Param("startTime") DateTime startTime, @Param("endTime") DateTime endTime, @Param("months") List<Integer> months);
|
|
|
+
|
|
|
}
|