Browse Source

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

zouxuan 4 năm trước cách đây
mục cha
commit
e53b946c68
25 tập tin đã thay đổi với 804 bổ sung364 xóa
  1. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentInstrumentDao.java
  2. 14 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java
  3. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentApplyDetailDto.java
  4. 177 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentInstrument.java
  5. 12 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPreRegistration.java
  6. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GroupType.java
  7. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java
  8. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java
  9. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupStudentQueryInfo.java
  10. 24 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentInstrumentQueryInfo.java
  11. 24 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentRegistrationQueryInfo.java
  12. 19 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentInstrumentService.java
  13. 10 6
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java
  14. 71 206
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  15. 137 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java
  16. 51 137
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  17. 117 0
      mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml
  18. 6 0
      mec-biz/src/main/resources/config/mybatis/StudentManageDao.xml
  19. 5 1
      mec-biz/src/main/resources/config/mybatis/StudentPreRegistrationMapper.xml
  20. 8 1
      mec-biz/src/main/resources/config/mybatis/StudentRegistrationMapper.xml
  21. 1 0
      mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java
  22. 55 0
      mec-student/src/main/java/com/ym/mec/student/controller/StudentInstrumentController.java
  23. 1 1
      mec-student/src/main/resources/bootstrap-test.properties
  24. 14 4
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupController.java
  25. 11 0
      mec-web/src/main/java/com/ym/mec/web/controller/OrganizationController.java

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentInstrumentDao.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface StudentInstrumentDao extends BaseDAO<Long, StudentInstrument> {
+
+}

+ 14 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java

