zouxuan преди 2 години
родител
ревизия
3b54c00570

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

@@ -104,4 +104,7 @@ public interface OperatingReportNewDao extends BaseDAO<Integer, OperatingReportN
 
     //统计学员管理费
     List<Map<Integer,BigDecimal>> sumStudentManagementFee();
+
+    //统计总部的销售收入,成本
+    OperatingReportNew sumTotalSellAmount(@Param("month") String currentMonth);
 }

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

@@ -207,7 +207,9 @@ public class OperatingReportNewServiceImpl extends BaseServiceImpl<Integer, Oper
 		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);

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

@@ -343,4 +343,12 @@
 		where sr.music_group_status_ = 'NORMAL' AND mg.status_ = 'PROGRESS'
 		group by mg.organ_id_
 	</select>
+	<select id="sumTotalSellAmount" resultMap="OperatingReportNew">
+		select SUM(so.organ_sell_cost_ * so.num_) sale_amount_,SUM(CASE WHEN so.status_ = 1 THEN 0 ELSE so.sell_cost_ * so.num_ END) sale_cost_ from sell_order so
+		left join student_payment_order spo ON spo.order_no_ = so.order_no_
+		left join music_group mg ON mg.id_ = spo.music_group_id_ AND spo.group_type_ = 'MUSIC'
+		where (mg.musical_instruments_provide_status_ = 1 AND mg.musical_instruments_provide_time_ = #{month}) OR
+			(DATE_FORMAT(spo.pay_time_,'%Y-%m') = #{month} AND (mg.musical_instruments_provide_status_ IS NULL OR mg.musical_instruments_provide_status_ = 1));
+
+	</select>
 </mapper>