Przeglądaj źródła

Merge branch 'maintenance_feature' into test

# Conflicts:
#	mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java
周箭河 4 lat temu
rodzic
commit
dde08e00aa

+ 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;
+    }
 }

+ 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;
+    }
+}

+ 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;

+ 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;
+    }
+}

+ 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;
 
     /**
      * 查询用户指定乐团的报名信息

+ 51 - 191
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -274,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());
         }
         // 保存乐团付费主体列表
         //批量新增
@@ -646,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;
@@ -657,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("乐器提供方式不存在,请核查");
+                }
+                if (!kitGroupPurchaseType.equals("GROUP")) {
+                    goodsGroup.setPrice(kitGroupPurchaseType.equals("FREE") ? new BigDecimal(0) : goodsGroup.getDepositFee());
+                } else {
+                    remitCourseRFeeFlag = goodsGroup.getGroupRemissionCourseFee().equals(1);
                 }
-                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);
+                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<>();
@@ -766,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("商品价格不符");
@@ -778,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();
@@ -866,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;
@@ -878,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("乐器提供方式不存在,请核查");
+                }
+                if (!kitGroupPurchaseType.equals("GROUP")) {
+                    goodsGroup.setPrice(kitGroupPurchaseType.equals("FREE") ? new BigDecimal(0) : goodsGroup.getDepositFee());
+                } else {
+                    remitCourseRFeeFlag = goodsGroup.getGroupRemissionCourseFee().equals(1);
                 }
-                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);
+                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()));
         }
 
         //新课程形态
@@ -987,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("商品价格不符");
         }
@@ -999,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();
 
@@ -1139,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());
 
     }
 
@@ -1245,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());
 
     }
 
@@ -1304,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());
@@ -2168,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;
+    }
+}

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

@@ -359,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());
@@ -408,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) {
@@ -466,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);
 
         //增加缴费学生数
@@ -496,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);
@@ -551,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) {
@@ -609,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;

+ 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>

+ 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}