Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 4 years ago
parent
commit
ad85eda7b0

+ 5 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/FinancialExpenditureDao.java

@@ -5,6 +5,7 @@ import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -20,18 +21,19 @@ public interface FinancialExpenditureDao extends BaseDAO<Long, FinancialExpendit
 
     /**
      * 统计合作单位各类型的支出
+     *
      * @return
      */
-    List<FinancialExpenditure> getCooperationExpenditure();
+    List<FinancialExpenditure> getCooperationExpenditure(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
 
     /**
+     * @param collect:
+     * @return java.lang.Integer
      * @describe
      * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
      * @author zouxuan
      * @date 2020/9/16
      * @time 11:38
-     * @param collect:
-     * @return java.lang.Integer
      */
     List<String> countBydingTalk(@Param("collect") List<Object> collect);
 }

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

@@ -76,9 +76,38 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
     List<OperatingReport> getRepairGoodsSellGroupMonthReport(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
 
     /**
+     * 维修单和商品销售,总收入
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<OperatingReport> getRepairGoodsSellGroupIncome(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+
+    /**
      * 根据订单号删除
+     *
      * @param orderId
      * @return
      */
     int deleteByOrderId(@Param("orderId") Long orderId);
+
+    /**
+     * 获取乐团订单总收入
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<OperatingReport> getMusicGroupIncome(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    /**
+     * 外部订单总收入
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<OperatingReport> getOutOrderIncome(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
 }

+ 10 - 10
mec-biz/src/main/java/com/ym/mec/biz/dal/page/SellOrderQueryInfo.java

@@ -13,8 +13,8 @@ public class SellOrderQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "商品名称",required = false)
     private String goodsName;
 
-    @ApiModelProperty(value = "学校id",required = false)
-    private Integer schoolId;
+    @ApiModelProperty(value = "合作单位id",required = false)
+    private Integer cooperationOrganId;
 
     @ApiModelProperty(value = "销售类型",required = false)
     private SellTypeEnum type;
@@ -42,14 +42,6 @@ public class SellOrderQueryInfo extends QueryInfo {
         this.goodsName = goodsName;
     }
 
-    public Integer getSchoolId() {
-        return schoolId;
-    }
-
-    public void setSchoolId(Integer schoolId) {
-        this.schoolId = schoolId;
-    }
-
     public SellTypeEnum getType() {
         return type;
     }
@@ -73,4 +65,12 @@ public class SellOrderQueryInfo extends QueryInfo {
     public void setEndTime(Date endTime) {
         this.endTime = endTime;
     }
+
+    public Integer getCooperationOrganId() {
+        return cooperationOrganId;
+    }
+
+    public void setCooperationOrganId(Integer cooperationOrganId) {
+        this.cooperationOrganId = cooperationOrganId;
+    }
 }

+ 77 - 156
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OperatingReportServiceImpl.java

@@ -42,7 +42,7 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
     public Boolean statistics() {
         Date nowDate = new Date();
         Date startTime = DateUtil.getFirstDayOfMonth(DateUtil.addDays1(nowDate, -1));
-        Date endTime = DateUtil.getLastDayOfMonth(startTime);
+        Date endTime = DateUtil.getLastTimeWithDay(DateUtil.getLastDayOfMonth(startTime));
 
         Map<Integer, OperatingReport> cooperationOperating = new HashMap<>();
         Map<Integer, OperatingReport> organOperating = new HashMap<>();
@@ -68,7 +68,7 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
         }
 
         //2、获取支出费用
-        List<FinancialExpenditure> cooperationExpenditures = financialExpenditureDao.getCooperationExpenditure();
+        List<FinancialExpenditure> cooperationExpenditures = financialExpenditureDao.getCooperationExpenditure(startTime, endTime);
         for (FinancialExpenditure cooperationExpenditure : cooperationExpenditures) {
             OperatingReport organOperatingReport = new OperatingReport();
             if (organOperating.containsKey(cooperationExpenditure.getOrganId())) {
@@ -100,176 +100,96 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
             }
         }
 
-        //3.1、乐团订单的统计
-        List<OperatingReport> musicReports = sellOrderDao.getMusicGroupMonthReport(startTime, endTime);
-        for (OperatingReport musicReport : musicReports) {
-            OperatingReport organOperatingReport = new OperatingReport();
-            if (organOperating.containsKey(musicReport.getOrganId())) {
-                organOperatingReport = organOperating.get(musicReport.getOrganId());
-            }
-
-            OperatingReport cooperationOperatingReport = new OperatingReport();
-            if (cooperationOperating.containsKey(musicReport.getCooperationOrganId())) {
-                cooperationOperatingReport = cooperationOperating.get(musicReport.getCooperationOrganId());
-            }
-            organOperatingReport.setOrganId(musicReport.getOrganId());
-            cooperationOperatingReport.setOrganId(musicReport.getOrganId());
-            cooperationOperatingReport.setCooperationOrganId(musicReport.getCooperationOrganId());
-
-            if (musicReport.getSellAmount() == null) {
-                musicReport.setSellAmount(BigDecimal.ZERO);
-                musicReport.setSellCost(BigDecimal.ZERO);
-            }
-            BigDecimal serviceAmount = musicReport.getIncomeTotal().subtract(musicReport.getSellAmount());
-
-            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(serviceAmount));
-            organOperatingReport.setSellAmount(organOperatingReport.getSellAmount().add(musicReport.getSellAmount()));
-            organOperatingReport.setSellCost(organOperatingReport.getSellCost().add(musicReport.getSellCost()));
-            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(serviceAmount));
-            cooperationOperatingReport.setSellAmount(cooperationOperatingReport.getSellAmount().add(musicReport.getSellAmount()));
-            cooperationOperatingReport.setSellCost(cooperationOperatingReport.getSellCost().add(musicReport.getSellCost()));
-            organOperating.put(musicReport.getOrganId(), organOperatingReport);
-            cooperationOperating.put(musicReport.getCooperationOrganId(), cooperationOperatingReport);
-        }
-
+        //3.1、乐团销售订单的统计
+        List<OperatingReport> reports = sellOrderDao.getMusicGroupMonthReport(startTime, endTime);
+        //乐团订单总收入的统计
+        reports.addAll(sellOrderDao.getMusicGroupIncome(startTime, endTime));
         //3.2、VIP、网管课订单的统计(关联学生注册取一条记录)
-        List<OperatingReport> VPReports = sellOrderDao.getMusicVipPracticeMonthReport(startTime, endTime);
-        for (OperatingReport vpReport : VPReports) {
-            OperatingReport organOperatingReport = new OperatingReport();
-            if (organOperating.containsKey(vpReport.getOrganId())) {
-                organOperatingReport = organOperating.get(vpReport.getOrganId());
-            }
-
-            OperatingReport cooperationOperatingReport = new OperatingReport();
-            if (vpReport.getCooperationOrganId() != null && cooperationOperating.containsKey(vpReport.getCooperationOrganId())) {
-                cooperationOperatingReport = cooperationOperating.get(vpReport.getCooperationOrganId());
-            }
-            organOperatingReport.setOrganId(vpReport.getOrganId());
-            cooperationOperatingReport.setOrganId(vpReport.getOrganId());
-            cooperationOperatingReport.setCooperationOrganId(vpReport.getCooperationOrganId());
-
-            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(vpReport.getIncomeTotal()));
-            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(vpReport.getIncomeTotal()));
-
-
-            organOperating.put(vpReport.getOrganId(), organOperatingReport);
-
-            if (vpReport.getCooperationOrganId() != null) {
-                cooperationOperating.put(vpReport.getCooperationOrganId(), cooperationOperatingReport);
-            }
-        }
-
-        //3.3、外部添加订单
-        List<OperatingReport> outOrderReports = sellOrderDao.getOutOrderMonthReport(startTime, endTime);
-        for (OperatingReport outOrderReport : outOrderReports) {
-            OperatingReport organOperatingReport = new OperatingReport();
-            if (organOperating.containsKey(outOrderReport.getOrganId())) {
-                organOperatingReport = organOperating.get(outOrderReport.getOrganId());
-            }
-
-            OperatingReport cooperationOperatingReport = new OperatingReport();
-            if (cooperationOperating.containsKey(outOrderReport.getCooperationOrganId())) {
-                cooperationOperatingReport = cooperationOperating.get(outOrderReport.getCooperationOrganId());
-            }
-
-            organOperatingReport.setOrganId(outOrderReport.getOrganId());
-            cooperationOperatingReport.setOrganId(outOrderReport.getOrganId());
-            cooperationOperatingReport.setCooperationOrganId(outOrderReport.getCooperationOrganId());
-
-            if (outOrderReport.getSellAmount() == null) {
-                outOrderReport.setSellAmount(BigDecimal.ZERO);
-                outOrderReport.setSellCost(BigDecimal.ZERO);
-            }
-            BigDecimal serviceAmount = outOrderReport.getIncomeTotal().subtract(outOrderReport.getSellAmount());
-
-            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(serviceAmount));
-            organOperatingReport.setSellAmount(organOperatingReport.getSellAmount().add(outOrderReport.getSellAmount()));
-            organOperatingReport.setSellCost(organOperatingReport.getSellCost().add(outOrderReport.getSellCost()));
-            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(serviceAmount));
-            cooperationOperatingReport.setSellAmount(cooperationOperatingReport.getSellAmount().add(outOrderReport.getSellAmount()));
-            cooperationOperatingReport.setSellCost(cooperationOperatingReport.getSellCost().add(outOrderReport.getSellCost()));
-            organOperating.put(cooperationOperatingReport.getOrganId(), organOperatingReport);
-            if (outOrderReport.getCooperationOrganId() != null) {
-                cooperationOperating.put(cooperationOperatingReport.getCooperationOrganId(), cooperationOperatingReport);
-            }
-        }
-
+        reports.addAll(sellOrderDao.getMusicVipPracticeMonthReport(startTime, endTime));
+        //3.3、外部添加订单销售
+        reports.addAll(sellOrderDao.getOutOrderMonthReport(startTime, endTime));
+        //外部添加订单销售总收入
+        reports.addAll(sellOrderDao.getOutOrderIncome(startTime, endTime));
         //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);
-        }
-
+        reports.addAll(sellOrderDao.getRepairGoodsSellGroupMonthReport(startTime, endTime));
+        reports.addAll(sellOrderDao.getRepairGoodsSellGroupIncome(startTime, endTime));
         //3.5、零星支付充值
-        List<OperatingReport> rechargeReports = sellOrderDao.getRechargeMonthReport(startTime, endTime);
-        for (OperatingReport rechargeReport : rechargeReports) {
+        reports.addAll(sellOrderDao.getRechargeMonthReport(startTime, endTime));
+        //3.6、零星收费(不是充值部分的)
+        reports.addAll(sellOrderDao.getSporadicMonthReport(startTime, endTime));
+        updateFee(organOperating,cooperationOperating,reports);
+
+//        Map<String, Object> params = new HashMap<>();
+//        params.put("startTime", startTime);
+//        params.put("endTime", endTime);
+//        organOperating.forEach((organId, operatingReport) -> {
+//            operatingReport.setMonth(startTime);
+//            operatingReport.setCreateTime(nowDate);
+//            updateReport(operatingReport, params);
+//        });
+//        cooperationOperating.forEach((organId, operatingReport) -> {
+//            operatingReport.setMonth(startTime);
+//            operatingReport.setCreateTime(nowDate);
+//            updateReport(operatingReport, params);
+//        });
+        return true;
+    }
+
+    /**
+     * 计算总收入
+     *
+     * @param organOperating
+     * @param cooperationOperating
+     * @param reports
+     */
+    private void updateFee(Map<Integer, OperatingReport> organOperating, Map<Integer, OperatingReport> cooperationOperating, List<OperatingReport> reports) {
+        for (OperatingReport report : reports) {
             OperatingReport organOperatingReport = new OperatingReport();
-            if (organOperating.containsKey(rechargeReport.getOrganId())) {
-                organOperatingReport = organOperating.get(rechargeReport.getOrganId());
+            if (organOperating.containsKey(report.getOrganId())) {
+                organOperatingReport = organOperating.get(report.getOrganId());
             }
 
             OperatingReport cooperationOperatingReport = new OperatingReport();
-            if (rechargeReport.getCooperationOrganId() != null && cooperationOperating.containsKey(rechargeReport.getCooperationOrganId())) {
-                cooperationOperatingReport = cooperationOperating.get(rechargeReport.getCooperationOrganId());
+            if (report.getCooperationOrganId() != null && cooperationOperating.containsKey(report.getCooperationOrganId())) {
+                cooperationOperatingReport = cooperationOperating.get(report.getCooperationOrganId());
             }
-            organOperatingReport.setOrganId(rechargeReport.getOrganId());
-            cooperationOperatingReport.setOrganId(rechargeReport.getOrganId());
-            cooperationOperatingReport.setCooperationOrganId(rechargeReport.getCooperationOrganId());
-
-            organOperatingReport.setOtherIncome(organOperatingReport.getOtherIncome().add(rechargeReport.getIncomeTotal()));
-            cooperationOperatingReport.setOtherIncome(cooperationOperatingReport.getIncomeTotal().add(rechargeReport.getIncomeTotal()));
-
-            organOperating.put(rechargeReport.getOrganId(), organOperatingReport);
+            organOperatingReport.setOrganId(report.getOrganId());
+            cooperationOperatingReport.setOrganId(report.getOrganId());
+            cooperationOperatingReport.setCooperationOrganId(report.getCooperationOrganId());
 
-            if (rechargeReport.getCooperationOrganId() != null) {
-                cooperationOperating.put(rechargeReport.getCooperationOrganId(), cooperationOperatingReport);
+            if (report.getSellAmount() == null) {
+                report.setSellAmount(BigDecimal.ZERO);
+                report.setSellCost(BigDecimal.ZERO);
             }
-        }
-
-        //3.6、零星收费(不是充值部分的)
-        List<OperatingReport> sporadicReports = sellOrderDao.getSporadicMonthReport(startTime, endTime);
-        for (OperatingReport sporadicReport : sporadicReports) {
-            OperatingReport organOperatingReport = new OperatingReport();
-            if (organOperating.containsKey(sporadicReport.getOrganId())) {
-                organOperatingReport = organOperating.get(sporadicReport.getOrganId());
+            if (report.getIncomeTotal() == null) {
+                report.setIncomeTotal(BigDecimal.ZERO);
             }
-
-            OperatingReport cooperationOperatingReport = new OperatingReport();
-            if (sporadicReport.getCooperationOrganId() != null && cooperationOperating.containsKey(sporadicReport.getCooperationOrganId())) {
-                cooperationOperatingReport = cooperationOperating.get(sporadicReport.getCooperationOrganId());
+            if (report.getOtherIncome() == null) {
+                report.setOtherIncome(BigDecimal.ZERO);
             }
-            organOperatingReport.setOrganId(sporadicReport.getOrganId());
-            cooperationOperatingReport.setOrganId(sporadicReport.getOrganId());
-            cooperationOperatingReport.setCooperationOrganId(sporadicReport.getCooperationOrganId());
 
-            organOperatingReport.setServiceAmount(organOperatingReport.getServiceAmount().add(sporadicReport.getIncomeTotal()));
-            cooperationOperatingReport.setServiceAmount(cooperationOperatingReport.getServiceAmount().add(sporadicReport.getIncomeTotal()));
+            //总收入
+            organOperatingReport.setIncomeTotal(organOperatingReport.getIncomeTotal().add(report.getIncomeTotal()));
+            cooperationOperatingReport.setIncomeTotal(cooperationOperatingReport.getIncomeTotal().add(report.getIncomeTotal()));
 
+            //销售收入
+            organOperatingReport.setSellAmount(organOperatingReport.getSellAmount().add(report.getSellAmount()));
+            organOperatingReport.setSellCost(organOperatingReport.getSellCost().add(report.getSellCost()));
+            cooperationOperatingReport.setSellAmount(cooperationOperatingReport.getSellAmount().add(report.getSellAmount()));
+            cooperationOperatingReport.setSellCost(cooperationOperatingReport.getSellCost().add(report.getSellCost()));
 
-            organOperating.put(sporadicReport.getOrganId(), organOperatingReport);
+            //其他收入
+            organOperatingReport.setOtherIncome(organOperatingReport.getOtherIncome().add(report.getOtherIncome()));
+            cooperationOperatingReport.setOtherIncome(cooperationOperatingReport.getOtherIncome().add(report.getOtherIncome()));
 
-            if (sporadicReport.getCooperationOrganId() != null) {
-                cooperationOperating.put(sporadicReport.getCooperationOrganId(), cooperationOperatingReport);
+            organOperating.put(report.getOrganId(), organOperatingReport);
+            if (report.getCooperationOrganId() != null) {
+                cooperationOperating.put(report.getCooperationOrganId(), cooperationOperatingReport);
             }
         }
-
+        Date nowDate = new Date();
+        Date startTime = DateUtil.getFirstDayOfMonth(DateUtil.addDays1(nowDate, -1));
+        Date endTime = DateUtil.getLastTimeWithDay(DateUtil.getLastDayOfMonth(startTime));
         Map<String, Object> params = new HashMap<>();
         params.put("startTime", startTime);
         params.put("endTime", endTime);
@@ -283,12 +203,13 @@ public class OperatingReportServiceImpl extends BaseServiceImpl<Integer, Operati
             operatingReport.setCreateTime(nowDate);
             updateReport(operatingReport, params);
         });
-        return true;
     }
 
     private void updateReport(OperatingReport operatingReport, Map<String, Object> params) {
         //收入合计:销售收入+服务收入-业务退费
-        BigDecimal incomeTotal = operatingReport.getSellAmount().add(operatingReport.getServiceAmount()).add(operatingReport.getOtherIncome()).subtract(operatingReport.getRefundAmount());
+        BigDecimal serviceTotal = operatingReport.getIncomeTotal().subtract(operatingReport.getSellAmount()).subtract(operatingReport.getOtherIncome());
+        operatingReport.setServiceAmount(serviceTotal);
+        BigDecimal incomeTotal = operatingReport.getIncomeTotal().subtract(operatingReport.getRefundAmount());
         operatingReport.setIncomeTotal(incomeTotal);
         //成本费用合计:销售成本+固定支出+变动支出+分摊费用
         BigDecimal costAmount = operatingReport.getSellCost().add(operatingReport.getExpensesAmount()).add(operatingReport.getVariableCost()).add(operatingReport.getDistributionAmount());

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

@@ -79,7 +79,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             }
             goodsPrice = nowGoods.getGroupPurchasePrice();
 
-            BigDecimal goodsBalance = goodsTotalBalance.multiply(goodsPrice).divide(totalAmount, 2, BigDecimal.ROUND_HALF_UP);
+            BigDecimal goodsBalance = goodsTotalBalance.multiply(goodsPrice).divide(goodsTotalPrice, 2, BigDecimal.ROUND_HALF_UP);
             if (i == goodsNum) {
                 goodsBalance = goodsTotalBalance.subtract(hasRouteBalance);
             }

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -89,6 +89,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
         studentPaymentRouteOrderDto.setRouteOrganId(studentPaymentRouteOrderDto.getOrganId());
         studentPaymentRouteOrderDto.setExpectAmount(studentPaymentRouteOrderDto.getActualAmount());
         studentPaymentRouteOrderDto.setStatus(DealStatusEnum.SUCCESS);
+        studentPaymentRouteOrderDto.setCreateTime(studentPaymentRouteOrderDto.getPayTime());
         studentPaymentRouteOrderDto.setUpdateTime(nowDate);
 
         studentPaymentOrderDao.insert(studentPaymentRouteOrderDto);
@@ -140,15 +141,15 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
                 sellOrder.setActualAmount(actualAmount);
                 sellOrder.setBalanceAmount(BigDecimal.ZERO);
                 sellOrder.setExpectAmount(actualAmount);
-                sellOrder.setSellCost(goods.getDiscountPrice().multiply(new BigDecimal(goodsMap.getValue())));
+                sellOrder.setSellCost(goods.getDiscountPrice());
                 sellOrder.setSellCost2(JSON.toJSONString(CostMap));
                 sellOrder.setNum(goodsMap.getValue());
                 sellOrder.setUserId(studentPaymentRouteOrderDto.getUserId());
                 sellOrder.setPaymentChannel(studentPaymentRouteOrderDto.getPaymentChannel());
                 sellOrder.setMerNo(studentPaymentRouteOrderDto.getMerNos());
                 sellOrder.setSellTime(studentPaymentRouteOrderDto.getCreateTime());
-                sellOrder.setCreateIme(new Date());
-                sellOrder.setUpdateTime(new Date());
+                sellOrder.setCreateIme(nowDate);
+                sellOrder.setUpdateTime(nowDate);
                 sellOrder.setType(SellTypeEnum.SCHOOL_BUY);
                 sellOrders.add(sellOrder);
             }

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

@@ -635,7 +635,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 List<Goods> goods = JSONObject.parseArray(repairInfo.getGoodsJson(), Goods.class);
                 List<Integer> goodsIds = goods.stream().map(Goods::getId).collect(Collectors.toList());
                 if (goodsIds.size() > 0) {
-                    sellOrderService.addSellOrder(studentPaymentOrder.getId(), repairInfo.getMusicGroupId(), goodsIds, studentPaymentOrder.getExpectAmount(), studentPaymentOrder.getBalancePaymentAmount());
+                    sellOrderService.addSellOrder(studentPaymentOrder.getId(), null, goodsIds, studentPaymentOrder.getExpectAmount(), studentPaymentOrder.getBalancePaymentAmount());
                 }
             }
 

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

@@ -142,13 +142,13 @@
 
     <select id="getOrganFullJobResourceNum" resultType="com.ym.mec.biz.dal.dto.OrganFullJobResourceNumDto">
         SELECT organ_id_ organId,COUNT(*) num FROM cooperation_organ
-        WHERE full_job_resource_ =1 AND is_enable_=1 AND del_flag_ = 0
+        WHERE full_job_resource_ =1 AND del_flag_ = 0
         GROUP BY organ_id_
     </select>
 
     <!-- 获取全部使用中的合作单位 -->
     <select id="getAllCooperationOrgan" resultMap="CooperationOrgan">
         SELECT * FROM cooperation_organ
-        WHERE full_job_resource_ =1 AND is_enable_=1 AND del_flag_ = 0
+        WHERE del_flag_ = 0
     </select>
 </mapper>

+ 40 - 21
mec-biz/src/main/resources/config/mybatis/FinancialExpenditureMapper.xml

@@ -27,22 +27,31 @@
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="FinancialExpenditure">
-		SELECT * FROM financial_expenditure WHERE id_ = #{id}
-	</select>
+        SELECT *
+        FROM financial_expenditure
+        WHERE id_ = #{id}
+    </select>
 
     <!-- 全查询 -->
     <select id="findAll" resultMap="FinancialExpenditure">
-		SELECT * FROM financial_expenditure WHERE del_flag_ = 0 ORDER BY id_
-	</select>
+        SELECT *
+        FROM financial_expenditure
+        WHERE del_flag_ = 0
+        ORDER BY id_
+    </select>
 
     <!-- 向数据库增加一条记录 -->
-    <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.FinancialExpenditure" useGeneratedKeys="true" keyColumn="id"
+    <insert id="insert" 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_,
-        organ_id_,cooperation_organ_id_,apply_user_,amount_,item_detail_,payment_time_,cause_,create_time_,update_time_,fee_project_,type_)
-        VALUES(#{batchNo},#{financialProcessNo},#{dingtalkProcessNo},#{organId},#{cooperationOrganId},#{applyUser},#{amount},
-        #{itemDetail},#{paymentTime},#{cause},now(),now(),#{feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        INSERT INTO financial_expenditure (batch_no_, financial_process_no_, dingtalk_process_no_,
+                                           organ_id_, cooperation_organ_id_, apply_user_, amount_, item_detail_,
+                                           payment_time_, cause_, create_time_, update_time_, fee_project_, type_)
+        VALUES (#{batchNo}, #{financialProcessNo}, #{dingtalkProcessNo}, #{organId}, #{cooperationOrganId},
+                #{applyUser}, #{amount},
+                #{itemDetail}, #{paymentTime}, #{cause}, now(), now(),
+                #{feeProject,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
 
     <insert id="batchInsert">
@@ -105,10 +114,14 @@
 
     <!-- 根据主键删除一条记录 -->
     <update id="delete">
-		UPDATE financial_expenditure SET del_flag_ = 1 WHERE id_ = #{id}
-	</update>
+        UPDATE financial_expenditure
+        SET del_flag_ = 1
+        WHERE id_ = #{id}
+    </update>
     <update id="batchDel">
-        UPDATE financial_expenditure SET del_flag_ = 1 WHERE FIND_IN_SET(id_,#{ids})
+        UPDATE financial_expenditure
+        SET del_flag_ = 1
+        WHERE FIND_IN_SET(id_, #{ids})
     </update>
 
     <sql id="queryPageSql">
@@ -131,7 +144,8 @@
             </if>
             <if test="search != null and search != ''">
                 AND (fe.id_ LIKE CONCAT('%',#{search},'%') OR fe.financial_process_no_ LIKE CONCAT('%',#{search},'%')
-                OR fe.dingtalk_process_no_ LIKE CONCAT('%',#{search},'%') OR fe.apply_user_ LIKE CONCAT('%',#{search},'%'))
+                OR fe.dingtalk_process_no_ LIKE CONCAT('%',#{search},'%') OR fe.apply_user_ LIKE
+                CONCAT('%',#{search},'%'))
             </if>
             <if test="organId != null and organId != ''">
                 AND FIND_IN_SET(fe.organ_id_,#{organId})
@@ -160,11 +174,12 @@
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(DISTINCT fe.id_) FROM financial_expenditure fe
+        SELECT COUNT(DISTINCT fe.id_) FROM financial_expenditure fe
         <include refid="queryPageSql"/>
-	</select>
+    </select>
 
-    <resultMap type="com.ym.mec.biz.dal.dto.FinancialExpenditureDto" id="FinancialExpenditureDto" extends="FinancialExpenditure">
+    <resultMap type="com.ym.mec.biz.dal.dto.FinancialExpenditureDto" id="FinancialExpenditureDto"
+               extends="FinancialExpenditure">
         <result column="organ_name_" property="organName"/>
         <result column="cooperation_name_" property="cooperationName"/>
     </resultMap>
@@ -183,10 +198,14 @@
     </select>
 
     <!-- 统计合作单位的支出 -->
-    <select id="getCooperationExpenditure" resultMap="FinancialExpenditure">
-        SELECT organ_id_,cooperation_organ_id_, type_, SUM(amount_) amount_ FROM financial_expenditure WHERE del_flag_ =0
-        GROUP BY organ_id_,cooperation_organ_id_,type_
-    </select>
+    <select id="getCooperationExpenditure" resultMap="FinancialExpenditure"><![CDATA[
+        SELECT organ_id_, cooperation_organ_id_, type_, SUM(amount_) amount_
+        FROM financial_expenditure
+        WHERE payment_time_ >= #{startTime}
+          AND payment_time_ <= #{endTime}
+          AND del_flag_ = 0
+        GROUP BY organ_id_, cooperation_organ_id_, type_
+        ]]></select>
     <select id="countBydingTalk" resultType="java.lang.String">
         SELECT dingtalk_process_no_ FROM financial_expenditure WHERE del_flag_ = 0 AND dingtalk_process_no_ IN
         <foreach collection="collect" separator="," open="(" close=")" item="item">

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

@@ -141,7 +141,7 @@
         </where>
     </sql>
     <select id="getReport" resultMap="OperatingReport" parameterType="map">
-        SELECT * FROM operating_report opr
+        SELECT * FROM operating_report
         <where>
             <if test="organId != null">
                 AND organ_id_ = #{organId}

+ 66 - 19
mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml

@@ -52,7 +52,8 @@
     <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SellOrder"
             useGeneratedKeys="true">
         <!--@mbg.generated-->
-        insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,
+        actual_amount_,
         balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
         mer_no_, sell_time_, create_ime_, update_time_)
         values (#{organId}, #{cooperationOrganId}, #{transNo}, #{orderNo},#{orderId}, #{expectAmount}, #{actualAmount},
@@ -129,7 +130,8 @@
     </update>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
-        insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_, actual_amount_,
+        insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,
+        actual_amount_,
         balance_amount_, type_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_, user_id_, payment_channel_,
         mer_no_, sell_time_, create_ime_, update_time_)
         VALUE
@@ -149,7 +151,7 @@
         LEFT JOIN organization o ON o.id_ = so.organ_id_
         LEFT JOIN cooperation_organ co ON co.id_= so.cooperation_organ_id_
         <include refid="queryPageSql"/>
-        ORDER BY so.sell_time_ DESC
+        ORDER BY so.create_ime_ DESC
         <include refid="global.limit"/>
     </select>
 
@@ -188,10 +190,9 @@
     <!-- 获取分部学校的收入支出(乐团订单) -->
     <select id="getMusicGroupMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
-               co.id_                  cooperation_organ_id_,
-               SUM(spo.actual_amount_) income_total_,
-               SUM(so.actual_amount_)  sell_amount_,
-               SUM(so.sell_cost_)      sellCost
+               co.id_                       cooperation_organ_id_,
+               SUM(so.actual_amount_)       sell_amount_,
+               SUM(so.sell_cost_ * so.num_) sell_cost_
         FROM student_payment_order spo
                  LEFT JOIN sell_order so on so.order_id_ = spo.id_
                  LEFT JOIN music_group mg ON mg.id_ = spo.music_group_id_
@@ -203,6 +204,20 @@
         GROUP BY spo.organ_id_, co.id_
         ]]></select>
 
+    <select id="getMusicGroupIncome" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
+        SELECT spo.organ_id_,
+               co.id_                  cooperation_organ_id_,
+               SUM(spo.actual_amount_) income_total_
+        FROM student_payment_order spo
+                 LEFT JOIN music_group mg ON mg.id_ = spo.music_group_id_
+                 LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
+        WHERE spo.status_ = 'SUCCESS'
+          AND spo.group_type_ = 'MUSIC'
+          AND spo.create_time_ >= #{startTime}
+          AND spo.create_time_ <= #{endTime}
+        GROUP BY spo.organ_id_, co.id_
+        ]]></select>
+
     <!-- 获取分部学校的收入支出(VIP,网管课) -->
     <select id="getMusicVipPracticeMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
@@ -228,10 +243,9 @@
     <!-- 获取分部学校的收入支出(外部添加订单) -->
     <select id="getOutOrderMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
-               co.id_                  cooperation_organ_id_,
-               SUM(spo.actual_amount_) income_total_,
-               SUM(so.actual_amount_)  sell_amount_,
-               SUM(so.sell_cost_)      sellCost
+               co.id_                       cooperation_organ_id_,
+               SUM(so.actual_amount_)       sell_amount_,
+               SUM(so.sell_cost_ * so.num_) sell_cost_
         FROM student_payment_order spo
                  LEFT JOIN sell_order so on so.order_id_ = spo.id_
                  LEFT JOIN cooperation_organ co ON co.id_ = spo.music_group_id_
@@ -242,11 +256,26 @@
         GROUP BY spo.organ_id_, co.id_
         ]]></select>
 
+    <!-- 获取分部学校的收入支出(外部添加订单) -->
+    <select id="getOutOrderIncome" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
+        SELECT spo.organ_id_,
+               co.id_                  cooperation_organ_id_,
+               SUM(spo.actual_amount_) income_total_
+        FROM student_payment_order spo
+                 LEFT JOIN cooperation_organ co ON co.id_ = spo.music_group_id_
+        WHERE spo.status_ = 'SUCCESS'
+          AND spo.group_type_ = 'OUTORDER'
+          AND spo.create_time_ >= #{startTime}
+          AND spo.create_time_ <= #{endTime}
+        GROUP BY spo.organ_id_, co.id_
+        ]]></select>
+
     <!-- 获取分部学校的收入(充值) -->
     <select id="getRechargeMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
         SELECT spo.organ_id_,
                co.id_                  cooperation_organ_id_,
-               SUM(spo.actual_amount_) income_total_
+               SUM(spo.actual_amount_) income_total_,
+               SUM(spo.actual_amount_) other_income_
         FROM student_payment_order spo
                  LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
                  LEFT JOIN music_group mg ON mg.id_ = sci.music_group_id_
@@ -277,26 +306,44 @@
         ]]></select>
 
     <!-- 获取分部学校的收入支出(维修、商品销售订单) -->
-    <select id="getRepairGoodsSellGroupMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
+    <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
+               SUM(so.actual_amount_)       sell_amount_,
+               SUM(so.sell_cost_ * so.num_) sell_cost_
         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.group_type_ IN ('REPAIR', 'GOODS_SELL')
           AND spo.create_time_ >= #{startTime}
           AND spo.create_time_ <= #{endTime}
         GROUP BY spo.organ_id_
         ]]></select>
 
+    <!-- 获取分部学校的收入支出(维修、商品销售订单) -->
+    <select id="getRepairGoodsSellGroupIncome"
+            resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
+        SELECT spo.organ_id_,
+               SUM(spo.actual_amount_) income_total_
+        FROM student_payment_order spo
+        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>
+
+
     <!-- 获取订单的销售列表 -->
     <select id="getOrderSellOrder" resultMap="SellOrder">
-        SELECT * FROM sell_order WHERE order_id_ = #{orderId}
+        SELECT *
+        FROM sell_order
+        WHERE order_id_ = #{orderId}
     </select>
 
     <delete id="deleteByOrderId">
-        DELETE FROM sell_order WHERE order_id_=#{orderId}
+        DELETE
+        FROM sell_order
+        WHERE order_id_ = #{orderId}
     </delete>
 </mapper>

+ 0 - 2
mec-web/src/main/java/com/ym/mec/web/controller/SellOrderController.java

