فهرست منبع

续费支持优惠券

zouxuan 3 سال پیش
والد
کامیت
4ad19459d0

+ 40 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PayParamBasicDto.java

@@ -0,0 +1,40 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.List;
+
+public class PayParamBasicDto {
+    @ApiModelProperty(value = "是否使用余额", required = false)
+    private Boolean isUseBalancePayment = false;
+
+    @ApiModelProperty(value = "是否继续支付", required = false)
+    private Boolean isRepeatPay = false;
+
+    @ApiModelProperty(value = "优惠券列表", required = false)
+    private List<Integer> couponIdList;
+
+    public List<Integer> getCouponIdList() {
+        return couponIdList;
+    }
+
+    public void setCouponIdList(List<Integer> couponIdList) {
+        this.couponIdList = couponIdList;
+    }
+
+    public Boolean getUseBalancePayment() {
+        return isUseBalancePayment;
+    }
+
+    public void setUseBalancePayment(Boolean useBalancePayment) {
+        isUseBalancePayment = useBalancePayment;
+    }
+
+    public Boolean getRepeatPay() {
+        return isRepeatPay;
+    }
+
+    public void setRepeatPay(Boolean repeatPay) {
+        isRepeatPay = repeatPay;
+    }
+}

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RenewParamDto.java

@@ -0,0 +1,27 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+public class RenewParamDto extends PayParamBasicDto{
+    @ApiModelProperty(value = "缴费项目编号", required = false)
+    private Long calenderId;
+
+    @ApiModelProperty(value = "学员编号", required = false)
+    private Integer userId;
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Long getCalenderId() {
+        return calenderId;
+    }
+
+    public void setCalenderId(Long calenderId) {
+        this.calenderId = calenderId;
+    }
+}

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentGoodsSell.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.entity;
 
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
+import com.ym.mec.biz.dal.dto.SysCouponCodeDto;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
@@ -67,6 +68,17 @@ public class StudentGoodsSell {
 	@ApiModelProperty(value = "优惠券列表", required = false)
 	private List<Integer> couponIdList;
 
+	@ApiModelProperty(value = "优惠券详情列表", required = false)
+	private List<SysCouponCodeDto> couponCodeDtoList;
+
+	public List<SysCouponCodeDto> getCouponCodeDtoList() {
+		return couponCodeDtoList;
+	}
+
+	public void setCouponCodeDtoList(List<SysCouponCodeDto> couponCodeDtoList) {
+		this.couponCodeDtoList = couponCodeDtoList;
+	}
+
 	public BigDecimal getCouponMarketAmount() {
 		return couponMarketAmount;
 	}

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

@@ -181,12 +181,9 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 
 	/**
 	 *  续费
-	 * @param calenderId 缴费项目编号
-	 * @param userId 用户编号
-	 * @param isUseBalancePayment 是否使用余额付款
 	 * @return
 	 */
-	Map renew(Long calenderId, Integer userId, boolean isUseBalancePayment) throws Exception;
+	Map renew(RenewParamDto renewParamDto) throws Exception;
 
 	/**
 	 * 学生支付订单

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentGoodsSellService.java

@@ -54,4 +54,10 @@ public interface StudentGoodsSellService extends BaseService<Integer, StudentGoo
      */
     List<StudentInstrument> saveStudentInstrument(StudentPaymentOrder order);
 
+    /**
+     * 获取商品订单详情
+     * @param goodsSellId
+     * @return
+     */
+    StudentGoodsSell getStudentGoodsOrder(Integer goodsSellId);
 }

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

