Przeglądaj źródła

Merge branch 'master' into feature_change_subject

周箭河 4 lat temu
rodzic
commit
5454906724
41 zmienionych plików z 1108 dodań i 138 usunięć
  1. 8 8
      codegen/src/main/resources/generateConfigration.xml
  2. 0 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDao.java
  3. 36 5
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  4. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentFeeDao.java
  5. 49 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentGoodsSellDao.java
  6. 64 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CalenderPushDto.java
  7. 62 16
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/GoodsSellDto.java
  8. 38 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentGoodsSellDto.java
  9. 33 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroup.java
  10. 45 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java
  11. 11 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentFee.java
  12. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java
  13. 172 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentGoodsSell.java
  14. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MessageTypeEnum.java
  15. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java
  16. 13 4
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  17. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SellOrderService.java
  18. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentGoodsSellService.java
  19. 5 7
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentRepairService.java
  20. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  21. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/FinancialExpenditureServiceImpl.java
  22. 63 14
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  23. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  24. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  25. 51 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java
  26. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  27. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  28. 91 22
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  29. 14 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml
  30. 70 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  31. 18 4
      mec-biz/src/main/resources/config/mybatis/MusicGroupStudentFeeMapper.xml
  32. 1 1
      mec-biz/src/main/resources/config/mybatis/SellOrderMapper.xml
  33. 115 0
      mec-biz/src/main/resources/config/mybatis/StudentGoodsSellMapper.xml
  34. 4 0
      mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java
  35. 5 0
      mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java
  36. 6 8
      mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java
  37. 4 1
      mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  38. 19 0
      mec-task/src/main/java/com/ym/mec/task/jobs/UpdateMusicGroupStudentFeeStatus.java
  39. 10 15
      mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderController.java
  40. 6 4
      mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java
  41. 42 8
      mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

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

@@ -2,16 +2,16 @@
 <GenerateConfiguration>
 	<dbConfiguration>
 		<driverClass>com.mysql.jdbc.Driver</driverClass>
-		<url>jdbc:mysql://47.114.176.40:3306/edu_saas</url>
-		<username>edu_saas</username>
+		<url>jdbc:mysql://47.114.1.200:3306/mec_dev</url>
+		<username>mec_dev</username>
 		<password>dayaDataOnline@2019</password>
-		<catalog>edu_saas</catalog>
-		<schema>edu_saas</schema>
+		<catalog>mec_dev</catalog>
+		<schema>mec_dev</schema>
 	</dbConfiguration>
-	<srcBase>e:/javabean</srcBase>
-	<pojoPackageName>com.keao.edu.datasource.dal.entity</pojoPackageName>
-	<daoPackageName>com.keao.edu.datasource.dal.dao</daoPackageName>
-	<servicePackageName>com.keao.edu.datasource.service</servicePackageName>
+	<srcBase>d:/javabean</srcBase>
+	<pojoPackageName>com.ym.mec.biz.dal.entity</pojoPackageName>
+	<daoPackageName>com.ym.mec.biz.dal.dao</daoPackageName>
+	<servicePackageName>com.ym.mec.biz.service</servicePackageName>
 	<sqlmapPackageName>resources</sqlmapPackageName>
 	<sqlmapConfigPackageName>resources/config</sqlmapConfigPackageName>
 </GenerateConfiguration>

+ 0 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDao.java

@@ -1,6 +1,5 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.MusicCardDto;
 import com.ym.mec.biz.dal.dto.MusicGroupRegisterDto;
 import com.ym.mec.biz.dal.dto.RegisterSubjectDto;

+ 36 - 5
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java

@@ -1,10 +1,8 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
+import com.ym.mec.biz.dal.dto.CalenderPushDto;
 import org.apache.ibatis.annotations.Param;
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
@@ -69,7 +67,7 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      * @return
      */
     int queryIntersectionByPaymentDate(@Param("musicGroupId") String musicGroupId, @Param("startPaymentDate") Date startPaymentDate,
-                                       @Param("deadlinePaymentDate") Date deadlinePaymentDate);
+                                       @Param("deadlinePaymentDate") Date deadlinePaymentDate,@Param("calenderId") Long calenderId);
 
     /**
      * 统计预计缴费人数
@@ -95,4 +93,37 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
     MusicGroupPaymentCalender getLastStartOne(@Param("musicGroupId") String musicGroupId);
 
     int queryIntersectionByDate(@Param("musicGroupId") String musicGroupId, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    /**
+     * @describe 根据指定乐团的有效日期查询交集
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/21
+     * @time 10:46
+     * @param musicGroupId:
+     * @param paymentValidStartDate:
+     * @param paymentValidEndDate:
+     * @return int
+     */
+    int queryIntersectionByValidDate(@Param("musicGroupId") String musicGroupId,
+                                     @Param("paymentValidStartDate") String paymentValidStartDate,
+                                     @Param("paymentValidEndDate") String paymentValidEndDate,
+                                     @Param("calenderId") Long calenderId);
+
+    /**
+     * @describe 获取指定时间后的缴费信息
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/21
+     * @time 17:35
+     * @param configValue:
+     * @return void
+     */
+    List<Map<Long, Long>> queryCalenderByDay(String configValue);
+
+    List<MusicGroupPaymentCalender> queryByIds(@Param("calenderId") Set<Long> calenderId);
+
+    List<Long> queryEndIds(@Param("configValue1") String configValue1, @Param("format") String format);
+
+    List<CalenderPushDto> getCalenderPushDto(@Param("calenderIds") Collection<Long> calenderIds);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupStudentFeeDao.java

@@ -209,4 +209,14 @@ public interface MusicGroupStudentFeeDao extends BaseDAO<Long, MusicGroupStudent
 	 * @param paymentStatus
 	 */
 	void updatePaymentStatus(@Param("calenderId") Long calenderId, @Param("paymentStatus") String paymentStatus);
+
+	/**
+	 * @describe 将缴费截止的缴费状态更改为未缴费
+	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+	 * @author zouxuan
+	 * @date 2020/9/21
+	 * @time 14:34
+	 * @return void
+	 */
+    void updateFeeStatus();
 }

+ 49 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentGoodsSellDao.java

@@ -0,0 +1,49 @@
+package com.ym.mec.biz.dal.dao;
+
+
+import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+public interface StudentGoodsSellDao extends BaseDAO<Integer, StudentGoodsSell> {
+
+
+    /**
+     * @describe 获取教务老师关联的学员商品订单
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/23
+     * @time 14:00
+     * @param params:
+     * @return int
+     */
+    int countStudentGoodsOrders(Map<String, Object> params);
+
+    /**
+     * @describe 获取教务老师关联的学员商品订单
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/23
+     * @time 14:01
+     * @param params:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentGoodsSellDto>
+     */
+    List<StudentGoodsSellDto> queryStudentGoodsOrders(Map<String, Object> params);
+
+    /**
+     * @describe 根据订单编号获取学员商品订单
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/23
+     * @time 17:04
+     * @param orderNo:
+     * @return com.ym.mec.biz.dal.entity.StudentGoodsSell
+     */
+    StudentGoodsSell findByOrderNo(@Param("orderNo") String orderNo);
+
+    StudentGoodsSellDto getStudentGoodsSellDto(String orderNo);
+}

+ 64 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CalenderPushDto.java

@@ -0,0 +1,64 @@
+package com.ym.mec.biz.dal.dto;
+
+public class CalenderPushDto{
+
+    private Long calenderId;
+
+    private Integer teacherId;
+
+    private String teacherPhone;
+
+    private String musicGroupName;
+
+    private String paymentValidStartDate;
+
+    private String paymentValidEndDate;
+
+    public Integer getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Integer teacherId) {
+        this.teacherId = teacherId;
+    }
+
+    public Long getCalenderId() {
+        return calenderId;
+    }
+
+    public void setCalenderId(Long calenderId) {
+        this.calenderId = calenderId;
+    }
+
+    public String getTeacherPhone() {
+        return teacherPhone;
+    }
+
+    public void setTeacherPhone(String teacherPhone) {
+        this.teacherPhone = teacherPhone;
+    }
+
+    public String getMusicGroupName() {
+        return musicGroupName;
+    }
+
+    public void setMusicGroupName(String musicGroupName) {
+        this.musicGroupName = musicGroupName;
+    }
+
+    public String getPaymentValidStartDate() {
+        return paymentValidStartDate;
+    }
+
+    public void setPaymentValidStartDate(String paymentValidStartDate) {
+        this.paymentValidStartDate = paymentValidStartDate;
+    }
+
+    public String getPaymentValidEndDate() {
+        return paymentValidEndDate;
+    }
+
+    public void setPaymentValidEndDate(String paymentValidEndDate) {
+        this.paymentValidEndDate = paymentValidEndDate;
+    }
+}

+ 62 - 16
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/GoodsSellDto.java

@@ -2,37 +2,83 @@ package com.ym.mec.biz.dal.dto;
 
 import io.swagger.annotations.ApiModelProperty;
 
