Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

Joburgess 4 лет назад
Родитель
Сommit
5c97c250fc
32 измененных файлов с 1634 добавлено и 538 удалено
  1. 17 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java
  2. 2 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java
  3. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentInstrumentDao.java
  4. 40 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MaintenancePayDto.java
  5. 14 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java
  6. 33 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RepairGoodsDto.java
  7. 238 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentInstrument.java
  8. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrderDetail.java
  9. 117 46
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentRepair.java
  10. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GroupType.java
  11. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java
  12. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java
  13. 25 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/RepairStudentQueryInfo.java
  14. 101 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentInstrumentQueryInfo.java
  15. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentGoodsSellService.java
  16. 41 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentInstrumentService.java
  17. 10 6
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java
  18. 47 185
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  19. 112 69
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java
  20. 301 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java
  21. 0 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java
  22. 5 10
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  23. 84 172
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  24. 34 13
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  25. 16 1
      mec-biz/src/main/resources/config/mybatis/GoodsMapper.xml
  26. 160 0
      mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml
  27. 3 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml
  28. 17 9
      mec-biz/src/main/resources/config/mybatis/StudentRepairMapper.xml
  29. 56 0
      mec-student/src/main/java/com/ym/mec/student/controller/StudentInstrumentController.java
  30. 10 10
      mec-web/src/main/java/com/ym/mec/web/controller/SporadicChargeInfoController.java
  31. 87 0
      mec-web/src/main/java/com/ym/mec/web/controller/StudentInstrumentController.java
  32. 13 4
      mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java

@@ -130,6 +130,7 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
 
     /**
      * 获取乐团的商品
+     *
      * @return
      */
     List<MusicGroupGoodsAndDiscountDto> getMusicGroupGoodsAndDiscount(@Param("subjectId") Integer subjectId, @Param("type") String type);
@@ -138,9 +139,25 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
 
     /**
      * 是否存在已上架的商品编号
+     *
      * @param goodsId
      * @param status
      * @return
      */
     Boolean findByIdAndStatus(@Param("goodsId") String goodsId, @Param("status") int status);
+
+    /**
+     * 获取
+     *
+     * @param id
+     * @return
+     */
+    Goods getGoodsInfo(@Param("id") Integer id);
+
+    /**
+     * 根据id获取商品和分类
+     * @param goodsIds
+     * @return
+     */
+    List<Goods> getGoodiesAndCate(@Param("goodsIds") List<Integer> goodsIds);
 }

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

@@ -139,10 +139,6 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
                                                 @Param("groupType")GroupType groupType,
                                                 @Param("courseStatus") CourseStatusEnum courseStatus);
 
-    List<IndexBaseMonthData> getGroupCourseDataWithGroup(@Param("dayStr") String dayStr,
-                                                @Param("groupType")GroupType groupType,
-                                                @Param("courseStatus") CourseStatusEnum courseStatus);
-
     int countLessThenThreeClassGroupNum(@Param("organIds") Set<Integer> organIds);
     List<String> getLessThenThreeMusicGroup(@Param("organIds") Set<Integer> organIds);
 
@@ -162,14 +158,14 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
      * @param organIds
      * @return
      */
-    int getAttendanceError(@Param("organIds") Set<Integer> organIds,@Param("startTime") String startTime);
+    int getAttendanceError(@Param("organIds") String organIds,@Param("startTime") String startTime);
 
     /**
      * 获取旷课考勤
      * @param organIds
      * @return
      */
-    int getNoAttendance(@Param("organIds") Set<Integer> organIds, @Param("startTime") String startTime);
+    int getNoAttendance(@Param("organIds") String organIds, @Param("startTime") String startTime);
 
     /**
      * 获取老师离职申请数

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

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface StudentInstrumentDao extends BaseDAO<Long, StudentInstrument> {
+
+    /**
+     * 批量添加
+     * @param studentInstruments
+     * @return
+     */
+    int batchAdd(@Param("studentInstruments") List<StudentInstrument> studentInstruments);
+
+    /**
+     * 批量修改
+     * @return
+     */
+    int batchUpdate();
+}

+ 40 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MaintenancePayDto.java

@@ -0,0 +1,40 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
+public class MaintenancePayDto {
+    @ApiModelProperty(value = "乐器列表id", required = true)
+    private Long id;
+
+    @ApiModelProperty(value = "支付金额", required = true)
+    private BigDecimal amount;
+
+    @ApiModelProperty(value = "是否使用余额", required = true)
+    private Boolean isUseBalance = false;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public Boolean getUseBalance() {
+        return isUseBalance;
+    }
+
+    public void setUseBalance(Boolean useBalance) {
+        isUseBalance = useBalance;
+    }
+}

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

+ 33 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RepairGoodsDto.java

