Browse Source

Merge remote-tracking branch 'origin/saas' into saas

hgw 3 years ago
parent
commit
0fe2df8533
33 changed files with 343 additions and 395 deletions
  1. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderActivityDao.java
  2. 0 20
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java
  3. 31 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java
  4. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java
  5. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ActivityUserMapperService.java
  6. 1 4
      mec-biz/src/main/java/com/ym/mec/biz/service/CloudTeacherOrderService.java
  7. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderActivityService.java
  8. 12 11
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderBaseService.java
  9. 0 2
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderMemberService.java
  10. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  11. 3 2
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java
  12. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentInstrumentService.java
  13. 11 20
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  14. 0 1
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java
  15. 23 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ActivityUserMapperServiceImpl.java
  16. 13 16
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java
  17. 0 63
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  18. 12 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderActivityServiceImpl.java
  19. 7 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java
  20. 7 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderMemberServiceImpl.java
  21. 9 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderRepairServiceImpl.java
  22. 26 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  23. 60 66
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  24. 1 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java
  25. 3 35
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java
  26. 25 11
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  27. 43 31
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  28. 5 19
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java
  29. 7 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderActivityDao.xml
  30. 3 24
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  31. 3 31
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java
  32. 1 4
      mec-student/src/main/java/com/ym/mec/student/controller/SporadicChargeInfoController.java
  33. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupController.java

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderActivityDao.java

@@ -13,4 +13,6 @@ public interface MusicGroupPaymentCalenderActivityDao extends BaseDAO<Long, Musi
     void delByCalenderId(@Param("calenderId") Long calenderId);
 
     List<MusicGroupPaymentCalenderActivity> findByCalenderId(Long calenderId);
+
+    List<MusicGroupPaymentCalenderActivity> findByIds(@Param("activityIdList") List<Long> buyCalenderActivityIdList);
 }

+ 0 - 20
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -30,15 +30,6 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
 
     StudentPaymentOrder lockOrder(@Param("id") Long id);
 
-    /**
-     * 查询商品列表
-     *
-     * @param musicGroupId
-     * @param type
-     * @return
-     */
-    List<Goods> queryApplyGoodsList(@Param("musicGroupId") String musicGroupId, @Param("type") OrderDetailTypeEnum type);
-
     List<StudentPaymentOrder> queryByCondition(@Param("groupType") GroupType groupType, @Param("musicGroupId") String musicGroupId,
                                                @Param("userId") Integer userId, @Param("status") DealStatusEnum status, @Param("type") OrderTypeEnum type);
 
@@ -168,17 +159,6 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
     List<StudentPaymentOrder> findStudentPaymentOrder(@Param("musicGroupId") String musicGroupId);
 
     /**
-     * 获取零星订单
-     *
-     * @param userId
-     * @param sporadicId
-     * @param groupType
-     * @param status
-     * @return
-     */
-    Integer findOrderByGroupType(@Param("userId") Integer userId, @Param("sporadicId") Integer sporadicId, @Param("groupType") String groupType, @Param("status") DealStatusEnum status);
-
-    /**
      * @param userId:
      * @param sporadicId:
      * @param groupType:

+ 31 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java

@@ -17,12 +17,19 @@ public class RegisterPayDto extends PayParamBasicDto{
     //乐器id->type
     private Map<Long, String> goodsGroups;
 
+    private Integer userId;
+
+    private String musicGroupId;
+
     @ApiModelProperty(value = "可选课程的key",required = false)
     private List<String> courseKeys;
 
     @ApiModelProperty(value = "新的乐团课程形态",required = false)
     private List<Integer> newCourse;
 
+    @ApiModelProperty(value = "缴费项目关联活动Id",required = false)
+    private List<Long> buyCalenderActivityId;
+
     @ApiModelProperty(value = "购买乐器保养",required = false)
     private Boolean buyMaintenance = false;
 
@@ -32,6 +39,30 @@ public class RegisterPayDto extends PayParamBasicDto{
     @ApiModelProperty(value = "购买云教练+",required = false)
     private Boolean buyCloudTeacherPlus= false;
 
+    public String getMusicGroupId() {
+        return musicGroupId;
+    }
+
+    public void setMusicGroupId(String musicGroupId) {
+        this.musicGroupId = musicGroupId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public List<Long> getBuyCalenderActivityId() {
+        return buyCalenderActivityId;
+    }
+
+    public void setBuyCalenderActivityId(List<Long> buyCalenderActivityId) {
+        this.buyCalenderActivityId = buyCalenderActivityId;
+    }
+
     public Integer getRegisterId() {
         return registerId;
     }

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

@@ -133,6 +133,17 @@ public class StudentPaymentOrder extends BaseEntity {
 
 	private Integer activityBuyNum = 0;
 
+	@ApiModelProperty(value = "缴费项目编号",required = true)
+	private Long calenderId;
+
+	public Long getCalenderId() {
+		return calenderId;
+	}
+
+	public void setCalenderId(Long calenderId) {
+		this.calenderId = calenderId;
+	}
+
 	public Integer getActivityBuyNum() {
 		return activityBuyNum;
 	}

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ActivityUserMapperService.java

@@ -5,6 +5,8 @@ import com.ym.mec.biz.dal.dto.ActivityStudentAdjustDto;
 import com.ym.mec.biz.dal.dto.ActivityStudentDto;
 import com.ym.mec.biz.dal.dto.ActivityUserMapperAddDto;
 import com.ym.mec.biz.dal.entity.ActivityUserMapper;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
@@ -104,4 +106,13 @@ public interface ActivityUserMapperService extends BaseService<Integer, Activity
     */
     void cut(Integer activityUserMapperId, String memo, BigDecimal amount);
 
+    /**
+    * @description: 生成排课资格
+     * @param studentPaymentOrder
+ * @param activity
+    * @return void
+    * @author zx
+    * @date 2021/12/29 17:28
+    */
+    void addOrderDetail2Activity(StudentPaymentOrder studentPaymentOrder, List<StudentPaymentOrderDetail> activity);
 }

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

@@ -24,9 +24,6 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
      */
     PageInfo<CloudTeacherStudent> queryInactive(CloudTeacherOrderQueryInfo cloudTeacherOrderQueryInfo) throws Exception;
 
-    /**
-     * 机构付款指定学生并激活
-     */
 
     /**
      * 将订单详情云教练加入云教练购买列表
@@ -34,7 +31,7 @@ public interface CloudTeacherOrderService extends BaseService<Long, CloudTeacher
      * @param order
      * @return
      */
-    Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order, BigDecimal cloudTeacherFee);
+    void addOrderDetail2CloudTeacher(StudentPaymentOrder order, BigDecimal cloudTeacherFee);
 
 
     /**

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderActivityService.java

@@ -19,4 +19,6 @@ public interface MusicGroupPaymentCalenderActivityService {
     void delByCalenderId(Long calenderId);
 
     List<MusicGroupPaymentCalenderActivity> findByCalenderId(Long calenderId);
+
+    List<MusicGroupPaymentCalenderActivity> findByIds(List<Long> buyCalenderActivityIdList);
 }

+ 12 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderBaseService.java

@@ -4,25 +4,17 @@ import com.ym.mec.biz.dal.dto.MusicGroupPaymentBaseCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderBase;
 import com.ym.mec.biz.dal.enums.CalenderBaseServiceEnum;
+import org.apache.poi.ss.formula.functions.T;
 
 import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.Map;
 
-public interface MusicGroupPaymentCalenderBaseService {
+public interface MusicGroupPaymentCalenderBaseService<T> {
 
     Map<CalenderBaseServiceEnum,MusicGroupPaymentCalenderBaseService> calenderBaseServiceMap = new HashMap<>();
 
     /**
-    * @description: 缴费项目组件
-     * @param baseCalender
-    * @return void
-    * @author zx
-    * @date 2021/12/21 11:37
-    */
-    void createComponent(MusicGroupPaymentBaseCalender baseCalender);
-
-    /**
     * @description: 校验缴费项目金额,是否需要审核
      * @param baseCalender
     * @return void
@@ -50,11 +42,20 @@ public interface MusicGroupPaymentCalenderBaseService {
     BigDecimal getOriginalAmount(MusicGroupPaymentBaseCalender baseCalender);
 
     /**
+    * @description: 获取缴费项目价格
+     * @param baseCalender
+    * @return java.math.BigDecimal
+    * @author zx
+    * @date 2021/12/29 15:32
+    */
+    BigDecimal getCurrentAmount(T baseCalender);
+
+    /**
     * @description: 缴费项目关联初始化
      * @param bean
     * @return T
     * @author zx
     * @date 2021/12/24 14:31
     */
