Browse Source

支持优惠券

zouxuan 4 years ago
parent
commit
58082988a6
18 changed files with 113 additions and 89 deletions
  1. 13 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MaintenancePayDto.java
  2. 1 12
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java
  3. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementPayDto.java
  4. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherOrderService.java
  5. 13 3
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java
  6. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/SysCouponCodeService.java
  7. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java
  8. 34 10
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  9. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java
  10. 6 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java
  11. 5 13
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java
  12. 11 28
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  13. 4 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  14. 4 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysCouponCodeServiceImpl.java
  15. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java
  16. 0 4
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java
  17. 1 2
      mec-student/src/main/java/com/ym/mec/student/controller/ReplacementInstrumentActivityController.java
  18. 1 2
      mec-student/src/main/java/com/ym/mec/student/controller/StudentInstrumentController.java

+ 13 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MaintenancePayDto.java

@@ -3,8 +3,9 @@ package com.ym.mec.biz.dal.dto;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
+import java.util.List;
 
-public class MaintenancePayDto {
+public class MaintenancePayDto{
     @ApiModelProperty(value = "乐器列表id", required = true)
     private Long id;
 
@@ -14,6 +15,17 @@ public class MaintenancePayDto {
     @ApiModelProperty(value = "是否使用余额", required = true)
     private Boolean isUseBalance = 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 Long getId() {
         return id;
     }

+ 1 - 12
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java

@@ -9,7 +9,7 @@ import java.util.Map;
 /**
  * 学团注册支付
  */
-public class RegisterPayDto {
+public class RegisterPayDto extends PayParamBasicDto{
     //总金额
     private BigDecimal amount;
     //报名id
@@ -23,9 +23,6 @@ public class RegisterPayDto {
     //乐器id->type
     private Map<Long, String> goodsGroups;
 
-    //是否余额支付
-    private Boolean isUseBalancePayment = false;
-
     @ApiModelProperty(value = "可选课程的key",required = false)
     private List<String> courseKeys;
 
@@ -81,14 +78,6 @@ public class RegisterPayDto {
         this.otherGoodsIds = otherGoodsIds;
     }
 
-	public Boolean getIsUseBalancePayment() {
-		return isUseBalancePayment;
-	}
-
-	public void setIsUseBalancePayment(Boolean isUseBalancePayment) {
-		this.isUseBalancePayment = isUseBalancePayment;
-	}
-
     public Map<Long, String> getGoodsGroups() {
         return goodsGroups;
     }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementPayDto.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dto;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 public class ReplacementPayDto {
     @ApiModelProperty(value = "调查id", required = true)
@@ -17,6 +18,17 @@ public class ReplacementPayDto {
     @ApiModelProperty(value = "重新支付", required = true)
     private Boolean rePay = 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 Integer getId() {
         return id;
     }

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

@@ -21,7 +21,7 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
      * @param order
      * @return
      */
-    Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order);
+    Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order, BigDecimal cloudTeacherFee);
 
 
     /**

+ 13 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -123,12 +123,22 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      * @param buyMaintenance
      * @param buyCloudTeacher
      * @param buyCloudTeacherPlus
+     * @param couponIdList
      * @return
      * @throws Exception
      */
-    StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee,
-                                 List<MusicGroupSubjectGoodsGroup> goodsGroups, BigDecimal remitFee, BigDecimal courseRemitFee,
-                                 List<MusicGroupPaymentCalenderCourseSettings> newCourses, Boolean buyMaintenance, Boolean buyCloudTeacher, Boolean buyCloudTeacherPlus) throws Exception;
+    StudentPaymentOrder addOrder(StudentRegistration studentRegistration,
+                                 BigDecimal amount,
+                                 String orderNo,
+                                 String paymentChannel,
+                                 BigDecimal courseFee,
+                                 List<MusicGroupSubjectGoodsGroup> goodsGroups,
+                                 BigDecimal remitFee,
+                                 BigDecimal courseRemitFee,
+                                 List<MusicGroupPaymentCalenderCourseSettings> newCourses,
+                                 Boolean buyMaintenance,
+                                 Boolean buyCloudTeacher,
+                                 Boolean buyCloudTeacherPlus,List<Integer> couponIdList) throws Exception;
 
     /**
      * 查询用户指定乐团的报名信息

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

@@ -55,9 +55,10 @@ public interface SysCouponCodeService extends BaseService<Long, SysCouponCode> {
      * 使用优惠券
      * @param couponIdList
      * @param amount
+     * @param useFlag 是否消耗优惠券
      * @return
      */
-    StudentPaymentOrder use(List<Integer> couponIdList, BigDecimal amount);
+    StudentPaymentOrder use(List<Integer> couponIdList, BigDecimal amount,Boolean useFlag);
 
     List<SysCouponCodeDto> findByIdList(List<Integer> couponIdList);
 

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

@@ -48,7 +48,7 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-	public Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order) {
+	public Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order,BigDecimal cloudTeacherFee) {
 		CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderDao.queryByOrderId(order.getId());
 
 		if (cloudTeacherOrder == null) {
@@ -56,6 +56,7 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
 		}
 		Date date = new Date();
 
+		cloudTeacherOrder.setAmount(cloudTeacherFee);
 		cloudTeacherOrder.setStatus(1);
 		cloudTeacherOrder.setUpdateTime(date);
 

+ 34 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -660,7 +660,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         Integer userId = sporadicPayDto.getUserId();
         String orderNo = idGeneratorService.generatorId("payment") + "";
         String channelType = "";
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(sporadicPayDto.getCouponIdList(),amount);
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(sporadicPayDto.getCouponIdList(),amount,true);
         amount = studentPaymentOrder.getActualAmount();
         studentPaymentOrder.setUserId(userId);
         studentPaymentOrder.setGroupType(GroupType.SPORADIC);
@@ -871,19 +871,32 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             cloudTeacherOrder.setMusicGroupId(musicGroup.getId());
         }
 
+
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
         }
 
-        if (amount.compareTo(BigDecimal.ZERO) < 0) {
-            throw new BizException("价格异常");
-        }
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
         String channelType = "";
 
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus());
-        studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration,
+                amount,
+                orderNo,
+                channelType,
+                courseFee,
+                goodsGroups,
+                remitFee,
+                courseRemitFee,
+                newCourses,
+                registerPayDto.getBuyMaintenance(),
+                registerPayDto.getBuyCloudTeacher(),
+                registerPayDto.getBuyCloudTeacherPlus(),registerPayDto.getCouponIdList());
+        amount = studentPaymentOrder.getActualAmount();
+        if (amount.compareTo(BigDecimal.ZERO) < 0) {
+            throw new BizException("价格异常");
+        }
+//        studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
         boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206);
         
         if(cloudTeacherOrder != null){
@@ -894,7 +907,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         BigDecimal balance = BigDecimal.ZERO;
-        if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+        if (registerPayDto.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
             if (userCashAccount == null) {
                 throw new BizException("用户账户找不到");
@@ -1144,7 +1157,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         String channelType = "";
 
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses, registerPayDto.getBuyMaintenance(), registerPayDto.getBuyCloudTeacher(), registerPayDto.getBuyCloudTeacherPlus());
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration,
+                amount,
+                orderNo,
+                channelType,
+                courseFee,
+                goodsGroups,
+                remitFee,
+                courseRemitFee,
+                newCourses,
+                registerPayDto.getBuyMaintenance(),
+                registerPayDto.getBuyCloudTeacher(),
+                registerPayDto.getBuyCloudTeacherPlus(),registerPayDto.getCouponIdList());
         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
         boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206);
         