@@ -73,8 +73,6 @@ public class SellOrderController extends BaseController {
     @PostMapping(value = "/update")
     @PreAuthorize("@pcs.hasPermissions('sellOrder/update')")
     public HttpResponseResult<SellOrder> update(SellOrder sellOrder) {
-        SellOrder oldOrder = sellOrderService.get(sellOrder.getId());
-        sellOrder.setSellCost(sellOrder.getSellCost().multiply(new BigDecimal(oldOrder.getNum())));
         sellOrderService.update(sellOrder);
         return succeed(sellOrder);
     }

+ 6 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentRouteOrderController.java

@@ -95,6 +95,12 @@ public class StudentPaymentRouteOrderController extends BaseController {
         if (studentPaymentRouteOrderDto.getSchoolId() != null) {
             studentPaymentRouteOrderDto.setMusicGroupId(studentPaymentRouteOrderDto.getSchoolId().toString());
         }
+        if (studentPaymentRouteOrderDto.getServiceAmount() == null) {
+            studentPaymentRouteOrderDto.setServiceAmount(BigDecimal.ZERO);
+        }
+        if (studentPaymentRouteOrderDto.getGoodsAmount() == null) {
+            studentPaymentRouteOrderDto.setGoodsAmount(BigDecimal.ZERO);
+        }
         studentPaymentRouteOrderDto.setActualAmount(studentPaymentRouteOrderDto.getServiceAmount().add(studentPaymentRouteOrderDto.getGoodsAmount()));
         return succeed(studentPaymentRouteOrderService.addOutOrder(studentPaymentRouteOrderDto));
     }