فهرست منبع

Merge branch 'sell_order' of http://git.dayaedu.com/yonge/mec into active_course_2021-09-26~29

zouxuan 3 سال پیش
والد
کامیت
60d69bd98a
17فایلهای تغییر یافته به همراه279 افزوده شده و 53 حذف شده
  1. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupSubjectGoodsAndInfoDto.java
  2. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentPaymentOrderExportDto.java
  3. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java
  4. 21 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentPreRegistrationQueryInfo.java
  5. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java
  6. 6 1
      mec-biz/src/main/java/com/ym/mec/biz/service/SubjectChangeService.java
  7. 13 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java
  8. 5 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java
  9. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java
  10. 50 8
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  11. 12 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  12. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  13. 42 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java
  14. 12 0
      mec-biz/src/main/resources/config/mybatis/StudentPreRegistrationMapper.xml
  15. 50 22
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java
  16. 12 1
      mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  17. 5 4
      mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupSubjectGoodsAndInfoDto.java

@@ -53,7 +53,7 @@ public class MusicGroupSubjectGoodsAndInfoDto {
     
     private List<StudentPaymentOrderDetail> studentPaymentOrderDetailList;
     
-    private Map<CourseScheduleType, BigDecimal> memberCoursePrice = new HashMap<CourseScheduleType, BigDecimal>();
+    private Map<String, BigDecimal> memberCoursePrice = new HashMap<String, BigDecimal>();
 
     public Map getCourseScheduleInfo() {
         return CourseScheduleInfo;
@@ -143,11 +143,11 @@ public class MusicGroupSubjectGoodsAndInfoDto {
 		this.studentPaymentOrderDetailList = studentPaymentOrderDetailList;
 	}
 
-	public Map<CourseScheduleType, BigDecimal> getMemberCoursePrice() {
+	public Map<String, BigDecimal> getMemberCoursePrice() {
 		return memberCoursePrice;
 	}
 
-	public void setMemberCoursePrice(Map<CourseScheduleType, BigDecimal> memberCoursePrice) {
+	public void setMemberCoursePrice(Map<String, BigDecimal> memberCoursePrice) {
 		this.memberCoursePrice = memberCoursePrice;
 	}
 }

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

@@ -92,6 +92,17 @@ public class StudentPaymentOrderExportDto extends StudentPaymentOrder {
 
     private Integer payingStatus;
 
+    //订单金额
+    private BigDecimal orderAmount = BigDecimal.ZERO;
+
+    public BigDecimal getOrderAmount() {
+        return orderAmount;
+    }
+
+    public void setOrderAmount(BigDecimal orderAmount) {
+        this.orderAmount = orderAmount;
+    }
+
     public BigDecimal getSporadicAmount() {
         return sporadicAmount;
     }

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

@@ -206,6 +206,17 @@ public class SellOrder {
     @ApiModelProperty(value="优惠券减免")
     private BigDecimal couponRemitAmount = BigDecimal.ZERO;
 
+    @ApiModelProperty(value="订单金额")
+    private BigDecimal orderAmount = BigDecimal.ZERO;
+
+    public BigDecimal getOrderAmount() {
+        return orderAmount;
+    }
+
+    public void setOrderAmount(BigDecimal orderAmount) {
+        this.orderAmount = orderAmount;
+    }
+
     public BigDecimal getCouponRemitAmount() {
         return couponRemitAmount;
     }

+ 21 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentPreRegistrationQueryInfo.java

@@ -24,7 +24,11 @@ public class StudentPreRegistrationQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "云教练提供方式",required = false)
     private String cloudTeacherMethod;
 
-
+    /** 老师推荐声部 */
+	private Integer teacherRecommandSubjectId;
+	
+	/** 选报声部 */
+	private Integer selectionSubjectId;
 
     public String getName() {
         return name;
@@ -73,4 +77,20 @@ public class StudentPreRegistrationQueryInfo extends QueryInfo {
     public void setCloudTeacherMethod(String cloudTeacherMethod) {
         this.cloudTeacherMethod = cloudTeacherMethod;
     }
+
+	public Integer getTeacherRecommandSubjectId() {
+		return teacherRecommandSubjectId;
+	}
+
+	public void setTeacherRecommandSubjectId(Integer teacherRecommandSubjectId) {
+		this.teacherRecommandSubjectId = teacherRecommandSubjectId;
+	}
+
+	public Integer getSelectionSubjectId() {
+		return selectionSubjectId;
+	}
+
+	public void setSelectionSubjectId(Integer selectionSubjectId) {
+		this.selectionSubjectId = selectionSubjectId;
+	}
 }

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

@@ -32,7 +32,7 @@ public interface SellOrderService extends BaseService<Integer, SellOrder> {
      * @param studentPaymentOrder
      * @return
      */
-    List<SellOrder> addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails, StudentPaymentOrder studentPaymentOrder, MusicGroup musicGroup);
+    List<SellOrder> addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails, StudentPaymentOrder studentPaymentOrder, MusicGroup musicGroup,BigDecimal musicRemitFee);
 
     void batchInsert(List<SellOrder> sellOrders);
 

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/SubjectChangeService.java

@@ -80,5 +80,10 @@ public interface SubjectChangeService extends BaseService<Integer, SubjectChange
      * @param balance
      * @return
      */
-    List<SellOrder> addSellOrder(Long orderId, String musicGroupId, List<Integer> goodsIds, BigDecimal totalAmount, BigDecimal balance,KitGroupPurchaseTypeEnum kitGroupPurchaseType);
+    List<SellOrder> addSellOrder(Long orderId,
+                                 String musicGroupId,
+                                 List<Integer> goodsIds,
+                                 BigDecimal totalAmount,
+                                 BigDecimal balance,
+                                 KitGroupPurchaseTypeEnum kitGroupPurchaseType,BigDecimal couponRemitAmount);
 }

+ 13 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -308,6 +308,7 @@ public class ExportServiceImpl implements ExportService {
             row.setPaymentChannel(paymentChannel);
             row.setId(i);
             row.setRepairFee(row.getRepairFee().add(row.getMaintenanceFee()).add(row.getMaintenanceProductFee()));
+            row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitFee()));
             i++;
         }
 
@@ -317,9 +318,13 @@ public class ExportServiceImpl implements ExportService {
 
         HSSFWorkbook workbook = null;
         try {
-            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "云教练", "押金", "乐器", "教辅费用", "上门费", "账户充值", "其它", "手续费", "到账时间",
+            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额", "现金支付", "余额支付", "优惠金额",
+                    "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "云教练", "押金", "乐器", "教辅费用", "上门费",
+                    "账户充值", "其它", "手续费", "到账时间",
                     "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
-            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "cloudTeacherFee", "leaseFee", "musicalFee", "teachingFee", "visitFee", "rechargeFee", "otherFee", "transferFee", "payTime", "musicGroupId",
+            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount", "expectAmount", "actualAmount", "balancePaymentAmount",  "couponRemitFee",
+                    "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "cloudTeacherFee",
+                    "leaseFee", "musicalFee", "teachingFee", "visitFee", "rechargeFee", "otherFee", "transferFee", "payTime", "musicGroupId",
                     "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
             workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
             workbook.write(fileOutputStream);
@@ -631,6 +636,7 @@ public class ExportServiceImpl implements ExportService {
                 paymentChannel = "余额";
             }
             row.setPaymentChannel(paymentChannel);
+            row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitFee()));
             i++;
         }
 