@@ -18,6 +18,15 @@ public class RepairGoodsDto {
     @ApiModelProperty(value = "商品编号", required = true)
     private Integer id;
 
+    @ApiModelProperty(value = "品牌", required = true)
+    private String brand;
+
+    @ApiModelProperty(value = "原价", required = true)
+    private BigDecimal marketPrice;
+
+    @ApiModelProperty(value = "型号", required = true)
+    private String specification;
+
     public BigDecimal getGroupPurchasePrice() {
         return groupPurchasePrice;
     }
@@ -49,4 +58,28 @@ public class RepairGoodsDto {
     public void setId(Integer id) {
         this.id = id;
     }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public BigDecimal getMarketPrice() {
+        return marketPrice;
+    }
+
+    public void setMarketPrice(BigDecimal marketPrice) {
+        this.marketPrice = marketPrice;
+    }
+
+    public String getSpecification() {
+        return specification;
+    }
+
+    public void setSpecification(String specification) {
+        this.specification = specification;
+    }
 }

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

@@ -0,0 +1,238 @@
+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;
+
+    /**
+     * 分类id
+     */
+    @ApiModelProperty(value = "商品分类id")
+    private Integer goodsCategoryId;
+
+    /**
+     * 分类id
+     */
+    @ApiModelProperty(value = "商品分类名称")
+    private String goodsCategoryName;
+
+    /**
+     * 是否乐保 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;
+
+    @ApiModelProperty(value = "学生姓名")
+    private String studentName;
+
+    @ApiModelProperty(value = "联系电话")
+    private String phone;
+
+    @ApiModelProperty(value = "分部")
+    private String organName;
+
+    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;
+    }
+
+    public String getStudentName() {
+        return studentName;
+    }
+
+    public void setStudentName(String studentName) {
+        this.studentName = studentName;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public Integer getGoodsCategoryId() {
+        return goodsCategoryId;
+    }
+
+    public void setGoodsCategoryId(Integer goodsCategoryId) {
+        this.goodsCategoryId = goodsCategoryId;
+    }
+
+    public String getGoodsCategoryName() {
+        return goodsCategoryName;
+    }
+
+    public void setGoodsCategoryName(String goodsCategoryName) {
+        this.goodsCategoryName = goodsCategoryName;
+    }
+}

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

@@ -51,6 +51,9 @@ public class StudentPaymentOrderDetail {
 	//减免费用
 	private BigDecimal remitFee;
 
+	//学生乐器id
+	private Long studentInstrumentId;
+
 	@ApiModelProperty(value = "子商品列表",required = false)
 	private List<Goods> childGoodsList;
 
@@ -154,4 +157,12 @@ public class StudentPaymentOrderDetail {
 	public void setChildGoodsList(List<Goods> childGoodsList) {
 		this.childGoodsList = childGoodsList;
 	}
+
+	public Long getStudentInstrumentId() {
+		return studentInstrumentId;
+	}
+
+	public void setStudentInstrumentId(Long studentInstrumentId) {
+		this.studentInstrumentId = studentInstrumentId;
+	}
 }

+ 117 - 46
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentRepair.java

@@ -9,14 +9,45 @@ import java.util.Date;
 public class StudentRepair {
     private Integer id;
     /**
-    * 维修单号
-    */
+     * 维修单号
+     */
     @ApiModelProperty(value = "维修单号", required = false)
     private String transNo;
 
     /**
-    * 分部id
-    */
+     * 学员乐器id
+     */
+    @ApiModelProperty(value = "学员乐器id", required = false)
+    private Long studentInstrumentId;
+
+    /**
+     * 学员乐器id
+     */
+    @ApiModelProperty(value = "乐保状态0-无 1-有", required = false)
+    private Integer maintenanceStatus = 0;
+
+    /**
+     * 维修单名称
+     */
+    @ApiModelProperty(value = "维修单名称", required = false)
+    private String repairName;
+
+
+    /**
+     * 维修单名称
+     */
+    @ApiModelProperty(value = "维修图片", required = false)
+    private String repairImg;
+
+    /**
+     * 特权减免金额
+     */
+    @ApiModelProperty(value = "特权减免金额", required = false)
+    private BigDecimal exemptionAmount = BigDecimal.ZERO;
+
+    /**
+     * 分部id
+     */
     @ApiModelProperty(value = "分部id", required = false)
     private Integer organId;
 
@@ -28,32 +59,32 @@ public class StudentRepair {
 
 
     /**
-    * 分部名称
-    */
+     * 分部名称
+     */
     @ApiModelProperty(value = "分部名称", required = false)
     private String organName;
 
     /**
-    * 学生id
-    */
+     * 学生id
+     */
     @ApiModelProperty(value = "学生id", required = true)
     private Integer studentId;
 
     /**
-    * 学生姓名
-    */
+     * 学生姓名
+     */
     @ApiModelProperty(value = "学生姓名", required = false)
     private String studentName;
 
     /**
-    * 学生学校
-    */
+     * 学生学校
+     */
     @ApiModelProperty(value = "学生学校", required = false)
     private String studentSchool;
 
     /**
-    * 技师id
-    */
+     * 技师id
+     */
     @ApiModelProperty(value = "技师id", required = false)
     private Integer employeeId;
 
@@ -76,26 +107,26 @@ public class StudentRepair {
     private String employeeAddress;
 
     /**
-    * 乐器类型id
-    */
+     * 乐器类型id
+     */
     @ApiModelProperty(value = "乐器类型id", required = false)
     private Integer subjectId;
 
     /**
-    * 乐器类型名称
-    */
+     * 乐器类型名称
+     */
     @ApiModelProperty(value = "乐器类型名称", required = false)
     private String subjectName;
 
     /**
-    * 维修类型 0-线下 1-线上
-    */
+     * 维修类型 0-线下 1-线上
+     */
     @ApiModelProperty(value = "维修类型 0-线下 1-线上", required = false)
     private Integer type;
 
     /**
-    * 乐器编号
-    */
+     * 乐器编号
+     */
     @ApiModelProperty(value = "乐器编号", required = false)
     private String instrumentNo;
 
@@ -106,62 +137,62 @@ public class StudentRepair {
     private String feeList;
 
     /**
-    * 问题描述及解决方法
-    */
+     * 问题描述及解决方法
+     */
     @ApiModelProperty(value = "问题描述及解决方法", required = false)
     private String description;
 
     /**
-    * 维修金额
-    */
+     * 维修金额
+     */
     @ApiModelProperty(value = "维修金额", required = false)
     private BigDecimal amount;
 
     /**
-    * 维修完成时间
-    */
+     * 维修完成时间
+     */
     @ApiModelProperty(value = "维修完成时间", required = false)
     private Date finishTime;
 
     /**
-    * 乐器取回方式 0-自取 1-快递
-    */
+     * 乐器取回方式 0-自取 1-快递
+     */
     @ApiModelProperty(value = "乐器取回方式 0-自取 1-快递", required = false)
     private Integer sendType;
 
     /**
-    * 联系人
-    */
+     * 联系人
+     */
     @ApiModelProperty(value = "联系人", required = false)
     private String contactName;
 
     /**
-    * 联系方式
-    */
+     * 联系方式
+     */
     @ApiModelProperty(value = "联系方式", required = false)
     private String contactMobile;
 
     /**
-    * 快递地址
-    */
+     * 快递地址
+     */
     @ApiModelProperty(value = "快递地址", required = false)
     private String address;
 
     /**
-    * 所选商品
-    */
+     * 所选商品
+     */
     @ApiModelProperty(value = "商品", required = false)
     private String goodsJson;
 
     /**
-    * 支付状态 0-未支付 1-支付中 2-已支付
-    */
+     * 支付状态 0-未支付 1-支付中 2-已支付
+     */
     @ApiModelProperty(value = "支付状态 0-未支付 1-支付中 2-已支付", required = false)
     private Integer payStatus;
 
     /**
-    * 维修状态 0维修中,1已完成
-    */
+     * 维修状态 0维修中,1已完成
+     */
     @ApiModelProperty(value = "维修状态 0维修中,1已完成", required = false)
     private Integer repairStatus;
 
@@ -172,14 +203,14 @@ public class StudentRepair {
     private Boolean isUseBalancePayment;
 
     /**
-    * 送修时间
-    */
+     * 送修时间
+     */
     @ApiModelProperty(value = "送修时间", required = true)
     private Date createTime;
 
     /**
-    * 更新时间
-    */
+     * 更新时间
+     */
     @ApiModelProperty(value = "更新时间", required = false)
     private Date updateTime;
 
@@ -427,4 +458,44 @@ public class StudentRepair {
     public void setMusicGroupId(String musicGroupId) {
         this.musicGroupId = musicGroupId;
     }
+
+    public Long getStudentInstrumentId() {
+        return studentInstrumentId;
+    }
+
+    public void setStudentInstrumentId(Long studentInstrumentId) {
+        this.studentInstrumentId = studentInstrumentId;
+    }
+
+    public String getRepairName() {
+        return repairName;
+    }
+
+    public void setRepairName(String repairName) {
+        this.repairName = repairName;
+    }
+
+    public BigDecimal getExemptionAmount() {
+        return exemptionAmount;
+    }
+
+    public void setExemptionAmount(BigDecimal exemptionAmount) {
+        this.exemptionAmount = exemptionAmount;
+    }
+
+    public Integer getMaintenanceStatus() {
+        return maintenanceStatus;
+    }
+
+    public void setMaintenanceStatus(Integer maintenanceStatus) {
+        this.maintenanceStatus = maintenanceStatus;
+    }
+
+    public String getRepairImg() {
+        return repairImg;
+    }
+
+    public void setRepairImg(String repairImg) {
+        this.repairImg = repairImg;
+    }
 }

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

+ 25 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/RepairStudentQueryInfo.java

@@ -1,7 +1,9 @@
 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 RepairStudentQueryInfo extends QueryInfo {
@@ -26,6 +28,13 @@ public class RepairStudentQueryInfo extends QueryInfo {
 
     private Integer payStatus;
 
+    @ApiModelProperty(value = "乐器列表id",required = false)
+    private Long studentInstrumentId;
+
+    @ApiModelProperty(value = "特权减免金额",required = false)
+    private BigDecimal exemptionAmount;
+
+
     public Integer getSubjectId() {
         return subjectId;
     }
@@ -97,4 +106,20 @@ public class RepairStudentQueryInfo extends QueryInfo {
     public void setPayStatus(Integer payStatus) {
         this.payStatus = payStatus;
     }
+
+    public Long getStudentInstrumentId() {
+        return studentInstrumentId;
+    }
+
+    public void setStudentInstrumentId(Long studentInstrumentId) {
+        this.studentInstrumentId = studentInstrumentId;
+    }
+
+    public BigDecimal getExemptionAmount() {
+        return exemptionAmount;
+    }
+
+    public void setExemptionAmount(BigDecimal exemptionAmount) {
+        this.exemptionAmount = exemptionAmount;
+    }
 }

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

@@ -0,0 +1,101 @@
+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;
+
+    @ApiModelProperty(value = "分部ids", required = true)
+    private String organId;
+
+    /**
+     * 商品id
+     */
+    @ApiModelProperty(value = "商品id")
+    private Integer goodsId;
+
+    /**
+     * 分类id
+     */
+    @ApiModelProperty(value = "商品分类id")
+    private Integer goodsCategoryId;
+
+
+    @ApiModelProperty(value = "乐器品牌")
+    private String goodsBrand;
+
+    @ApiModelProperty(value = "乐器规格")
+    private String specification;
+
+    /**
+     * 是否乐保 0-不是 1-是
+     */
+    @ApiModelProperty(value = "是否乐保 0-不是 1-是")
+    private Integer status;
+
+
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
+
+    public Integer getGoodsId() {
+        return goodsId;
+    }
+
+    public void setGoodsId(Integer goodsId) {
+        this.goodsId = goodsId;
+    }
+
+    public Integer getGoodsCategoryId() {
+        return goodsCategoryId;
+    }
+
+    public void setGoodsCategoryId(Integer goodsCategoryId) {
+        this.goodsCategoryId = goodsCategoryId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    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;
+    }
+}

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

@@ -4,10 +4,13 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
 import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
 import com.ym.mec.biz.dal.page.GoodsSellQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface StudentGoodsSellService extends BaseService<Integer, StudentGoodsSell> {
 
     /**
@@ -42,4 +45,12 @@ public interface StudentGoodsSellService extends BaseService<Integer, StudentGoo
      * @return com.ym.mec.common.page.PageInfo<com.ym.mec.biz.dal.dto.StudentGoodsSellDto>
      */
     PageInfo<StudentPaymentOrderDto> queryStudentPaymentOrders(GoodsSellQueryInfo queryInfo);
+
+
+    /**
+     * 将购买的乐器加入学生乐器列表
+     * @return
+     */
+    List<StudentInstrument> saveStudentInstrument(String orderNo);
+
 }

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

@@ -0,0 +1,41 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.dto.MaintenancePayDto;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.common.service.BaseService;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+public interface StudentInstrumentService extends BaseService<Long, StudentInstrument> {
+
+    /**
+     * 乐保支付
+     */
+    Map pay(MaintenancePayDto maintenancePayDto) throws Exception;
+
+    /**
+     * 回调页面
+     *
+     * @param studentPaymentOrder
+     * @return
+     */
+    Boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
+
+    /**
+     * 添加学生乐器
+     * @param studentInstrument
+     * @return
+     */
+    StudentInstrument addStudentInstrument(StudentInstrument studentInstrument);
+
+
+    /**
+     * 将订单详情乐器加入学生乐器列表
+     * @param order
+     * @return
+     */
+    Boolean addOrderDetail2Instrument(StudentPaymentOrder order);
+}

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

+ 47 - 185
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -647,9 +647,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;
@@ -658,102 +655,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<>();
@@ -767,6 +693,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 orderAmount = orderAmount.add(calenderCourseSetting.getCourseCurrentPrice());
             }
         }
+        //乐器保养
+        if(registerPayDto.getBuyMaintenance()){
+            BigDecimal maintenancePrice = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
+            orderAmount = orderAmount.add(maintenancePrice);
+        }
 
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
@@ -779,7 +710,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();
@@ -867,9 +798,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;
@@ -879,100 +807,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()));
         }
 
         //新课程形态
@@ -988,6 +845,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
         }
 
