瀏覽代碼

经营报表

zouxuan 2 年之前
父節點
當前提交
7adccdfe2d

+ 17 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/OperatingReportCloudDao.java

@@ -11,12 +11,26 @@ public interface OperatingReportCloudDao extends BaseDAO<Integer, OperatingRepor
     void batchInsert(@Param("operatingReportClouds") List<OperatingReportCloud> operatingReportClouds);
 
     /**
-    * @description: 根据缴费项目编号和是否当月结算查询
+    * @description: 根据缴费项目编号查询
      * @param calenderId
-     * @param monthFlag
     * @return com.ym.mec.biz.dal.entity.OperatingReportCloud
     * @author zx
     * @date 2022/9/7 09:45
     */
-    OperatingReportCloud findByCalenderId(@Param("calenderId") Long calenderId, @Param("monthFlag") Boolean monthFlag);
+    OperatingReportCloud findByCalenderId(@Param("calenderId") Long calenderId);
+
+    //标记经营报表已结算
+    void settlementCalender(@Param("month") String month);
+
+    //当月的经营报表标记为已结算
+    void settlementCurrentCalender(@Param("month") String month);
+
+    /**
+    * @description: 获取当月结算的缴费项目
+     * @param calenderId
+    * @return com.ym.mec.biz.dal.entity.OperatingReportCloud
+    * @author zx
+    * @date 2022/9/13 15:47
+    */
+    OperatingReportCloud findByCurrentCalenderId(@Param("calenderId") Long calenderId);
 }

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

@@ -10,9 +10,9 @@ import java.util.Map;
 
 public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportNew> {
 
-    List<OperatingReportNew> initOperatingReport(String currentMonth);
+    List<OperatingReportNew> initOperatingReport(String month);
 
-    //获取销售收入和销售成本
+    //获取销售收入和销售成本(销售成本扣除已退)
     List<OperatingReportNew> sumSellAmount(String month);
 
     //云教练赠送课程服务收入
@@ -67,7 +67,7 @@ public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportN
     void initCloudStartTime(@Param("lastDay") String lastDay);
 
     //汇总乐器押金
-    List<Map<Integer,BigDecimal>> sumMusicMagrin();
+    List<Map<Integer,BigDecimal>> sumMusicMargin();
 
     void batchInsert(@Param("operatingList") List<OperatingReportNew> operatingList);
 
@@ -76,4 +76,7 @@ public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportN
     List<Map<Integer,BigDecimal>> sumInternalSettlement(@Param("month") String month);
 
     List<Map<Integer,BigDecimal>> sumPrepayments(@Param("month") String month);
+
+    //云教练赠送排课资格预收
+    List<Map<Integer,BigDecimal>> sumActivityUserMapperAmount(@Param("categoryId") Integer categoryId);
 }

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupCategoryDao.java

@@ -17,4 +17,6 @@ public interface VipGroupCategoryDao extends BaseDAO<Integer, VipGroupCategory>
     List<ConditionDto> findConditionCategorys();
 
     List<VipGroupCategory> findByIds(@Param("categoryIds") Set<Integer> categoryIds);
+
+    VipGroupCategory getTheory();
 }

+ 0 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/OperatingReportNew.java

@@ -31,9 +31,6 @@ public class OperatingReportNew {
     @ApiModelProperty(value="云教练收入")
     private BigDecimal cloudAmount = BigDecimal.ZERO;
 
-    @ApiModelProperty(value="其他收入")
-    private BigDecimal otherAmount = BigDecimal.ZERO;
-
     //当月退费列表总金额(当月退费列表已退费总金额)
     @ApiModelProperty(value="业务退费")
     private BigDecimal businessRefund = BigDecimal.ZERO;
@@ -191,14 +188,6 @@ public class OperatingReportNew {
         this.cloudAmount = cloudAmount;
     }
 
-    public BigDecimal getOtherAmount() {
-        return otherAmount;
-    }
-
-    public void setOtherAmount(BigDecimal otherAmount) {
-        this.otherAmount = otherAmount;
-    }
-
     public BigDecimal getBusinessRefund() {
         return businessRefund;
     }

+ 42 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/OperatingReportNewQueryInfo.java

@@ -0,0 +1,42 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+public class OperatingReportNewQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "分部id", required = false)
+    private String organId;
+
+    @ApiModelProperty(value = "年月", required = false)
+    private String startTime;
+
+    @ApiModelProperty(value = "年月", required = false)
+    private String endTime;
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+}

