Prechádzať zdrojové kódy

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

hgw 3 rokov pred
rodič
commit
b57635d2b9

+ 82 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupApplyGoodsDto.java

@@ -0,0 +1,82 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+public class MusicGroupApplyGoodsDto {
+    //订单金额
+    BigDecimal orderAmount = BigDecimal.ZERO;
+
+    BigDecimal remitFee = BigDecimal.ZERO; //乐器减免金额
+
+    BigDecimal courseRemitFee = BigDecimal.ZERO; //课程减免费用
+
+    boolean remitCourseRFeeFlag = false; //减免课程费用标识
+
+    private Integer organId;
+
+    //乐器及打包辅件价格
+    List<MusicGroupSubjectGoodsGroup> goodsGroups;
+
+    //乐团课
+    List<MusicGroupPaymentCalenderCourseSettings> newCourses;
+
+    public List<MusicGroupPaymentCalenderCourseSettings> getNewCourses() {
+        return newCourses;
+    }
+
+    public void setNewCourses(List<MusicGroupPaymentCalenderCourseSettings> newCourses) {
+        this.newCourses = newCourses;
+    }
+
+    public List<MusicGroupSubjectGoodsGroup> getGoodsGroups() {
+        return goodsGroups;
+    }
+
+    public void setGoodsGroups(List<MusicGroupSubjectGoodsGroup> goodsGroups) {
+        this.goodsGroups = goodsGroups;
+    }
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+
+    public BigDecimal getOrderAmount() {
+        return orderAmount;
+    }
+
+    public void setOrderAmount(BigDecimal orderAmount) {
+        this.orderAmount = orderAmount;
+    }
+
+    public BigDecimal getRemitFee() {
+        return remitFee;
+    }
+
+    public void setRemitFee(BigDecimal remitFee) {
+        this.remitFee = remitFee;
+    }
+
+    public BigDecimal getCourseRemitFee() {
+        return courseRemitFee;
+    }
+
+    public void setCourseRemitFee(BigDecimal courseRemitFee) {
+        this.courseRemitFee = courseRemitFee;
+    }
+
+    public boolean isRemitCourseRFeeFlag() {
+        return remitCourseRFeeFlag;
+    }
+
+    public void setRemitCourseRFeeFlag(boolean remitCourseRFeeFlag) {
+        this.remitCourseRFeeFlag = remitCourseRFeeFlag;
+    }
+}

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

@@ -17,10 +17,14 @@ public class RegisterPayDto extends PayParamBasicDto{
     //乐器id->type
     private Map<Long, String> goodsGroups;
 
+    private String batchNo;
+
     private Integer userId;
 
     private String musicGroupId;
 
+    private Long calenderId;
+
     @ApiModelProperty(value = "可选课程的key",required = false)
     private List<String> courseKeys;
 
@@ -39,6 +43,22 @@ public class RegisterPayDto extends PayParamBasicDto{
     @ApiModelProperty(value = "购买云教练+",required = false)
     private Boolean buyCloudTeacherPlus= false;
 
+    public String getBatchNo() {
+        return batchNo;
+    }
+
+    public void setBatchNo(String batchNo) {
+        this.batchNo = batchNo;
+    }
+
+    public Long getCalenderId() {
+        return calenderId;
+    }
+
+    public void setCalenderId(Long calenderId) {
+        this.calenderId = calenderId;
+    }
+
     public String getMusicGroupId() {
         return musicGroupId;
     }

+ 11 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderDetailService.java

@@ -9,10 +9,7 @@ import com.ym.mec.biz.dal.dto.FeeStudentDto;
 import com.ym.mec.biz.dal.dto.MusicArrearageStudentDto;
 import com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderDetailDto;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderStudentDetail;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.page.ArrearageStudentsQueryInfo;
 import com.ym.mec.biz.dal.page.MusicCalenderDetailQueryInfo;
 import com.ym.mec.common.page.PageInfo;
@@ -113,4 +110,14 @@ public interface MusicGroupPaymentCalenderDetailService extends BaseService<Long
     void pushWaitRenewMessage(Long calenderId, String studentIds);
 
     PageInfo<MusicGroupPaymentCalenderDetailDto> queryDetailPage(MusicCalenderDetailQueryInfo queryInfo);
+
+    /**
+    * @description: 生成缴费项目学员详情
+     * @param studentPaymentOrder
+ * @param studentRegistration
+    * @return void
+    * @author zx
+    * @date 2021/12/30 15:16
+    */
+    void addCalenderDetail(StudentPaymentOrder studentPaymentOrder, StudentRegistration studentRegistration);
 }

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

@@ -68,7 +68,7 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	 * @param registerPayDto
 	 * @return
 	 */
-	Map rePay(RegisterPayDto registerPayDto) throws Exception;
+//	Map rePay(RegisterPayDto registerPayDto) throws Exception;
 
 	/**
 	 * 获取学生所在乐团详情
@@ -204,7 +204,7 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	 *  续费
 	 * @return
 	 */
-	HttpResponseResult renew(RenewParamDto renewParamDto) throws Exception;
+	HttpResponseResult renew(RegisterPayDto renewParamDto) throws Exception;
 
 	/**
 	 * 学生支付订单

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderDetailService.java

@@ -103,5 +103,12 @@ public interface StudentPaymentOrderDetailService extends BaseService<Long, Stud
      */
     List<StudentPaymentOrderDetail> getOrderGoodsDetail(Long orderId);
 
+    /**
+    * @description: 获取订单详情列表
+     * @param orderId
+    * @return java.util.List<com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail>
+    * @author zx
+    * @date 2021/12/30 15:13
+    */
     List<StudentPaymentOrderDetail> queryOrderDetail(Long orderId);
 }

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