@@ -1156,7 +1180,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         
         BigDecimal balance = BigDecimal.ZERO;
-        if (registerPayDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+        if (registerPayDto.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.get(userId);
             if (userCashAccount == null) {
                 throw new BizException("用户账户找不到");
@@ -2741,7 +2765,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         Date date = new Date();
         //使用优惠券
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(renewParamDto.getCouponIdList(),amount);
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(renewParamDto.getCouponIdList(),amount,true);
         amount = studentPaymentOrder.getActualAmount();
         studentPaymentOrder.setGroupType(GroupType.MUSIC);
         studentPaymentOrder.setUserId(userId);

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -3114,7 +3114,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             return BaseController.failed(HttpStatus.FOUND, errMessage);
         }
         //使用优惠券
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(),amount);
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(),amount,true);
         amount = studentPaymentOrder.getActualAmount();
         studentPaymentOrder.setUserId(practiceGroupBuyParams.getStudentId());
         studentPaymentOrder.setGroupType(GroupType.PRACTICE);
@@ -3562,7 +3562,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         }
 
         //使用优惠券
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(),amount);
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(),amount,true);
         amount = studentPaymentOrder.getActualAmount();
         studentPaymentOrder.setUserId(practiceGroupBuyParams.getStudentId());
         studentPaymentOrder.setGroupType(GroupType.PRACTICE);

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