@@ -786,9 +792,12 @@ public class ExportServiceImpl implements ExportService {
 
         HSSFWorkbook workbook = null;
         try {
-            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "应付金额", "现金支付", "余额支付", "分润账户", "分润金额", "分配余额", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "云教练", "押金", "乐器", "教辅费用", "上门费", "账户充值", "其它", "手续费", "到账时间",
+            String[] header = {"序号", "学生姓名", "交易流水号", "订单编号", "收款渠道", "收款账户", "订单金额", "应付金额", "现金支付", "余额支付", "分润账户", "分润金额", "分配余额", "优惠金额", "乐团课", "VIP课", "网管课", "乐理课", "考级", "维修费用", "云教练", "押金", "乐器", "教辅费用", "上门费", "账户充值", "其它", "手续费", "到账时间",
                     "关联乐团ID/VIP课ID", "课程形态", "零星收款类别", "专业", "分部", "教学点", "合作单位", "乐团主管", "备注"};
-            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "expectAmount", "actualAmount", "balancePaymentAmount", "routeMerNo", "routeAmount", "routeBalance", "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "cloudTeacherFee", "leaseFee", "musicalFee", "teachingFee", "visitFee", "rechargeFee", "otherFee", "transferFee", "payTime", "musicGroupId",
+            String[] body = {"id", "user.username", "transNo", "orderNo", "paymentChannel", "merNos", "orderAmount"
+                    , "expectAmount", "actualAmount", "balancePaymentAmount", "routeMerNo", "routeAmount", "routeBalance",  "couponRemitFee",
+                    "musicGroupCourseFee", "vipCourseFee", "practiceCourseFee", "theoryCourseFee", "degreeFee", "repairFee", "cloudTeacherFee", "leaseFee", "musicalFee", "teachingFee", "visitFee",
+                    "rechargeFee", "otherFee", "transferFee", "payTime", "musicGroupId",
                     "groupType.desc", "sporadicType", "subjectName", "organName", "schoolName", "cooperationOrganName", "eduTeacher", "memo"};
             workbook = POIUtil.exportExcel(header, body, studentPaymentOrderExportDtos);
             workbook.write(fileOutputStream);

+ 5 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupSubjectPlanServiceImpl.java

@@ -184,18 +184,20 @@ public class MusicGroupSubjectPlanServiceImpl extends BaseServiceImpl<Integer, M
 				musicGroupSubjectGoodsAndInfo.setMemberPrivilegesItemList(memberRankPrivilegesService.queryByMemberRankId(1));
 			}
 			
-			Map<CourseScheduleType, BigDecimal> memberCoursePrice = new HashMap<CourseScheduleType, BigDecimal>();
+			Map<String, BigDecimal> memberCoursePrice = new HashMap<String, BigDecimal>();
 			
 			OrganizationCourseUnitPriceSettings singleUnitPriceSettings = organizationCourseUnitPriceSettingsService.queryByOrganIdAndCourseTypeAndChargeType(musicGroup.getOrganId(), CourseScheduleType.SINGLE, musicGroup.getChargeTypeId());
 			if (singleUnitPriceSettings != null) {
-				memberCoursePrice.put(CourseScheduleType.SINGLE,
+				memberCoursePrice.put(CourseScheduleType.SINGLE.name(),
 						singleUnitPriceSettings.getUnitPrice().multiply(new BigDecimal(1980)).setScale(0, BigDecimal.ROUND_HALF_UP));
 			}
 			OrganizationCourseUnitPriceSettings mixUnitPriceSettings = organizationCourseUnitPriceSettingsService.queryByOrganIdAndCourseTypeAndChargeType(musicGroup.getOrganId(), CourseScheduleType.MIX, musicGroup.getChargeTypeId());
 			if (mixUnitPriceSettings != null) {
-				memberCoursePrice.put(CourseScheduleType.MIX,
+				memberCoursePrice.put(CourseScheduleType.MIX.name(),
 						mixUnitPriceSettings.getUnitPrice().multiply(new BigDecimal(1980)).setScale(0, BigDecimal.ROUND_HALF_UP));
 			}
+			
+			musicGroupSubjectGoodsAndInfo.setMemberCoursePrice(memberCoursePrice);
 		}
 		
 		// 查询已购买内容

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java

@@ -324,6 +324,8 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
 
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setExpectAmount(amount.add(balance));
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setUserId(userId);
         studentPaymentOrder.setGroupType(GroupType.REPLACEMENT);
@@ -554,6 +556,7 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
             sellOrder.setActualAmount(sellOrderExpectAmount.subtract(sellOrderBalance));
             sellOrder.setBalanceAmount(sellOrderBalance);
             sellOrder.setExpectAmount(sellOrderExpectAmount);
+            sellOrder.setCouponRemitAmount(groupPurchasePriceMap.get(sellOrder.getGoodsId()).subtract(sellOrderExpectAmount));
             sellOrder.setNum(1);
             sellOrder.setUserId(order.getUserId());
             sellOrder.setPaymentChannel(order.getPaymentChannel());

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

@@ -161,26 +161,22 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 }
                 BigDecimal sellOrderActualAmount = BigDecimal.ZERO;
                 BigDecimal sellOrderBalance = BigDecimal.ZERO;
-                BigDecimal sellOrderCouponBalance = BigDecimal.ZERO;
                 if (complementPrice.compareTo(BigDecimal.ZERO) > 0) {
                     sellOrderActualAmount = complementGoodsPrice.get(sellOrder.getGoodsId()).multiply(new BigDecimal(sellOrder.getNum())).multiply(goodsActualAmount).divide(complementPrice, 2, BigDecimal.ROUND_DOWN);
                     sellOrderBalance = complementGoodsPrice.get(sellOrder.getGoodsId()).multiply(new BigDecimal(sellOrder.getNum())).multiply(goodsBalance).divide(complementPrice, 2, BigDecimal.ROUND_DOWN);
-                    sellOrderCouponBalance = complementGoodsPrice.get(sellOrder.getGoodsId()).multiply(new BigDecimal(sellOrder.getNum())).multiply(couponBalance).divide(complementPrice, 2, BigDecimal.ROUND_DOWN);
                 }
 
                 complementGoodsNum = complementGoodsNum - sellOrder.getNum();
                 if (complementGoodsNum <= 0) {
                     sellOrderActualAmount = goodsActualAmount.subtract(hasRouteSellOrderActualAmount);
                     sellOrderBalance = goodsBalance.subtract(hasRouteSellOrderBalance);
-                    sellOrderCouponBalance = couponBalance.subtract(hasRouteCouponBalance);
                 }
                 hasRouteSellOrderActualAmount = hasRouteSellOrderActualAmount.add(sellOrderActualAmount);
                 hasRouteSellOrderBalance = hasRouteSellOrderBalance.add(sellOrderBalance);
-                hasRouteCouponBalance = hasRouteCouponBalance.add(sellOrderCouponBalance);
 
-                sellOrder.setExpectAmount(sellOrderActualAmount.add(sellOrderBalance).add(sellOrderCouponBalance));
+                sellOrder.setExpectAmount(sellOrderActualAmount.add(sellOrderBalance));
                 sellOrder.setBalanceAmount(sellOrderBalance);
-                sellOrder.setCouponRemitAmount(sellOrderCouponBalance);
+//                sellOrder.setCouponRemitAmount(sellOrderCouponBalance);
                 sellOrder.setActualAmount(sellOrderActualAmount);
                 sellOrder.setOrganId(order.getOrganId());
                 sellOrder.setCooperationOrganId(musicGroup.getCooperationOrganId());
@@ -206,13 +202,37 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                 }
             }
         }