+        if(registerPayDto.getBuyMaintenance()){
+            BigDecimal maintenancePrice = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
+            orderAmount = orderAmount.add(maintenancePrice);
+        }
+
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
         }
@@ -1000,7 +862,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();
 

+ 112 - 69
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java

@@ -1,11 +1,17 @@
 package com.ym.mec.biz.service.impl;
 
 
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.biz.dal.dao.GoodsDao;
 import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderDto;
+import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
 import com.ym.mec.biz.dal.page.GoodsSellQueryInfo;
 import com.ym.mec.biz.service.StudentGoodsSellService;
 import com.ym.mec.common.dal.BaseDAO;
@@ -25,78 +31,115 @@ import java.util.Map;
 
 @Service
 public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, StudentGoodsSell> implements StudentGoodsSellService {
-	
-	@Autowired
-	private StudentGoodsSellDao studentGoodsSellDao;
-	@Autowired
-	private SysConfigDao sysConfigDao;
 
-	@Override
-	public BaseDAO<Integer, StudentGoodsSell> getDAO() {
-		return studentGoodsSellDao;
-	}
+    @Autowired
+    private StudentGoodsSellDao studentGoodsSellDao;
+    @Autowired
+    private SysConfigDao sysConfigDao;
+    @Autowired
+    private GoodsDao goodsDao;
+    @Autowired
+    private StudentInstrumentDao studentInstrumentDao;
 
-	@Override
-	public PageInfo<StudentGoodsSellDto> queryStudentGoodsOrders(GoodsSellQueryInfo queryInfo) {
-		//根据订单状态和教务老师获取订单列表
-		PageInfo<StudentGoodsSellDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
-		Map<String, Object> params = new HashMap<>();
-		MapUtil.populateMap(params, queryInfo);
-		List<StudentGoodsSellDto> dataList = null;
-		int count = studentGoodsSellDao.countStudentGoodsOrders(params);
-		if (count > 0) {
-			pageInfo.setTotal(count);
-			params.put("offset", pageInfo.getOffset());
-			dataList = studentGoodsSellDao.queryStudentGoodsOrders(params);
-			Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
-			dataList.forEach(e->{
-				e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
-			});
-		}
-		if (count == 0) {
-			dataList = new ArrayList<>();
-		}
-		pageInfo.setRows(dataList);
-		return pageInfo;
-	}
+    @Override
+    public BaseDAO<Integer, StudentGoodsSell> getDAO() {
+        return studentGoodsSellDao;
+    }
 
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void affirmReceive(String orderNo) {
-		String str = "MANUAL_RECEIVE";
-		//如果订单编号为空,那么自动确认
-		if(StringUtils.isEmpty(orderNo)){
-			String autoAffirmReceiveTime = sysConfigDao.findConfigValue("auto_affirm_receive_time");
-			//获取到期的订单编号
-			orderNo = studentGoodsSellDao.queryNoAffirmOrderNo(autoAffirmReceiveTime);
-			str = "AUTO_RECEIVE";
-		}
-		if(StringUtils.isNotEmpty(orderNo)){
-			studentGoodsSellDao.autoAffirmReceive(orderNo,str);
-		}
-	}
+    @Override
+    public PageInfo<StudentGoodsSellDto> queryStudentGoodsOrders(GoodsSellQueryInfo queryInfo) {
+        //根据订单状态和教务老师获取订单列表
+        PageInfo<StudentGoodsSellDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+        List<StudentGoodsSellDto> dataList = null;
+        int count = studentGoodsSellDao.countStudentGoodsOrders(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = studentGoodsSellDao.queryStudentGoodsOrders(params);
+            Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
+            dataList.forEach(e -> {
+                e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
+            });
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void affirmReceive(String orderNo) {
+        String str = "MANUAL_RECEIVE";
+        //如果订单编号为空,那么自动确认
+        if (StringUtils.isEmpty(orderNo)) {
+            String autoAffirmReceiveTime = sysConfigDao.findConfigValue("auto_affirm_receive_time");
+            //获取到期的订单编号
+            orderNo = studentGoodsSellDao.queryNoAffirmOrderNo(autoAffirmReceiveTime);
+            str = "AUTO_RECEIVE";
+        }
+        if (StringUtils.isNotEmpty(orderNo)) {
+            studentGoodsSellDao.autoAffirmReceive(orderNo, str);
+        }
+    }
+
+    @Override
+    public PageInfo<StudentPaymentOrderDto> queryStudentPaymentOrders(GoodsSellQueryInfo queryInfo) {
+        PageInfo<StudentPaymentOrderDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+        List<StudentPaymentOrderDto> dataList = null;
+        int count = studentGoodsSellDao.countStudentPaymentOrders(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = studentGoodsSellDao.queryStudentPaymentOrders(params);
+            Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
+            dataList.forEach(e -> {
+                e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
+            });
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
+    @Override
+    public List<StudentInstrument> saveStudentInstrument(String orderNo) {
+        StudentGoodsSell studentGoodsSell = studentGoodsSellDao.findByOrderNo(orderNo);
+        List<GoodsSellDto> goodsSellDtos = JSONObject.parseArray(studentGoodsSell.getGoodsJson(), GoodsSellDto.class);
+        List<Integer> goodsIds = new ArrayList<>();
+        for (GoodsSellDto goodsSellDto : goodsSellDtos) {
+            if (!goodsSellDto.getGoodsType().equals("INSTRUMENT")) continue;
+            goodsIds.add(goodsSellDto.getGoodsId());
+        }
+        if (goodsIds.size() <= 0) {
+            return null;
+        }
+        List<Goods> goodies = goodsDao.getGoodiesAndCate(goodsIds);
+        List<StudentInstrument> studentInstruments = new ArrayList<>();
+        for (Goods goods : goodies) {
+            StudentInstrument studentInstrument = new StudentInstrument();
+            studentInstrument.setStudentId(studentGoodsSell.getUserId());
+            studentInstrument.setOrganId(studentGoodsSell.getOrganId());
+            studentInstrument.setGoodsId(goods.getId());
+            studentInstrument.setGoodsCategoryId(goods.getGoodsCategoryId());
+            studentInstrument.setGoodsCategoryName(goods.getGoodsCategoryName());
+            studentInstrument.setGoodsName(goods.getName());
+            studentInstrument.setGoodsBrand(goods.getBrand());
+            studentInstrument.setSpecification(goods.getSpecification());
+            studentInstrument.setGoodsImg(goods.getImage());
+            studentInstrument.setStatus(0);
+            studentInstruments.add(studentInstrument);
+        }
+        studentInstrumentDao.batchAdd(studentInstruments);
+        return studentInstruments;
+    }
 
-	@Override
-	public PageInfo<StudentPaymentOrderDto> queryStudentPaymentOrders(GoodsSellQueryInfo queryInfo) {
-		PageInfo<StudentPaymentOrderDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
-		Map<String, Object> params = new HashMap<>();
-		MapUtil.populateMap(params, queryInfo);
-		List<StudentPaymentOrderDto> dataList = null;
-		int count = studentGoodsSellDao.countStudentPaymentOrders(params);
-		if (count > 0) {
-			pageInfo.setTotal(count);
-			params.put("offset", pageInfo.getOffset());
-			dataList = studentGoodsSellDao.queryStudentPaymentOrders(params);
-			Integer autoAffirmReceiveTime = Integer.parseInt(sysConfigDao.findConfigValue("auto_affirm_receive_time"));
-			dataList.forEach(e->{
-				e.setAutoAffirmReceiveTime(autoAffirmReceiveTime);
-			});
-		}
-		if (count == 0) {
-			dataList = new ArrayList<>();
-		}
-		pageInfo.setRows(dataList);
-		return pageInfo;
-	}
 
 }

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

@@ -0,0 +1,301 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dto.MaintenancePayDto;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.service.*;
+import com.ym.mec.common.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 com.ym.mec.thirdparty.message.MessageSenderPluginContext;
+import com.ym.mec.util.date.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@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 ContractService contractService;
+    @Autowired
+    private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+    @Autowired
+    private SysMessageService sysMessageService;
+    @Autowired
+    private GoodsService goodsService;
+    @Autowired
+    private GoodsCategoryService goodsCategoryService;
+    @Autowired
+    private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Override
+    public BaseDAO<Long, StudentInstrument> getDAO() {
+        return studentInstrumentDao;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map pay(MaintenancePayDto maintenancePayDto) throws Exception {
+        StudentInstrument studentInstrument = studentInstrumentDao.get(maintenancePayDto.getId());
+        if (studentInstrument == null) {
+            throw new BizException("所选乐器不存在,请核查");
+        }
+        Integer userId = studentInstrument.getStudentId();
+        BigDecimal orderAmount = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
+        BigDecimal amount = maintenancePayDto.getAmount(); //扣除余额之前的金额
+        if (amount.compareTo(orderAmount) != 0) {
+            throw new BizException("商品价格不符");
+        }
+
+        String channelType = "";
+        Date date = new Date();
+
+        BigDecimal balance = BigDecimal.ZERO;
+        if (maintenancePayDto.getUseBalance() && 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, "乐保购买");
+            }
+        }
+
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+
+        studentPaymentOrder.setPaymentChannel("BALANCE");
+        studentPaymentOrder.setUserId(userId);
+        studentPaymentOrder.setGroupType(GroupType.MAINTENANCE);
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setType(OrderTypeEnum.MAINTENANCE);
+        studentPaymentOrder.setExpectAmount(orderAmount);
+        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;
+    }
+
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean orderCallback(StudentPaymentOrder studentPaymentOrder) {
+        Date nowDate = new Date();
+        //更新订单信息
+        studentPaymentOrder.setUpdateTime(nowDate);
+        int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
+        if (updateCount <= 0) {
+            throw new BizException("订单更新失败");
+        }
+        //更新维修单信息
+        StudentInstrument studentInstrument = get(Long.parseLong(studentPaymentOrder.getMusicGroupId()));
+        if (studentInstrument == null) {
+            throw new BizException("乐保信息不存在");
+        }
+
+        Integer userId = studentPaymentOrder.getUserId();
+
+        Map<Integer, String> map = new HashMap<>();
+        map.put(userId, userId.toString());
+
+        //支付成功
+        if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
+            try {
+                contractService.transferProduceContract(userId, null);
+            } catch (Exception e) {
+                logger.error("产品协议生成失败", e);
+            }
+            Date startTime = nowDate;
+            Date endTime = DateUtil.addYears(nowDate, 1);
+            if (studentInstrument.getEndTime() != null &&
+                    studentInstrument.getEndTime().compareTo(nowDate) >= 0) {
+                startTime = studentInstrument.getStartTime();
+                endTime = DateUtil.addYears(studentInstrument.getEndTime(), 1);
+            }
+            studentInstrument.setStartTime(startTime);
+            studentInstrument.setEndTime(endTime);
+            studentInstrument.setStatus(1);
+            if (this.update(studentInstrument) <= 0) {
+                throw new BizException("乐保信息更新失败");
+            }
+
+            //插入交易明细
+            BigDecimal amount = studentPaymentOrder.getActualAmount();
+            if (amount.compareTo(BigDecimal.ZERO) > 0) {
+                SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
+                //充值
+                SysUserCashAccountDetail rechargeDetail = new SysUserCashAccountDetail();
+                rechargeDetail.setAmount(amount);
+                rechargeDetail.setBalance(cashAccount.getBalance().add(amount));
+                rechargeDetail.setComment("缴费前充值");
+                rechargeDetail.setCreateTime(nowDate);
+                rechargeDetail.setStatus(DealStatusEnum.SUCCESS);
+                rechargeDetail.setTransNo(studentPaymentOrder.getTransNo());
+                rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
+                rechargeDetail.setUpdateTime(nowDate);
+                rechargeDetail.setUserId(userId);
+                rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+                rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
+                rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+                sysUserCashAccountDetailService.insert(rechargeDetail);
+
+                //缴费
+                SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
+                paymentDetail.setAmount(amount.negate());
+                paymentDetail.setBalance(cashAccount.getBalance());
+                paymentDetail.setComment("乐保购买");
+                paymentDetail.setCreateTime(nowDate);
+                paymentDetail.setStatus(DealStatusEnum.SUCCESS);
+                paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
+                paymentDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
+                paymentDetail.setUpdateTime(nowDate);
+                paymentDetail.setUserId(userId);
+                rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+                sysUserCashAccountDetailService.insert(paymentDetail);
+            }
+
+            return true;
+        }
+
+        if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
+
+            if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
+                sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐保购买支付失败");
+            }
+
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SMS_SPORADIC_PAYMENT_FAILED, map, null, 0, "", "STUDENT",
+                    studentPaymentOrder.getActualAmount(), "乐保购买");
+            return false;
+        }
+        return false;
+    }
+
+    @Override
+    public StudentInstrument addStudentInstrument(StudentInstrument studentInstrument) {
+        Goods goods = goodsService.get(studentInstrument.getGoodsId());
+        GoodsCategory goodsCategory = goodsCategoryService.get(goods.getGoodsCategoryId());
+        studentInstrument.setGoodsCategoryId(goods.getGoodsCategoryId());
+        studentInstrument.setGoodsCategoryName(goodsCategory.getName());
+        studentInstrument.setGoodsName(goods.getName());
+        studentInstrument.setGoodsBrand(goods.getBrand());
+        studentInstrument.setSpecification(goods.getSpecification());
+        studentInstrument.setGoodsImg(goods.getImage());
+        studentInstrumentDao.insert(studentInstrument);
+        return studentInstrument;
+    }
+
+    @Override
+    public Boolean addOrderDetail2Instrument(StudentPaymentOrder order) {
+        List<OrderDetailTypeEnum> orderDetailTypes = new ArrayList<>();
+        orderDetailTypes.add(OrderDetailTypeEnum.MAINTENANCE);
+        orderDetailTypes.add(OrderDetailTypeEnum.MUSICAL);
+        List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailDao.getOrderDetailByType(order.getId(), orderDetailTypes);
+        List<StudentPaymentOrderDetail> orderDetails4Instruments = orderDetails.stream()
+                .filter(e -> e.getType().equals(OrderDetailTypeEnum.MUSICAL))
+                .filter(e -> KitGroupPurchaseTypeEnum.GROUP.equals(e.getKitGroupPurchaseType())).collect(Collectors.toList());
+        if (orderDetails4Instruments.size() <= 0) {
+            return false;
+        }
+        List<StudentPaymentOrderDetail> orderDetails4Maintenance = orderDetails.stream()
+                .filter(e -> e.getType().equals(OrderDetailTypeEnum.MAINTENANCE)).collect(Collectors.toList());
+
+        StudentPaymentOrderDetail maintenanceDetail = null;
+        int maintenanceStatus = 0;
+        Date startTime = null;
+        Date endTime = null;
+        if (orderDetails4Maintenance.size() > 0) {
+            maintenanceDetail = orderDetails4Maintenance.get(0);
+            maintenanceStatus = 1;
+            startTime = new Date();
+            endTime = DateUtil.addYears(startTime, 1);
+        }
+
+        Integer goodsId = Integer.valueOf(orderDetails4Instruments.get(0).getGoodsIdList());
+        StudentInstrument studentInstrument = new StudentInstrument();
+        studentInstrument.setStudentId(order.getUserId());
+        studentInstrument.setOrganId(order.getOrganId());
+        studentInstrument.setGoodsId(goodsId);
+        studentInstrument.setStatus(maintenanceStatus);
+        studentInstrument.setStartTime(startTime);
+        studentInstrument.setEndTime(endTime);
+        addStudentInstrument(studentInstrument);
+        if (maintenanceDetail != null) {
+            maintenanceDetail.setStudentInstrumentId(studentInstrument.getId());
+            studentPaymentOrderDetailDao.update(maintenanceDetail);
+        }
+        return true;
+    }
+}

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

