Sfoglia il codice sorgente

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 anni fa
parent
commit
d1a4357dd7

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SellOrderDao.java

@@ -56,4 +56,12 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
      * @return
      */
     List<OperatingReport> getSporadicMonthReport(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    /**
+     * 维修单和商品销售
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<OperatingReport> getRepairGoodsSellGroupMonthReport(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
 }

+ 27 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportServiceImpl.java

@@ -40,7 +40,7 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
     @Transactional(rollbackFor = Exception.class)
     public Boolean statistics() {
         Date nowDate = new Date();
-        Date startTime = DateUtil.getFirstDayOfMonth( DateUtil.addDays1(nowDate, -1));
+        Date startTime = DateUtil.getFirstDayOfMonth(DateUtil.addDays1(nowDate, -1));
         Date endTime = DateUtil.getLastDayOfMonth(startTime);
 
         Map<Integer, OperatingReport> cooperationOperating = new HashMap<>();
@@ -52,7 +52,7 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
         for (OrganFullJobResourceNumDto organFullJobResource : organFullJobResources) {
             OperatingReport operatingReport = new OperatingReport();
             operatingReport.setOrganId(organFullJobResource.getOrganId());
-            operatingReport.setDistributionAmount(new BigDecimal(organFullJobResource.getNum()).multiply(fullJobFee).divide(new BigDecimal(12),2,BigDecimal.ROUND_HALF_UP));
+            operatingReport.setDistributionAmount(new BigDecimal(organFullJobResource.getNum()).multiply(fullJobFee).divide(new BigDecimal(12), 2, BigDecimal.ROUND_HALF_UP));
             organOperating.put(organFullJobResource.getOrganId(), operatingReport);
         }
 
@@ -117,8 +117,8 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
             cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(serviceAmount));
             cooperationOperatingReport.setSellAmount(cooperationOperatingReport.getSellAmount().add(musicReport.getSellAmount()));
             cooperationOperatingReport.setSellCost(cooperationOperatingReport.getSellCost().add(musicReport.getSellCost()));
-            organOperating.put(cooperationOperatingReport.getOrganId(), organOperatingReport);
-            cooperationOperating.put(cooperationOperatingReport.getCooperationOrganId(), cooperationOperatingReport);
+            organOperating.put(musicReport.getOrganId(), organOperatingReport);
+            cooperationOperating.put(musicReport.getCooperationOrganId(), cooperationOperatingReport);
         }
 
         //3.2、VIP、网管课订单的统计(关联学生注册取一条记录)
@@ -183,7 +183,28 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
             }
         }
 
-        //3.4、乐器维修
+        //3.4、乐器维修、商品销售
+        List<OperatingReport> repairGoodsSellReports = sellOrderDao.getRepairGoodsSellGroupMonthReport(startTime, endTime);
+        for (OperatingReport repairGoodsSellReport : repairGoodsSellReports) {
+            OperatingReport organOperatingReport = new OperatingReport();
+            if (organOperating.containsKey(repairGoodsSellReport.getOrganId())) {
+                organOperatingReport = organOperating.get(repairGoodsSellReport.getOrganId());
+            }
+
+            organOperatingReport.setOrganId(repairGoodsSellReport.getOrganId());
+
+            if (repairGoodsSellReport.getSellAmount() == null) {
+                repairGoodsSellReport.setSellAmount(BigDecimal.ZERO);
+                repairGoodsSellReport.setSellCost(BigDecimal.ZERO);
+            }
+            BigDecimal serviceAmount = repairGoodsSellReport.getIncomeTotal().subtract(repairGoodsSellReport.getSellAmount());
+
+            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(serviceAmount));
+            organOperatingReport.setSellAmount(organOperatingReport.getSellAmount().add(repairGoodsSellReport.getSellAmount()));
+            organOperatingReport.setSellCost(organOperatingReport.getSellCost().add(repairGoodsSellReport.getSellCost()));
+
+            organOperating.put(repairGoodsSellReport.getOrganId(), organOperatingReport);
+        }
 
         //3.5、零星支付充值
         List<OperatingReport> rechargeReports = sellOrderDao.getRechargeMonthReport(startTime, endTime);
@@ -247,7 +268,7 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
             updateReport(operatingReport, params);
         });
         cooperationOperating.forEach((organId, operatingReport) -> {
-            operatingReport.setDistributionAmount(fullJobFee.divide(new BigDecimal(12),2,BigDecimal.ROUND_HALF_UP));
+            operatingReport.setDistributionAmount(fullJobFee.divide(new BigDecimal(12), 2, BigDecimal.ROUND_HALF_UP));
             operatingReport.setMonth(startTime);
             operatingReport.setCreateTime(nowDate);
             updateReport(operatingReport, params);

+ 15 - 0
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -275,4 +275,19 @@
           AND spo.create_time_ <= #{endTime}
         GROUP BY spo.organ_id_, co.id_
         ]]></select>
+
+    <!-- 获取分部学校的收入支出(维修、商品销售订单) -->
+    <select id="getRepairGoodsSellGroupMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
+        SELECT spo.organ_id_,
+               SUM(spo.actual_amount_) income_total_,
+               SUM(so.actual_amount_)  sell_amount_,
+               SUM(so.sell_cost_)      sellCost
+        FROM student_payment_order spo
+                 LEFT JOIN sell_order so on so.order_id_ = spo.id_
+        WHERE spo.status_ = 'SUCCESS'
+          AND spo.group_type_ IN ('REPAIR','GOODS_SELL')
+          AND spo.create_time_ >= #{startTime}
+          AND spo.create_time_ <= #{endTime}
+        GROUP BY spo.organ_id_
+        ]]></select>
 </mapper>