@@ -2,11 +2,13 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.MusicalListDetailDto;
 import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.BaseService;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface StudentPaymentOrderDetailService extends BaseService<Long, StudentPaymentOrderDetail> {
@@ -18,7 +20,7 @@ public interface StudentPaymentOrderDetailService extends BaseService<Long, Stud
      * @param studentPaymentOrderDetailList
      * @return
      */
-    int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList);
+    int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList, BigDecimal couponRemitFee);
 
     /**
      * 查询注册支付的订单详情

+ 29 - 57
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -4,6 +4,7 @@ import static com.ym.mec.biz.dal.entity.ApprovalStatus.PROCESSING;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.CLOSE;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.ING;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*;
 import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
 
 import java.io.IOException;
@@ -21,6 +22,8 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.dal.dto.*;
+import com.ym.mec.biz.service.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -74,18 +77,6 @@ import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
-import com.ym.mec.biz.dal.dto.BasicUserDto;
-import com.ym.mec.biz.dal.dto.CloseMusicGroupDto;
-import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
-import com.ym.mec.biz.dal.dto.HighClassGroupDto;
-import com.ym.mec.biz.dal.dto.MusicCardDto;
-import com.ym.mec.biz.dal.dto.MusicGroupBasicDto;
-import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.dto.SporadicPayDto;
-import com.ym.mec.biz.dal.dto.StudentApplyInstrumentDto;
-import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
-import com.ym.mec.biz.dal.dto.SubjectRegisterDto;
-import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
 import com.ym.mec.biz.dal.entity.ApprovalStatus;
 import com.ym.mec.biz.dal.entity.ChargeType;
 import com.ym.mec.biz.dal.entity.ClassGroup;
@@ -152,29 +143,6 @@ import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
 import com.ym.mec.biz.dal.page.MusicMemberQueryInfo;
 import com.ym.mec.biz.event.source.GroupEventSource;
-import com.ym.mec.biz.service.ClassGroupService;
-import com.ym.mec.biz.service.ClassGroupStudentMapperService;
-import com.ym.mec.biz.service.CloudTeacherOrderService;
-import com.ym.mec.biz.service.ContractService;
-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
-import com.ym.mec.biz.service.GoodsService;
-import com.ym.mec.biz.service.ImGroupMemberService;
-import com.ym.mec.biz.service.ImGroupService;
-import com.ym.mec.biz.service.ImUserFriendService;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
-import com.ym.mec.biz.service.MusicGroupService;
-import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService;
-import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
-import com.ym.mec.biz.service.PayService;
-import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
-import com.ym.mec.biz.service.StudentRegistrationService;
-import com.ym.mec.biz.service.StudentService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysMessageService;
-import com.ym.mec.biz.service.SysUserCashAccountDetailService;
-import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.ImGroupMember;
@@ -352,6 +320,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Autowired
     private StudentService studentService;
 
+    @Autowired
+    private SysCouponCodeService sysCouponCodeService;
+
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
 
     private SimpleDateFormat sdf_hms = new SimpleDateFormat("HH:mm:ss");
@@ -2360,7 +2331,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     				for (StudentPaymentOrderDetail detail : orderDetailList) {
 
     					// 退乐器费用
-    					if (returnFeeDto.getIsReturnMusicalFee() && detail.getType() == OrderDetailTypeEnum.MUSICAL) {
+    					if (returnFeeDto.getIsReturnMusicalFee() && detail.getType() == MUSICAL) {
     						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
     						
     						StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId);
@@ -2372,7 +2343,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     					// 退教辅费用
     					if (returnFeeDto.getIsReturnAccessoriesFee()
-    							&& (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING)) {
+    							&& (detail.getType() == ACCESSORIES || detail.getType() == TEACHING)) {
     						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
     					}
     				}
@@ -2682,7 +2653,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 				for (StudentPaymentOrderDetail detail : orderDetailList) {
 
 					// 退乐器费用
-					if (isRefundInstrumentFee && detail.getType() == OrderDetailTypeEnum.MUSICAL) {
+					if (isRefundInstrumentFee && detail.getType() == MUSICAL) {
 						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
 						
 						StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId);
@@ -2694,7 +2665,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
 					// 退教辅费用
 					if (isRefundTeachingAssistantsFee
-							&& (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING)) {
+							&& (detail.getType() == ACCESSORIES || detail.getType() == TEACHING)) {
 						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
 					}
 				}
@@ -2730,7 +2701,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public Map renew(Long calenderId, Integer userId, boolean isUseBalancePayment) throws Exception {
+    public Map renew(RenewParamDto renewParamDto) throws Exception {
+        Long calenderId = renewParamDto.getCalenderId();
+        Integer userId = renewParamDto.getUserId();
         MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
         if (calender == null) {
             throw new BizException("缴费项目不存在");
@@ -2755,12 +2728,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 		throw new BizException("订单还在交易中,请稍后重试");
                 	}
                 }
-                
                 oldStudentPaymentOrder.setStatus(CLOSE);
                 studentPaymentOrderService.update(oldStudentPaymentOrder);
                 if (oldStudentPaymentOrder.getBalancePaymentAmount() != null && oldStudentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                     sysUserCashAccountService.updateBalance(oldStudentPaymentOrder.getUserId(), oldStudentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "关闭订单");
                 }
+                sysCouponCodeService.quit(oldStudentPaymentOrder.getCouponCodeId());
             }
         }
         String orderNo = idGeneratorService.generatorId("payment") + "";
@@ -2768,7 +2741,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         BigDecimal amount = calenderDetail.getExpectAmount().add(calenderDetail.getExpectMemberAmount());
 
         Date date = new Date();
-        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+        //使用优惠券
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(renewParamDto.getCouponIdList(),amount);
+        amount = studentPaymentOrder.getActualAmount();
         studentPaymentOrder.setGroupType(GroupType.MUSIC);
         studentPaymentOrder.setUserId(userId);
         studentPaymentOrder.setOrderNo(orderNo);
@@ -2778,8 +2753,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		} else {
 			studentPaymentOrder.setType(OrderTypeEnum.RENEW);
 		}
-        studentPaymentOrder.setExpectAmount(amount);
-        studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setMusicGroupId(calender.getMusicGroupId());
         studentPaymentOrder.setBatchNo(calender.getId() + "");
@@ -2814,19 +2787,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     		cloudTeacherOrderService.insert(cloudTeacherOrder);
         }
 
-        /*ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
-        StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE);
-        studentPaymentOrderDetail.setPrice(amount);
-        studentPaymentOrderDetail.setCreateTime(date);
-        studentPaymentOrderDetail.setUpdateTime(date);
-        studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-        studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
-
-        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);*/
-
         BigDecimal balance = BigDecimal.ZERO;
