Browse Source

经营报表统计

zouxuan 2 năm trước cách đây
mục cha
commit
e673758684

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportNewDao.java

@@ -101,4 +101,7 @@ public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportN
 
     //课程未开始团体云教练预收
     List<Map<Integer,BigDecimal>> sumNotStartCloudPreAmount();
+
+    //统计学员管理费
+    List<Map<Integer,BigDecimal>> sumStudentManagementFee();
 }

+ 6 - 208
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReportNew.java

@@ -1,9 +1,11 @@
 package com.ym.mec.biz.dal.entity;
 
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.math.BigDecimal;
 
+@Data
 public class OperatingReportNew {
 
     private Integer id;
@@ -46,6 +48,10 @@ public class OperatingReportNew {
     @ApiModelProperty(value="销售成本")
     private BigDecimal saleCost = BigDecimal.ZERO;
 
+    //学员管理费
+    @ApiModelProperty(value="学员管理费")
+    private BigDecimal studentManagementFee = BigDecimal.ZERO;
+
     //OA审批固定费用总和
     @ApiModelProperty(value="固定费用")
     private BigDecimal fixedCosts = BigDecimal.ZERO;
@@ -94,212 +100,4 @@ public class OperatingReportNew {
 
     @ApiModelProperty(value="月份")
     private String month;
-
-    public BigDecimal getMaintenanceAmount() {
-        return maintenanceAmount;
-    }
-
-    public void setMaintenanceAmount(BigDecimal maintenanceAmount) {
-        this.maintenanceAmount = maintenanceAmount;
-    }
-
-    public BigDecimal getCloudPrepaidFee() {
-        return cloudPrepaidFee;
-    }
-
-    public void setCloudPrepaidFee(BigDecimal cloudPrepaidFee) {
-        this.cloudPrepaidFee = cloudPrepaidFee;
-    }
-
-    public BigDecimal getCoursePrepaidFee() {
-        return coursePrepaidFee;
-    }
-
-    public void setCoursePrepaidFee(BigDecimal coursePrepaidFee) {
-        this.coursePrepaidFee = coursePrepaidFee;
-    }
-
-    public BigDecimal getSalePrepaidFee() {
-        return salePrepaidFee;
-    }
-
-    public void setSalePrepaidFee(BigDecimal salePrepaidFee) {
-        this.salePrepaidFee = salePrepaidFee;
-    }
-
-    public BigDecimal getOtherPrepaidFee() {
-        return otherPrepaidFee;
-    }
-
-    public void setOtherPrepaidFee(BigDecimal otherPrepaidFee) {
-        this.otherPrepaidFee = otherPrepaidFee;
-    }
-
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    public String getPrincipal() {
-        return principal;
-    }
-
-    public void setPrincipal(String principal) {
-        this.principal = principal;
-    }
-
-    public String getOrganName() {
-        return organName;
-    }
-
-    public void setOrganName(String organName) {
-        this.organName = organName;
-    }
-
-    public Integer getOrganId() {
-        return organId;
-    }
-
-    public void setOrganId(Integer organId) {
-        this.organId = organId;
-    }
-
-    public BigDecimal getSaleAmount() {
-        return saleAmount;
-    }
-
-    public void setSaleAmount(BigDecimal saleAmount) {
-        this.saleAmount = saleAmount;
-    }
-
-    public BigDecimal getServiceAmount() {
-        return serviceAmount;
-    }
-
-    public void setServiceAmount(BigDecimal serviceAmount) {
-        this.serviceAmount = serviceAmount;
-    }
-
-    public BigDecimal getCourseAmount() {
-        return courseAmount;
-    }
-
-    public void setCourseAmount(BigDecimal courseAmount) {
-        this.courseAmount = courseAmount;
-    }
-
-    public BigDecimal getCloudAmount() {
-        return cloudAmount;
-    }
-
-    public void setCloudAmount(BigDecimal cloudAmount) {
-        this.cloudAmount = cloudAmount;
-    }
-
-    public BigDecimal getBusinessRefund() {
-        return businessRefund;
-    }
-
-    public void setBusinessRefund(BigDecimal businessRefund) {
-        this.businessRefund = businessRefund;
-    }
-
-    public BigDecimal getTotalIncome() {
-        return totalIncome;
-    }
-
-    public void setTotalIncome(BigDecimal totalIncome) {
-        this.totalIncome = totalIncome;
-    }
-
-    public BigDecimal getSaleCost() {
-        return saleCost;
-    }
-
-    public void setSaleCost(BigDecimal saleCost) {
-        this.saleCost = saleCost;
-    }
-
-    public BigDecimal getFixedCosts() {
-        return fixedCosts;
-    }
-
-    public void setFixedCosts(BigDecimal fixedCosts) {
-        this.fixedCosts = fixedCosts;
-    }
-
-    public BigDecimal getVariableCosts() {
-        return variableCosts;
-    }
-
-    public void setVariableCosts(BigDecimal variableCosts) {
-        this.variableCosts = variableCosts;
-    }
-
-    public BigDecimal getInternalSettlement() {
-        return internalSettlement;
-    }
-
-    public void setInternalSettlement(BigDecimal internalSettlement) {
-        this.internalSettlement = internalSettlement;
-    }
-
-    public BigDecimal getTotalCost() {
-        return totalCost;
-    }
-
-    public void setTotalCost(BigDecimal totalCost) {
-        this.totalCost = totalCost;
-    }
-
-    public BigDecimal getQuasiDiscretionaryProfit() {
-        return quasiDiscretionaryProfit;
-    }
-
-    public void setQuasiDiscretionaryProfit(BigDecimal quasiDiscretionaryProfit) {
-        this.quasiDiscretionaryProfit = quasiDiscretionaryProfit;
-    }
-
-    public BigDecimal getPrepaidFee() {
-        return prepaidFee;
-    }
-
-    public void setPrepaidFee(BigDecimal prepaidFee) {
-        this.prepaidFee = prepaidFee;
-    }
-
-    public BigDecimal getPrepayments() {
-        return prepayments;
-    }
-
-    public void setPrepayments(BigDecimal prepayments) {
-        this.prepayments = prepayments;
-    }
-
-    public BigDecimal getReceivables() {
-        return receivables;
-    }
-
-    public void setReceivables(BigDecimal receivables) {
-        this.receivables = receivables;
-    }
-
-    public BigDecimal getPayable() {
-        return payable;
-    }
-
-    public void setPayable(BigDecimal payable) {
-        this.payable = payable;
-    }
-
-    public String getMonth() {
-        return month;
-    }
-
-    public void setMonth(String month) {
-        this.month = month;
-    }
 }

+ 15 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportNewServiceImpl.java

@@ -59,7 +59,7 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 		operatingReportCloudDao.settlementCalender(currentMonth);
 		//标记当月结算的缴费项目(缴费项目结算后缴费、或者进行中加学员的都算当月结算)
 		operatingReportCloudDao.settlementCurrentCalender(currentMonth);
-		//销售收入、销售成本
+		//分部销售收入、销售成本
 		List<OperatingReportNew> sellList = operatingReportNewDao.sumSellAmount(currentMonth);
 		Map<Integer, OperatingReportNew> collect = sellList.stream().collect(Collectors.groupingBy(OperatingReportNew::getOrganId,Collectors.collectingAndThen(Collectors.toList(),value->value.get(0))));
 		//服务收入
@@ -83,6 +83,9 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 //		Map<Integer, BigDecimal> collect22 = MapUtil.convertIntegerMap(operatingReportNewDao.sumLossCloudAmount(currentMonth));
 		//付费课程实际收入
 		Map<Integer, BigDecimal> collect2 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCourseAmount(firstDayOfMonth,lastDayOfMonth,currentYear));
+		//获取分部学员管理费(每个在读学员80块,算分部成本,总部收入)
+		Map<Integer, BigDecimal> studentManagementFeeMap = MapUtil.convertIntegerMap(operatingReportNewDao.sumStudentManagementFee());
+
 
 		//个人云教练当月收入
 		Map<Integer, BigDecimal> collect3 = MapUtil.convertIntegerMap(operatingReportNewDao.sumPersonalCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth));