@@ -109,13 +109,7 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      * @throws Exception
      */
     StudentPaymentOrder addOrder(StudentRegistration studentRegistration,
-                                 BigDecimal amount,
-                                 String orderNo,
-                                 String paymentChannel,
-                                 List<MusicGroupSubjectGoodsGroup> goodsGroups,
-                                 BigDecimal remitFee,
-                                 BigDecimal courseRemitFee,
-                                 List<MusicGroupPaymentCalenderCourseSettings> newCourses,RegisterPayDto registerPayDto, Long calenderId) throws Exception;
+                                 StudentPaymentOrder studentPaymentOrder,MusicGroupApplyGoodsDto goodsDto,RegisterPayDto registerPayDto) throws Exception;
 
     /**
      * 查询用户指定乐团的报名信息

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

@@ -89,7 +89,7 @@ public class MusicGroupPaymentCalenderActivityServiceImpl extends BaseServiceImp
             calenderActivities.forEach(e -> {
                 VipGroupActivity activity1 = vipGroupActivityMap.get(e.getActivityId());
                 if(activity1 != null){
-                    e.setOriginalAmount(activity1.getMarketPrice());
+                    e.setOriginalAmount(activity1.getOriginalPrice());
                     e.setActivityName(activity1.getName());
                     e.setNum(new BigDecimal(activity1.getMaxCourseNum()));
                     if(StringUtils.isNotEmpty(activity1.getVipGroupCategoryIdList())){

+ 114 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -716,4 +716,118 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 		pageInfo.setRows(dataList);
 		return pageInfo;
     }
+
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public void addCalenderDetail(StudentPaymentOrder studentPaymentOrder, StudentRegistration studentRegistration) {
+		Date nowDate = new Date();
+
+		String currentMusicGroupId = studentRegistration.getMusicGroupId();
+
+		//缴费详情 calender detail
+		MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(currentMusicGroupId);
+		if (musicGroupRegCalender == null) {
+			throw new BizException("报名缴费信息查询失败");
+		}
+		Integer tenantId = studentPaymentOrder.getTenantId();
+
+		String batchNo = musicGroupRegCalender.getBatchNo();
+		Long currentPaymentCalenderId = musicGroupRegCalender.getId();
+
+		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
+
+		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
+			if (currentPaymentCalenderId.longValue() == musicGroupPaymentCalender.getId()) {
+				// 更新实际缴费人数
+				if (musicGroupPaymentCalender.getActualNum() == null) {
+					musicGroupPaymentCalender.setActualNum(1);
+				} else {
+					musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + 1);
+				}
+			}
+			if (musicGroupPaymentCalender.getExpectNum() == null) {
+				musicGroupPaymentCalender.setExpectNum(1);
+			} else {
+				musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + 1);
+			}
+			musicGroupPaymentCalender.setUpdateTime(nowDate);
+		}
+		if (musicGroupPaymentCalenderList.size() > 0) {
+			musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
+		}
+
+		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(e -> orderDetailTypes.contains(e.getCourseType().getCode())).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+		List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
+
+		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
+			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
+			musicGroupPaymentCalenderDetail.setTenantId(tenantId);
+			musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+			musicGroupPaymentCalenderDetail.setUserId(studentPaymentOrder.getUserId());
+			musicGroupPaymentCalenderDetail.setResponsibleUserId(musicGroupPaymentCalender.getOperator());
+
+			if (currentPaymentCalenderId.longValue() == musicGroupPaymentCalender.getId()) {
+				musicGroupPaymentCalenderDetail.setExpectAmount(courseTotalPrice);
+				if (studentPaymentOrder.getCourseRemitFee() != null && (studentPaymentOrder.getCourseRemitFee().compareTo(BigDecimal.ZERO) > 0)) {
+					musicGroupPaymentCalenderDetail.setActualAmount(optionalCourseFee);
+				} else {
+					musicGroupPaymentCalenderDetail.setActualAmount(courseTotalPrice);
+				}
+				musicGroupPaymentCalenderDetail.setPaymentStatus(PAID_COMPLETED);
+				musicGroupPaymentCalenderDetail.setPayTime(nowDate);
+				musicGroupPaymentCalenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+				musicGroupPaymentCalenderDetail.setUseInCourse(0);
+				musicGroupPaymentCalenderDetail.setOpen(1);
+			} else {
+				musicGroupPaymentCalenderDetail.setExpectAmount(musicGroupPaymentCalender.getPaymentAmount());
+				musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
+			}
+			if(orderDetailTypes.contains(OrderDetailTypeEnum.CLOUD_TEACHER.name()) || orderDetailTypes.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS.name())){
+				musicGroupPaymentCalenderDetail.setExpectAmount(musicGroupPaymentCalenderDetail.getExpectAmount().add(musicGroupPaymentCalender.getMemberPaymentAmount()));
+				musicGroupPaymentCalenderDetail.setActualAmount(musicGroupPaymentCalenderDetail.getActualAmount().add(musicGroupPaymentCalender.getMemberPaymentAmount()));
+			}
+
+			musicGroupPaymentCalenderDetail.setUserStatus(null);
+			musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
+			musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
+			musicGroupPaymentCalenderDetail.setCreateTime(nowDate);
+			musicGroupPaymentCalenderDetail.setUpdateTime(nowDate);
+
+			musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
+
+			List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
+					.getWithPaymentCalender(musicGroupPaymentCalender.getId());
+			for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
+				if (musicGroupRegCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)
+						&& !orderDetailTypes.contains(courseSetting.getCourseType().getCode())) {
+					continue;
+				}
+				if (courseSetting.getCourseTotalMinuties() == null || courseSetting.getCourseTotalMinuties() == 0) {
+					continue;
+				}
+				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
+				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
+				musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
+				musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
+				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
+				musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
+				musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
+				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
+				musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
+				musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);
+				musicGroupPaymentStudentCourseDetail.setTenantId(tenantId);
+
+				musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
+			}
+		}
+
+		if (musicGroupPaymentStudentCourseDetails.size() > 0) {
+			musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
+		}
+    }
 }

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

@@ -1850,10 +1850,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.get(calenderDetailId);
 		MusicGroupPaymentCalender calender = this.get(calenderDetail.getMusicGroupPaymentCalenderId());
 		MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, calender.getMusicGroupId());
-		if(calender.getIsGiveMusicNetwork() && musicGroupStudentFee != null){
-			//赠送网管课
-			musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
-		}
+//		if(calender.getIsGiveMusicNetwork() && musicGroupStudentFee != null){
+//			//赠送网管课
+//			musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
+//		}
 		//更新学生的缴费记录状态
 		calenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
 		calenderDetail.setActualAmount(calenderDetail.getExpectAmount().add(calenderDetail.getExpectMemberAmount()));

+ 297 - 345
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -4,14 +4,8 @@ import static com.ym.mec.biz.dal.entity.ApprovalStatus.PROCESSING;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.CLOSE;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.ING;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.ACCESSORIES;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.CLOUD_TEACHER;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.CLOUD_TEACHER_PLUS;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.DEGREE_REGISTRATION;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.MAINTENANCE;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.MUSICAL;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.OTHER;
-import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.TEACHING;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.*;
+import static com.ym.mec.biz.dal.enums.OrderDetailTypeEnum.VIP;
 import static com.ym.mec.biz.dal.enums.PaymentStatusEnum.YES;
 
 import java.io.IOException;
@@ -32,6 +26,7 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.service.*;
@@ -51,19 +46,6 @@ import com.alibaba.fastjson.TypeReference;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUserRole;
-import com.ym.mec.biz.dal.dto.BasicUserDto;
-import com.ym.mec.biz.dal.dto.CloseMusicGroupDto;
-import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
-import com.ym.mec.biz.dal.dto.HighClassGroupDto;
-import com.ym.mec.biz.dal.dto.MusicCardDto;
-import com.ym.mec.biz.dal.dto.MusicGroupBasicDto;
-import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.dto.RenewParamDto;
-import com.ym.mec.biz.dal.dto.SporadicPayDto;
-import com.ym.mec.biz.dal.dto.StudentApplyInstrumentDto;
-import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
-import com.ym.mec.biz.dal.dto.SubjectRegisterDto;
-import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType;
@@ -151,6 +133,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Autowired
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
     @Autowired
+    private SellOrderService sellOrderService;
+    @Autowired
     private PayService payService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
@@ -179,6 +163,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Autowired
     private ClassGroupStudentMapperService classGroupStudentMapperService;
     @Autowired
+    private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
+    @Autowired
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
     @Autowired
     private ImGroupMemberService imGroupMemberService;
@@ -208,7 +194,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     @Autowired
     private StudentPreRegistrationDao studentPreRegistrationDao;
     @Autowired
-    private OrganizationCloudTeacherFeeDao organizationCloudTeacherFeeDao;
+    private ActivityUserMapperService activityUserMapperService;
 
     @Autowired
     private GroupEventSource groupEventSource;
@@ -233,6 +219,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Autowired
     private SysCouponCodeService sysCouponCodeService;
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
 
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
 
@@ -664,109 +652,237 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    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());
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+    public HttpResponseResult renew(RegisterPayDto renewParamDto) throws Exception {
+        Long calenderId = renewParamDto.getCalenderId();
+        Integer userId = renewParamDto.getUserId();
+        MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
+        StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, calender.getMusicGroupId());
+        if (studentRegistration == null) {
+            throw new BizException("请走报名缴费流程");
+        }
+        Integer organId = studentRegistration.getOrganId();
+        MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByCalenderIdAndUserId(calenderId, userId);
+        //关闭之前的订单
+        if (calenderDetail.getPaymentOrderId() != null) {
+            StudentPaymentOrder oldStudentPaymentOrder = studentPaymentOrderDao.get(calenderDetail.getPaymentOrderId());
+            HttpResponseResult result = studentPaymentOrderService.checkRepeatPay(oldStudentPaymentOrder, renewParamDto.getRepeatPay());
             if(result.getCode() != 200){
                 return result;
             }
         }
-        StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
-        if (studentRegistration == null) {
-            throw new BizException("报名信息有误,请核查");
+
+        //获取订单总金额
+        MusicGroupApplyGoodsDto goodsDto = getCalenderTotalAmount(renewParamDto,calender);
+
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+
+        Date date = new Date();
+        //使用优惠券
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(renewParamDto.getCouponIdList(),goodsDto.getOrderAmount(),true);
+        studentPaymentOrder.setGroupType(GroupType.MUSIC);
+        studentPaymentOrder.setUserId(userId);
+        studentPaymentOrder.setOrderNo(orderNo);
+        if (calender.getPaymentType() == PaymentType.ADD_STUDENT) {
+            studentPaymentOrder.setType(OrderTypeEnum.ADD_STUDENT);
+        } else {
+            studentPaymentOrder.setType(OrderTypeEnum.RENEW);
         }
-        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(studentRegistration.getMusicGroupId());
-        if(musicGroupRegCalender == null){
-        	throw new BizException("缴费信息不存在");
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setMusicGroupId(calender.getMusicGroupId());
+        studentPaymentOrder.setBatchNo(calender.getId() + "");
+        studentPaymentOrder.setCreateTime(date);
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrder.setVersion(0);
+        studentPaymentOrderService.insert(studentPaymentOrder);
+        // 订单详情
+        studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration,studentPaymentOrder,goodsDto,renewParamDto);
+        BigDecimal actualAmount = studentPaymentOrder.getActualAmount();
+
+        BigDecimal amount = renewParamDto.getAmount(); //前端获取的价格
+        if (amount.compareTo(actualAmount) != 0) {
+            throw new BizException("商品价格不符");
         }
-        MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
-        if(musicGroup == null){
-            throw new BizException("查询乐团信息失败");
+        if (amount.compareTo(BigDecimal.ZERO) < 0) {
+            throw new BizException("价格异常");
         }
-//        Integer tenantId = TenantContextHolder.getTenantId();
+        calenderDetail.setPaymentStatus(PaymentStatus.PROCESSING);
+        calenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+        musicGroupPaymentCalenderDetailDao.update(calenderDetail);
 
-        Long calenderId = musicGroupRegCalender.getId();
-        Integer userId = studentRegistration.getUserId();
+        BigDecimal balance = BigDecimal.ZERO;
+        if (renewParamDto.getUseBalancePayment() || amount.doubleValue() == 0) {
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+            if (userCashAccount == null) {
+                throw new BizException("用户账户找不到");
+            }
+            studentPaymentOrder.setPaymentChannel("BALANCE");
+            if (userCashAccount.getBalance().subtract(amount).doubleValue() >= 0) {
+                // 更新订单信息
+                balance = amount;
+                studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
+                studentPaymentOrder.setBalancePaymentAmount(amount);
+                studentPaymentOrder.setActualAmount(new BigDecimal(0));
+                studentPaymentOrder.setUpdateTime(date);
+                studentPaymentOrder.setOrganId(organId);
+                studentPaymentOrder.setRoutingOrganId(organId);
+                studentPaymentOrderService.update(studentPaymentOrder);
+                sysUserCashAccountService.updateBalance(userId, amount.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团续费");
+                amount = BigDecimal.ZERO;
+            } else {
+                if (userCashAccount.getBalance().doubleValue() > 0) {
+                    balance = userCashAccount.getBalance();
+                    sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团续费");
+                    amount = amount.subtract(userCashAccount.getBalance());
+                    studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
+                    studentPaymentOrder.setActualAmount(studentPaymentOrder.getActualAmount().subtract(userCashAccount.getBalance()));
+                } else {
+                    studentPaymentOrder.setBalancePaymentAmount(new BigDecimal(0));
+                }
+            }
+        }
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
 
-        BigDecimal orderAmount = BigDecimal.ZERO;
-        //获取课程价格
-//        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
-//        BigDecimal courseFee = musicOneSubjectClassPlan.getFee() == null ? BigDecimal.ZERO : musicOneSubjectClassPlan.getFee();
-//        orderAmount = orderAmount.add(courseFee);
+        if (amount.compareTo(BigDecimal.ZERO) == 0) {
+            studentPaymentRouteOrderService.addRouteOrder(orderNo, organId, balance);
+            Map<String, String> notifyMap = new HashMap<>(4);
+            notifyMap.put("tradeState", "1");
+            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+            notifyMap.put("channelType", "");
+            notifyMap.put("orderNo", "");
+            studentPaymentOrderService.updateOrder(notifyMap);
+            return BaseController.failed(HttpStatus.CREATED, notifyMap, "恭喜您,缴费成功!");
+        }
 
-        BigDecimal remitFee = BigDecimal.ZERO; //乐器减免金额
-        BigDecimal courseRemitFee = BigDecimal.ZERO; //课程减免费用
-        boolean remitCourseRFeeFlag = false; //减免课程费用标识
+        Map<String, Object> payMap = payService.getPayMap(
+                amount,
+                balance,
+                orderNo,
+                baseApiUrl + "/api-student/studentOrder/notify",
+                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + studentPaymentOrder.getOrderNo(),
+                "续费",
+                "乐团续费",
+                organId,
+                "renew"
+        );
+
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setOrganId(organId);
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.update(studentPaymentOrder);
+        return BaseController.succeed(payMap);
+    }
 
+    private MusicGroupApplyGoodsDto getCalenderTotalAmount(RegisterPayDto registerPayDto,MusicGroupPaymentCalender calender){
+        MusicGroupApplyGoodsDto goodsDto = new MusicGroupApplyGoodsDto();
         //乐器及打包辅件价格
-        List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
+        List<MusicGroupSubjectGoodsGroup> goodsGroups;
         if (registerPayDto.getGoodsGroups() != null && registerPayDto.getGoodsGroups().size() > 0) {
             String goodsGroupIds = registerPayDto.getGoodsGroups().keySet().stream().map(Object::toString).collect(Collectors.joining(","));
             goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(goodsGroupIds);
-        }
-        for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
-            Map<String, BigDecimal> groupType = JSONObject.parseObject(goodsGroup.getKitGroupPurchaseTypeJson(), new TypeReference<Map<String, BigDecimal>>() {});
-
-            if (goodsGroup.getType().equals(GoodsType.INSTRUMENT)) {
-                String kitGroupPurchaseType = registerPayDto.getGoodsGroups().get(goodsGroup.getId());
-                if (!groupType.containsKey(kitGroupPurchaseType)) {
-                    throw new BizException("乐器提供方式不存在,请核查");
-                }
-                if (!kitGroupPurchaseType.equals("GROUP")) {
-                    goodsGroup.setPrice(kitGroupPurchaseType.equals("FREE") ? new BigDecimal(0) : goodsGroup.getDepositFee());
-                } else {
-                    //购买乐器是否减免课程费用
-                    remitCourseRFeeFlag = goodsGroup.getGroupRemissionCourseFee().equals(1);
+            goodsDto.setGoodsGroups(goodsGroups);
+            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+                Map<String, BigDecimal> groupType = JSONObject.parseObject(goodsGroup.getKitGroupPurchaseTypeJson(), new TypeReference<Map<String, BigDecimal>>() {});
+
+                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT)) {
+                    String kitGroupPurchaseType = registerPayDto.getGoodsGroups().get(goodsGroup.getId());
+                    if (!groupType.containsKey(kitGroupPurchaseType)) {
+                        throw new BizException("乐器提供方式不存在,请核查");
+                    }
+                    if (!kitGroupPurchaseType.equals("GROUP")) {
+                        goodsGroup.setPrice(kitGroupPurchaseType.equals("FREE") ? new BigDecimal(0) : goodsGroup.getDepositFee());
+                    } else {
+                        //购买乐器是否减免课程费用
+                        goodsDto.setRemitCourseRFeeFlag(goodsGroup.getGroupRemissionCourseFee().equals(1));
+                    }
+                    goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
+                    goodsDto.setRemitFee(groupType.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : groupType.get(kitGroupPurchaseType));
                 }
-                goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
-                remitFee = groupType.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : groupType.get(kitGroupPurchaseType);
-            }
-            goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
-
-            if(musicGroup.getOrganId() == 55 && (registerPayDto.getNewCourse() == null || registerPayDto.getNewCourse().size() == 0) && !(registerPayDto.getBuyCloudTeacher() || registerPayDto.getBuyCloudTeacherPlus())){
-            	//取商品零售价
-                if (StringUtils.isNotBlank(goodsGroup.getGoodsIdList())) {
-                	List<Goods> goodsList = goodsDao.findGoodsByIds(goodsGroup.getGoodsIdList());
-                	for(Goods goods : goodsList){
-                		orderAmount = orderAmount.add(goods.getDiscountPrice());
-                	}
+                goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
+
+                //齐齐哈尔走特殊规则
+                if(calender.getOrganId() == 55 && (registerPayDto.getNewCourse() == null || registerPayDto.getNewCourse().size() == 0) && !(registerPayDto.getBuyCloudTeacher() || registerPayDto.getBuyCloudTeacherPlus())){
+                    //取商品零售价
+                    if (StringUtils.isNotBlank(goodsGroup.getGoodsIdList())) {
+                        List<Goods> goodsList = goodsDao.findGoodsByIds(goodsGroup.getGoodsIdList());
+                        for(Goods goods : goodsList){
+                            goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(goods.getDiscountPrice()));
+                        }
+                    }
+                }else{
+                    goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(goodsGroup.getPrice()));
                 }
-            }else{
-            	orderAmount = orderAmount.add(goodsGroup.getPrice());
             }
+            goodsDto.setOrderAmount(goodsDto.getOrderAmount().subtract(goodsDto.getRemitFee()));
         }
-        orderAmount = orderAmount.subtract(remitFee);
-
         //新课程形态
-        List<MusicGroupPaymentCalenderCourseSettings> newCourses = new ArrayList<>();
-        if (musicGroupRegCalender.getPayUserType() == PayUserType.STUDENT && registerPayDto.getNewCourse() != null && registerPayDto.getNewCourse().size() > 0) {
+        List<MusicGroupPaymentCalenderCourseSettings> newCourses;
+        if (calender.getPayUserType() == PayUserType.STUDENT && registerPayDto.getNewCourse() != null && registerPayDto.getNewCourse().size() > 0) {
             newCourses = musicGroupPaymentCalenderCourseSettingsDao.getCalenderCourseSettings(registerPayDto.getNewCourse());
             for (MusicGroupPaymentCalenderCourseSettings calenderCourseSetting : newCourses) {
-                if (remitCourseRFeeFlag) {
-                    courseRemitFee = courseRemitFee.add(calenderCourseSetting.getCourseCurrentPrice());
+                if (goodsDto.isRemitCourseRFeeFlag()) {
+                    goodsDto.setCourseRemitFee(goodsDto.getCourseRemitFee().add(calenderCourseSetting.getCourseCurrentPrice()));
                 }else {
-                    orderAmount = orderAmount.add(calenderCourseSetting.getCourseCurrentPrice());
+                    goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(calenderCourseSetting.getCourseCurrentPrice()));
                 }
             }
+            goodsDto.setNewCourses(newCourses);
         }
         //活动价格
         List<Long> buyCalenderActivityIdList = registerPayDto.getBuyCalenderActivityId();
         if(buyCalenderActivityIdList != null && buyCalenderActivityIdList.size() > 0){
-            orderAmount = orderAmount.add(musicGroupPaymentCalenderService.getActivityAmount(buyCalenderActivityIdList));
+            goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(musicGroupPaymentCalenderService.getActivityAmount(buyCalenderActivityIdList)));
         }
         //乐器保养价格
         if (registerPayDto.getBuyMaintenance()) {
-            orderAmount = orderAmount.add(musicGroupPaymentCalenderService.getRepairAmount(calenderId));
+            goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(musicGroupPaymentCalenderService.getRepairAmount(calender.getId())));
         }
         //云教练价格和订单
         if (registerPayDto.getBuyCloudTeacher()){
-            orderAmount = orderAmount.add(musicGroupPaymentCalenderService.getMemberAmount(calenderId));
+            goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(musicGroupPaymentCalenderService.getMemberAmount(calender.getId())));
         }
-        
+        //合班缴费
+        List<MusicGroupPaymentCalenderStudentDetail> studentDetails = musicGroupPaymentCalenderStudentDetailDao.findByBatchNoAndUserId(registerPayDto.getBatchNo(), registerPayDto.getUserId());
+        if(studentDetails != null && studentDetails.size() > 0){
+            goodsDto.setOrderAmount(goodsDto.getOrderAmount().add(studentDetails.stream().map(e->e.getCourseCurrentPrice()).reduce(BigDecimal.ZERO,BigDecimal::add)));
+        }
+        return goodsDto;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    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("缴费信息不存在");
+        }
+        registerPayDto.setBatchNo(musicGroupRegCalender.getBatchNo());
+        MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
+        if(musicGroup == null){
+            throw new BizException("查询乐团信息失败");
+        }
+
+        Long calenderId = musicGroupRegCalender.getId();
+        Integer userId = studentRegistration.getUserId();
+
+        //获取缴费项目金额
+        MusicGroupApplyGoodsDto goodsDto = getCalenderTotalAmount(registerPayDto,musicGroupRegCalender);
+
         studentRegistration.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
         studentRegistration.setOrganId(musicGroup.getOrganId());
         studentRegistration.setPayingStatus(1);
@@ -776,20 +892,23 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
         String channelType = "";
-        //生成订单、订单详情
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration,
-                orderAmount,
-                orderNo,
-                channelType,
-                goodsGroups,
-                remitFee,
-                courseRemitFee,
-                newCourses,
-                registerPayDto,calenderId);
-        orderAmount = studentPaymentOrder.getActualAmount();
+        //生成订单、
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(registerPayDto.getCouponIdList(),goodsDto.getOrderAmount(),true);
+        studentPaymentOrder.setUserId(studentRegistration.getUserId());
+        studentPaymentOrder.setGroupType(GroupType.MUSIC);
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setType(OrderTypeEnum.APPLY);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setPaymentChannel(channelType);
+        studentPaymentOrder.setMusicGroupId(studentRegistration.getMusicGroupId());
+        studentPaymentOrder.setCalenderId(calenderId);
+        studentPaymentOrderService.insert(studentPaymentOrder);
+        // 订单详情
+        studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration,studentPaymentOrder,goodsDto,registerPayDto);
+        BigDecimal actualAmount = studentPaymentOrder.getActualAmount();
 
         BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
-        if (amount.compareTo(orderAmount) != 0) {
+        if (amount.compareTo(actualAmount) != 0) {
             throw new BizException("商品价格不符");
         }
         if (amount.compareTo(BigDecimal.ZERO) < 0) {
@@ -815,8 +934,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
         studentPaymentOrder.setBatchNo(musicGroupRegCalender.getId() + "");
         studentPaymentOrder.setPaymentChannel("BALANCE");
-        studentPaymentOrder.setRemitFee(remitFee);
-        studentPaymentOrder.setCourseRemitFee(courseRemitFee);
+        studentPaymentOrder.setRemitFee(goodsDto.getRemitFee());
+        studentPaymentOrder.setCourseRemitFee(goodsDto.getCourseRemitFee());
         studentPaymentOrder.setOrganId(musicGroup.getOrganId());
         studentPaymentOrder.setRoutingOrganId(musicGroup.getOrganId());
         studentPaymentOrder.setUpdateTime(date);
@@ -886,7 +1005,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         return BaseController.succeed(payMap);
     }
 
-    @Override
+    /*@Override
     @Transactional(rollbackFor = Exception.class)
     public Map rePay(RegisterPayDto registerPayDto) throws Exception {
         StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
@@ -914,9 +1033,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if(payStatus != PayStatus.FAILED){
         	if(payStatus == PayStatus.SUCCESSED){
         		throw new BizException("订单已支付成功,请勿重复支付");
-        	}/*else if(payStatus == PayStatus.PAYING){
+        	}*//*else if(payStatus == PayStatus.PAYING){
         		throw new BizException("订单还在交易中,请稍后重试");
-        	}*/
+        	}*//*
         }
 
     	MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(studentRegistration.getMusicGroupId());
