浏览代码

Merge remote-tracking branch 'origin/master'

zouxuan 4 年之前
父节点
当前提交
2cacae853b
共有 30 个文件被更改,包括 727 次插入153 次删除
  1. 1 1
      codegen/src/main/resources/generateConfigration.xml
  2. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentExtracurricularExercisesSituationDao.java
  3. 40 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SoundCompareHelper.java
  4. 43 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicCompareRecord.java
  5. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysSuggestion.java
  6. 35 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/DeviceTypeEnum.java
  7. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/PayStatus.java
  8. 34 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SuggestionType.java
  9. 54 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/SysSuggestionQueryInfo.java
  10. 7 6
      mec-biz/src/main/java/com/ym/mec/biz/handler/WebSocketHandler.java
  11. 3 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  12. 6 4
      mec-biz/src/main/java/com/ym/mec/biz/service/WebSocketEventHandler.java
  13. 65 27
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  14. 57 24
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundCompareHandler.java
  15. 16 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java
  16. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java
  17. 46 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  18. 89 40
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  19. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java
  20. 45 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java
  21. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicCompareRecordServiceImpl.java
  22. 1 1
      mec-biz/src/main/resources/config/mybatis/StudentExtracurricularExercisesSituationMapper.xml
  23. 16 4
      mec-biz/src/main/resources/config/mybatis/SysMusicCompareRecordMapper.xml
  24. 29 3
      mec-biz/src/main/resources/config/mybatis/SysSuggestionMapper.xml
  25. 6 4
      mec-student/src/main/java/com/ym/mec/student/controller/StudentManageController.java
  26. 6 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/SoundController.java
  27. 6 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherManageController.java
  28. 28 0
      mec-web/src/main/java/com/ym/mec/web/controller/SoundCompareController.java
  29. 1 8
      mec-web/src/main/java/com/ym/mec/web/controller/StudentRegistrationController.java
  30. 40 10
      mec-web/src/main/java/com/ym/mec/web/controller/SysSuggestionController.java

+ 1 - 1
codegen/src/main/resources/generateConfigration.xml

@@ -8,7 +8,7 @@
 		<catalog>mec_dev</catalog>
 		<schema>mec_dev</schema>
 	</dbConfiguration>
-	<srcBase>/Users/chenxiaoyu/Documents/javabean</srcBase>
+	<srcBase>e:/javabean</srcBase>
 	<pojoPackageName>com.ym.mec.biz.dal.entity</pojoPackageName>
 	<daoPackageName>com.ym.mec.biz.dal.dao</daoPackageName>
 	<servicePackageName>com.ym.mec.biz.service</servicePackageName>

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

@@ -108,10 +108,10 @@ public interface StudentExtracurricularExercisesSituationDao extends BaseDAO<Lon
      * @describe 统计指定星期的服务记录数量
      * @author Joburgess
      * @date 2020/12/25 0025
-     * @param sunday:
+     * @param monday:
      * @return int
      */