@@ -147,7 +147,6 @@ public class StudentManageServiceImpl implements StudentManageService {
             userContractVersionMap = userAllContract.stream().collect(Collectors.groupingBy(SysUserContracts::getUserId, Collectors.mapping(SysUserContracts::getVersion, Collectors.toSet())));
         }
 
-        //List<Subject> studentSubject = studentManageDao.getStudentSubject(userIds);
         StudentListCourseDto studentListCourseDto = null;
         for (StudentManageListDto dto : dataList) {
             studentListCourseDto = StudentListCourseDtoMap.get(dto.getUserId());

+ 5 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -13,6 +13,7 @@ import java.util.stream.Collectors;
 
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.service.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
@@ -35,16 +36,6 @@ import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
 import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
-import com.ym.mec.biz.service.DegreeRegistrationService;
-import com.ym.mec.biz.service.MusicGroupService;
-import com.ym.mec.biz.service.PracticeGroupService;
-import com.ym.mec.biz.service.SporadicChargeInfoService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.StudentRegistrationService;
-import com.ym.mec.biz.service.StudentRepairService;
-import com.ym.mec.biz.service.SubjectChangeService;
-import com.ym.mec.biz.service.SysUserCashAccountService;
-import com.ym.mec.biz.service.VipGroupService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
@@ -95,6 +86,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     private SysConfigDao sysConfigDao;
     @Autowired
     private GoodsDao goodsDao;
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
 
     @Override
     public BaseDAO<Long, StudentPaymentOrder> getDAO() {
@@ -372,6 +365,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             subjectChangeService.orderCallback(order);
         } else if (order.getType().equals(OrderTypeEnum.DEGREE_REGISTRATION)) {
             degreeRegistrationService.updateStatus(order);
+        }else if (order.getType().equals(OrderTypeEnum.MAINTENANCE)) {
+            studentInstrumentService.orderCallback(order);
         }
     }
 