@@ -1054,15 +1173,21 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
         String channelType = "";
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration,
-                orderAmount,
-                orderNo,
-                channelType,
-                goodsGroups,
-                remitFee,
+        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(registerPayDto.getCouponIdList(),amount,true);
+        studentPaymentOrder.setUserId(studentRegistration.getUserId());
+        studentPaymentOrder.setGroupType(GroupType.MUSIC);
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setType(OrderTypeEnum.APPLY);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setPaymentChannel(channelType);
+        studentPaymentOrder.setMusicGroupId(studentRegistration.getMusicGroupId());
+        studentPaymentOrder.setCalenderId(musicGroupRegCalender.getId());
+        studentPaymentOrderService.insert(studentPaymentOrder);
+        //生成订单详情
+        studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration,studentPaymentOrder,goodsGroups,remitFee,
                 courseRemitFee,
                 newCourses,
-                registerPayDto,musicGroupRegCalender.getId());
+                registerPayDto);
         studentPaymentOrder = studentPaymentOrderService.get(studentPaymentOrder.getId());
         orderAmount = studentPaymentOrder.getActualAmount();
         if (amount.compareTo(orderAmount) != 0) {
@@ -1165,7 +1290,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setUpdateTime(date);
         studentPaymentOrderService.update(studentPaymentOrder);
         return payMap;
-    }
+    }*/
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -2929,142 +3054,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public HttpResponseResult renew(RenewParamDto renewParamDto) throws Exception {
-        Long calenderId = renewParamDto.getCalenderId();
-        Integer userId = renewParamDto.getUserId();
-        MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(calenderId);
-        if (calender == null) {
-            throw new BizException("缴费项目不存在");
-        }
-        StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, calender.getMusicGroupId());
-        if (studentRegistration == null) {
-            throw new BizException("请走报名缴费流程");
-        }
-        Integer organId = studentRegistration.getOrganId();
-        MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByCalenderIdAndUserId(calenderId, userId);
-        //关闭之前的订单
-        if (calenderDetail.getPaymentOrderId() != null) {
-            StudentPaymentOrder oldStudentPaymentOrder = studentPaymentOrderDao.get(calenderDetail.getPaymentOrderId());
-            HttpResponseResult result = studentPaymentOrderService.checkRepeatPay(oldStudentPaymentOrder, renewParamDto.getRepeatPay());
-            if(result.getCode() != 200){
-                return result;
-            }
-        }
-        String orderNo = idGeneratorService.generatorId("payment") + "";
-
-        BigDecimal amount = calenderDetail.getExpectAmount().add(calenderDetail.getExpectMemberAmount());
-
-        Date date = new Date();
-        //使用优惠券
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(renewParamDto.getCouponIdList(),amount,true);
-        amount = studentPaymentOrder.getActualAmount();
-        studentPaymentOrder.setGroupType(GroupType.MUSIC);
-        studentPaymentOrder.setUserId(userId);
-        studentPaymentOrder.setOrderNo(orderNo);
-		if (calender.getPaymentType() == PaymentType.ADD_STUDENT) {
-			studentPaymentOrder.setType(OrderTypeEnum.ADD_STUDENT);
-		} else {
-			studentPaymentOrder.setType(OrderTypeEnum.RENEW);
-		}
-        studentPaymentOrder.setStatus(DealStatusEnum.ING);
-        studentPaymentOrder.setMusicGroupId(calender.getMusicGroupId());
-        studentPaymentOrder.setBatchNo(calender.getId() + "");
-        studentPaymentOrder.setCreateTime(date);
-        studentPaymentOrder.setUpdateTime(date);
-        studentPaymentOrder.setVersion(0);
-        studentPaymentOrderService.insert(studentPaymentOrder);
-        calenderDetail.setPaymentStatus(PaymentStatus.PROCESSING);
-        calenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-        musicGroupPaymentCalenderDetailDao.update(calenderDetail);
-
-        CloudTeacherOrder cloudTeacherOrder = null;
-        //云教练/云教练+
-        if (calender.getMemberRankSettingId() != null) {
-            //创建订单
-            cloudTeacherOrder = new CloudTeacherOrder();
-    		cloudTeacherOrder.setType(PeriodEnum.MONTH);//月
-			cloudTeacherOrder.setTime(calender.getMemberValidDate());
-    		cloudTeacherOrder.setOrganId(organId);
-    		cloudTeacherOrder.setStudentId(studentRegistration.getUserId());
-    		cloudTeacherOrder.setLevel(calender.getMemberRankSettingId());
-    		cloudTeacherOrder.setAmount(calender.getMemberPaymentAmount());
-    		cloudTeacherOrder.setStatus(0);
-    		cloudTeacherOrder.setOrderId(studentPaymentOrder.getId());
-    		cloudTeacherOrder.setCreateTime(date);
-    		cloudTeacherOrder.setUpdateTime(date);
-            cloudTeacherOrder.setMusicGroupId(calender.getMusicGroupId());
-    		cloudTeacherOrderService.insert(cloudTeacherOrder);
-        }
-
-        BigDecimal balance = BigDecimal.ZERO;
-        if (renewParamDto.getUseBalancePayment() || amount.doubleValue() == 0) {
-            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
-            if (userCashAccount == null) {
-                throw new BizException("用户账户找不到");
-            }
-            studentPaymentOrder.setPaymentChannel("BALANCE");
-            if (userCashAccount.getBalance().subtract(amount).doubleValue() >= 0) {
-                // 更新订单信息
-                balance = amount;
-                studentPaymentOrder.setActualAmount(BigDecimal.ZERO);
-                studentPaymentOrder.setBalancePaymentAmount(amount);
-                studentPaymentOrder.setActualAmount(new BigDecimal(0));
-                studentPaymentOrder.setUpdateTime(date);
-                studentPaymentOrder.setOrganId(organId);
-                studentPaymentOrder.setRoutingOrganId(organId);
-                studentPaymentOrderService.update(studentPaymentOrder);
-                sysUserCashAccountService.updateBalance(userId, amount.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团续费");
-                amount = BigDecimal.ZERO;
-            } else {
-                if (userCashAccount.getBalance().doubleValue() > 0) {
-                    balance = userCashAccount.getBalance();
-                    sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团续费");
-                    amount = amount.subtract(userCashAccount.getBalance());
-                    studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
-                    studentPaymentOrder.setActualAmount(studentPaymentOrder.getActualAmount().subtract(userCashAccount.getBalance()));
-                } else {
-                    studentPaymentOrder.setBalancePaymentAmount(new BigDecimal(0));
-                }
-            }
-        }
-        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
-
-        if (amount.compareTo(BigDecimal.ZERO) == 0) {
-            studentPaymentRouteOrderService.addRouteOrder(orderNo, organId, balance);
-            Map<String, String> notifyMap = new HashMap<>(4);
-            notifyMap.put("tradeState", "1");
-            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
-            notifyMap.put("channelType", "");
-            notifyMap.put("orderNo", "");
-            studentPaymentOrderService.updateOrder(notifyMap);
-            return BaseController.failed(HttpStatus.CREATED, notifyMap, "恭喜您,缴费成功!");
-        }
-
-        Map<String, Object> payMap = payService.getPayMap(
-                amount,
-                balance,
-                orderNo,
-                baseApiUrl + "/api-student/studentOrder/notify",
-                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + studentPaymentOrder.getOrderNo(),
-                "续费",
-                "乐团续费",
-                organId,
-                "renew"
-        );
-
-        studentPaymentOrder.setActualAmount(amount);
-        studentPaymentOrder.setOrganId(organId);
-        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
-        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
-        studentPaymentOrder.setUpdateTime(date);
-        studentPaymentOrderService.update(studentPaymentOrder);
-        return BaseController.succeed(payMap);
-    }
-
-    @Override
-    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) throws IOException {
-
         int updateNum = studentPaymentOrderService.update(studentPaymentOrder);
         if (updateNum <= 0) {
             throw new BizException("订单更新失败");
@@ -3074,14 +3064,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         Date date = new Date();
         StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
-        Map<Integer, String> yimei = new HashMap<>(1);
-        Map<Integer, String> push = new HashMap<>(1);
-        push.put(userId, userId.toString());
-        yimei.put(userId, studentRegistration.getParentsPhone());
-
         MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.findByOrderId(studentPaymentOrder.getId());
         
         if (studentPaymentOrder.getStatus() == SUCCESS) {
+            MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
             //当前乐团报名是否赠送乐团网管课
             MusicGroupStudentFee musicGroupStudentFee = musicGroupPaymentCalenderService.updateCalender(calenderDetail.getId(), studentRegistration.getUserId());
             if (musicGroupStudentFee != null) {
@@ -3098,45 +3084,64 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
                 studentRegistration.setMusicGroupPaymentCalenderId(paymentCalender.getId());
                 studentRegistrationDao.update(studentRegistration);
-                
                 //统计变更学员数
                 groupEventSource.musicGroupStudentChangeEvent(studentRegistration.getMusicGroupId(), StudentMusicGroupStatusEnum.NORMAL, new ArrayList<>(Arrays.asList(userId)));
             }
 
-            List<StudentPaymentOrderDetail> paymentOrderDetails = new ArrayList<>();
+            //缴费项目详情
+            musicGroupPaymentCalenderDetailService.addCalenderDetail(studentPaymentOrder, studentRegistration);
+
+            List<StudentPaymentOrderDetail> allDetails = studentPaymentOrderDetailService.getOrderGoodsDetail(studentPaymentOrder.getId());
+            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);
+
+            //销售订单详情
+            if (allDetails.size() > 0) {
+                BigDecimal couponRemitFee = studentPaymentOrder.getCouponRemitFee();
+                if(couponRemitFee.compareTo(BigDecimal.ZERO) > 0){
+                    BigDecimal musicFee = allDetails.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();
+                    //获取比例
+                    BigDecimal ratioAmount = musicFee.divide(expectAmount, 6, BigDecimal.ROUND_HALF_UP);
+                    //获取分配的减免金额
+                    couponRemitFee = couponRemitFee.multiply(ratioAmount).setScale(2, BigDecimal.ROUND_HALF_UP);
+                }
+                sellOrderService.addOrderDetail2SellOrder(allDetails, studentPaymentOrder, musicGroup,couponRemitFee);
+            }
 
-			// 查询会员订单信息
-			CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderService.queryByOrderId(studentPaymentOrder.getId());
-			if (cloudTeacherOrder != null) {
-				Student student = studentService.getLocked(userId);
-				if (student == null) {
-					throw new BizException("学员信息不存在");
-				}
-				cloudTeacherOrder.setStatus(1);
-				cloudTeacherOrder.setUpdateTime(date);
-//				if (student.getMemberRankSettingId() == null || date.after(student.getMembershipEndTime())) {
-//					cloudTeacherOrder.setStartTime(date);
-//                    cloudTeacherOrder.setEndTime(studentService.getMembershipEndTime(cloudTeacherOrder.getType(),date, cloudTeacherOrder.getTime()));
-//				} else {
-//					cloudTeacherOrder.setStartTime(DateUtil.addDays(student.getMembershipEndTime(), 1));
-//                    cloudTeacherOrder.setEndTime(studentService.getMembershipEndTime(cloudTeacherOrder.getType(),student.getMembershipEndTime(), cloudTeacherOrder.getTime()));
-//				}
-
-                cloudTeacherOrder.setAmount(calenderDetail.getExpectMemberAmount());
-				cloudTeacherOrderService.update(cloudTeacherOrder);
-				// 添加会员有效时长
-//				studentService.updateMemberRank(cloudTeacherOrder);
-				
-				//添加订单明细
-				StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-                studentPaymentOrderDetail.setType(OrderDetailTypeEnum.CLOUD_TEACHER);
-                studentPaymentOrderDetail.setPrice(cloudTeacherOrder.getAmount());
-                studentPaymentOrderDetail.setCreateTime(date);
-                studentPaymentOrderDetail.setUpdateTime(date);
-                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-                
-                paymentOrderDetails.add(studentPaymentOrderDetail);
-			}
+            //活动小课包处理
+            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);
+            }
+
+            //学生乐器与月保处理
+            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);
+            }
+
+            //学生云教练处理
+            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);
+            }
 
             //插入交易明细
             SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