-    int countWeekServiceNum(@Param("sunday") String sunday);
+    int countWeekServiceNum(@Param("monday") String monday);
 
     /**
      * @describe 获取指定周指定学员的服务指标

+ 40 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SoundCompareHelper.java

@@ -4,10 +4,12 @@ import be.tarsos.dsp.AudioEvent;
 import be.tarsos.dsp.SilenceDetector;
 import be.tarsos.dsp.pitch.PitchDetectionHandler;
 import be.tarsos.dsp.pitch.PitchDetectionResult;
+import com.ym.mec.biz.dal.enums.DeviceTypeEnum;
 import com.ym.mec.biz.service.impl.SoundCompareHandler;
 import io.swagger.annotations.ApiModelProperty;
 import org.springframework.util.CollectionUtils;
 
+import java.io.File;
 import java.io.RandomAccessFile;
 import java.math.BigDecimal;
 import java.util.ArrayList;
@@ -21,15 +23,23 @@ import java.util.Map;
  */
 public class SoundCompareHelper implements PitchDetectionHandler {
 
+    @ApiModelProperty(value = "设备类型")
+    private DeviceTypeEnum deviceType;
+
     @ApiModelProperty(value = "伴奏编号")
     private Integer musicScoreId;
 
+    @ApiModelProperty(value = "声部编号")
+    private Integer subjectId;
+
     @ApiModelProperty(value = "小节开始时间")
     private double measureStartTime = 0;
 
     @ApiModelProperty
     private RandomAccessFile accessFile;
 
+    private File file;
+
     @ApiModelProperty(value = "录音文件地址")
     private String recordFilePath;
 
@@ -55,7 +65,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
 
     private List<MusicPitchDetailDto> musicXmlInfos;
 
-    private byte[] preDataArray = new byte[0];
+    private String clientId;
     /**
      * @describe 分贝检测器
      */
@@ -77,12 +87,20 @@ public class SoundCompareHelper implements PitchDetectionHandler {
         this.musicalNotePitchMap = musicalNotePitchMap;
     }
 
-    public byte[] getPreDataArray() {
-        return preDataArray;
+    public Integer getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Integer subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public DeviceTypeEnum getDeviceType() {
+        return deviceType;
     }
 
-    public void setPreDataArray(byte[] preDataArray) {
-        this.preDataArray = preDataArray;
+    public void setDeviceType(DeviceTypeEnum deviceType) {
+        this.deviceType = deviceType;
     }
 
     public int getOffsetTime() {
@@ -105,6 +123,14 @@ public class SoundCompareHelper implements PitchDetectionHandler {
         return accessFile;
     }
 
+    public File getFile() {
+        return file;
+    }
+
+    public void setFile(File file) {
+        this.file = file;
+    }
+
     public String getRecordFilePath() {
         return recordFilePath;
     }
@@ -117,6 +143,14 @@ public class SoundCompareHelper implements PitchDetectionHandler {
         this.accessFile = accessFile;
     }
 
+    public String getClientId() {
+        return clientId;
+    }
+
+    public void setClientId(String clientId) {
+        this.clientId = clientId;
+    }
+
     public double getMeasureStartTime() {
         return measureStartTime;
     }
@@ -169,7 +203,7 @@ public class SoundCompareHelper implements PitchDetectionHandler {
     public void handlePitch(PitchDetectionResult pitchDetectionResult, AudioEvent audioEvent) {
         int timeStamp = (int) (measureStartTime + audioEvent.getTimeStamp()*1000);
         float pitch = pitchDetectionResult.getPitch();
-        if(pitch>0 && offsetTime == -1){
+        if(offsetTime == -1 && !DeviceTypeEnum.IOS.equals(deviceType) && pitch>0){
             int preTimeStamp = CollectionUtils.isEmpty(recordMeasurePithInfo)?0:recordMeasurePithInfo.get(recordMeasurePithInfo.size()-1).getTimeStamp();
             offsetTime = timeStamp - (timeStamp - preTimeStamp)/2;
             for (Map.Entry<Integer, MusicPitchDetailDto> musicPitchDetailDtoEntry : measureEndTime.entrySet()) {

+ 43 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysMusicCompareRecord.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.enums.DeviceTypeEnum;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.math.BigDecimal;
@@ -35,9 +36,18 @@ public class SysMusicCompareRecord {
 
 	/** 录音文件地址 */
 	private String recordFilePath;
+
+	/** 周一日期 */
+	private String monday;
 	
 	/** 创建时间 */
 	private java.util.Date createTime;
+
+	private DeviceTypeEnum deviceType;
+
+	private float playTime = 0;
+
+	private String clientId;
 	
 	public void setId(Long id){
 		this.id = id;
@@ -54,7 +64,15 @@ public class SysMusicCompareRecord {
 	public Integer getUserId(){
 		return this.userId;
 	}
-			
+
+	public String getClientId() {
+		return clientId;
+	}
+
+	public void setClientId(String clientId) {
+		this.clientId = clientId;
+	}
+
 	public void setSysMusicScoreId(Integer sysMusicScoreId){
 		this.sysMusicScoreId = sysMusicScoreId;
 	}
@@ -111,6 +129,30 @@ public class SysMusicCompareRecord {
 		this.recordFilePath = recordFilePath;
 	}
 
+	public DeviceTypeEnum getDeviceType() {
+		return deviceType;
+	}
+
+	public void setDeviceType(DeviceTypeEnum deviceType) {
+		this.deviceType = deviceType;
+	}
+
+	public float getPlayTime() {
+		return playTime;
+	}
+
+	public void setPlayTime(float playTime) {
+		this.playTime = playTime;
+	}
+
+	public String getMonday() {
+		return monday;
+	}
+
+	public void setMonday(String monday) {
+		this.monday = monday;
+	}
+
 	public void setCreateTime(java.util.Date createTime){
 		this.createTime = createTime;
 	}

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

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.enums.SuggestionType;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
@@ -30,6 +31,9 @@ public class SysSuggestion {
 	@ApiModelProperty(value = "客户端类型",required = false)
 	private String clientType;
 
+	@ApiModelProperty(value = "建议类型")
+	private SuggestionType type = SuggestionType.APP;
+
 	@ApiModelProperty(value = "用户名",required = false)
 	private String username;
 	
@@ -92,6 +96,14 @@ public class SysSuggestion {
 		this.clientType = clientType;
 	}
 
+	public SuggestionType getType() {
+		return type;
+	}
+
+	public void setType(SuggestionType type) {
+		this.type = type;
+	}
+
 	public void setCreateTime(java.util.Date createTime){
 		this.createTime = createTime;
 	}

+ 35 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/DeviceTypeEnum.java

@@ -0,0 +1,35 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+public enum DeviceTypeEnum implements BaseEnum<String, DeviceTypeEnum> {
+	IOS("IOS", "苹果"),
+	ANDROID("ANDROID", "安卓"),
+	WEB("WEB", "浏览器");
+
+	private String code;
+
+	private String msg;
+
+	DeviceTypeEnum(String code, String msg) {
+		this.code = code;
+		this.msg = msg;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+	@Override
+	public String getCode() {
+		return this.code;
+	}
+}

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/PayStatus.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+public enum PayStatus implements BaseEnum<String, PayStatus> {
+
+	FAILED("支付失败"), WAIT_PAY("待支付"), PAYING("支付中"), SUCCESSED("支付成功");
+
+	private String desc;
+
+	private PayStatus(String desc) {
+		this.desc = desc;
+	}
+
+	@Override
+	public String getCode() {
+		return this.name();
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+}

+ 34 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/SuggestionType.java

@@ -0,0 +1,34 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+public enum SuggestionType implements BaseEnum<String, SuggestionType> {
+	APP("APP", "软件反馈"),
+	SMART_PRACTICE("SMART_PRACTICE", "智能陪练");
+
+	private String code;
+
+	private String msg;
+
+	SuggestionType(String code, String msg) {
+		this.code = code;
+		this.msg = msg;
+	}
+
+	public void setCode(String code) {
+		this.code = code;
+	}
+
+	public String getMsg() {
+		return msg;
+	}
+
+	public void setMsg(String msg) {
+		this.msg = msg;
+	}
+
+	@Override
+	public String getCode() {
+		return this.code;
+	}
+}

+ 54 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/SysSuggestionQueryInfo.java

@@ -0,0 +1,54 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.biz.dal.enums.SuggestionType;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/8/10 0010
+ */
+public class SysSuggestionQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "建议类型")
+    private SuggestionType type;
+
+    private String startTime;
+
+    private String endTime;
+
+    @ApiModelProperty(value = "客户端类型",required = false)
+    private String clientType;
+
+    public SuggestionType getType() {
+        return type;
+    }
+
+    public void setType(SuggestionType type) {
+        this.type = type;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getClientType() {
+        return clientType;
+    }
+
+    public void setClientType(String clientType) {
+        this.clientType = clientType;
+    }
+}

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/handler/WebSocketHandler.java

@@ -53,7 +53,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
         String phone = session.getPrincipal().getName().split(":")[1];
         LOGGER.info("{}上线", phone);
         WS_CLIENTS.put(phone, new WebSocketClientDetail(session, new Date()));
-        appMap.values().forEach(e->e.afterConnectionEstablished(session));
+        appMap.values().forEach(e->e.afterConnectionEstablished(session, phone));
         super.afterConnectionEstablished(session);
     }
 
@@ -72,15 +72,16 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
             tag = webSocketInfo.getHeader().get(SoundSocketService.TAG);
         }
         if(StringUtils.isNotBlank(tag)){
-            appMap.get(tag).receiveTextMessage(session, message);
+            appMap.get(tag).receiveTextMessage(session, phone, message);
         }else{
-            appMap.values().forEach(e->e.receiveTextMessage(session, message));
+            appMap.values().forEach(e->e.receiveTextMessage(session, phone, message));
         }
     }
 
     @Override
     protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) {
-        appMap.values().forEach(e->e.receiveBinaryMessage(session, message));
+        String phone = session.getPrincipal().getName().split(":")[1];
+        appMap.values().forEach(e->e.receiveBinaryMessage(session, phone, message));
     }
 
     @Override
@@ -94,7 +95,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
         String phone = session.getPrincipal().getName().split(":")[1];
         session.close();
         LOGGER.info("发生了错误,移除客户端: {}", phone);
-        appMap.values().forEach(e->e.afterConnectionClosed(session));
+        appMap.values().forEach(e->e.afterConnectionClosed(session, phone));
         exception.printStackTrace();
         if(!WS_CLIENTS.containsKey(phone)){
             return;
@@ -107,7 +108,7 @@ public class WebSocketHandler extends AbstractWebSocketHandler {
         super.afterConnectionClosed(session, status);
         String phone = session.getPrincipal().getName().split(":")[1];
         LOGGER.info("{}离线", phone);
-        appMap.values().forEach(e->e.afterConnectionClosed(session));
+        appMap.values().forEach(e->e.afterConnectionClosed(session, phone));
         WS_CLIENTS.remove(phone);
     }
 

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -15,6 +15,7 @@ import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 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.page.SporadicOrderQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.common.page.PageInfo;
@@ -185,5 +186,7 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
     void callOrderCallBack(StudentPaymentOrder order) throws Exception;
     
     int batchUpdate(List<StudentPaymentOrder> studentPaymentOrderList);
+    
+    PayStatus queryPayStatus(String paymentChannel, String orderNo, String transNo) throws Exception;
 
 }

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/WebSocketEventHandler.java

@@ -10,6 +10,8 @@ import org.springframework.web.socket.WebSocketSession;
  **/
 public interface WebSocketEventHandler {
 
+
+
     /**
      * @describe 连接成功
      * @author Joburgess
@@ -17,7 +19,7 @@ public interface WebSocketEventHandler {
      * @param session: 会话信息
      * @return void
      */
-    void afterConnectionEstablished(WebSocketSession session);
+    void afterConnectionEstablished(WebSocketSession session, String phone);
 
     /**
      * @describe 接受到文本信息
@@ -27,7 +29,7 @@ public interface WebSocketEventHandler {
      * @param message: 文本信息
      * @return void
      */
-    void receiveTextMessage(WebSocketSession session, TextMessage message);
+    void receiveTextMessage(WebSocketSession session, String phone, TextMessage message);
 
     /**
      * @describe 接收到二进制数据
@@ -37,7 +39,7 @@ public interface WebSocketEventHandler {
      * @param message: 二进制数据
      * @return void
      */
-    void receiveBinaryMessage(WebSocketSession session, BinaryMessage message);
+    void receiveBinaryMessage(WebSocketSession session, String phone, BinaryMessage message);
 
     /**
      * @describe 连接关闭
@@ -46,6 +48,6 @@ public interface WebSocketEventHandler {
      * @param session: 会话信息
      * @return void
      */
-    void afterConnectionClosed(WebSocketSession session);
+    void afterConnectionClosed(WebSocketSession session, String phone);
 
 }

+ 65 - 27
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -595,8 +595,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (isCheckStudentNum) {
             // 查询乐团已报名人数
             List<StudentPreRegistration> studentPreRegistrationList = studentPreRegistrationDao.queryByMusicGroupId(musicGroupId);
-            if (studentPreRegistrationList == null || studentPreRegistrationList.size() < 120) {
-                throw new BizException("操作失败:报名人数没有达到120人");
+            if (studentPreRegistrationList == null || studentPreRegistrationList.size() < 80) {
+                throw new BizException("操作失败:报名人数没有达到80人");
             }
         }
         musicGroup.setStatus(MusicGroupStatusEnum.PRE_BUILD_FEE);
@@ -2180,29 +2180,41 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                     studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
                 }
                 
-				if (studentLastChange != null && minPaymentOrderId <= studentLastChange.getOriginalOrderId()) {
-					if (isRefundInstrumentFee) {
-						amount = amount.add(studentLastChange.getChangeMusicalPrice());
-					}
+    			if (studentLastChange != null && minPaymentOrderId <= studentLastChange.getOriginalOrderId()) {
+    				if (isRefundInstrumentFee) {
+    					amount = amount.add(studentLastChange.getChangeMusicalPrice());
+    					
+    					StudentInstrument studentMaintenance = studentInstrumentDao.getByOrderId(studentLastChange.getOrderId().longValue());
+    		            if (studentMaintenance != null) {
+    		                studentMaintenance.setDelFlag(1);
+    		                studentInstrumentDao.update(studentMaintenance);
+    		            }
+    				}
 
-					if (isRefundTeachingAssistantsFee) {
-						amount = amount.add(studentLastChange.getChangeAccessoriesPrice());
-					}
-				} else {
-					for (StudentPaymentOrderDetail detail : orderDetailList) {
-
-						// 退乐器费用
-						if (isRefundInstrumentFee && detail.getType() == OrderDetailTypeEnum.MUSICAL) {
-							amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
-						}
-
-						// 退教辅费用
-						if (isRefundTeachingAssistantsFee
-								&& (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING)) {
-							amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
-						}
-					}
-				}
+    				if (isRefundTeachingAssistantsFee) {
+    					amount = amount.add(studentLastChange.getChangeAccessoriesPrice());
+    				}
+    			} else {
+    				for (StudentPaymentOrderDetail detail : orderDetailList) {
+
+    					// 退乐器费用
+    					if (isRefundInstrumentFee && detail.getType() == OrderDetailTypeEnum.MUSICAL) {
+    						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
+    						
+    						StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId);
+    			            if (studentMaintenance != null) {
+    			                studentMaintenance.setDelFlag(1);
+    			                studentInstrumentDao.update(studentMaintenance);
+    			            }
+    					}
+
+    					// 退教辅费用
+    					if (isRefundTeachingAssistantsFee
+    							&& (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING)) {
+    						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
+    					}
+    				}
+    			}
             }
 
             //退乐保费用
@@ -2215,7 +2227,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 }
                 amount = amount.add(maintenanceFee);
                 if (maintenanceFee.compareTo(BigDecimal.ZERO) > 0 && studentMaintenance != null) {
-                    studentMaintenance.setDelFlag(1);
+                    studentMaintenance.setStatus(0);
+                    studentMaintenance.setStartTime(null);
+                    studentMaintenance.setEndTime(null);
                     studentInstrumentDao.update(studentMaintenance);
                 }
             }
@@ -2463,6 +2477,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 			if (studentLastChange != null && minPaymentOrderId <= studentLastChange.getOriginalOrderId()) {
 				if (isRefundInstrumentFee) {
 					amount = amount.add(studentLastChange.getChangeMusicalPrice());
+					
+					StudentInstrument studentMaintenance = studentInstrumentDao.getByOrderId(studentLastChange.getOrderId().longValue());
+		            if (studentMaintenance != null) {
+		                studentMaintenance.setDelFlag(1);
+		                studentInstrumentDao.update(studentMaintenance);
+		            }
 				}
 
 				if (isRefundTeachingAssistantsFee) {
@@ -2474,6 +2494,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 					// 退乐器费用
 					if (isRefundInstrumentFee && detail.getType() == OrderDetailTypeEnum.MUSICAL) {
 						amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
+						
+						StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId);
+			            if (studentMaintenance != null) {
+			                studentMaintenance.setDelFlag(1);
+			                studentInstrumentDao.update(studentMaintenance);
+			            }
 					}
 
 					// 退教辅费用
@@ -2496,7 +2522,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
             amount = amount.add(maintenanceFee);
             if (maintenanceFee.compareTo(BigDecimal.ZERO) > 0 && studentMaintenance != null) {
-                studentMaintenance.setDelFlag(1);
+                studentMaintenance.setStatus(0);
+                studentMaintenance.setStartTime(null);
+                studentMaintenance.setEndTime(null);
                 studentInstrumentDao.update(studentMaintenance);
             }
         }
@@ -3684,6 +3712,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 			throw new BizException("乐器已发货,请勿重复操作");
 		}
 		
+		Set<String> musicGroupIds = new HashSet<String>();
+        musicGroupIds.add(musicGroupId);
+        List<MusicGroupPurchaseList> musicGroupPurchaseListCount = musicGroupPurchaseListDao.getCount(musicGroupIds);
+        if (musicGroupPurchaseListCount == null || musicGroupPurchaseListCount.size() == 0) {
+            throw new BizException("乐器清单未确认,不能确认发货");
+        }
+		
 		Date date = new Date();
 		
 		musicGroup.setMusicalInstrumentsProvideStatus(1);
@@ -3700,12 +3735,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		List<StudentInstrument> updateList = new ArrayList<StudentInstrument>();
 		
 		for (StudentInstrument si : studentInstrumentList) {
+			if (si.getDelFlag() == 1) {
+				continue;
+			}
 			if (si.getStatus() == 0 && si.getStartTime() == null) {
 				si.setStatus(1);
 				si.setStartTime(date);
 				si.setEndTime(DateUtil.addYears(date, 1));
 				si.setUpdateTime(date);
-				
+
 				updateList.add(si);
 			}
 		}

+ 57 - 24
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SoundCompareHandler.java

@@ -7,20 +7,26 @@ import be.tarsos.dsp.util.PitchConverter;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.config.SoundCompareConfig;
+import com.ym.mec.biz.dal.dao.SysMusicScoreAccompanimentDao;
 import com.ym.mec.biz.dal.dto.MusicPitchDetailDto;
 import com.ym.mec.biz.dal.dto.SoundCompareHelper;
 import com.ym.mec.biz.dal.dto.WavHeader;
 import com.ym.mec.biz.dal.dto.WebSocketInfo;
+import com.ym.mec.biz.dal.enums.DeviceTypeEnum;
 import com.ym.mec.biz.handler.WebSocketHandler;
 import com.ym.mec.biz.service.SoundSocketService;
 import com.ym.mec.biz.service.SysMusicCompareRecordService;
 import com.ym.mec.biz.service.WebSocketEventHandler;
 import com.ym.mec.common.constant.CommonConstants;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.thirdparty.storage.StoragePluginContext;
+import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
+import com.ym.mec.util.upload.UploadUtil;
 import org.apache.commons.io.FileUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.socket.BinaryMessage;
@@ -52,7 +58,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
 
     private final String tmpDir = FileUtils.getTempDirectoryPath() + "/soundCompare/";
     /**
-     * @describe 用户对应评分信息------------------------------------------------------------------------------
+     * @describe 用户对应评分信息
      */
     private Map<String, SoundCompareHelper> userSoundInfoMap = new ConcurrentHashMap<>();
     /**
@@ -61,7 +67,11 @@ public class SoundCompareHandler implements WebSocketEventHandler {
     public static final SoundCompareConfig soundCompareConfig = new SoundCompareConfig();
 
     @Autowired
+    private StoragePluginContext storagePluginContext;
+    @Autowired
     private SysMusicCompareRecordService sysMusicCompareRecordService;
+    @Autowired
+    private SysMusicScoreAccompanimentDao sysMusicScoreAccompanimentDao;
 
     public SoundCompareHandler() {
         WebSocketHandler.regist("SOUND_COMPARE", this);
@@ -72,13 +82,12 @@ public class SoundCompareHandler implements WebSocketEventHandler {
     }
 
     @Override
-    public void afterConnectionEstablished(WebSocketSession session) {
-        System.out.println("已登录:+++++++++++++++++++++++++++++++++++++++++++++++++++");
+    public void afterConnectionEstablished(WebSocketSession session, String phone) {
+
     }
 
     @Override
-    public void receiveTextMessage(WebSocketSession session, TextMessage message) {
-        String phone = session.getPrincipal().getName().split(":")[1];
+    public void receiveTextMessage(WebSocketSession session, String phone, TextMessage message) {
         WebSocketInfo webSocketInfo = JSON.parseObject(message.getPayload(), WebSocketInfo.class);
         JSONObject bodyObject = (JSONObject) webSocketInfo.getBody();
 
@@ -89,10 +98,18 @@ public class SoundCompareHandler implements WebSocketEventHandler {
         switch (commond){
             case SoundSocketService.MUSIC_XML:
                 userSoundInfoMap.put(phone, new SoundCompareHelper());
+                userSoundInfoMap.get(phone).setClientId(((OAuth2Authentication)session.getPrincipal()).getOAuth2Request().getClientId());
                 List<MusicPitchDetailDto> musicXmlInfos = JSON.parseArray(bodyObject.getString("musicXmlInfos"), MusicPitchDetailDto.class);
                 userSoundInfoMap.get(phone).setMusicXmlInfos(musicXmlInfos);
                 musicXmlInfos = musicXmlInfos.stream().filter(m->!m.getDontEvaluating()).collect(Collectors.toList());
                 userSoundInfoMap.get(phone).setMusicScoreId(bodyObject.getInteger("id"));
+                if(bodyObject.containsKey("platform")){
+                    userSoundInfoMap.get(phone).setDeviceType(DeviceTypeEnum.valueOf(bodyObject.getString("platform")));
+                }
+                List<Integer> subjectIds = sysMusicScoreAccompanimentDao.findSubjectByMusicScoreId(userSoundInfoMap.get(phone).getMusicScoreId(), null);
+                if(!CollectionUtils.isEmpty(subjectIds)){
+                    userSoundInfoMap.get(phone).setSubjectId(subjectIds.get(0));
+                }
                 userSoundInfoMap.get(phone).setMeasureXmlInfoMap(musicXmlInfos.stream().collect(Collectors.groupingBy(MusicPitchDetailDto::getMeasureIndex)));
                 musicXmlInfos.forEach(e->userSoundInfoMap.get(phone).getMusicalNotePitchMap().put(e.getMusicalNotesIndex(), e.getFrequency()));
                 for (Map.Entry<Integer, List<MusicPitchDetailDto>> userMeasureXmlInfoEntry : userSoundInfoMap.get(phone).getMeasureXmlInfoMap().entrySet()) {
@@ -112,6 +129,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                 }
                 try {
                     File file = new File(tmpDir+phone + "_"+ userSoundInfoMap.get(phone).getMusicScoreId() +"_"+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) +".wav");
+                    userSoundInfoMap.get(phone).setFile(file);
                     userSoundInfoMap.get(phone).setAccessFile(new RandomAccessFile(file, "rw"));
                     userSoundInfoMap.get(phone).setRecordFilePath(file.getAbsolutePath());
                 } catch (FileNotFoundException e) {
@@ -142,10 +160,10 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                 createHeader(phone);
                 break;
             case SoundSocketService.PROXY_MESSAGE:
-//                if(bodyObject.containsKey(SoundSocketService.OFFSET_TIME)){
-//                    int offsetTime = bodyObject.getIntValue(SoundSocketService.OFFSET_TIME);
-//                    calOffsetTime(phone, offsetTime);
-//                }
+                if(DeviceTypeEnum.IOS.equals(userSoundInfoMap.get(phone).getDeviceType())&&bodyObject.containsKey(SoundSocketService.OFFSET_TIME)){
+                    int offsetTime = bodyObject.getIntValue(SoundSocketService.OFFSET_TIME);
+                    calOffsetTime(phone, offsetTime);
+                }
                 break;
             default:
                 break;
@@ -153,8 +171,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
     }
 
     @Override
-    public void receiveBinaryMessage(WebSocketSession session, BinaryMessage message) {
-        String phone = session.getPrincipal().getName().split(":")[1];
+    public void receiveBinaryMessage(WebSocketSession session, String phone, BinaryMessage message) {
         if(!userSoundInfoMap.containsKey(phone)){
             return;
         }
@@ -191,11 +208,8 @@ public class SoundCompareHandler implements WebSocketEventHandler {
     }
 
     @Override
-    public void afterConnectionClosed(WebSocketSession session){
-        String phone = session.getPrincipal().getName().split(":")[1];
-        LOGGER.info("发生了错误,移除客户端: {}", phone);
+    public void afterConnectionClosed(WebSocketSession session, String phone){
         createHeader(phone);
-        userSoundInfoMap.remove(phone);
     }
 
     /**
@@ -237,6 +251,24 @@ public class SoundCompareHandler implements WebSocketEventHandler {
             }
             userSoundInfoMap.get(phone).setAccessFile(null);
         }
+
+        if(Objects.nonNull(userSoundInfoMap.get(phone).getFile())){
+            String url = null;
+            try {
+                String folder = UploadUtil.getFileFloder();
+                url = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME,"soundCompare/" + folder, userSoundInfoMap.get(phone).getFile());
+            } catch (Exception e) {
+                LOGGER.error("录音文件上传失败:{}", e);
+            }
+            userSoundInfoMap.get(phone).setRecordFilePath(url);
+        }
+        //存储评分数据
+        sysMusicCompareRecordService.saveMusicCompareData(phone, userSoundInfoMap.get(phone));
+
+        if(Objects.nonNull(userSoundInfoMap.get(phone).getFile())){
+            userSoundInfoMap.get(phone).getFile().deleteOnExit();
+        }
+
         userSoundInfoMap.remove(phone);
     }
 
@@ -379,7 +411,10 @@ public class SoundCompareHandler implements WebSocketEventHandler {
                     if (avgPitch > 0){
                         recordCents = PitchConverter.hertzToAbsoluteCent(avgPitch);
                     }
-                    double cents = PitchConverter.hertzToAbsoluteCent(musicXmlInfo.getFrequency());
+                    double cents = 0;
+                    if(musicXmlInfo.getFrequency()>0){
+                        cents =  PitchConverter.hertzToAbsoluteCent(musicXmlInfo.getFrequency());
+                    }
                     double score = 100 - Math.round(Math.abs(cents - recordCents)) + soundCompareConfig.intonationCentsRange;
                     if (score < 0){
                         score = 0;
@@ -439,7 +474,7 @@ public class SoundCompareHandler implements WebSocketEventHandler {
      * @param phone:
      * @return void
      */
-    private void calTotalScore(String phone) throws IOException {
+    private void calTotalScore(String phone) {
         int totalCompareNum = userSoundInfoMap.get(phone).getMeasureXmlInfoMap().keySet().size();
         int currentCompareNum = totalCompareNum-userSoundInfoMap.get(phone).getMeasureEndTime().keySet().size();
         BigDecimal intonation = BigDecimal.ZERO;
@@ -455,9 +490,6 @@ public class SoundCompareHandler implements WebSocketEventHandler {
         //计算分数并推送
         createPushInfo(phone, "overall", -1, intonation, cadence, integrity);
 
-        //存储评分数据
-        sysMusicCompareRecordService.saveMusicCompareData(phone, userSoundInfoMap.get(phone));
-
         LOGGER.info("评分数据:{}", JSON.toJSONString(userSoundInfoMap.get(phone)));
     }
 
@@ -478,10 +510,11 @@ public class SoundCompareHandler implements WebSocketEventHandler {
         HashMap<String, String> header = new HashMap<>();
         header.put("commond", command);
         webSocketInfo.setHeader(header);
-        Map<String, Object> result = new HashMap<>();
-//        BigDecimal score = intonation.multiply(new BigDecimal(0.5)).add(cadence.multiply(new BigDecimal(0.5))).setScale(0, BigDecimal.ROUND_HALF_UP);
-        BigDecimal score = intonation.add(cadence).add(integrity).divide(new BigDecimal(3), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).setScale(0, BigDecimal.ROUND_UP);
-//        BigDecimal score = integrity.setScale(0, BigDecimal.ROUND_HALF_UP);
+        Map<String, Object> result = new HashMap<>(5);
+        BigDecimal score = cadence;
+        if(Objects.isNull(userSoundInfoMap.get(phone).getSubjectId())||userSoundInfoMap.get(phone).getSubjectId()!=23){
+            score = intonation.add(cadence).add(integrity).divide(new BigDecimal(3), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).setScale(0, BigDecimal.ROUND_UP);
+        }
         result.put("score", score);
         result.put("intonation", intonation);
         result.put("cadence", cadence);

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

@@ -381,17 +381,29 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
 
     @Override
     public Boolean subjectChangeUpdateInstrument(SubjectChange subjectChange) {
-        if (subjectChange == null || subjectChange.getChangeMusical() == null ||
+        StudentInstrument studentInstrument = null;
+    	
+		if (subjectChange.getOriginalOrderId() != null) {
+			studentInstrument = studentInstrumentDao.getByOrderId(subjectChange.getOriginalOrderId().longValue());
+		}
+        
+		if (subjectChange == null || subjectChange.getChangeMusical() == null ||
                 KitGroupPurchaseTypeEnum.OWNED.equals(subjectChange.getKitGroupPurchaseType())) {
+        	
+        	if(studentInstrument != null){
+        		studentInstrument.setDelFlag(1);
+        		update(studentInstrument);
+        	}
+        	
             return false;
         }
-        StudentInstrument studentInstrument = studentInstrumentDao.getByOrderId(subjectChange.getOriginalOrderId().longValue());
-
         if (studentInstrument == null) {
             studentInstrument = new StudentInstrument();
             studentInstrument.setStudentId(subjectChange.getStudentId());
             studentInstrument.setOrganId(subjectChange.getOrganId());
-            studentInstrument.setOrderId(subjectChange.getOriginalOrderId().longValue());
+            if (subjectChange.getOriginalOrderId() != null) {
+            	studentInstrument.setOrderId(subjectChange.getOriginalOrderId().longValue());
+            }
             studentInstrument.setStatus(0);
         }
         studentInstrument.setChangeOrderId(subjectChange.getOrderId().longValue());

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

@@ -419,6 +419,10 @@ public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long,
 
     @Override
 	public List<StudentPaymentOrderDetail> getOrderDetail(Long orderId) {
+    	
+    	if(orderId == null){
+    		return new ArrayList<StudentPaymentOrderDetail>();
+    	}
 		
     	List<Long> orderIdList = new ArrayList<Long>();
     	orderIdList.add(orderId);

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

@@ -31,6 +31,7 @@ import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 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.PlatformCashAccountDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
 import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
@@ -645,4 +646,49 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 	public int batchUpdate(List<StudentPaymentOrder> studentPaymentOrderList) {
 		return studentPaymentOrderDao.batchUpdate(studentPaymentOrderList);
 	}
+
+	@Override
+	public PayStatus queryPayStatus(String paymentChannel, String orderNo, String transNo) throws Exception {
+		if (StringUtils.isBlank(transNo)) {
+			return PayStatus.FAILED;
+		}
+
+		if (StringUtils.equals(paymentChannel, "ADAPAY")) {
+			Map<String, Object> payment = Payment.queryPayment(transNo);
+			String status = (String) payment.get("status");
+			if (status.equals("succeeded")) {
+				return PayStatus.SUCCESSED;
+			} else if (status.equals("failed")) {
+				return PayStatus.FAILED;
+			} else {
+				return PayStatus.PAYING;
+			}
+		} else if (StringUtils.equals(paymentChannel, "YQPAY")) {
+			String notifyUrl = ""; // 回调地址
+			Map<String, Object> resultMap = new LinkedHashMap<>();
+			resultMap.put("merOrderNoList", orderNo);
+			Map<String, Object> requestMap = YqPayUtil.getRequestMap(notifyUrl, resultMap);
+
+			RsqMsg rsqMsg = new RsqMsg(requestMap);
+
+			Msg queryRs = yqPayFeignService.orderQuery(rsqMsg);
+
+			if (queryRs.getCode().equals("88")) {
+				// 更新订单状态
+				String responseParameters = queryRs.getResponseParameters();
+				List<Map<String, String>> responseList = JSON.parseObject(responseParameters, List.class);
+				for (Map<String, String> response : responseList) {
+
+					if (StringUtils.equals(response.get("tradeState"), "1")) {
+						return PayStatus.SUCCESSED;
+					} else if (StringUtils.equals(response.get("tradeState"), "0") || StringUtils.equals(response.get("tradeState"), "7")) {
+						return PayStatus.FAILED;
+					} else {
+						return PayStatus.PAYING;
+					}
+				}
+			}
+		}
+		throw new BizException("支付渠道错误");
+	}
 }

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

@@ -341,7 +341,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
 		List<Long> orderIdList = studentPaymentOrderList.stream().map(t -> t.getId()).collect(Collectors.toList());
 
-		List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.getOrderDetail(orderIdList);
+		List<StudentPaymentOrderDetail> studentPaymentOrderDetailList =new ArrayList<StudentPaymentOrderDetail>();
+		if(orderIdList != null && orderIdList.size() > 0){
+			studentPaymentOrderDetailList = studentPaymentOrderDetailService.getOrderDetail(orderIdList);
+		}
 
 		SubjectChange studentLastChange = subjectChangeDao.getStudentLastChange(studentId, musicGroupId);
 		
@@ -376,7 +379,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 				if (goods != null && goods.size() > 0) {
 					detail.setName(goods.stream().map(t -> t.getName()).collect(Collectors.joining(",")));
 				}
-				detail.setPaymentOrderId((long) studentLastChange.getOriginalOrderId());
+				if(studentLastChange.getOriginalOrderId() != null){
+					detail.setPaymentOrderId((long) studentLastChange.getOriginalOrderId());
+				}
 				detail.setPrice(studentLastChange.getChangeMusicalPrice());
 				detail.setType(OrderDetailTypeEnum.MUSICAL);
 				detail.setCreateTime(studentLastChange.getCreateTime());
@@ -640,31 +645,35 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
         
-        //判断之前是否已有订单
-        List<StudentPaymentOrder> oldStudentPaymentOrderList = studentPaymentOrderService.queryByCondition(GroupType.MUSIC, studentRegistration.getMusicGroupId(), studentRegistration.getUserId(),DealStatusEnum.SUCCESS , OrderTypeEnum.APPLY);
-        
-        int paidNum = musicOneSubjectClassPlan.getPaidStudentNum() == null ? 0 : musicOneSubjectClassPlan.getPaidStudentNum();
-        int paidZeroNum = musicOneSubjectClassPlan.getPaidZeroNum() == null ? 0 : musicOneSubjectClassPlan.getPaidZeroNum();
-        if ((musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) && !buyCloudTeacher))
-        {
-            paidZeroFlag = true;
-            if (studentRegistration.getNoneNeedCloudTeacher().equals(1) && (oldStudentPaymentOrderList == null || oldStudentPaymentOrderList.size() == 0)) {
-                musicOneSubjectClassPlan.setPaidZeroNum(paidZeroNum + 1);
-                musicOneSubjectClassPlan.setPaidStudentNum(paidNum + 1);
-            }
-        } else {
-			if (oldStudentPaymentOrderList == null || oldStudentPaymentOrderList.size() == 0) {
-				musicOneSubjectClassPlan.setPaidStudentNum(paidNum + 1);
+		if (studentRegistration.getMusicGroupStatus() != StudentMusicGroupStatusEnum.NORMAL) {
+			// 判断之前是否已有订单
+			List<StudentPaymentOrder> oldStudentPaymentOrderList = studentPaymentOrderService.queryByCondition(GroupType.MUSIC,
+					studentRegistration.getMusicGroupId(), studentRegistration.getUserId(), DealStatusEnum.SUCCESS, OrderTypeEnum.APPLY);
+
+			int paidNum = musicOneSubjectClassPlan.getPaidStudentNum() == null ? 0 : musicOneSubjectClassPlan.getPaidStudentNum();
+			int paidZeroNum = musicOneSubjectClassPlan.getPaidZeroNum() == null ? 0 : musicOneSubjectClassPlan.getPaidZeroNum();
+			if ((musicGroup.getCourseViewType().equals(CourseViewTypeEnum.MEMBER_FEE) && !buyCloudTeacher && StringUtils.isBlank(maintenanceGoodsId))) {
+				if (studentRegistration.getPaymentStatus() != YES) {
+					paidZeroFlag = true;
+				}
+				if (studentRegistration.getNoneNeedCloudTeacher().equals(1) && (oldStudentPaymentOrderList == null || oldStudentPaymentOrderList.size() == 0)) {
+					musicOneSubjectClassPlan.setPaidZeroNum(paidZeroNum + 1);
+					musicOneSubjectClassPlan.setPaidStudentNum(paidNum + 1);
+				}
+			} else {
+				if (oldStudentPaymentOrderList == null || oldStudentPaymentOrderList.size() == 0) {
+					musicOneSubjectClassPlan.setPaidStudentNum(paidNum + 1);
+				}
 			}
-        }
-        if (musicOneSubjectClassPlan.getPaidStudentNum() > musicOneSubjectClassPlan.getExpectedStudentNum()) {
-            throw new BizException("乐团该声部人数暂时已满,请稍后再试");
-        }
-        
-        int count = musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
-        if (count <= 0) {
-            throw new BizException("排队人数过多,请重试");
-        }
+			if (musicOneSubjectClassPlan.getPaidStudentNum() > musicOneSubjectClassPlan.getExpectedStudentNum()) {
+				throw new BizException("乐团该声部人数暂时已满,请稍后再试");
+			}
+
+			int count = musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);
+			if (count <= 0) {
+				throw new BizException("排队人数过多,请重试");
+			}
+		}
         if (paidZeroFlag) {
             studentPaymentOrder.setVersion(0);
             String code = studentRegistration.getNoneNeedCloudTeacher().equals(1) ? "200" : "205";
@@ -1180,11 +1189,13 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 					studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
 				}
 				
-				if (orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER)
-						|| orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS)) {
+				if (orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER) || orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS)
+						|| orderTypeList.contains(OrderDetailTypeEnum.MUSICAL)) {
 					studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
-					studentRegistration.setNoneNeedCloudTeacher(1);
-					studentRegistration.setHasCloudTeacher(1);
+					//studentRegistration.setNoneNeedCloudTeacher(1);
+					if (orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER) || orderTypeList.contains(OrderDetailTypeEnum.CLOUD_TEACHER_PLUS)) {
+						studentRegistration.setHasCloudTeacher(1);
+					}
 				}
 			} else {
 				studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
@@ -1681,14 +1692,25 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         for (int i = 0; i < 10; i++) {
             MusicGroupSubjectPlan originalSubjectPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId, originalSubjectId);
             int originalPaidNum = originalSubjectPlan.getPaidStudentNum() == null ? 0 : originalSubjectPlan.getPaidStudentNum();
+            int originalZeroPaidNum = originalSubjectPlan.getPaidZeroNum() == null ? 0 : originalSubjectPlan.getPaidZeroNum();
             int originalPaidCount = 1;
             if (originalPaidNum > 0) {
                 originalSubjectPlan.setPaidStudentNum(originalPaidNum - 1);
+                //是否是0元入团
+                if(studentRegistration.getNoneNeedCloudTeacher() != null && studentRegistration.getNoneNeedCloudTeacher() == 1){
+                	originalSubjectPlan.setPaidZeroNum(originalZeroPaidNum - 1);
+                }
                 originalPaidCount = musicGroupSubjectPlanService.update(originalSubjectPlan);
             }
             MusicGroupSubjectPlan changeSubjectPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId, changeSubjectId);
             int changelPaidNum = changeSubjectPlan.getPaidStudentNum() == null ? 0 : changeSubjectPlan.getPaidStudentNum();
             changeSubjectPlan.setPaidStudentNum(changelPaidNum + 1);
+            if(studentRegistration.getNoneNeedCloudTeacher() != null && studentRegistration.getNoneNeedCloudTeacher() == 1){
+            	if(changeSubjectPlan.getPaidZeroNum() != null && changeSubjectPlan.getPaidZeroNum() > 0){
+            		throw new BizException("声部更换失败,当前用户是0元入团,且当前声部已有0元入团学生");
+            	}
+            	changeSubjectPlan.setPaidZeroNum(1);
+            }
             int changePaidCount = musicGroupSubjectPlanService.update(changeSubjectPlan);
             if (originalPaidCount > 0 && changePaidCount > 0) {
                 updateFlag = true;
@@ -1962,6 +1984,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }
         studentRegistration.setPayingStatus(0);
         studentRegistration.setNoneNeedCloudTeacher(1);
+        studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
         if (studentRegistrationDao.update(studentRegistration) <= 0) {
             throw new BizException("设置失败,请重试");
         }
@@ -1971,16 +1994,23 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     @Transactional(rollbackFor = Exception.class)
     public HttpResponseResult<Boolean> addPaidNum(Long id, boolean isContinue) {
-        StudentRegistration studentRegistration = studentRegistrationDao.get(id);
+        StudentRegistration studentRegistration = studentRegistrationDao.lock(id);
         if (!studentRegistration.getPayingStatus().equals(2)) {
             throw new BizException("该学生不在审核");
         }
-        if (!studentRegistration.getPaymentStatus().equals(YES)) {
-            throw new BizException("该学生状态已更新,请刷新查看");
+        if (studentRegistration.getNoneNeedCloudTeacher().equals(1)) {
+            throw new BizException("该学生已设置");
         }
 
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
         
+        int paidNum = musicOneSubjectClassPlan.getPaidStudentNum() == null ? 0 : musicOneSubjectClassPlan.getPaidStudentNum();
+        int paidZeroNum = musicOneSubjectClassPlan.getPaidZeroNum() == null ? 0 : musicOneSubjectClassPlan.getPaidZeroNum();
+        
+        if(paidZeroNum > 0){
+        	throw new BizException("每个声部只能有一个免费入团名额");
+        }
+        
         if(!isContinue){
         	if (musicOneSubjectClassPlan.getPaidStudentNum() >= musicOneSubjectClassPlan.getExpectedStudentNum()) {
                 return new HttpResponseResult<Boolean>(true, HttpStatus.CONTINUE, null, "乐团该声部招生人数已满,是否继续操作?");
@@ -1989,16 +2019,35 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         
         studentRegistration.setPayingStatus(0);
         studentRegistration.setNoneNeedCloudTeacher(1);
+        studentRegistration.setPaymentStatus(YES);
         studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
         studentRegistrationDao.update(studentRegistration);
-        StudentPaymentOrder order = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.SUCCESS);
-        order.setPaymentAccountNo("200");
-        if(studentPaymentOrderService.update(order)<=0){
-            throw new BizException("订单处理失败,请重试");
-        }
+        /*StudentPaymentOrder order = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.SUCCESS);
+		if (order != null) {
+			order.setPaymentAccountNo("200");
+			if (studentPaymentOrderService.update(order) <= 0) {
+				throw new BizException("订单处理失败,请重试");
+			}
+		}*/
+        
+		List<StudentPaymentOrder> studentPaymentOrderList = studentPaymentOrderService.queryByCondition(GroupType.MUSIC, studentRegistration.getMusicGroupId(), studentRegistration.getUserId(), DealStatusEnum.ING, OrderTypeEnum.APPLY);
+		
+		List<StudentPaymentOrder> updateList = new ArrayList<StudentPaymentOrder>();
+		
+		if(studentPaymentOrderList != null && studentPaymentOrderList.size() > 0){
+			for(StudentPaymentOrder studentPaymentOrder : studentPaymentOrderList){
+				if(StringUtils.equals("205", studentPaymentOrder.getPaymentAccountNo())){
+					studentPaymentOrder.setStatus(DealStatusEnum.CLOSE);
+					studentPaymentOrder.setMemo("用户未支付");
+					updateList.add(studentPaymentOrder);
+				}
+			}
+		}
+		
+		if(updateList.size() > 0){
+			studentPaymentOrderService.batchUpdate(updateList);
+		}
         
-        int paidNum = musicOneSubjectClassPlan.getPaidStudentNum() == null ? 0 : musicOneSubjectClassPlan.getPaidStudentNum();
-        int paidZeroNum = musicOneSubjectClassPlan.getPaidZeroNum() == null ? 0 : musicOneSubjectClassPlan.getPaidZeroNum();
         musicOneSubjectClassPlan.setPaidZeroNum(paidZeroNum + 1);
         musicOneSubjectClassPlan.setPaidStudentNum(paidNum + 1);
         int count = musicGroupSubjectPlanService.update(musicOneSubjectClassPlan);

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

@@ -299,8 +299,9 @@ public class StudentServeServiceImpl implements StudentServeService {
     public void exercisesSituationStatistics2(String monday, List<Integer> studentIds) {
         LocalDate nowDate = LocalDateTime.now(DateUtil.zoneId).toLocalDate();
 
+        int preWeekServiceNum = studentExtracurricularExercisesSituationDao.countWeekServiceNum(nowDate.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue()).plusDays(-7).toString());
         int lastWeekTodayUpdateNum = studentExtracurricularExercisesSituationDao.findLastWeekTodayUpdateNum(nowDate.plusDays(-nowDate.getDayOfWeek().getValue()).toString());
-        if(lastWeekTodayUpdateNum<=0){
+        if(preWeekServiceNum>0 && lastWeekTodayUpdateNum<=0){
             nowDate = nowDate.plusDays(-nowDate.getDayOfWeek().getValue());
         }
 

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

@@ -77,6 +77,8 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
     private MusicGroupPurchaseListDao musicGroupPurchaseListDao;
     @Autowired
     private StudentRegistrationDao studentRegistrationDao;
+    @Autowired
+    private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -229,10 +231,36 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
     @Override
     @Transactional(rollbackFor = Exception.class)
     public SubjectChange addChange(SubjectChange subjectChange) {
-        SubjectChange studentWaitPay = subjectChangeDao.getStudentWaitPay(subjectChange.getStudentId(), subjectChange.getMusicGroupId());
+    	String musicGroupId = subjectChange.getMusicGroupId();
+        SubjectChange studentWaitPay = subjectChangeDao.getStudentWaitPay(subjectChange.getStudentId(), musicGroupId);
         if (studentWaitPay != null) {
             throw new BizException("已有未支付的声部更改,请勿重复创建");
         }
+        
+        Set<String> musicGroupIds = new HashSet<String>();
+        musicGroupIds.add(musicGroupId);
+        
+        List<MusicGroupPurchaseList> musicGroupPurchaseListCount = musicGroupPurchaseListDao.getCount(musicGroupIds);
+        if (musicGroupPurchaseListCount.size() > 0) {
+            throw new BizException("乐器清单已确认,不能做声部更改");
+        }
+        
+        //判断新声部人数是否已满
+        MusicGroupSubjectPlan changeSubjectPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId, subjectChange.getChangeSubjectId());
+		if (changeSubjectPlan.getExpectedStudentNum() <= changeSubjectPlan.getPaidStudentNum()) {
+			throw new BizException("当前声部人数已满");
+		}
+		
+		StudentRegistration studentRegistration = studentRegistrationDao.getStudentRegister(musicGroupId, subjectChange.getStudentId());
+		if(studentRegistration == null){
+			throw new BizException("用户乐团报名信息查询失败");
+		}
+        
+        if(studentRegistration.getNoneNeedCloudTeacher() != null && studentRegistration.getNoneNeedCloudTeacher() == 1){
+        	if(changeSubjectPlan.getPaidZeroNum() != null && changeSubjectPlan.getPaidZeroNum() > 0){
+        		throw new BizException("声部更换失败,当前用户是0元入团,且当前声部已有0元入团学生");
+        	}
+        }        
         Date nowDate = new Date();
         SubjectChange studentOriginal = getStudentOriginal(subjectChange.getStudentId(), subjectChange.getMusicGroupId());
         if(studentOriginal != null){
@@ -403,8 +431,10 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         
         List<Long> paymentOrderIdList = studentPaymentOrderList.stream().map(t -> t.getId()).collect(Collectors.toList());
 
-        List<StudentPaymentOrderDetail> details = studentPaymentOrderDetailDao.getWithIds(paymentOrderIdList);
-        
+        List<StudentPaymentOrderDetail> details = new ArrayList<StudentPaymentOrderDetail>();
+		if (paymentOrderIdList != null && paymentOrderIdList.size() > 0) {
+			details = studentPaymentOrderDetailDao.getWithIds(paymentOrderIdList);
+		}
 
         //查询乐器订单
         StudentPaymentOrderDetail musicalOrderDetail =null, accessoriesOrderDetail = null;
@@ -417,8 +447,11 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         	}
         }
 
-        Set<Integer> refundSellOrderGoodsIds = getRefundGoodsId(details.stream().map(t -> t.getPaymentOrderId()).collect(Collectors.toList()));
-
+		Set<Integer> refundSellOrderGoodsIds = new HashSet<Integer>();
+		if (details.size() > 0) {
+			refundSellOrderGoodsIds = getRefundGoodsId(details.stream().map(t -> t.getPaymentOrderId()).collect(Collectors.toList()));
+		}
+		
         MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
         subjectChange.setStudentId(studentId);
         subjectChange.setOrganId(musicGroup.getOrganId());
@@ -466,7 +499,10 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
             subjectChange.setOriginalAccessoriesPrice(price);
         }
         //2.2 计算销售成本
-        BigDecimal orderSellCost = sellOrderDao.getOrderSellCost(paymentOrderIdList);
+        BigDecimal orderSellCost = BigDecimal.ZERO;
+        if (paymentOrderIdList != null && paymentOrderIdList.size() > 0) {
+        	orderSellCost = sellOrderDao.getOrderSellCost(paymentOrderIdList);
+        }
         subjectChange.setOriginalCost(orderSellCost == null ? BigDecimal.ZERO : orderSellCost);
         return subjectChange;
     }
@@ -541,7 +577,9 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
             if (StringUtils.isNotBlank(goodsIds)) {
                 List<Integer> goodsIdList = Arrays.stream(goodsIds.split(",")).map(Integer::parseInt).collect(Collectors.toList());
                 //退原订单商品
-                sellOrderService.refundByOrderId(subjectChange.getOriginalOrderId().longValue(), false);
+                if(subjectChange.getOriginalOrderId() != null){
+                	sellOrderService.refundByOrderId(subjectChange.getOriginalOrderId().longValue(), false);
+                }
                 //添加新订单
                 this.addSellOrder(studentPaymentOrder.getId(), subjectChange.getMusicGroupId(), goodsIdList, studentPaymentOrder.getExpectAmount(), studentPaymentOrder.getBalancePaymentAmount(), subjectChange.getKitGroupPurchaseType());
             }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMusicCompareRecordServiceImpl.java

@@ -5,6 +5,7 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dto.SoundCompareHelper;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.util.date.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.biz.dal.entity.SysMusicCompareRecord;
@@ -12,7 +13,10 @@ import com.ym.mec.biz.service.SysMusicCompareRecordService;
 import com.ym.mec.biz.dal.dao.SysMusicCompareRecordDao;
 import org.springframework.stereotype.Service;
 
+import java.io.IOException;
 import java.math.BigDecimal;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
 import java.util.Map;
 import java.util.Objects;
 
@@ -47,6 +51,12 @@ public class SysMusicCompareRecordServiceImpl extends BaseServiceImpl<Long, SysM
 			sysMusicCompareRecord.setIntegrity((BigDecimal) finalScore.get("integrity"));
 		}
 		sysMusicCompareRecord.setRecordFilePath(soundCompareInfo.getRecordFilePath());
+		sysMusicCompareRecord.setDeviceType(soundCompareInfo.getDeviceType());
+		sysMusicCompareRecord.setClientId(soundCompareInfo.getClientId());
+		if(Objects.nonNull(soundCompareInfo.getFile())){
+			sysMusicCompareRecord.setPlayTime(soundCompareInfo.getFile().length()/(SoundCompareHandler.soundCompareConfig.audioFormat.getFrameSize()*SoundCompareHandler.soundCompareConfig.audioFormat.getFrameRate()));
+		}
+		sysMusicCompareRecord.setMonday(LocalDate.now().with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue()).toString());
 		sysMusicCompareRecordDao.insert(sysMusicCompareRecord);
 	}
 }

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

@@ -471,7 +471,7 @@
 	</select>
 
 	<select id="countWeekServiceNum" resultType="int">
-		SELECT COUNT(id_) FROM student_extracurricular_exercises_situation_ WHERE monday_=#{sunday}
+		SELECT COUNT(id_) FROM student_extracurricular_exercises_situation_ WHERE monday_=#{monday}
 	</select>
 
 	<select id="findWeekServiceWithStudents" resultMap="StudentExtracurricularExercisesSituation">

+ 16 - 4
mec-biz/src/main/resources/config/mybatis/SysMusicCompareRecordMapper.xml

@@ -16,6 +16,10 @@
 		<result column="cadence_" property="cadence" />
 		<result column="integrity_" property="integrity" />
 		<result column="record_file_path_" property="recordFilePath" />
+		<result column="device_type_" property="deviceType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
+		<result column="client_id_" property="clientId" />
+		<result column="play_time_" property="playTime"/>
+		<result column="monday_" property="monday"/>
 		<result column="create_time_" property="createTime" />
 	</resultMap>
 
@@ -36,8 +40,10 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO sys_music_compare_record (id_,user_id_,sys_music_score_id_,score_data_,score_,intonation_,cadence_,integrity_,record_file_path_,create_time_)
-		VALUES(#{id},#{userId},#{sysMusicScoreId},#{scoreData},#{score},#{intonation},#{cadence},#{integrity},#{recordFilePath},NOW())
+		INSERT INTO sys_music_compare_record (id_,user_id_,sys_music_score_id_,score_data_,score_,intonation_,cadence_,integrity_,
+		                                      record_file_path_,device_type_,client_id_,play_time_,monday_,create_time_)
+		VALUES(#{id},#{userId},#{sysMusicScoreId},#{scoreData},#{score},#{intonation},#{cadence},#{integrity},
+		       #{recordFilePath},#{deviceType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{clientId},#{playTime},#{monday},NOW())
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->
@@ -70,8 +76,14 @@
 		<if test="recordFilePath != null">
 			record_file_path_ = #{recordFilePath},
 		</if>
-		<if test="createTime != null">
-			create_time_ = #{createTime},
+		<if test="clientId != null">
+			client_id_ = #{clientId},
+		</if>
+		<if test="playTime != null">
+			play_time_ = #{playTime},
+		</if>
+		<if test="monday != null">
+			monday_ = #{monday},
 		</if>
 	</set> WHERE id_ = #{id}
 	</update>

+ 29 - 3
mec-biz/src/main/resources/config/mybatis/SysSuggestionMapper.xml

@@ -15,6 +15,7 @@
         <result column="username_" property="username"/>
         <result column="create_time_" property="createTime"/>
         <result column="client_type_" property="clientType"/>
+        <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -30,8 +31,8 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysSuggestion" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
-        INSERT INTO sys_suggestion (id_,mobile_no_,title_,content_,user_id_,create_time_,client_type_)
-        VALUES(#{id},#{mobileNo},#{title},#{content},#{userId},now(),#{clientType})
+        INSERT INTO sys_suggestion (id_,mobile_no_,title_,content_,user_id_,create_time_,client_type_,type_)
+        VALUES(#{id},#{mobileNo},#{title},#{content},#{userId},now(),#{clientType},#{type, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -53,6 +54,9 @@
             <if test="mobileNo != null">
                 mobile_no_ = #{mobileNo},
             </if>
+            <if test="type != null">
+                type_ = #{type, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>
@@ -62,16 +66,38 @@
 		DELETE FROM sys_suggestion WHERE id_ = #{id} 
 	</delete>
 
+    <sql id="queryCondition">
+        <where>
+            <if test="type!=null">
+                AND ss.type_ = #{type, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+            <if test="clientType!=null">
+                AND ss.client_type_ = #{clientType}
+            </if>
+            <if test="startTime!=null and startTime!=''">
+                AND DATE_FORMAT(ss.create_time_,'%Y-%m-%d') &gt;= #{startTime}
+            </if>
+            <if test="endTime!=null and endTime!=''">
+                AND DATE_FORMAT(ss.create_time_,'%Y-%m-%d') &lt;= #{endTime}
+            </if>
+            <if test="search!=null and search!=''">
+                AND (su.real_name_ LIKE CONCAT('%', #{search}, '%') OR su.username_ LIKE CONCAT('%', #{search}, '%') OR ss.user_id_=#{search} OR su.phone_=#{search})
+            </if>
+        </where>
+    </sql>
+
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="SysSuggestion" parameterType="map">
         SELECT ss.*,CASE WHEN su.real_name_ IS NULL THEN su.username_ ELSE su.real_name_ END username_ FROM sys_suggestion ss
         LEFT JOIN sys_user su ON su.id_ = ss.user_id_
+        <include refid="queryCondition" />
         ORDER BY ss.id_ DESC
         <include refid="global.limit"/>
     </select>
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM sys_suggestion
+		SELECT COUNT(*) FROM sys_suggestion ss
+        <include refid="queryCondition" />
 	</select>
 </mapper>

+ 6 - 4
mec-student/src/main/java/com/ym/mec/student/controller/StudentManageController.java

@@ -1,13 +1,11 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.biz.dal.enums.SuggestionType;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -121,6 +119,9 @@ public class StudentManageController extends BaseController {
         }
     	sysSuggestion.setClientType("STUDENT");
         sysSuggestion.setUserId(sysUser.getId().longValue());
+        if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
+            sysSuggestion.setMobileNo(sysUser.getPhone());
+        }
         suggestionService.insert(sysSuggestion);
         return succeed();
     }
@@ -136,6 +137,7 @@ public class StudentManageController extends BaseController {
 		Student student = studentService.get(user.getId());
 		student.setId(user.getId());
 		student.setUsername(user.getUsername());
+		student.setAvatar(user.getAvatar());
 		student.setPhone(user.getPhone());
 		student.setCurrentClass(user.getCurrentClass());
 		student.setCurrentGrade(user.getCurrentGrade());

+ 6 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SoundController.java

@@ -49,6 +49,12 @@ public class SoundController extends BaseController {
         return soundService.measureCompare(musicXmlInfoList, record);
     }
 
+    @ApiOperation(value = "获取在线人数")
+    @GetMapping("getOnlineUserNum")
+    public HttpResponseResult getOnlineUserNum(){
+        return succeed(WebSocketHandler.WS_CLIENTS.size());
+    }
+
     @RequestMapping("sendToUser")
     public HttpResponseResult sendToUser(String phone, String message) throws IOException {
         if(!WebSocketHandler.WS_CLIENTS.containsKey(phone)){

+ 6 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherManageController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.teacher.controller;
 
+import com.ym.mec.biz.dal.enums.SuggestionType;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -30,6 +31,8 @@ import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.UploadReturnBean;
 import com.ym.mec.util.upload.UploadUtil;
 
+import java.util.Objects;
+
 @Api(tags = "教师管理")
 @RestController
 public class TeacherManageController extends BaseController {
@@ -79,6 +82,9 @@ public class TeacherManageController extends BaseController {
         }
         sysSuggestion.setUserId(sysUser.getId().longValue());
     	sysSuggestion.setClientType("TEACHER");
+        if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
+            sysSuggestion.setMobileNo(sysUser.getPhone());
+        }
         suggestionService.insert(sysSuggestion);
         return succeed();
     }

+ 28 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SoundCompareController.java

@@ -0,0 +1,28 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.handler.WebSocketHandler;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/8/10 0010
+ */
+@Api(tags = "音频服务")
+@RequestMapping("soundCompare")
+@RestController
+public class SoundCompareController extends BaseController {
+
+    @ApiOperation(value = "获取在线人数")
+    @GetMapping("getOnlineUserNum")
+    public HttpResponseResult getOnlineUserNum(){
+        return succeed(WebSocketHandler.WS_CLIENTS.size());
+    }
+
+}

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

@@ -46,7 +46,6 @@ import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.biz.dal.page.NoClassMusicStudentQueryInfo;
 import com.ym.mec.biz.dal.page.RegistrationOrPreQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPreRegistrationQueryInfo;
@@ -443,13 +442,7 @@ public class StudentRegistrationController extends BaseController {
     	if(isContinue == null){
     		isContinue = false;
     	}
-        StudentRegistration studentRegistration = studentRegistrationService.get(id);
-        //已付费的增加,已缴费人数、和0元付费人数
-        if (studentRegistration.getPaymentStatus().equals(PaymentStatusEnum.YES)) {
-            return studentRegistrationService.addPaidNum(id, isContinue);
-        } else {
-            return succeed(studentRegistrationService.setNoneCloudTeacher(id));
-        }
+    	return studentRegistrationService.addPaidNum(id, isContinue);
     }
 
 

+ 40 - 10
mec-web/src/main/java/com/ym/mec/web/controller/SysSuggestionController.java

@@ -1,36 +1,66 @@
 package com.ym.mec.web.controller;
 
-import com.ym.mec.biz.dal.entity.ChargeType;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.SysSuggestion;
-import com.ym.mec.biz.service.ChargeTypeService;
+import com.ym.mec.biz.dal.enums.SuggestionType;
+import com.ym.mec.biz.dal.page.SysSuggestionQueryInfo;
 import com.ym.mec.biz.service.SysSuggestionService;
 import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Objects;
 
-@RequestMapping("sysSuggestion")
 @Api(tags = "意见反馈")
 @RestController
 public class SysSuggestionController extends BaseController {
 
     @Autowired
     private SysSuggestionService sysSuggestionService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @ApiOperation(value = "新增")
-    @RequestMapping("/add")
+    @RequestMapping("sysSuggestion/add")
     @PreAuthorize("@pcs.hasPermissions('sysSuggestion/add')")
     public Object add(SysSuggestion sysSuggestion) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        sysSuggestion.setUserId(sysUser.getId().longValue());
+        sysSuggestion.setClientType("TEACHER");
+        if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
+            sysSuggestion.setMobileNo(sysUser.getPhone());
+        }
+        sysSuggestionService.insert(sysSuggestion);
+        return succeed();
+    }
+
+    @ApiOperation(value = "新增")
+    @RequestMapping("suggestion/add")
+    public Object suggestionAdd(SysSuggestion sysSuggestion) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        sysSuggestion.setUserId(sysUser.getId().longValue());
+        sysSuggestion.setClientType("EDUCATION");
+        if(StringUtils.isEmpty(sysSuggestion.getMobileNo())){
+            sysSuggestion.setMobileNo(sysUser.getPhone());
+        }
         sysSuggestionService.insert(sysSuggestion);
         return succeed();
     }
 
     @ApiOperation(value = "删除")
-    @RequestMapping("/del")
+    @RequestMapping("sysSuggestion/del")
     @PreAuthorize("@pcs.hasPermissions('sysSuggestion/del')")
     public Object del(Long id) {
         sysSuggestionService.delete(id);
@@ -38,9 +68,9 @@ public class SysSuggestionController extends BaseController {
     }
 
     @ApiOperation(value = "分页查询")
-    @RequestMapping("/queryPage")
+    @RequestMapping("sysSuggestion/queryPage")
     @PreAuthorize("@pcs.hasPermissions('sysSuggestion/queryPage')")
-    public Object queryPage(QueryInfo queryInfo) {
+    public Object queryPage(SysSuggestionQueryInfo queryInfo) {
         return succeed(sysSuggestionService.queryPage(queryInfo));
     }