-    <T> T initBean(T bean);
+    <E> E initBean(E bean);
 }

+ 0 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderMemberService.java

@@ -3,8 +3,6 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderMember;
 import com.ym.mec.common.service.BaseService;
 
-import java.util.List;
-
 public interface MusicGroupPaymentCalenderMemberService extends BaseService<Long, MusicGroupPaymentCalenderMember> {
 
     void deleteByCalenderId(Long calenderId);

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -196,4 +196,13 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
     String merge1(MusicGroupPaymentBaseCalender musicGroupPaymentBaseCalender);
 
     MusicGroupPaymentCalender getMusicGroupRegCalender(String musicGroupId);
+
+    //获取乐保金额
+    BigDecimal getRepairAmount(Long calenderId);
+
+    //获取会员金额
+    BigDecimal getMemberAmount(Long calenderId);
+
+    //获取活动总金额
+	BigDecimal getActivityAmount(List<Long> buyCalenderActivityIdList);
 }

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java

@@ -11,6 +11,7 @@ import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
 import com.ym.mec.biz.dal.page.MusicMemberQueryInfo;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.ImGroupMember;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
@@ -60,7 +61,7 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	 * @param registerPayDto
 	 * @return
 	 */
-	Map pay(RegisterPayDto registerPayDto) throws Exception;
+	HttpResponseResult pay(RegisterPayDto registerPayDto) throws Exception;
 
 	/**
 	 * 继续缴费
@@ -364,7 +365,7 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	 * @param registerIds 学员注册id
 	 * @return 添加学员记录
 	 */
-	List<StudentRegistration> addMusicGroupRegs(String musicGroupId,List<Long> registerIds) throws Exception;
+	HttpResponseResult addMusicGroupRegs(String musicGroupId,List<Long> registerIds) throws Exception;
 
 
 	/**

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

@@ -38,7 +38,7 @@ public interface StudentInstrumentService extends BaseService<Long, StudentInstr
      * @param order
      * @return
      */
-    Boolean addOrderDetail2Instrument(StudentPaymentOrder order);
+    Long addOrderDetail2Instrument(StudentPaymentOrder order, BigDecimal cloudTeacherFee,Integer goodsId);
 
 
     /**

+ 11 - 20
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -18,6 +18,7 @@ import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.enums.PayStatus;
 import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 import org.apache.ibatis.annotations.Param;
@@ -29,15 +30,6 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
     Map createOrder(StudentPaymentOrder studentPaymentOrder, List<StudentPaymentOrderDetail> details, String payReceiver) throws Exception;
 
     /**
-     * 查询商品列表
-     *
-     * @param musicGroupId
-     * @param type
-     * @return
-     */
-    List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type);
-
-    /**
      * 查询订单列表
      *
      * @param groupType
@@ -97,17 +89,6 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
 
     void updateOrder(Map<String, String> rpMap) throws Exception;
 
-    /**
-     * 获取零星订单
-     *
-     * @param userId
-     * @param sporadicId
-     * @param sporadic
-     * @param status
-     * @return
-     */
-    Integer findOrderByGroupType(Integer userId, Integer sporadicId, String sporadic, DealStatusEnum status);
-
     List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params);
 
     /**
@@ -205,4 +186,14 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
                          Long vipGroupId,
                          Long practiceGroupId,
                          Integer teacherId);
+
+    /**
+    * @description: 校验重复支付
+     * @param order
+ * @param repeatPay
+    * @return com.ym.mec.common.entity.HttpResponseResult
+    * @author zx
+    * @date 2021/12/29 14:50
+    */
+    HttpResponseResult checkRepeatPay(StudentPaymentOrder order, Boolean repeatPay) throws Exception;
 }

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

@@ -105,7 +105,6 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      * @param amount
      * @param orderNo
      * @param paymentChannel
-     * @param courseFee
      * @param goodsGroups
      * @param remitFee
      * @param courseRemitFee

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

@@ -8,6 +8,7 @@ import com.ym.mec.biz.dal.dto.ActivityStudentAdjustDto;
 import com.ym.mec.biz.dal.dto.ActivityStudentDto;
 import com.ym.mec.biz.dal.dto.ActivityUserMapperAddDto;
 import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.ReturnFeeEnum;
 import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
 import com.ym.mec.biz.service.ActivityUserMapperService;
@@ -29,8 +30,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
-import static com.ym.mec.biz.dal.enums.GroupType.ACTIVITY;
-import static com.ym.mec.biz.dal.enums.GroupType.SUBJECT_CHANGE;
+import static com.ym.mec.biz.dal.enums.GroupType.*;
 
 @Service
 public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, ActivityUserMapper>  implements ActivityUserMapperService {
@@ -242,4 +242,25 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
 		sysUserCashAccountLog.setComment("取消活动排课");
 		sysUserCashAccountLogService.insert(sysUserCashAccountLog);
 	}
+
+    @Override
+    public void addOrderDetail2Activity(StudentPaymentOrder studentPaymentOrder, List<StudentPaymentOrderDetail> activity) {
+		List<ActivityUserMapper> activityUserMapperList = new ArrayList<>();
+		for (StudentPaymentOrderDetail orderDetail : activity) {
+			ActivityUserMapper activityUserMapper = new ActivityUserMapper();
+			activityUserMapper.setActualPrice(orderDetail.getPrice());
+			//这里的studentInstrumentId存的是活动编号
+			activityUserMapper.setActivityId(orderDetail.getStudentInstrumentId().intValue());
+			Student student = studentDao.get(studentPaymentOrder.getUserId());
+			activityUserMapper.setUserId(studentPaymentOrder.getUserId());
+			activityUserMapper.setTeacherId(student.getTeacherId());
+			if(orderDetail.getType() == OrderDetailTypeEnum.VIP){
+				activityUserMapper.setVipFlag(1);
+			}else {
+				activityUserMapper.setPracticeFlag(1);
+			}
+			activityUserMapperList.add(activityUserMapper);
+		}
+		activityUserMapperDao.batchInsert(activityUserMapperList);
+    }
 }

+ 13 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CloudTeacherOrderServiceImpl.java

@@ -47,7 +47,7 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
     @Autowired
     private StudentService studentService;
     @Autowired
-    private SysConfigDao sysConfigDao;
+    private MusicGroupPaymentCalenderMemberService musicGroupPaymentCalenderMemberService;
     @Autowired
     private TenantConfigService tenantConfigService;
     @Autowired