@@ -86,6 +86,8 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
     private QuestionnaireQuestionDao questionnaireQuestionDao;
     @Autowired
     private QuestionnaireQuestionItemDao questionnaireQuestionItemDao;
+    @Autowired
+    private SysCouponCodeService sysCouponCodeService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -296,11 +298,12 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
 
         Goods goods = goodsDao.get(replacementInstrumentActivity.getInstrumentsId());
         BigDecimal orderAmount = goods.getGroupPurchasePrice();
-        BigDecimal amount = replacementPayDto.getAmount(); //扣除余额之前的金额
+
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(replacementPayDto.getCouponIdList(),replacementPayDto.getAmount(),true);
+        BigDecimal amount = studentPaymentOrder.getActualAmount();
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
         }
-
         String channelType = "";
         Date nowDate = new Date();
 
@@ -320,7 +323,6 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
         CooperationOrgan cooperationOrgan = cooperationOrganDao.get(replacementInstrumentActivity.getCooperationOrganId());
 
         String orderNo = idGeneratorService.generatorId("payment") + "";
-        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setUserId(userId);
@@ -465,6 +467,7 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                 sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐保购买支付失败");
             }
+            sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
 
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_SMS_PUSH_SPORADIC_PAYMENT_FAILED, map, null, 0, null, "STUDENT",
                     studentPaymentOrder.getActualAmount(), "乐器置换");

+ 5 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -8,6 +8,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import com.ym.mec.biz.service.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,16 +35,6 @@ import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
-import com.ym.mec.biz.service.ContractService;
-import com.ym.mec.biz.service.GoodsCategoryService;
-import com.ym.mec.biz.service.GoodsService;
-import com.ym.mec.biz.service.PayService;
-import com.ym.mec.biz.service.StudentInstrumentService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
-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.exception.BizException;
 import com.ym.mec.common.service.IdGeneratorService;
@@ -82,6 +73,8 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
     @Autowired
     private GoodsDao goodsDao;
+    @Autowired
+    private SysCouponCodeService sysCouponCodeService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -99,7 +92,8 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
         }
         Integer userId = studentInstrument.getStudentId();
         BigDecimal orderAmount = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
-        BigDecimal amount = maintenancePayDto.getAmount(); //扣除余额之前的金额
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(maintenancePayDto.getCouponIdList(),maintenancePayDto.getAmount(),true);
+        BigDecimal amount = studentPaymentOrder.getActualAmount();
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
         }
@@ -121,7 +115,6 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
         }
 
         String orderNo = idGeneratorService.generatorId("payment") + "";
-        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 
         studentPaymentOrder.setPaymentChannel("BALANCE");
         studentPaymentOrder.setUserId(userId);
@@ -129,7 +122,6 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
         studentPaymentOrder.setOrderNo(orderNo);
         studentPaymentOrder.setType(OrderTypeEnum.MAINTENANCE);
         studentPaymentOrder.setExpectAmount(orderAmount);
-        studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setBalancePaymentAmount(balance);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setMusicGroupId(studentInstrument.getId().toString());

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

@@ -20,6 +20,7 @@ import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
+import com.ym.mec.biz.service.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -116,26 +117,6 @@ import com.ym.mec.biz.dal.page.MusicGroupRecordStudentQueryInfo;
 import com.ym.mec.biz.dal.page.NoClassMusicStudentQueryInfo;
 import com.ym.mec.biz.dal.page.RegistrationOrPreQueryInfo;
 import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
-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.CourseScheduleService;
-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
-import com.ym.mec.biz.service.ImGroupMemberService;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
-import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
-import com.ym.mec.biz.service.SellOrderService;
-import com.ym.mec.biz.service.StudentInstrumentService;
-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.service.StudentService;
-import com.ym.mec.biz.service.SubjectService;
-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.ImResult;
@@ -240,6 +221,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     private OrganizationCloudTeacherFeeDao organizationCloudTeacherFeeDao;
     @Autowired
     private CloudTeacherOrderService cloudTeacherOrderService;
