ソースを参照

经营报表导出

zouxuan 2 年 前
コミット
610a50e24b

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportNewDao.java

@@ -1,7 +1,8 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.HumanTypeDto;
 import com.ym.mec.biz.dal.dto.OASummaryExpensesDto;
-import com.ym.mec.biz.dal.dto.OperatingReportNewDto1;
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.OperatingReportNew;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
@@ -111,4 +112,10 @@ public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportN
 
     //oa费用汇总
     List<OASummaryExpensesDto> queryOASummaryExpenses(String month);
+
+    //统计额外的经营报表的收入
+    List<HumanTypeDto> sumHumanCost(@Param("month") String currentMonth);
+
+    //oa费用明细
+    List<FinancialExpenditure> queryOASummaryExpensesDetail(@Param("month") String month);
 }

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/HumanTypeDto.java

@@ -0,0 +1,16 @@
+package com.ym.mec.biz.dal.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class HumanTypeDto {
+    private Integer organId;
+    private BigDecimal fixedCost = BigDecimal.ZERO; // 固定人力成本
+    private BigDecimal variableCost = BigDecimal.ZERO; // 变动人力成本
+    private BigDecimal networkClassroomCost = BigDecimal.ZERO; // 网络教室成本
+    private BigDecimal cloudCoachingCost = BigDecimal.ZERO; // 云教练成本
+    private BigDecimal internalSettlement = BigDecimal.ZERO; // 内部结算
+    private BigDecimal studentManagementFeeAdjustment = BigDecimal.ZERO; // 学员管理费调整
+}

+ 50 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/OperatingTotalIncomeDto.java

@@ -0,0 +1,50 @@
+package com.ym.mec.biz.dal.dto;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class OperatingTotalIncomeDto {
+    // 城市
+    private String organName;
+
+    // 学生指导费课耗收入
+    private BigDecimal studentGuidanceIncome;
+
+    // 云教练团课耗收入
+//    private BigDecimal cloudCoachGroupClassIncome;
+
+    // 学校课程采买课耗收入
+    private BigDecimal coursePurchaseIncome;
+
+    // 考级
+    private BigDecimal examIncome;
+
+    // 维修费用
+    private BigDecimal maintenanceCost;
+
+    // 乐保费用
+    private BigDecimal instrumentInsuranceCost;
+
+    // 其他服务收入
+    private BigDecimal otherServiceIncome;
+
+    // 云教练收入
+    private BigDecimal cloudCoachIncome;
+
+    // 团购乐器
+    private BigDecimal groupPurchaseInstruments;
+
+    // 团购教辅
+    private BigDecimal groupPurchaseTeachingAids;
+
+    // 大件乐器
+    private BigDecimal largeInstruments;
+
+    // 服务收入
+    private BigDecimal serviceIncome;
+
+    // 销售收入
+    private BigDecimal salesIncome;
+}

+ 2 - 296
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentOrderExportDto.java

@@ -4,10 +4,12 @@ import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.common.enums.BaseEnum;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.math.BigDecimal;
 import java.util.List;
 