-        if (isUseBalancePayment || amount.doubleValue() == 0) {
+        if (renewParamDto.getUseBalancePayment() || amount.doubleValue() == 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
             if (userCashAccount == null) {
                 throw new BizException("用户账户找不到");
@@ -3047,7 +3009,17 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 }
             }
             if (paymentOrderDetails.size() > 0) {
-                studentPaymentOrderDetailService.batchAdd(paymentOrderDetails);
+                studentPaymentOrderDetailService.batchAdd(paymentOrderDetails,studentPaymentOrder.getCouponRemitFee());
+                //获取实际支付课程费用
+                courseFee = paymentOrderDetails.stream().filter(e->e.getType() != MUSICAL && e.getType() != ACCESSORIES
+                        && e.getType() != TEACHING && e.getType() != OTHER && e.getType() != DEGREE_REGISTRATION
+                        && e.getType() != MAINTENANCE && e.getType() != CLOUD_TEACHER && e.getType() != CLOUD_TEACHER_PLUS).map(t -> t.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                //获取云教练订单费用
+                if(cloudTeacherOrder != null){
+                    BigDecimal cloudTeacherFee = paymentOrderDetails.stream().filter(e->e.getType() == CLOUD_TEACHER).map(t -> t.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+                    cloudTeacherOrder.setAmount(cloudTeacherFee);
+                    cloudTeacherOrderService.update(cloudTeacherOrder);
+                }
             }
 
             //缴费

+ 23 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java

@@ -2,13 +2,11 @@ package com.ym.mec.biz.service.impl;
 
 
 import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.biz.dal.dao.GoodsDao;
-import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
-import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
+import com.ym.mec.biz.dal.dto.SysCouponCodeDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentGoodsSell;
 import com.ym.mec.biz.dal.entity.StudentInstrument;
@@ -16,6 +14,7 @@ import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.page.GoodsSellQueryInfo;
 import com.ym.mec.biz.service.StudentGoodsSellService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -25,10 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, StudentGoodsSell> implements StudentGoodsSellService {
@@ -41,6 +38,10 @@ public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, Studen
     private GoodsDao goodsDao;
     @Autowired
     private StudentInstrumentDao studentInstrumentDao;
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+    @Autowired
+    private SysCouponCodeDao sysCouponCodeDao;
 
     @Override
     public BaseDAO<Integer, StudentGoodsSell> getDAO() {
@@ -144,5 +145,18 @@ public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, Studen
         return studentInstruments;
     }
 
-
+    @Override
+    public StudentGoodsSell getStudentGoodsOrder(Integer goodsSellId) {
+        StudentGoodsSell studentGoodsSell = studentGoodsSellDao.get(goodsSellId);
+        //获取优惠券列表
+        StudentPaymentOrder paymentOrder = studentPaymentOrderDao.findOrderByOrderNo(studentGoodsSell.getOrderNo());
+        if(paymentOrder != null){
+            String couponCodeId = paymentOrder.getCouponCodeId();
+            if(StringUtils.isNotEmpty(couponCodeId)){
+                List<Integer> couponIdList = Arrays.stream(couponCodeId.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
+                studentGoodsSell.setCouponCodeDtoList(sysCouponCodeDao.findByIdList(couponIdList));
+            }
+        }
+        return studentGoodsSell;
+    }
 }

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

@@ -84,10 +84,36 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
     }
 
     @Override
-    public int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList) {
+    public int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList, BigDecimal couponRemitFee) {
         if(studentPaymentOrderDetailList == null || studentPaymentOrderDetailList.size() == 0){
             return 0;
         }
+        //按比例分摊优惠券减免金额
+        if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0){
+            //待分配减免
+            BigDecimal waitRemitFee = couponRemitFee;
+            //已使用减免金额
+            BigDecimal useRemitFee = BigDecimal.ZERO;
+            List<StudentPaymentOrderDetail> collect = studentPaymentOrderDetailList.stream().filter(e -> e.getPrice().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
+            if(collect.size() == 0){
+                throw new BizException("订单金额异常");
+            }
+            for (int i = 0; i < collect.size(); i++) {
+                StudentPaymentOrderDetail orderDetail = collect.get(i);
+                //如果是最后一件商品
+                if (i == collect.size() - 1) {
+                    orderDetail.setPrice(orderDetail.getPrice().subtract(waitRemitFee));
+                } else {
+                    //获取比例
+                    BigDecimal ratioAmount = orderDetail.getPrice().divide((couponRemitFee.add(orderDetail.getPrice())), 6, BigDecimal.ROUND_HALF_UP);
+                    //获取分配的减免金额
+                    BigDecimal multiply = ratioAmount.multiply(couponRemitFee).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    waitRemitFee = waitRemitFee.subtract(multiply);
+                    useRemitFee = useRemitFee.add(multiply);
+                    orderDetail.setPrice(orderDetail.getPrice().subtract(multiply));
+                }
+            }
+        }
         return studentPaymentOrderDetailDao.batchAdd(studentPaymentOrderDetailList);
     }
 

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

@@ -153,7 +153,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 				spod.setUpdateTime(date);
 			}
 
-			studentPaymentOrderDetailService.batchAdd(details);
+			studentPaymentOrderDetailService.batchAdd(details,studentPaymentOrder.getCouponRemitFee());
 		}
 
 		String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");

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