+    @Autowired
+    private SysCouponCodeService sysCouponCodeService;
 
     @Override
     public BaseDAO<Long, StudentRegistration> getDAO() {
@@ -618,15 +601,14 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     @Transactional(rollbackFor = Exception.class)
     public StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel,
-                                        BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses, Boolean buyMaintenance, Boolean buyCloudTeacher, Boolean buyCloudTeacherPlus) throws Exception {
+                                        BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, BigDecimal remitFee, BigDecimal courseRemitFee,
+                                        List<MusicGroupPaymentCalenderCourseSettings> newCourses, Boolean buyMaintenance, Boolean buyCloudTeacher, Boolean buyCloudTeacherPlus,List<Integer> couponIdList) throws Exception {
         Date date = new Date();
-        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(couponIdList,amount,true);
         studentPaymentOrder.setUserId(studentRegistration.getUserId());
         studentPaymentOrder.setGroupType(GroupType.MUSIC);
         studentPaymentOrder.setOrderNo(orderNo);
         studentPaymentOrder.setType(OrderTypeEnum.APPLY);
-        studentPaymentOrder.setExpectAmount(amount);
-        studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setPaymentChannel(paymentChannel);
         studentPaymentOrder.setMusicGroupId(studentRegistration.getMusicGroupId());
@@ -1234,7 +1216,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             studentInstrumentService.addOrderDetail2Instrument(studentPaymentOrder);
 
             //学生云教练处理
-            cloudTeacherOrderService.addOrderDetail2CloudTeacher(studentPaymentOrder);
+            BigDecimal cloudTeacherFee = allDetails.stream() .filter(o -> o.getType().getCode().equals("CLOUD_TEACHER"))
+                    .map(o -> o.getPrice().subtract(o.getRemitFee() == null ? BigDecimal.ZERO : o.getRemitFee()))
+                    .reduce(BigDecimal.ZERO, BigDecimal::add);
+            cloudTeacherOrderService.addOrderDetail2CloudTeacher(studentPaymentOrder,cloudTeacherFee);
 
             //合并学员处理
             if (studentRegistration.getIsMerge().equals(1) && studentPaymentOrder.getExpectAmount().compareTo(BigDecimal.ZERO) <= 0) {
@@ -1293,6 +1278,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                 sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "报名缴费失败");
             }
+            sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
             //三方乐团不发送缴费通知
             if (musicGroup.getOwnershipType() != null && musicGroup.getOwnershipType() == CooperationOrgan.OwnershipType.OWN) {
                 String studentApplyUrl = sysConfigDao.findConfigValue(SysConfigService.STUDENT_APPLY_URL) + studentRegistration.getMusicGroupId();
@@ -1302,9 +1288,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                         MessageTypeEnum.STUDENT_SMS_PAYMENT_FAILED, map, null, 0, null, "",
                         HttpUtil.getSortUrl(studentApplyUrl));
             }
-//            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,
-//                    MessageTypeEnum.STUDENT_SMS_PAYMENT_FAILED,map,null,0,"1",
-//                    studentApplyUrl);
         }
 
         return studentPaymentOrder;

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

@@ -208,7 +208,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             throw new BizException("操作失败:订单金额异常");
         }
         //使用优惠券
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(studentGoodsSell.getCouponIdList(),amount);
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(studentGoodsSell.getCouponIdList(),amount,studentGoodsSell.getType() != 1);
         amount = studentPaymentOrder.getActualAmount();
         // 判断金额是否正确
 //        if (studentGoodsSell.getTotalAmount().compareTo(amount) != 0) {
@@ -339,6 +339,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                     sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "关闭订单");
                 }
+                sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
             }
         }
         studentGoodsSellDao.update(studentGoodsSell);
@@ -347,7 +348,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         if(StringUtils.isNotEmpty(couponIds)){
             couponIdList = Arrays.stream(couponIds.split(",")).mapToInt(Integer::valueOf).boxed().collect(Collectors.toList());
         }
