Explorar o código

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

zouxuan %!s(int64=4) %!d(string=hai) anos
pai
achega
32f45a962e
Modificáronse 20 ficheiros con 647 adicións e 176 borrados
  1. 4 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentInstrumentDao.java
  2. 40 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MaintenancePayDto.java
  3. 33 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentInstrument.java
  4. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrderDetail.java
  5. 102 46
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentRepair.java
  6. 25 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/RepairStudentQueryInfo.java
  7. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentInstrumentQueryInfo.java
  8. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentGoodsSellService.java
  9. 9 2
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentInstrumentService.java
  10. 110 69
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java
  11. 118 13
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java
  12. 5 10
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  13. 17 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  14. 22 7
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  15. 30 3
      mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml
  16. 13 2
      mec-biz/src/main/resources/config/mybatis/StudentRepairMapper.xml
  17. 4 6
      mec-student/src/main/java/com/ym/mec/student/controller/StudentInstrumentController.java
  18. 10 10
      mec-web/src/main/java/com/ym/mec/web/controller/SporadicChargeInfoController.java
  19. 63 0
      mec-web/src/main/java/com/ym/mec/web/controller/StudentInstrumentController.java
  20. 9 4
      mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

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

@@ -2,7 +2,11 @@ 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> {
 
+    int batchAdd(@Param("studentInstruments") List<StudentInstrument> studentInstruments);
 }

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

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

@@ -70,6 +70,15 @@ public class StudentInstrument {
     @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;
     }
@@ -174,4 +183,28 @@ public class StudentInstrument {
     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;
+    }
 }

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

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

@@ -9,14 +9,38 @@ 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 BigDecimal exemptionAmount = BigDecimal.ZERO;
+
+    /**
+     * 分部id
+     */
     @ApiModelProperty(value = "分部id", required = false)
     private Integer organId;
 
@@ -28,32 +52,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 +100,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 +130,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 +196,14 @@ public class StudentRepair {
     private Boolean isUseBalancePayment;
 
     /**
-    * 送修时间
-    */
+     * 送修时间
+     */
     @ApiModelProperty(value = "送修时间", required = true)
     private Date createTime;
 
     /**
-    * 更新时间
-    */
+     * 更新时间
+     */
     @ApiModelProperty(value = "更新时间", required = false)
     private Date updateTime;
 
@@ -427,4 +451,36 @@ 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;
+    }
 }

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

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

@@ -14,6 +14,9 @@ public class StudentInstrumentQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "学生id", required = true)
     private Integer studentId;
 
+    @ApiModelProperty(value = "分部ids", required = true)
+    private String organId;
+
     public Integer getStudentId() {
         return studentId;
     }
@@ -21,4 +24,12 @@ public class StudentInstrumentQueryInfo extends QueryInfo {
     public void setStudentId(Integer studentId) {
         this.studentId = studentId;
     }
+
+    public String getOrganId() {
+        return organId;
+    }
+
+    public void setOrganId(String organId) {
+        this.organId = organId;
+    }
 }

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

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

@@ -1,7 +1,9 @@
 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;
@@ -11,9 +13,14 @@ public interface StudentInstrumentService extends BaseService<Long, StudentInstr
 
     /**
      * 乐保支付
+     */
+    Map pay(MaintenancePayDto maintenancePayDto) throws Exception;
+
+    /**
+     * 回调页面
      *
-     * @param id
+     * @param studentPaymentOrder
      * @return
      */
-    Map pay(Long id, BigDecimal amount, boolean isUseBalance) throws Exception;
+    Boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
 }

+ 110 - 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,113 @@ 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.getGoodies(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.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;
-	}
 
 }

+ 118 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentInstrumentServiceImpl.java

@@ -1,22 +1,26 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.dao.StudentDao;
 import com.ym.mec.biz.dal.dao.StudentInstrumentDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dto.MaintenancePayDto;
 import com.ym.mec.biz.dal.entity.StudentInstrument;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.SysUserCashAccount;
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.GroupType;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+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.Date;
@@ -41,7 +45,13 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
-    private StudentDao studentDao;
+    private ContractService contractService;
+    @Autowired
+    private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+    @Autowired
+    private SysMessageService sysMessageService;
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     @Override
     public BaseDAO<Long, StudentInstrument> getDAO() {
@@ -49,25 +59,24 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
     }
 
     @Override
-    public Map pay(Long id, BigDecimal amount, boolean isUseBalance) throws Exception {
-        StudentInstrument studentInstrument = studentInstrumentDao.get(id);
+    @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(400);
-
+        BigDecimal amount = maintenancePayDto.getAmount(); //扣除余额之前的金额
         if (amount.compareTo(orderAmount) != 0) {
             throw new BizException("商品价格不符");
         }
 
-        String orderNo = idGeneratorService.generatorId("payment") + "";
-
         String channelType = "";
         Date date = new Date();
 
         BigDecimal balance = BigDecimal.ZERO;
-        if (isUseBalance && amount.compareTo(BigDecimal.ZERO) > 0) {
+        if (maintenancePayDto.getUseBalance() && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
             if (userCashAccount == null) {
                 throw new BizException("用户账户找不到");
@@ -78,6 +87,8 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
                 sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐保购买");
             }
         }
+
+        String orderNo = idGeneratorService.generatorId("payment") + "";
         StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
 
         studentPaymentOrder.setPaymentChannel("BALANCE");
@@ -85,7 +96,7 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
         studentPaymentOrder.setGroupType(GroupType.MAINTENANCE);
         studentPaymentOrder.setOrderNo(orderNo);
         studentPaymentOrder.setType(OrderTypeEnum.MAINTENANCE);
-        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setExpectAmount(orderAmount);
         studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setBalancePaymentAmount(balance);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
@@ -134,4 +145,98 @@ public class StudentInstrumentServiceImpl extends BaseServiceImpl<Long, StudentI
         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 &&
+                    DateUtil.getLastTimeWithDay(studentInstrument.getEndTime()).compareTo(nowDate) >= 0) {
+                startTime = studentInstrument.getStartTime();
+                endTime = DateUtil.addYears(studentInstrument.getStartTime(), 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;
+    }
 }

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

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

@@ -360,7 +360,7 @@ 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, BigDecimal remitFee, BigDecimal courseRemitFee, List<MusicGroupPaymentCalenderCourseSettings> newCourses,Boolean buyMaintenance) throws Exception {
+                                        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());
@@ -384,6 +384,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();
@@ -406,6 +407,9 @@ 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();
+                }
             }
         }
 