+ 84 - 172
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -20,7 +20,10 @@ import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
 
+import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.event.source.GroupEventSource;
+import com.ym.mec.biz.service.*;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -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,30 +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;
@@ -100,23 +61,6 @@ 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;
-import com.ym.mec.biz.service.ContractService;
-import com.ym.mec.biz.service.CourseScheduleService;
-import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
-import com.ym.mec.biz.service.ImGroupMemberService;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
-import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
-import com.ym.mec.biz.service.SellOrderService;
-import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.StudentRegistrationService;
-import com.ym.mec.biz.service.SubjectService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysMessageService;
-import com.ym.mec.biz.service.SysUserCashAccountDetailService;
-import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.ImResult;
 import com.ym.mec.common.entity.ImUserModel;
@@ -207,6 +151,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Autowired
     private GroupEventSource groupEventSource;
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
 
     @Override
     public BaseDAO<Long, StudentRegistration> getDAO() {
@@ -356,11 +302,11 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentRegistration.setUpdateTime(date);
         studentRegistration.setUserId(sysUser.getId());
         studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.APPLY);
-        if(hasReg != null){
+        if (hasReg != null) {
             studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
             studentRegistration.setId(hasReg.getId());
             studentRegistrationDao.update(studentRegistration);
-        }else {
+        } else {
             studentRegistrationDao.insert(studentRegistration);
         }
 
@@ -387,7 +333,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());
@@ -411,6 +358,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
         studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
         //乐器及打包辅件
+        String maintenanceGoodsId = "";
         if (goodsGroups != null && goodsGroups.size() > 0) {
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 StudentPaymentOrderDetail studentPaymentOrderDetail4goodsGroup = new StudentPaymentOrderDetail();
@@ -433,54 +381,17 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetail4goodsGroup.setPaymentOrderId(studentPaymentOrder.getId());
                 studentPaymentOrderDetail4goodsGroup.setKitGroupPurchaseType(goodsGroup.getKitGroupPurchaseType());
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goodsGroup);
+                if (OrderDetailTypeEnum.MUSICAL.equals(type) && KitGroupPurchaseTypeEnum.GROUP.equals(goodsGroup.getKitGroupPurchaseType())) {
+                    maintenanceGoodsId = goodsGroup.getGoodsIdList();
+                }
             }
         }
 
-        //单独辅件
-        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) {
                 StudentPaymentOrderDetail studentPaymentOrderDetailCourse = new StudentPaymentOrderDetail();
                 studentPaymentOrderDetailCourse.setType(OrderDetailTypeEnum.valueOf(newCourse.getCourseType().getCode()));
-                studentPaymentOrderDetailCourse.setPrice(newCourse.getCourseCurrentPrice());
                 if (courseRemitFee.compareTo(BigDecimal.ZERO) > 0 && !newCourse.getIsStudentOptional()) {
                     studentPaymentOrderDetailCourse.setPrice(BigDecimal.ZERO);
                     studentPaymentOrderDetailCourse.setRemitFee(newCourse.getCourseCurrentPrice());
@@ -494,6 +405,20 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
             }
         }
+        if (buyMaintenance) {
+            if ("".equals(maintenanceGoodsId)) {
+                throw new BizException("团购乐器才能购买乐保,请核查");
+            }
+            BigDecimal maintenancePrice = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
+            StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
+            maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
+            maintenanceOrderDetail.setPrice(maintenancePrice);
+            maintenanceOrderDetail.setRemitFee(BigDecimal.ZERO);
+            maintenanceOrderDetail.setCreateTime(date);
+            maintenanceOrderDetail.setUpdateTime(date);
+            maintenanceOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+            studentPaymentOrderDetailList.add(maintenanceOrderDetail);
+        }
         studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
 
         //增加缴费学生数
@@ -524,7 +449,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);
@@ -554,6 +483,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
         studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
         //乐器及打包辅件
+        String maintenanceGoodsId = "";
         if (goodsGroups != null && goodsGroups.size() > 0) {
             for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
                 StudentPaymentOrderDetail studentPaymentOrderDetail4goodsGroup = new StudentPaymentOrderDetail();
@@ -576,49 +506,12 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetail4goodsGroup.setPaymentOrderId(studentPaymentOrder.getId());
                 studentPaymentOrderDetail4goodsGroup.setKitGroupPurchaseType(goodsGroup.getKitGroupPurchaseType());
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goodsGroup);
+                if (OrderDetailTypeEnum.MUSICAL.equals(type) && KitGroupPurchaseTypeEnum.GROUP.equals(goodsGroup.getKitGroupPurchaseType())) {
+                    maintenanceGoodsId = goodsGroup.getGoodsIdList();
+                }
             }
         }
 
-        //单独辅件
-        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) {
@@ -637,6 +530,20 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
             }
         }
+        if (buyMaintenance) {
+            if ("".equals(maintenanceGoodsId)) {
+                throw new BizException("团购乐器才能购买乐保,请核查");
+            }
+            BigDecimal maintenancePrice = new BigDecimal(sysConfigDao.findConfigValue("maintenance_price"));
+            StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
+            maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
+            maintenanceOrderDetail.setPrice(maintenancePrice);
+            maintenanceOrderDetail.setRemitFee(BigDecimal.ZERO);
+            maintenanceOrderDetail.setCreateTime(date);
+            maintenanceOrderDetail.setUpdateTime(date);
+            maintenanceOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+            studentPaymentOrderDetailList.add(maintenanceOrderDetail);
+        }
         studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
 
         return studentPaymentOrder;
@@ -650,7 +557,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             return null;
         }
         SysUserCashAccount account = sysUserCashAccountDao.getLocked(userId);
-        registration.setBalance(account==null?BigDecimal.ZERO : account.getBalance());
+        registration.setBalance(account == null ? BigDecimal.ZERO : account.getBalance());
         registration.setTransferStudent(0);
         return registration;
     }