@@ -298,21 +298,18 @@ public class CloudTeacherOrderServiceImpl extends BaseServiceImpl<Long, CloudTea
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-	public Boolean addOrderDetail2CloudTeacher(StudentPaymentOrder order,BigDecimal cloudTeacherFee) {
-		CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderDao.queryByOrderId(order.getId());
-
-		if (cloudTeacherOrder == null) {
-			return true;
-		}
-		Date date = new Date();
-
-		cloudTeacherOrder.setAmount(cloudTeacherFee);
-		cloudTeacherOrder.setStatus(1);
-		cloudTeacherOrder.setUpdateTime(date);
-
-		cloudTeacherOrderDao.update(cloudTeacherOrder);
-
-		return true;
+	public void addOrderDetail2CloudTeacher(StudentPaymentOrder order,BigDecimal cloudTeacherFee) {
+        CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
+        cloudTeacherOrder.setOrganId(order.getOrganId());
+        cloudTeacherOrder.setOrderId(order.getId());
+        MusicGroupPaymentCalenderMember calenderMember = musicGroupPaymentCalenderMemberService.findByCalenderId(order.getCalenderId());
+        cloudTeacherOrder.setLevel(calenderMember.getMemberRankSettingId());
+        cloudTeacherOrder.setTime(calenderMember.getNum().intValue());
+        cloudTeacherOrder.setType(calenderMember.getPeriod());
+        cloudTeacherOrder.setAmount(cloudTeacherFee);
+        cloudTeacherOrder.setStudentId(order.getUserId());
+        cloudTeacherOrder.setStatus(1);
+		cloudTeacherOrderDao.insert(cloudTeacherOrder);
 	}
 
     @Override

+ 0 - 63
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -4082,38 +4082,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
     public boolean updateCourseScheduleToOverStatus() {
 
         Date date = new Date();
-        //课程已结束,更新“未签到”学生的状态未“旷课”
-		/*List<StudentAttendance> studentAttendanceList = courseScheduleDao.queryUnsignedStudentList();
-		if (studentAttendanceList != null && studentAttendanceList.size() > 0) {
-			// 获取老师的考勤记录
-			Map<Long, TeacherAttendance> teacherAttendanceMap = teacherAttendanceDao
-					.findTeacherIdByCourseSchedule(studentAttendanceList.stream().map(sa -> sa.getCourseScheduleId()).collect(Collectors.toList())).stream()
-					.collect(Collectors.toMap(TeacherAttendance::getCourseScheduleId, ta -> ta));
-			
-			Date updateTime = DateUtil.stringToDate("19700101 000000", DateUtil.DATE_TIME_FORMAT);
-			for (Iterator<StudentAttendance> list = studentAttendanceList.iterator(); list.hasNext();) {
-				StudentAttendance studentAttendance = list.next();
-				TeacherAttendance teacherAttendance = teacherAttendanceMap.get(studentAttendance.getCourseScheduleId());
-				if (teacherAttendance != null && teacherAttendance.getSignOutTime() == null) {
-					list.remove();
-				} else {
-					studentAttendance.setStatus(StudentAttendanceStatusEnum.TRUANT);
-					studentAttendance.setRemark("课程已结束,自动补旷课");
-					if (Objects.isNull(studentAttendance.getCurrentClassTimes())) {
-						studentAttendance.setCurrentClassTimes(1);
-					} else {
-						studentAttendance.setCurrentClassTimes(studentAttendance.getCurrentClassTimes() + 1);
-					}
-					studentAttendance.setCreateTime(date);
-					studentAttendance.setUpdateTime(updateTime);
-				}
-			}
-
-			if (studentAttendanceList != null && studentAttendanceList.size() > 0) {
-				studentAttendanceDao.addStudentAttendances(studentAttendanceList);
-			}
-		}*/
-
         //自动更新课程状态至“已结束”
         List<CourseSchedule> list = courseScheduleDao.queryFinishedWithNoUpdateStatus();
 
@@ -4149,46 +4117,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				courseScheduleDao.batchUpdate(beMergeCourses);
 			}
 		}
-
         // 更新班级已上课次
         if (classGroupIds.size() > 0) {
             classGroupService.batchIncreaseClassTimes(classGroupIds);
-
-            //查询班级信息
-//            List<ClassGroup> classGroupList = classGroupService.findClassGroupByIds(classGroupIds.stream().map(e -> e.toString()).collect(Collectors.joining(",")));
-//
-//            List<String> vipGroupIdList = new ArrayList<String>();
-//            for (ClassGroup classGroup : classGroupList) {
-//                if (classGroup.getGroupType() == GroupType.VIP && classGroup.getCurrentClassTimes() == classGroup.getTotalClassTimes().intValue()) {
-//                    if (!vipGroupIdList.contains(classGroup.getMusicGroupId())) {
-//                        vipGroupIdList.add(classGroup.getMusicGroupId());
-//                    }
-//                }
-//            }
-//            if (vipGroupIdList.size() > 0) {
-//                List<VipGroup> vipGroupList = vipGroupDao.queryByIds(vipGroupIdList.stream().collect(Collectors.joining(",")));
-//                for (VipGroup vipGroup : vipGroupList) {
-//                    if (!vipGroup.getStatus().equals(VipGroupStatusEnum.PAUSE)
-//                            && !vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)) {
-//                        vipGroup.setStatus(VipGroupStatusEnum.FINISHED);
-//                    }
-//                    vipGroup.setUpdateTime(date);
-//                }
-//                vipGroupDao.batchUpdate(vipGroupList);
-//            }
         }
-
-        /*if (courseScheduleIdList.size() > 0) {
-            // vip课自动签退
-            teacherAttendanceDao.updateViPSignOutStatus(courseScheduleIdList.stream().map(a -> a.toString()).collect(Collectors.joining(",")));
-        }*/
-
 		try {
 			practiceGroupService.practiceGroupRenewRemind();
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
-
 		return true;
     }
 

+ 12 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderActivityServiceImpl.java

@@ -15,6 +15,7 @@ import com.ym.mec.biz.service.MusicGroupPaymentCalenderBaseService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -27,7 +28,7 @@ import java.util.stream.Collectors;
 
 @Service
 public class MusicGroupPaymentCalenderActivityServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderActivity>
-        implements MusicGroupPaymentCalenderActivityService, MusicGroupPaymentCalenderBaseService {
+        implements MusicGroupPaymentCalenderActivityService, MusicGroupPaymentCalenderBaseService<MusicGroupPaymentCalenderActivity> {
 
     @Autowired
     private MusicGroupPaymentCalenderActivityDao musicGroupPaymentCalenderActivityDao;
@@ -47,11 +48,6 @@ public class MusicGroupPaymentCalenderActivityServiceImpl extends BaseServiceImp
     }
 
     @Override
-    public void createComponent(MusicGroupPaymentBaseCalender baseCalender) {
-
-    }
-
-    @Override
     public MusicGroupPaymentCalender.PaymentCalenderStatusEnum checkComponentAmount(MusicGroupPaymentBaseCalender baseCalender) {
         return null;
     }
@@ -77,6 +73,11 @@ public class MusicGroupPaymentCalenderActivityServiceImpl extends BaseServiceImp
     }
 
     @Override
