Parcourir la source

订单导出增加类型详细

周箭河 il y a 4 ans
Parent
commit
08a5deef52

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

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
+import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.entity.OperatingReport;
 import com.ym.mec.biz.dal.entity.SellOrder;
 import com.ym.mec.common.dal.BaseDAO;
@@ -92,6 +93,7 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
 
     /**
      * 商品销售
+     *
      * @param startTime
      * @param endTime
      * @return
@@ -191,4 +193,11 @@ public interface SellOrderDao extends BaseDAO<Integer, SellOrder> {
      * @return
      */
     List<SellOrder> getRefundSellOrder(@Param("orderId") Long orderId);
+
+    /**
+     * 获取订单的各类型费用
+     * @param orderId
+     * @return
+     */
+    StudentPaymentOrderExportDto getFeeByType(@Param("orderId") Long orderId);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentOrderExportDto.java

@@ -27,6 +27,9 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
     //教辅费用
     private BigDecimal teachingFee;
 
+    //维修费用
+    private BigDecimal repairFee;
+
     //手续费
     private BigDecimal transferFee;
 
@@ -193,4 +196,12 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
     public void setHighOnlineCourseFee(BigDecimal highOnlineCourseFee) {
         this.highOnlineCourseFee = highOnlineCourseFee;
     }
+
+    public BigDecimal getRepairFee() {
+        return repairFee;
+    }
+
+    public void setRepairFee(BigDecimal repairFee) {
+        this.repairFee = repairFee;
+    }
 }

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

@@ -481,7 +481,7 @@
         FROM student_payment_order spo
                  LEFT JOIN sell_order so on so.order_id_ = spo.id_
         WHERE spo.status_ = 'SUCCESS'
-          AND spo.group_type_ ='GOODS_SELL'
+          AND spo.group_type_ = 'GOODS_SELL'
           AND spo.create_time_ >= #{startTime}
           AND spo.create_time_ <= #{endTime}
         GROUP BY spo.organ_id_, so.cooperation_organ_id_
@@ -586,4 +586,14 @@
             #{sellOrderId}
         </foreach>
     </select>
+
+    <select id="getFeeByType" resultType="com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto">
+        SELECT MAX(spo.expect_amount_)                                expectAmount,
+               SUM(IF(g.type_ = 'INSTRUMENT', so.expect_amount_, 0))  musicalFee,
+               SUM(IF(g.type_ != 'INSTRUMENT', so.expect_amount_, 0)) teachingFee
+        FROM sell_order so
+                 LEFT JOIN goods g ON g.id_ = so.goods_id_
+                 LEFT JOIN student_payment_order spo ON spo.id_ = so.order_id_
+        WHERE spo.id_ = #{orderId}
+    </select>
 </mapper>

+ 14 - 3
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -107,6 +107,8 @@ public class ExportController extends BaseController {
     private MusicGroupBuildLogDao musicGroupBuildLogDao;
     @Autowired
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+    @Autowired
+    private SellOrderDao sellOrderDao;
 
     @ApiOperation(value = "学员考勤记录导出")
     @PostMapping("export/exportStudentAttendances")
@@ -135,7 +137,7 @@ public class ExportController extends BaseController {
         OutputStream outputStream = response.getOutputStream();
         try {
             HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{"分部编号", "分部名称", "课程组类型", "课程组编号", "课程组名称", "学员姓名",
-                    "学员编号", "课程编号", "课程名称", "上课日期", "上课开始时间","上课结束时间","指导老师名称","指导老师编号","教务老师名称","教务老师编号","学员考勤状态"}, new String[]{
+                    "学员编号", "课程编号", "课程名称", "上课日期", "上课开始时间", "上课结束时间", "指导老师名称", "指导老师编号", "教务老师名称", "教务老师编号", "学员考勤状态"}, new String[]{
                     "organId", "organName", "groupType.desc", "groupId", "groupName", "username",
                     "userId", "courseScheduleId", "courseScheduleName", "classDate", "startClassTime", "endClassTime", "guideTeacherName", "guideTeacherId"
                     , "educationalTeacherName", "educationalTeacherId", "studentAttendanceStatus.msg"}, rows);
@@ -976,6 +978,15 @@ public class ExportController extends BaseController {
                 if (practiceGroup != null) {
                     row.setSubjectName(practiceGroup.getSubjectName());
                 }
+            } else {
+                StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
+                row.setMusicalFee(feeByType.getMusicalFee());
+                row.setTeachingFee(feeByType.getTeachingFee());
+                if (row.getType().equals(OrderTypeEnum.REPAIR)) {
+                    row.setRepairFee(feeByType.getExpectAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()));
+                } else if (row.getType().equals(OrderTypeEnum.OUTORDER)) {
+                    row.setCourseFee(feeByType.getExpectAmount().subtract(feeByType.getMusicalFee()).subtract(feeByType.getTeachingFee()));
+                }
             }
             String paymentChannel = "";
             if (row.getPaymentChannel() == null) {
@@ -1270,7 +1281,7 @@ public class ExportController extends BaseController {
         Set<Integer> studentIds = vipGroupExports.stream().map(CourseGroupExportDto::getStudentId).collect(Collectors.toSet());
         List<Map<Integer, Date>> studentLastCourseSchedule = courseScheduleStudentPaymentDao.findStudentLastCourseSchedule(new ArrayList<>(studentIds));
         Map<Integer, String> studentLastCourseMap = new HashMap<>();
-        if(!CollectionUtils.isEmpty(studentLastCourseSchedule)){
+        if (!CollectionUtils.isEmpty(studentLastCourseSchedule)) {
             studentLastCourseMap = MapUtil.convertMybatisMap(studentLastCourseSchedule);
         }
         List<CourseGroupExportDto> studentCourseInfos = courseScheduleDao.getStudentVipCourseInfo(studentIds);
@@ -1279,7 +1290,7 @@ public class ExportController extends BaseController {
         for (CourseGroupExportDto vipGroupExport : vipGroupExports) {
 
             String lastClassDateStr = studentLastCourseMap.get(vipGroupExport.getStudentId());
-            if(StringUtils.isNotBlank(lastClassDateStr)){
+            if (StringUtils.isNotBlank(lastClassDateStr)) {
                 vipGroupExport.setLastClassDate(DateUtil.stringToDate(lastClassDateStr));
             }