+import java.math.BigDecimal;
+
 public class GoodsSellDto{
-	@ApiModelProperty(value = "使用余额", required = false)
-	private Boolean isUseBalancePayment;
+	@ApiModelProperty(value = "商品数量", required = false)
+	private Integer goodsNum = 1;
+
+	@ApiModelProperty(value = "商品编号", required = false)
+	private Integer goodsId;
+
+	@ApiModelProperty(value = "商品图片", required = false)
+	private String image;
+
+	@ApiModelProperty(value = "商品名称", required = false)
+	private String goodsName;
+
+	@ApiModelProperty(value = "商品销售类型", required = false)
+	private String goodsType;
+
+	@ApiModelProperty(value = "商品销售价", required = false)
+	private BigDecimal goodsPrice = BigDecimal.ZERO;
 
-	@ApiModelProperty(value = "商品列表", required = false)
-	String goodsId;
+	@ApiModelProperty(value = "商品销售总价", required = false)
+	private BigDecimal totalGoodsPrice = BigDecimal.ZERO;
 
-	@ApiModelProperty(value = "是否重复支付", required = false)
-	private boolean isRepeatPay;
+	public String getGoodsType() {
+		return goodsType;
+	}
+
+	public void setGoodsType(String goodsType) {
+		this.goodsType = goodsType;
+	}
+
+	public BigDecimal getTotalGoodsPrice() {
+		return totalGoodsPrice;
+	}
+
+	public void setTotalGoodsPrice(BigDecimal totalGoodsPrice) {
+		this.totalGoodsPrice = totalGoodsPrice;
+	}
+
+	public BigDecimal getGoodsPrice() {
+		return goodsPrice;
+	}
+
+	public void setGoodsPrice(BigDecimal goodsPrice) {
+		this.goodsPrice = goodsPrice;
+	}
+
+	public String getImage() {
+		return image;
+	}
+
+	public void setImage(String image) {
+		this.image = image;
+	}
 
-	public boolean getIsRepeatPay() {
-		return isRepeatPay;
+	public String getGoodsName() {
+		return goodsName;
 	}
 
-	public void setIsRepeatPay(boolean repeatPay) {
-		isRepeatPay = repeatPay;
+	public void setGoodsName(String goodsName) {
+		this.goodsName = goodsName;
 	}
 
-	public Boolean getIsUseBalancePayment() {
-		return isUseBalancePayment;
+	public Integer getGoodsNum() {
+		return goodsNum;
 	}
 
-	public void setIsUseBalancePayment(Boolean useBalancePayment) {
-		isUseBalancePayment = useBalancePayment;
+	public void setGoodsNum(Integer goodsNum) {
+		this.goodsNum = goodsNum;
 	}
 
-	public String getGoodsId() {
+	public Integer getGoodsId() {
 		return goodsId;
 	}
 
-	public void setGoodsId(String goodsId) {
+	public void setGoodsId(Integer goodsId) {
 		this.goodsId = goodsId;
 	}
 }

+ 38 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentGoodsSellDto.java

@@ -0,0 +1,38 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+
+import java.math.BigDecimal;
+
+public class StudentGoodsSellDto extends StudentPaymentOrder {
+
+    private String goodsJson;
+
+    private BigDecimal totalAmount;
+
+    private BigDecimal marketAmount;
+
+    public String getGoodsJson() {
+        return goodsJson;
+    }
+
+    public void setGoodsJson(String goodsJson) {
+        this.goodsJson = goodsJson;
+    }
+
+    public BigDecimal getTotalAmount() {
+        return totalAmount;
+    }
+
+    public void setTotalAmount(BigDecimal totalAmount) {
+        this.totalAmount = totalAmount;
+    }
+
+    public BigDecimal getMarketAmount() {
+        return marketAmount;
+    }
+
+    public void setMarketAmount(BigDecimal marketAmount) {
+        this.marketAmount = marketAmount;
+    }
+}

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

@@ -86,6 +86,15 @@ public class MusicGroup {
 	/** 缴费截止日期 */
 	@ApiModelProperty(value = "乐团缴费截止日期",required = false)
 	private java.util.Date paymentExpireDate;
+
+	@ApiModelProperty(value = "缴费有效期开始时间", required = false)
+	private String paymentValidStartDate;
+
+	@ApiModelProperty(value = "缴费有效期结束时间", required = false)
+	private String paymentValidEndDate;
+
+	@ApiModelProperty(value = "缴费方式0按月,1按季,2一次性", required = false)
+	private Integer paymentPattern;
 	
 	/** 计费开始日期 */
 	@ApiModelProperty(value = "乐团计费开始日期 ",required = false)
@@ -156,6 +165,30 @@ public class MusicGroup {
 
 	private Boolean hasVerifyMusicalList = false;
 
+	public Integer getPaymentPattern() {
+		return paymentPattern;
+	}
+
+	public void setPaymentPattern(Integer paymentPattern) {
+		this.paymentPattern = paymentPattern;
+	}
+
+	public String getPaymentValidStartDate() {
+		return paymentValidStartDate;
+	}
+
+	public void setPaymentValidStartDate(String paymentValidStartDate) {
+		this.paymentValidStartDate = paymentValidStartDate;
+	}
+
+	public String getPaymentValidEndDate() {
+		return paymentValidEndDate;
+	}
+
+	public void setPaymentValidEndDate(String paymentValidEndDate) {
+		this.paymentValidEndDate = paymentValidEndDate;
+	}
+
 	public String getSubjectName() {
 		return subjectName;
 	}

+ 45 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalender.java

@@ -43,23 +43,32 @@ public class MusicGroupPaymentCalender implements Comparable<MusicGroupPaymentCa
 		}
 	}
 
-	/**  */
 	private Long id;
 
-	/**  */
 	@ApiModelProperty(value = "乐团编号", required = false)
 	private String musicGroupId;
 
-	/** 缴费月份 */
 	@ApiModelProperty(value = "缴费月份", required = false)
 	private Integer paymentMonth;
 
-	/** 开始缴费日期 */
 	@ApiModelProperty(value = "开始缴费日期", required = false)
 	private java.util.Date startPaymentDate;
 
+	@ApiModelProperty(value = "截止缴费日期", required = false)
 	private Date deadlinePaymentDate;
 
+	@ApiModelProperty(value = "缴费有效期开始时间", required = false)
+	private String paymentValidStartDate;
+
+	@ApiModelProperty(value = "缴费有效期截止时间", required = false)
+	private String paymentValidEndDate;
+
+	@ApiModelProperty(value = "缴费方式0按月,1按季,2一次性", required = false)
+	private Integer paymentPattern;
+
+	@ApiModelProperty(value = "缴费类型0续费,1报名", required = false)
+	private Integer paymentType;
+
 	private PaymentStatusEnum paymentStatus;
 
 	private Integer expectNum;
@@ -70,14 +79,44 @@ public class MusicGroupPaymentCalender implements Comparable<MusicGroupPaymentCa
 
 	private FeeType type;
 
-	/**  */
 	private java.util.Date createTime;
 
-	/**  */
 	private java.util.Date updateTime;
 
 	private String studentIds;
 
+	public Integer getPaymentType() {
+		return paymentType;
+	}
+
+	public void setPaymentType(Integer paymentType) {
+		this.paymentType = paymentType;
+	}
+
+	public Integer getPaymentPattern() {
+		return paymentPattern;
+	}
+
+	public void setPaymentPattern(Integer paymentPattern) {
+		this.paymentPattern = paymentPattern;
+	}
+
+	public String getPaymentValidStartDate() {
+		return paymentValidStartDate;
+	}
+
+	public void setPaymentValidStartDate(String paymentValidStartDate) {
+		this.paymentValidStartDate = paymentValidStartDate;
+	}
+
+	public String getPaymentValidEndDate() {
+		return paymentValidEndDate;
+	}
+
+	public void setPaymentValidEndDate(String paymentValidEndDate) {
+		this.paymentValidEndDate = paymentValidEndDate;
+	}
+
 	public String getStudentIds() {
 		return studentIds;
 	}

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

@@ -58,6 +58,9 @@ public class MusicGroupStudentFee {
 	@ApiModelProperty(value = "最近缴费时间", required = false)
 	private Date latestPaidTime;
 
+	@ApiModelProperty(value = "缴费有效期结束时间", required = false)
+	private String paymentValidEndDate;
+
 	@ApiModelProperty(value = "连续旷到次数", required = false)
 	private Integer continuousAbsenteeismTimes;
 
@@ -98,6 +101,14 @@ public class MusicGroupStudentFee {
 	public MusicGroupStudentFee() {
 	}
 
+	public String getPaymentValidEndDate() {
+		return paymentValidEndDate;
+	}
+
+	public void setPaymentValidEndDate(String paymentValidEndDate) {
+		this.paymentValidEndDate = paymentValidEndDate;
+	}
+
 	public SysUser getSysUser() {
 		return sysUser;
 	}

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SellOrder.java

@@ -53,19 +53,19 @@ public class SellOrder {
     * 应付金额
     */
     @ApiModelProperty(value="应付金额")
-    private BigDecimal expectAmount;
+    private BigDecimal expectAmount = BigDecimal.ZERO;
 
     /**
     * 现金支付金额
     */
     @ApiModelProperty(value="现金支付金额")
-    private BigDecimal actualAmount;
+    private BigDecimal actualAmount = BigDecimal.ZERO;
 
     /**
     * 余额支付金额
     */
     @ApiModelProperty(value="余额支付金额")
-    private BigDecimal balanceAmount;
+    private BigDecimal balanceAmount = BigDecimal.ZERO;
 
     /**
     * 销售成本

+ 172 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentGoodsSell.java

@@ -0,0 +1,172 @@
+package com.ym.mec.biz.dal.entity;
+
+import com.ym.mec.biz.dal.dto.GoodsSellDto;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 对应数据库表(student_goods_sell):
+ */
+public class StudentGoodsSell {
+
+	private Integer id;
+	
+	@ApiModelProperty(value = "用户编号",required = true)
+	private Integer userId;
+	
+	@ApiModelProperty(value = "教师编号",required = true)
+	private Integer teacherId;
+	
+	@ApiModelProperty(value = "商品列表",required = true)
+	private String goodsJson;
+
+	@ApiModelProperty(value = "订单编号",required = true)
+	private String orderNo;
+	
+	@ApiModelProperty(value = "总金额",required = true)
+	private java.math.BigDecimal totalAmount = BigDecimal.ZERO;
+	
+	@ApiModelProperty(value = "减免费用",required = true)
+	private java.math.BigDecimal marketAmount = BigDecimal.ZERO;
+
+	private Date createTime;
+
+	private Date updateTime;
+
+	@ApiModelProperty(value = "是否使用余额",required = true)
+	private Boolean isUseBalancePayment = false;
+
+	@ApiModelProperty(value = "是否重复支付",required = true)
+	private boolean isRepeatPay;
+
+	@ApiModelProperty(value = "商品列表",required = true)
+	private List<GoodsSellDto> goodsSellDtos;
+
+	@ApiModelProperty(value = "支付类型",required = true)
+	private Integer type = 0;
+
+	@ApiModelProperty(value = "分部编号", required = false)
+	private Integer organId;
+
+	public Integer getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(Integer organId) {
+		this.organId = organId;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public List<GoodsSellDto> getGoodsSellDtos() {
+		return goodsSellDtos;
+	}
+
+	public void setGoodsSellDtos(List<GoodsSellDto> goodsSellDtos) {
+		this.goodsSellDtos = goodsSellDtos;
+	}
+
+	public String getOrderNo() {
+		return orderNo;
+	}
+
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+
+	public boolean getIsRepeatPay() {
+		return isRepeatPay;
+	}
+
+	public void setIsRepeatPay(boolean repeatPay) {
+		isRepeatPay = repeatPay;
+	}
+
+	public Boolean getIsUseBalancePayment() {
+		return isUseBalancePayment;
+	}
+
+	public void setIsUseBalancePayment(Boolean useBalancePayment) {
+		isUseBalancePayment = useBalancePayment;
+	}
+
+	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 void setId(Integer id){
+		this.id = id;
+	}
+	
+	public Integer getId(){
+		return this.id;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setTeacherId(Integer teacherId){
+		this.teacherId = teacherId;
+	}
+	
+	public Integer getTeacherId(){
+		return this.teacherId;
+	}
+			
+	public void setGoodsJson(String goodsJson){
+		this.goodsJson = goodsJson;
+	}
+	
+	public String getGoodsJson(){
+		return this.goodsJson;
+	}
+			
+	public void setTotalAmount(java.math.BigDecimal totalAmount){
+		this.totalAmount = totalAmount;
+	}
+	
+	public java.math.BigDecimal getTotalAmount(){
+		return this.totalAmount;
+	}
+			
+	public void setMarketAmount(java.math.BigDecimal marketAmount){
+		this.marketAmount = marketAmount;
+	}
+	
+	public java.math.BigDecimal getMarketAmount(){
+		return this.marketAmount;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MessageTypeEnum.java

@@ -154,6 +154,8 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     SMS_REPAIR_ONLINE_PAYMENT_SUCCESS("SMS_REPAIR_ONLINE_PAYMENT_SUCCESS","乐器线上维修支付成功"),
     SMS_REPAIR_OFFLINE_PAYMENT_SUCCESS("SMS_REPAIR_OFFLINE_PAYMENT_SUCCESS","乐器线下维修支付成功"),
     SMS_REPAIR_UNSEND_COMPLETED("SMS_REPAIR_UNSEND_COMPLETED","乐器维修完成自取"),
+    SMS_PAYMENT_DETAIL("SMS_PAYMENT_DETAIL","缴费项目缴费详情提醒"),
+    SMS_PAYMENT_CREATE("SMS_PAYMENT_CREATE","缴费项目创建提醒"),
     SMS_REPAIR_SEND_COMPLETED("SMS_REPAIR_SEND_COMPLETED","乐器维修完成邮寄");
 
 

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java

@@ -302,7 +302,7 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 
 	/**
 	 * @describe 临时课检测
-	 * @author Joburgess
+	 * @author 周剑河
 	 * @date 2019/12/6
 	 * @param courseSchedules: 课程计划列表
 	 * @return void

+ 13 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -40,11 +40,9 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 
 	/**
 	 * 修改缴费日期
-	 * @param startTime
-	 * @param endTime
-	 * @param id
+	 * @param paymentCalender
 	 */
-    void updateStartTime(Date startTime,Date endTime,Long id);
+    void updateStartTime(MusicGroupPaymentCalender paymentCalender);
 
 	/**
 	 * 删除
@@ -73,4 +71,15 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	 * @return
 	 */
 	void paymentPush(Long id, String userIds);
+
+	/**
+	 * @describe 更新乐团学员缴费状态
+	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+	 * @author zouxuan
+	 * @date 2020/9/21
+	 * @time 13:56
+	 * @param :
+	 * @return void
+	 */
+	void autoUpdateMusicGroupStudentFeeStatus();
 }

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

@@ -31,4 +31,5 @@ public interface SellOrderService extends BaseService<Integer, SellOrder> {
      */
     List<SellOrder> addOrderDetail2SellOrder(List<StudentPaymentOrderDetail> orderDetails, StudentPaymentOrder studentPaymentOrder, MusicGroup musicGroup);
 
+    void batchInsert(List<SellOrder> sellOrders);
 }

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

@@ -0,0 +1,20 @@
+package com.ym.mec.biz.service;
+
+
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.common.service.BaseService;
+
+public interface StudentGoodsSellService extends BaseService<Integer, StudentGoodsSell> {
+
+    /**
+     * @describe 分页查询教务老师关联的学员订单
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/9/23
+     * @time 11:51
+     * @param queryInfo:
+     * @return java.lang.Object
+     */
+    Object queryStudentGoodsOrders(QueryInfo queryInfo);
+}

+ 5 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRepairService.java

@@ -1,16 +1,14 @@
 package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.BasicUserDto;
-import com.ym.mec.biz.dal.dto.GoodsSellDto;
+import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
-import org.springframework.stereotype.Service;
 
-import java.math.BigDecimal;
-import java.util.Date;
 import java.util.Map;
 
 public interface StudentRepairService extends BaseService<Integer, StudentRepair> {
@@ -75,10 +73,10 @@ public interface StudentRepairService extends BaseService<Integer, StudentRepair
      * @author zouxuan
      * @date 2020/9/16
      * @time 13:47
-     * @param goodsSellDto:
+     * @param studentGoodsSell:
      * @return java.util.Map
      */
-    Map addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception;
+    Map addGoodsSellOrder(StudentGoodsSell studentGoodsSell) throws Exception;
 
     /**
      * @describe 商品销售订单回调
@@ -89,5 +87,5 @@ public interface StudentRepairService extends BaseService<Integer, StudentRepair
      * @param order:
      * @return void
      */
-    void goodsSellorderCallback(StudentPaymentOrder order);
+    void goodsSellOrderCallback(StudentPaymentOrder order);
 }

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

@@ -1929,7 +1929,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                         }
                         //助教冲突检测
                         if (Objects.isNull(preCourseSchedule.getId())) {
-                            IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(preCourseSchedule.getClassGroupId());
+                            IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(preCourseSchedule.getClassGroupId().longValue());
                             if (Objects.nonNull(integerAndIntegerListDto)) {
                                 preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
                             }
@@ -1940,7 +1940,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                             }
                         }
                         if (Objects.isNull(backCourseSchedule.getId())) {
-                            IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(backCourseSchedule.getClassGroupId());
+                            IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(backCourseSchedule.getClassGroupId().longValue());
                             if (Objects.nonNull(integerAndIntegerListDto)) {
                                 backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
                             }

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

@@ -58,7 +58,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
 		List<FinancialExpenditure> financialExpenditures = new ArrayList<>();
 		Map<String, Integer> organMap = getMap("organization", "name_", "id_", true, String.class, Integer.class);
 		Map<String, Integer> cooperationOrganMap = getMap("cooperation_organ", "name_", "id_", true, String.class, Integer.class);
-		Map<String, Integer> phoneMap = getMap("sys_user", "phone_", "id_", true, String.class, Integer.class);
+//		Map<String, Integer> phoneMap = getMap("sys_user", "phone_", "id_", true, String.class, Integer.class);
 		for (String e : sheetsListMap.keySet()) {
 			List<Map<String, Object>> sheet = sheetsListMap.get(e);
 			List<Object> collect = sheet.stream().map(m -> m.get("钉钉流程编号")).collect(Collectors.toList());

+ 63 - 14
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.*;
+import com.ym.mec.biz.dal.dto.CalenderPushDto;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
@@ -35,10 +36,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
-
 	@Autowired
 	private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
-
 	@Autowired
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
 	@Autowired
@@ -70,13 +69,18 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		}
 		// 判断缴费开始时间、结束时间是否被其他缴费记录占用
 		int count = musicGroupPaymentCalenderDao.queryIntersectionByPaymentDate(musicGroupId, musicGroupPaymentCalender.getStartPaymentDate(),
-				musicGroupPaymentCalender.getDeadlinePaymentDate());
+				musicGroupPaymentCalender.getDeadlinePaymentDate(),null);
 
 //		String format = DateUtil.format(musicGroupPaymentCalender.getStartPaymentDate(), DateUtil.DEFAULT_PATTERN);
 //		String format1 = DateUtil.format(musicGroupPaymentCalender.getDeadlinePaymentDate(), DateUtil.DEFAULT_PATTERN);
 //		int count = musicGroupPaymentCalenderDao.queryIntersectionByDate(musicGroupId, format,format1);
 		if (count > 0) {
-			throw new BizException("缴费时间存在冲突,请修改缴费开始日期");
+			throw new BizException("缴费日期存在冲突,请修改缴费日期");
+		}
+		count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(musicGroupId, musicGroupPaymentCalender.getPaymentValidStartDate(),
+				musicGroupPaymentCalender.getPaymentValidEndDate(),null);
+		if (count > 0) {
+			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
 		}
 		if (date.after(musicGroupPaymentCalender.getDeadlinePaymentDate())) {
 			musicGroupPaymentCalender.setPaymentStatus(PaymentStatusEnum.YES);
@@ -149,6 +153,45 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	}
 
 	@Override
+	public void autoUpdateMusicGroupStudentFeeStatus() {
+		Date date = new Date();
+		String format = DateUtil.format(date, DateUtil.DEFAULT_PATTERN);
+		//将有效期已截止的学员缴费信息修改为未缴费
+		musicGroupStudentFeeDao.updateFeeStatus();
+		//获取距离缴费开启指定天数后的缴费明细
+		String configValue = sysConfigDao.findConfigValue("push_payment_detail");
+		Map<Long, Long> maps = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.queryCalenderByDay(configValue));
+		if(maps != null && maps.size() > 0){
+			Set<Long> calenderId = maps.keySet();
+			List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getCalenderPushDto(calenderId);
+			Map<Long, List<CalenderPushDto>> collect = calenderPushDtos.stream().collect(Collectors.groupingBy(CalenderPushDto::getCalenderId));
+			calenderId.forEach(e->{
+				CalenderPushDto calenderPushDto = collect.get(e).get(0);
+				Map<Integer, String> receivers = new HashMap<>(1);
+				receivers.put(calenderPushDto.getTeacherId(),calenderPushDto.getTeacherPhone());
+				sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.SMS_PAYMENT_DETAIL,
+						receivers, null, 0, null, null,calenderPushDto.getMusicGroupName(),
+						calenderPushDto.getPaymentValidStartDate(),calenderPushDto.getPaymentValidEndDate(),maps.get(e));
+			});
+		}
+		//获取离截止还有指定时间的缴费项,并发送推送消息给指定老师
+		String configValue1 = sysConfigDao.findConfigValue("push_create_payment_calender");
+		List<Long> calenderIds = musicGroupPaymentCalenderDao.queryEndIds(configValue1,format);
+		if(calenderIds != null && calenderIds.size() > 0){
+			List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getCalenderPushDto(calenderIds);
+			Map<Long, List<CalenderPushDto>> collect = calenderPushDtos.stream().collect(Collectors.groupingBy(CalenderPushDto::getCalenderId));
+			calenderIds.forEach(e->{
+				CalenderPushDto calenderPushDto = collect.get(e).get(0);
+				Map<Integer, String> receivers = new HashMap<>(1);
+				receivers.put(calenderPushDto.getTeacherId(),calenderPushDto.getTeacherPhone());
+				sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI, MessageTypeEnum.SMS_PAYMENT_CREATE,
+						receivers, null, 0, null, null,calenderPushDto.getMusicGroupName(),
+						calenderPushDto.getPaymentValidStartDate(),calenderPushDto.getPaymentValidEndDate());
+			});
+		}
+	}
+
+	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public boolean autoUpdateMusicGroupPaymentCalenderStatus() {
 		// 获取当天创建且未缴费的数据,并推送
@@ -342,11 +385,11 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void updateStartTime(Date startTime,Date endTime,Long id) {
-		if (startTime == null || id == null || endTime == null) {
-			throw new BizException("参数校验失败");
-		}
-		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(id);
+	public void updateStartTime(MusicGroupPaymentCalender paymentCalender) {
+//		if (startTime == null || id == null || endTime == null) {
+//			throw new BizException("参数校验失败");
+//		}
+		MusicGroupPaymentCalender calender = musicGroupPaymentCalenderDao.get(paymentCalender.getId());
 		if (calender == null) {
 			throw new BizException("缴费信息不存在");
 		}
@@ -355,19 +398,25 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		}
 		Date date = new Date();
 		// 判断缴费开始时间、结束时间是否被其他缴费记录占用
-		int count = musicGroupPaymentCalenderDao.queryIntersectionByPaymentDate(calender.getMusicGroupId(), startTime,endTime);
+		int count = musicGroupPaymentCalenderDao.queryIntersectionByPaymentDate(calender.getMusicGroupId(), paymentCalender.getStartPaymentDate(),paymentCalender.getDeadlinePaymentDate(),paymentCalender.getId());
 //		String format = DateUtil.format(startTime, DateUtil.DEFAULT_PATTERN);
 //		String format1 = DateUtil.format(endTime, DateUtil.DEFAULT_PATTERN);
 //		int count = musicGroupPaymentCalenderDao.queryIntersectionByDate(calender.getMusicGroupId(), format,format1);
 		if (count > 0) {
 			throw new BizException("缴费时间存在冲突,请修改缴费开始日期");
 		}
-		calender.setStartPaymentDate(startTime);
-		calender.setDeadlinePaymentDate(endTime);
+		count = musicGroupPaymentCalenderDao.queryIntersectionByValidDate(calender.getMusicGroupId(), paymentCalender.getPaymentValidStartDate(),
+				paymentCalender.getPaymentValidEndDate(),paymentCalender.getId());
+		if (count > 0) {
+			throw new BizException("缴费有效期存在冲突,请修改缴费有效期");
+		}
+		calender.setStartPaymentDate(paymentCalender.getStartPaymentDate());
+		calender.setDeadlinePaymentDate(paymentCalender.getDeadlinePaymentDate());
+		calender.setPaymentPattern(paymentCalender.getPaymentPattern());
 		calender.setUpdateTime(date);
-		if (endTime.before(date) && !DateUtil.isSameDay(date,endTime)) {
+		if (paymentCalender.getDeadlinePaymentDate().before(date) && !DateUtil.isSameDay(date,paymentCalender.getDeadlinePaymentDate())) {
 			calender.setPaymentStatus(PaymentStatusEnum.YES);
-		} else if (date.after(startTime) || DateUtil.isSameDay(date,endTime)) {
+		} else if (date.after(paymentCalender.getStartPaymentDate()) || DateUtil.isSameDay(date,paymentCalender.getStartPaymentDate())) {
 			calender.setPaymentStatus(PaymentStatusEnum.OPEN);
 			//修改Fee缴费状态为未缴费
 			musicGroupStudentFeeDao.updatePaymentStatus(calender.getId(),"NON_PAYMENT");

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

@@ -26,7 +26,6 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
-
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -1758,6 +1757,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
                 musicGroupStudentFee.setRemainNetworkClassTimes(getRemainNetworkClassTimes + 1);
             }
 //            musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, musicGroupStudentFee.getNextPaymentDate(), musicGroupStudentFee));
+            musicGroupStudentFee.setPaymentValidEndDate(musicGroupPaymentCalender.getPaymentValidEndDate());
             musicGroupStudentFeeDao.update(musicGroupStudentFee);
 
             //更新学生的缴费记录状态

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -214,4 +214,9 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         return sellOrders;
     }
 
+    @Override
+    public void batchInsert(List<SellOrder> sellOrders) {
+        sellOrderDao.batchInsert(sellOrders);
+    }
+
 }

+ 51 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentGoodsSellServiceImpl.java

@@ -0,0 +1,51 @@
+package com.ym.mec.biz.service.impl;
+
+
+import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
+import com.ym.mec.biz.dal.dto.StudentGoodsSellDto;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.biz.service.StudentGoodsSellService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class StudentGoodsSellServiceImpl extends BaseServiceImpl<Integer, StudentGoodsSell> implements StudentGoodsSellService {
+	
+	@Autowired
+	private StudentGoodsSellDao studentGoodsSellDao;
+
+	@Override
+	public BaseDAO<Integer, StudentGoodsSell> getDAO() {
+		return studentGoodsSellDao;
+	}
+
+	@Override
+	public PageInfo<StudentGoodsSellDto> queryStudentGoodsOrders(QueryInfo queryInfo) {
+		//根据订单状态和教务老师获取订单列表
+		PageInfo<StudentGoodsSellDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		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);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+}

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

@@ -246,7 +246,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
             studentRepairService.orderCallback(order);
         } else if (order.getType().equals(OrderTypeEnum.GOODS_SELL)) {
-            studentRepairService.goodsSellorderCallback(order);
+            studentRepairService.goodsSellOrderCallback(order);
         }
     }
 
@@ -283,7 +283,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 } else if (order.getType().equals(OrderTypeEnum.REPAIR)) {
                     studentRepairService.orderCallback(order);
                 } else if (order.getType().equals(OrderTypeEnum.GOODS_SELL)) {
-                    studentRepairService.goodsSellorderCallback(order);
+                    studentRepairService.goodsSellOrderCallback(order);
                 }
             } catch (Exception e) {
                 e.printStackTrace();

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -704,9 +704,13 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             MusicGroupStudentFee musicGroupStudentFee = new MusicGroupStudentFee(musicGroupId,
                     userId, studentRegistration.getSubjectId(), studentAddDto.getCourseFee(),
                     null, studentAddDto.getTemporaryCourseFee(), paymentStatus);
+
             if (musicGroup.getFeeType() != null && musicGroup.getFeeType() != MusicGroupPaymentCalender.FeeType.OFFLINE && musicGroupStudentFee.getTemporaryCourseFee().doubleValue() * 100 == 0) {
                 musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
             }
+            if(studentRegistration.getPaymentStatus() == PaymentStatusEnum.YES){
+                musicGroupStudentFee.setPaymentValidEndDate(musicGroup.getPaymentValidEndDate());
+            }
             musicGroupStudentFeeDao.insert(musicGroupStudentFee);
 //            musicGroupStudentFeeDao.insert(new MusicGroupStudentFee(musicGroupId,
 //                    userId, studentRegistration.getSubjectId(), studentAddDto.getCourseFee(),
@@ -872,6 +876,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 if (musicGroup.getFeeType() != null && musicGroup.getFeeType() != MusicGroupPaymentCalender.FeeType.OFFLINE) {
                     musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
                 }
+                musicGroupStudentFee.setPaymentValidEndDate(musicGroup.getPaymentValidEndDate());
                 musicGroupStudentFee.setUpdateTime(nowDate);
                 musicGroupStudentFeeDao.update(musicGroupStudentFee);
                 //添加学生

+ 91 - 22
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -5,8 +5,8 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.SellOrderDao;
 import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dao.StudentGoodsSellDao;
 import com.ym.mec.biz.dal.dao.StudentRepairDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
@@ -28,6 +28,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -61,15 +62,15 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     @Autowired
     private StudentDao studentDao;
     @Autowired
-    private GoodsService goodsService;
-    @Autowired
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     @Autowired
     private SellOrderService sellOrderService;
     @Autowired
-    private SellOrderDao sellOrderDao;
+    private StudentGoodsSellDao studentGoodsSellDao;
     @Autowired
     private ContractService contractService;
+    @Autowired
+    private GoodsService goodsService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -106,12 +107,12 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
-    public Map addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception {
+    @Transactional(rollbackFor = Exception.class,isolation = Isolation.SERIALIZABLE)
+    public Map addGoodsSellOrder(StudentGoodsSell studentGoodsSell) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Integer studentId = sysUser.getId();
-        String goodsId = goodsSellDto.getGoodsId();
-        if (StringUtils.isEmpty(goodsId)) {
+        List<GoodsSellDto> goodsSellDtos = studentGoodsSell.getGoodsSellDtos();
+        if(goodsSellDtos == null || goodsSellDtos.size() == 0){
             throw new BizException("请选择需要购买的商品");
         }
         if (studentId == null) {
@@ -120,14 +121,42 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         studentDao.lockUser(studentId);
         SysUser student = sysUserFeignService.queryUserById(studentId);
         String orderNo = idGeneratorService.generatorId("payment") + "";
+        studentGoodsSell.setOrderNo(orderNo);
 
-        String[] goodsIds = goodsId.split(",");
-        Map<String, BigDecimal> map = getMap("goods", "id_", "group_purchase_price_", goodsId, String.class, BigDecimal.class);
+        List<Integer> goodsIds = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+
+//        String[] goodsIds = goodsJson.split(",");
+        Map<Integer, BigDecimal> map = getMap("goods", "id_", "market_price_", goodsIds, Integer.class, BigDecimal.class);
+        for (GoodsSellDto goodsSellDto : goodsSellDtos) {
+            goodsSellDto.setGoodsPrice(map.get(goodsSellDto.getGoodsId()));
+            goodsSellDto.setTotalGoodsPrice(map.get(goodsSellDto.getGoodsId()).multiply(new BigDecimal(goodsSellDto.getGoodsNum())));
+        }
+        Map<Integer, List<GoodsSellDto>> goodsMap = goodsSellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
         BigDecimal amount = BigDecimal.ZERO;
-        for (String id : goodsIds) {
-            amount.add(map.get(id));
+        for (Integer id : goodsIds) {
+            GoodsSellDto goodsSellDto = goodsMap.get(id).get(0);
+            amount = amount.add(goodsSellDto.getTotalGoodsPrice());
+        }
+        amount = amount.subtract(studentGoodsSell.getMarketAmount());
+        if(amount.signum() < 0){
+            throw new BizException("操作失败:订单金额异常");
+        }
+        studentGoodsSell.setOrganId(sysUser.getOrganId());
+        studentGoodsSell.setTotalAmount(amount);
+        studentGoodsSell.setGoodsJson(JSONObject.toJSONString(goodsSellDtos));
+        if(studentGoodsSell.getId() == null){
+            studentGoodsSellDao.insert(studentGoodsSell);
+        }else {
+            studentGoodsSellDao.update(studentGoodsSell);
         }
-        List<Goods> goods = goodsService.findGoodsByIds(goodsId);
+
+        if (studentGoodsSell.getType() == 1) {
+            Map<String, Object> repairInfoMap = new HashMap<>();
+            MapUtil.populateMap(repairInfoMap, studentGoodsSell);
+            return repairInfoMap;
+        }
+
+//        List<Goods> goods = goodsService.findGoodsByIds(StringUtils.join(goodsIds,","));
 
         StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
         studentPaymentOrder.setUserId(studentId);
@@ -141,7 +170,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         studentPaymentOrder.setRoutingOrganId(student.getOrganId());
         studentPaymentOrderService.insert(studentPaymentOrder);
 
-        Map<Integer, List<Goods>> collect = goods.stream().collect(Collectors.groupingBy(Goods::getId));
+        /*Map<Integer, List<Goods>> collect = goods.stream().collect(Collectors.groupingBy(Goods::getId));
         List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
         for (String id : goodsIds) {
             Goods e = collect.get(id).get(0);
@@ -162,11 +191,11 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             studentPaymentOrderDetail.setKitGroupPurchaseType(KitGroupPurchaseTypeEnum.GROUP);
             studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
         }
-        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);*/
 
         studentPaymentOrder.setVersion(0);
         BigDecimal balance = BigDecimal.ZERO;
-        if (goodsSellDto.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
+        if (studentGoodsSell.getIsUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
             SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(studentId);
             if (userCashAccount == null) {
                 throw new BizException("用户账户不存在");
@@ -509,7 +538,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-    public void goodsSellorderCallback(StudentPaymentOrder studentPaymentOrder) {
+    public void goodsSellOrderCallback(StudentPaymentOrder studentPaymentOrder) {
         Date nowDate = new Date();
         //更新订单信息
         studentPaymentOrder.setUpdateTime(nowDate);
@@ -555,11 +584,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
             }
             sysUserCashAccountDetailService.insert(paymentDetail);
-            //销售订单详情
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.getOrderDetail(studentPaymentOrder.getId());
-            if (orderDetails.size() > 0) {
-                sellOrderService.addOrderDetail2SellOrder(orderDetails, studentPaymentOrder, null);
-            }
+            saveSellOrder(studentPaymentOrder.getOrderNo());
         } else 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, "乐器维修支付失败");
@@ -567,6 +592,50 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         }
     }
 
+    private void saveSellOrder(String orderNo){
+        StudentPaymentOrder orderByOrderNo = studentPaymentOrderService.findOrderByOrderNo(orderNo);
+        StudentGoodsSell studentGoodsSell = studentGoodsSellDao.findByOrderNo(orderNo);
+        String goodsJson = studentGoodsSell.getGoodsJson();
+        List<GoodsSellDto> goodsSellDtos = JSONObject.parseArray(goodsJson, GoodsSellDto.class);
+        Map<Integer, List<GoodsSellDto>> collect = goodsSellDtos.stream().collect(Collectors.groupingBy(GoodsSellDto::getGoodsId));
+        List<Integer> goodsId = goodsSellDtos.stream().map(e -> e.getGoodsId()).collect(Collectors.toList());
+        List<Goods> goodsByIds = goodsService.findGoodsByIds(StringUtils.join(goodsId, ","));
+        Map<Integer, List<Goods>> goodsMap = goodsByIds.stream().collect(Collectors.groupingBy(Goods::getId));
+        Map<String, BigDecimal> costMap = new HashMap<>(2);
+        List<SellOrder> sellOrders = new ArrayList<>();
+        goodsId.forEach(e->{
+            GoodsSellDto goodsSellDto = collect.get(e).get(0);
+            Goods goods = goodsMap.get(e).get(0);
+
+            costMap.put("sellCost", goods.getDiscountPrice());
+            if (goods.getAgreeCostPrice() != null) {
+                costMap.put("SellCost2", goods.getAgreeCostPrice());
+            }
+            SellOrder sellOrder = new SellOrder();
+            sellOrder.setOrganId(orderByOrderNo.getOrganId());
+            sellOrder.setTransNo(orderByOrderNo.getTransNo());
+            sellOrder.setOrderId(orderByOrderNo.getId());
+            sellOrder.setOrderNo(orderByOrderNo.getOrderNo());
+            sellOrder.setExpectAmount(orderByOrderNo.getExpectAmount());
+            sellOrder.setActualAmount(orderByOrderNo.getActualAmount());
+            sellOrder.setBalanceAmount(orderByOrderNo.getBalancePaymentAmount());
+            sellOrder.setSellCost(goods.getDiscountPrice());
+            sellOrder.setSellCost2(JSONObject.toJSONString(costMap));
+            sellOrder.setType(SellTypeEnum.valueOf(goods.getType().getCode()));
+            sellOrder.setGoodsId(e);
+            sellOrder.setGoodsName(goods.getName());
+            sellOrder.setNum(goodsSellDto.getGoodsNum());
+            sellOrder.setUserId(studentGoodsSell.getUserId());
+            sellOrder.setPaymentChannel(orderByOrderNo.getPaymentChannel());
+            sellOrder.setMerNo(orderByOrderNo.getMerNos());
+            sellOrder.setSellTime(orderByOrderNo.getPayTime());
+            sellOrders.add(sellOrder);
+        });
+        if(sellOrders.size() > 0){
+            sellOrderService.batchInsert(sellOrders);
+        }
+    }
+
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public Boolean orderCallback(StudentPaymentOrder studentPaymentOrder) {

+ 14 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -36,6 +36,9 @@
                 typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="fee_type_" property="feeType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="del_flag_" property="delFlag"/>
+        <result column="payment_valid_start_date_" property="paymentValidStartDate"/>
+        <result column="payment_valid_end_date_" property="paymentValidEndDate"/>
+        <result column="payment_pattern_" property="paymentPattern"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -68,7 +71,7 @@
          bill_start_date_, improvent_classes_num_, enroll_classes_, payment_expire_date_, is_extra_class_,
          settlement_type_, cooperation_organ_id_, enlightenment_course_time_,
          parent_meeting_time_, img_, director_user_id_, is_classroom_lessons_, memo_, expect_start_group_date_,
-         ownership_type_, repair_user_id_, fee_type_, del_flag_)
+         ownership_type_, repair_user_id_, fee_type_, del_flag_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_)
         VALUES (#{id}, #{name}, #{organId}, #{schoolId}, #{applyExpireDate}, #{teamTeacherId}, #{educationalTeacherId},
                 #{chargeTypeId}, #{courseForm}, now(), now(),
                 #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{billStartDate},
@@ -78,13 +81,22 @@
                 #{cooperationOrganId}, #{enlightenmentCourseTime}, #{parentMeetingTime}, #{img}, #{directorUserId},
                 #{isClassroomLessons}, #{memo}, #{expectStartGroupDate},
                 #{ownershipType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{repairUserId},
-                #{feeType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{delFlag})
+                #{feeType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{delFlag},#{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroup">
         UPDATE music_group
         <set>
+            <if test="paymentPattern != null">
+                payment_pattern_ = #{paymentPattern},
+            </if>
+            <if test="paymentValidStartDate != null">
+                payment_valid_start_date_ = #{paymentValidStartDate},
+            </if>
+            <if test="paymentValidEndDate != null">
+                payment_valid_end_date_ = #{paymentValidEndDate},
+            </if>
             <if test="ownershipType != null">
                 ownership_type_ = #{ownershipType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>

+ 70 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -19,6 +19,10 @@
         <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
+        <result column="payment_valid_start_date_" property="paymentValidStartDate"/>
+        <result column="payment_valid_end_date_" property="paymentValidEndDate"/>
+        <result column="payment_pattern_" property="paymentPattern"/>
+        <result column="payment_type_" property="paymentType"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -35,9 +39,11 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
         INSERT INTO music_group_payment_calender
-        (music_group_id_,payment_month_,start_payment_date_,deadline_payment_date_,payment_status_,expect_num_,actual_num_,memo_,type_,create_time_,update_time_)
+        (music_group_id_,payment_month_,start_payment_date_,deadline_payment_date_,payment_status_,expect_num_,
+        actual_num_,memo_,type_,create_time_,update_time_,payment_valid_start_date_,payment_valid_end_date_,payment_pattern_,payment_type_)
         VALUES(#{musicGroupId},#{paymentMonth},#{startPaymentDate},#{deadlinePaymentDate},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{expectNum},#{actualNum},#{memo},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},now(),now())
+        #{expectNum},#{actualNum},#{memo},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},now(),now(),
+        #{paymentValidStartDate},#{paymentValidEndDate},#{paymentPattern},#{paymentType})
     </insert>
     <insert id="batchAdd">
         INSERT INTO music_group_payment_calender
@@ -52,6 +58,16 @@
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender">
         UPDATE music_group_payment_calender
         <set>
+            <if test="paymentType != null">
+                payment_type_ = #{paymentType},
+            </if>
+            <if test="paymentValidStartDate != null">
+                payment_valid_start_date_ = #{paymentValidStartDate},
+                payment_valid_end_date_ = #{paymentValidEndDate},
+            </if>
+            <if test="paymentPattern != null">
+                payment_pattern_ = #{paymentPattern},
+            </if>
             <if test="type != null">
                 type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             </if>
@@ -90,6 +106,9 @@
 	    <foreach collection="list" item="item" index="index" open="" close="" separator=";">
 	        UPDATE music_group_payment_calender
 	        <set>
+                <if test="paymentPattern != null">
+                    payment_pattern_ = #{paymentPattern},
+                </if>
 	            <if test="item.type != null">
 	                type_ = #{item.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
 	            </if>
@@ -175,6 +194,9 @@
         WHERE music_group_id_ = #{musicGroupId} 
         and (start_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate}
         or deadline_payment_date_ between #{startPaymentDate} and #{deadlinePaymentDate})
+        <if test="calenderId != null">
+            AND mgpc.id_ != #{calenderId}
+        </if>
     </select>
     <select id="countExpectNum" resultType="java.util.Map">
         SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(DISTINCT mgpcd.user_id_) 'value' FROM music_group_payment_calender_detail mgpcd
@@ -204,4 +226,50 @@
         AND (DATE_FORMAT(mgpcd.start_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime}
         OR DATE_FORMAT(mgpcd.deadline_payment_date_,'%Y-%m-%d') between #{startTime} AND #{endTime})
     </select>
+    <select id="queryIntersectionByValidDate" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM music_group_payment_calender mgpc
+        WHERE music_group_id_ = #{musicGroupId}
+        AND (payment_valid_end_date_ IS NULL OR payment_valid_start_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate}
+        OR payment_valid_end_date_ BETWEEN #{paymentValidStartDate} AND #{paymentValidEndDate})
+        <if test="calenderId != null">
+            AND mgpc.id_ = #{calenderId}
+        </if>
+    </select>
+    <select id="queryCalenderByDay" resultType="java.util.Map">
+        SELECT mgpcd.music_group_payment_calender_id_ 'key',COUNT(mgpcd.payment_status_) 'value'
+        FROM music_group_payment_calender_detail mgpcd
+        WHERE mgpcd.music_group_payment_calender_id_ IN
+        (SELECT id_ FROM music_group_payment_calender WHERE payment_status_ != 0 AND DATEDIFF('',DATE_FORMAT(start_payment_date_,'%Y-%m-%d')) = #{configValue})
+        AND mgpcd.payment_status_ = 'NON_PAYMENT'
+        GROUP BY mgpcd.music_group_payment_calender_id_
+    </select>
+    <select id="queryByIds" resultMap="MusicGroupPaymentCalender">
+        SELECT * FROM music_group_payment_calender WHERE id_ IN
+        <foreach collection="calenderId" open="(" close=")" item="item" separator=",">
+            #{item}
+        </foreach>
+    </select>
+    <select id="queryEndIds" resultType="java.lang.Long">
+        SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
+        WHERE mgpc.payment_status_ = 2 AND DATEDIFF(#{format},DATE_FORMAT(mgpc.payment_valid_end_date_,'%Y-%m-%d')) = #{configValue1};
+    </select>
+    <resultMap id="CalenderPushDto" type="com.ym.mec.biz.dal.dto.CalenderPushDto">
+        <result property="paymentValidEndDate" column="payment_valid_end_date_"/>
+        <result property="paymentValidStartDate" column="payment_valid_start_date_"/>
+        <result property="teacherId" column="educational_teacher_id_"/>
+        <result property="musicGroupName" column="name_"/>
+        <result property="teacherPhone" column="phone_"/>
+        <result property="calenderId" column="id_"/>
+    </resultMap>
+    <select id="getCalenderPushDto" resultMap="CalenderPushDto">
+        SELECT mgpc.id_,mgpc.payment_valid_start_date_,mgpc.payment_valid_end_date_,
+        mg.educational_teacher_id_,su.real_name_,mg.name_,su.phone_
+        FROM music_group_payment_calender mgpc
+        LEFT JOIN music_group mg ON mgpc.music_group_id_ = mg.id_
+        LEFT JOIN sys_user su ON su.id_ = mg.educational_teacher_id_
+        WHERE mgpc.id_ IN
+        <foreach collection="calenderIds" open="(" close=")" separator="," item="item">
+            #{item}
+        </foreach>
+    </select>
 </mapper>

+ 18 - 4
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentFeeMapper.xml

@@ -15,6 +15,7 @@
         <result column="course_fee_" property="courseFee"/>
         <result column="next_payment_date_" property="nextPaymentDate"/>
         <result column="latest_paid_time_" property="latestPaidTime"/>
+        <result column="payment_valid_end_date_" property="paymentValidEndDate"/>
         <result column="continuous_absenteeism_times_" property="continuousAbsenteeismTimes"/>
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
@@ -42,15 +43,21 @@
     <!-- 向数据库增加一条记录 -->
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentFee" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
-		INSERT INTO music_group_student_fee_ (id_,music_group_id_,user_id_,course_fee_,create_time_,update_time_,next_payment_date_,latest_paid_time_,continuous_absenteeism_times_,subject_id_,payment_status_,temporary_course_fee_,payment_period_list_,remain_network_class_times_)
-		VALUES(#{id},#{musicGroupId},#{userId},#{courseFee},now(),now(),#{nextPaymentDate},#{latestPaidTime},#{continuousAbsenteeismTimes},#{subjectId},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{temporaryCourseFee},#{paymentPeriodList},#{remainNetworkClassTimes})
+		INSERT INTO music_group_student_fee_ (id_,music_group_id_,user_id_,course_fee_,create_time_,
+		update_time_,next_payment_date_,latest_paid_time_,continuous_absenteeism_times_,subject_id_,
+		payment_status_,temporary_course_fee_,payment_period_list_,remain_network_class_times_,payment_valid_end_date_)
+		VALUES(#{id},#{musicGroupId},#{userId},#{courseFee},now(),now(),#{nextPaymentDate},#{latestPaidTime},
+		#{continuousAbsenteeismTimes},#{subjectId},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+		#{temporaryCourseFee},#{paymentPeriodList},#{remainNetworkClassTimes},#{paymentValidEndDate})
 	</insert>
 
     <insert id="batchInsert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentFee">
-        INSERT INTO music_group_student_fee_ (music_group_id_,user_id_,create_time_,update_time_,next_payment_date_,subject_id_,payment_status_,course_fee_,payment_period_list_,remain_network_class_times_)
+        INSERT INTO music_group_student_fee_ (music_group_id_,user_id_,create_time_,update_time_,next_payment_date_,
+        subject_id_,payment_status_,course_fee_,payment_period_list_,remain_network_class_times_,payment_valid_end_date_)
 		VALUES
 		<foreach collection="musicGroupStudentFees" item="item" separator=",">
-            (#{item.musicGroupId},#{item.userId},NOW(),NOW(),#{nextPaymentDate},#{item.subjectId},#{paymentStatus},#{item.courseFee},#{item.paymentPeriodList},#{item.remainNetworkClassTimes})
+            (#{item.musicGroupId},#{item.userId},NOW(),NOW(),#{nextPaymentDate},#{item.subjectId},
+            #{paymentStatus},#{item.courseFee},#{item.paymentPeriodList},#{item.remainNetworkClassTimes},#{item.paymentValidEndDate})
         </foreach>
     </insert>
 
@@ -58,6 +65,9 @@
     <update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentFee">
         UPDATE music_group_student_fee_
         <set>
+            <if test="paymentValidEndDate != null">
+                payment_valid_end_date_ = #{paymentValidEndDate},
+            </if>
             <if test="userId != null">
                 user_id_ = #{userId},
             </if>
@@ -364,4 +374,8 @@
         SET mgsf.payment_status_ = #{paymentStatus},mgsf.update_time_ = NOW()
         WHERE mgpcd.music_group_payment_calender_id_ = mgpc.id_ AND mgpc.id_ = #{calenderId}
     </update>
+    <update id="updateFeeStatus">
+        UPDATE music_group_student_fee_ mgsf SET mgsf.payment_status_ = 'NON_PAYMENT',mgsf.update_time_ = NOW()
+        WHERE mgsf.payment_valid_end_date_ IS NOT NULL AND mgsf.payment_status_ = 'PAID_COMPLETED' AND mgsf.payment_valid_end_date_ &lt; NOW()
+    </update>
 </mapper>

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

@@ -139,7 +139,7 @@
             (#{sellOrder.organId},#{sellOrder.cooperationOrganId},#{sellOrder.transNo},#{sellOrder.orderId},#{sellOrder.orderNo},
             #{sellOrder.expectAmount},#{sellOrder.actualAmount},#{sellOrder.balanceAmount},#{sellOrder.type},#{sellOrder.goodsId},
             #{sellOrder.goodsName},#{sellOrder.sellCost},#{sellOrder.sellCost2},#{sellOrder.num},#{sellOrder.userId},
-            #{sellOrder.paymentChannel},#{sellOrder.merNo},#{sellOrder.sellTime},#{sellOrder.createIme},#{sellOrder.updateTime})
+            #{sellOrder.paymentChannel},#{sellOrder.merNo},#{sellOrder.sellTime},NOW(),NOW())
         </foreach>
     </insert>
 

+ 115 - 0
mec-biz/src/main/resources/config/mybatis/StudentGoodsSellMapper.xml

@@ -0,0 +1,115 @@
+<?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.StudentGoodsSellDao">
+	
+	<resultMap type="com.ym.mec.biz.dal.entity.StudentGoodsSell" id="StudentGoodsSell">
+		<result column="id_" property="id" />
+		<result column="user_id_" property="userId" />
+		<result column="teacher_id_" property="teacherId" />
+		<result column="goods_json_" property="goodsJson" />
+		<result column="total_amount_" property="totalAmount" />
+		<result column="market_amount_" property="marketAmount" />
+		<result column="order_no_" property="orderNo" />
+		<result column="organ_id_" property="organId" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="StudentGoodsSell" >
+		SELECT * FROM student_goods_sell WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="StudentGoodsSell">
+		SELECT * FROM student_goods_sell ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO student_goods_sell (id_,user_id_,teacher_id_,goods_json_,total_amount_,market_amount_,create_time_,update_time_,order_no_,organ_id_)
+		VALUES(#{id},#{userId},#{teacherId},#{goodsJson},#{totalAmount},#{marketAmount},NOW(),NOW(),#{orderNo},#{organId})
+	</insert>
+	
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentGoodsSell">
+		UPDATE student_goods_sell <set>
+		<if test="organId != null">
+			organ_id_ = #{organId},
+		</if>
+		<if test="orderNo != null">
+			order_no_ = #{orderNo},
+		</if>
+		<if test="userId != null">
+			user_id_ = #{userId},
+		</if>
+		<if test="totalAmount != null">
+			total_amount_ = #{totalAmount},
+		</if>
+		<if test="marketAmount != null">
+			market_amount_ = #{marketAmount},
+		</if>
+		<if test="teacherId != null">
+			teacher_id_ = #{teacherId},
+		</if>
+		<if test="goodsJson != null">
+			goods_json_ = #{goodsJson},
+		</if>
+		update_time_ = NOW()
+		</set> WHERE id_ = #{id}
+	</update>
+	
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM student_goods_sell WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="StudentGoodsSell" parameterType="map">
+		SELECT * FROM student_goods_sell ORDER BY id_ <include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM student_goods_sell
+	</select>
+    <select id="countStudentGoodsOrders" resultType="java.lang.Integer">
+		SELECT COUNT(spo.id_) FROM student_payment_order spo
+		LEFT JOIN student_goods_sell sgs ON spo.id_ = sgs.order_no_
+		<include refid="queryStudentGoodsOrdersSql"/>
+	</select>
+	<resultMap type="com.ym.mec.biz.dal.dto.StudentGoodsSellDto" id="StudentGoodsSellDto" extends="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.StudentPaymentOrder">
+		<result column="goods_json_" property="goodsJson" />
+		<result column="total_amount_" property="totalAmount" />
+		<result column="market_amount_" property="marketAmount" />
+	</resultMap>
+	<sql id="queryStudentGoodsOrdersSql">
+		<where>
+			<if test="teacherId != null">
+				sgs.teacher_id_ = #{teacherId}
+			</if>
+			<if test="paymentStatus != null">
+				AND spo.status_ = #{paymentStatus}
+			</if>
+		</where>
+	</sql>
+	<select id="queryStudentGoodsOrders" resultMap="StudentGoodsSellDto">
+		SELECT spo.*,sgs.goods_json_,sgs.total_amount_,sgs.market_amount_ FROM student_payment_order spo
+		LEFT JOIN student_goods_sell sgs ON spo.id_ = sgs.order_no_
+		<include refid="queryStudentGoodsOrdersSql"/>
+		ORDER BY spo.create_time_ DESC
+		<include refid="global.limit"/>
+	</select>
+	<select id="findByOrderNo" resultMap="StudentGoodsSell">
+		SELECT * FROM student_goods_sell WHERE order_no_ = #{orderNo} LIMIT 1
+	</select>
+	<select id="getStudentGoodsSellDto" resultMap="StudentGoodsSellDto">
+		SELECT spo.*,sgs.goods_json_,sgs.total_amount_,sgs.market_amount_ FROM student_payment_order spo
+		LEFT JOIN student_goods_sell sgs ON spo.order_no_ = sgs.order_no_
+		WHERE spo.order_no_ = #{orderNo} LIMIT 1
+	</select>
+</mapper>

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -16,6 +16,10 @@ public interface TaskRemoteService {
 	// 教师异常考勤推送
 	public void pushTeacherExceptionAttendanceTask();
 
+	@GetMapping(value = "task/updateMusicGroupStudentFeeStatus")
+	// 更新学员缴费状态(新)
+	public void updateMusicGroupStudentFeeStatus();
+
 	@GetMapping(value = "task/refreshPaymentFeeStatus")
 	// 刷新付费状态
 	public void refreshPaymentFeeStatus();

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -157,6 +157,11 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
 	}
 
 	@Override
+	public void updateMusicGroupStudentFeeStatus() {
+		logger.info("更新乐团学员缴费状态失败");
+	}
+
+	@Override
 	public void studentServeRemind() {
 		logger.info("本周应布置课外训练推送失败");
 	}

+ 6 - 8
mec-student/src/main/java/com/ym/mec/student/controller/RepairController.java

@@ -3,7 +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.GoodsSellDto;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
@@ -23,10 +23,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 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 org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.Map;
@@ -49,19 +46,20 @@ public class RepairController extends BaseController {
 
     @ApiOperation("添加商品销售订单")
     @PostMapping(value = "/addGoodsSellOrder")
-    public HttpResponseResult addGoodsSellOrder(GoodsSellDto goodsSellDto) throws Exception {
+    public HttpResponseResult addGoodsSellOrder(@RequestBody StudentGoodsSell studentGoodsSell) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             throw new BizException("请登录");
         }
-        if (goodsSellDto.getIsRepeatPay() == false) {
+        if (studentGoodsSell.getIsRepeatPay() == false) {
             List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.GOODS_SELL, null, sysUser.getId(), DealStatusEnum.ING,
                     OrderTypeEnum.RENEW);
             if (list.size() > 0) {
                 return failed(HttpStatus.CONTINUE, "您有待支付的订单");
             }
         }
-        Map map = studentRepairService.addGoodsSellOrder(goodsSellDto);
+        studentGoodsSell.setUserId(sysUser.getId());
+        Map map = studentRepairService.addGoodsSellOrder(studentGoodsSell);
         if(map.containsKey("tradeState")){
             return failed(HttpStatus.CREATED, "恭喜您,购买成功!");
         }

+ 4 - 1
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -70,6 +70,8 @@ public class StudentOrderController extends BaseController {
     private TenantPaymentOrderService tenantPaymentOrderService;
     @Autowired
     private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
+    @Autowired
+    private StudentGoodsSellDao studentGoodsSellDao;
 
 
     @Value("${spring.profiles.active:dev}")
@@ -133,8 +135,9 @@ public class StudentOrderController extends BaseController {
         } else if (orderByOrderNo.getGroupType().equals(GroupType.SPORADIC)) {
             SporadicChargeInfo info = sporadicChargeInfoService.get(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
             orderDetail.put("detail", info);
+        }else if(orderByOrderNo.getGroupType().equals(GroupType.GOODS_SELL)){
+            orderDetail.put("detail", studentGoodsSellDao.getStudentGoodsSellDto(orderNo));
         }
-
         return succeed(orderDetail);
     }
 

+ 19 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/UpdateMusicGroupStudentFeeStatus.java

@@ -0,0 +1,19 @@
+package com.ym.mec.task.jobs;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UpdateMusicGroupStudentFeeStatus extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.updateMusicGroupStudentFeeStatus();
+	}
+}

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

@@ -1,22 +1,17 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
+import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
+import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
+import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import java.util.Date;
-import java.util.List;
-
 import org.springframework.beans.factory.annotation.Autowired;
 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.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
-import com.ym.mec.biz.dal.page.MusicCalenderQueryInfo;
-import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
-import com.ym.mec.common.controller.BaseController;
+import java.util.Date;
+import java.util.List;
 
 @RequestMapping("musicGroupPaymentCalender")
 @Api(tags = "乐团缴费日历服务")
@@ -50,11 +45,11 @@ public class MusicGroupPaymentCalenderController extends BaseController {
         return succeed();
     }
 
-    @ApiOperation(value = "修改乐团缴费日历")
+    @ApiOperation(value = "修改乐团缴费时间")
     @PostMapping("/updateStartTime")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalender/updateStartTime')")
-    public Object updateStartTime(Date startTime,Date endTime,Long id) {
-        musicGroupPaymentCalenderService.updateStartTime(startTime,endTime,id);
+    public Object updateStartTime(MusicGroupPaymentCalender paymentCalender) {
+        musicGroupPaymentCalenderService.updateStartTime(paymentCalender);
         return succeed();
     }
 

+ 6 - 4
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -2,7 +2,6 @@ package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -57,9 +56,6 @@ public class TaskController extends BaseController {
 	private CoursesGroupService coursesGroupService;
 
 	@Autowired
-	private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
-
-	@Autowired
 	private ExtracurricularExercisesService extracurricularExercisesService;
 	
 	@Autowired
@@ -252,6 +248,12 @@ public class TaskController extends BaseController {
 		musicGroupPaymentCalenderService.autoUpdateMusicGroupPaymentCalenderStatus();
 	}
 
+	// 更新乐团学员缴费状态
+	@GetMapping("/updateMusicGroupStudentFeeStatus")
+	public void updateMusicGroupStudentFeeStatus() {
+		musicGroupPaymentCalenderService.autoUpdateMusicGroupStudentFeeStatus();
+	}
+
 	// 推送教师异常考勤
 	@GetMapping("/pushTeacherExceptionAttendanceTask")
 	public void pushTeacherExceptionAttendanceTask() {

+ 42 - 8
mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

@@ -6,28 +6,31 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
+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.RepairStudentQueryInfo;
-import com.ym.mec.biz.service.GoodsCategoryService;
-import com.ym.mec.biz.service.GoodsService;
-import com.ym.mec.biz.service.StudentRepairService;
-import com.ym.mec.biz.service.SubjectService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.util.date.DateUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 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 org.springframework.web.bind.annotation.*;
 
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 @RequestMapping("eduRepair")
@@ -43,11 +46,15 @@ public class EduRepairController extends BaseController {
     @Autowired
     private StudentRepairService studentRepairService;
     @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
+    @Autowired
     private SubjectService subjectService;
     @Autowired
     private GoodsService goodsService;
     @Autowired
     private GoodsCategoryService goodsCategoryService;
+    @Autowired
+    private StudentGoodsSellService studentGoodsSellService;
 
     @ApiOperation("获取学生列表")
     @GetMapping(value = "/getStudents")
@@ -66,6 +73,28 @@ public class EduRepairController extends BaseController {
         return succeed(studentRepairService.getStudents(queryInfo));
     }
 
+    @ApiOperation("添加商品销售订单")
+    @PostMapping(value = "/addGoodsSellOrder")
+    public HttpResponseResult addGoodsSellOrder(@RequestBody StudentGoodsSell studentGoodsSell) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("请登录");
+        }
+        if (studentGoodsSell.getIsRepeatPay() == false) {
+            List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.GOODS_SELL, null,studentGoodsSell.getUserId(), DealStatusEnum.ING,
+                    OrderTypeEnum.RENEW);
+            if (list.size() > 0) {
+                return failed(HttpStatus.CONTINUE, "该学员有待支付的订单");
+            }
+        }
+        studentGoodsSell.setTeacherId(sysUser.getId());
+        Map map = studentRepairService.addGoodsSellOrder(studentGoodsSell);
+        if(map.containsKey("tradeState")){
+            return failed(HttpStatus.CREATED, "恭喜您,购买成功!");
+        }
+        return succeed(map);
+    }
+
     @ApiOperation("添加维修单")
     @PostMapping(value = "/addRepair")
     public HttpResponseResult addRepair(StudentRepair repairInfo) throws Exception {
@@ -157,4 +186,9 @@ public class EduRepairController extends BaseController {
         return succeed(goodsCategoryService.queryPage(queryInfo));
     }
 
+    @ApiOperation(value = "分页查询教务老师关联的学员订单")
+    @GetMapping("/queryStudentGoodsOrders")
+    public Object queryStudentGoodsOrders(QueryInfo queryInfo) {
+        return succeed(studentGoodsSellService.queryStudentGoodsOrders(queryInfo));
+    }
 }