@@ -154,7 +157,7 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 				operatingReportNew.setSaleAmount(reportNew.getSaleAmount());
 				operatingReportNew.setSaleCost(reportNew.getSaleCost());
 			}
-
+			operatingReportNew.setStudentManagementFee(studentManagementFeeMap.get(organId));
 			operatingReportNew.setCourseAmount(getAmount(collect2.get(organId)));
 //			operatingReportNew.setCourseAmount(operatingReportNew.getCourseAmount().add(getAmount(collect2.get(organId))));
 			operatingReportNew.setCourseAmount(operatingReportNew.getCourseAmount().add(getAmount(collect24.get(organId))));
@@ -172,9 +175,13 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 
 			operatingReportNew.setInternalSettlement(getAmount(collect18.get(organId)));
 			operatingReportNew.setVariableCosts(getAmount(collect7.get(organId)));
+			//固定费用
 			operatingReportNew.setFixedCosts(getAmount(collect8.get(organId)));
+			//成本合计
 			operatingReportNew.setTotalCost(operatingReportNew.getInternalSettlement().
-					add(operatingReportNew.getFixedCosts()).add(operatingReportNew.getVariableCosts()));
+					add(operatingReportNew.getFixedCosts()).
+					add(operatingReportNew.getVariableCosts()).
+					add(operatingReportNew.getStudentManagementFee()));
 
 			operatingReportNew.setCloudPrepaidFee(getAmount(collect9.get(organId)).
 					add(getAmount(collect10.get(organId))).
@@ -196,6 +203,11 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 
 			operatingReportNew.setQuasiDiscretionaryProfit(operatingReportNew.getTotalIncome().subtract(operatingReportNew.getTotalCost()));
 		}