@@ -414,7 +418,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             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());
@@ -428,7 +431,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
             }
         }
-        if(buyMaintenance){
+        if (buyMaintenance) {
+            if ("".equals(maintenanceGoodsId)) {
+                throw new BizException("团购乐器才能购买乐保,请核查");
+            }
             StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
             maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
             maintenanceOrderDetail.setPrice(new BigDecimal(400));
@@ -502,6 +508,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();
@@ -524,6 +531,9 @@ 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();
+                }
             }
         }
 
@@ -545,7 +555,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderDetailList.add(studentPaymentOrderDetailCourse);
             }
         }
-        if(buyMaintenance){
+        if (buyMaintenance) {
+            if ("".equals(maintenanceGoodsId)) {
+                throw new BizException("团购乐器才能购买乐保,请核查");
+            }
             StudentPaymentOrderDetail maintenanceOrderDetail = new StudentPaymentOrderDetail();
             maintenanceOrderDetail.setType(OrderDetailTypeEnum.MAINTENANCE);
             maintenanceOrderDetail.setPrice(new BigDecimal(400));

+ 22 - 7
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);
@@ -421,6 +438,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 }
             }
         }
+        amount = amount.subtract(repairInfo.getExemptionAmount());
 
         repairInfo.setPayStatus(1);
         String channelType = "";
@@ -473,12 +491,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,
@@ -717,6 +729,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) {

+ 30 - 3
mec-biz/src/main/resources/config/mybatis/StudentInstrumentMapper.xml

@@ -94,7 +94,9 @@
 
   <!-- 分页查询 -->
   <select id="queryPage" resultMap="StudentInstrument" parameterType="map">
-    SELECT * FROM student_instrument
+    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>
@@ -102,16 +104,41 @@
   <!-- 查询当前表的总记录数 -->
   <select id="queryCount" resultType="int">
     SELECT COUNT(*)
-    FROM student_instrument
+    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 student_id_ = #{studentId}
+        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="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_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.goodsName},#{item.goodsBrand},#{item.specification},#{item.goodsImg}, #{item.status}, #{item.startTime},
+      #{item.endTime}, NOW(), NOW())
+    </foreach>
+  </insert>
+
 </mapper>

+ 13 - 2
mec-biz/src/main/resources/config/mybatis/StudentRepairMapper.xml

@@ -4,6 +4,10 @@
     <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="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,8 +48,8 @@
     <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_,
+        insert into student_repair (id_,music_group_id_, trans_no_, organ_id_,student_instrument_id_,maintenance_status_,
+        repair_name_,exemption_amount_,student_id_, student_name_, student_school_,
         employee_id_, employee_name_, subject_id_,
         subject_name_, type_, instrument_no_,fee_list_,
         description_, amount_, finish_time_,
@@ -53,6 +57,7 @@
         address_, pay_status_, create_time_,
         update_time_,repair_status_,goods_json_)
         values (#{id,jdbcType=INTEGER},#{musicGroupId}, #{transNo,jdbcType=VARCHAR}, #{organId,jdbcType=INTEGER},
+        #{studentInstrumentId},#{maintenanceStatus},#{repairName},#{exemptionAmount},
         #{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 +209,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">

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

@@ -3,6 +3,7 @@ package com.ym.mec.student.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.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;
@@ -45,11 +46,8 @@ public class StudentInstrumentController extends BaseController {
 
     @ApiOperation(value = "乐保支付")
     @PostMapping("/pay")
-    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "开通月保的乐器记录id", required = true, dataType = "int"),
-            @ApiImplicitParam(name = "amount", value = "金额", required = true, dataType = "BigDecimal"),
-            @ApiImplicitParam(name = "isUseBalance", value = "是否使用余额", required = true, dataType = "boolean")
-    })
-    public HttpResponseResult pay(Long id, BigDecimal amount, Boolean isUseBalance) throws Exception {
-        return succeed(studentInstrumentService.pay(id, amount, isUseBalance));
+    @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));
 	}

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

@@ -0,0 +1,63 @@
+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.entity.Employee;
+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.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;
+
+
+    @ApiOperation(value = "乐器保养列表")
+    @GetMapping("/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("非法请求");
+            }
+        }
+        return succeed(studentInstrumentService.queryPage(queryInfo));
+    }
+
+}

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

@@ -9,10 +9,7 @@ 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 +49,8 @@ public class EduRepairController extends BaseController {
     private GoodsCategoryService goodsCategoryService;
     @Autowired
     private StudentGoodsSellService studentGoodsSellService;
+    @Autowired
+    private StudentInstrumentService studentInstrumentService;
 
     @ApiOperation("获取学生列表")
     @GetMapping(value = "/getStudents")
@@ -205,4 +204,10 @@ 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) {
+        return succeed(studentInstrumentService.queryPage(queryInfo));
+    }
 }