+ 14 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportCloudServiceImpl.java

@@ -65,7 +65,7 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 		}
 		//找出非当月结算的缴费项目预算,如果为空则创建。如果已结算则创建当月结转的云教练预收、否则修改云教练预算
 		//获取云教练信息
-		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calender.getId(),false);
+		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calender.getId());
 		if(Objects.isNull(reportCloud)){
 			reportCloud = new OperatingReportCloud();
 			reportCloud.setCalenderId(calender.getId());
@@ -74,12 +74,18 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 			operatingReportCloudDao.insert(reportCloud);
 		}else {
 			if(reportCloud.getSettlementFlag()){
-				OperatingReportCloud monthReportCloud = new OperatingReportCloud();
-				reportCloud.setCalenderId(calender.getId());
-				reportCloud.setCloudPrice(amount);
-				reportCloud.setOrganId(calender.getOrganId());
-				reportCloud.setMonthFlag(true);
-				operatingReportCloudDao.insert(monthReportCloud);
+				OperatingReportCloud currentReportCloud = operatingReportCloudDao.findByCurrentCalenderId(calender.getId());
+				if(Objects.isNull(currentReportCloud)){
+					currentReportCloud = new OperatingReportCloud();
+					currentReportCloud.setCalenderId(calender.getId());
+					currentReportCloud.setCloudPrice(amount);
+					currentReportCloud.setOrganId(calender.getOrganId());
+					currentReportCloud.setMonthFlag(true);
+					operatingReportCloudDao.insert(currentReportCloud);
+				}else {
+					currentReportCloud.setCloudPrice(currentReportCloud.getCloudPrice().add(amount));
+					operatingReportCloudDao.update(currentReportCloud);
+				}
 			}else {
 				reportCloud.setCloudPrice(reportCloud.getCloudPrice().add(amount));
 				reportCloud.setUpdateTime(new Date());
@@ -91,7 +97,7 @@ public class OperatingReportCloudServiceImpl extends BaseServiceImpl<Integer, Op
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateSet(Long calenderId,List<Long> scheduleIdList) {
-		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calenderId,false);
+		OperatingReportCloud reportCloud = operatingReportCloudDao.findByCalenderId(calenderId);
 		if(Objects.isNull(reportCloud)){
 			throw new BizException("操作失败,请联系管理员");
 		}

+ 43 - 26
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportNewServiceImpl.java

@@ -1,10 +1,9 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.OperatingReportCloudDao;
 import com.ym.mec.biz.dal.dao.OperatingReportNewDao;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.OperatingReport;
-import com.ym.mec.biz.dal.entity.OperatingReportNew;
+import com.ym.mec.biz.dal.dao.VipGroupCategoryDao;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.service.OperatingReportNewService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -26,6 +25,10 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 	
 	@Autowired
 	private OperatingReportNewDao operatingReportNewDao;
+	@Autowired
+	private OperatingReportCloudDao operatingReportCloudDao;
+	@Autowired
+	private VipGroupCategoryDao vipGroupCategoryDao;
 
 	@Override
 	public BaseDAO<Integer, OperatingReportNew> getDAO() {
@@ -47,58 +50,67 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 		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> collect1 = MapUtil.mapListToMap(operatingReportNewDao.sumCloudCourseAmount(firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect1 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCloudCourseAmount(firstDayOfMonth,lastDayOfMonth));
 		//付费课程实际收入
-		Map<Integer, BigDecimal> collect2 = MapUtil.mapListToMap(operatingReportNewDao.sumCourseAmount(firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect2 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCourseAmount(firstDayOfMonth,lastDayOfMonth));
 		//个人云教练当月收入
-		Map<Integer, BigDecimal> collect3 = MapUtil.mapListToMap(operatingReportNewDao.sumPersonalCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect3 = MapUtil.convertIntegerMap(operatingReportNewDao.sumPersonalCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth));
 		//团体云教练费用
-		Map<Integer, BigDecimal> collect4 = MapUtil.mapListToMap(operatingReportNewDao.sumGroupCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect4 = MapUtil.convertIntegerMap(operatingReportNewDao.sumGroupCloudAmount(currentMonth,firstDayOfMonth,lastDayOfMonth));
 		//团体云教练当月一次性结转
-		Map<Integer, BigDecimal> collect5 = MapUtil.mapListToMap(operatingReportNewDao.sumGroupAmount(),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect5 = MapUtil.convertIntegerMap(operatingReportNewDao.sumGroupAmount());
 
 		//业务退费
-		Map<Integer, BigDecimal> collect6 = MapUtil.mapListToMap(operatingReportNewDao.sumRefundAmount(currentMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect6 = MapUtil.convertIntegerMap(operatingReportNewDao.sumRefundAmount(currentMonth));
 		//变动费用
-		Map<Integer, BigDecimal> collect7 = MapUtil.mapListToMap(operatingReportNewDao.sumVariableCosts(currentMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect7 = MapUtil.convertIntegerMap(operatingReportNewDao.sumVariableCosts(currentMonth));
 		//固定费用
-		Map<Integer, BigDecimal> collect8 = MapUtil.mapListToMap(operatingReportNewDao.sumFixedCosts(currentMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect8 = MapUtil.convertIntegerMap(operatingReportNewDao.sumFixedCosts(currentMonth));
 		//内部结算
-		Map<Integer, BigDecimal> collect18 = MapUtil.mapListToMap(operatingReportNewDao.sumInternalSettlement(currentMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect18 = MapUtil.convertIntegerMap(operatingReportNewDao.sumInternalSettlement(currentMonth));
 
 		//云教练预收款
 		//个人云教练预收款
-		Map<Integer, BigDecimal> collect9 = MapUtil.mapListToMap(operatingReportNewDao.sumCloudPreAmount(currentMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect9 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCloudPreAmount(currentMonth,lastDayOfMonth));
 		//团体云教练预收款
-		Map<Integer, BigDecimal> collect10 = MapUtil.mapListToMap(operatingReportNewDao.sumGroupCloudPreAmount(currentMonth,lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect10 = MapUtil.convertIntegerMap(operatingReportNewDao.sumGroupCloudPreAmount(currentMonth,lastDayOfMonth));
 
 		//课程预收
 		//云教练赠课预收
-		Map<Integer, BigDecimal> collect11 = MapUtil.mapListToMap(operatingReportNewDao.sumCloudCoursePreAmount(lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect11 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCloudCoursePreAmount(lastDayOfMonth));
+		//云教练赠送,未排课排课资格预收
+		//获取categoryId
+		VipGroupCategory category = vipGroupCategoryDao.getTheory();
+		Map<Integer, BigDecimal> collect20 = MapUtil.convertIntegerMap(operatingReportNewDao.sumActivityUserMapperAmount(category.getId()));
 		//付费课程预收
-		Map<Integer, BigDecimal> collect12 = MapUtil.mapListToMap(operatingReportNewDao.sumCoursePreAmount(lastDayOfMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect12 = MapUtil.convertIntegerMap(operatingReportNewDao.sumCoursePreAmount(lastDayOfMonth));
 		//销售预收
-		Map<Integer, BigDecimal> collect13 = MapUtil.mapListToMap(operatingReportNewDao.sumSalePreAmount(),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect13 = MapUtil.convertIntegerMap(operatingReportNewDao.sumSalePreAmount());
 		//其他预收
-		Map<Integer, BigDecimal> collect14 = MapUtil.mapListToMap(operatingReportNewDao.sumOtherPreAmount(),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect14 = MapUtil.convertIntegerMap(operatingReportNewDao.sumOtherPreAmount());
 
 		//预付款
 		//房租
-		Map<Integer, BigDecimal> collect19 = MapUtil.mapListToMap(operatingReportNewDao.sumPrepayments(currentMonth),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect19 = MapUtil.convertIntegerMap(operatingReportNewDao.sumPrepayments(currentMonth));
 
 		//应收
 		//欠费学员总金额
-		Map<Integer, BigDecimal> collect15 = MapUtil.mapListToMap(operatingReportNewDao.sumArrearsAmount(),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect15 = MapUtil.convertIntegerMap(operatingReportNewDao.sumArrearsAmount());
 		//学校缴费订单待收款金额
-		Map<Integer, BigDecimal> collect16 = MapUtil.mapListToMap(operatingReportNewDao.sumSchoolAmount(),Integer.class,BigDecimal.class);
+		Map<Integer, BigDecimal> collect16 = MapUtil.convertIntegerMap(operatingReportNewDao.sumSchoolAmount());
 
 		//应付(乐器押金)
-		Map<Integer, BigDecimal> collect17 = MapUtil.mapListToMap(operatingReportNewDao.sumMusicMagrin(),Integer.class,BigDecimal.class);
+		List<Map<Integer, BigDecimal>> maps = operatingReportNewDao.sumMusicMargin();
+		Map<Integer, BigDecimal> collect17 = MapUtil.convertIntegerMap(maps);
 
 		for (OperatingReportNew operatingReportNew : operatingList) {
 			Integer organId = operatingReportNew.getOrganId();
@@ -116,13 +128,16 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 			operatingReportNew.setCloudAmount(operatingReportNew.getCloudAmount().add(getAmount(collect5.get(organId))));
 
 			operatingReportNew.setServiceAmount(operatingReportNew.getCloudAmount().add(operatingReportNew.getCourseAmount()));
+			operatingReportNew.setTotalIncome(operatingReportNew.getSaleAmount().add(operatingReportNew.getServiceAmount()));
 
 			operatingReportNew.setBusinessRefund(getAmount(collect6.get(organId)));
 			operatingReportNew.setFixedCosts(getAmount(collect7.get(organId)));
 			operatingReportNew.setVariableCosts(getAmount(collect8.get(organId)));
+			operatingReportNew.setTotalCost(operatingReportNew.getBusinessRefund().
+					add(operatingReportNew.getFixedCosts()).add(operatingReportNew.getVariableCosts()));
 
-			operatingReportNew.setCloudPrepaidFee(getAmount(collect9.get(organId)).add(collect10.get(organId)));
-			operatingReportNew.setCoursePrepaidFee(getAmount(collect11.get(organId)).add(collect12.get(organId)));
+			operatingReportNew.setCloudPrepaidFee(getAmount(collect9.get(organId)).add(getAmount(collect10.get(organId))));
+			operatingReportNew.setCoursePrepaidFee(getAmount(collect11.get(organId)).add(getAmount(collect12.get(organId))).add(getAmount(collect20.get(organId))));
 			operatingReportNew.setSalePrepaidFee(getAmount(collect13.get(organId)));
 			operatingReportNew.setOtherPrepaidFee(getAmount(collect14.get(organId)));
 			operatingReportNew.setPrepaidFee(operatingReportNew.getCloudPrepaidFee().
@@ -130,11 +145,13 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 					add(operatingReportNew.getOtherPrepaidFee()).
 					add(operatingReportNew.getCoursePrepaidFee()));
 
-			operatingReportNew.setReceivables(getAmount(collect15.get(organId)).add(collect16.get(organId)));
+			operatingReportNew.setReceivables(getAmount(collect15.get(organId)).add(getAmount(collect16.get(organId))));
 			operatingReportNew.setPayable(getAmount(collect17.get(organId)));
 
 			operatingReportNew.setInternalSettlement(getAmount(collect18.get(organId)));
 			operatingReportNew.setPrepayments(getAmount(collect19.get(organId)));
+
+			operatingReportNew.setQuasiDiscretionaryProfit(operatingReportNew.getTotalIncome().subtract(operatingReportNew.getTotalCost()));
 		}
 		operatingReportNewDao.batchInsert(operatingList);
 	}

+ 16 - 2
mec-biz/src/main/resources/config/mybatis/OperatingReportCloudMapper.xml

@@ -65,7 +65,18 @@
 		</if>
 		</set> WHERE id_ = #{id}
 	</update>
-	
+    <update id="settlementCalender">
+		UPDATE operating_report_cloud orc
+		LEFT JOIN cloud_teacher_free_course ctf ON ctf.calender_id_ = orc.calender_id_
+		SET orc.settlement_flag_ = 1
+		WHERE orc.month_flag_ = 0 AND orc.settlement_flag_ = 0 AND DATE_FORMAT(orc.start_date_,'%Y-%m') = #{month};
+	</update>
+	<update id="settlementCurrentCalender">
+		UPDATE operating_report_cloud orc
+		SET orc.settlement_flag_ = 1
+		WHERE orc.month_flag_ = 1 AND orc.settlement_flag_ = 0 AND DATE_FORMAT(orc.create_time_,'%Y-%m') = #{month};
+	</update>
+
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM operating_report_cloud WHERE id_ = #{id} 
@@ -81,6 +92,9 @@
 		SELECT COUNT(*) FROM operating_report_cloud
 	</select>
 	<select id="findByCalenderId" resultMap="OperatingReportCloud">
-		SELECT * FROM operating_report_cloud WHERE calender_id_ = #{calenderId} AND month_flag_ = #{monthFlag} LIMIT 1
+		SELECT * FROM operating_report_cloud WHERE calender_id_ = #{calenderId} AND month_flag_ = 0 LIMIT 1
+	</select>
+	<select id="findByCurrentCalenderId" resultMap="OperatingReportCloud">
+		SELECT * FROM operating_report_cloud WHERE calender_id_ = #{calenderId} AND month_flag_ = 1 AND DATE_FORMAT(create_time_,'%Y-%m') = DATE_FORMAT(NOW(),'%Y-%m') LIMIT 1
 	</select>
 </mapper>

+ 49 - 12
mec-biz/src/main/resources/config/mybatis/OperatingReportNewMapper.xml

@@ -13,6 +13,8 @@
 		<result column="organ_id_" property="organId" />
 		<result column="sale_amount_" property="saleAmount" />
 		<result column="service_amount_" property="serviceAmount" />
+		<result column="cloud_amount_" property="cloudAmount" />
+		<result column="course_amount_" property="courseAmount" />
 		<result column="business_refund_" property="businessRefund" />
 		<result column="total_income_" property="totalIncome" />
 		<result column="sale_cost_" property="saleCost" />
@@ -22,6 +24,10 @@
 		<result column="total_cost_" property="totalCost" />
 		<result column="quasi_discretionary_profit_" property="quasiDiscretionaryProfit" />
 		<result column="prepaid_fee_" property="prepaidFee" />
+		<result column="cloud_prepaid_fee_" property="cloudPrepaidFee" />
+		<result column="course_prepaid_fee_" property="coursePrepaidFee" />
+		<result column="sale_prepaid_fee_" property="salePrepaidFee" />
+		<result column="other_prepaid_fee_" property="otherPrepaidFee" />
 		<result column="prepayments_" property="prepayments" />
 		<result column="receivables_" property="receivables" />
 		<result column="payable_" property="payable" />
@@ -40,18 +46,25 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OperatingReportNew" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO operating_report_new (id_,principal_,organ_name_,sale_amount_,service_amount_,business_refund_,total_income_,sale_cost_,fixed_costs_,variable_costs_,internal_settlement_,total_cost_,quasi_discretionary_profit_,prepaid_fee_,prepayments_,receivables_,payable_,month_)
-		VALUES(#{id},#{principal},#{organName},#{saleAmount},#{serviceAmount},#{businessRefund},#{totalIncome},#{saleCost},#{fixedCosts},#{variableCosts},#{internalSettlement},#{totalCost},#{quasiDiscretionaryProfit},#{prepaidFee},#{prepayments},#{receivables},#{payable},#{month})
+		INSERT INTO operating_report_new (id_,principal_,organ_id_,organ_name_,sale_amount_,service_amount_,cloud_amount_,course_amount_,
+		                                  business_refund_,total_income_,sale_cost_,fixed_costs_,variable_costs_,internal_settlement_,
+		                                  total_cost_,quasi_discretionary_profit_,prepaid_fee_,cloud_prepaid_fee_,course_prepaid_fee_,sale_prepaid_fee_,other_prepaid_fee_
+		                                  ,prepayments_,receivables_,payable_,month_)
+		VALUES(#{id},#{principal},#{organId},#{organName},#{saleAmount},#{serviceAmount},#{cloudAmount},#{courseAmount},
+		       #{businessRefund},#{totalIncome},#{saleCost},#{fixedCosts},#{variableCosts},#{internalSettlement},
+		       #{totalCost},#{quasiDiscretionaryProfit},#{prepaidFee},#{cloudPrepaidFee},#{coursePrepaidFee},#{salePrepaidFee},#{otherPrepaidFee},
+		       #{prepayments},#{receivables},#{payable},#{month})
 	</insert>
 	<insert id="batchInsert">
-		INSERT INTO operating_report_new (principal_,organ_name_,sale_amount_,service_amount_,business_refund_,total_income_,sale_cost_,
+		INSERT INTO operating_report_new (principal_,organ_id_,organ_name_,sale_amount_,service_amount_,cloud_amount_,course_amount_,business_refund_,total_income_,sale_cost_,
 		                                  fixed_costs_,variable_costs_,internal_settlement_,total_cost_,quasi_discretionary_profit_,
-		                                  prepaid_fee_,prepayments_,receivables_,payable_,month_)
+		                                  prepaid_fee_,cloud_prepaid_fee_,course_prepaid_fee_,sale_prepaid_fee_,other_prepaid_fee_,prepayments_,receivables_,payable_,month_)
 		VALUES
 		<foreach collection="operatingList" item="bean" separator=",">
-			(#{bean.principal},#{bean.organName},#{bean.saleAmount},#{bean.serviceAmount},#{bean.businessRefund},#{bean.totalIncome},
+			(#{bean.principal},#{bean.organId},#{bean.organName},#{bean.saleAmount},#{bean.serviceAmount},#{bean.cloudAmount},#{bean.courseAmount},#{bean.businessRefund},#{bean.totalIncome},
 			 #{bean.saleCost},#{bean.fixedCosts},#{bean.variableCosts},#{bean.internalSettlement},#{bean.totalCost},#{bean.quasiDiscretionaryProfit},
-			 #{bean.prepaidFee},#{bean.prepayments},#{bean.receivables},#{bean.payable},#{bean.month})
+			 #{bean.prepaidFee},#{bean.cloudPrepaidFee},#{bean.coursePrepaidFee},#{bean.salePrepaidFee},#{bean.otherPrepaidFee},
+			 #{bean.prepayments},#{bean.receivables},#{bean.payable},#{bean.month})
 		</foreach>
 	</insert>
 
@@ -137,25 +150,39 @@
 	<delete id="deleteByMonth">
 		DELETE FROM operating_report_new WHERE month_ = #{month}
 	</delete>
+	<sql id="queryPageSql">
+		<where>
+			<if test="organId != null and organId != ''">
+				AND FIND_IN_SET(organ_id_,#{organId})
+			</if>
+			<if test="startTime != null and startTime != ''">
+				AND month_ BETWEEN #{startTime} AND #{endTime}
+			</if>
+		</where>
+	</sql>
 
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="OperatingReportNew" parameterType="map">
-		SELECT * FROM operating_report_new ORDER BY id_ <include refid="global.limit"/>
+		SELECT * FROM operating_report_new
+		<include refid="queryPageSql"/>
+		ORDER BY id_
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM operating_report_new
+		SELECT COUNT(id_) FROM operating_report_new
+		<include refid="queryPageSql"/>
 	</select>
 	<select id="initOperatingReport" resultMap="OperatingReportNew">
-		select id_ organ_id_,name_ organ_name_ from organization where del_flag_ = 0 and tenant_id_ = 1
+		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(so.sell_cost_) sale_cost_ from sell_order so
+		select so.organ_id_,SUM(so.actual_amount_) sale_amount_,SUM(CASE WHEN so.status_ = 1 THEN 0 ELSE so.sell_cost_ 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'
 		LEFT JOIN organization o ON o.id_ = so.organ_id_
-		where (mg.musical_instruments_provide_status_ = 1 AND mg.musical_instruments_provide_date_ = #{month}) OR (DATE_FORMAT(so.create_ime_,'%Y-%m') = #{month} AND (mg.musical_instruments_provide_status_ IS NULL OR mg.musical_instruments_provide_status_ = 1))
+		where (mg.musical_instruments_provide_status_ = 1 AND mg.musical_instruments_provide_time_ = #{month}) OR (DATE_FORMAT(so.create_ime_,'%Y-%m') = #{month} AND (mg.musical_instruments_provide_status_ IS NULL OR mg.musical_instruments_provide_status_ = 1))
 		group by so.organ_id_
 	</select>
 	<select id="sumCloudCourseAmount" resultType="java.util.Map">
@@ -248,7 +275,7 @@
 		where spro.calender_id_ IS NOT NULL AND spro.audit_status_ = 'PASS' AND mgpc.id_ = spro.calender_id_
 		group by mgpc.organ_id_
 	</select>
-	<select id="sumMusicMagrin" resultType="java.util.Map">
+	<select id="sumMusicMargin" resultType="java.util.Map">
 		select mm.organ_id_ 'key',SUM(mm.balance_) 'value' from music_margin mm where mm.refund_flag_ = 0 group by mm.organ_id_;
 	</select>
 	<select id="sumInternalSettlement" resultType="java.util.Map">
@@ -259,4 +286,14 @@
 		select fe.organ_id_ 'key',SUM(amount_) 'value' from financial_expenditure fe
 		where DATE_FORMAT(fe.create_time_,'%Y-%m') = #{month} AND fee_project_ = 3 AND process_id_ = 28 group by fe.organ_id_;
 	</select>
+	<select id="sumActivityUserMapperAmount" resultType="java.util.Map">
+		SELECT mgpc.organ_id_ 'key',(SUM(CASE WHEN aum.sub_course_num_ > 0 AND aum.category_id_ != 8 THEN aum.sub_course_num_ ELSE 0 END) +
+							   SUM(CASE WHEN aum.sub_give_course_num_ > 0 AND aum.give_category_id_ != 8 THEN aum.sub_give_course_num_ ELSE 0 END)) * oct.price_ 'value'
+		FROM activity_user_mapper aum
+				 LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = aum.calender_id_
+				 LEFT JOIN organ_course_type_original_cost oct ON oct.course_type_ = 'VIP' AND oct.organ_id_ = mgpc.organ_id_
+		WHERE aum.calender_id_ IS NOT NULL AND return_fee_ = 0
+		  AND ((aum.sub_course_num_ > 0 AND aum.category_id_ != 8) OR (aum.sub_give_course_num_ > 0 AND aum.give_category_id_ != 8))
+		GROUP BY mgpc.organ_id_
+	</select>
 </mapper>

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

@@ -116,4 +116,7 @@
 			#{id}
 		</foreach>
 	</select>
+	<select id="getTheory" resultMap="VipGroupCategory">
+		SELECT * FROM vip_group_category WHERE del_flag_ = 0 AND music_theory_ = 1 LIMIT 1
+	</select>
 </mapper>

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -277,4 +277,8 @@ public interface TaskRemoteService {
      */
     @GetMapping("task/pushStartTrain")
     void pushStartTrain();
+
+    //新经营报表统计
+    @GetMapping("task/operatingReportMonth")
+    void operatingReportMonth();
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -319,4 +319,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
     public void pushStartTrain(){
         logger.error("开始训练通知推送失败");
     }
+
+    @Override
+    public void operatingReportMonth() {
+        logger.error("新经营报表统计失败");
+    }
 }

+ 20 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/OperatingReportNewTask.java

@@ -0,0 +1,20 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class OperatingReportNewTask extends BaseTask {
+
+    @Autowired
+    private TaskRemoteService taskRemoteService;
+
+    @Override
+    public void execute() throws TaskException {
+        taskRemoteService.operatingReportMonth();
+    }
+
+}

+ 35 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OperatingReportNewController.java

@@ -0,0 +1,35 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.entity.OperatingReportNew;
+import com.ym.mec.biz.dal.page.OperatingReportNewQueryInfo;
+import com.ym.mec.biz.service.OperatingReportNewService;
+import com.ym.mec.biz.service.OrganizationService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@Api(tags = "经营报表服务")
+@RequestMapping("operatingReportNew")
+@RestController
+public class OperatingReportNewController extends BaseController {
+
+    @Autowired
+    private OperatingReportNewService operatingReportNewService;
+    @Autowired
+    private OrganizationService organizationService;
+
+    @ApiOperation("报表列表")
+    @GetMapping(value = "/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('operatingReportNew/queryPage')")
+    public HttpResponseResult<PageInfo<OperatingReportNew>> queryPage(OperatingReportNewQueryInfo queryInfo) {
+        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
+        return succeed(operatingReportNewService.queryPage(queryInfo));
+    }
+}