-        sellOrderDao.batchInsert(sellOrderList);
+        if (sellOrderList.size() > 0) {
+            //如果有优惠券金额
+            if (couponRemitFee.compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal reduce = sellOrderList.stream().map(e -> e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                List<SellOrder> sellOrders = sellOrderList.stream().filter(e -> e.getExpectAmount().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
+                //可用优惠券金额
+                BigDecimal subCouponMarketAmount = couponRemitFee;
+                for (int j = 0; j < sellOrders.size(); j++) {
+                    SellOrder sellOrder = sellOrders.get(j);
+                    //如果是最后一件商品
+                    if (j == sellOrders.size() - 1) {
+                        sellOrder.setCouponRemitAmount(subCouponMarketAmount);
+                    } else {
+                        //获取比例
+                        BigDecimal ratioAmount = sellOrder.getExpectAmount().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
+                        //获取分配的减免金额
+                        BigDecimal multiply = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        subCouponMarketAmount = subCouponMarketAmount.subtract(multiply);
+                        sellOrder.setCouponRemitAmount(multiply);
+                    }
+                }
+            }
+            sellOrderDao.batchInsert(sellOrderList);
+        }
         return sellOrderList;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public List<SellOrder> addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails, StudentPaymentOrder studentPaymentOrder, MusicGroup musicGroup) {
+    public List<SellOrder> addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails,
+                                                    StudentPaymentOrder studentPaymentOrder, MusicGroup musicGroup,BigDecimal musicRemitFee) {
         List<SellOrder> sellOrders = new ArrayList<>();
         //总余额支付
         BigDecimal totalBalance = studentPaymentOrder.getBalancePaymentAmount() != null ? studentPaymentOrder.getBalancePaymentAmount() : BigDecimal.ZERO;
@@ -304,6 +324,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
                     sellOrder.setActualAmount(sellOrderExpectAmount.subtract(sellOrderBalance));
                     sellOrder.setBalanceAmount(sellOrderBalance);
                     sellOrder.setExpectAmount(sellOrderExpectAmount);
+//                    sellOrder.setCouponRemitAmount(goods.getGroupPurchasePrice().subtract(sellOrderExpectAmount));
                     sellOrder.setNum(1);
                     sellOrder.setUserId(studentPaymentOrder.getUserId());
                     sellOrder.setPaymentChannel(studentPaymentOrder.getPaymentChannel());
@@ -337,6 +358,27 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             sellOrders.addAll(sellOrderList);
         }
         if (sellOrders.size() > 0) {
+            //如果有优惠券金额
+            if (musicRemitFee.compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal reduce = sellOrders.stream().map(e -> e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                List<SellOrder> sellOrderList = sellOrders.stream().filter(e -> e.getExpectAmount().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
+                //可用优惠券金额
+                BigDecimal subCouponMarketAmount = musicRemitFee;
+                for (int j = 0; j < sellOrderList.size(); j++) {
+                    SellOrder sellOrder = sellOrderList.get(j);
+                    //如果是最后一件商品
+                    if (j == sellOrderList.size() - 1) {
+                        sellOrder.setCouponRemitAmount(subCouponMarketAmount);
+                    } else {
+                        //获取比例
+                        BigDecimal ratioAmount = sellOrder.getExpectAmount().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
+                        //获取分配的减免金额
+                        BigDecimal multiply = musicRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        subCouponMarketAmount = subCouponMarketAmount.subtract(multiply);
+                        sellOrder.setCouponRemitAmount(multiply);
+                    }
+                }
+            }
             sellOrderDao.batchInsert(sellOrders);
         }
         return sellOrders;

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

@@ -1206,7 +1206,18 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
             //销售订单详情
             if (orderDetails.size() > 0) {
-                sellOrderService.addOrderDetail2SellOrder(orderDetails, studentPaymentOrder, musicGroup);
+                BigDecimal couponRemitFee = studentPaymentOrder.getCouponRemitFee();
+                if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0){
+                    BigDecimal musicFee = orderDetails.stream().filter(o -> o.getType().getCode().equals("MUSICAL")
+                            || o.getType().getCode().equals("ACCESSORIES") || o.getType().getCode().equals("TEACHING"))
+                            .map(o -> o.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                    BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
+                    //获取比例
+                    BigDecimal ratioAmount = musicFee.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
+                    //获取分配的减免金额
+                    couponRemitFee = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                }
+                sellOrderService.addOrderDetail2SellOrder(orderDetails, studentPaymentOrder, musicGroup,couponRemitFee);
             }
 
             //课程处理

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

@@ -1013,6 +1013,28 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             sellOrder.setCooperationOrganId(studentGoodsSell.getCooperationOrganId());
         }
         if (sellOrderList.size() > 0) {
+            //如果有优惠券金额
+            BigDecimal couponMarketAmount = studentGoodsSell.getCouponMarketAmount();
+            if (couponMarketAmount.compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal reduce = sellOrderList.stream().map(e -> e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                List<SellOrder> sellOrders = sellOrderList.stream().filter(e -> e.getExpectAmount().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
+                //可用优惠券金额
+                BigDecimal subCouponMarketAmount = couponMarketAmount;
+                for (int i = 0; i < sellOrders.size(); i++) {
+                    SellOrder sellOrder = sellOrders.get(i);
+                    //如果是最后一件商品
+                    if (i == sellOrders.size() - 1) {
+                        sellOrder.setCouponRemitAmount(subCouponMarketAmount);
+                    } else {
+                        //获取比例
+                        BigDecimal ratioAmount = sellOrder.getExpectAmount().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
+                        //获取分配的减免金额
+                        BigDecimal multiply = couponMarketAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        subCouponMarketAmount = subCouponMarketAmount.subtract(multiply);
+                        sellOrder.setCouponRemitAmount(multiply);
+                    }
+                }
+            }
             sellOrderService.batchInsert(sellOrderList);
         }
     }

+ 42 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java

@@ -375,7 +375,12 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
             if (StringUtils.isNotBlank(goodsIds)) {
                 List<Integer> goodsIdList = Arrays.stream(goodsIds.split(",")).map(Integer::parseInt).collect(Collectors.toList());
                 //添加新订单
-                this.addSellOrder(studentPaymentOrder.getId(), subjectChange.getMusicGroupId(), goodsIdList, BigDecimal.ZERO, BigDecimal.ZERO, subjectChange.getKitGroupPurchaseType());
+                this.addSellOrder(studentPaymentOrder.getId(),
+                        subjectChange.getMusicGroupId(),
+                        goodsIdList,
+                        BigDecimal.ZERO,
+                        BigDecimal.ZERO,
+                        subjectChange.getKitGroupPurchaseType(),BigDecimal.ZERO);
             }
             //乐保处理
             studentInstrumentService.subjectChangeUpdateInstrument(subjectChange);
@@ -625,7 +630,12 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
                 	sellOrderService.refundByOrderId(subjectChange.getOriginalOrderId().longValue(), false);
                 }
                 //添加新订单
-                List<SellOrder> sellOrders = this.addSellOrder(studentPaymentOrder.getId(), subjectChange.getMusicGroupId(), goodsIdList, studentPaymentOrder.getExpectAmount(), studentPaymentOrder.getBalancePaymentAmount(), subjectChange.getKitGroupPurchaseType());
+                List<SellOrder> sellOrders = this.addSellOrder(studentPaymentOrder.getId(),
+                        subjectChange.getMusicGroupId(),
+                        goodsIdList,
+                        studentPaymentOrder.getExpectAmount(),
+                        studentPaymentOrder.getBalancePaymentAmount(),
+                        subjectChange.getKitGroupPurchaseType(),studentPaymentOrder.getCouponRemitFee());
                 if(sellOrders != null && sellOrders.size() > 0){
                     SubjectChange change = subjectChangeDao.get(subjectChange.getId());
                     BigDecimal instrumentAmount = sellOrders.stream().filter(e -> e.getType() == SellTypeEnum.INSTRUMENT).map(e -> e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -742,7 +752,12 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
 
     @Override
     @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-    public List<SellOrder> addSellOrder(Long orderId, String musicGroupId, List<Integer> goodsIds, BigDecimal totalAmount, BigDecimal balance, KitGroupPurchaseTypeEnum kitGroupPurchaseType) {
+    public List<SellOrder> addSellOrder(Long orderId,
+                                        String musicGroupId,
+                                        List<Integer> goodsIds,
+                                        BigDecimal totalAmount,
+                                        BigDecimal balance,
+                                        KitGroupPurchaseTypeEnum kitGroupPurchaseType,BigDecimal couponRemitAmount) {
         if (goodsIds == null || goodsIds.size() <= 0) {
             return null;
         }
@@ -865,7 +880,30 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
                 }
             }
         }
-        sellOrderDao.batchInsert(sellOrderList);
+        if (sellOrderList.size() > 0) {
+            //如果有优惠券金额
+            if (couponRemitAmount.compareTo(BigDecimal.ZERO) > 0) {
+                BigDecimal reduce = sellOrderList.stream().map(e -> e.getExpectAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                List<SellOrder> sellOrders = sellOrderList.stream().filter(e -> e.getExpectAmount().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
+                //可用优惠券金额
+                BigDecimal subCouponMarketAmount = couponRemitAmount;
+                for (int j = 0; j < sellOrders.size(); j++) {
+                    SellOrder sellOrder = sellOrders.get(j);
+                    //如果是最后一件商品
+                    if (j == sellOrders.size() - 1) {
+                        sellOrder.setCouponRemitAmount(subCouponMarketAmount);
+                    } else {
+                        //获取比例
+                        BigDecimal ratioAmount = sellOrder.getExpectAmount().divide(reduce, 6, BigDecimal.ROUND_HALF_UP);
+                        //获取分配的减免金额
+                        BigDecimal multiply = couponRemitAmount.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                        subCouponMarketAmount = subCouponMarketAmount.subtract(multiply);
+                        sellOrder.setCouponRemitAmount(multiply);
+                    }
+                }
+            }
+            sellOrderService.batchInsert(sellOrderList);
+        }
         return sellOrderList;
     }
 }

+ 12 - 0
mec-biz/src/main/resources/config/mybatis/StudentPreRegistrationMapper.xml

@@ -177,6 +177,12 @@
             <if test="subjectId != null">
                 and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
             </if>
+            <if test="teacherRecommandSubjectId != null">
+                and (spr.teacher_recommand_subject_id_ = #{teacherRecommandSubjectId})
+            </if>
+            <if test="selectionSubjectId != null">
+                and (spr.selection_subject_id_ = #{selectionSubjectId})
+            </if>
             <if test="name != null">
                 and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or
                 spr.user_id_ like concat('%',#{name},'%'))
@@ -208,6 +214,12 @@
             <if test="subjectId != null">
                 and (spr.subject_first_ = #{subjectId} or spr.subject_second_ = #{subjectId})
             </if>
+            <if test="teacherRecommandSubjectId != null">
+                and (spr.teacher_recommand_subject_id_ = #{teacherRecommandSubjectId})
+            </if>
+            <if test="selectionSubjectId != null">
+                and (spr.selection_subject_id_ = #{selectionSubjectId})
+            </if>
             <if test="name != null">
                 and (spr.phone_ like concat('%',#{name},'%') or spr.user_name_ like concat('%',#{name},'%') or
                 spr.user_id_ like concat('%',#{name},'%'))

+ 50 - 22
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -1,38 +1,66 @@
 package com.ym.mec.student.controller;
 
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.ADD_STUDENT;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.StudentPreRegistrationDao;
+import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
 import com.ym.mec.biz.dal.dto.RenewParamDto;
-import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.entity.ApprovalStatus;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
+import com.ym.mec.biz.dal.entity.MusicGroupQuit;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
-import com.ym.mec.biz.dal.enums.*;
-import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.entity.StudentPreRegistration;
+import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PayStatus;
+import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.service.MusicGroupService;
+import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
+import com.ym.mec.biz.service.OrganizationService;
+import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.*;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.ADD_STUDENT;
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
 
 @RequestMapping("musicGroup")
 @Api(tags = "乐团服务")
@@ -122,7 +150,7 @@ public class MusicGroupController extends BaseController {
     @GetMapping("/getSubjectGoodsAndInfo")
     @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "String"),
             @ApiImplicitParam(name = "subjectId", value = "声部编号", required = true, dataType = "Integer")})
-    public HttpResponseResult getSubjectGoodsAndInfo(String musicGroupId, Integer subjectId) {
+    public HttpResponseResult<MusicGroupSubjectGoodsAndInfoDto> getSubjectGoodsAndInfo(String musicGroupId, Integer subjectId) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         return succeed(musicGroupSubjectPlanService.getSubjectGoodsAndInfo(musicGroupId, subjectId));
     }

+ 12 - 1
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -897,7 +897,18 @@ public class StudentOrderController extends BaseController {
         //销售订单详情
         if (orderDetails.size() > 0) {
             MusicGroup musicGroup = musicGroupService.get(order.getMusicGroupId());
-            sellOrders = sellOrderService.addOrderDetail2SellOrder(orderDetails, order, musicGroup);
+            BigDecimal couponRemitFee = order.getCouponRemitFee();
+            if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0){
+                BigDecimal musicFee = orderDetails.stream().filter(o -> o.getType().getCode().equals("MUSICAL")
+                        || o.getType().getCode().equals("ACCESSORIES") || o.getType().getCode().equals("TEACHING"))
+                        .map(o -> o.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                BigDecimal expectAmount = order.getExpectAmount();
+                //获取比例
+                BigDecimal ratioAmount = musicFee.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
+                //获取分配的减免金额
+                couponRemitFee = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+            }
+            sellOrders = sellOrderService.addOrderDetail2SellOrder(orderDetails, order, musicGroup,couponRemitFee);
         }
         return succeed(sellOrders);
 

+ 5 - 4
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -2655,15 +2655,16 @@ public class ExportController extends BaseController {
                     row.setReceiveStatusStr("自动确认");
                     break;
             }
+            row.setOrderAmount(row.getExpectAmount().add(row.getCouponRemitAmount()));
         }
         OutputStream outputStream = response.getOutputStream();
         try {
             HSSFWorkbook workbook = POIUtil.exportExcel(new String[]{
-                    "交易流水号", "订单号", "销售日期", "销售类型", "商品名称", "数量", "应付金额(元)", "余额支付(元)",
-                    "现金支付(元)", "销售成本(元)", "学员姓名", "交易方式", "收款账户", "账户类型", "扣减库存", "所属分部",
+                    "交易流水号", "订单号", "销售日期", "销售类型", "商品名称", "数量", "订单金额(元)", "应付金额(元)", "余额支付(元)",
+                    "现金支付(元)", "优惠金额(元)", "销售成本(元)", "学员姓名", "交易方式", "收款账户", "账户类型", "扣减库存", "所属分部",
                     "所属学校", "教务老师", "确认收货", "状态"}, new String[]{
-                    "transNo", "orderNo", "sellTime", "type.desc", "goodsName", "num", "expectAmount", "balanceAmount",
-                    "actualAmount", "sellCost", "userName", "paymentChannelStr", "merNo", "accountTypeStr", "stockType.msg", "organName",
+                    "transNo", "orderNo", "sellTime", "type.desc", "goodsName", "num", "orderAmount", "expectAmount", "balanceAmount",
+                    "actualAmount", "couponRemitAmount", "sellCost", "userName", "paymentChannelStr", "merNo", "accountTypeStr", "stockType.msg", "organName",
                     "schoolName", "eduTeacher", "receiveStatusStr", "status.msg"}, rows);
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");