-        studentPaymentOrder = sysCouponCodeService.use(couponIdList,amount);
+        studentPaymentOrder = sysCouponCodeService.use(couponIdList,amount,true);
         amount = studentPaymentOrder.getActualAmount();
         studentPaymentOrder.setUserId(studentId);
         studentPaymentOrder.setGroupType(GroupType.GOODS_SELL);
@@ -463,7 +464,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             }
         }
         List<Integer> couponIdList = repairInfo.getCouponIdList();
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(couponIdList,amount);
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(couponIdList,amount,repairInfo.getType() != 1);
         amount = studentPaymentOrder.getActualAmount();
         amount = amount.subtract(repairInfo.getExemptionAmount());
         if (amount.compareTo(BigDecimal.ZERO) < 0) {

+ 4 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysCouponCodeServiceImpl.java

@@ -162,7 +162,7 @@ public class SysCouponCodeServiceImpl extends BaseServiceImpl<Long, SysCouponCod
 
     @Override
 	@Transactional(rollbackFor = Exception.class)
-    public StudentPaymentOrder use(List<Integer> couponIdList, BigDecimal amount) {
+    public StudentPaymentOrder use(List<Integer> couponIdList, BigDecimal amount,Boolean useFlag) {
 		StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 		if(couponIdList != null && couponIdList.size() > 0){
 			Date date = new Date();
@@ -203,7 +203,9 @@ public class SysCouponCodeServiceImpl extends BaseServiceImpl<Long, SysCouponCod
 				amount = BigDecimal.ZERO;
 			}
 			//使用优惠券
-			sysCouponCodeDao.use(couponIdList);
+			if(useFlag){
+				sysCouponCodeDao.use(couponIdList);
+			}
 			studentPaymentOrder.setCouponCodeId(StringUtils.join(couponIdList,","));
 			studentPaymentOrder.setCouponRemitFee(faceAmount);
 		}

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

@@ -2168,7 +2168,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
 		courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
 
-		StudentPaymentOrder studentPaymentOrder=sysCouponCodeService.use(vipGroupBuyParams.getCouponIdList(),vipGroup.getTotalPrice());
+		StudentPaymentOrder studentPaymentOrder=sysCouponCodeService.use(vipGroupBuyParams.getCouponIdList(),vipGroup.getTotalPrice(),true);
 		studentPaymentOrder.setUserId(user.getId());
         studentPaymentOrder.setGroupType(GroupType.VIP);
 		String orderNo=idGeneratorService.generatorId("payment") + "";

+ 0 - 4
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -318,10 +318,6 @@ public class MusicGroupController extends BaseController {
 
         Integer userId = studentRegistration.getUserId();
 
-        /*StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.SUCCESS);
-        if (ApplyOrder != null) {
-            return failed("您已支付成功,请勿重复支付");
-        }*/
         //判断用户是否已存在订单
         List<StudentPaymentOrder> applyOrderList = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.ING);
         

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

@@ -145,8 +145,7 @@ public class ReplacementInstrumentActivityController extends BaseController {
 
     @ApiOperation(value = "置换支付")
     @PostMapping("/pay")
-    @ApiImplicitParams({@ApiImplicitParam(name = "replacementPayDto", value = "支付参数", required = true, dataType = "ReplacementPayDto")})
-    public HttpResponseResult pay(ReplacementPayDto replacementPayDto) throws Exception {
+    public HttpResponseResult pay(@RequestBody ReplacementPayDto replacementPayDto) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             throw new BizException("用户信息获取失败,请重新登陆");

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

@@ -50,8 +50,7 @@ public class StudentInstrumentController extends BaseController {
 
     @ApiOperation(value = "乐保支付")
     @PostMapping("/pay")
-    @ApiImplicitParams({@ApiImplicitParam(name = "maintenancePayDto", value = "支付参数", required = true, dataType = "MaintenancePayDto")})
-    public HttpResponseResult pay(MaintenancePayDto maintenancePayDto) throws Exception {
+    public HttpResponseResult pay(@RequestBody MaintenancePayDto maintenancePayDto) throws Exception {
         Map payMap = studentInstrumentService.pay(maintenancePayDto);
         if (payMap.containsKey("tradeState")) {
             return failed(HttpStatus.CREATED, payMap, "恭喜您,支付成功!");