@@ -735,7 +735,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             cloudTeacherOrderDetail.setIsRenew(0);
             studentPaymentOrderDetailList.add(cloudTeacherOrderDetail);
         }
-        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList,studentPaymentOrder.getCouponRemitFee());
 
         //增加缴费学生数,0元订单不增加报名人数(没买云教练/云教练+的)
         boolean paidZeroFlag = false;

+ 44 - 67
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -1,63 +1,38 @@
 package com.ym.mec.student.controller;
 
-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.CourseScheduleDao;
 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.RegisterPayDto;
-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.dto.RenewParamDto;
+import com.ym.mec.biz.dal.entity.*;
 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.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.biz.dal.enums.*;
+import com.ym.mec.biz.service.*;
 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 = "乐团服务")
@@ -227,31 +202,32 @@ public class MusicGroupController extends BaseController {
     }
 
     @ApiOperation(value = "续费")
-    @GetMapping("/renew")
-    @ApiImplicitParams({@ApiImplicitParam(name = "calenderId", value = "缴费项目编号", required = true, dataType = "Long"),
-            @ApiImplicitParam(name = "isUseBalancePayment", value = "是否使用余额付款", required = true, dataType = "Boolean")})
-    public HttpResponseResult renew(Long calenderId, Boolean isUseBalancePayment, boolean isRepeatPay) throws Exception {
+    @PostMapping("/renew")
+    public HttpResponseResult renew(@RequestBody RenewParamDto renewParamDto) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Integer userId = sysUser.getId();
-
-        if (isUseBalancePayment == null) {
-            isUseBalancePayment = false;
+        Long calenderId = renewParamDto.getCalenderId();
+        if(calenderId == null){
+            throw new BizException("参数校验失败");
         }
         MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
-        if (isRepeatPay == false) {
+        if (renewParamDto.getRepeatPay() == false) {
+            MusicGroupPaymentCalender.PaymentType paymentType = calender.getPaymentType();
+            OrderTypeEnum type = paymentType== ADD_STUDENT?OrderTypeEnum.ADD_STUDENT:paymentType == MUSIC_APPLY?OrderTypeEnum.APPLY:OrderTypeEnum.RENEW;
             // 判断是否存在支付中的记录
             List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.MUSIC, calender.getMusicGroupId(), userId, DealStatusEnum.ING,
-                    OrderTypeEnum.RENEW);
-            if (list.size() > 0) {
-            	StudentPaymentOrder applyOrder = list.get(list.size() - 1);
-            	// 查询订单状态
-                PayStatus payStatus = studentPaymentOrderService.queryPayStatus(applyOrder.getPaymentChannel(), applyOrder.getOrderNo(), applyOrder.getTransNo());
-                if(payStatus == PayStatus.SUCCESSED){
-            		throw new BizException("订单已支付成功,请勿重复支付");
-            	}else if(payStatus == PayStatus.PAYING){
-            		throw new BizException("订单还在交易中,请稍后重试");
-            	}
-                return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+                    type);
+            if (list != null && list.size() > 0) {
+                for (StudentPaymentOrder order : list) {
+                    // 查询订单状态
+                    PayStatus payStatus = studentPaymentOrderService.queryPayStatus(order.getPaymentChannel(), order.getOrderNo(), order.getTransNo());
+                    if(payStatus == PayStatus.SUCCESSED){
+                        throw new BizException("订单已支付成功,请勿重复支付");
+                    }else if(payStatus == PayStatus.PAYING){
+                        throw new BizException("订单还在交易中,请稍后重试");
+                    }
+                    return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+                }
             }
         }
         MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByCalenderIdAndUserId(calenderId, userId);
@@ -264,7 +240,8 @@ public class MusicGroupController extends BaseController {
         //缴费项目已开启或者单独开启
         Map renew;
         if (calender.getStatus() == PaymentCalenderStatusEnum.OPEN || calenderDetail.getOpen() == 1) {
-            renew = musicGroupService.renew(calenderId, userId, isUseBalancePayment);
+            renewParamDto.setUserId(userId);
+            renew = musicGroupService.renew(renewParamDto);
         } else if (calender.getStatus() == PaymentCalenderStatusEnum.OVER) {
             throw new BizException("缴费已截止,如有问题请联系指导老师");
         } else {

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

@@ -172,7 +172,7 @@ public class RepairController extends BaseController {
     @ApiOperation(value = "获取学员商品订单")
     @GetMapping("/getStudentGoodsOrder")
     public Object getStudentGoodsOrder(Integer goodsSellId) {
-        return succeed(studentGoodsSellService.get(goodsSellId));
+        return succeed(studentGoodsSellService.getStudentGoodsOrder(goodsSellId));
     }
 
     @ApiOperation(value = "确认收货")