+@Data
 public class StudentPaymentOrderExportDto extends StudentPaymentOrderRouteDto {
     @ApiModelProperty(value = "分部",required = true)
     private String organName;
@@ -195,300 +197,4 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrderRouteDto {
 
     @ApiModelProperty(value = "教学点",required = true)
     private String schoolName;
-
-    public String getOrganName() {
-        return organName;
-    }
-
-    public void setOrganName(String organName) {
-        this.organName = organName;
-    }
-
-    public String getUserOrganName() {
-        return userOrganName;
-    }
-
-    public void setUserOrganName(String userOrganName) {
-        this.userOrganName = userOrganName;
-    }
-
-    public BigDecimal getSporadicAmount() {
-        return sporadicAmount;
-    }
-
-    public void setSporadicAmount(BigDecimal sporadicAmount) {
-        this.sporadicAmount = sporadicAmount;
-    }
-
-    public String getSporadicType() {
-        return sporadicType;
-    }
-
-    public void setSporadicType(String sporadicType) {
-        this.sporadicType = sporadicType;
-    }
-
-    public BigDecimal getMusicalFee() {
-        return musicalFee;
-    }
-
-    public void setMusicalFee(BigDecimal musicalFee) {
-        this.musicalFee = musicalFee;
-    }
-
-    public BigDecimal getLeaseFee() {
-        return leaseFee;
-    }
-
-    public void setLeaseFee(BigDecimal leaseFee) {
-        this.leaseFee = leaseFee;
-    }
-
-    public BigDecimal getTeachingFee() {
-        return teachingFee;
-    }
-
-    public void setTeachingFee(BigDecimal teachingFee) {
-        this.teachingFee = teachingFee;
-    }
-
-    public BigDecimal getRepairFee() {
-        return repairFee;
-    }
-
-    public void setRepairFee(BigDecimal repairFee) {
-        this.repairFee = repairFee;
-    }
-
-    public BigDecimal getMusicGroupCourseFee() {
-        return musicGroupCourseFee;
-    }
-
-    public void setMusicGroupCourseFee(BigDecimal musicGroupCourseFee) {
-        this.musicGroupCourseFee = musicGroupCourseFee;
-    }
-
-    public BigDecimal getCourseSchoolBuyAmount() {
-        return courseSchoolBuyAmount;
-    }
-
-    public void setCourseSchoolBuyAmount(BigDecimal courseSchoolBuyAmount) {
-        this.courseSchoolBuyAmount = courseSchoolBuyAmount;
-    }
-
-    public BigDecimal getHighCourseFee() {
-        return highCourseFee;
-    }
-
-    public void setHighCourseFee(BigDecimal highCourseFee) {
-        this.highCourseFee = highCourseFee;
-    }
-
-    public BigDecimal getVipCourseFee() {
-        return vipCourseFee;
-    }
-
-    public void setVipCourseFee(BigDecimal vipCourseFee) {
-        this.vipCourseFee = vipCourseFee;
-    }
-
-    public BigDecimal getPracticeCourseFee() {
-        return practiceCourseFee;
-    }
-
-    public void setPracticeCourseFee(BigDecimal practiceCourseFee) {
-        this.practiceCourseFee = practiceCourseFee;
-    }
-
-    public BigDecimal getTheoryCourseFee() {
-        return theoryCourseFee;
-    }
-
-    public void setTheoryCourseFee(BigDecimal theoryCourseFee) {
-        this.theoryCourseFee = theoryCourseFee;
-    }
-
-    public BigDecimal getDegreeFee() {
-        return degreeFee;
-    }
-
-    public void setDegreeFee(BigDecimal degreeFee) {
-        this.degreeFee = degreeFee;
-    }
-
-    public BigDecimal getOtherFee() {
-        return otherFee;
-    }
-
-    public void setOtherFee(BigDecimal otherFee) {
-        this.otherFee = otherFee;
-    }
-
-    public BigDecimal getMaintenanceFee() {
-        return maintenanceFee;
-    }
-
-    public void setMaintenanceFee(BigDecimal maintenanceFee) {
-        this.maintenanceFee = maintenanceFee;
-    }
-
-    public BigDecimal getRetailGoodsFee() {
-        return retailGoodsFee;
-    }
-
-    public void setRetailGoodsFee(BigDecimal retailGoodsFee) {
-        this.retailGoodsFee = retailGoodsFee;
-    }
-
-    public BigDecimal getLargeMusicalFee() {
-        return largeMusicalFee;
-    }
-
-    public void setLargeMusicalFee(BigDecimal largeMusicalFee) {
-        this.largeMusicalFee = largeMusicalFee;
-    }
-
-    public BigDecimal getMaintenanceProductFee() {
-        return maintenanceProductFee;
-    }
-
-    public void setMaintenanceProductFee(BigDecimal maintenanceProductFee) {
-        this.maintenanceProductFee = maintenanceProductFee;
-    }
-
-    public BigDecimal getCloudTeacherFee() {
-        return cloudTeacherFee;
-    }
-
-    public void setCloudTeacherFee(BigDecimal cloudTeacherFee) {
-        this.cloudTeacherFee = cloudTeacherFee;
-    }
-
-    public BigDecimal getVisitFee() {
-        return visitFee;
-    }
-
-    public void setVisitFee(BigDecimal visitFee) {
-        this.visitFee = visitFee;
-    }
-
-    public BigDecimal getRechargeFee() {
-        return rechargeFee;
-    }
-
-    public void setRechargeFee(BigDecimal rechargeFee) {
-        this.rechargeFee = rechargeFee;
-    }
-
-    public String getSubjectName() {
-        return subjectName;
-    }
-
-    public void setSubjectName(String subjectName) {
-        this.subjectName = subjectName;
-    }
-
-    public String getCooperationOrganName() {
-        return cooperationOrganName;
-    }
-
-    public void setCooperationOrganName(String cooperationOrganName) {
-        this.cooperationOrganName = cooperationOrganName;
-    }
-
-    public String getEduTeacher() {
-        return eduTeacher;
-    }
-
-    public void setEduTeacher(String eduTeacher) {
-        this.eduTeacher = eduTeacher;
-    }
-
-    public Integer getChargeType() {
-        return chargeType;
-    }
-
-    public void setChargeType(Integer chargeType) {
-        this.chargeType = chargeType;
-    }
-
-    public List<StudentPaymentOrderDetail> getOrderDetailList() {
-        return orderDetailList;
-    }
-
-    public void setOrderDetailList(List<StudentPaymentOrderDetail> orderDetailList) {
-        this.orderDetailList = orderDetailList;
-    }
-
-    public List<Goods> getGoodsList() {
-        return goodsList;
-    }
-
-    public void setGoodsList(List<Goods> goodsList) {
-        this.goodsList = goodsList;
-    }
-
-    public String getFeeFlag() {
-        return feeFlag;
-    }
-
-    public void setFeeFlag(String feeFlag) {
-        this.feeFlag = feeFlag;
-    }
-
-    public Integer getPayingStatus() {
-        return payingStatus;
-    }
-
-    public void setPayingStatus(Integer payingStatus) {
-        this.payingStatus = payingStatus;
-    }
-
-    public BigDecimal getOrderAmount() {
-        return orderAmount;
-    }
-
-    public void setOrderAmount(BigDecimal orderAmount) {
-        this.orderAmount = orderAmount;
-    }
-
-    public BigDecimal getTranslatedIncome() {
-        return translatedIncome;
-    }
-
-    public void setTranslatedIncome(BigDecimal translatedIncome) {
-        this.translatedIncome = translatedIncome;
-    }
-
-    public String getTypeDesc() {
-        return typeDesc;
-    }
-
-    public void setTypeDesc(String typeDesc) {
-        this.typeDesc = typeDesc;
-    }
-
-    public String getFeeMusicGroupId() {
-        return feeMusicGroupId;
-    }
-
-    public void setFeeMusicGroupId(String feeMusicGroupId) {
-        this.feeMusicGroupId = feeMusicGroupId;
-    }
-
-    public String getFeeMusicGroupName() {
-        return feeMusicGroupName;
-    }
-
-    public void setFeeMusicGroupName(String feeMusicGroupName) {
-        this.feeMusicGroupName = feeMusicGroupName;
-    }
-
-    public String getSchoolName() {
-        return schoolName;
-    }
-
-    public void setSchoolName(String schoolName) {
-        this.schoolName = schoolName;
-    }
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/FinancialExpenditure.java

@@ -4,8 +4,10 @@ import com.ym.mec.biz.dal.enums.ExpenditureTypeEnum;
 import com.ym.mec.biz.dal.enums.FeeProjectEnum;
 import com.ym.mec.common.entity.BaseEntity;
 import com.ym.mec.common.tenant.TenantContextHolder;
+import com.ym.mec.util.date.DateUtil;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.apache.commons.lang3.StringUtils;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -57,6 +59,12 @@ public class FinancialExpenditure {
 	@ApiModelProperty(value = "费用明细",required = false)
 	private String itemDetail;
 	/**  */
+	@ApiModelProperty(value = "经营报表生效时间",required = false)
+	private String effectiveTime;
+
+	@ApiModelProperty(value = "当月实际金额",required = false)
+	private BigDecimal currentAmount = BigDecimal.ZERO;;
+	/**  */
 	@ApiModelProperty(value = "支付时间",required = false)
 	private Date paymentTime;
 	/**  */

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportEnum.java

@@ -89,6 +89,8 @@ public enum ExportEnum implements BaseEnum<String, ExportEnum> {
     EXPORT_INDEX_COOP("EXPORT_INDEX_COOP", "首页经营数据合作单位导出"),
     EXPORT_TEACHER_CLOUD_COURSE_REPORT("EXPORT_TEACHER_CLOUD_COURSE_REPORT","老师云教练使用数据"),
     EXPORT_OA_SUMMARY_EXPENSES("EXPORT_OA_SUMMARY_EXPENSES","oa费用汇总"),
+    EXPORT_OA_SUMMARY_EXPENSES_DETAIL("EXPORT_OA_SUMMARY_EXPENSES_DETAIL","oa费用明细"),
+    EXPORT_OPERATING_SUMMARY_INCOME("EXPORT_OPERATING_SUMMARY_INCOME","经营报表收入汇总"),
     ;
 
     private String code;

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ExportTypeEnum.java

@@ -27,7 +27,9 @@ public enum ExportTypeEnum implements BaseEnum<Integer, ExportTypeEnum> {
 	CLASS_GROUP(21, "班级列表导出"),
 	EXPORT_CLOUD_TEACHER_SUM_DETAIL(22, "云教练统计详情导出"),
 	EXPORT_TEACHER_CLOUD_COURSE_REPORT(23, "老师云教练使用数据"),
-	EXPORT_OA_SUMMARY_EXPENSES(24,"oa费用汇总")
+	EXPORT_OA_SUMMARY_EXPENSES(24,"oa费用汇总"),
+	EXPORT_OA_SUMMARY_EXPENSES_DETAIL(25,"oa费用明细"),
+	EXPORT_OPERATING_SUMMARY_INCOME(26,"经营报表收入汇总"),
 	;
 
 	private Integer code;

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ExportService.java

@@ -270,6 +270,8 @@ public interface ExportService {
 
     void orderList(Map<String, Object> params, ManagerDownload managerDownload);
 
+    void operatingSummaryIncome(Map<String, Object> params, ManagerDownload managerDownload);
+
     void orderListSum(Map<String, Object> params, ManagerDownload managerDownload);
 
     void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload);

+ 5 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/OperatingReportNewService.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dao.OperatingReportNewDao;
 import com.ym.mec.biz.dal.dto.OASummaryExpensesDto;
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.OperatingReportNew;
 import com.ym.mec.common.service.BaseService;
 
@@ -14,12 +15,9 @@ public interface OperatingReportNewService extends BaseService<Integer, Operatin
 
     void operatingReportMonth(Date month);
 
-    /**
-    * @description: oa费用汇总
-     * @param month
-    * @return void
-    * @author zx
-    * @date 2023/4/21 14:55
-    */
+    //oa费用汇总
     List<OASummaryExpensesDto> queryOASummaryExpenses(String month);
+
+    //oa费用明细
+    List<FinancialExpenditure> queryOASummaryExpensesDetail(String month);
 }

+ 301 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -384,6 +384,8 @@ public class ExportServiceImpl implements ExportService {
         exportManageFuncMap.put(ExportEnum.CLASS_GROUP, info -> exportClassGroup(info));
         exportManageFuncMap.put(ExportEnum.EXPORT_TEACHER_CLOUD_COURSE_REPORT, info -> exportTeacherCloudCourseReport(info));
         exportManageFuncMap.put(ExportEnum.EXPORT_OA_SUMMARY_EXPENSES, info -> exportOaSummaryExpenses(info));
+        exportManageFuncMap.put(ExportEnum.EXPORT_OA_SUMMARY_EXPENSES_DETAIL, info -> exportOaSummaryExpensesDetail(info));
+        exportManageFuncMap.put(ExportEnum.EXPORT_OPERATING_SUMMARY_INCOME, info -> exportOperatingSummaryIncome(info));
     }
 
     private HttpResponseResult exportOaSummaryExpenses(Map<String, Object> info) {
@@ -395,6 +397,32 @@ public class ExportServiceImpl implements ExportService {
                 managerDownload.getName());
     }
 
+    private HttpResponseResult exportOaSummaryExpensesDetail(Map<String, Object> info) {
+        String month = getParam(info, "month", String.class);
+        SysUser user = sysUserService.getUser();
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_OA_SUMMARY_EXPENSES_DETAIL,user.getId());
+        return this.asyncExport(() -> this.initExportInfo(operatingReportNewService.queryOASummaryExpensesDetail(month),
+                        managerDownload,ExportEnum.EXPORT_OA_SUMMARY_EXPENSES_DETAIL),
+                managerDownload.getName());
+    }
+
+    private HttpResponseResult exportOperatingSummaryIncome(Map<String, Object> info) {
+        String month = getParam(info, "month", String.class);
+        Map<String, Object> params = new HashMap<>();
+        params.put("notGroupType","MALL_SELL");
+        params.put("month",month);
+        int count = studentPaymentOrderDao.queryCount(params);
+        if (count <= 0) {
+            return BaseController.failed("没有可导出的数据");
+        }
+        if (count > 50000) {
+            return BaseController.failed("数据集太大,不能导出.最大数据集不能超过50000");
+        }
+        ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.EXPORT_OPERATING_SUMMARY_INCOME, sysUserService.getUserId());
+        return this.asyncExport(() -> this.operatingSummaryIncome(params, managerDownload),
+                managerDownload.getName());
+    }
+
     private List<StudentServeExportDto> exportStudentServeInfo(Map<String, Object> info) {
         String monday = getParam(info, "monday", String.class);
         String sunday = getParam(info, "sunday", String.class);
@@ -2149,8 +2177,6 @@ public class ExportServiceImpl implements ExportService {
                 if (!CollectionUtils.isEmpty(exportDtoList)) {
                     StudentPaymentOrderExportDto feeByType = exportDtoList.get(0);
                     BigDecimal childRepairFee = childRepairMap.get(row.getId()) == null ? BigDecimal.ZERO : childRepairMap.get(row.getId());
-//                    StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
-//                    BigDecimal childRepairFee = sellOrderDao.getChildRepair(row.getId());
                     row.setMusicalFee(feeByType.getMusicalFee());
                     row.setTeachingFee(feeByType.getTeachingFee().subtract(childRepairFee));
                     row.setMaintenanceProductFee(feeByType.getRepairFee().add(childRepairFee));
@@ -2279,6 +2305,275 @@ public class ExportServiceImpl implements ExportService {
     }
 
     @Override
+    public void operatingSummaryIncome(Map<String, Object> params, ManagerDownload managerDownload) {
+        List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
+        long i = 1;
+        //获取机构费率
+        List<Long> otherOrderIds = studentPaymentOrderExportDtos.stream().filter(e -> e.getGroupType() != GroupType.GOODS_SELL
+                && e.getGroupType() != GroupType.REPLACEMENT
+                && e.getGroupType() != GroupType.PRACTICE
+                && e.getGroupType() != GroupType.SPORADIC
+                && e.getGroupType() != GroupType.MEMBER
+                && e.getGroupType() != GroupType.ACTIVITY
+                && e.getGroupType() != GroupType.VIP).map(e -> e.getId()).collect(Collectors.toList());
+        Map<Long, List<StudentPaymentOrderExportDto>> feeByTypeMap = new HashMap<>();
+        Map<Long, BigDecimal> childRepairMap = new HashMap<>();
+        if (!CollectionUtils.isEmpty(otherOrderIds)) {
+            List<StudentPaymentOrderExportDto> feeByType = sellOrderDao.queryFeeByType(otherOrderIds);
+            feeByTypeMap = feeByType.stream().collect(Collectors.groupingBy(StudentPaymentOrderExportDto::getId));
+            childRepairMap = MapUtil.convertIntegerMap(sellOrderDao.queryChildRepair(otherOrderIds));
+        }
+        //按分部分组
+        Map<Integer, List<StudentPaymentOrderExportDto>> listMap = studentPaymentOrderExportDtos.stream().collect(Collectors.groupingBy(e -> e.getOrganId()));
+        for (Integer organId : listMap.keySet()) {
+            OperatingTotalIncomeDto incomeDto = new OperatingTotalIncomeDto();
+            List<StudentPaymentOrderExportDto> orderExportDtos = listMap.get(organId);
+            StudentPaymentOrderExportDto dto = orderExportDtos.get(0);
+            incomeDto.setOrganName(dto.getOrganName());
+            for (StudentPaymentOrderExportDto row : orderExportDtos) {
+                if (row.getActualAmount() == null) {
+                    row.setActualAmount(BigDecimal.ZERO);
+                }
+                if (row.getBalancePaymentAmount() == null) {
+                    row.setBalancePaymentAmount(BigDecimal.ZERO);
+                }
+                if (row.getOrderDetailList() != null) {
+                    for (StudentPaymentOrderDetail orderDetail : row.getOrderDetailList()) {
+                        switch (orderDetail.getType()) {
+                            case COURSE:
+                            case CLASSROOM:
+                            case SINGLE:
+                            case MIX:
+                            case COMPREHENSIVE:
+                            case ENLIGHTENMENT:
+                            case TRAINING_SINGLE:
+                            case TRAINING_MIX:
+                            case MUSIC_NETWORK:
+                            case HIGH:
+                            case HIGH_ONLINE:
+                            case HIGH_ONLINE_COURSE:
+                                row.setMusicGroupCourseFee(row.getMusicGroupCourseFee().add(orderDetail.getPrice()));
+                                break;
+                            case MUSICAL:
+                                if (row.getGroupType() != GroupType.GOODS_SELL) {
+                                    if (orderDetail.getKitGroupPurchaseType() != null && orderDetail.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
+                                        row.setLeaseFee(getActualAmount(orderDetail.getPrice(), row));
+                                    } else {
+                                        row.setMusicalFee(orderDetail.getPrice());
+                                    }
+                                }
+                                break;
+                            case ACCESSORIES:
+                            case TEACHING:
+                                row.setTeachingFee(row.getTeachingFee().add(orderDetail.getPrice()));
+                                break;
+                            case OTHER:
+                                row.setOtherFee(row.getOtherFee().add(orderDetail.getPrice()));
+                                break;
+                            case MAINTENANCE:
+                                row.setMaintenanceFee(getActualAmount(orderDetail.getPrice(), row));
+                                break;
+                            case CLOUD_TEACHER:
+                            case CLOUD_TEACHER_PLUS:
+                                row.setCloudTeacherFee(getActualAmount(orderDetail.getPrice(), row));
+                                break;
+                            case DEGREE_REGISTRATION:
+                                row.setDegreeFee(getActualAmount(orderDetail.getPrice(), row));
+                                break;
+                            case PRACTICE:
+                                row.setPracticeCourseFee(getActualAmount(orderDetail.getPrice(), row));
+                                break;
+                            case VIP:
+                                row.setVipCourseFee(getActualAmount(orderDetail.getPrice(), row));
+                                break;
+                            case THEORY_COURSE:
+                                row.setTheoryCourseFee(getActualAmount(orderDetail.getPrice(), row));
+                                break;
+                            case REPAIR:
+                                row.setRepairFee(getActualAmount(orderDetail.getPrice(), row));
+                                break;
+                            default:
+                                break;
+                        }
+                    }
+                }
+                //专业
+                if (row.getGroupType().equals(GroupType.VIP)) {
+                    row.setVipCourseFee(row.getActualAmount());
+                } else if (row.getGroupType() == GroupType.ACTIVITY) {
+                    row.setVipCourseFee(row.getActualAmount());
+                } else if (row.getGroupType() == GroupType.MEMBER) {
+                    row.setCloudTeacherFee(row.getActualAmount());
+                } else if (row.getGroupType().equals(GroupType.SPORADIC)) {
+                    //考级报名
+                    if (row.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
+                        String[] feeTypes = row.getMemo().split(";");
+                        List<String> feeTypeList = Arrays.asList(feeTypes);
+                        for (String feeTypeStr : feeTypeList) {
+                            int index = feeTypeStr.lastIndexOf(":");
+                            if (index < 0) {
+                                continue;
+                            }
+                            BigDecimal typeFee = new BigDecimal(feeTypeStr.substring(index + 1));
+                            if (row.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
+                                typeFee = typeFee.multiply(row.getActualAmount()).divide(row.getExpectAmount(), 2, BigDecimal.ROUND_DOWN);
+                            }
+                            if (feeTypeStr.contains("VIP")) {
+                                row.setVipCourseFee(typeFee);
+                            } else if (feeTypeStr.contains("网管课")) {
+                                row.setPracticeCourseFee(typeFee);
+                            } else if (feeTypeStr.contains("乐理课")) {
+                                row.setTheoryCourseFee(typeFee);
+                            }
+                        }
+                        row.setDegreeFee(row.getActualAmount().subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()).subtract(row.getTheoryCourseFee()));
+                    } else {
+                        if (row.getChargeType() != null && SporadicChargeTypeEnum.LEVEL.getCode().equals(row.getChargeType())) {
+                            row.setDegreeFee(row.getActualAmount());
+                        } else if (row.getChargeType() != null && SporadicChargeTypeEnum.PRACTICE_GROUP_BUY.getCode().equals(row.getChargeType())) {
+                            row.setPracticeCourseFee(row.getActualAmount());
+                        } else if (row.getChargeType() != null && SporadicChargeTypeEnum.MUSIC_UPKEEP.getCode().equals(row.getChargeType())) {
+                            row.setMaintenanceFee(row.getActualAmount());
+                        } else if (row.getChargeType() != null && SporadicChargeTypeEnum.VISITING_FEE.getCode().equals(row.getChargeType())) {
+                            row.setVisitFee(row.getActualAmount());
+                        } else if (row.getChargeType() != null && (SporadicChargeTypeEnum.RECHARGE.getCode().equals(row.getChargeType()) ||
+                                SporadicChargeTypeEnum.HIGH_ONLINE_ACTIVITY.getCode().equals(row.getChargeType()))) {
+                            row.setRechargeFee(row.getActualAmount());
+                        } else if (row.getChargeType() != null && SporadicChargeTypeEnum.CLOUD_TEACHER_BUY.getCode().equals(row.getChargeType())) {
+                            row.setCloudTeacherFee(row.getActualAmount());
+                        } else {
+                            row.setOtherFee(row.getActualAmount());
+                        }
+                    }
+                } else if (row.getGroupType().equals(GroupType.PRACTICE)) {
+                    row.setPracticeCourseFee(row.getActualAmount());
+                } else if (row.getGroupType().equals(GroupType.REPLACEMENT)) {
+                    row.setMusicalFee(row.getActualAmount());
+                } else if (row.getGroupType().equals(GroupType.GOODS_SELL)) {
+                    row.setRetailGoodsFee(row.getActualAmount());
+                } else {
+                    List<StudentPaymentOrderExportDto> exportDtoList = feeByTypeMap.get(row.getId());
+                    if (!CollectionUtils.isEmpty(exportDtoList)) {
+                        StudentPaymentOrderExportDto feeByType = exportDtoList.get(0);
+                        BigDecimal childRepairFee = childRepairMap.get(row.getId()) == null ? BigDecimal.ZERO : childRepairMap.get(row.getId());
+                        row.setMusicalFee(feeByType.getMusicalFee());
+                        row.setTeachingFee(feeByType.getTeachingFee().subtract(childRepairFee));
+                        row.setMaintenanceProductFee(feeByType.getRepairFee().add(childRepairFee));
+                        row.setOtherFee(feeByType.getOtherFee());
+                        if (row.getGroupType().equals(GroupType.MUSIC)) {
+                            row.setMusicGroupCourseFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).
+                                    subtract(row.getTeachingFee()).subtract(row.getMaintenanceFee()).subtract(row.getMaintenanceProductFee()).
+                                    subtract(feeByType.getOtherFee()).subtract(row.getLeaseFee()).subtract(row.getCloudTeacherFee()).
+                                    subtract(row.getVipCourseFee()).subtract(row.getPracticeCourseFee()));
+                        } else if (row.getGroupType().equals(OrderTypeEnum.REPAIR)) {
+                            row.setRepairFee(feeByType.getActualAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()).subtract(feeByType.getOtherFee()));
+                        } else if (row.getGroupType() == GroupType.OUTORDER) {
+                            //销售收入
+                            BigDecimal add = feeByType.getMusicalFee().add(row.getTeachingFee()).add(row.getMaintenanceProductFee()).add(feeByType.getOtherFee());
+                            //服务收入
+                            BigDecimal subtract = feeByType.getActualAmount().subtract(add);
+                            //如果是淘器微信那么就是零售
+                            if (Objects.equals("淘器微信", row.getMerNos()) && add.compareTo(BigDecimal.ZERO) > 0) {
+                                //如果有服务收入那么是课程学校采买
+                                row.setMusicalFee(BigDecimal.ZERO);
+                                row.setTeachingFee(BigDecimal.ZERO);
+                                row.setMaintenanceProductFee(BigDecimal.ZERO);
+                                row.setOtherFee(subtract);
+                                row.setRetailGoodsFee(add);
+                            } else {
+                                //拆分导入订单
+                                if (row.getType() == OrderTypeEnum.OUTORDER || row.getType() == OrderTypeEnum.SCHOOL) {
+                                    if (row.getType() == OrderTypeEnum.SCHOOL) {
+                                        row.setMusicalFee(BigDecimal.ZERO);
+                                        row.setTeachingFee(BigDecimal.ZERO);
+                                        row.setMaintenanceProductFee(BigDecimal.ZERO);
+                                        row.setOtherFee(BigDecimal.ZERO);
+                                        row.setLargeMusicalFee(add);
+                                    }
+                                    row.setCourseSchoolBuyAmount(subtract);
+                                } else if (row.getType() == OrderTypeEnum.OTHER) {
+                                    row.setOtherFee(row.getOtherFee().add(subtract));
+                                } else {
+                                    row.setMusicalFee(BigDecimal.ZERO);
+                                    row.setTeachingFee(BigDecimal.ZERO);
+                                    row.setMaintenanceProductFee(BigDecimal.ZERO);
+                                    row.setOtherFee(BigDecimal.ZERO);
+                                    row.setRetailGoodsFee(add);
+                                    row.setMusicGroupCourseFee(subtract);
+                                }
+                            }
+                            row.setTransferFee(BigDecimal.ZERO);
+                            row.setPlatformFee(BigDecimal.ZERO);
+                        }
+                    }
+                }
+                row.setId(i);
+                row.setRepairFee(row.getRepairFee().add(row.getMaintenanceProductFee()));
+                row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitFee()));
+                i++;
+                //学员指导课费
+                incomeDto.setStudentGuidanceIncome(incomeDto.getStudentGuidanceIncome()
+                        .add(row.getMusicGroupCourseFee())
+                        .add(row.getVipCourseFee())
+                        .add(row.getPracticeCourseFee())
+                        .add(row.getTheoryCourseFee()));
+                //云教练团课耗收入
+//                incomeDto.setCloudCoachGroupClassIncome();
+                //学校课程采买
+                incomeDto.setCoursePurchaseIncome(incomeDto.getCoursePurchaseIncome()
+                        .add(row.getCourseSchoolBuyAmount()));
+                //考级
+                incomeDto.setExamIncome(incomeDto.getExamIncome()
+                        .add(row.getDegreeFee()));
+                //维修费用
+                incomeDto.setMaintenanceCost(incomeDto.getMaintenanceCost()
+                        .add(row.getRepairFee()));
+                //月保费用
+                incomeDto.setInstrumentInsuranceCost(incomeDto.getInstrumentInsuranceCost()
+                        .add(row.getMaintenanceFee()));
+                //其他服务收入
+                incomeDto.setOtherServiceIncome(incomeDto.getOtherServiceIncome()
+                        .add(row.getLeaseFee())
+                        .add(row.getVisitFee())
+                        .add(row.getRechargeFee())
+                        .add(row.getOtherFee())
+                );
+                //云教练收入
+                incomeDto.setCloudCoachIncome(incomeDto.getCloudCoachIncome()
+                        .add(row.getCloudTeacherFee()));
+                //团购乐器
+                incomeDto.setGroupPurchaseInstruments(incomeDto.getGroupPurchaseInstruments()
+                        .add(row.getRetailGoodsFee()));
+                //教辅
+                incomeDto.setGroupPurchaseTeachingAids(incomeDto.getGroupPurchaseTeachingAids()
+                        .add(row.getTeachingFee()));
+                //大件乐器
+                incomeDto.setLargeInstruments(incomeDto.getLargeInstruments()
+                        .add(row.getLargeMusicalFee()));
+                //其他?
+                //服务收入
+                incomeDto.setServiceIncome(incomeDto.getLargeInstruments()
+                        .add(incomeDto.getStudentGuidanceIncome())
+                        .add(incomeDto.getCoursePurchaseIncome())
+                        .add(incomeDto.getExamIncome())
+                        .add(incomeDto.getMaintenanceCost())
+                        .add(incomeDto.getInstrumentInsuranceCost())
+                        .add(incomeDto.getOtherServiceIncome())
+                );
+                //销售收入
+                incomeDto.setSalesIncome(incomeDto.getSalesIncome()
+                        .add(incomeDto.getCloudCoachIncome())
+                        .add(incomeDto.getGroupPurchaseInstruments())
+                        .add(incomeDto.getGroupPurchaseTeachingAids())
+                        .add(incomeDto.getLargeInstruments())
+                );
+            }
+        }
+        HSSFWorkbook workbook = getHSSFWorkbook(studentPaymentOrderExportDtos, ExportEnum.EXPORT_OPERATING_SUMMARY_INCOME);
+        exportManagerDownload(workbook, managerDownload);
+    }
+
+    @Override
     public void orderListSum(Map<String, Object> params, ManagerDownload managerDownload) {
         List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
         //获取机构费率
@@ -2622,6 +2917,7 @@ public class ExportServiceImpl implements ExportService {
         exportManagerDownload(workbook, managerDownload);
     }
 
+    @Override
     public void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload) {
         //获取分润订单(不包含订单详情)(纯余额支付不处理)
         List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.ExportQueryPage1(params);
@@ -3074,7 +3370,9 @@ public class ExportServiceImpl implements ExportService {
         groupTypeConsumerMap1.put(GroupType.SPORADIC, (basicOrder) -> {
             if (basicOrder.getType() != OrderTypeEnum.DEGREE_REGISTRATION && basicOrder.getChargeType() != null) {
                 for (SporadicChargeTypeEnum chargeType : SporadicChargeTypeEnum.values()) {
-                    if (!chargeType.getCode().equals(basicOrder.getChargeType())) continue;
+                    if (!chargeType.getCode().equals(basicOrder.getChargeType())) {
+                        continue;
+                    }
                     basicOrder.setSporadicType(chargeType.getMsg());
                 }
             }

+ 47 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/FinancialExpenditureServiceImpl.java

@@ -253,13 +253,38 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
             JSONObject formData = JSONObject.parseObject(financialExpenditureDao.getFormData(workOrderId));
             OaFormStructureDto oaFormStructureDto = JSONObject.parseObject(formStructure, OaFormStructureDto.class);
             List<OaInputDto> oaInputDtos = oaFormStructureDto.getList();
+            Date now = new Date();
             //课程退费和乐团退费需要单独处理
             if(pWorkOrderInfo.getProcess().equals(33) ||
                     pWorkOrderInfo.getProcess().equals(22) ||
                     pWorkOrderInfo.getProcess().equals(19) ||
                     pWorkOrderInfo.getProcess().equals(28)){
                 List<FinancialExpenditure> financialExpenditureList = new ArrayList<>();
+                Integer organId = null;
+                String note = "";
+                BigDecimal totalAmount = BigDecimal.ZERO;
                 for (OaInputDto oaInputDto : oaInputDtos) {
+                    if (StringUtils.equals("分部",oaInputDto.getName())) {
+                        String submitForm = oaInputDto.getModel();
+                        if(Objects.isNull(formData.get(submitForm))){
+                            continue;
+                        }
+                        organId = Integer.parseInt(formData.get(submitForm).toString());
+                    }
+                    if (StringUtils.equals("情况说明",oaInputDto.getName())) {
+                        String submitForm = oaInputDto.getModel();
+                        if(Objects.isNull(formData.get(submitForm))){
+                            continue;
+                        }
+                        note = formData.get(submitForm).toString();
+                    }
+                    if (StringUtils.equals("金额",oaInputDto.getName())) {
+                        String submitForm = oaInputDto.getModel();
+                        if(Objects.isNull(formData.get(submitForm))){
+                            continue;
+                        }
+                        totalAmount = new BigDecimal(formData.get(submitForm).toString());
+                    }
                     if(!StringUtils.equals("子表单",oaInputDto.getName()) && !StringUtils.equals("分摊明细",oaInputDto.getName())){
                         continue;
                     }
@@ -272,37 +297,42 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                         //处理房租的分摊明细
                         nullUser:
                         for (HashMap hashMap : hashMaps) {
-                            FinancialExpenditure financialExpenditure = new FinancialExpenditure();
-                            financialExpenditure.setBatchNo(pWorkOrderInfo.getId().toString());
-                            financialExpenditure.setFinancialProcessNo(pWorkOrderInfo.getId().toString());
-                            financialExpenditure.setApplyUser(realName);
-                            financialExpenditure.setApplyUserId(pWorkOrderInfo.getCreator());
-                            financialExpenditure.setProcessId(pWorkOrderInfo.getProcess());
                             List<OaColumnDto> columns = oaInputDto.getColumns();
                             if (columns != null && columns.size() > 0) {
-                                for (OaColumnDto column : columns) {
+                                nullAmount:for (OaColumnDto column : columns) {
                                     List<OaInputDto> columnList = column.getList();
                                     if (columnList != null && columnList.size() > 0) {
+                                        FinancialExpenditure financialExpenditure = new FinancialExpenditure();
                                         for (OaInputDto inputDto : columnList) {
                                             String name = inputDto.getName();
                                             if (name.contains("金额")) {
                                                 Object o = hashMap.get(inputDto.getModel());
                                                 if (Objects.nonNull(o) && StringUtils.isNotEmpty(o.toString())) {
-                                                    financialExpenditure.setAmount(financialExpenditure.getAmount().add(new BigDecimal(Double.parseDouble(o.toString()))));
-                                                    continue;
+                                                    financialExpenditure.setCurrentAmount(new BigDecimal(Double.parseDouble(o.toString())));
+                                                }else {
+                                                    continue nullAmount;
                                                 }
                                             } else if (name.contains("日期")) {
                                                 Object o = hashMap.get(inputDto.getModel());
                                                 if (Objects.nonNull(o) && StringUtils.isNotEmpty(o.toString())) {
-                                                    financialExpenditure.setCause(o.toString());
-                                                    continue;
+                                                    financialExpenditure.setEffectiveTime(o.toString());
+                                                }else {
+                                                    continue nullAmount;
                                                 }
                                             }
                                         }
+                                        financialExpenditure.setAmount(totalAmount);
+                                        financialExpenditure.setCause(note);
+                                        financialExpenditure.setBatchNo(pWorkOrderInfo.getId().toString());
+                                        financialExpenditure.setFinancialProcessNo(pWorkOrderInfo.getId().toString());
+                                        financialExpenditure.setApplyUser(realName);
+                                        financialExpenditure.setApplyUserId(pWorkOrderInfo.getCreator());
+                                        financialExpenditure.setProcessId(pWorkOrderInfo.getProcess());
+                                        financialExpenditure.setOrganId(organId);
+                                        financialExpenditureList.add(financialExpenditure);
                                     }
                                 }
                             }
-                            financialExpenditureList.add(financialExpenditure);
                         }
                     }else {
                         nullUser:
@@ -313,6 +343,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                             financialExpenditure.setApplyUser(realName);
                             financialExpenditure.setApplyUserId(pWorkOrderInfo.getCreator());
                             financialExpenditure.setProcessId(pWorkOrderInfo.getProcess());
+                            financialExpenditure.setEffectiveTime(DateUtil.format(now,DateUtil.ISO_YEAR_MONTH_FORMAT));
                             List<OaColumnDto> columns = oaInputDto.getColumns();
                             if (columns != null && columns.size() > 0) {
                                 for (OaColumnDto column : columns) {
@@ -355,8 +386,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                                             } else if (name.contains("分部")) {
                                                 Object o = hashMap.get(inputDto.getModel());
                                                 if (Objects.nonNull(o) && StringUtils.isNotEmpty(o.toString())) {
-                                                    int organId = Integer.parseInt(o.toString());
-                                                    Organization organization = organizationDao.get(organId);
+                                                    Organization organization = organizationDao.get(Integer.parseInt(o.toString()));
                                                     if (organization != null) {
                                                         financialExpenditure.setOrganId(organization.getId());
                                                         financialExpenditure.setOrganName(organization.getName());
@@ -485,6 +515,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                 financialExpenditure.setApplyUser(realName);
                 financialExpenditure.setApplyUserId(pWorkOrderInfo.getCreator());
                 financialExpenditure.setProcessId(pWorkOrderInfo.getProcess());
+                financialExpenditure.setEffectiveTime(DateUtil.format(now,DateUtil.ISO_YEAR_MONTH_FORMAT));
                 Integer organId = financialExpenditureDao.getDeptId(pWorkOrderInfo.getDeptId());
                 Organization organization = organizationDao.get(organId);
                 if(organization != null){
@@ -537,6 +568,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
             }
             JSONObject formData = JSONObject.parseObject(data);
             String formStructure = financialExpenditureDao.getTplInfo(tplInfoId);
+            Date now = new Date();
             OaFormStructureDto oaFormStructureDto = JSONObject.parseObject(formStructure, OaFormStructureDto.class);
             List<OaInputDto> oaInputDtos = oaFormStructureDto.getList();
             List<FinancialExpenditure> financialExpenditureList = new ArrayList<>();
@@ -551,6 +583,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                 List<HashMap> hashMaps = JSONObject.parseArray(formData.get(submitForm).toString(), HashMap.class);
                 nullUser: for (HashMap hashMap : hashMaps) {
                     FinancialExpenditure financialExpenditure = new FinancialExpenditure();
+                    financialExpenditure.setEffectiveTime(DateUtil.format(now,DateUtil.ISO_YEAR_MONTH_FORMAT));
                     List<OaColumnDto> columns = oaInputDto.getColumns();
                     if(columns != null && columns.size() > 0){
                         for (OaColumnDto column : columns) {

+ 168 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportNewServiceImpl.java

@@ -4,7 +4,9 @@ import com.ym.mec.biz.dal.dao.CourseScheduleDao;
 import com.ym.mec.biz.dal.dao.OperatingReportCloudDao;
 import com.ym.mec.biz.dal.dao.OperatingReportNewDao;
 import com.ym.mec.biz.dal.dao.VipGroupCategoryDao;
+import com.ym.mec.biz.dal.dto.HumanTypeDto;
 import com.ym.mec.biz.dal.dto.OASummaryExpensesDto;
+import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.OperatingReportNew;
 import com.ym.mec.biz.dal.entity.VipGroupCategory;
 import com.ym.mec.biz.service.OperatingReportNewService;
@@ -12,15 +14,13 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -45,9 +45,9 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
         return operatingReportNewDao;
     }
 
-	@Override
+
 	@Transactional(rollbackFor = Exception.class)
-	public void operatingReportMonth(Date month) {
+	public void operatingReportMonth1(Date month) {
 		String firstDayOfMonth = DateUtil.dateToString(DateUtil.getFirstDayOfMonth(month),DateUtil.ISO_EXPANDED_DATE_FORMAT);
 		String lastDayOfMonth = DateUtil.dateToString(DateUtil.getLastDayOfMonth(month),DateUtil.ISO_EXPANDED_DATE_FORMAT);
 		String currentMonth = DateUtil.dateToString(DateUtil.getLastDayOfMonth(month),DateUtil.ISO_YEAR_MONTH_FORMAT);
@@ -216,12 +216,173 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 		courseScheduleDao.makeSettlementReport(currentMonth);
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void operatingReportMonth(Date month) {
+		String firstDayOfMonth = DateUtil.dateToString(DateUtil.getFirstDayOfMonth(month),DateUtil.ISO_EXPANDED_DATE_FORMAT);
+		String lastDayOfMonth = DateUtil.dateToString(DateUtil.getLastDayOfMonth(month),DateUtil.ISO_EXPANDED_DATE_FORMAT);
+		String currentMonth = DateUtil.dateToString(DateUtil.getLastDayOfMonth(month),DateUtil.ISO_YEAR_MONTH_FORMAT);
+		String currentYear = DateUtil.dateToString(DateUtil.getLastDayOfMonth(month),DateUtil.ISO_YEAR_FORMAT);
+		operatingReportNewDao.deleteByMonth(currentMonth);
+		List<OperatingReportNew> operatingList = operatingReportNewDao.initOperatingReport(currentMonth);
+		//更新团体云教练计费时间()
+		operatingReportNewDao.initCloudStartTime(lastDayOfMonth);
+		//标记缴费项目为已结算(已排课,并且在上个月有关联的课程)
+		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))));
+		//服务收入
+		//导入的服务收入  (全部记录为课程收入)
+		Map<Integer, BigDecimal> collect24 = MapUtil.convertIntegerMap(operatingReportNewDao.sumImportServerOrderAmount(currentMonth));
+		//付费课程实际收入
+		Map<Integer, BigDecimal> collect2 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCourseAmount(firstDayOfMonth,lastDayOfMonth,currentYear));
+		//个人云教练当月收入
+		Map<Integer, BigDecimal> collect3 = MapUtil.convertIntegerMap(operatingReportNewDao.sumPersonalCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth));
+		//团体云教练费用
+		Map<Integer, BigDecimal> collect4 = MapUtil.convertIntegerMap(operatingReportNewDao.sumGroupCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth));
+		//团体云教练当月一次性结转
+		Map<Integer, BigDecimal> collect5 = MapUtil.convertIntegerMap(operatingReportNewDao.sumGroupAmount(currentMonth));
+
+		//乐保实收
+		Map<Integer, BigDecimal> collect26 = MapUtil.convertIntegerMap(operatingReportNewDao.sumMaintenanceAmount(currentMonth));
+		//业务退费
+		Map<Integer, BigDecimal> collect6 = MapUtil.convertIntegerMap(operatingReportNewDao.sumRefundAmount(currentMonth));
+		//变动费用
+		Map<Integer, BigDecimal> collect7 = MapUtil.convertIntegerMap(operatingReportNewDao.sumVariableCosts(currentMonth));
+		//固定费用
+		Map<Integer, BigDecimal> collect8 = MapUtil.convertIntegerMap(operatingReportNewDao.sumFixedCosts(currentMonth));
+
+
+		//云教练预收款
+		//个人云教练预收款
+		Map<Integer, BigDecimal> collect9 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCloudPreAmount(currentMonth,lastDayOfMonth));
+		//团体云教练预收款
+		Map<Integer, BigDecimal> collect10 = MapUtil.convertIntegerMap(operatingReportNewDao.sumGroupCloudPreAmount(currentMonth,lastDayOfMonth));
+		//未生效云教练预收款
+		Map<Integer, BigDecimal> collect25 = MapUtil.convertIntegerMap(operatingReportNewDao.sumWaitCloudPreAmount());
+		//已排课但是课程未开始的云教练预收
+		Map<Integer, BigDecimal> collect27 = MapUtil.convertIntegerMap(operatingReportNewDao.sumNotStartCloudPreAmount());
+		//获取categoryId
+		VipGroupCategory category = vipGroupCategoryDao.getTheory();
+		Map<Integer, BigDecimal> collect20 = MapUtil.convertIntegerMap(operatingReportNewDao.sumActivityUserMapperAmount(category.getId()));
+		//付费课程预收
+		Map<Integer, BigDecimal> collect12 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCoursePreAmount(lastDayOfMonth));
+		//付费团未排乐团课程预收(学员缴费)
+		Map<Integer, BigDecimal> collect21 = MapUtil.convertIntegerMap(operatingReportNewDao.sumMusicCourseAmount());
+		//排课资格预收
+		Map<Integer, BigDecimal> collect23 = MapUtil.convertIntegerMap(operatingReportNewDao.sumSubActivityUserMapperAmount());
+
+		//销售预收
+		Map<Integer, BigDecimal> collect13 = MapUtil.convertIntegerMap(operatingReportNewDao.sumSalePreAmount());
+
+		//其他预收
+		Map<Integer, BigDecimal> collect14 = MapUtil.convertIntegerMap(operatingReportNewDao.sumOtherPreAmount());
+
+		//预付款
+		//房租
+		Map<Integer, BigDecimal> collect19 = MapUtil.convertIntegerMap(operatingReportNewDao.sumPrepayments(currentMonth));
+
+		//应收
+		//欠费学员总金额
+		Map<Integer, BigDecimal> collect15 = MapUtil.convertIntegerMap(operatingReportNewDao.sumArrearsAmount());
+		//学校缴费订单待收款金额
+		Map<Integer, BigDecimal> collect16 = MapUtil.convertIntegerMap(operatingReportNewDao.sumSchoolAmount());
+
+		//应付(乐器押金)
+		List<Map<Integer, BigDecimal>> maps = operatingReportNewDao.sumMusicMargin();
+		Map<Integer, BigDecimal> collect17 = MapUtil.convertIntegerMap(maps);
+		//统计额外的经营报表数据
+		List<HumanTypeDto> humanTypeDtos = operatingReportNewDao.sumHumanCost(currentMonth);
+		Map<Integer, HumanTypeDto> humanMap = new HashMap<>();
+		if(CollectionUtils.isNotEmpty(humanTypeDtos)){
+			humanMap = humanTypeDtos.stream().collect(Collectors.groupingBy(e -> e.getOrganId(),Collectors.collectingAndThen(Collectors.toList(),v->v.get(0))));
+		}
+
+		for (OperatingReportNew operatingReportNew : operatingList) {
+			Integer organId = operatingReportNew.getOrganId();
+			OperatingReportNew reportNew = collect.get(organId);
+			if(Objects.nonNull(reportNew)){
+				operatingReportNew.setSaleAmount(reportNew.getSaleAmount());
+				operatingReportNew.setSaleCost(reportNew.getSaleCost());
+			}
+			HumanTypeDto humanTypeDto = humanMap.get(organId);
+			if(Objects.isNull(humanTypeDto)){
+				humanTypeDto = new HumanTypeDto();
+			}
+			//业务退费
+			operatingReportNew.setBusinessRefund(getAmount(collect6.get(organId)));
+			//服务收入
+			operatingReportNew.setServiceAmount(
+					getAmount(collect3.get(organId))
+					.add(getAmount(collect2.get(organId)))
+					.add(getAmount(collect4.get(organId)))
+					.add(getAmount(collect5.get(organId)))
+					.add(getAmount(collect24.get(organId)))
+					.add(getAmount(collect26.get(organId)))
+					.add(operatingReportNew.getCourseAmount()));
+			//收入合计
+			operatingReportNew.setTotalIncome(operatingReportNew.getSaleAmount().add(operatingReportNew.getServiceAmount()).subtract(operatingReportNew.getBusinessRefund()));
+			//内部结算
+			operatingReportNew.setInternalSettlement(humanTypeDto.getInternalSettlement());
+			//变动费用
+			operatingReportNew.setVariableCosts(getAmount(collect7.get(organId))
+					.add(humanTypeDto.getVariableCost())
+					.add(humanTypeDto.getNetworkClassroomCost())
+					.add(humanTypeDto.getStudentManagementFeeAdjustment()));
+			//固定费用
+			operatingReportNew.setFixedCosts(getAmount(collect8.get(organId)).add(humanTypeDto.getFixedCost()));
+			//成本合计
+			operatingReportNew.setTotalCost(operatingReportNew.getInternalSettlement().
+					add(operatingReportNew.getFixedCosts()).
+					add(operatingReportNew.getVariableCosts()).
+					add(operatingReportNew.getStudentManagementFee()));
+
+			operatingReportNew.setCloudPrepaidFee(getAmount(collect9.get(organId)).
+					add(getAmount(collect10.get(organId))).
+					add(getAmount(collect27.get(organId))).
+					add(getAmount(collect25.get(organId))));
+			operatingReportNew.setCoursePrepaidFee(getAmount(collect12.get(organId)).
+					add(getAmount(collect20.get(organId))).add(getAmount(collect21.get(organId))).add(getAmount(collect23.get(organId))));
+			operatingReportNew.setSalePrepaidFee(getAmount(collect13.get(organId)));
+			operatingReportNew.setOtherPrepaidFee(getAmount(collect14.get(organId)));
+			operatingReportNew.setPrepaidFee(operatingReportNew.getCloudPrepaidFee().
+					add(operatingReportNew.getSalePrepaidFee()).
+					add(operatingReportNew.getOtherPrepaidFee()).
+					add(operatingReportNew.getCoursePrepaidFee()));
+
+			operatingReportNew.setReceivables(getAmount(collect15.get(organId)).add(getAmount(collect16.get(organId))));
+			operatingReportNew.setPayable(getAmount(collect17.get(organId)));
+
+			operatingReportNew.setPrepayments(getAmount(collect19.get(organId)));
+
+			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));
+		OperatingReportNew totalSellAmount = operatingReportNewDao.sumTotalSellAmount(currentMonth);
+		operatingReportNew.setSaleAmount(totalSellAmount.getSaleAmount());
+		operatingReportNew.setSaleCost(totalSellAmount.getSaleCost());
+		operatingReportNewDao.batchInsert(operatingList);
+		//将本月乐团课标记为已结算
+//		courseScheduleDao.makeSettlementReport(currentMonth);
+	}
+
     @Override
     public List<OASummaryExpensesDto> queryOASummaryExpenses(String month) {
 		return operatingReportNewDao.queryOASummaryExpenses(month);
     }
 
-    private BigDecimal getAmount(BigDecimal amount){
+	@Override
+	public List<FinancialExpenditure> queryOASummaryExpensesDetail(String month) {
+		return operatingReportNewDao.queryOASummaryExpensesDetail(month);
+	}
+
+	private BigDecimal getAmount(BigDecimal amount){
 		if(amount == null){
 			amount = BigDecimal.ZERO;
 		}

+ 8 - 4
mec-biz/src/main/resources/config/mybatis/FinancialExpenditureMapper.xml

@@ -14,11 +14,14 @@
         <result column="organ_id_" property="organId"/>
         <result column="cooperation_organ_id_" property="cooperationOrganId"/>
         <result column="apply_user_" property="applyUser"/>
+        <result column="student_id_" property="studentId"/>
         <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="fee_project_" property="feeProject" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="amount_" property="amount"/>
         <result column="item_detail_" property="itemDetail"/>
         <result column="payment_time_" property="paymentTime"/>
+        <result column="effective_time_" property="effectiveTime"/>
+        <result column="current_amount_" property="currentAmount"/>
         <result column="del_flag_" property="delFlag"/>
         <result column="cause_" property="cause"/>
         <result column="create_time_" property="createTime"/>
@@ -47,26 +50,27 @@
             keyProperty="id">
         INSERT INTO financial_expenditure (batch_no_, financial_process_no_, dingtalk_process_no_,
                                            process_id_,organ_id_, cooperation_organ_id_, apply_user_, apply_user_id_, amount_, item_detail_,
-                                           payment_time_, cause_, create_time_, update_time_, fee_project_, type_, tenant_id_)
+                                           payment_time_, cause_, create_time_, update_time_, fee_project_, type_, tenant_id_,student_id_,effective_time_)
         VALUES (#{batchNo}, #{financialProcessNo}, #{dingtalkProcessNo},#{processId}, #{organId}, #{cooperationOrganId},
                 #{applyUser}, #{applyUserId}, #{amount},
                 #{itemDetail}, #{paymentTime}, #{cause}, now(), now(),
                 #{feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{tenantId})
+                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{tenantId},#{studentId},#{effectiveTime})
     </insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure" useGeneratedKeys="true"
             keyColumn="id"
             keyProperty="id">
         INSERT INTO financial_expenditure (batch_no_,financial_process_no_,dingtalk_process_no_,
-        process_id_,organ_id_,cooperation_organ_id_,apply_user_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_,fee_project_,type_,tenant_id_)
+        process_id_,organ_id_,cooperation_organ_id_,apply_user_,amount_,item_detail_,payment_time_,
+                                           cause_,create_time_,update_time_,fee_project_,type_,tenant_id_,student_id_,effective_time_)
         VALUES
         <foreach collection="financialExpenditures" item="item" separator=",">
             (#{item.batchNo},#{item.financialProcessNo},#{item.dingtalkProcessNo},#{item.processId},#{item.organId},
             #{item.cooperationOrganId},#{item.applyUser},#{item.amount},
             #{item.itemDetail},#{item.paymentTime},#{item.cause},now(),now(),
             #{item.feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-            #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.tenantId})
+            #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.tenantId},#{item.studentId},#{effectiveTime})
         </foreach>
     </insert>
 

+ 34 - 0
mec-biz/src/main/resources/config/mybatis/OperatingReportNewMapper.xml

@@ -384,4 +384,38 @@
 		GROUP BY
 			o.id_
 	</select>
+	<resultMap type="com.ym.mec.biz.dal.entity.FinancialExpenditure" id="FinancialExpenditure">
+		<result column="name_" property="organName"/>
+		<result column="batch_no_" property="batchNo"/>
+		<result column="cooperation_organ_name_" property="cooperationOrganName"/>
+		<result column="apply_user_" property="applyUser"/>
+		<result column="student_id_" property="studentId"/>
+		<result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+		<result column="fee_project_" property="feeProject" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+		<result column="amount_" property="amount"/>
+		<result column="payment_time_" property="paymentTime"/>
+		<result column="current_amount_" property="currentAmount"/>
+		<result column="cause_" property="cause"/>
+	</resultMap>
+	<select id="queryOASummaryExpensesDetail" resultMap="FinancialExpenditure">
+		select o.name_,fe.batch_no_,co.name_ cooperationName,fe.apply_user_,
+			   fe.fee_project_,fe.type_,fe.amount_,fe.payment_time_,fe.cause_,fe.current_amount_,fe.student_id_
+		from financial_expenditure fe
+				 left join organization o ON o.id_ = fe.organ_id_
+				 left join cooperation_organ co ON co.id_ = fe.cooperation_organ_id_
+		where fe.process_id_ = 28 AND fe.del_flag_ = 0 AND DATE_FORMAT(fe.create_time_, '%Y-%m') = #{month}
+		order by fe.id_ DESC
+	</select>
+	<select id="sumHumanCost" resultType="com.ym.mec.biz.dal.dto.HumanTypeDto">
+		select
+			organ_id_,
+			SUM(CASE WHEN human_cost_type_ = 'FIXED' THEN amount_ ELSE 0 END) AS fixedCost,
+			SUM(CASE WHEN human_cost_type_ = 'VARIABLE' THEN amount_ ELSE 0 END) AS variableCost,
+			SUM(CASE WHEN human_cost_type_ = 'NETWORK_CLASSROOM' THEN amount_ ELSE 0 END) AS networkClassroomCost,
+			SUM(CASE WHEN human_cost_type_ = 'CLOUD_COACHING_COST' THEN amount_ ELSE 0 END) AS cloudCoachingCost,
+			SUM(CASE WHEN human_cost_type_ = 'INTERNAL_SETTLEMENT' THEN amount_ ELSE 0 END) AS internalSettlement,
+			SUM(CASE WHEN human_cost_type_ = 'STUDENT_MANAGEMENT_FEE_ADJUSTMENT' THEN amount_ ELSE 0 END) AS studentManagementFeeAdjustment
+		from human_cost
+		where month_ = #{month} group by organ_id_
+	</select>
 </mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -421,6 +421,9 @@
             <if test="orderEndDate != null">
                 AND DATE_FORMAT(spo.create_time_,'%Y-%m-%d') &lt;= #{orderEndDate}
             </if>
+            <if test="month != null and month != ''">
+                AND DATE_FORMAT(spo.create_time_,'%Y-%m') = #{month} AND spo.status_ = 'SUCCESS'
+            </if>
             <if test="notGroupType != null and notGroupType != ''">
                 AND spo.group_type_ != #{notGroupType}
             </if>

+ 10 - 2
mec-web/src/main/resources/exportColumnMapper.ini

@@ -299,8 +299,8 @@ headColumns = ["分部", "预计回访人数", "实际回访人数", "覆盖率"
 fieldColumns = ["organName","expectVisitNum","visitNum","coverRate"]
 
 [经营报表导出]
-headColumns = ["月份","分部", "销售收入", "服务收入", "课程收入", "云教练收入","乐保收入", "业务退费", "收入合计", "销售成本", "固定费用", "变动费用", "内部结算", "成本费用合计", "准可自由支配利润", "预收账款", "云教练预收", "课程预收", "商品预收", "其他预收", "预付账款", "应收账款", "应付账款"]
-fieldColumns = ["month","organName","saleAmount","serviceAmount","courseAmount","cloudAmount","maintenanceAmount","businessRefund","totalIncome","saleCost","fixedCosts","variableCosts","internalSettlement","totalCost","quasiDiscretionaryProfit","prepaidFee","cloudPrepaidFee","coursePrepaidFee","salePrepaidFee","otherPrepaidFee","prepayments","receivables","payable"]
+headColumns = ["月份","分部", "销售收入", "服务收入""业务退费", "收入合计", "销售成本", "固定费用", "变动费用", "内部结算", "成本费用合计", "准可自由支配利润", "预收账款","预付账款", "应收账款", "应付账款"]
+fieldColumns = ["month","organName","saleAmount","serviceAmount","businessRefund","totalIncome","saleCost","fixedCosts","variableCosts","internalSettlement","totalCost","quasiDiscretionaryProfit","prepaidFee","prepayments","receivables","payable"]
 
 [实际课耗导出]
 headColumns = ["分部", "在读人数", "大于等于5节", "4节","3节","2节","1节","0节"]
@@ -345,3 +345,11 @@ fieldColumns = ["organName", "teacherName", "subjectName", "courseTime", "playTi
 [oa费用汇总]
 headColumns = ["城市","固定人力成本","房屋","办公","水电物业","变动人力成本","差旅","外部服务","福利","活动","交通","考级","临时场地租赁","通讯","邮递运输","招待费","其他","学员管理费","云教练成本","网络教室成本","业务退费","内部结算"]
 fieldColumns = ["organName", "fixedHumanCost", "house", "office", "mainsProperty","variableHumanCost", "travel","services", "welfare", "activities", "traffic", "certificates", "instrument","communications", "postalTransport", "hospitality", "other", "studentManagementFeeAdjustment","cloudCoachingCost", "network", "refund", "internalSettlement"]
+
+[oa费用明细]
+headColumns = ["城市","钉钉流程编号","费用归属学校","申请人","费用项目","费用类型","付款金额","付款时间","明细","学员编号","当期金额"]
+fieldColumns = ["organName","batchNo","cooperationOrganName","applyUser","feeProject","type","amount","paymentTime","cause","studentId","currentAmount"]
+
+[经营报表收入汇总]
+headColumns = ["城市","学生指导费课耗收入","学校课程采买课耗收入","考级","维修费用","乐保费用","其他服务收入","云教练收入","团购乐器","团购教辅","大件乐器","其他","服务收入","销售收入"]
+fieldColumns = ["organName","studentGuidanceIncome","coursePurchaseIncome","examIncome","maintenanceCost","instrumentInsuranceCost","otherServiceIncome","cloudCoachIncome","groupPurchaseInstruments","groupPurchaseTeachingAids","largeInstruments","serviceIncome","salesIncome"]