|
@@ -818,8 +818,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
if (Objects.nonNull(couponPayParam) && Objects.nonNull(couponPayParam.getCouponTypeInfo())) {
|
|
|
//如果买乐器送课,那么就是0元买课,那么就先剔除送的课程再算优惠券,但是写入数据流水要加上
|
|
|
List<StudentPaymentOrderDetail> collect = new ArrayList<>();
|
|
|
- //按OrderDetailTypeEnum类型 进行聚合分组
|
|
|
- Map<OrderDetailTypeEnum, List<StudentPaymentOrderDetail>> orderDetailGroupList;
|
|
|
BigDecimal freeNewCourse = BigDecimal.ZERO;
|
|
|
//如果送课 并且 课程不为空,那么就是0元买课
|
|
|
if (goodsDto.isRemitCourseRFeeFlag() && CollectionUtils.isNotEmpty(newCourses)) {
|
|
@@ -833,17 +831,14 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
.filter(a -> newCourseType.contains(a.getType().getCode()))
|
|
|
.map(StudentPaymentOrderDetail::getRemitFee)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- orderDetailGroupList =
|
|
|
- WrapperUtil.groupList(collect, StudentPaymentOrderDetail::getType);
|
|
|
} else {
|
|
|
- orderDetailGroupList =
|
|
|
- WrapperUtil.groupList(studentPaymentOrderDetailList, StudentPaymentOrderDetail::getType);
|
|
|
+ collect = studentPaymentOrderDetailList;
|
|
|
}
|
|
|
|
|
|
//获取本次交易中各优惠券的使用信息
|
|
|
Map<String, CouponPayTypeInfo> couponParam = couponPayParam.getCouponTypeInfo();
|
|
|
//计算使用优惠券后的对应的商品应该均摊的金额
|
|
|
- calculateCoupon(couponParam, orderDetailGroupList);
|
|
|
+ calculateCoupon(couponParam, collect);
|
|
|
//获取使用了优惠券之后的总金额
|
|
|
BigDecimal useCouponAmount = WrapperUtil.sumList(studentPaymentOrderDetailList, StudentPaymentOrderDetail::getRemitFee);
|
|
|
//赋值
|
|
@@ -991,14 +986,15 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
|
|
|
* @param couponParam 优惠券的信息
|
|
|
* @param orderDetailGroupList 订单信息
|
|
|
*/
|
|
|
- private void calculateCoupon(Map<String, CouponPayTypeInfo> couponParam,
|
|
|
- Map<OrderDetailTypeEnum, List<StudentPaymentOrderDetail>> orderDetailGroupList) {
|
|
|
+ private void calculateCoupon(Map<String, CouponPayTypeInfo> couponParam,List<StudentPaymentOrderDetail> paymentOrderDetails) {
|
|
|
List<StudentPaymentOrderDetail> singleTypeList = new ArrayList<>();
|
|
|
List<StudentPaymentOrderDetail> allTypeList = new ArrayList<>();
|
|
|
+ paymentOrderDetails.forEach(e->e.setCouponDetailTypeEnum(CouponDetailTypeEnum.valueOf(CouponDetailTypeEnum.of(e.getType().getCode()))));
|
|
|
+ Map<CouponDetailTypeEnum, List<StudentPaymentOrderDetail>> orderDetailGroupList = paymentOrderDetails.stream().collect(Collectors.groupingBy(e -> e.getCouponDetailTypeEnum()));
|
|
|
//先处理”非全类型券“的数据
|
|
|
orderDetailGroupList.forEach((e, list) -> {
|
|
|
//根据OrderDetailTypeEnum类型找到对应的券类型,默认全类型
|
|
|
- String couponDetailCode = CouponDetailTypeEnum.of(e.getCode());
|
|
|
+ String couponDetailCode = e.getCode();
|
|
|
//获取本次支付中该类型优惠券的详情,如果该商品没有找到本次支付时选择的优惠券则当作全类型
|
|
|
CouponPayTypeInfo couponPayTypeInfo = couponParam.get(couponDetailCode);
|
|
|
//全类型券数据后面处理
|