+		//计算总部经营报表
+		OperatingReportNew operatingReportNew = new OperatingReportNew();
+		operatingReportNew.setOrganName("总部");
+		operatingReportNew.setStudentManagementFee(operatingList.stream().map(e->e.getStudentManagementFee()).reduce(BigDecimal.ZERO,BigDecimal::add));
+
 		operatingReportNewDao.batchInsert(operatingList);
 		//将本月乐团课标记为已结算
 		courseScheduleDao.makeSettlementReport(currentMonth);

+ 7 - 1
mec-biz/src/main/resources/config/mybatis/OperatingReportNewMapper.xml

@@ -180,7 +180,7 @@
 		select id_ organ_id_,name_ organ_name_,#{month} month_ from organization where del_flag_ = 0 and tenant_id_ = 1
 	</select>
 	<select id="sumSellAmount" resultMap="OperatingReportNew">
-		select so.organ_id_,SUM(so.actual_amount_) sale_amount_,SUM(CASE WHEN so.status_ = 1 THEN 0 ELSE so.sell_cost_ * so.num_ END) sale_cost_ from sell_order so
+		select so.organ_id_,SUM(so.expect_amount_) sale_amount_,SUM(CASE WHEN so.status_ = 1 THEN 0 ELSE so.organ_sell_cost_ * so.num_ END) sale_cost_ from sell_order so
 		left join student_payment_order spo ON spo.order_no_ = so.order_no_
 		left join music_group mg ON mg.id_ = spo.music_group_id_ AND spo.group_type_ = 'MUSIC'
 		where (mg.musical_instruments_provide_status_ = 1 AND mg.musical_instruments_provide_time_ = #{month}) OR
@@ -337,4 +337,10 @@
 		where orc.start_date_ IS NULL AND orc.course_price_ > 0
 		group by orc.organ_id_
 	</select>
+	<select id="sumStudentManagementFee" resultType="java.util.Map">
+		select mg.organ_id_ 'key',COUNT(DISTINCT sr.user_id_) * 80 'value' from student_registration sr
+		left join music_group mg ON mg.id_ = sr.music_group_id_
+		where sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
+		group by mg.organ_id_
+	</select>
 </mapper>