Browse Source

收支情况统计

gqx 2 years ago
parent
commit
f0ec368e9f

+ 7 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/finance/controller/SummaryController.java

@@ -263,4 +263,11 @@ public class SummaryController {
 		List<PayTypeStatVo>  list = summaryService.dayPayTypeExpendList(hotelId);
 		return Result.OK(list);
 	}
+
+	@ApiOperation(value = "收支情况统计", notes = "收支情况统计")
+	@GetMapping(value = "/financeSummary")
+	public Result<List<HashMap<String,Object>>> getFinanceSummary(@RequestParam String hotelId,@RequestParam Integer section) {
+		List<HashMap<String,Object>> list = summaryService.financeSummary(hotelId,section);
+		return Result.OK(list);
+	}
 }

+ 73 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/finance/mapper/SummaryMapper.java

@@ -732,4 +732,77 @@ public interface SummaryMapper extends BaseMapper<PosOrderGoodsPayment> {
             "<if test='payType != null and payType !=\"\"'> and b.pay_type = '${payType}' </if>" +
             "</script>")
     public List<HashMap<String, Object>> dayPayTypeExpendDetailList(@Param("payType") String payType);
+
+    /**
+     * 收支情况近N天统计
+     * @param hotelId
+     * @param day 天数
+     * @return
+     */
+    @Select("<script>select sum(money) as money,abs(sum(zc_money)) as zc_money,sum(money)-abs(sum(zc_money)) as jy_money from(\n" +
+            "select ifnull(sum(pay_money),0) as money,0 as zc_money from pos_order_goods_payment\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and datediff(create_time,now())>-${day}\n" +
+            "UNION ALL\n" +
+            "select ifnull(sum(money),0) as money,0 as zc_money from bus_order_fee\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and fee_type=2 and preferential_status=2 and subject_type!=5\n" +
+            "and datediff(create_time,now())>-${day}"+
+            "UNION ALL\n" +
+            "select 0 as money,ifnull(sum(money),0) as zc_money from bus_order_fee\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and fee_type=2 and preferential_status=2 and subject_type=5 and custorer_order_remark='结账退款'\n" +
+            "and datediff(create_time,now())>-${day})t</script>")
+    public List<HashMap<String, Object>> _7DayFinanceSummary(@Param("hotelId") String hotelId,Integer day);
+
+    /**
+     * 收支情况本月统计
+     * @param hotelId
+     * @return
+     */
+    @Select("<script>select sum(money) as money,abs(sum(zc_money)) as zc_money,sum(money)-abs(sum(zc_money)) as jy_money from(\n" +
+            "select ifnull(sum(pay_money),0) as money,0 as zc_money from pos_order_goods_payment\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and DATE_FORMAT(create_time,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m')\n" +
+            "UNION ALL\n" +
+            "select ifnull(sum(money),0) as money,0 as zc_money from bus_order_fee\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and fee_type=2 and preferential_status=2 and subject_type!=5\n" +
+            "and DATE_FORMAT(create_time,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m')"+
+            "UNION ALL\n" +
+            "select 0 as money,ifnull(sum(money),0) as zc_money from bus_order_fee\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and fee_type=2 and preferential_status=2 and subject_type=5 and custorer_order_remark='结账退款'\n" +
+            "and DATE_FORMAT(create_time,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m'))t</script>")
+    public List<HashMap<String, Object>> monthFinanceSummary(@Param("hotelId") String hotelId);
+
+    /**
+     * 收支情况本年统计
+     * @param hotelId
+     * @return
+     */
+    @Select("<script>select sum(money) as money,abs(sum(zc_money)) as zc_money,sum(money)-abs(sum(zc_money)) as jy_money from(\n" +
+            "select ifnull(sum(pay_money),0) as money,0 as zc_money from pos_order_goods_payment\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and DATE_FORMAT(create_time,'%Y')=DATE_FORMAT(CURDATE(),'%Y')\n" +
+            "UNION ALL\n" +
+            "select ifnull(sum(money),0) as money,0 as zc_money from bus_order_fee\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and fee_type=2 and preferential_status=2 and subject_type!=5\n" +
+            "and DATE_FORMAT(create_time,'%Y')=DATE_FORMAT(CURDATE(),'%Y')"+
+            "UNION ALL\n" +
+            "select 0 as money,ifnull(sum(money),0) as zc_money from bus_order_fee\n" +
+            "where 1=1\n" +
+            "<if test='hotelId != null and hotelId !=\"\"'> and hotel_id = '${hotelId}' </if>" +
+            "and fee_type=2 and preferential_status=2 and subject_type=5 and custorer_order_remark='结账退款'\n" +
+            "and DATE_FORMAT(create_time,'%Y')=DATE_FORMAT(CURDATE(),'%Y'))t</script>")
+    public List<HashMap<String, Object>> yearFinanceSummary(@Param("hotelId") String hotelId);
 }

+ 8 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/finance/service/ISummaryService.java

@@ -144,4 +144,12 @@ public interface ISummaryService extends IService<PosOrderGoodsPayment> {
      * @return
      */
     public List<PayTypeStatVo> dayPayTypeExpendList(String hotelId);
+
+    /**
+     * 收支情况统计
+     * @param hotelId
+     * @param section 1近7天 2本月 3近半年 4本年度
+     * @return
+     */
+    public List<HashMap<String, Object>> financeSummary(String hotelId,Integer section);
 }

+ 19 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/finance/service/impl/SummaryServiceImpl.java

@@ -289,4 +289,23 @@ public class SummaryServiceImpl extends ServiceImpl<SummaryMapper, PosOrderGoods
         }
         return list;
     }
+
+    /**
+     * 收支情况统计
+     * @param hotelId
+     * @param section 1近7天 2本月 3近半年 4本年度
+     * @return
+     */
+    public List<HashMap<String, Object>> financeSummary(String hotelId,Integer section) {
+        if (section.equals(1)) {
+            return summaryMapper._7DayFinanceSummary(hotelId, 7);
+        } else if (section.equals(2)) {
+            return summaryMapper.monthFinanceSummary(hotelId);
+        } else if (section.equals(3)) {
+            return summaryMapper._7DayFinanceSummary(hotelId, 182);
+        } else if (section.equals(4)) {
+            return summaryMapper.yearFinanceSummary(hotelId);
+        }
+        return null;
+    }
 }