@@ -814,30 +721,30 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void insertStudent(String studentIds,String oldMusicGroupId,String newMusicGroupId,Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect){
+    public void insertStudent(String studentIds, String oldMusicGroupId, String newMusicGroupId, Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect) {
         SysUser sysUser1 = sysUserFeignService.queryUserInfo();
         //获取旧乐团学员注册信息
-        List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryByUserIdsAndMusicGroupId(studentIds,oldMusicGroupId);
+        List<StudentRegistration> studentRegistrations = studentRegistrationDao.queryByUserIdsAndMusicGroupId(studentIds, oldMusicGroupId);
         List<StudentCourseFeeDetail> studentCourseFeeDetails = new ArrayList<>();
         BigDecimal amount = BigDecimal.ZERO;
         for (StudentRegistration studentRegistration : studentRegistrations) {
             List<MusicGroupPaymentCalenderStudentDetail> details = collect.get(studentRegistration.getUserId());
-            BigDecimal masterTotalPrice = details.stream().map(e->e.getCutAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
-            if(masterTotalPrice.doubleValue() > studentRegistration.getSurplusCourseFee().doubleValue()){
+            BigDecimal masterTotalPrice = details.stream().map(e -> e.getCutAmount()).reduce(BigDecimal.ZERO, BigDecimal::add);
+            if (masterTotalPrice.doubleValue() > studentRegistration.getSurplusCourseFee().doubleValue()) {
                 throw new BizException("用户信息发生变动,请重新提交");
             }
-            if(oldMusicGroupId == newMusicGroupId){
+            if (oldMusicGroupId == newMusicGroupId) {
                 continue;
             }
-            courseScheduleStudentPaymentService.updateCourseActualPrice(Arrays.asList(oldMusicGroupId),null, GroupType.MUSIC);
+            courseScheduleStudentPaymentService.updateCourseActualPrice(Arrays.asList(oldMusicGroupId), null, GroupType.MUSIC);
             //记录课程余额消费日志
-            if(studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d){
+            if (studentRegistration.getSurplusCourseFee().doubleValue() > 0d && masterTotalPrice.doubleValue() > 0d) {
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
-                if(studentRegistration.getSurplusCourseFee().doubleValue() > masterTotalPrice.doubleValue()){
+                if (studentRegistration.getSurplusCourseFee().doubleValue() > masterTotalPrice.doubleValue()) {
                     amount = masterTotalPrice;
                     studentCourseFeeDetail.setAmount(masterTotalPrice.negate());
                     studentCourseFeeDetail.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().subtract(masterTotalPrice));
-                }else {
+                } else {
                     amount = studentRegistration.getSurplusCourseFee();
                     studentCourseFeeDetail.setAmount(studentRegistration.getSurplusCourseFee().negate());
                     studentCourseFeeDetail.setSurplusCourseFee(BigDecimal.ZERO);
@@ -854,7 +761,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             //用户是否在主乐团
             StudentRegistration registration = studentRegistrationDao.getByPhoneAndMusicGroupId(newMusicGroupId, studentRegistration.getParentsPhone());
             if (registration != null) {
-                if(registration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.NORMAL){
+                if (registration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.NORMAL) {
                     orderFlag = false;
                 }
                 //修改剩余课程余额
@@ -864,7 +771,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 registration.setUpdateTime(date);
                 registration.setSurplusCourseFee(registration.getSurplusCourseFee().add(amount));
                 studentRegistrationDao.update(registration);
-            }else {
+            } else {
                 //生成学员乐团注册表
                 studentRegistration.setOrganId(musicGroupDao.get(newMusicGroupId).getOrganId());
                 studentRegistration.setSurplusCourseFee(amount);
@@ -875,11 +782,11 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //增加报名学生数
                 musicGroupSubjectPlanService.addApplyStudentNum(newMusicGroupId, studentRegistration.getActualSubjectId(), 1);
                 //新增Fee表
-                MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(),newMusicGroupId);
-                if(musicGroupStudentFee == null){
+                MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), newMusicGroupId);
+                if (musicGroupStudentFee == null) {
                     musicGroupStudentFee = new MusicGroupStudentFee(newMusicGroupId,
-                            studentRegistration.getUserId(), studentRegistration.getSubjectId(),BigDecimal.ZERO,
-                            null, studentRegistration.getTemporaryCourseFee(), studentRegistration.getPaymentStatus()==YES?PAID_COMPLETED:NON_PAYMENT);
+                            studentRegistration.getUserId(), studentRegistration.getSubjectId(), BigDecimal.ZERO,
+                            null, studentRegistration.getTemporaryCourseFee(), studentRegistration.getPaymentStatus() == YES ? PAID_COMPLETED : NON_PAYMENT);
                     musicGroupStudentFeeDao.insert(musicGroupStudentFee);
                 }
             }
@@ -889,7 +796,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 waitPayOrder.setStatus(DealStatusEnum.CLOSE);
                 studentPaymentOrderService.update(waitPayOrder);
             }
-            if(orderFlag){
+            if (orderFlag) {
                 //生成订单
                 StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
                 studentPaymentOrder.setUserId(registration.getUserId());
@@ -906,7 +813,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderService.insert(studentPaymentOrder);
             }
             //主班新增余额日志
-            if(amount.doubleValue() != 0d && masterTotalPrice.doubleValue() > 0d){
+            if (amount.doubleValue() != 0d && masterTotalPrice.doubleValue() > 0d) {
                 StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
                 studentCourseFeeDetail.setAmount(amount);
                 studentCourseFeeDetail.setSurplusCourseFee(registration.getSurplusCourseFee());
@@ -916,7 +823,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentCourseFeeDetails.add(studentCourseFeeDetail);
             }
         }
-        if(studentCourseFeeDetails.size() > 0){
+        if (studentCourseFeeDetails.size() > 0) {
             studentCourseFeeDetailDao.batchInsert(studentCourseFeeDetails);
         }
     }
@@ -1133,8 +1040,13 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 sellOrderService.addOrderDetail2SellOrder(orderDetails, studentPaymentOrder, musicGroup);
             }
 
+            //课程处理
             addCalenderDetail(studentPaymentOrder, studentRegistration);
 
+            //学生乐器与月保处理
+            studentInstrumentService.addOrderDetail2Instrument(studentPaymentOrder);
+
+            //合并学员处理
             if (studentRegistration.getIsMerge().equals(1) && studentPaymentOrder.getExpectAmount().compareTo(BigDecimal.ZERO) <= 0) {
                 return studentPaymentOrder;
             }
@@ -1408,7 +1320,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     @Transactional
     public StudentRegistration updateStudent(StudentRegistration studentRegistration) {
-        if(StringUtils.isBlank(studentRegistration.getCertificateType())){
+        if (StringUtils.isBlank(studentRegistration.getCertificateType())) {
             studentRegistration.setCertificateType(CertificateTypeEnum.IDENTITY.getCode());
         }
         StudentRegistration student = get(studentRegistration.getId());
@@ -1420,9 +1332,9 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         student.setIdCardNo(studentRegistration.getIdCardNo());
         student.setGender(studentRegistration.getGender());
         update(studentRegistration);
-        studentRegistrationDao.updateUser(student.getUserId(),student.getName(), student.getParentsName(), student.getIdCardNo(), student.getGender(),studentRegistration.getCertificateType());
+        studentRegistrationDao.updateUser(student.getUserId(), student.getName(), student.getParentsName(), student.getIdCardNo(), student.getGender(), studentRegistration.getCertificateType());
         // 添加用户电子签章账户
-        if(CertificateTypeEnum.IDENTITY.getCode().equals(studentRegistration.getCertificateType())){
+        if (CertificateTypeEnum.IDENTITY.getCode().equals(studentRegistration.getCertificateType())) {
             contractService.register(student.getUserId(), student.getParentsName(), student.getIdCardNo(), student.getParentsPhone());
         }
         return student;
@@ -1610,10 +1522,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         return amount;
     }
 
-	@Override
-	public List<StudentMusicGroupDto> queryStudentMusicGroupInfo(Integer userId) {
-		return studentRegistrationDao.queryStudentMusicGroupInfo(userId);
-	}
+    @Override
+    public List<StudentMusicGroupDto> queryStudentMusicGroupInfo(Integer userId) {
+        return studentRegistrationDao.queryStudentMusicGroupInfo(userId);
+    }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -1634,8 +1546,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     public Boolean batchDelRegs(String musicGroupId, List<Integer> userIds) {
         List<StudentRegistration> registrations = studentRegistrationDao.findStudentListByUserIdList(musicGroupId, userIds);
         for (StudentRegistration registration : registrations) {
-            if(registration.getPaymentStatus().equals(PaymentStatusEnum.OPEN)||registration.getPaymentStatus().equals(PaymentStatusEnum.YES)){
-                throw new BizException(registration.getName()+"("+registration.getPaymentStatus().getDesc()+"),不能删除");
+            if (registration.getPaymentStatus().equals(PaymentStatusEnum.OPEN) || registration.getPaymentStatus().equals(PaymentStatusEnum.YES)) {
+                throw new BizException(registration.getName() + "(" + registration.getPaymentStatus().getDesc() + "),不能删除");
             }
         }
         if (registrations.size() <= 0) {
@@ -1663,6 +1575,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Override
     public List<StudentRegistration> getMusicGroupStuReBack(String musicGroupId) {
         courseScheduleStudentPaymentService.updateCourseActualPrice(Arrays.asList(musicGroupId), null, GroupType.MUSIC);
-        return this.findMusicGroupStudent(musicGroupId,null);
+        return this.findMusicGroupStudent(musicGroupId, null);
     }
 }

+ 34 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -73,6 +73,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     private ContractService contractService;
     @Autowired
     private GoodsService goodsService;
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
+    @Autowired
+    private StudentGoodsSellService studentGoodsSellService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -383,10 +387,23 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         ) {
             throw new BizException("邮寄信息必填");
         }
+        Date date = new Date();
+        StudentInstrument studentInstrument = null;
+        if (repairInfo.getStudentInstrumentId() != null) {
+            studentInstrument = studentInstrumentService.get(repairInfo.getStudentInstrumentId());
+        }
+
+        if (repairInfo.getExemptionAmount().compareTo(BigDecimal.ZERO) > 0) {
+            if (studentInstrument == null || studentInstrument.getEndTime() == null || studentInstrument.getEndTime().compareTo(date) <= 0) {
+                throw new BizException("乐保不存在,不能使用特权减免,请核查");
+            }
+        }
+        if (studentInstrument != null && studentInstrument.getEndTime() != null && studentInstrument.getEndTime().compareTo(date) > 0) {
+            repairInfo.setMaintenanceStatus(1);
+        }
         SysUser student = sysUserFeignService.queryUserById(repairInfo.getStudentId());
         repairInfo.setOrganId(student.getOrganId());
 
-        Date date = new Date();
         BigDecimal amount = repairInfo.getAmount();
         String orderNo = idGeneratorService.generatorId("payment") + "";
         repairInfo.setTransNo(orderNo);
@@ -404,12 +421,6 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             });
             repairInfo.setGoodsJson(JSONObject.toJSONString(repairGoodsDtos));
         }
-        studentRepairDao.insert(repairInfo);
-        if (repairInfo.getType() == 1) {
-            Map<String, Object> repairInfoMap = new HashMap<>();
-            MapUtil.populateMap(repairInfoMap, repairInfo);
-            return repairInfoMap;
-        }
 
         if (StringUtils.isNoneBlank(repairInfo.getGoodsJson())) {
             JSONArray goods = JSON.parseArray(repairInfo.getGoodsJson());
@@ -421,6 +432,17 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 }
             }
         }
+        amount = amount.subtract(repairInfo.getExemptionAmount());
+        if (amount.compareTo(BigDecimal.ZERO) < 0) {
+            throw new BizException("特权减免金额不能大于总金额");
+        }
+
+        studentRepairDao.insert(repairInfo);
+        if (repairInfo.getType() == 1) {
+            Map<String, Object> repairInfoMap = new HashMap<>();
+            MapUtil.populateMap(repairInfoMap, repairInfo);
+            return repairInfoMap;
+        }
 
         repairInfo.setPayStatus(1);
         String channelType = "";
@@ -473,12 +495,6 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
         String baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.BASE_API_URL);
 
-        Map<String, BigDecimal> classFee = new HashMap<>();
-        classFee.put("course", BigDecimal.ZERO);
-        classFee.put("instrument", BigDecimal.ZERO);
-        classFee.put("accessories", BigDecimal.ZERO);
-        classFee.put("other", amount);
-
         Map payMap = payService.getPayMap(
                 amount,
                 balance,
@@ -571,6 +587,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             BigDecimal reduce = repairGoodsDtos.stream().map(e -> e.getGroupPurchasePrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
             amount = amount.add(reduce);
         }
+        amount = amount.subtract(studentRepair.getExemptionAmount());
+
         String orderNo = idGeneratorService.generatorId("payment") + "";
         studentRepair.setIsUseBalancePayment(repairInfo.getIsUseBalancePayment());
         studentRepair.setTransNo(orderNo);
@@ -717,6 +735,9 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             paymentDetail.setType(PlatformCashAccountDetailTypeEnum.GOODS_SELL);
             paymentDetail.setUserId(userId);
             sysUserCashAccountDetailService.insert(paymentDetail);
+            //将购买的乐器加入学生乐器列表
+            studentGoodsSellService.saveStudentInstrument(studentPaymentOrder.getOrderNo());
+            //购买的商品加入销售列表
             saveSellOrder(studentPaymentOrder.getOrderNo());
         } else if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {

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

@@ -270,7 +270,7 @@
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
-		DELETE FROM goods WHERE id_ = #{id} 
+		DELETE FROM goods WHERE id_ = #{id}
 	</delete>
 
     <!-- 分页查询 -->
@@ -413,4 +413,19 @@
     <select id="findByIdAndStatus" resultType="java.lang.Boolean">
         SELECT COUNT(0) FROM goods WHERE status_ = #{status} AND id_ = #{goodsId}
     </select>
+
+    <select id="getGoodsInfo" resultMap="Goods">
+        SELECT g.*,gc.name_ goods_category_name_ FROM goods g
+        LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
+        WHERE g.id_=#{id}
+    </select>
+
+    <select id="getGoodiesAndCate" resultMap="Goods">
+        SELECT g.*,gc.name_ goods_category_name_ FROM goods g
+        LEFT JOIN goods_category gc on g.goods_category_id_ = gc.id_
+        WHERE g.id_ IN
+        <foreach collection="goodsIds" item="goodsId" open="(" close=")" separator=",">
+            #{goodsId}
+        </foreach>
+    </select>
 </mapper>

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

@@ -0,0 +1,160 @@
+<?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="goods_category_id_" property="goodsCategoryId"/>
+        <result column="goods_category_name_" property="goodsCategoryName"/>
+        <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>
+
+    <select id="get" parameterType="java.lang.Long" resultMap="StudentInstrument">
+        <!--@mbg.generated-->
+        SELECT * FROM student_instrument
+        where id_ = #{id}
+    </select>
+    <delete id="delete" parameterType="java.lang.Long">
+        <!--@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_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
+        status_, start_time_, end_time_, create_time_, update_time
+        )
+        values
+        (#{studentId},#{organId},#{goodsId},#{goodsCategoryId},#{goodsCategoryName},#{goodsName},#{goodsBrand},#{specification},#{goodsImg},
+        #{status}, #{startTime}, #{endTime}, NOW(), NOW()
+        )
+    </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 si.*,su.username_ studentName,su.phone_ phone,o.name_ organName FROM student_instrument si
+        LEFT JOIN sys_user su ON su.id_ = si.student_id_
+        LEFT JOIN organization o ON o.id_ = si.organ_id_
+        <include refid="queryPageSql"/>
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*)
+        FROM student_instrument si
+        LEFT JOIN sys_user su ON su.id_ = si.student_id_
+        <include refid="queryPageSql"/>
+    </select>
+
+    <sql id="queryPageSql">
+        <where>
+            <if test="studentId != null">
+                AND si.student_id_ = #{studentId}
+            </if>
+            <if test="organId != null">
+                AND FIND_IN_SET(si.organ_id_,#{organId})
+            </if>
+            <if test="goodsId != null">
+                AND si.goods_id_ = #{goodsId}
+            </if>
+            <if test="goodsCategoryId != null">
+                AND si.goods_category_id_ = #{goodsCategoryId}
+            </if>
+            <if test="goodsBrand != null">
+                AND si.goods_brand_ LIKE CONCAT('%',#{goodsBrand},'%')
+            </if>
+            <if test="specification != null">
+                AND si.specification_ LIKE CONCAT('%',#{specification},'%')
+            </if>
+            <if test="search != null">
+                AND (si.student_id_ = #{search} OR su.phone_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%'))
+            </if>
+        </where>
+    </sql>
+
+    <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+        insert into student_instrument
+        (student_id_,organ_id_,goods_id_,goods_category_id_,goods_category_name_,goods_name_,goods_brand_,specification_,goods_img_,
+        status_, start_time_, end_time_, create_time_, update_time)
+        VALUE
+        <foreach collection="studentInstruments" item="item" separator=",">
+            (#{item.studentId},#{item.organId},#{item.goodsId},#{item.goodsCategoryId},#{item.goodsCategoryName},#{item.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg},
+            #{item.status}, #{item.startTime},
+            #{item.endTime}, NOW(), NOW())
+        </foreach>
+    </insert>
+
+    <update id="batchUpdate">
+   <![CDATA[
+        UPDATE student_instrument
+        SET status_ = 0
+        WHERE end_time_ <= NOW()
+        ]]>
+    </update>
+
+</mapper>

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -78,6 +78,9 @@
             <if test="type != null">
                 type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
+            <if test="studentInstrumentId != null">
+                student_instrument_id_ = #{studentInstrumentId},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>

+ 17 - 9
mec-biz/src/main/resources/config/mybatis/StudentRepairMapper.xml

@@ -4,6 +4,11 @@
     <resultMap id="StudentRepair" type="com.ym.mec.biz.dal.entity.StudentRepair">
         <result column="id_" jdbcType="INTEGER" property="id"/>
         <result column="music_group_id_" jdbcType="VARCHAR" property="musicGroupId"/>
+        <result column="student_instrument_id_" property="studentInstrumentId"/>
+        <result column="maintenance_status_" property="maintenanceStatus"/>
+        <result column="repair_name_" property="repairName"/>
+        <result column="repair_img_" property="repairImg"/>
+        <result column="exemption_amount_" property="exemptionAmount"/>
         <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
         <result column="trans_no_" jdbcType="VARCHAR" property="transNo"/>
         <result column="organ_id_" jdbcType="INTEGER" property="organId"/>
@@ -44,15 +49,12 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentRepair" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
         <!--@mbg.generated-->
-        insert into student_repair (id_,music_group_id_, trans_no_, organ_id_,
-        student_id_, student_name_, student_school_,
-        employee_id_, employee_name_, subject_id_,
-        subject_name_, type_, instrument_no_,fee_list_,
-        description_, amount_, finish_time_,
-        send_type_, contact_name_, contact_mobile_,
-        address_, pay_status_, create_time_,
-        update_time_,repair_status_,goods_json_)
-        values (#{id,jdbcType=INTEGER},#{musicGroupId}, #{transNo,jdbcType=VARCHAR}, #{organId,jdbcType=INTEGER},
+        insert into student_repair (id_,music_group_id_, trans_no_,student_instrument_id_,maintenance_status_,repair_name_,
+        repair_img_,exemption_amount_,organ_id_,student_id_, student_name_,student_school_,employee_id_, employee_name_,
+        subject_id_,subject_name_, type_, instrument_no_,fee_list_,description_, amount_, finish_time_,send_type_,
+        contact_name_, contact_mobile_,address_,pay_status_, create_time_,update_time_,repair_status_,goods_json_)
+        values (#{id,jdbcType=INTEGER},#{musicGroupId}, #{transNo,jdbcType=VARCHAR}, #{studentInstrumentId},
+        #{maintenanceStatus},#{repairName},#{repairImg},#{exemptionAmount},#{organId,jdbcType=INTEGER},
         #{studentId,jdbcType=INTEGER}, #{studentName,jdbcType=VARCHAR}, #{studentSchool,jdbcType=VARCHAR},
         #{employeeId,jdbcType=INTEGER}, #{employeeName,jdbcType=VARCHAR}, #{subjectId,jdbcType=INTEGER},
         #{subjectName,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{instrumentNo,jdbcType=VARCHAR},
@@ -204,6 +206,12 @@
             <if test="endTime != null">
                 AND sr.create_time_ &lt;= #{endTime}
             </if>
+            <if test="studentInstrumentId != null">
+                AND sr.student_instrument_id_ = #{studentInstrumentId}
+            </if>
+            <if test="exemptionAmount != null">
+                AND sr.exemption_amount_ > #{exemptionAmount}
+            </if>
         </where>
     </sql>
     <select id="queryCount" resultType="int">

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

@@ -0,0 +1,56 @@
+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.dao.StudentInstrumentDao;
+import com.ym.mec.biz.dal.dto.MaintenancePayDto;
+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;
+    @Autowired
+    private StudentInstrumentDao studentInstrumentDao;
+
+    @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());
+        studentInstrumentDao.batchUpdate();
+        return succeed(studentInstrumentService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "乐保支付")
+    @PostMapping("/pay")
+    @ApiImplicitParams({@ApiImplicitParam(name = "maintenancePayDto", value = "支付参数", required = true, dataType = "MaintenancePayDto")})
+    public HttpResponseResult pay(MaintenancePayDto maintenancePayDto) throws Exception {
+        return succeed(studentInstrumentService.pay(maintenancePayDto));
+    }
+}

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

@@ -43,17 +43,17 @@ public class SporadicChargeInfoController extends BaseController {
 		if (sysUser == null) {
 			return failed("用户信息获取失败");
 		}
-			Employee employee = employeeDao.get(sysUser.getId());
-			if (StringUtils.isEmpty(queryInfo.getOrganId())) {
-				queryInfo.setOrganId(employee.getOrganIdList());
-			}else if(StringUtils.isEmpty(employee.getOrganIdList())){
-				return failed("用户所在分部异常");
-			}else {
-				List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
-				if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
-					return failed("非法请求");
-				}
+		Employee employee = employeeDao.get(sysUser.getId());
+		if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+			queryInfo.setOrganId(employee.getOrganIdList());
+		}else if(StringUtils.isEmpty(employee.getOrganIdList())){
+			return failed("用户所在分部异常");
+		}else {
+			List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+			if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+				return failed("非法请求");
 			}
+		}
 		queryInfo.setSort("id_");
 		return succeed(sporadicChargeInfoService.queryDetailPage(queryInfo));
 	}

+ 87 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentInstrumentController.java

@@ -0,0 +1,87 @@
+package com.ym.mec.web.controller;
+
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.page.StudentInstrumentQueryInfo;
+import com.ym.mec.biz.service.StudentInstrumentService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.List;
+
+@RequestMapping("studentInstrument")
+@Api(tags = "乐器与乐保服务")
+@RestController
+public class StudentInstrumentController extends BaseController {
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private EmployeeDao employeeDao;
+    @Autowired
+    private StudentInstrumentDao studentInstrumentDao;
+
+
+    @ApiOperation(value = "乐器保养列表")
+    @GetMapping("/getList")
+    @PreAuthorize("@pcs.hasPermissions('studentInstrument/getList')")
+    public HttpResponseResult<PageInfo<StudentInstrument>> getList(StudentInstrumentQueryInfo queryInfo) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+            return failed("用户所在分部异常");
+        } else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                return failed("非法请求");
+            }
+        }
+        studentInstrumentDao.batchUpdate();
+        return succeed(studentInstrumentService.queryPage(queryInfo));
+    }
+
+    @ApiOperation(value = "新增乐器")
+    @PostMapping("/add")
+    @PreAuthorize("@pcs.hasPermissions('studentInstrument/add')")
+    public HttpResponseResult<StudentInstrument> add(StudentInstrument studentInstrument) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        if (studentInstrument.getStudentId() == null) {
+            return failed("学生id不能为空");
+        }
+        SysUser student = sysUserFeignService.queryUserById(studentInstrument.getStudentId());
+        studentInstrument.setOrganId(student.getOrganId());
+        return succeed(studentInstrumentService.addStudentInstrument(studentInstrument));
+    }
+
+}