+    public BigDecimal getCurrentAmount(MusicGroupPaymentCalenderActivity baseCalender) {
+        return baseCalender.getActualAmount();
+    }
+
+    @Override
     public <T> T initBean(T bean) {
         if(bean != null){
             List<MusicGroupPaymentCalenderActivity> calenderActivities = (List<MusicGroupPaymentCalenderActivity>) bean;
@@ -120,4 +121,9 @@ public class MusicGroupPaymentCalenderActivityServiceImpl extends BaseServiceImp
     public List<MusicGroupPaymentCalenderActivity> findByCalenderId(Long calenderId) {
         return musicGroupPaymentCalenderActivityDao.findByCalenderId(calenderId);
     }
+
+    @Override
+    public List<MusicGroupPaymentCalenderActivity> findByIds(List<Long> buyCalenderActivityIdList) {
+        return musicGroupPaymentCalenderActivityDao.findByIds(buyCalenderActivityIdList);
+    }
 }

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderCourseSettingsServiceImpl.java

@@ -27,7 +27,8 @@ import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MU
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW;
 
 @Service
-public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServiceImpl<Integer, MusicGroupPaymentCalenderCourseSettings>  implements MusicGroupPaymentCalenderCourseSettingsService, MusicGroupPaymentCalenderBaseService {
+public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServiceImpl<Integer, MusicGroupPaymentCalenderCourseSettings>
+		implements MusicGroupPaymentCalenderCourseSettingsService, MusicGroupPaymentCalenderBaseService<MusicGroupPaymentCalenderCourseSettings> {
 	
 	@Autowired
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
@@ -102,11 +103,6 @@ public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServ
 		return musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettingsByBatchNo(batchNo);
 	}
 
-    @Override
-	public void createComponent(MusicGroupPaymentBaseCalender baseCalender) {
-
-	}
-
 	@Override
 	public MusicGroupPaymentCalender.PaymentCalenderStatusEnum checkComponentAmount(MusicGroupPaymentBaseCalender baseCalender) {
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = baseCalender.getMusicGroupPaymentCalenderCourseSettingsList();
@@ -195,6 +191,11 @@ public class MusicGroupPaymentCalenderCourseSettingsServiceImpl extends BaseServ
     }
 
 	@Override
+	public BigDecimal getCurrentAmount(MusicGroupPaymentCalenderCourseSettings baseCalender) {
+		return null;
+	}
+
+	@Override
 	public <T> T initBean(T bean) {
 		return null;
 	}

+ 7 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderMemberServiceImpl.java

@@ -23,7 +23,7 @@ import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalende
 
 @Service
 public class MusicGroupPaymentCalenderMemberServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderMember>
-        implements MusicGroupPaymentCalenderBaseService, MusicGroupPaymentCalenderMemberService {
+        implements MusicGroupPaymentCalenderBaseService<MusicGroupPaymentCalenderMember>, MusicGroupPaymentCalenderMemberService {
 
     @Autowired
     private MusicGroupPaymentCalenderMemberDao musicGroupPaymentCalenderMemberDao;
@@ -43,11 +43,6 @@ public class MusicGroupPaymentCalenderMemberServiceImpl extends BaseServiceImpl<
     }
 
     @Override
-    public void createComponent(MusicGroupPaymentBaseCalender baseCalender) {
-
-    }
-
-    @Override
     public MusicGroupPaymentCalender.PaymentCalenderStatusEnum checkComponentAmount(MusicGroupPaymentBaseCalender baseCalender) {
         MusicGroupPaymentCalenderMember calenderMember = baseCalender.getCalenderMember();
         if(calenderMember != null){
@@ -93,7 +88,12 @@ public class MusicGroupPaymentCalenderMemberServiceImpl extends BaseServiceImpl<
     }
 
     @Override
-    public <T> T initBean(T bean) {
+    public BigDecimal getCurrentAmount(MusicGroupPaymentCalenderMember baseCalender) {
+        return null;
+    }
+
+    @Override
+    public <E> E initBean(E bean) {
         if(bean != null){
             MusicGroupPaymentCalenderMember calenderMember = (MusicGroupPaymentCalenderMember)bean;
             MemberRankSetting memberRankSetting = memberRankSettingDao.get(calenderMember.getMemberRankSettingId());

+ 9 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderRepairServiceImpl.java

@@ -15,6 +15,7 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -24,7 +25,8 @@ import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalende
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.NO;
 
 @Service
-public class MusicGroupPaymentCalenderRepairServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderRepair> implements MusicGroupPaymentCalenderBaseService, MusicGroupPaymentCalenderRepairService {
+public class MusicGroupPaymentCalenderRepairServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderRepair>
+        implements MusicGroupPaymentCalenderBaseService<MusicGroupPaymentCalenderRepair>, MusicGroupPaymentCalenderRepairService {
 
     @Autowired
     private MusicGroupPaymentCalenderRepairDao musicGroupPaymentCalenderRepairDao;
@@ -42,11 +44,6 @@ public class MusicGroupPaymentCalenderRepairServiceImpl extends BaseServiceImpl<
     }
 
     @Override
-    public void createComponent(MusicGroupPaymentBaseCalender baseCalender) {
-
-    }
-
-    @Override
     public MusicGroupPaymentCalender.PaymentCalenderStatusEnum checkComponentAmount(MusicGroupPaymentBaseCalender baseCalender) {
         MusicGroupPaymentCalenderRepair musicRepair = baseCalender.getMusicRepair();
         if(musicRepair != null){
@@ -89,11 +86,16 @@ public class MusicGroupPaymentCalenderRepairServiceImpl extends BaseServiceImpl<
     }
 
     @Override
-    public <T> T initBean(T bean) {
+    public BigDecimal getCurrentAmount(MusicGroupPaymentCalenderRepair baseCalender) {
         return null;
     }
 
     @Override
+    public <E> E initBean(E bean) {
+        return bean;
+    }
+
+    @Override
     public void deleteByCalenderId(Long calenderId) {
         musicGroupPaymentCalenderRepairDao.deleteByCalenderId(calenderId);
     }

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.toolkit.support.Property;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUserRole;
@@ -33,6 +34,7 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.util.*;
 import java.util.Map.Entry;
 import java.util.function.Consumer;
@@ -1679,7 +1681,30 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		return musicGroupPaymentCalenderDao.getMusicGroupRegCalender(musicGroupId);
     }
 
-    @Override
+    private BigDecimal getActualAmount(MusicGroupPaymentCalenderBase baseCalender){
+		if(baseCalender != null){
+			return baseCalender.getActualAmount();
+		}
+		return BigDecimal.ZERO;
+	}
+
+	@Override
+	public BigDecimal getRepairAmount(Long calenderId) {
+		return getActualAmount(musicGroupPaymentCalenderRepairService.findByCalenderId(calenderId));
+	}
+
+	@Override
+	public BigDecimal getMemberAmount(Long calenderId) {
+		return getActualAmount(musicGroupPaymentCalenderMemberService.findByCalenderId(calenderId));
+	}
+
+	@Override
+	public BigDecimal getActivityAmount(List<Long> buyCalenderActivityIdList) {
+		List<MusicGroupPaymentCalenderActivity> activityList = musicGroupPaymentCalenderActivityService.findByIds(buyCalenderActivityIdList);
+		return activityList.stream().map(e->e.getActualAmount()).reduce(BigDecimal.ZERO,BigDecimal::add);
+	}
+
+	@Override
 	@Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
 	public boolean autoUpdateMusicGroupPaymentCalenderStatus() {
 		Date date = new Date();

+ 60 - 66
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -16,6 +16,7 @@ import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
 
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.sql.Connection;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -34,11 +35,13 @@ import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.*;
 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.tenant.TenantContextHolder;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -662,13 +665,20 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Map pay(RegisterPayDto registerPayDto) throws Exception {
-
+    public HttpResponseResult pay(RegisterPayDto registerPayDto) throws Exception {
+        //判断用户是否已存在订单
+        List<StudentPaymentOrder> applyOrderList = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(registerPayDto.getUserId(), registerPayDto.getMusicGroupId(), DealStatusEnum.ING);
+
+        if (applyOrderList != null && applyOrderList.size() > 0) {
+            HttpResponseResult result = studentPaymentOrderService.checkRepeatPay(applyOrderList.get(0), registerPayDto.getRepeatPay());
+            if(result.getCode() != 200){
+                return result;
+            }
+        }
         StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
         if (studentRegistration == null) {
             throw new BizException("报名信息有误,请核查");
         }
-        
         MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(studentRegistration.getMusicGroupId());
         if(musicGroupRegCalender == null){
         	throw new BizException("缴费信息不存在");
@@ -677,12 +687,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if(musicGroup == null){
             throw new BizException("查询乐团信息失败");
         }
-        Integer tenantId = TenantContextHolder.getTenantId();
+//        Integer tenantId = TenantContextHolder.getTenantId();
 
+        Long calenderId = musicGroupRegCalender.getId();
         Integer userId = studentRegistration.getUserId();
 
         BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
-        BigDecimal orderAmount = new BigDecimal("0");
+        BigDecimal orderAmount = BigDecimal.ZERO;
 
         //获取课程价格
 //        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
@@ -693,7 +704,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         BigDecimal courseRemitFee = BigDecimal.ZERO; //课程减免费用
         boolean remitCourseRFeeFlag = false; //减免课程费用标识
 
-        //乐器及打包辅件
+        //乐器及打包辅件价格
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
         if (registerPayDto.getGoodsGroups() != null && registerPayDto.getGoodsGroups().size() > 0) {
             String goodsGroupIds = registerPayDto.getGoodsGroups().keySet().stream().map(Object::toString).collect(Collectors.joining(","));
@@ -710,6 +721,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 if (!kitGroupPurchaseType.equals("GROUP")) {
                     goodsGroup.setPrice(kitGroupPurchaseType.equals("FREE") ? new BigDecimal(0) : goodsGroup.getDepositFee());
                 } else {
+                    //购买乐器是否减免课程费用
                     remitCourseRFeeFlag = goodsGroup.getGroupRemissionCourseFee().equals(1);
                 }
                 goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
@@ -743,20 +755,37 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (musicGroupRegCalender.getPayUserType() == PayUserType.STUDENT && registerPayDto.getNewCourse() != null && registerPayDto.getNewCourse().size() > 0) {
             newCourses = musicGroupPaymentCalenderCourseSettingsDao.getCalenderCourseSettings(registerPayDto.getNewCourse());
             for (MusicGroupPaymentCalenderCourseSettings calenderCourseSetting : newCourses) {
-                if (remitCourseRFeeFlag && !calenderCourseSetting.getIsStudentOptional()) {
+                if (remitCourseRFeeFlag) {
                     courseRemitFee = courseRemitFee.add(calenderCourseSetting.getCourseCurrentPrice());
-                    continue;
+                }else {
+                    orderAmount = orderAmount.add(calenderCourseSetting.getCourseCurrentPrice());
                 }
-                orderAmount = orderAmount.add(calenderCourseSetting.getCourseCurrentPrice());
             }
         }
-        //乐器保养
+        //活动价格
+        List<Long> buyCalenderActivityIdList = registerPayDto.getBuyCalenderActivityId();
+        if(buyCalenderActivityIdList != null && buyCalenderActivityIdList.size() > 0){
+            orderAmount = orderAmount.add(musicGroupPaymentCalenderService.getActivityAmount(buyCalenderActivityIdList));
+        }
+        //乐器保养价格
         if (registerPayDto.getBuyMaintenance()) {
-            String configValue = sysTenantConfigService.getTenantConfigValue(SysConfigService.ONE_YEAR_MUSICAL_REPAIR_AMOUNT, tenantId);
-            if(StringUtils.isEmpty(configValue)){
-                throw new BizException("乐保价格异常,请联系指导老师");
-            }
-            orderAmount = orderAmount.add(new BigDecimal(configValue));
+            orderAmount = orderAmount.add(musicGroupPaymentCalenderService.getRepairAmount(calenderId));
+        }
+        //云教练价格和订单
+//        CloudTeacherOrder cloudTeacherOrder = null;
+        if (registerPayDto.getBuyCloudTeacher()){
+            orderAmount = orderAmount.add(musicGroupPaymentCalenderService.getMemberAmount(calenderId));
+//            studentRegistration.setHasCloudTeacher(0);
+//            //创建订单
+//            cloudTeacherOrder = new CloudTeacherOrder();
+//            cloudTeacherOrder.setType(PeriodEnum.MONTH);//月
+//            cloudTeacherOrder.setTime(musicGroupRegCalender.getMemberValidDate() == null ? 6 : musicGroupRegCalender.getMemberValidDate());
+//            cloudTeacherOrder.setOrganId(musicGroup.getOrganId());
+//            cloudTeacherOrder.setStudentId(studentRegistration.getUserId());
+//            cloudTeacherOrder.setLevel(musicGroupRegCalender.getMemberRankSettingId() == null ? 1 : musicGroupRegCalender.getMemberRankSettingId());
+//            cloudTeacherOrder.setAmount(cloudTeacherPrice);
+//            cloudTeacherOrder.setStatus(0);
+//            cloudTeacherOrder.setMusicGroupId(musicGroup.getId());
         }
         
         studentRegistration.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
@@ -766,36 +795,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         Date date = new Date();
 
-        CloudTeacherOrder cloudTeacherOrder = null;
-        //云教练/云教练+
-        if (registerPayDto.getBuyCloudTeacher() || registerPayDto.getBuyCloudTeacherPlus()) {
-            BigDecimal cloudTeacherPrice = BigDecimal.ZERO;
-			if (musicGroupRegCalender.getMemberRankSettingId() != null) {
-				cloudTeacherPrice = musicGroupRegCalender.getMemberPaymentAmount();
-			} else {
-				if (musicGroup.getCloudTeacherType() != null) {
-					OrganizationCloudTeacherFee cloudTeacher = organizationCloudTeacherFeeDao.getByOrganId(studentRegistration.getOrganId());
-					cloudTeacherPrice = musicGroup.getCloudTeacherType() == 0 ? cloudTeacher.getPrice() : cloudTeacher.getPlusPrice();
-				}
-			}
-            
-            orderAmount = orderAmount.add(cloudTeacherPrice);
-            studentRegistration.setHasCloudTeacher(0);
-            
-
-            //创建订单
-            cloudTeacherOrder = new CloudTeacherOrder();
-
-    		cloudTeacherOrder.setType(PeriodEnum.MONTH);//月
-			cloudTeacherOrder.setTime(musicGroupRegCalender.getMemberValidDate() == null ? 6 : musicGroupRegCalender.getMemberValidDate());
-    		
-    		cloudTeacherOrder.setOrganId(musicGroup.getOrganId());
-    		cloudTeacherOrder.setStudentId(studentRegistration.getUserId());
-    		cloudTeacherOrder.setLevel(musicGroupRegCalender.getMemberRankSettingId() == null ? 1 : musicGroupRegCalender.getMemberRankSettingId());
-    		cloudTeacherOrder.setAmount(cloudTeacherPrice);
-    		cloudTeacherOrder.setStatus(0);
-            cloudTeacherOrder.setMusicGroupId(musicGroup.getId());
-        }
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
         String channelType = "";
@@ -810,6 +809,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 registerPayDto.getBuyMaintenance(),
                 registerPayDto.getBuyCloudTeacher(),
                 registerPayDto.getBuyCloudTeacherPlus(),registerPayDto.getCouponIdList());
+        studentPaymentOrder.setCalenderId(calenderId);
         orderAmount = studentPaymentOrder.getActualAmount();
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
@@ -820,12 +820,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
         boolean canPay = studentPaymentOrder.getClassGroupId() != null && studentPaymentOrder.getClassGroupId().equals(206);
         
-        if(cloudTeacherOrder != null){
-    		cloudTeacherOrder.setOrderId(studentPaymentOrder.getId());
-    		cloudTeacherOrder.setCreateTime(date);
-    		cloudTeacherOrder.setUpdateTime(date);
-    		cloudTeacherOrderService.insert(cloudTeacherOrder);
-        }
+//        if(cloudTeacherOrder != null){
+//    		cloudTeacherOrder.setOrderId(studentPaymentOrder.getId());
+//    		cloudTeacherOrder.setCreateTime(date);
+//    		cloudTeacherOrder.setUpdateTime(date);
+//    		cloudTeacherOrderService.insert(cloudTeacherOrder);
+//        }
 
         BigDecimal balance = BigDecimal.ZERO;
         if (registerPayDto.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
@@ -869,12 +869,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             userPhoneMap.put(endTeacher.getId(), endTeacher.getPhone());
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.NO_BUY_CLOUD_TEACHER_MSG,
                     userPhoneMap, null, 0, null, null, musicGroup.getName(), studentRegistration.getName());
-
             if(!canPay){
                 Map<String, String> notifyMap = new HashMap<>();
                 notifyMap.put("hasPaidZero", "205");
                 notifyMap.put("orderNo", studentPaymentOrder.getOrderNo());
-                return notifyMap;
+                return BaseController.failed(HttpStatus.RESET_CONTENT, notifyMap, "报名审核中");
             }
         }
 
@@ -886,7 +885,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             notifyMap.put("channelType", channelType);
             notifyMap.put("orderNo", "");
             studentPaymentOrderService.updateOrder(notifyMap);
-            return notifyMap;
+            return BaseController.failed(HttpStatus.CREATED, notifyMap, "恭喜您,报名成功!");
         }
 
         String orderSubject = "乐团报名";
@@ -913,15 +912,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrderService.update(studentPaymentOrder);
-        return payMap;
+        return BaseController.succeed(payMap);
     }
 
-    private BigDecimal getCalenderAmount(Long calenderId,Function<Long,BigDecimal> func){
-        return func.apply(calenderId);
-    }
-
-
-
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Map rePay(RegisterPayDto registerPayDto) throws Exception {
@@ -3897,7 +3890,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public List<StudentRegistration> addMusicGroupRegs(String musicGroupId, List<Long> registerIds) throws Exception {
+    public HttpResponseResult addMusicGroupRegs(String musicGroupId, List<Long> registerIds) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null || sysUser.getId() == null) {
             throw new BizException("获取用户信息失败");
@@ -3976,7 +3969,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             registerPayDto.setNewCourse(courseSettings);
             for (StudentRegistration studentRegistration : studentRegistrationList) {
                 registerPayDto.setRegisterId(studentRegistration.getId().intValue());
-                Map payMap = this.pay(registerPayDto);
+                HttpResponseResult result = this.pay(registerPayDto);
+                if(result.getCode() != 200){
+                    return result;
+                }
             }
         }
 
@@ -3984,10 +3980,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
         musicGroup.setIsExtraClass(YesOrNoEnum.YES);
         musicGroupDao.update(musicGroup);
-
         musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "添加报名学员", sysUser.getId(), ""));
-
-        return studentRegistrationList;
+        return BaseController.succeed(studentRegistrationList);
     }
 
     @Override

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

@@ -4532,9 +4532,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 				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("订单还在交易中,请稍后重试");
-				}*/
+				}
 				//处理关闭订单
 				applyOrder.setStatus(DealStatusEnum.CLOSE);
 				applyOrder.setMemo("主动关闭订单");
@@ -4546,7 +4544,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 				sysCouponCodeService.quit(applyOrder.getCouponCodeId());
 			}
     		
-    		
         } else if (practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL)) {
             return BaseController.failed(HttpStatus.CREATED, "该订单已经支付成功");
         } else if (practiceGroup.getGroupStatus().equals(GroupStatusEnum.CANCEL)) {

+ 3 - 35
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -304,47 +304,15 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
     }
 
     @Override
-    public Boolean addOrderDetail2Instrument(StudentPaymentOrder order) {
-        List<OrderDetailTypeEnum> orderDetailTypes = new ArrayList<>();
-        orderDetailTypes.add(OrderDetailTypeEnum.MAINTENANCE);
-        orderDetailTypes.add(OrderDetailTypeEnum.MUSICAL);
-        List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.getOrderDetailByType(order.getId(), orderDetailTypes);
-        List<StudentPaymentOrderDetail> orderDetails4Instruments = orderDetails.stream()
-                .filter(e -> e.getType().equals(OrderDetailTypeEnum.MUSICAL))
-                .collect(Collectors.toList());
-        if (orderDetails4Instruments.size() <= 0) {
-            return false;
-        }
-        List<StudentPaymentOrderDetail> orderDetails4Maintenance = orderDetails.stream()
-                .filter(e -> e.getType().equals(OrderDetailTypeEnum.MAINTENANCE)).collect(Collectors.toList());
-
-        StudentPaymentOrderDetail maintenanceDetail = null;
-        int maintenanceStatus = 0;
-        Date startTime = null;
-        Date endTime = null;
-        if (orderDetails4Maintenance.size() > 0) {
-            maintenanceDetail = orderDetails4Maintenance.get(0);
-            //maintenanceStatus = 1;
-            startTime = new Date();
-            endTime = DateUtil.addYears(startTime, 1);
-        }
-
-        Integer goodsId = Integer.valueOf(orderDetails4Instruments.get(0).getGoodsIdList());
+    public Long addOrderDetail2Instrument(StudentPaymentOrder order, BigDecimal cloudTeacherFee,Integer goodsId) {
         StudentInstrument studentInstrument = new StudentInstrument();
         studentInstrument.setStudentId(order.getUserId());
         studentInstrument.setOrganId(order.getOrganId());
         studentInstrument.setGoodsId(goodsId);
-        studentInstrument.setStatus(maintenanceStatus);
+        studentInstrument.setStatus(1);
         studentInstrument.setOrderId(order.getId());
         studentInstrument.setChangeOrderId(order.getId());
-        //studentInstrument.setStartTime(startTime);
-        //studentInstrument.setEndTime(endTime);
-        addStudentInstrument(studentInstrument);
-        if (maintenanceDetail != null) {
-            maintenanceDetail.setStudentInstrumentId(studentInstrument.getId());
-            studentPaymentOrderDetailDao.update(maintenanceDetail);
-        }
-        return true;
+        return addStudentInstrument(studentInstrument).getId();
     }
 
     @Override

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

@@ -16,12 +16,15 @@ import com.ym.mec.biz.dal.entity.*;
 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.util.excel.POIUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -185,11 +188,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 		return payMap;
 	}
 
-	@Override
-    public List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type) {
-        return studentPaymentOrderDao.queryApplyGoodsList(musicGroupId, type);
-    }
-
     @Override
     public List<StudentPaymentOrder> queryByCondition(GroupType groupType, String musicGroupId, Integer userId, DealStatusEnum status, OrderTypeEnum type) {
         return studentPaymentOrderDao.queryByCondition(groupType, musicGroupId, userId, status, type);
@@ -490,12 +488,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
     }
 
-    @Override
-    public Integer findOrderByGroupType(Integer userId, Integer sporadicId, String sporadic, DealStatusEnum status) {
-        return studentPaymentOrderDao.findOrderByGroupType(userId, sporadicId, sporadic, status);
-    }
-
-
     private void closeOrders(List<String> orderNoList) throws Exception {
         if (orderNoList.size() == 0) {
             return;
@@ -789,4 +781,26 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         return activityUserMapperId;
     }
+
+    @Override
+    public HttpResponseResult checkRepeatPay(StudentPaymentOrder order, Boolean repeatPay) throws Exception {
+        // 查询订单状态
+        PayStatus payStatus = this.queryPayStatus(order.getPaymentChannel(), order.getOrderNo(), order.getTransNo());
+        if(payStatus == PayStatus.SUCCESSED){
+            throw new BizException("订单已支付成功,请勿重复支付");
+        }
+        if(!repeatPay){
+            return BaseController.failed(HttpStatus.CONTINUE, "您有待支付的订单,是否继续支付");
+        }
+        //处理关闭订单
+        order.setStatus(DealStatusEnum.CLOSE);
+        order.setMemo("关闭订单");
+        if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
+            sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(),
+                    PlatformCashAccountDetailTypeEnum.REFUNDS, "订单主动关闭退费");
+        }
+        studentPaymentOrderDao.update(order);
+        sysCouponCodeService.quit(order.getCouponCodeId());
+        return BaseController.succeed();
+    }
 }

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

@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*;
 import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
 
 import java.io.IOException;
@@ -195,6 +196,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     private SysCouponCodeService sysCouponCodeService;
     @Autowired
     private SysUserCashAccountLogService sysUserCashAccountLogService;
+    @Autowired
+    private ActivityUserMapperService activityUserMapperService;
 
     @Override
     public BaseDAO<Long, StudentRegistration> getDAO() {
@@ -371,7 +374,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 			map.put(OrderDetailTypeEnum.MUSICAL.getCode(), BigDecimal.ZERO);
 		}
 
-		if (detailMap.containsKey(OrderDetailTypeEnum.MAINTENANCE)) {
+		if (detailMap.containsKey(MAINTENANCE)) {
 
 			BigDecimal totalAmount = BigDecimal.ZERO;
 
@@ -384,7 +387,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 			if (studentPaymentOrderDetailList != null && studentPaymentOrderDetailList.size() > 0) {
 
 				Map<Long, StudentPaymentOrderDetail> maintenanceMap = studentPaymentOrderDetailList.stream()
-						.filter(t -> (t.getType() == OrderDetailTypeEnum.MAINTENANCE))
+						.filter(t -> (t.getType() == MAINTENANCE))
 						.collect(Collectors.toMap(t -> t.getStudentInstrumentId(), StudentPaymentOrderDetail -> StudentPaymentOrderDetail));
 
 				List<Long> instrumentIdList = new ArrayList<Long>(maintenanceMap.keySet());
@@ -402,9 +405,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 					}
 				}
 			}
-			map.put(OrderDetailTypeEnum.MAINTENANCE.getCode(), sysUserCashAccountLogService.musicReturnFeeCharges(totalAmount,0));
+			map.put(MAINTENANCE.getCode(), sysUserCashAccountLogService.musicReturnFeeCharges(totalAmount,0));
 		} else {
-			map.put(OrderDetailTypeEnum.MAINTENANCE.getCode(), BigDecimal.ZERO);
+			map.put(MAINTENANCE.getCode(), BigDecimal.ZERO);
 		}
 
 		if (detailMap.containsKey(OrderDetailTypeEnum.ACCESSORIES)) {
@@ -595,14 +598,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentPaymentOrderService.insert(studentPaymentOrder);
 
         ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
-        /*StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE);
-        studentPaymentOrderDetail.setPrice(BigDecimal.ZERO);
-        studentPaymentOrderDetail.setRemitFee(BigDecimal.ZERO);
-        studentPaymentOrderDetail.setCreateTime(date);
-        studentPaymentOrderDetail.setUpdateTime(date);
-        studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-        studentPaymentOrderDetailList.add(studentPaymentOrderDetail);*/
         Integer tenantId = TenantContextHolder.getTenantId();
         //乐器及打包辅件
         String maintenanceGoodsId = "";
@@ -654,7 +649,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             for (MusicGroupPaymentCalenderCourseSettings newCourse : newCourses) {
                 StudentPaymentOrderDetail studentPaymentOrderDetailCourse = new StudentPaymentOrderDetail();
                 studentPaymentOrderDetailCourse.setType(OrderDetailTypeEnum.valueOf(newCourse.getCourseType().getCode()));
-                if (courseRemitFee.compareTo(BigDecimal.ZERO) > 0 && !newCourse.getIsStudentOptional()) {
+                if (courseRemitFee.compareTo(BigDecimal.ZERO) > 0) {
                     studentPaymentOrderDetailCourse.setPrice(BigDecimal.ZERO);
                     studentPaymentOrderDetailCourse.setRemitFee(newCourse.getCourseCurrentPrice());
                 } else {
@@ -677,7 +672,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             }
             BigDecimal maintenancePrice = new BigDecimal(configValue);
             StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
-            maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
+            maintenanceOrderDetail.setType(MAINTENANCE);
             maintenanceOrderDetail.setPrice(maintenancePrice);
             maintenanceOrderDetail.setRemitFee(BigDecimal.ZERO);
             maintenanceOrderDetail.setCreateTime(date);
@@ -1121,6 +1116,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
             }
             studentRegistration.setPaymentStatus(YES);
+            studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
             
             if (studentPaymentOrder.getClassGroupId() == null || !studentPaymentOrder.getClassGroupId().equals(206)) {
                 studentRegistration.setPayingStatus(0);
@@ -1131,17 +1127,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             List<Long> orderIdList = new ArrayList<Long>();
             orderIdList.add(studentPaymentOrder.getId());
             List<StudentPaymentOrderDetail> allDetails = studentPaymentOrderDetailDao.getOrderDetailByOrderId(orderIdList);
-            BigDecimal courseFee = allDetails.stream().filter(o -> !o.getType().getCode().equals("MUSICAL"))
-                    .filter(o -> !o.getType().getCode().equals("ACCESSORIES"))
-                    .filter(o -> !o.getType().getCode().equals("MAINTENANCE"))
-                    .filter(o -> !o.getType().getCode().equals("CLOUD_TEACHER"))
-                    .filter(o -> !o.getType().getCode().equals("CLOUD_TEACHER_PLUS"))
+            BigDecimal courseFee = allDetails.stream().filter(o -> !(o.getType()==MUSICAL))
+                    .filter(o -> !(o.getType() == ACCESSORIES))
+                    .filter(o -> !(o.getType() == MAINTENANCE))
+                    .filter(o -> !(o.getType() == CLOUD_TEACHER))
+                    .filter(o -> !(o.getType() == CLOUD_TEACHER_PLUS))
                     .map(o -> o.getPrice().subtract(o.getRemitFee() == null ? BigDecimal.ZERO : o.getRemitFee()))
                     .reduce(BigDecimal.ZERO, BigDecimal::add);
             
             //已购买内容
-            List<OrderDetailTypeEnum> orderTypeList = allDetails.stream().map(t -> t.getType()).collect(Collectors.toList());
-            
+            /*List<OrderDetailTypeEnum> orderTypeList = allDetails.stream().map(t -> t.getType()).collect(Collectors.toList());
 			if (musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE) {
 
 				if(studentRegistration.getNoneNeedCloudTeacher() == 1){
@@ -1151,14 +1146,13 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 				if (orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER) || orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS)
 						|| orderTypeList.contains(OrderDetailTypeEnum.MUSICAL)) {
 					studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
-					//studentRegistration.setNoneNeedCloudTeacher(1);
 					if (orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER) || orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS)) {
 						studentRegistration.setHasCloudTeacher(1);
 					}
 				}
 			} else {
 				studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
-			}
+			}*/
 
             //累加充值金额
             studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(courseFee));
@@ -1214,8 +1208,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             if (orderDetails.size() > 0) {
                 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"))
+                    BigDecimal musicFee = orderDetails.stream().filter(o -> o.getType()==MUSICAL
+                            || o.getType()==ACCESSORIES || o.getType()==TEACHING)
                             .map(o -> o.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
                     BigDecimal expectAmount = studentPaymentOrder.getExpectAmount();
                     //获取比例
@@ -1229,14 +1223,32 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             //课程处理
             addCalenderDetail(studentPaymentOrder, studentRegistration);
 
+            //活动小课包处理
+            List<StudentPaymentOrderDetail> activity = allDetails.stream().filter(o -> o.getType()==PRACTICE || o.getType() == VIP).collect(Collectors.toList());
+            if(activity != null && activity.size() > 0){
+                activityUserMapperService.addOrderDetail2Activity(studentPaymentOrder,activity);
+            }
+
             //学生乐器与月保处理
-            studentInstrumentService.addOrderDetail2Instrument(studentPaymentOrder);
+            StudentPaymentOrderDetail repair = allDetails.stream().filter(o -> o.getType()==MAINTENANCE).findFirst().get();
+            if(repair != null){
+                BigDecimal repairFee = allDetails.stream() .filter(o -> o.getType()==MAINTENANCE)
+                        .map(o -> o.getPrice().subtract(o.getRemitFee() == null ? BigDecimal.ZERO : o.getRemitFee()))
+                        .reduce(BigDecimal.ZERO, BigDecimal::add);
+                StudentPaymentOrderDetail musical = allDetails.stream().filter(o -> o.getType()==MUSICAL).findFirst().get();
+                Long studentInstrumentId = studentInstrumentService.addOrderDetail2Instrument(studentPaymentOrder, repairFee, Integer.valueOf(musical.getGoodsIdList()));
+                repair.setStudentInstrumentId(studentInstrumentId);
+                studentPaymentOrderDetailDao.update(repair);
+            }
 
             //学生云教练处理
-            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);
+            StudentPaymentOrderDetail cloudTeacher = allDetails.stream().filter(o -> o.getType()==CLOUD_TEACHER).findFirst().get();
+            if(cloudTeacher != null){
+                BigDecimal cloudTeacherFee = allDetails.stream() .filter(o -> o.getType()==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) {
@@ -1350,7 +1362,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         List<String> orderDetailTypes = studentPaymentOrderDetailDao.getOrderDetailType(studentPaymentOrder.getId());
         List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupRegCalender.getId());
         BigDecimal courseTotalPrice = courseSettings.stream().filter(e -> orderDetailTypes.contains(e.getCourseType().getCode())).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-        BigDecimal optionalCourseFee = courseSettings.stream().filter(MusicGroupPaymentCalenderCourseSettings::getIsStudentOptional).filter(e -> orderDetailTypes.contains(e.getCourseType().getCode())).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal optionalCourseFee = courseSettings.stream().filter(e -> orderDetailTypes.contains(e.getCourseType().getCode())).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 
         List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
 

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

@@ -2629,25 +2629,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		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("订单还在交易中,请稍后重试");
-			}*/
-			if(!vipGroupBuyParams.isRepeatPay()){
-				return BaseController.failed(HttpStatus.CONTINUE, "您有待支付的订单,是否继续支付");
-			}
-			//处理关闭订单
-			applyOrder.setStatus(DealStatusEnum.CLOSE);
-			applyOrder.setMemo("关闭VIP订单");
-			if (applyOrder.getBalancePaymentAmount() != null && applyOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
-				sysUserCashAccountService.updateBalance(applyOrder.getUserId(), applyOrder.getBalancePaymentAmount(),
-						PlatformCashAccountDetailTypeEnum.REFUNDS, "购买VIP支付失败");
-			}
-			studentPaymentOrderService.update(applyOrder);
-			sysCouponCodeService.quit(applyOrder.getCouponCodeId());
+			//校验重复支付
+			HttpResponseResult result = studentPaymentOrderService.checkRepeatPay(applyOrder, vipGroupBuyParams.isRepeatPay());
+			if(result.getCode() != 200){
+				return result;
+			}
 			classGroup.setStudentNum(classGroup.getStudentNum() - 1);
 		}
 

+ 7 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderActivityDao.xml

@@ -101,4 +101,11 @@
     <select id="findByCalenderId" resultType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderActivity">
       SELECT <include refid="Base_Column_List"/> FROM music_group_payment_calender_activity WHERE calender_id_ = #{calenderId}
     </select>
+    <select id="findByIds" resultType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderActivity">
+      SELECT <include refid="Base_Column_List"/> FROM music_group_payment_calender_activity
+      WHERE id_ IN
+        <foreach collection="activityIdList" separator="," item="id" close=")" open="(">
+          #{id}
+        </foreach>
+    </select>
 </mapper>

+ 3 - 24
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -40,6 +40,7 @@
         <result column="activity_id_" property="activityId"/>
         <result column="activity_buy_num_" property="activityBuyNum"/>
         <result column="tenant_id_" property="tenantId"/>
+        <result column="calender_id_" property="calenderId"/>
     </resultMap>
 
     <resultMap type="com.ym.mec.biz.dal.dto.StudentPaymentOrderDto" extends="StudentPaymentOrder"
@@ -109,7 +110,7 @@
          balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
          status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
          payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_,batch_no_,coupon_code_id_,
-         coupon_remit_fee_,activity_id_,activity_buy_num_,tenant_id_)
+         coupon_remit_fee_,activity_id_,activity_buy_num_,tenant_id_,calender_id_)
         VALUES (#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
                 #{userId}, #{organId}, #{routingOrganId},
                 #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
@@ -118,7 +119,7 @@
                 #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
                 #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
                 #{musicGroupId},
-                #{classGroupId}, #{payTime},#{batchNo},#{couponCodeId},#{couponRemitFee},#{activityId},#{activityBuyNum},#{tenantId})
+                #{classGroupId}, #{payTime},#{batchNo},#{couponCodeId},#{couponRemitFee},#{activityId},#{activityBuyNum},#{tenantId},#{calenderId})
     </insert>
 
 
@@ -404,19 +405,6 @@
         </where>
     </sql>
 
-    <select id="queryApplyGoodsList" resultMap="Goods" parameterType="map">
-        select g.*
-        from goods g
-        where g.id_ in (SELECT spod.goods_id_list_
-                        FROM student_payment_order spo
-                                 left join
-                             student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
-                        where spo.music_group_id_ =
-                              #{musicGroupId}
-                          and spo.type_ = 'APPLY'
-                          and spod.type_ =
-                              #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
-    </select>
     <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
         SELECT spo.*
         FROM student_payment_order spo
@@ -572,15 +560,6 @@
           AND spo.type_ = 'APPLY' and spo.status_ = 'SUCCESS'
         GROUP BY sr.user_id_;
     </select>
-    <select id="findOrderByGroupType" resultType="int">
-        SELECT COUNT(id_) FROM student_payment_order
-        WHERE group_type_ = #{groupType}
-        AND user_id_ = #{userId}
-        AND music_group_id_ = #{sporadicId}
-        <if test="status != null">
-            AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-        </if>
-    </select>
     <select id="findPaymentOrderByGroupType" resultMap="StudentPaymentOrder">
         SELECT * FROM student_payment_order
         WHERE group_type_ = #{groupType}

+ 3 - 31
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -331,39 +331,17 @@ public class MusicGroupController extends BaseController {
     @ApiOperation(value = "乐团报名支付")
     @PostMapping("/pay")
     public HttpResponseResult pay(@RequestBody RegisterPayDto registerPayDto) throws Exception {
-
         StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
         if (studentRegistration == null) {
             return failed("报名信息有误,请核查");
         }
-
         String err = studentRegistrationService.checkRegOrPayStatus(studentRegistration.getMusicGroupId());
         if (err != null) {
             return failed(err + "不可缴费,请联系教务老师");
         }
-
-        Integer userId = studentRegistration.getUserId();
-
-        //判断用户是否已存在订单
-        List<StudentPaymentOrder> applyOrderList = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.ING);
-        
-        if (applyOrderList != null && applyOrderList.size() > 0) {
-        	StudentPaymentOrder applyOrder = applyOrderList.get(0);
-        	// 查询订单状态
-            PayStatus payStatus = studentPaymentOrderService.queryPayStatus(applyOrder.getPaymentChannel(), applyOrder.getOrderNo(), applyOrder.getTransNo());
-            if(payStatus == PayStatus.SUCCESSED){
-        		throw new BizException("订单已支付成功,请勿重复支付");
-        	}
-            return failed(HttpStatus.CONTINUE, "您有待支付的订单");
-        }
-        Map payMap = musicGroupService.pay(registerPayDto);
-        if (payMap.containsKey("hasPaidZero")) {
-            return failed(HttpStatus.RESET_CONTENT, payMap, "报名审核中");
-        }
-        if (payMap.containsKey("tradeState")) {
-            return failed(HttpStatus.CREATED, payMap, "恭喜您,报名成功!");
-        }
-        return succeed(payMap);
+        registerPayDto.setUserId(studentRegistration.getUserId());
+        registerPayDto.setMusicGroupId(studentRegistration.getMusicGroupId());
+        return succeed(musicGroupService.pay(registerPayDto));
     }
 
     @ApiOperation(value = "乐团报名重新支付")
@@ -374,16 +352,10 @@ public class MusicGroupController extends BaseController {
         if (studentRegistration == null) {
             return failed("报名信息有误,请核查");
         }
-
         String err = studentRegistrationService.checkRegOrPayStatus(studentRegistration.getMusicGroupId());
         if (err != null) {
             return failed(err + "不可缴费,请联系教务老师");
         }
-//        Integer userId = studentRegistration.getUserId();
-        /*StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId(), DealStatusEnum.SUCCESS);
-        if (ApplyOrder != null) {
-            return failed("您已支付成功,请勿重复支付");
-        }*/
         Map payMap = musicGroupService.rePay(registerPayDto);
         if (payMap.containsKey("hasPaidZero")) {
             return failed(HttpStatus.RESET_CONTENT, payMap, "报名审核中");

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

@@ -77,10 +77,7 @@ public class SporadicChargeInfoController extends BaseController {
                 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, "您有待支付的订单");
             }
         }

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupController.java

@@ -293,7 +293,7 @@ public class MusicGroupController extends BaseController {
 		if(musicGroupRegsDto.getRegisterIds().size() <=0){
 			return failed("请选择要添加的学员");
 		}
-		return succeed(musicGroupService.addMusicGroupRegs(musicGroupRegsDto.getMusicGroupId(),musicGroupRegsDto.getRegisterIds()));
+		return musicGroupService.addMusicGroupRegs(musicGroupRegsDto.getMusicGroupId(),musicGroupRegsDto.getRegisterIds());
 	}
 
 	@ApiOperation(value = "关闭乐团")