@@ -14,11 +14,11 @@ public class RegisterPayDto {
     private BigDecimal amount;
     //报名id
     private Integer registerId;
-    //打包商品ids
+    //打包商品ids(废弃)
     private String goodsGroupIds;
-    //单独商品ids
+    //单独商品ids(废弃)
     private String goodsIds;
-    //教谱ids
+    //教谱ids(废弃)
     private String otherGoodsIds;
     //乐器id->type
     private Map<Long, String> goodsGroups;
@@ -32,6 +32,9 @@ public class RegisterPayDto {
     @ApiModelProperty(value = "新的乐团课程形态",required = false)
     private List<Integer> newCourse;
 
+    @ApiModelProperty(value = "购买乐器保养",required = false)
+    private Boolean buyMaintenance = false;
+
     public Integer getRegisterId() {
         return registerId;
     }
@@ -103,4 +106,12 @@ public class RegisterPayDto {
     public void setNewCourse(List<Integer> newCourse) {
         this.newCourse = newCourse;
     }
+
+    public Boolean getBuyMaintenance() {
+        return buyMaintenance;
+    }
+
+    public void setBuyMaintenance(Boolean buyMaintenance) {
+        this.buyMaintenance = buyMaintenance;
+    }
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentApplyDetailDto.java

@@ -65,6 +65,9 @@ public class StudentApplyDetailDto{
     @ApiModelProperty(value = "备注",required = false)
     private String remark;
 
+    @ApiModelProperty(value = "注册时间",required = false)
+    private Date createTime;
+
     @ApiModelProperty(value = "声部更换详情",required = false)
     private SubjectChange subjectChange;
 
@@ -203,4 +206,12 @@ public class StudentApplyDetailDto{
     public void setCurrentGradeDate(Date currentGradeDate) {
         this.currentGradeDate = currentGradeDate;
     }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
 }

+ 177 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentInstrument.java

@@ -0,0 +1,177 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
+
+@ApiModel(value = "com-ym-mec-biz-dal-entity-StudentInstrument")
+public class StudentInstrument {
+    @ApiModelProperty(value = "")
+    private Long id;
+
+    /**
+     * 学生id
+     */
+    @ApiModelProperty(value = "学生id")
+    private Integer studentId;
+
+    /**
+     * 分部id
+     */
+    @ApiModelProperty(value = "分部id")
+    private Integer organId;
+
+    /**
+     * 商品id
+     */
+    @ApiModelProperty(value = "商品id")
+    private Integer goodsId;
+
+    /**
+     * 是否月保 0-不是 1-是
+     */
+    @ApiModelProperty(value = "是否月保 0-不是 1-是")
+    private Integer status;
+
+    /**
+     * 月保开始时间
+     */
+    @ApiModelProperty(value = "月保开始时间")
+    private Date startTime;
+
+    /**
+     * 月保结束时间
+     */
+    @ApiModelProperty(value = "月保结束时间")
+    private Date endTime;
+
+    /**
+     * 添加时间
+     */
+    @ApiModelProperty(value = "添加时间")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "乐器名称")
+    private String goodsName;
+
+    @ApiModelProperty(value = "乐器品牌")
+    private String goodsBrand;
+
+    @ApiModelProperty(value = "乐器规格")
+    private String specification;
+
+    @ApiModelProperty(value = "乐器图片")
+    private String goodsImg;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Integer getGoodsId() {
+        return goodsId;
+    }
+
+    public void setGoodsId(Integer goodsId) {
+        this.goodsId = goodsId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+
+    public String getGoodsName() {
+        return goodsName;
+    }
+
+    public void setGoodsName(String goodsName) {
+        this.goodsName = goodsName;
+    }
+
+
+    public String getGoodsImg() {
+        return goodsImg;
+    }
+
+    public void setGoodsImg(String goodsImg) {
+        this.goodsImg = goodsImg;
+    }
+
+    public String getGoodsBrand() {
+        return goodsBrand;
+    }
+
+    public void setGoodsBrand(String goodsBrand) {
+        this.goodsBrand = goodsBrand;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(Integer organId) {
+        this.organId = organId;
+    }
+}

+ 12 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPreRegistration.java

@@ -23,10 +23,13 @@ public class StudentPreRegistration {
 	
 	/** 性别 */
 	private boolean gender;
-	
+
 	/** 年级 */
 	private String currentGrade;
-	
+
+	/** 年级编号 */
+	private Integer currentGradeNum;
+
 	/** 班级 */
 	private String currentClass;
 	
@@ -154,4 +157,11 @@ public class StudentPreRegistration {
 		return ToStringBuilder.reflectionToString(this);
 	}
 
+	public Integer getCurrentGradeNum() {
+		return currentGradeNum;
+	}
+
+	public void setCurrentGradeNum(Integer currentGradeNum) {
+		this.currentGradeNum = currentGradeNum;
+	}
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GroupType.java

@@ -12,7 +12,8 @@ public enum GroupType implements BaseEnum<String, GroupType> {
 	REPAIR("乐器维修"),
 	GOODS_SELL("商品销售"),
 	OUTORDER("外部订单"),
-	SUBJECT_CHANGE("声部更换");
+	SUBJECT_CHANGE("声部更换"),
+	MAINTENANCE("乐保");
 
 	private String desc;
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java

@@ -24,7 +24,8 @@ public enum OrderDetailTypeEnum implements BaseEnum<String, OrderDetailTypeEnum>
     HIGH_ONLINE("HIGH_ONLINE", "网络基础训练课"),
     MUSIC_NETWORK("MUSIC_NETWORK", "乐团网管课"),
     CLASSROOM("CLASSROOM", "课堂课"),
-	DEGREE_REGISTRATION("DEGREE_REGISTRATION", "考级报名");
+	DEGREE_REGISTRATION("DEGREE_REGISTRATION", "考级报名"),
+    MAINTENANCE("MAINTENANCE","月保服务");
 
     private String code;
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java

@@ -21,7 +21,8 @@ public enum OrderTypeEnum implements BaseEnum<String, OrderTypeEnum> {
 	OUTORDER("OUTORDER", "外部订单"),
 	REPAIR("REPAIR","乐器维修"),
 	SUBJECT_CHANGE("SUBJECT_CHANGE","声部更换"),
-	DEGREE_REGISTRATION("DEGREE_REGISTRATION", "考级报名");
+	DEGREE_REGISTRATION("DEGREE_REGISTRATION", "考级报名"),
+	MAINTENANCE("MAINTENANCE","乐保");
 
 
 	private String code;

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupStudentQueryInfo.java

@@ -41,6 +41,12 @@ public class MusicGroupStudentQueryInfo extends QueryInfo {
   @ApiModelProperty(value = "加油包:0:默认不可用;1:可用;2:已使用;")
   private Integer comeOnPackage;
 
+  @ApiModelProperty(value = "年级",required = false)
+  private String currentGrade;
+
+  @ApiModelProperty(value = "入学年份",required = false)
+  private String createYear;
+
   private boolean isExport = false;
 
   public Boolean getOweFlag() {
@@ -146,4 +152,20 @@ public class MusicGroupStudentQueryInfo extends QueryInfo {
   public void setPaymentStatus(String paymentStatus) {
     this.paymentStatus = paymentStatus;
   }
+
+  public String getCurrentGrade() {
+    return currentGrade;
+  }
+
+  public void setCurrentGrade(String currentGrade) {
+    this.currentGrade = currentGrade;
+  }
+
+  public String getCreateYear() {
+    return createYear;
+  }
+
+  public void setCreateYear(String createYear) {
+    this.createYear = createYear;
+  }
 }

+ 24 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentInstrumentQueryInfo.java

@@ -0,0 +1,24 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+public class StudentInstrumentQueryInfo extends QueryInfo {
+
+    /**
+     * 学生id
+     */
+    @ApiModelProperty(value = "学生id", required = true)
+    private Integer studentId;
+
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+}

+ 24 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentRegistrationQueryInfo.java

@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.common.page.QueryInfo;
 
+import javax.xml.crypto.Data;
+
 public class StudentRegistrationQueryInfo extends QueryInfo {
 
     @ApiModelProperty(value = "乐团编号",required = false)
@@ -25,6 +27,12 @@ public class StudentRegistrationQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "用户名或手机号",required = false)
     private String name;
 
+    @ApiModelProperty(value = "年级",required = false)
+    private String currentGrade;
+
+    @ApiModelProperty(value = "入学年份",required = false)
+    private String createYear;
+
     private boolean isExport = false;
 
     public boolean getIsExport() {
@@ -82,4 +90,20 @@ public class StudentRegistrationQueryInfo extends QueryInfo {
     public void setPaymentStatus(String paymentStatus) {
         this.paymentStatus = paymentStatus;
     }
+
+    public String getCreateYear() {
+        return createYear;
+    }
+
+    public void setCreateYear(String createYear) {
+        this.createYear = createYear;
+    }
+
+    public String getCurrentGrade() {
+        return currentGrade;
+    }
+
+    public void setCurrentGrade(String currentGrade) {
+        this.currentGrade = currentGrade;
+    }
 }

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

@@ -0,0 +1,19 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+
+import com.ym.mec.common.service.BaseService;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+public interface StudentInstrumentService extends BaseService<Long, StudentInstrument> {
+
+    /**
+     * 乐保支付
+     *
+     * @param id
+     * @return
+     */
+    Map pay(Long id, BigDecimal amount, boolean isUseBalance) throws Exception;
+}

+ 10 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -83,17 +83,22 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
 
     /**
      * 学生注册缴费订单
-     *
      * @param studentRegistration
      * @param amount
+     * @param orderNo
+     * @param paymentChannel
      * @param courseFee
      * @param goodsGroups
-     * @param goodsList
+     * @param remitFee
+     * @param courseRemitFee
+     * @param newCourses
+     * @param buyMaintenance
      * @return
+     * @throws Exception
      */
     StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee,
-                                 List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, List<CourseFormDto> courseForms,
-                                 BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses) throws Exception;
+                                 List<MusicGroupSubjectGoodsGroup> goodsGroups,BigDecimal remitFee, BigDecimal courseRemitFee,
+                                 List<MusicGroupPaymentCalenderCourseSettings> newCourses,Boolean buyMaintenance) throws Exception;
 
     /**
      * 学生注册缴费重新下订单
@@ -107,8 +112,7 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      */
     StudentPaymentOrder reAddOrder(
             Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee,
-            List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList,
-            String musicGroupId, StudentPaymentOrder oldOrder, List<CourseFormDto> courseForms, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses) throws Exception;
+            List<MusicGroupSubjectGoodsGroup> goodsGroups, String musicGroupId, StudentPaymentOrder oldOrder, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses,Boolean buyMaintenance) throws Exception;
 
     /**
      * 查询用户指定乐团的报名信息

+ 71 - 206
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -19,6 +19,7 @@ import java.util.stream.Collectors;
 
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.event.source.GroupEventSource;
+import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.service.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -75,21 +76,6 @@ import com.ym.mec.biz.dal.entity.Subject;
 import com.ym.mec.biz.dal.entity.SubjectChange;
 import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
-import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
-import com.ym.mec.biz.dal.enums.CourseStatusEnum;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GoodsType;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
-import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-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.PaymentStatusEnum;
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.MusicGroupQueryInfo;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -288,7 +274,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         if (musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT) {
             Set<Integer> roleIds = new HashSet<>(1);
             roleIds.add(SysUserRole.SECTION_MANAGER);
-            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(),musicGroup.getName());
+            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(), musicGroup.getName());
         }
         // 保存乐团付费主体列表
         //批量新增
@@ -420,6 +406,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             student.setCreateTime(date);
             student.setUpdateTime(date);
             student.setIsNewUser(true);
+            student.setCurrentGradeNum(studentPreRegistration.getCurrentGradeNum());
+            student.setCurrentClass(studentPreRegistration.getCurrentClass());
             studentDao.insert(student);
             sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
         }
@@ -427,6 +415,23 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPreRegistration.setCreateTime(date);
         studentPreRegistration.setUserId(user.getId());
 
+        Organization organization = organizationDao.get(musicGroup.getOrganId());
+        if(organization.getGradeType().equals(GradeTypeEnum.SIX_PLUS)){
+            for (SixPlusGradeEnum value : SixPlusGradeEnum.values()) {
+                if(value.getCode().equals(studentPreRegistration.getCurrentGradeNum())){
+                    studentPreRegistration.setCurrentGrade(value.getDesc());
+                    break;
+                }
+            }
+        }else {
+            for (FivePlusGradeEnum value : FivePlusGradeEnum.values()) {
+                if(value.getCode().equals(studentPreRegistration.getCurrentGradeNum())){
+                    studentPreRegistration.setCurrentGrade(value.getDesc());
+                    break;
+                }
+            }
+        }
+
         studentPreRegistrationDao.insert(studentPreRegistration);
 
         // 添加成员
@@ -641,9 +646,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         //获取课程价格
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
         BigDecimal courseFee = musicOneSubjectClassPlan.getFee() == null ? BigDecimal.ZERO : musicOneSubjectClassPlan.getFee();
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            courseFee = studentRegistration.getTemporaryCourseFee();
-        }
         orderAmount = orderAmount.add(courseFee);
 
         BigDecimal remitFee = BigDecimal.ZERO;
@@ -652,102 +654,31 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         //乐器及打包辅件
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
-            for (StudentPaymentOrderDetail orderDetail : orderDetails) {
-                if (orderDetail == null || orderDetail.getPrice() == null || orderDetail.getGoodsIdList() == null) {
-                    continue;
-                }
-                MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup = new MusicGroupSubjectGoodsGroup();
-                GoodsType goodsType = orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) ? GoodsType.INSTRUMENT : GoodsType.ACCESSORIES;
-                musicGroupSubjectGoodsGroup.setType(goodsType);
-                musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
-                musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
-                musicGroupSubjectGoodsGroup.setKitGroupPurchaseType(orderDetail.getKitGroupPurchaseType());
-                goodsGroups.add(musicGroupSubjectGoodsGroup);
-
-                orderAmount = orderAmount.add(orderDetail.getPrice());
-            }
-        } else if (StringUtils.isNoneBlank(registerPayDto.getGoodsGroupIds())) {
-            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
-            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                    goodsGroup.setPrice(musicOneSubjectClassPlan.getDepositFee());
-                    goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.LEASE);
-                }
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
-                    goodsGroup.setPrice(new BigDecimal(0));
-                }
-                orderAmount = orderAmount.add(goodsGroup.getPrice());
-                //团购乐器减免课程费用
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && goodsGroup.getRemissionCourseFee() != null && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
-                    orderAmount = orderAmount.subtract(goodsGroup.getRemissionCourseFee());
-                    courseFee = courseFee.subtract(goodsGroup.getRemissionCourseFee());
-                }
-            }
-        } else if (registerPayDto.getGoodsGroups() != null && registerPayDto.getGoodsGroups().size() > 0) {
+        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);
-                    }
-                    goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
-                    remitFee = groupType.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : groupType.get(kitGroupPurchaseType);
-                }
-                orderAmount = orderAmount.add(goodsGroup.getPrice());
-                goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
-            }
-            orderAmount = orderAmount.subtract(remitFee);
-        }
-
-        //单独辅件
-        List<Goods> goodsList = null;
-        if (registerPayDto.getGoodsIds() != null && !registerPayDto.getGoodsIds().equals("")) {
-            goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
-            for (Goods goods : goodsList) {
-                orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
-            }
         }
+        for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+            Map<String, BigDecimal> groupType = JSONObject.parseObject(goodsGroup.getKitGroupPurchaseTypeJson(), new TypeReference<Map<String, BigDecimal>>() {
+            });
 
-        //单独教谱
-        List<Goods> otherGoodsList = null;
-        if (registerPayDto.getOtherGoodsIds() != null && !registerPayDto.getOtherGoodsIds().equals("")) {
-            otherGoodsList = goodsService.findGoodsByIds(registerPayDto.getOtherGoodsIds());
-            for (Goods goods : otherGoodsList) {
-                orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
-            }
-        }
-        //可选课程
-        List<CourseFormDto> courseForms = new ArrayList<>();
-        if (registerPayDto.getCourseKeys() != null && registerPayDto.getCourseKeys().size() > 0) {
-            MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
-            if (musicGroup.getCourseForm() == null) {
-                throw new BizException("可选课程不存在");
-            }
-            JSONObject courseForm = JSON.parseObject(musicGroup.getCourseForm());
-            for (String courseKey : registerPayDto.getCourseKeys()) {
-                if (courseForm.get(courseKey) == null) {
-                    throw new BizException("可选课程不存在");
+            if (goodsGroup.getType().equals(GoodsType.INSTRUMENT)) {
+                String kitGroupPurchaseType = registerPayDto.getGoodsGroups().get(goodsGroup.getId());
+                if (!groupType.containsKey(kitGroupPurchaseType)) {
+                    throw new BizException("乐器提供方式不存在,请核查");
                 }
-                CourseFormDto courseFormDto = new CourseFormDto();
-                JSONObject jsonObject = JSON.parseObject(courseForm.getString(courseKey));
-                orderAmount = orderAmount.add(jsonObject.getBigDecimal("value"));
-                courseFormDto.setType(courseKey);
-                courseFormDto.setPrice(jsonObject.getBigDecimal("value"));
-                courseForms.add(courseFormDto);
+                if (!kitGroupPurchaseType.equals("GROUP")) {
+                    goodsGroup.setPrice(kitGroupPurchaseType.equals("FREE") ? new BigDecimal(0) : goodsGroup.getDepositFee());
+                } else {
+                    remitCourseRFeeFlag = goodsGroup.getGroupRemissionCourseFee().equals(1);
+                }
+                goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
+                remitFee = groupType.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : groupType.get(kitGroupPurchaseType);
             }
+            orderAmount = orderAmount.add(goodsGroup.getPrice());
+            goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
         }
+        orderAmount = orderAmount.subtract(remitFee);
 
         //新课程形态
         List<MusicGroupPaymentCalenderCourseSettings> newCourses = new ArrayList<>();
@@ -761,6 +692,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 orderAmount = orderAmount.add(calenderCourseSetting.getCourseCurrentPrice());
             }
         }
+        //乐器保养
+        if(registerPayDto.getBuyMaintenance()){
+            orderAmount = orderAmount.add(new BigDecimal(400));
+        }
 
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
@@ -773,7 +708,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         String channelType = "";
 
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, courseForms, remitFee, courseRemitFee, newCourses);
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, remitFee, courseRemitFee, newCourses,registerPayDto.getBuyMaintenance());
         studentPaymentOrder.setVersion(0);
 
         Date date = new Date();
@@ -861,9 +796,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         //获取课程价格
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
         BigDecimal courseFee = musicOneSubjectClassPlan.getFee() == null ? BigDecimal.ZERO : musicOneSubjectClassPlan.getFee();
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            courseFee = studentRegistration.getTemporaryCourseFee();
-        }
         orderAmount = orderAmount.add(courseFee);
 
         BigDecimal remitFee = BigDecimal.ZERO;
@@ -873,100 +805,29 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         //乐器及打包辅件
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
-            for (StudentPaymentOrderDetail orderDetail : orderDetails) {
-                if (orderDetail == null || orderDetail.getPrice() == null || orderDetail.getGoodsIdList() == null) {
-                    continue;
-                }
-                MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup = new MusicGroupSubjectGoodsGroup();
-                GoodsType goodsType = orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) ? GoodsType.INSTRUMENT : GoodsType.ACCESSORIES;
-                musicGroupSubjectGoodsGroup.setType(goodsType);
-                musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
-                musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
-                musicGroupSubjectGoodsGroup.setKitGroupPurchaseType(orderDetail.getKitGroupPurchaseType());
-                goodsGroups.add(musicGroupSubjectGoodsGroup);
-
-                orderAmount = orderAmount.add(orderDetail.getPrice());
-            }
-        } else if (StringUtils.isNoneBlank(registerPayDto.getGoodsGroupIds())) {
-            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
-            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                    goodsGroup.setPrice(musicOneSubjectClassPlan.getDepositFee());
-                }
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
-                    goodsGroup.setPrice(new BigDecimal(0));
-                }
-                orderAmount = orderAmount.add(goodsGroup.getPrice());
-
-                //团购乐器减免课程费用
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && goodsGroup.getRemissionCourseFee() != null && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
-                    orderAmount = orderAmount.subtract(goodsGroup.getRemissionCourseFee());
-                    courseFee = courseFee.subtract(goodsGroup.getRemissionCourseFee());
-                }
-            }
-        } else if (registerPayDto.getGoodsGroups() != null && registerPayDto.getGoodsGroups().size() > 0) {
+        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);
-                    }
-                    goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
-                    remitFee = groupType.get(kitGroupPurchaseType);
-                }
-                orderAmount = orderAmount.add(goodsGroup.getPrice());
-                goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
-            }
-            orderAmount = orderAmount.subtract(remitFee).subtract(courseRemitFee);
-        }
-
-        //单独辅件
-        List<Goods> goodsList = null;
-        if (registerPayDto.getGoodsIds() != null && !registerPayDto.getGoodsIds().equals("")) {
-            goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
-            for (Goods goods : goodsList) {
-                orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
-            }
         }
+        for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+            Map<String, BigDecimal> groupType = JSONObject.parseObject(goodsGroup.getKitGroupPurchaseTypeJson(), new TypeReference<Map<String, BigDecimal>>() {
+            });
 
-        //单独教谱
-        List<Goods> otherGoodsList = null;
-        if (registerPayDto.getOtherGoodsIds() != null && !registerPayDto.getOtherGoodsIds().equals("")) {
-            otherGoodsList = goodsService.findGoodsByIds(registerPayDto.getOtherGoodsIds());
-            for (Goods goods : otherGoodsList) {
-                orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
-            }
-        }
-        //可选课程
-        List<CourseFormDto> courseForms = new ArrayList<>();
-        if (registerPayDto.getCourseKeys() != null && registerPayDto.getCourseKeys().size() > 0) {
-            MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
-            if (musicGroup.getCourseForm() == null) {
-                throw new BizException("可选课程不存在");
-            }
-            JSONObject courseForm = JSON.parseObject(musicGroup.getCourseForm());
-            for (String courseKey : registerPayDto.getCourseKeys()) {
-                if (courseForm.get(courseKey) == null) {
-                    throw new BizException("可选课程不存在");
+            if (goodsGroup.getType().equals(GoodsType.INSTRUMENT)) {
+                String kitGroupPurchaseType = registerPayDto.getGoodsGroups().get(goodsGroup.getId());
+                if (!groupType.containsKey(kitGroupPurchaseType)) {
+                    throw new BizException("乐器提供方式不存在,请核查");
                 }
-                CourseFormDto courseFormDto = new CourseFormDto();
-                JSONObject jsonObject = JSON.parseObject(courseForm.getString(courseKey));
-                orderAmount = orderAmount.add(jsonObject.getBigDecimal("value"));
-                courseFormDto.setType(courseKey);
-                courseFormDto.setPrice(jsonObject.getBigDecimal("value"));
-                courseForms.add(courseFormDto);
+                if (!kitGroupPurchaseType.equals("GROUP")) {
+                    goodsGroup.setPrice(kitGroupPurchaseType.equals("FREE") ? new BigDecimal(0) : goodsGroup.getDepositFee());
+                } else {
+                    remitCourseRFeeFlag = goodsGroup.getGroupRemissionCourseFee().equals(1);
+                }
+                goodsGroup.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.valueOf(kitGroupPurchaseType));
+                remitFee = groupType.get(kitGroupPurchaseType) == null ? BigDecimal.ZERO : groupType.get(kitGroupPurchaseType);
             }
+            orderAmount = orderAmount.add(goodsGroup.getPrice());
+            goodsGroup.setGoodsList(goodsService.findGoodsByIds(goodsGroup.getGoodsIdList()));
         }
 
         //新课程形态
@@ -982,6 +843,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
         }
 
+        if(registerPayDto.getBuyMaintenance()){
+            orderAmount = orderAmount.add(new BigDecimal(400));
+        }
+
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
         }
@@ -994,7 +859,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         String channelType = "";
 
-        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId(), ApplyOrder, courseForms, remitFee, courseRemitFee, newCourses);
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, studentRegistration.getMusicGroupId(), ApplyOrder, remitFee, courseRemitFee, newCourses,registerPayDto.getBuyMaintenance());
         studentPaymentOrder.setVersion(0);
         Date date = new Date();
 
@@ -1134,7 +999,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         Set<Integer> roleIds = new HashSet<>(1);
         roleIds.add(SysUserRole.SECTION_MANAGER);
 
-        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(),musicGroup.getName());
+        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(), musicGroup.getName());
 
     }
 
@@ -1240,7 +1105,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         Set<Integer> roleIds = new HashSet<>(1);
         roleIds.add(SysUserRole.SECTION_MANAGER);
 
-        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(),musicGroup.getName());
+        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(), musicGroup.getName());
 
     }
 
@@ -1299,9 +1164,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         Set<Integer> roleIds = new HashSet<>(1);
         roleIds.add(SysUserRole.EDUCATIONAL_TEACHER);
         sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()),
-                MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS, "",musicGroup.getName());
+                MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS, "", musicGroup.getName());
         Map<Integer, String> map = new HashMap<>(1);
-        map.put(musicGroup.getEducationalTeacherId(),musicGroup.getEducationalTeacherId().toString());
+        map.put(musicGroup.getEducationalTeacherId(), musicGroup.getEducationalTeacherId().toString());
         if (map != null && map.size() > 0) {
             sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS,
                     map, null, 0, null, "SYSTEM", musicGroup.getName());
@@ -2163,7 +2028,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             if (oldStudentPaymentOrder != null) {
                 if (oldStudentPaymentOrder.getStatus() == SUCCESS) {
                     throw new BizException("您已支付请勿重复提交");
-                }else if(oldStudentPaymentOrder.getStatus() == ING){
+                } else if (oldStudentPaymentOrder.getStatus() == ING) {
                     oldStudentPaymentOrder.setStatus(CLOSE);
                     studentPaymentOrderService.update(oldStudentPaymentOrder);
                     if (oldStudentPaymentOrder.getBalancePaymentAmount() != null && oldStudentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {

+ 137 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -0,0 +1,137 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.service.*;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.IdGeneratorService;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentInstrument> implements StudentInstrumentService {
+
+    @Autowired
+    private StudentInstrumentDao studentInstrumentDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
+    @Autowired
+    private PayService payService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
+    @Autowired
+    private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
+    @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
+    @Autowired
+    private StudentDao studentDao;
+
+    @Override
+    public BaseDAO<Long, StudentInstrument> getDAO() {
+        return studentInstrumentDao;
+    }
+
+    @Override
+    public Map pay(Long id, BigDecimal amount, boolean isUseBalance) throws Exception {
+        StudentInstrument studentInstrument = studentInstrumentDao.get(id);
+        if (studentInstrument == null) {
+            throw new BizException("所选乐器不存在,请核查");
+        }
+        Integer userId = studentInstrument.getStudentId();
+        BigDecimal orderAmount = new BigDecimal(400);
+
+        if (amount.compareTo(orderAmount) != 0) {
+            throw new BizException("商品价格不符");
+        }
+
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+
+        String channelType = "";
+        Date date = new Date();
+
+        BigDecimal balance = BigDecimal.ZERO;
+        if (isUseBalance && amount.compareTo(BigDecimal.ZERO) > 0) {
+            SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+            if (userCashAccount == null) {
+                throw new BizException("用户账户找不到");
+            }
+            if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
+                balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
+                amount = amount.subtract(balance);
+                sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐保购买");
+            }
+        }
+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+
+        studentPaymentOrder.setPaymentChannel("BALANCE");
+        studentPaymentOrder.setUserId(userId);
+        studentPaymentOrder.setGroupType(GroupType.MAINTENANCE);
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setType(OrderTypeEnum.MAINTENANCE);
+        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setBalancePaymentAmount(balance);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setMusicGroupId(studentInstrument.getId().toString());
+        studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
+        studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
+        studentPaymentOrder.setOrganId(studentInstrument.getOrganId());
+        studentPaymentOrder.setRoutingOrganId(studentInstrument.getOrganId());
+        studentPaymentOrder.setCreateTime(date);
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.insert(studentPaymentOrder);
+        studentPaymentOrder.setVersion(0);
+
+        if (amount.compareTo(BigDecimal.ZERO) == 0) {
+            studentPaymentRouteOrderService.addRouteOrder(orderNo, studentInstrument.getOrganId(), balance);
+            Map<String, String> notifyMap = new HashMap<>();
+            notifyMap.put("tradeState", "1");
+            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+            notifyMap.put("channelType", channelType);
+            notifyMap.put("orderNo", "");
+            studentPaymentOrderService.updateOrder(notifyMap);
+            return notifyMap;
+        }
+
+        String orderSubject = "乐保服务";
+        String receiver = "maintenance";
+
+        String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+
+        Map payMap = payService.getPayMap(
+                amount,
+                balance,
+                orderNo,
+                baseApiUrl + "/api-student/studentOrder/notify",
+                baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
+                orderSubject,
+                orderSubject,
+                studentInstrument.getOrganId(),
+                receiver
+        );
+
+        studentPaymentOrder.setOrganId(studentInstrument.getOrganId());
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.update(studentPaymentOrder);
+        return payMap;
+    }
+}

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

@@ -22,6 +22,9 @@ import javax.annotation.Resource;
 
 import com.ym.mec.biz.event.source.GroupEventSource;
 import org.apache.commons.lang3.ArrayUtils;
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,24 +40,6 @@ 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.auth.api.enums.CertificateTypeEnum;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.GoodsDao;
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
-import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
-import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
-import com.ym.mec.biz.dal.dao.StudentCourseFeeDetailDao;
-import com.ym.mec.biz.dal.dao.StudentDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
-import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
-import com.ym.mec.biz.dal.dao.SubjectChangeDao;
-import com.ym.mec.biz.dal.dao.SubjectDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
-import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
-import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dto.CourseFormDto;
 import com.ym.mec.biz.dal.dto.StudentAddDto;
 import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
@@ -62,43 +47,6 @@ import com.ym.mec.biz.dal.dto.StudentFeeDetailDto;
 import com.ym.mec.biz.dal.dto.StudentInfo;
 import com.ym.mec.biz.dal.dto.StudentMusicDetailDto;
 import com.ym.mec.biz.dal.dto.StudentMusicGroupDto;
-import com.ym.mec.biz.dal.entity.ClassGroup;
-import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
-import com.ym.mec.biz.dal.entity.CooperationOrgan;
-import com.ym.mec.biz.dal.entity.CourseSchedule;
-import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
-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.MusicGroupPaymentCalenderCourseSettings;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderStudentDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
-import com.ym.mec.biz.dal.entity.Student;
-import com.ym.mec.biz.dal.entity.StudentCourseFeeDetail;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
-import com.ym.mec.biz.dal.entity.Subject;
-import com.ym.mec.biz.dal.entity.SubjectChange;
-import com.ym.mec.biz.dal.entity.SysUserCashAccount;
-import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
-import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
-import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
-import com.ym.mec.biz.dal.enums.CourseStatusEnum;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GoodsType;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
-import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
-import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
-import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
 import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.ClassGroupStudentMapperService;
@@ -204,6 +152,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     private StudentCourseFeeDetailDao studentCourseFeeDetailDao;
     @Autowired
     private CourseScheduleDao courseScheduleDao;
+    @Autowired
+    private OrganizationDao organizationDao;
 
     @Autowired
     private GroupEventSource groupEventSource;
@@ -356,6 +306,24 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentRegistration.setUpdateTime(date);
         studentRegistration.setUserId(sysUser.getId());
         studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.APPLY);
+
+        Organization organization = organizationDao.get(studentRegistration.getOrganId());
+        if(organization.getGradeType().equals(GradeTypeEnum.SIX_PLUS)){
+            for (SixPlusGradeEnum value : SixPlusGradeEnum.values()) {
+                if(value.getCode().equals(studentRegistration.getCurrentGradeNum())){
+                    studentRegistration.setCurrentGrade(value.getDesc());
+                    break;
+                }
+            }
+        }else {
+            for (FivePlusGradeEnum value : FivePlusGradeEnum.values()) {
+                if(value.getCode().equals(studentRegistration.getCurrentGradeNum())){
+                    studentRegistration.setCurrentGrade(value.getDesc());
+                    break;
+                }
+            }
+        }
+
         if(hasReg != null){
             studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
             studentRegistration.setId(hasReg.getId());
@@ -391,7 +359,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, List<CourseFormDto> courseForms, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses) throws Exception {
+    public StudentPaymentOrder addOrder(StudentRegistration studentRegistration, BigDecimal amount, String orderNo, String paymentChannel,
+                                        BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses,Boolean buyMaintenance) throws Exception {
         Date date = new Date();
         StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
         studentPaymentOrder.setUserId(studentRegistration.getUserId());
@@ -440,45 +409,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             }
         }
 
-        //单独辅件
-        if (goodsList != null && goodsList.size() > 0) {
-            for (Goods goods : goodsList) {
-                StudentPaymentOrderDetail studentPaymentOrderDetail4goods = new StudentPaymentOrderDetail();
-                OrderDetailTypeEnum orderDetailType = goods.getType().equals(GoodsType.INSTRUMENT) ? OrderDetailTypeEnum.MUSICAL : OrderDetailTypeEnum.ACCESSORIES;
-                studentPaymentOrderDetail4goods.setType(orderDetailType);
-                studentPaymentOrderDetail4goods.setPrice(goods.getGroupPurchasePrice());
-                studentPaymentOrderDetail4goods.setGoodsIdList(goods.getId().toString());
-                studentPaymentOrderDetail4goods.setCreateTime(date);
-                studentPaymentOrderDetail4goods.setUpdateTime(date);
-                studentPaymentOrderDetail4goods.setPaymentOrderId(studentPaymentOrder.getId());
-                studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goods);
-            }
-        }
-        //单独教谱
-        if (otherGoodsList != null && otherGoodsList.size() > 0) {
-            for (Goods goods : otherGoodsList) {
-                StudentPaymentOrderDetail studentPaymentOrderDetail4otherGoods = new StudentPaymentOrderDetail();
-                studentPaymentOrderDetail4otherGoods.setType(OrderDetailTypeEnum.TEACHING);
-                studentPaymentOrderDetail4otherGoods.setPrice(goods.getGroupPurchasePrice());
-                studentPaymentOrderDetail4otherGoods.setGoodsIdList(goods.getId().toString());
-                studentPaymentOrderDetail4otherGoods.setCreateTime(date);
-                studentPaymentOrderDetail4otherGoods.setUpdateTime(date);
-                studentPaymentOrderDetail4otherGoods.setPaymentOrderId(studentPaymentOrder.getId());
-                studentPaymentOrderDetailList.add(studentPaymentOrderDetail4otherGoods);
-            }
-        }
-        //可选课程
-        if (courseForms != null && courseForms.size() > 0) {
-            for (CourseFormDto courseForm : courseForms) {
-                StudentPaymentOrderDetail studentPaymentOrderDetailCourse = new StudentPaymentOrderDetail();
-                studentPaymentOrderDetailCourse.setType(OrderDetailTypeEnum.HIGH_ONLINE_COURSE);
-                studentPaymentOrderDetailCourse.setPrice(courseForm.getPrice());
-                studentPaymentOrderDetailCourse.setCreateTime(date);
-                studentPaymentOrderDetailCourse.setUpdateTime(date);
-                studentPaymentOrderDetailCourse.setPaymentOrderId(studentPaymentOrder.getId());
-                studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
-            }
-        }
         //新的课程形态
         if (newCourses != null && newCourses.size() > 0) {
             for (MusicGroupPaymentCalenderCourseSettings newCourse : newCourses) {
@@ -498,6 +428,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
             }
         }
+        if(buyMaintenance){
+            StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
+            maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
+            maintenanceOrderDetail.setPrice(new BigDecimal(400));
+            maintenanceOrderDetail.setRemitFee(BigDecimal.ZERO);
+            maintenanceOrderDetail.setCreateTime(date);
+            maintenanceOrderDetail.setUpdateTime(date);
+            maintenanceOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+            studentPaymentOrderDetailList.add(maintenanceOrderDetail);
+        }
         studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
 
         //增加缴费学生数
@@ -528,7 +468,11 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public StudentPaymentOrder reAddOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId, StudentPaymentOrder oldOrder, List<CourseFormDto> courseForms, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses) {
+    public StudentPaymentOrder reAddOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee,
+                                          List<MusicGroupSubjectGoodsGroup> goodsGroups, String musicGroupId, StudentPaymentOrder oldOrder,
+                                          BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses,
+                                          Boolean buyMaintenance
+    ) {
         //关闭老订单
         oldOrder.setStatus(DealStatusEnum.CLOSE);
         studentPaymentOrderService.update(oldOrder);
@@ -583,46 +527,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             }
         }
 
-        //单独辅件
-        if (goodsList != null && goodsList.size() > 0) {
-            for (Goods goods : goodsList) {
-                StudentPaymentOrderDetail studentPaymentOrderDetail4goods = new StudentPaymentOrderDetail();
-                OrderDetailTypeEnum orderDetailType = goods.getType().equals(GoodsType.INSTRUMENT) ? OrderDetailTypeEnum.MUSICAL : OrderDetailTypeEnum.ACCESSORIES;
-                studentPaymentOrderDetail4goods.setType(orderDetailType);
-                studentPaymentOrderDetail4goods.setPrice(goods.getGroupPurchasePrice());
-                studentPaymentOrderDetail4goods.setGoodsIdList(goods.getId().toString());
-                studentPaymentOrderDetail4goods.setCreateTime(date);
-                studentPaymentOrderDetail4goods.setUpdateTime(date);
-                studentPaymentOrderDetail4goods.setPaymentOrderId(studentPaymentOrder.getId());
-                studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goods);
-
-            }
-        }
-        //单独教谱
-        if (otherGoodsList != null && otherGoodsList.size() > 0) {
-            for (Goods goods : otherGoodsList) {
-                StudentPaymentOrderDetail studentPaymentOrderDetail4otherGoods = new StudentPaymentOrderDetail();
-                studentPaymentOrderDetail4otherGoods.setType(OrderDetailTypeEnum.TEACHING);
-                studentPaymentOrderDetail4otherGoods.setPrice(goods.getGroupPurchasePrice());
-                studentPaymentOrderDetail4otherGoods.setGoodsIdList(goods.getId().toString());
-                studentPaymentOrderDetail4otherGoods.setCreateTime(date);
-                studentPaymentOrderDetail4otherGoods.setUpdateTime(date);
-                studentPaymentOrderDetail4otherGoods.setPaymentOrderId(studentPaymentOrder.getId());
-                studentPaymentOrderDetailList.add(studentPaymentOrderDetail4otherGoods);
-            }
-        }
-        //可选课程
-        if (courseForms != null && courseForms.size() > 0) {
-            for (CourseFormDto courseForm : courseForms) {
-                StudentPaymentOrderDetail studentPaymentOrderDetailCourse = new StudentPaymentOrderDetail();
-                studentPaymentOrderDetailCourse.setType(OrderDetailTypeEnum.HIGH_ONLINE_COURSE);
-                studentPaymentOrderDetailCourse.setPrice(courseForm.getPrice());
-                studentPaymentOrderDetailCourse.setCreateTime(date);
-                studentPaymentOrderDetailCourse.setUpdateTime(date);
-                studentPaymentOrderDetailCourse.setPaymentOrderId(studentPaymentOrder.getId());
-                studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
-            }
-        }
         //新的课程形态
         if (newCourses != null && newCourses.size() > 0) {
             for (MusicGroupPaymentCalenderCourseSettings newCourse : newCourses) {
@@ -641,6 +545,16 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
             }
         }
+        if(buyMaintenance){
+            StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
+            maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
+            maintenanceOrderDetail.setPrice(new BigDecimal(400));
+            maintenanceOrderDetail.setRemitFee(BigDecimal.ZERO);
+            maintenanceOrderDetail.setCreateTime(date);
+            maintenanceOrderDetail.setUpdateTime(date);
+            maintenanceOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+            studentPaymentOrderDetailList.add(maintenanceOrderDetail);
+        }
         studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
 
         return studentPaymentOrder;
@@ -1429,7 +1343,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         update(studentRegistration);
         studentRegistrationDao.updateUser(student.getUserId(),student.getName(), student.getParentsName(), student.getIdCardNo(), student.getGender(),studentRegistration.getCertificateType());
         //更新年级信息
-        Student studentInfo = studentDao.get(studentRegistration.getUserId());
+        Student studentInfo = studentDao.get(student.getUserId());
         studentInfo.setCurrentGradeNum(studentRegistration.getCurrentGradeNum());
         studentInfo.setCurrentClass(studentRegistration.getCurrentClass());
         studentDao.update(studentInfo);

+ 117 - 0
mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ym.mec.biz.dal.dao.StudentInstrumentDao">
+  <resultMap id="StudentInstrument" type="com.ym.mec.biz.dal.entity.StudentInstrument">
+    <!--@mbg.generated-->
+    <!--@Table student_instrument-->
+    <id column="id_" property="id" />
+    <result column="student_id_" property="studentId" />
+    <result column="organ_id_" property="organId" />
+    <result column="goods_id_" property="goodsId" />
+    <result column="status_" property="status" />
+    <result column="start_time_" property="startTime" />
+    <result column="end_time_" property="endTime" />
+    <result column="create_time_" property="createTime" />
+    <result column="update_time" property="updateTime" />
+    <result column="goods_name_" property="goodsName" />
+    <result column="specification_" property="specification" />
+    <result column="goods_brand_" property="goodsBrand" />
+    <result column="goods_img_" property="goodsImg" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    <!--@mbg.generated-->
+    id_,student_id_,organ_id_, goods_id_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time
+  </sql>
+  <select id="get" parameterType="java.lang.Integer" resultMap="StudentInstrument">
+    <!--@mbg.generated-->
+    select 
+    <include refid="Base_Column_List" />
+    from student_instrument
+    where id_ = #{id}
+  </select>
+  <delete id="delete" parameterType="java.lang.Integer">
+    <!--@mbg.generated-->
+    delete from student_instrument
+    where id_ = #{id}
+  </delete>
+  
+  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument" useGeneratedKeys="true">
+    <!--@mbg.generated-->
+    insert into student_instrument (student_id_,organ_id_,goods_id_,goods_name_,goods_brand_,specification_,goods_img_, status_, start_time_, end_time_, create_time_, update_time
+      )
+    values (#{studentId},#{organId},#{goodsId},#{goodsName},#{goodsBrand},#{specification},#{goodsImg}, #{status}, #{startTime}, #{endTime}, #{createTime}, #{updateTime}
+      )
+  </insert>
+  <update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentInstrument">
+    <!--@mbg.generated-->
+    update student_instrument
+    <set>
+      <if test="studentId != null">
+        student_id_ = #{studentId},
+      </if>
+      <if test="organId != null">
+        organ_id_ = #{organId},
+      </if>
+      <if test="goodsId != null">
+        goods_id_ = #{goodsId},
+      </if>
+      <if test="goodsName != null">
+        goods_name_ = #{goodsName},
+      </if>
+      <if test="goodsBrand != null">
+        goods_brand_ = #{goodsBrand},
+      </if>
+      <if test="specification != null">
+        specification_ = #{specification},
+      </if>
+      <if test="goodsImg != null">
+        goods_img_ = #{goodsImg},
+      </if>
+      <if test="status != null">
+        status_ = #{status},
+      </if>
+      <if test="startTime != null">
+        start_time_ = #{startTime},
+      </if>
+      <if test="endTime != null">
+        end_time_ = #{endTime},
+      </if>
+      <if test="createTime != null">
+        create_time_ = #{createTime},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime},
+      </if>
+    </set>
+    where id_ = #{id}
+  </update>
+
+  <!-- 全查询 -->
+  <select id="findAll" resultMap="StudentInstrument">
+    SELECT *
+    FROM student
+  </select>
+
+  <!-- 分页查询 -->
+  <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
+    SELECT * FROM student_instrument
+    <include refid="queryPageSql"/>
+    <include refid="global.limit"/>
+  </select>
+
+  <!-- 查询当前表的总记录数 -->
+  <select id="queryCount" resultType="int">
+    SELECT COUNT(*)
+    FROM student_instrument
+    <include refid="queryPageSql"/>
+  </select>
+
+  <sql id="queryPageSql">
+    <where>
+      <if test="studentId != null">
+        AND student_id_ = #{studentId}
+      </if>
+    </where>
+  </sql>
+
+</mapper>

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/StudentManageDao.xml

@@ -474,6 +474,12 @@
                     #{item}
                 </foreach>
             </if>
+            <if test="currentGrade != null">
+                AND sr.current_grade_ LIKE CONCAT('%',#{currentGrade},'%')
+            </if>
+            <if test="createYear != null">
+                AND DATE_FORMAT(sr.create_time_,'%Y') =  #{createYear}
+            </if>
         </where>
     </sql>
     <resultMap id="MusicGroupStudentsDto" type="com.ym.mec.biz.dal.dto.MusicGroupStudentsDto">

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

@@ -14,6 +14,7 @@
 		<result column="user_name_" property="userName" />
 		<result column="gender_" property="gender" />
 		<result column="current_grade_" property="currentGrade" />
+		<result column="current_grade_num_" property="currentGradeNum" />
 		<result column="current_class_" property="currentClass" />
 		<result column="subject_first_" property="subjectFirst" />
 		<result column="subject_second_" property="subjectSecond" />
@@ -46,7 +47,7 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO student_pre_registration (id_,music_group_id_,user_id_,phone_,user_name_,gender_,current_grade_,current_class_,subject_first_,subject_second_,is_allow_adjust_,kit_purchase_method_,create_time_) VALUES(#{id},#{musicGroupId},#{userId},#{phone},#{userName},#{gender},#{currentGrade},#{currentClass},#{subjectFirst},#{subjectSecond},#{isAllowAdjust},#{kitPurchaseMethod},#{createTime})
+		INSERT INTO student_pre_registration (id_,music_group_id_,user_id_,phone_,user_name_,gender_,current_grade_,current_grade_num_,current_class_,subject_first_,subject_second_,is_allow_adjust_,kit_purchase_method_,create_time_) VALUES(#{id},#{musicGroupId},#{userId},#{phone},#{userName},#{gender},#{currentGrade},#{currentGradeNum},#{currentClass},#{subjectFirst},#{subjectSecond},#{isAllowAdjust},#{kitPurchaseMethod},#{createTime})
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -67,6 +68,9 @@
 		<if test="currentGrade != null">
 		current_grade_ = #{currentGrade},
 		</if>
+		<if test="currentGradeNum != null">
+			current_grade_num_ = #{currentGradeNum},
+		</if>
 		<if test="gender != null">
 		gender_ = #{gender},
 		</if>

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

@@ -291,6 +291,12 @@
             <if test="name != null">
                 AND (sr.name_ LIKE CONCAT('%',#{name},'%') OR sr.parents_phone_ LIKE CONCAT('%',#{name},'%'))
             </if>
+            <if test="currentGrade != null">
+                AND sr.current_grade_ LIKE CONCAT('%',#{currentGrade},'%')
+            </if>
+            <if test="createYear != null">
+                AND DATE_FORMAT(sr.create_time_,'%Y') =  #{createYear}
+            </if>
         </where>
     </sql>
 
@@ -310,9 +316,10 @@
         <result column="user_id_" property="studentId"/>
         <result column="id_" property="id"/>
         <result column="remark_" property="remark"/>
+        <result column="create_time_" property="createTime"/>
     </resultMap>
     <select id="queryStudentDetailPage" resultMap="studentApplyDetail">
-        SELECT sr.id_, sr.user_id_,su.username_ username_,sr.parents_name_,sr.current_class_,sr.current_grade_,sr.current_grade_date_,
+        SELECT sr.id_,sr.create_time_, sr.user_id_,su.username_ username_,sr.parents_name_,sr.current_class_,sr.current_grade_,sr.current_grade_date_,
         su.gender_,sr.is_allow_adjust_, s.name_ subject_name_,ss.name_
         actual_subject_name_,su.phone_ parents_phone_,sr.payment_status_,sr.remark_,sr.actual_subject_id_
         FROM student_registration sr

+ 1 - 0
mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java

@@ -44,6 +44,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
                 "/contracts/queryProduceContract",
                 "/repair/studentPaymentGoodsOrder",
                 "/studentCompetition/getWinnerList",
+                "/musicGroup/getGradeList",
                 "/studentCompetition/get","/musicGroup/preRegister").permitAll().anyRequest().authenticated().and().httpBasic();
     }
 

+ 55 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentInstrumentController.java

@@ -0,0 +1,55 @@
+package com.ym.mec.student.controller;
+
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.RegisterPayDto;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.page.DegreeQueryInfo;
+import com.ym.mec.biz.dal.page.StudentInstrumentQueryInfo;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.biz.service.StudentInstrumentService;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+
+@RequestMapping("studentInstrument")
+@Api(tags = "乐器与月保服务")
+@RestController
+public class StudentInstrumentController extends BaseController {
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+
+    @ApiOperation(value = "获取乐器与月保列表")
+    @GetMapping("/getList")
+    public HttpResponseResult<PageInfo<StudentInstrument>> getList(StudentInstrumentQueryInfo queryInfo) {
+        SysUser user = sysUserFeignService.queryUserInfo();
+        if (user == null || user.getId() == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        queryInfo.setStudentId(user.getId());
+        return succeed(studentInstrumentService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "乐保支付")
+    @PostMapping("/pay")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "开通月保的乐器记录id", required = true, dataType = "int"),
+            @ApiImplicitParam(name = "amount", value = "金额", required = true, dataType = "BigDecimal"),
+            @ApiImplicitParam(name = "isUseBalance", value = "是否使用余额", required = true, dataType = "boolean")
+    })
+    public HttpResponseResult pay(Long id, BigDecimal amount, Boolean isUseBalance) throws Exception {
+        return succeed(studentInstrumentService.pay(id, amount, isUseBalance));
+    }
+}

+ 1 - 1
mec-student/src/main/resources/bootstrap-test.properties

@@ -3,7 +3,7 @@
 #\u670d\u52a1\u5668\u5730\u5740
 spring.cloud.nacos.config.server-addr=47.114.1.200:8848
 #\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
-spring.cloud.nacos.config.namespace=f753d9d9-4bb2-4df6-a483-da9e169617c4
+spring.cloud.nacos.config.namespace=f9d46b0a-9847-48ae-8e4b-216c7a3eb466
 #\u6307\u5b9a\u914d\u7f6e\u7fa4\u7ec4 --\u5982\u679c\u662fPublic\u547d\u540d\u7a7a\u95f4 \u5219\u53ef\u4ee5\u7701\u7565\u7fa4\u7ec4\u914d\u7f6e
 spring.cloud.nacos.config.group=DEFAULT_GROUP
 #\u6587\u4ef6\u540d -- \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u5219\u9ed8\u8ba4\u4e3a ${spring.appliction.name}

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

@@ -2,7 +2,9 @@ package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.dal.dto.CloseMusicGroupDto;
 import com.ym.mec.biz.dal.dto.MusicGroupRegsDto;
+import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.service.OrganizationService;
 import com.ym.mec.common.entity.HttpResponseResult;
 
 import io.swagger.annotations.Api;
@@ -10,10 +12,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -48,6 +47,8 @@ public class MusicGroupController extends BaseController {
 	private SysUserFeignService sysUserFeignService;
 	@Autowired
 	private EmployeeDao employeeDao;
+	@Autowired
+	private OrganizationService organizationService;
 
 	@ApiOperation(value = "修改乐团基本信息")
 	@PostMapping("/update")
@@ -321,4 +322,13 @@ public class MusicGroupController extends BaseController {
 		return musicGroupService.sendParentMeetingNotice(sysUser.getId(), musicGroupId, meetingDate, address) ? succeed() : failed();
 	}
 
+	@ApiOperation(value = "获取乐团的年级列表")
+	@GetMapping("/getGradeList")
+	@PreAuthorize("@pcs.hasPermissions('musicGroup/getGradeList')")
+	@ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团编号", required = true, dataType = "String")})
+	public HttpResponseResult<Map<Integer,String>> getGradeList(String musicGroupId) {
+		MusicGroup musicGroup = musicGroupService.get(musicGroupId);
+		return succeed(organizationService.getGradeList(musicGroup.getOrganId()));
+	}
+
 }

+ 11 - 0
mec-web/src/main/java/com/ym/mec/web/controller/OrganizationController.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.page.OrganizationQueryInfo;
 import com.ym.mec.biz.service.OrganizationService;
 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 io.swagger.annotations.ApiParam;
@@ -14,6 +15,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
+import java.util.Map;
 
 @RequestMapping("organization")
 @Api(tags = "分部服务")
@@ -72,4 +74,13 @@ public class OrganizationController extends BaseController {
     public Object get( @PathVariable("id") Integer id){
         return succeed(organizationService.get(id));
     }
+
+
+    @ApiOperation(value = "获取用户所在分部的年级列表)")
+    @GetMapping("organization/getGradeList")
+    @PreAuthorize("@pcs.hasPermissions('organization/getGradeList')")
+    @ApiParam(value = "分部编号", required = true)
+    public HttpResponseResult<Map<Integer,String>> getGradeList(Integer id) {
+        return succeed(organizationService.getGradeList(id));
+    }
 }