@@ -3156,50 +3161,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
             rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
             sysUserCashAccountDetailService.insert(rechargeDetail);
-
-            //不包含云教练费用
-            BigDecimal courseFee = BigDecimal.ZERO;
-            //跨团合班没有settings
-            if(paymentCalender.getPaymentType() == PaymentType.SPAN_GROUP_CLASS_ADJUST){
-                List<MusicGroupPaymentCalenderStudentDetail> studentDetails = musicGroupPaymentCalenderStudentDetailDao.findByBatchNoAndUserId(paymentCalender.getBatchNo(), userId);
-                for (MusicGroupPaymentCalenderStudentDetail studentDetail : studentDetails) {
-                    StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-                    studentPaymentOrderDetail.setType(OrderDetailTypeEnum.valueOf(studentDetail.getCourseType()));
-                    studentPaymentOrderDetail.setPrice(studentDetail.getCourseCurrentPrice());
-                    studentPaymentOrderDetail.setCreateTime(date);
-                    studentPaymentOrderDetail.setUpdateTime(date);
-                    studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-                    paymentOrderDetails.add(studentPaymentOrderDetail);
-                    courseFee = courseFee.add(studentDetail.getCourseCurrentPrice());
-                }
-            } else {
-                List<MusicGroupPaymentStudentCourseDetail> studentCourseDetails = musicGroupPaymentStudentCourseDetailDao.findByCalenderAndUserId(calenderDetail.getMusicGroupPaymentCalenderId(), userId);
-                for (MusicGroupPaymentStudentCourseDetail e : studentCourseDetails) {
-                    StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
-                    studentPaymentOrderDetail.setType(OrderDetailTypeEnum.valueOf(e.getCourseType().getCode()));
-                    studentPaymentOrderDetail.setPrice(e.getCourseCurrentPrice());
-                    studentPaymentOrderDetail.setCreateTime(date);
-                    studentPaymentOrderDetail.setUpdateTime(date);
-                    studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-                    paymentOrderDetails.add(studentPaymentOrderDetail);
-                    courseFee = courseFee.add(e.getCourseCurrentPrice());
-                }
-            }
-            if (paymentOrderDetails.size() > 0) {
-                studentPaymentOrderDetailService.batchAdd(paymentOrderDetails,studentPaymentOrder.getCouponRemitFee());
-                //获取实际支付课程费用
-                courseFee = paymentOrderDetails.stream().filter(e->e.getType() != MUSICAL && e.getType() != ACCESSORIES
-                        && e.getType() != TEACHING && e.getType() != OTHER && e.getType() != DEGREE_REGISTRATION
-                        && e.getType() != MAINTENANCE && e.getType() != CLOUD_TEACHER && e.getType() != CLOUD_TEACHER_PLUS).map(t -> t.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
-                //获取云教练订单费用
-                if(cloudTeacherOrder != null){
-                    CloudTeacherOrder teacherOrder = cloudTeacherOrderService.get(cloudTeacherOrder.getId());
-                    BigDecimal cloudTeacherFee = paymentOrderDetails.stream().filter(e->e.getType() == CLOUD_TEACHER).map(t -> t.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
-                    teacherOrder.setAmount(cloudTeacherFee);
-                    cloudTeacherOrderService.update(teacherOrder);
-                }
-            }
-
             //缴费
             SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
             paymentDetail.setAmount(amount.negate());
@@ -3213,7 +3174,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             paymentDetail.setUserId(userId);
             paymentDetail.setChannel(studentPaymentOrder.getPaymentChannel());
             sysUserCashAccountDetailService.insert(paymentDetail);
-            MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 
             studentRegistrationService.updateUserSurplusCourseFee(userId, musicGroupId, courseFee, "乐团续费", userId);
 
@@ -3223,6 +3183,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 logger.error("产品协议生成失败", e);
             }
             if (musicGroup.getOwnershipType() != null && musicGroup.getOwnershipType() == CooperationOrgan.OwnershipType.OWN) {
+                Map<Integer, String> yimei = new HashMap<>(1);
+                Map<Integer, String> push = new HashMap<>(1);
+                push.put(userId, userId.toString());
+                yimei.put(userId, studentRegistration.getParentsPhone());
                 // 发送续费结果通知
                 sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_SMS_PUSH_MUSIC_GROUP_RENEW_SUCCESS, push, null, 0, "1", "STUDENT",
                         studentRegistration.getName(), studentPaymentOrder.getActualAmount());
@@ -3231,7 +3195,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
             return true;
         } else {
-
     		//更新学生的缴费记录状态
     		calenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
     		calenderDetail.setUpdateTime(date);
@@ -3242,17 +3205,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                         "乐团续费失败");
             }
         }