+ 13 - 4
mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

@@ -4,15 +4,13 @@ package com.ym.mec.web.controller.education;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.entity.*;
 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.page.GoodsCategoryQueryInfo;
-import com.ym.mec.biz.dal.page.GoodsQueryInfo;
-import com.ym.mec.biz.dal.page.GoodsSellQueryInfo;
-import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
+import com.ym.mec.biz.dal.page.*;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -52,6 +50,10 @@ public class EduRepairController extends BaseController {
     private GoodsCategoryService goodsCategoryService;
     @Autowired
     private StudentGoodsSellService studentGoodsSellService;
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
+    @Autowired
+    private StudentInstrumentDao studentInstrumentDao;
 
     @ApiOperation("获取学生列表")
     @GetMapping(value = "/getStudents")
@@ -205,4 +207,11 @@ public class EduRepairController extends BaseController {
         queryInfo.setTeacherId(sysUser.getId());
         return succeed(studentGoodsSellService.queryStudentGoodsOrders(queryInfo));
     }
+
+    @ApiOperation(value = "获取乐器与乐保列表")
+    @GetMapping("/getInstrumentList")
+    public HttpResponseResult<PageInfo<StudentInstrument>> getInstrumentList(StudentInstrumentQueryInfo queryInfo) {
+        studentInstrumentDao.batchUpdate();
+        return succeed(studentInstrumentService.queryPage(queryInfo));
+    }
 }