-        /*MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
-        if (musicGroup.getOwnershipType() != null && musicGroup.getOwnershipType() == CooperationOrgan.OwnershipType.OWN) {
-            if (studentPaymentOrder.getStatus() == CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
-                String baseUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
-                String memo = baseUrl + "/#/renew?musicGroupId=" + musicGroupId;
-                //4?http://mstudev.dayaedu.com/#/renew?musicGroupId=" +musicGroupId
-                sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_MUSIC_GROUP_RENEW_FAILED, push, null, 0, "4?" + memo, "STUDENT",
-                        HttpUtil.getSortUrl(memo));
-                return false;
-            }
-        }*/
         return false;
     }
 

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

@@ -140,6 +140,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
     @Autowired
+    private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
+    @Autowired
     private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
     @Autowired
     private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
@@ -162,7 +164,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private StudentInstrumentDao studentInstrumentDao;
     @Autowired
-    private OrganizationCloudTeacherFeeDao organizationCloudTeacherFeeDao;
+    private MusicGroupPaymentCalenderStudentDetailDao musicGroupPaymentCalenderStudentDetailDao;
     @Autowired
     private CloudTeacherOrderService cloudTeacherOrderService;
     @Autowired
@@ -560,25 +562,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel,
-                                        List<MusicGroupSubjectGoodsGroup> goodsGroups, BigDecimal remitFee, BigDecimal courseRemitFee,
-                                        List<MusicGroupPaymentCalenderCourseSettings> newCourses, RegisterPayDto registerPayDto,Long calenderId) throws Exception {
+    public StudentPaymentOrder addOrder(StudentRegistration studentRegistration, StudentPaymentOrder studentPaymentOrder,
+                                        MusicGroupApplyGoodsDto goodsDto,RegisterPayDto registerPayDto) throws Exception {
         Date date = new Date();
-        StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(registerPayDto.getCouponIdList(),amount,true);
-        studentPaymentOrder.setUserId(studentRegistration.getUserId());
-        studentPaymentOrder.setGroupType(GroupType.MUSIC);
-        studentPaymentOrder.setOrderNo(orderNo);
-        studentPaymentOrder.setType(OrderTypeEnum.APPLY);
-        studentPaymentOrder.setStatus(DealStatusEnum.ING);
-        studentPaymentOrder.setPaymentChannel(paymentChannel);
-        studentPaymentOrder.setMusicGroupId(studentRegistration.getMusicGroupId());
-        studentPaymentOrder.setCalenderId(calenderId);
-        studentPaymentOrderService.insert(studentPaymentOrder);
-
         ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
         Integer tenantId = TenantContextHolder.getTenantId();
         //乐器及打包辅件
         String maintenanceGoodsId = "";
+        List<MusicGroupSubjectGoodsGroup> goodsGroups = goodsDto.getGoodsGroups();
+        List<MusicGroupPaymentCalenderCourseSettings> newCourses = goodsDto.getNewCourses();
+        BigDecimal remitFee = goodsDto.getRemitFee();
         if (goodsGroups != null && goodsGroups.size() > 0) {
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 StudentPaymentOrderDetail studentPaymentOrderDetail4goodsGroup = new StudentPaymentOrderDetail();
@@ -623,6 +616,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
         //新的课程形态
         if (newCourses != null && newCourses.size() > 0) {
+            BigDecimal courseRemitFee = goodsDto.getCourseRemitFee();
             for (MusicGroupPaymentCalenderCourseSettings newCourse : newCourses) {
                 StudentPaymentOrderDetail studentPaymentOrderDetailCourse = new StudentPaymentOrderDetail();
                 studentPaymentOrderDetailCourse.setType(OrderDetailTypeEnum.valueOf(newCourse.getCourseType().getCode()));
@@ -639,6 +633,21 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
             }
         }
+
+        //合班缴费
+        List<MusicGroupPaymentCalenderStudentDetail> studentDetails = musicGroupPaymentCalenderStudentDetailDao.findByBatchNoAndUserId(registerPayDto.getBatchNo(), studentPaymentOrder.getUserId());
+        if(studentDetails != null && studentDetails.size() > 0){
+            for (MusicGroupPaymentCalenderStudentDetail studentDetail : studentDetails) {
+                StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail.setType(OrderDetailTypeEnum.valueOf(studentDetail.getCourseType()));
+                studentPaymentOrderDetail.setPrice(studentDetail.getCourseCurrentPrice());
+                studentPaymentOrderDetail.setCreateTime(date);
+                studentPaymentOrderDetail.setUpdateTime(date);
+                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+            }
+        }
+
         //乐保
         if (registerPayDto.getBuyMaintenance()) {
             if ("".equals(maintenanceGoodsId)) {
@@ -1104,9 +1113,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentRegistration.setPayingStatus(0);
             }
 
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.getOrderGoodsDetail(studentPaymentOrder.getId());
-
-            List<Long> orderIdList = new ArrayList<Long>();
+            List<Long> orderIdList = new ArrayList<>();
             orderIdList.add(studentPaymentOrder.getId());
             List<StudentPaymentOrderDetail> allDetails = studentPaymentOrderDetailDao.getOrderDetailByOrderId(orderIdList);
             BigDecimal courseFee = allDetails.stream().filter(o -> !(o.getType()==MUSICAL))
@@ -1117,25 +1124,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                     .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());
-			if (musicGroup.getCourseViewType() == CourseViewTypeEnum.MEMBER_FEE) {
-
-				if(studentRegistration.getNoneNeedCloudTeacher() == 1){
-					studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
-				}
-				
-				if (orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER) || orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS)
-						|| orderTypeList.contains(OrderDetailTypeEnum.MUSICAL)) {
-					studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
-					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));
             studentRegistrationDao.update(studentRegistration);
@@ -1189,6 +1177,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             paymentDetail.setTenantId(tenantId);
             sysUserCashAccountDetailService.insert(paymentDetail);
 
+            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.getOrderGoodsDetail(studentPaymentOrder.getId());
             //销售订单详情
             if (orderDetails.size() > 0) {
                 BigDecimal couponRemitFee = studentPaymentOrder.getCouponRemitFee();
@@ -1206,7 +1195,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             }
 
             //课程处理
-            addCalenderDetail(studentPaymentOrder, studentRegistration);
+            musicGroupPaymentCalenderDetailService.addCalenderDetail(studentPaymentOrder, studentRegistration);
 
             //活动小课包处理
             List<StudentPaymentOrderDetail> activity = allDetails.stream().filter(o -> o.getType()==PRACTICE || o.getType() == VIP).collect(Collectors.toList());
@@ -1308,119 +1297,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     }
 
 
-    private boolean addCalenderDetail(StudentPaymentOrder studentPaymentOrder, StudentRegistration studentRegistration) {
-        Date nowDate = new Date();
-
-        String currentMusicGroupId = studentRegistration.getMusicGroupId();
-
-        //缴费详情 calender detail
-        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(currentMusicGroupId);
-        if (musicGroupRegCalender == null) {
-            throw new BizException("报名缴费信息查询失败");
-        }
-        Integer tenantId = studentPaymentOrder.getTenantId();
-
-        String batchNo = musicGroupRegCalender.getBatchNo();
-        Long currentPaymentCalenderId = musicGroupRegCalender.getId();
-
-        List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
-
-        for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
-            if (currentPaymentCalenderId.longValue() == musicGroupPaymentCalender.getId()) {
-                // 更新实际缴费人数
-                if (musicGroupPaymentCalender.getActualNum() == null) {
-                    musicGroupPaymentCalender.setActualNum(1);
-                } else {
-                    musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + 1);
-                }
-            }
-            if (musicGroupPaymentCalender.getExpectNum() == null) {
-                musicGroupPaymentCalender.setExpectNum(1);
-            } else {
-                musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + 1);
-            }
-            musicGroupPaymentCalender.setUpdateTime(nowDate);
-        }
-        if (musicGroupPaymentCalenderList.size() > 0) {
-            musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
-        }
-
-        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(e -> orderDetailTypes.contains(e.getCourseType().getCode())).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-        List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
-
-        for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
-            MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
-            musicGroupPaymentCalenderDetail.setTenantId(tenantId);
-            musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-            musicGroupPaymentCalenderDetail.setUserId(studentPaymentOrder.getUserId());
-            musicGroupPaymentCalenderDetail.setResponsibleUserId(musicGroupPaymentCalender.getOperator());
-
-            if (currentPaymentCalenderId.longValue() == musicGroupPaymentCalender.getId()) {
-                musicGroupPaymentCalenderDetail.setExpectAmount(courseTotalPrice);
-                if (studentPaymentOrder.getCourseRemitFee() != null && (studentPaymentOrder.getCourseRemitFee().compareTo(BigDecimal.ZERO) > 0)) {
-                    musicGroupPaymentCalenderDetail.setActualAmount(optionalCourseFee);
-                } else {
-                    musicGroupPaymentCalenderDetail.setActualAmount(courseTotalPrice);
-                }
-                musicGroupPaymentCalenderDetail.setPaymentStatus(PAID_COMPLETED);
-                musicGroupPaymentCalenderDetail.setPayTime(nowDate);
-                musicGroupPaymentCalenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
-                musicGroupPaymentCalenderDetail.setUseInCourse(0);
-                musicGroupPaymentCalenderDetail.setOpen(1);
-            } else {
-                musicGroupPaymentCalenderDetail.setExpectAmount(musicGroupPaymentCalender.getPaymentAmount());
-                musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
-            }
-            if(orderDetailTypes.contains(OrderDetailTypeEnum.CLOUD_TEACHER.name()) || orderDetailTypes.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS.name())){
-            	musicGroupPaymentCalenderDetail.setExpectAmount(musicGroupPaymentCalenderDetail.getExpectAmount().add(musicGroupPaymentCalender.getMemberPaymentAmount()));
-            	musicGroupPaymentCalenderDetail.setActualAmount(musicGroupPaymentCalenderDetail.getActualAmount().add(musicGroupPaymentCalender.getMemberPaymentAmount()));
-            }
-            
-            musicGroupPaymentCalenderDetail.setUserStatus(null);
-            musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupPaymentCalender.getDeadlinePaymentDate());
-            musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupPaymentCalender.getStartPaymentDate());
-            musicGroupPaymentCalenderDetail.setCreateTime(nowDate);
-            musicGroupPaymentCalenderDetail.setUpdateTime(nowDate);
-
-            musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
-
-            List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
-                    .getWithPaymentCalender(musicGroupPaymentCalender.getId());
-            for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
-                if (musicGroupRegCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)
-                        && !orderDetailTypes.contains(courseSetting.getCourseType().getCode())) {
-                    continue;
-                }
-                if (courseSetting.getCourseTotalMinuties() == null || courseSetting.getCourseTotalMinuties() == 0) {
-                    continue;
-                }
-                MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-                musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-                musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
-                musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
-                musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
-                musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
-                musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
-                musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
-                musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
-                musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
-                musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);
-                musicGroupPaymentStudentCourseDetail.setTenantId(tenantId);
-
-                musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
-            }
-        }
-
-        if (musicGroupPaymentStudentCourseDetails.size() > 0) {
-            musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
-        }
-        return true;
-    }
-
     @Override
     public List<StudentRegistration> findMusicGroupNoClassGroupStudent(String musicGroupId, Integer actualSubjectId) {
         //获取所有声部

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -696,7 +696,7 @@
     <sql id="queryCalenderPageSql">
         <where>
             <if test="search != null and search != ''">
-                AND mgpc.music_group_id_ = #{search} OR mg.name_ LIKE CONCAT('%',#{search},'%')
+                AND (mgpc.music_group_id_ = #{search} OR mg.name_ LIKE CONCAT('%',#{search},'%'))
             </if>
             <if test="musicGroupId != null">
                 AND mgpc.music_group_id_ = #{musicGroupId}

+ 21 - 42
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -1,59 +1,37 @@
 package com.ym.mec.student.controller;
 
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.ADD_STUDENT;
-import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
-
-import com.ym.mec.biz.service.*;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-import javax.annotation.Resource;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.StudentPreRegistrationDao;
 import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
 import com.ym.mec.biz.dal.dto.RenewParamDto;
-import com.ym.mec.biz.dal.entity.ApprovalStatus;
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.MusicGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupQuit;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
-import com.ym.mec.biz.dal.entity.StudentPreRegistration;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
-import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.MusicGroupStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
-import com.ym.mec.biz.dal.enums.PayStatus;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 @RequestMapping("musicGroup")
 @Api(tags = "乐团服务")
@@ -94,7 +72,6 @@ public class MusicGroupController extends BaseController {
         if (sysUser == null) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-
         return succeed(studentPreRegistrationDao.queryByMusicGroupIdAndUserId(sysUser.getId(), musicGroupId));
     }
 
@@ -287,7 +264,7 @@ public class MusicGroupController extends BaseController {
 
     @ApiOperation(value = "续费")
     @PostMapping("/renew")
-    public HttpResponseResult renew(@RequestBody RenewParamDto renewParamDto) throws Exception {
+    public HttpResponseResult renew(@RequestBody RegisterPayDto renewParamDto) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Integer userId = sysUser.getId();
         Long calenderId = renewParamDto.getCalenderId();
@@ -305,6 +282,7 @@ public class MusicGroupController extends BaseController {
         //缴费项目已开启或者单独开启
         if (calender.getStatus() == PaymentCalenderStatusEnum.OPEN || calenderDetail.getOpen() == 1) {
             renewParamDto.setUserId(userId);
+            renewParamDto.setBatchNo(calender.getBatchNo());
             return musicGroupService.renew(renewParamDto);
         } else if (calender.getStatus() == PaymentCalenderStatusEnum.OVER) {
             throw new BizException("缴费已截止,如有问题请联系指导老师");
@@ -333,7 +311,7 @@ public class MusicGroupController extends BaseController {
     @PostMapping("/rePay")
     @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "RegisterPayDto")})
     public HttpResponseResult rePay(@RequestBody RegisterPayDto registerPayDto) throws Exception {
-        StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
+        /*StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
         if (studentRegistration == null) {
             return failed("报名信息有误,请核查");
         }
@@ -348,7 +326,8 @@ public class MusicGroupController extends BaseController {
         if (payMap.containsKey("tradeState")) {
             return failed(HttpStatus.CREATED, payMap, "恭喜您,报名成功!");
         }
-        return succeed(payMap);
+        return succeed(payMap);*/
+        return failed("操作失败,请联系管理员");
     }
 
     @ApiOperation(value = "订单状态查询")