Browse Source

Merge branch 'online1' into musicGroup_found_change

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDao.java
#	mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml
周箭河 4 năm trước cách đây
mục cha
commit
4b43193658
29 tập tin đã thay đổi với 834 bổ sung205 xóa
  1. 2 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupDao.java
  2. 25 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ReplacementInstrumentActivityDao.java
  3. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java
  4. 18 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ExportTeacherSalaryDto.java
  5. 86 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementInstrumentActivityStatDto.java
  6. 12 4
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementPayDto.java
  7. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/IndexBaseMonthData.java
  8. 16 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ReplacementInstrumentActivity.java
  9. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ReplacementInstrumentCooperation.java
  10. 45 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/ReplacementInstrumentActivityQueryInfo.java
  11. 18 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ReplacementInstrumentActivityService.java
  12. 152 126
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  13. 18 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java
  14. 27 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java
  15. 81 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java
  16. 3 5
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentCooperationServiceImpl.java
  17. 6 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  18. 6 3
      mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml
  19. 11 0
      mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml
  20. 99 19
      mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentActivityMapper.xml
  21. 6 2
      mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentCooperationMapper.xml
  22. 4 0
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  23. 1 1
      mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java
  24. 44 1
      mec-student/src/main/java/com/ym/mec/student/controller/ReplacementInstrumentActivityController.java
  25. 6 2
      mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  26. 2 2
      mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java
  27. 119 12
      mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentActivityController.java
  28. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentController.java
  29. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentCooperationController.java

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

@@ -386,4 +386,6 @@ public interface MusicGroupDao extends BaseDAO<String, MusicGroup> {
      * @return
      */
     Integer getCooperationMusicGroupNum(@Param("cooperationOrganId") Integer cooperationOrganId, @Param("musicGroupId") String musicGroupId);
+
+    CooperationOrgan findCooperationOrganEduTeacher(@Param("id") Integer id);
 }

+ 25 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ReplacementInstrumentActivityDao.java

@@ -13,7 +13,7 @@ import com.ym.mec.common.dal.BaseDAO;
 public interface ReplacementInstrumentActivityDao extends BaseDAO<Integer, ReplacementInstrumentActivity> {
 
 
-    ReplacementInstrumentActivity findByUserId(@Param("cooperationOrganId") Integer cooperationOrganId, @Param("userId")Integer userId);
+    ReplacementInstrumentActivity findByUserId(@Param("cooperationOrganId") Integer cooperationOrganId, @Param("userId") Integer userId);
 
     List<ReplacementInstrumentActivityStatDto> queryReplacements(Map<String, Object> params);
 
@@ -27,8 +27,32 @@ public interface ReplacementInstrumentActivityDao extends BaseDAO<Integer, Repla
 
     /**
      * 获取开启缴费推送的人
+     *
      * @param cooperationOrganId
      * @return
      */
     List<ReplacementInstrumentActivityStatDto> getPushUsers(@Param("cooperationOrganId") Integer cooperationOrganId);
+
+    /**
+     * 获取置换记录详情
+     *
+     * @param id
+     * @return
+     */
+    ReplacementInstrumentActivityStatDto getInfo(@Param("id") Integer id);
+
+
+    /**
+     * 获取问卷分页数据
+     * @param params
+     * @return
+     */
+    List<ReplacementInstrumentActivityStatDto> getPageList(Map<String, Object> params);
+
+    /**
+     * 获取问卷总条数
+     * @param params
+     * @return
+     */
+    Integer getCount(Map<String, Object> params);
 }

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -398,4 +398,11 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
      * @return
      */
     List<StudentPaymentOrder> getAdaPayOrdersByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    /**
+     * 获取用户乐器置换的订单
+     *
+     * @return
+     */
+    StudentPaymentOrder getUserReplacementIngOrder(@Param("userId") Integer userId, @Param("replacementId") Integer replacementId);
 }

+ 18 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ExportTeacherSalaryDto.java

@@ -1,9 +1,13 @@
 package com.ym.mec.biz.dal.dto;
 
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+
 public class ExportTeacherSalaryDto{
 
     //课时编号
-    private Integer courseScheduleId;
+    private Long courseScheduleId;
 
     //老师编号
     private  Integer teacherId;
@@ -109,6 +113,17 @@ public class ExportTeacherSalaryDto{
     //实际上课学员
     private int realStudentNum;
 
+    @ApiModelProperty(value = "课程收入")
+    private BigDecimal courseIncome;
+
+    public BigDecimal getCourseIncome() {
+        return courseIncome;
+    }
+
+    public void setCourseIncome(BigDecimal courseIncome) {
+        this.courseIncome = courseIncome;
+    }
+
     public String getDeductionReason() {
         return deductionReason;
     }
@@ -221,11 +236,11 @@ public class ExportTeacherSalaryDto{
         this.courseScheduleEndTime = courseScheduleEndTime;
     }
 
-    public Integer getCourseScheduleId() {
+    public Long getCourseScheduleId() {
         return courseScheduleId;
     }
 
-    public void setCourseScheduleId(Integer courseScheduleId) {
+    public void setCourseScheduleId(Long courseScheduleId) {
         this.courseScheduleId = courseScheduleId;
     }
 

+ 86 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementInstrumentActivityStatDto.java

@@ -2,6 +2,9 @@ package com.ym.mec.biz.dal.dto;
 
 import com.ym.mec.biz.dal.entity.ReplacementInstrument;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
 
 /**
  * @Author Joburgess
@@ -9,6 +12,8 @@ import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
  */
 public class ReplacementInstrumentActivityStatDto extends ReplacementInstrumentActivity {
 
+    private String organName;
+
     private String subjectName;
 
     /** 品牌 */
@@ -17,6 +22,23 @@ public class ReplacementInstrumentActivityStatDto extends ReplacementInstrumentA
     /** 型号 */
     private String specification;
 
+    /** 配置 */
+    private String param;
+
+    private BigDecimal marketPrice;
+
+    private BigDecimal discountPrice;
+
+    private BigDecimal depreciationPrice;
+
+    private BigDecimal salePrice;
+
+    @ApiModelProperty(value = "是否参与校赛")
+    private String hasYesFirstAnswer;
+
+    @ApiModelProperty(value="是否有置换乐器")
+    private String hasInstrumentsId;
+
     public String getSubjectName() {
         return subjectName;
     }
@@ -40,4 +62,68 @@ public class ReplacementInstrumentActivityStatDto extends ReplacementInstrumentA
     public void setSpecification(String specification) {
         this.specification = specification;
     }
+
+    public BigDecimal getMarketPrice() {
+        return marketPrice;
+    }
+
+    public void setMarketPrice(BigDecimal marketPrice) {
+        this.marketPrice = marketPrice;
+    }
+
+    public BigDecimal getDiscountPrice() {
+        return discountPrice;
+    }
+
+    public void setDiscountPrice(BigDecimal discountPrice) {
+        this.discountPrice = discountPrice;
+    }
+
+    public BigDecimal getDepreciationPrice() {
+        return depreciationPrice;
+    }
+
+    public void setDepreciationPrice(BigDecimal depreciationPrice) {
+        this.depreciationPrice = depreciationPrice;
+    }
+
+    public BigDecimal getSalePrice() {
+        return salePrice;
+    }
+
+    public void setSalePrice(BigDecimal salePrice) {
+        this.salePrice = salePrice;
+    }
+
+    public String getParam() {
+        return param;
+    }
+
+    public void setParam(String param) {
+        this.param = param;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getHasInstrumentsId() {
+        return hasInstrumentsId;
+    }
+
+    public void setHasInstrumentsId(String hasInstrumentsId) {
+        this.hasInstrumentsId = hasInstrumentsId;
+    }
+
+    public String getHasYesFirstAnswer() {
+        return hasYesFirstAnswer;
+    }
+
+    public void setHasYesFirstAnswer(String hasYesFirstAnswer) {
+        this.hasYesFirstAnswer = hasYesFirstAnswer;
+    }
 }

+ 12 - 4
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ReplacementPayDto.java

@@ -12,10 +12,10 @@ public class ReplacementPayDto {
     private BigDecimal amount;
 
     @ApiModelProperty(value = "是否使用余额", required = true)
-    private Boolean isUseBalance = false;
+    private Boolean useBalance = false;
 
     @ApiModelProperty(value = "重新支付", required = true)
-    private Boolean isRePay = false;
+    private Boolean rePay = false;
 
     public Integer getId() {
         return id;
@@ -34,10 +34,18 @@ public class ReplacementPayDto {
     }
 
     public Boolean getUseBalance() {
-        return isUseBalance;
+        return useBalance;
     }
 
     public void setUseBalance(Boolean useBalance) {
-        isUseBalance = useBalance;
+        this.useBalance = useBalance;
+    }
+
+    public Boolean getRePay() {
+        return rePay;
+    }
+
+    public void setRePay(Boolean rePay) {
+        this.rePay = rePay;
     }
 }

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

@@ -22,13 +22,13 @@ public class IndexBaseMonthData {
 	private Integer organId;
 	
 	/** 总数量 */
-	private BigDecimal totalNum;
+	private BigDecimal totalNum = BigDecimal.ZERO;
 	
 	/** 有效数量 */
-	private BigDecimal activateNum;
+	private BigDecimal activateNum = BigDecimal.ZERO;
 	
 	/** 最终结果 */
-	private BigDecimal percent;
+	private BigDecimal percent = BigDecimal.ZERO;
 
 	private IndexDataType dataType;
 

+ 16 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ReplacementInstrumentActivity.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
@@ -21,7 +22,7 @@ public class ReplacementInstrumentActivity {
 	private Integer userId;
 
 	/**  */
-	private Integer openFlag;
+	private Integer openFlag = 0;
 	
 	/**  */
 	private String userName;
@@ -48,6 +49,12 @@ public class ReplacementInstrumentActivity {
 
 	@ApiModelProperty(value = "缴费状态 0-未缴费 1-缴费中 2-已缴费")
 	private Integer payStatus = 0;
+
+	/**
+	 * 是否有问卷 0-没有 1-有
+	 */
+	@ApiModelProperty(value = "是否有问卷 0-没有 1-有")
+	private YesOrNoEnum showQuestion = YesOrNoEnum.YES;
 	
 	/**  */
 	private java.util.Date createTime;
@@ -187,4 +194,12 @@ public class ReplacementInstrumentActivity {
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
+
+	public YesOrNoEnum getShowQuestion() {
+		return showQuestion;
+	}
+
+	public void setShowQuestion(YesOrNoEnum showQuestion) {
+		this.showQuestion = showQuestion;
+	}
 }

+ 15 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ReplacementInstrumentCooperation.java

@@ -30,6 +30,13 @@ public class ReplacementInstrumentCooperation {
     @ApiModelProperty(value = "是否开启缴费 0-未开启 1-已开启")
     private YesOrNoEnum openPay = YesOrNoEnum.NO;
 
+
+    /**
+     * 是否有问卷 0-没有 1-有
+     */
+    @ApiModelProperty(value = "是否有问卷 0-没有 1-有")
+    private YesOrNoEnum showQuestion = YesOrNoEnum.YES;
+
     /**
      * 创建时间
      */
@@ -182,4 +189,12 @@ public class ReplacementInstrumentCooperation {
     public void setPayScale(BigDecimal payScale) {
         this.payScale = payScale;
     }
+
+    public YesOrNoEnum getShowQuestion() {
+        return showQuestion;
+    }
+
+    public void setShowQuestion(YesOrNoEnum showQuestion) {
+        this.showQuestion = showQuestion;
+    }
 }

+ 45 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ReplacementInstrumentActivityQueryInfo.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.page;
 
 
 import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
 
 public class ReplacementInstrumentActivityQueryInfo extends QueryInfo {
 
@@ -15,6 +16,26 @@ public class ReplacementInstrumentActivityQueryInfo extends QueryInfo {
 
     private String specification;
 
+    @ApiModelProperty(value="是否有置换乐器")
+    private Boolean hasInstrumentsId;
+
+    @ApiModelProperty(value="合作单位名称或编号搜索")
+    private String cooperationOrganIdOrName;
+
+    @ApiModelProperty(value = "缴费状态 0-未缴费 1-缴费中 2-已缴费")
+    private Integer payStatus;
+
+    @ApiModelProperty(value = "是否参与校赛")
+    private Boolean hasYesFirstAnswer;
+
+    public Integer getPayStatus() {
+        return payStatus;
+    }
+
+    public void setPayStatus(Integer payStatus) {
+        this.payStatus = payStatus;
+    }
+
     public Integer getCooperationOrganId() {
         return cooperationOrganId;
     }
@@ -54,4 +75,28 @@ public class ReplacementInstrumentActivityQueryInfo extends QueryInfo {
     public void setSpecification(String specification) {
         this.specification = specification;
     }
+
+    public Boolean getHasInstrumentsId() {
+        return hasInstrumentsId;
+    }
+
+    public void setHasInstrumentsId(Boolean hasInstrumentsId) {
+        this.hasInstrumentsId = hasInstrumentsId;
+    }
+
+    public String getCooperationOrganIdOrName() {
+        return cooperationOrganIdOrName;
+    }
+
+    public void setCooperationOrganIdOrName(String cooperationOrganIdOrName) {
+        this.cooperationOrganIdOrName = cooperationOrganIdOrName;
+    }
+
+    public Boolean getHasYesFirstAnswer() {
+        return hasYesFirstAnswer;
+    }
+
+    public void setHasYesFirstAnswer(Boolean hasYesFirstAnswer) {
+        this.hasYesFirstAnswer = hasYesFirstAnswer;
+    }
 }

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ReplacementInstrumentActivityService.java

@@ -20,6 +20,7 @@ public interface ReplacementInstrumentActivityService extends BaseService<Intege
 
     /**
      * 乐器置换的支付
+     *
      * @param replacementPayDto
      * @return
      * @throws Exception
@@ -28,9 +29,26 @@ public interface ReplacementInstrumentActivityService extends BaseService<Intege
 
     /**
      * 支付回调处理
+     *
      * @param studentPaymentOrder
      * @return
      */
     Boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
 
+    /**
+     * 获取置换的详情
+     *
+     * @param id
+     * @return
+     */
+    ReplacementInstrumentActivityStatDto getInfo(Integer id);
+
+
+    /**
+     * 获取问卷列表
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<ReplacementInstrumentActivityStatDto> getPageList(ReplacementInstrumentActivityQueryInfo queryInfo);
+
 }

+ 152 - 126
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -21,130 +21,156 @@ import com.ym.mec.common.service.BaseService;
 
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {
 
-	/**
-	 * 查询商品列表
-	 * @param musicGroupId
-	 * @param type
-	 * @return
-	 */
-	List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type);
-
-	/**
-	 * 查询订单列表
-	 * @param groupType
-	 * @param musicGroupId
-	 * @param userId
-	 * @param status
-	 * @param type
-	 * @return
-	 */
-	List<StudentPaymentOrder> queryByCondition(GroupType groupType, String musicGroupId, Integer userId, DealStatusEnum status, OrderTypeEnum type);
-
-	/**
-	 * 查询报名缴费订单
-	 * @param musicGroupId
-	 * @param status
-	 * @return
-	 */
-	StudentPaymentOrder findMusicGroupApplyOrderByStatus(Integer userId, String musicGroupId, DealStatusEnum status);
-
-	/**
-	 * 根据orderNo查询订单
-	 * @param orderNo
-	 * @return
-	 */
-	StudentPaymentOrder findOrderByOrderNo(String orderNo);
-
-	/**
-	 * 查找支付成功和支付中订单
-	 * @return
-	 */
-	int findPayOrderNum();
-
-	/**
-	 * 查询支付中订单
-	 *
-	 * @param status
-	 * @return
-	 */
-	List<StudentPaymentOrder> findOrdersByStatus(DealStatusEnum status, String paymentChannel);
-
-	/**
-	 * 查询支付中超时的订单
-	 * @param orderNoList
-	 * @param status
-	 * @param beforeTime
-	 * @return
-	 */
-	List<StudentPaymentOrder> findOrdersOverTime(List<String> orderNoList, DealStatusEnum status, Date beforeTime);
-
-	void queryOrderStatus() throws Exception;
-
-	void updateOrder(Map<String, String> rpMap) throws Exception;
-
-	/**
-	 * 获取零星订单
-	 * @param userId
-	 * @param sporadicId
-	 * @param sporadic
-	 * @param status
-	 * @return
-	 */
-	Integer findOrderByGroupType(Integer userId, Integer sporadicId, String sporadic, DealStatusEnum status);
-
-	List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params);
-
-	/**
-	 * 获取零星收费订单列表
-	 * @param queryInfo
-	 * @return
-	 */
-	PageInfo<SporadicChargeInfoDto> sporadicQueryPage(SporadicOrderQueryInfo queryInfo);
-
-
-	StudentPaymentOrder getOrderMoneyAmount(StudentPaymentOrderQueryInfo queryInfo);
-
-
-	PageInfoOrder<StudentPaymentOrderDto> OrderQueryPage(StudentPaymentOrderQueryInfo queryInfo);
-
-
-	/**
-	 * 获取订单第三方状态
-	 * @param id
-	 * @return
-	 */
-	Boolean getOrderStatus(Long id) throws Exception;
-
-	/**
-	 * 获取分部支付成功支付中订单数量
-	 * @param organId
-	 * @return
-	 */
-	Integer findOrganPayOrderNum(Integer organId);
-
-	/**
-	 * 获取用户某种类型的订单
-	 * @param userId
-	 * @param type
-	 * @param status
-	 * @return
-	 */
-	List<StudentPaymentOrder> getUserOrderByType(Integer userId, OrderTypeEnum type, DealStatusEnum status);
-
-
-	/**
-	 * 从新提交分账信息
-	 * @param startTime
-	 * @param endTime
-	 * @return
-	 */
-	List<StudentPaymentOrder> reConfirmOrder(Date startTime,Date endTime);
-
-	/**
-	 * 获取学生报名的订单
-	 * @param studentId
-	 * @param musicGroupId
-	 * @return
-	 */
-	List<StudentPaymentOrderExportDto> getUserApplyOrders(Integer studentId,String musicGroupId);
+    /**
+     * 查询商品列表
+     *
+     * @param musicGroupId
+     * @param type
+     * @return
+     */
+    List<Goods> queryApplyGoodsList(String musicGroupId, OrderDetailTypeEnum type);
+
+    /**
+     * 查询订单列表
+     *
+     * @param groupType
+     * @param musicGroupId
+     * @param userId
+     * @param status
+     * @param type
+     * @return
+     */
+    List<StudentPaymentOrder> queryByCondition(GroupType groupType, String musicGroupId, Integer userId, DealStatusEnum status, OrderTypeEnum type);
+
+    /**
+     * 查询报名缴费订单
+     *
+     * @param musicGroupId
+     * @param status
+     * @return
+     */
+    StudentPaymentOrder findMusicGroupApplyOrderByStatus(Integer userId, String musicGroupId, DealStatusEnum status);
+
+    /**
+     * 根据orderNo查询订单
+     *
+     * @param orderNo
+     * @return
+     */
+    StudentPaymentOrder findOrderByOrderNo(String orderNo);
+
+    /**
+     * 查找支付成功和支付中订单
+     *
+     * @return
+     */
+    int findPayOrderNum();
+
+    /**
+     * 查询支付中订单
+     *
+     * @param status
+     * @return
+     */
+    List<StudentPaymentOrder> findOrdersByStatus(DealStatusEnum status, String paymentChannel);
+
+    /**
+     * 查询支付中超时的订单
+     *
+     * @param orderNoList
+     * @param status
+     * @param beforeTime
+     * @return
+     */
+    List<StudentPaymentOrder> findOrdersOverTime(List<String> orderNoList, DealStatusEnum status, Date beforeTime);
+
+    void queryOrderStatus() throws Exception;
+
+    void updateOrder(Map<String, String> rpMap) throws Exception;
+
+    /**
+     * 获取零星订单
+     *
+     * @param userId
+     * @param sporadicId
+     * @param sporadic
+     * @param status
+     * @return
+     */
+    Integer findOrderByGroupType(Integer userId, Integer sporadicId, String sporadic, DealStatusEnum status);
+
+    List<StudentPaymentOrderExportDto> ExportQueryPage(Map<String, Object> params);
+
+    /**
+     * 获取零星收费订单列表
+     *
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<SporadicChargeInfoDto> sporadicQueryPage(SporadicOrderQueryInfo queryInfo);
+
+
+    StudentPaymentOrder getOrderMoneyAmount(StudentPaymentOrderQueryInfo queryInfo);
+
+
+    PageInfoOrder<StudentPaymentOrderDto> OrderQueryPage(StudentPaymentOrderQueryInfo queryInfo);
+
+
+    /**
+     * 获取订单第三方状态
+     *
+     * @param id
+     * @return
+     */
+    Boolean getOrderStatus(Long id) throws Exception;
+
+    /**
+     * 获取分部支付成功支付中订单数量
+     *
+     * @param organId
+     * @return
+     */
+    Integer findOrganPayOrderNum(Integer organId);
+
+    /**
+     * 获取用户某种类型的订单
+     *
+     * @param userId
+     * @param type
+     * @param status
+     * @return
+     */
+    List<StudentPaymentOrder> getUserOrderByType(Integer userId, OrderTypeEnum type, DealStatusEnum status);
+
+
+    /**
+     * 从新提交分账信息
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    List<StudentPaymentOrder> reConfirmOrder(Date startTime, Date endTime);
+
+    /**
+     * 获取学生报名的订单
+     *
+     * @param studentId
+     * @param musicGroupId
+     * @return
+     */
+    List<StudentPaymentOrderExportDto> getUserApplyOrders(Integer studentId, String musicGroupId);
+
+    /**
+     * 获取用户支付中的乐器置换订单
+     *
+     * @param userId
+     * @param replacementId
+     * @return
+     */
+    StudentPaymentOrder getUserReplacementIngOrder(Integer userId, Integer replacementId);
+
+
+    void callOrderCallBack(StudentPaymentOrder order) throws Exception;
+
 }

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -969,6 +969,24 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         //vip课(梯度课酬)
         //陪练课
         exportTeacherSalaryDtos.addAll(courseScheduleTeacherSalaryDao.exportPracticeTeacherSalary(params));
+
+        Set<Long> allCourseIds = exportTeacherSalaryDtos.stream().map(ExportTeacherSalaryDto::getCourseScheduleId).collect(Collectors.toSet());
+        Map<Long, BigDecimal> courseIncomeMap = new HashMap<>();
+        if(!CollectionUtils.isEmpty(allCourseIds)){
+            List<CourseScheduleStudentPayment> courseScheduleStudentPayments = courseScheduleStudentPaymentDao.findByCourseScheduleIds(new ArrayList<>(allCourseIds));
+            if(!CollectionUtils.isEmpty(courseScheduleStudentPayments)){
+                courseIncomeMap = courseScheduleStudentPayments.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getCourseScheduleId, Collectors.mapping(CourseScheduleStudentPayment::getExpectPrice, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+            }
+        }
+
+        for (ExportTeacherSalaryDto exportTeacherSalaryDto : exportTeacherSalaryDtos) {
+            if(!courseIncomeMap.containsKey(exportTeacherSalaryDto.getCourseScheduleId())){
+                exportTeacherSalaryDto.setCourseIncome(BigDecimal.ZERO);
+            }else{
+                exportTeacherSalaryDto.setCourseIncome(courseIncomeMap.get(exportTeacherSalaryDto.getCourseScheduleId()));
+            }
+        }
+
         exportTeacherSalaryDtos.sort(Comparator.comparing(ExportTeacherSalaryDto::getTeacherId));
         return exportTeacherSalaryDtos;
     }

+ 27 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service.impl;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.FeeFlagNumDto;
 import com.ym.mec.biz.dal.dto.PracticeCourseDto;
+import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
 import com.ym.mec.biz.dal.dto.StudentPaymentOrderExportDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.GroupType;
@@ -57,6 +58,8 @@ public class ExportServiceImpl implements ExportService {
     private ManagerDownloadDao managerDownloadDao;
     @Autowired
     private CooperationOrganDao cooperationOrganDao;
+    @Autowired
+    private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
 
     @Override
     @Async
@@ -205,6 +208,18 @@ public class ExportServiceImpl implements ExportService {
                     row.setSubjectName(practiceGroup.getSubjectName());
                     row.setEduTeacher(practiceGroup.getEduTeacherName());
                 }
+            } else if (row.getGroupType().equals(GroupType.REPLACEMENT)) {
+                row.setMusicalFee(row.getActualAmount());
+                ReplacementInstrumentActivityStatDto info = replacementInstrumentActivityDao.getInfo(Integer.parseInt(row.getMusicGroupId()));
+                if (info != null) {
+                    row.setSubjectName(info.getSubjectName());
+                    row.setCooperationOrganName(info.getCooperationOrganName());
+                    row.setMemo(info.getBrand() + "(" + info.getSpecification() + ")");
+                    CooperationOrgan cooperationOrganEduTeacher = musicGroupDao.findCooperationOrganEduTeacher(info.getCooperationOrganId());
+                    if (cooperationOrganEduTeacher != null) {
+                        row.setEduTeacher(cooperationOrganEduTeacher.getLinkman());
+                    }
+                }
             } else {
                 StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
                 BigDecimal childRepairFee = sellOrderDao.getChildRepair(row.getId());
@@ -441,6 +456,18 @@ public class ExportServiceImpl implements ExportService {
                     row.setSubjectName(practiceGroup.getSubjectName());
                     row.setEduTeacher(practiceGroup.getEduTeacherName());
                 }
+            } else if (row.getGroupType().equals(GroupType.REPLACEMENT)) {
+                row.setMusicalFee(row.getActualAmount());
+                ReplacementInstrumentActivityStatDto info = replacementInstrumentActivityDao.getInfo(Integer.parseInt(row.getMusicGroupId()));
+                if (info != null) {
+                    row.setSubjectName(info.getSubjectName());
+                    row.setCooperationOrganName(info.getCooperationOrganName());
+                    row.setMemo(info.getBrand() + "(" + info.getSpecification() + ")");
+                    CooperationOrgan cooperationOrganEduTeacher = musicGroupDao.findCooperationOrganEduTeacher(info.getCooperationOrganId());
+                    if (cooperationOrganEduTeacher != null) {
+                        row.setEduTeacher(cooperationOrganEduTeacher.getLinkman());
+                    }
+                }
             } else {
                 StudentPaymentOrderExportDto feeByType = sellOrderDao.getFeeByType(row.getId());
                 BigDecimal childRepairFee = sellOrderDao.getChildRepair(row.getId());

+ 81 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentActivityServiceImpl.java

@@ -2,9 +2,7 @@ package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
-import com.ym.mec.biz.dal.dao.CooperationOrganDao;
-import com.ym.mec.biz.dal.dao.ReplacementInstrumentDao;
-import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
 import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatHead;
 import com.ym.mec.biz.dal.dto.ReplacementPayDto;
@@ -23,13 +21,13 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 
+import com.ym.mec.util.http.HttpUtil;
 import org.apache.poi.ss.formula.functions.T;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
-
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -66,9 +64,11 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     @Autowired
     private SysMessageService sysMessageService;
-    
+
     @Autowired
     private CooperationOrganService cooperationOrganService;
+    @Autowired
+    private ReplacementInstrumentCooperationDao replacementInstrumentCooperationDao;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
@@ -86,22 +86,50 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
         }
         replacementInstrumentActivity.setUserId(sysUser.getId());
         //如果用户是43分部,那么修改用户信息
-        if(sysUser.getOrganId() == 43){
-        	CooperationOrgan cooperationOrgan = cooperationOrganService.get(replacementInstrumentActivity.getCooperationOrganId());
+        if (sysUser.getOrganId() == 43) {
+            CooperationOrgan cooperationOrgan = cooperationOrganService.get(replacementInstrumentActivity.getCooperationOrganId());
             if (cooperationOrgan != null) {
-            	sysUser.setOrganId(cooperationOrgan.getOrganId());
-            	sysUser.setUpdateTime(new Date());
-            	sysUserFeignService.updateSysUser(sysUser);
+                sysUser.setOrganId(cooperationOrgan.getOrganId());
+                sysUser.setUpdateTime(new Date());
+                sysUserFeignService.updateSysUser(sysUser);
             }
         }
+        ReplacementInstrumentCooperation replacementInstrumentCooperation = replacementInstrumentCooperationDao.getByCooperationId(replacementInstrumentActivity.getCooperationOrganId());
         //如果提交过调查问卷,那么覆盖之前的记录
         ReplacementInstrumentActivity activity = replacementInstrumentActivityDao.findByUserId(replacementInstrumentActivity.getCooperationOrganId(), sysUser.getId());
+        if (replacementInstrumentCooperation != null && replacementInstrumentCooperation.getOpenPay().equals(YesOrNoEnum.YES)) {
+            replacementInstrumentActivity.setOpenFlag(1);
+        }
+        Boolean sendPush = false;
         if (activity != null) {
+            if (!activity.getPayStatus().equals(0)) {
+                throw new BizException("您已参与调查,谢谢参与!");
+            }
             //覆盖之前的数据
             replacementInstrumentActivity.setId(activity.getId());
             replacementInstrumentActivityDao.update(replacementInstrumentActivity);
+            if (replacementInstrumentActivity.getInstrumentsId() != null && (activity.getInstrumentsId() == null || activity.getInstrumentsId() == 0)) {
+                sendPush = true;
+            }
         } else {
             replacementInstrumentActivityDao.insert(replacementInstrumentActivity);
+            sendPush = true;
+        }
+        //已开启缴费推送购买链接
+        if (sendPush && replacementInstrumentActivity.getOpenFlag().equals(1) && replacementInstrumentActivity.getInstrumentsId() != null) {
+            ReplacementInstrument replacementInstrument = replacementInstrumentDao.get(replacementInstrumentActivity.getInstrumentsId());
+            Map<Integer, String> userMap = new HashMap<>();
+            Map<Integer, String> userPhoneMap = new HashMap<>();
+            Integer userId = replacementInstrumentActivity.getUserId();
+            String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+            String pushUrl = baseApiUrl + "/#/questionGoodsSale?id=";
+            userMap.put(userId, userId.toString());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
+                    userMap, null, 0, "5?" + pushUrl + replacementInstrumentActivity.getId(), "STUDENT", replacementInstrument.getBrand(), "");
+
+            userPhoneMap.put(replacementInstrumentActivity.getUserId(), replacementInstrumentActivity.getMobileNo());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
+                    userPhoneMap, null, 0, null, "STUDENT", replacementInstrument.getBrand(), HttpUtil.getSortUrl(pushUrl + replacementInstrumentActivity.getId()));
         }
         return replacementInstrumentActivity;
     }
@@ -141,15 +169,21 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Map pay(ReplacementPayDto replacementPayDto) throws Exception {
         ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityDao.getLock(replacementPayDto.getId());
-        if (replacementInstrumentActivity == null) {
-            throw new BizException("乐器置换不存在,请核查");
-        }
-        if (replacementInstrumentActivity.getInstrumentsId() == null || replacementInstrumentActivity.getInstrumentsId() == 0) {
-            throw new BizException("没有置换的乐器,请核查");
-        }
         Integer userId = replacementInstrumentActivity.getUserId();
+
+        //处理关闭订单
+        if (replacementInstrumentActivity.getPayStatus().equals(1) && replacementPayDto.getRePay()) {
+            StudentPaymentOrder oldOrder = studentPaymentOrderService.getUserReplacementIngOrder(userId, replacementInstrumentActivity.getId());
+            if (oldOrder != null) {
+                oldOrder.setStatus(DealStatusEnum.FAILED);
+                oldOrder.setMemo("用户手动关闭");
+                studentPaymentOrderService.callOrderCallBack(oldOrder);
+            }
+        }
+
         ReplacementInstrument replacementInstrument = replacementInstrumentDao.get(replacementInstrumentActivity.getInstrumentsId());
         BigDecimal orderAmount = replacementInstrument.getSalePrice();
         BigDecimal amount = replacementPayDto.getAmount(); //扣除余额之前的金额
@@ -326,4 +360,34 @@ public class ReplacementInstrumentActivityServiceImpl extends BaseServiceImpl<In
         }
         return false;
     }
+
+    @Override
+    public ReplacementInstrumentActivityStatDto getInfo(Integer id) {
+        ReplacementInstrumentActivityStatDto info = replacementInstrumentActivityDao.getInfo(id);
+        if (info != null && info.getOpenFlag().equals(0)) {
+            ReplacementInstrumentCooperation byCooperationId = replacementInstrumentCooperationDao.getByCooperationId(info.getCooperationOrganId());
+            if (byCooperationId != null && byCooperationId.getOpenPay().equals(YesOrNoEnum.YES)) {
+                info.setOpenFlag(1);
+            }
+        }
+        return info;
+    }
+
+    @Override
+    public PageInfo<ReplacementInstrumentActivityStatDto> getPageList(ReplacementInstrumentActivityQueryInfo queryInfo) {
+        PageInfo<ReplacementInstrumentActivityStatDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<String, Object>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<ReplacementInstrumentActivityStatDto> dataList = new ArrayList<>();
+        int count = replacementInstrumentActivityDao.getCount(params);
+
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = replacementInstrumentActivityDao.getPageList(params);
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

+ 3 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ReplacementInstrumentCooperationServiceImpl.java

@@ -63,14 +63,12 @@ public class ReplacementInstrumentCooperationServiceImpl extends BaseServiceImpl
 
         replacementInstrumentActivityDao.openPay(replacementInstrumentCooperation.getCooperationOrganId());
 
-        Map<Integer, String> userMap = new HashMap<>();
-        Map<Integer, String> userPhoneMap = new HashMap<>();
 
         String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
-        String pushUrl = baseApiUrl + "/#/auditionActive/1?id=";
+        String pushUrl = baseApiUrl + "/#/questionGoodsSale?id=";
         for (ReplacementInstrumentActivityStatDto pushUser : pushUsers) {
-            userMap.clear();
-            userPhoneMap.clear();
+            Map<Integer, String> userMap = new HashMap<>();
+            Map<Integer, String> userPhoneMap = new HashMap<>();
             userMap.put(pushUser.getUserId(), pushUser.getUserId().toString());
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
                     userMap, null, 0, "5?" + pushUrl + pushUser.getId(), "STUDENT", pushUser.getBrand(), "");

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

@@ -348,7 +348,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     //        }
 
     //调用相应业务回调接口
-    private void callOrderCallBack(StudentPaymentOrder order) throws Exception {
+    public void callOrderCallBack(StudentPaymentOrder order) throws Exception {
         if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
             studentRegistrationService.updateApplyOrder(order);
         } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
@@ -537,4 +537,9 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         return orders;
     }
+
+    @Override
+    public StudentPaymentOrder getUserReplacementIngOrder(Integer userId, Integer replacementId) {
+        return studentPaymentOrderDao.getUserReplacementIngOrder(userId, replacementId);
+    }
 }

+ 6 - 3
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -1230,9 +1230,12 @@
 		GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
 	</select>
 	<select id="getTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
-		SELECT spo.organ_id_,SUM(spo.actual_amount_ + spo.balance_payment_amount_) total_num_,
-			   SUM(spo.actual_amount_ + spo.balance_payment_amount_) activate_num_,
-			   SUM(spo.actual_amount_ + spo.balance_payment_amount_) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
+		SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+		                         CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
+			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
+			   SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
+		CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
 		FROM student_payment_order spo
 		WHERE spo.status_ = 'SUCCESS' AND DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
 		<if test="organIds!=null and organIds.size()>0">

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -713,6 +713,17 @@
             </if>
     </select>
 
+    <select id="findCooperationOrganEduTeacher" resultMap="com.ym.mec.biz.dal.dao.CooperationOrganDao.CooperationOrgan">
+        SELECT co.name_,su.real_name_ linkman_
+        FROM music_group mg
+        LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
+        LEFT JOIN sys_user su ON su.id_ = mg.educational_teacher_id_
+        WHERE co.id_ = #{id}
+        AND mg.status_ IN ('PREPARE','PROGRESS','PAUSE','CLOSE')
+        ORDER BY mg.create_time_ DESC
+        LIMIT 1
+    </select>
+
     <select id="getCooperationMusicGroupNum" resultType="java.lang.Integer">
         SELECT COUNT(*) FROM  music_group
         WHERE cooperation_organ_id_ = #{cooperationOrganId} AND status_ IN ('PROGRESS','PAUSE','CLOSE')

+ 99 - 19
mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentActivityMapper.xml

@@ -9,6 +9,7 @@
     <resultMap type="com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity" id="ReplacementInstrumentActivity">
         <result column="id_" property="id"/>
         <result column="cooperation_organ_id_" property="cooperationOrganId"/>
+        <result column="cooperationOrganName" property="cooperationOrganName"/>
         <result column="user_id_" property="userId"/>
         <result column="user_name_" property="userName"/>
         <result column="grade_" property="grade"/>
@@ -27,9 +28,16 @@
     <resultMap id="ReplacementInstrumentActivityStatDto"
                type="com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto"
                extends="ReplacementInstrumentActivity">
+        <result property="organName" column="organ_name_"/>
         <result property="subjectName" column="subject_name_"/>
         <result property="brand" column="brand_"/>
         <result property="specification" column="specification_"/>
+        <result property="param" column="param_"/>
+        <result property="marketPrice" column="market_price_"/>
+        <result property="discountPrice" column="discount_price_"/>
+        <result property="depreciationPrice" column="depreciation_price_"/>
+        <result property="salePrice" column="sale_price_"/>
+        <result property="mobileNo" column="phone_"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -107,8 +115,8 @@
     </delete>
 
     <!-- 分页查询 -->
-    <select id="queryPage" resultMap="ReplacementInstrumentActivity" parameterType="map">
-        SELECT * FROM replacement_instrument_activity ORDER BY id_
+    <select id="queryPage" resultMap="ReplacementInstrumentActivityStatDto" parameterType="map">
+        SELECT * FROM replacement_instrument_activity
         <include refid="global.limit"/>
     </select>
 
@@ -120,7 +128,8 @@
     <select id="findByUserId" resultMap="ReplacementInstrumentActivity">
         SELECT *
         FROM replacement_instrument_activity
-        WHERE user_id_ = #{userId} and cooperation_organ_id_ = #{cooperationOrganId}
+        WHERE user_id_ = #{userId}
+          and cooperation_organ_id_ = #{cooperationOrganId}
         LIMIT 1
     </select>
 
@@ -132,25 +141,43 @@
             <if test="subjectId!=null">
                 AND ria.subject_id_ = #{subjectId}
             </if>
+            <if test="hasInstrumentsId!=null and hasInstrumentsId==true">
+                AND ria.instruments_id_ >=1
+            </if>
+            <if test="hasInstrumentsId!=null and hasInstrumentsId==false">
+                AND ria.instruments_id_ IS NULL
+            </if>
+            <if test="hasYesFirstAnswer!=null and hasYesFirstAnswer==true">
+                AND ria.question_result_ LIKE CONCAT('1', '%')
+            </if>
+            <if test="hasYesFirstAnswer!=null and hasYesFirstAnswer==false ">
+                AND ria.question_result_ LIKE CONCAT('0', '%')
+            </if>
             <if test="brand!=null and brand!=''">
                 AND ri.brand_ = #{brand}
             </if>
             <if test="specification!=null and specification!=''">
                 AND ri.specification_ = #{specification}
             </if>
+            <if test="organId != null">
+                AND FIND_IN_SET(o.id_ , #{organId})
+            </if>
             <if test="search!=null and search!=''">
                 AND (ria.mobile_no_ LIKE CONCAT('%', #{search}, '%') OR ria.user_name_ LIKE CONCAT('%', #{search}, '%'))
             </if>
+            <if test="cooperationOrganIdOrName!=null and cooperationOrganIdOrName!=''">
+                AND (ria.cooperation_organ_id_ = #{cooperationOrganIdOrName} OR co.name_ LIKE CONCAT('%', #{cooperationOrganIdOrName}, '%'))
+            </if>
+            <if test="payStatus!=null">
+                AND ria.pay_status_ = #{payStatus}
+            </if>
         </where>
     </sql>
 
     <select id="queryReplacements" resultMap="ReplacementInstrumentActivityStatDto">
         SELECT
-        ria.subject_id_,
+        ria.*,
         sub.name_ subject_name_,
-        ria.user_name_,
-        ria.mobile_no_,
-        ria.pay_status_,
         ri.brand_,
         ri.specification_
         FROM
@@ -174,13 +201,18 @@
 
     <select id="countReplacementsInfo"
             resultType="com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatHead">
-        SELECT ric.open_pay_ openPay,
-               COUNT(DISTINCT ria.user_id_)                                            surveyNum,
-               COUNT(DISTINCT IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) replacementNum,
-               TRUNCATE(COUNT(IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) / COUNT(DISTINCT ria.user_id_) * 100, 2) replacementRate,
-               TRUNCATE(COUNT(IF(ria.pay_status_ = 2, ria.user_id_, NULL)) / COUNT(DISTINCT IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) * 100, 2) paymentRate
+        SELECT ric.open_pay_                                                                              openPay,
+               COUNT(DISTINCT ria.user_id_)                                                               surveyNum,
+               COUNT(DISTINCT
+                     IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL))                             replacementNum,
+               TRUNCATE(COUNT(IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) / COUNT(DISTINCT ria.user_id_) *
+                        100,
+                        2)                                                                                replacementRate,
+               TRUNCATE(COUNT(IF(ria.pay_status_ = 2, ria.user_id_, NULL)) /
+                        COUNT(DISTINCT IF(ria.instruments_id_ IS NOT NULL, ria.user_id_, NULL)) * 100, 2) paymentRate
         FROM replacement_instrument_activity ria
-            LEFT JOIN replacement_instrument_cooperation ric ON ria.cooperation_organ_id_=ric.cooperation_organ_id_
+                 LEFT JOIN replacement_instrument_cooperation ric
+                           ON ria.cooperation_organ_id_ = ric.cooperation_organ_id_
         WHERE ria.cooperation_organ_id_ = #{cooperationOrganId}
     </select>
 
@@ -188,18 +220,66 @@
         UPDATE replacement_instrument_activity
         SET open_flag_ = 1
         WHERE cooperation_organ_id_ = #{cooperationOrganId}
-          AND open_flag_ = 0 AND instruments_id_ > 0
+          AND open_flag_ = 0
+          AND instruments_id_ > 0
     </update>
 
     <select id="getLock" resultMap="ReplacementInstrumentActivity">
-        SELECT * FROM replacement_instrument_activity WHERE id_ = #{id} FOR UPDATE
+        SELECT *
+        FROM replacement_instrument_activity
+        WHERE id_ = #{id} FOR
+        UPDATE
     </select>
 
     <select id="getPushUsers" resultMap="ReplacementInstrumentActivityStatDto">
-        SELECT ria.*,su.phone_ mobile_no_,ri.brand_ FROM replacement_instrument_activity ria
-        LEFT JOIN sys_user su ON su.id_ = ria.user_id_
-        LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
+        SELECT ria.id_,ria.user_id_, su.phone_ mobile_no_, ri.brand_
+        FROM replacement_instrument_activity ria
+                 LEFT JOIN sys_user su ON su.id_ = ria.user_id_
+                 LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
         WHERE cooperation_organ_id_ = #{cooperationOrganId}
-        AND open_flag_ = 0 AND instruments_id_ > 0
+          AND open_flag_ = 0
+          AND instruments_id_ > 0
+    </select>
+
+    <select id="getInfo" resultMap="ReplacementInstrumentActivityStatDto">
+        SELECT ria.*,
+               ri.brand_,
+               ri.specification_,
+               ri.param_,
+               ri.market_price_,
+               ri.discount_price_,
+               ri.depreciation_price_,
+               ri.sale_price_,
+               s.name_ subject_name_,
+               co.name_ cooperationOrganName
+        FROM replacement_instrument_activity ria
+                 LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
+                 LEFT JOIN subject s ON s.id_ = ri.subject_id_
+                 LEFT JOIN cooperation_organ co ON co.id_ = ria.cooperation_organ_id_
+        WHERE ria.id_ = #{id}
+    </select>
+
+    <!-- 获取问卷分页数据 -->
+    <select id="getPageList" resultMap="ReplacementInstrumentActivityStatDto" parameterType="map">
+        SELECT ria.*,su.phone_,o.name_ organ_name_,ri.brand_,ri.specification_,ri.param_,ri.market_price_,ri.discount_price_,ri.depreciation_price_,
+        ri.sale_price_,s.name_ subject_name_,co.name_ cooperationOrganName FROM replacement_instrument_activity ria
+        LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
+        LEFT JOIN subject s ON s.id_ = ria.subject_id_
+        lEFT JOIN sys_user su ON su.id_ = ria.user_id_
+        LEFT JOIN cooperation_organ co ON co.id_ = ria.cooperation_organ_id_
+        LEFT JOIN organization o ON o.id_ = co.organ_id_
+        <include refid="queryReplacementsCondition"/>
+        ORDER BY ria.id_ DESC
+        <include refid="global.limit"/>
+    </select>
+
+    <!-- 获取问卷总条数 -->
+    <select id="getCount" resultType="int">
+        SELECT COUNT(*)
+        FROM replacement_instrument_activity ria
+        LEFT JOIN replacement_instrument ri ON ri.id_ = ria.instruments_id_
+        LEFT JOIN cooperation_organ co on co.id_ = ria.cooperation_organ_id_
+        LEFT JOIN organization o on o.id_ = co.organ_id_
+        <include refid="queryReplacementsCondition"/>
     </select>
 </mapper>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/ReplacementInstrumentCooperationMapper.xml

@@ -8,6 +8,7 @@
         <result column="organ_id_" property="organId"/>
         <result column="cooperation_organ_id_" property="cooperationOrganId"/>
         <result column="open_pay_" property="openPay" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="show_question_" property="showQuestion" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="organName" property="organName"/>
         <result column="cooperationOrganName" property="cooperationOrganName"/>
         <result column="create_time_" property="createTime"/>
@@ -23,11 +24,11 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.ReplacementInstrumentCooperation"
             useGeneratedKeys="true" keyColumn="id" keyProperty="id">
         <!--@mbg.generated-->
-        insert into replacement_instrument_cooperation (id_, organ_id_, cooperation_organ_id_, open_pay_, create_time_,
+        insert into replacement_instrument_cooperation (id_, organ_id_, cooperation_organ_id_, open_pay_,show_question_, create_time_,
         update_time_
         )
         values (#{id}, #{organId}, #{cooperationOrganId},
-        #{openPay,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{createTime}, #{updateTime}
+        #{openPay,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{showQuestion,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{createTime}, #{updateTime}
         )
     </insert>
 
@@ -75,6 +76,9 @@
             <if test="openPay != null">
                 AND ric.open_pay_ = #{openPay,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
             </if>
+            <if test="showQuestion != null">
+                AND ric.show_question_ = #{showQuestion,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
             <if test="search != null and search != ''">
                 AND (ric.cooperation_organ_id_ = #{search} OR co.name_ LIKE CONCAT('%',#{search},'%'))
             </if>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -875,4 +875,8 @@
     <select id="getAdaPayOrdersByTime" resultMap="StudentPaymentOrder"><![CDATA[
         SELECT * FROM student_payment_order WHERE pay_time_ >= #{startTime} AND pay_time_ <= #{endTime} AND payment_channel_='ADAPAY' AND status_ ='SUCCESS']]>
     </select>
+
+    <select id="getUserReplacementIngOrder" resultMap="StudentPaymentOrder">
+        SELECT * FROM student_payment_order WHERE user_id_=#{userId} AND music_group_id_ = #{replacementId} AND status_ = 'ING' LIMIT 1
+    </select>
 </mapper>

+ 1 - 1
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -195,7 +195,6 @@ public class RoomServiceImpl implements RoomService {
             userResult.setHandUpOn(false);
             userResult.setJoinTime(curTime);
             saveRoomMember(userId,sysUser.getAvatar(), userName, roomId, roleEnum.getValue(), curTime);
-            imHelper.joinGroup(new String[]{userId}, roomId, roomId);
         } else {
             roleEnum = RoleEnum.getEnumByValue(member.getRole());
             if(roleEnum == RoleTeacher){
@@ -206,6 +205,7 @@ public class RoomServiceImpl implements RoomService {
             userResult.setHandUpOn(member.isHand());
             userResult.setJoinTime(member.getJoinDt());
         }
+        imHelper.joinGroup(new String[]{userId}, roomId, roomId);
 
         List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(null, courseId,null, null, null);
 

+ 44 - 1
mec-student/src/main/java/com/ym/mec/student/controller/ReplacementInstrumentActivityController.java

@@ -2,12 +2,16 @@ package com.ym.mec.student.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.ReplacementInstrumentCooperationDao;
+import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
 import com.ym.mec.biz.dal.dto.ReplacementPayDto;
 import com.ym.mec.biz.dal.entity.CooperationOrgan;
 import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
+import com.ym.mec.biz.dal.entity.ReplacementInstrumentCooperation;
 import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.service.CooperationOrganService;
 import com.ym.mec.biz.service.ReplacementInstrumentActivityService;
+import com.ym.mec.biz.service.ReplacementInstrumentCooperationService;
 import com.ym.mec.biz.service.StudentService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -37,6 +41,8 @@ public class ReplacementInstrumentActivityController extends BaseController {
     private StudentService studentService;
     @Autowired
     private CooperationOrganService cooperationOrganService;
+    @Autowired
+    private ReplacementInstrumentCooperationService replacementInstrumentCooperationService;
 
     @ApiOperation(value = "新增调查问卷")
     @PostMapping("/insert")
@@ -62,16 +68,18 @@ public class ReplacementInstrumentActivityController extends BaseController {
             }
             replacementInstrumentActivity.setCooperationOrganId(cooperationOrganId);
             replacementInstrumentActivity.setUserName(StringUtils.isEmpty(user.getUsername()) ? user.getRealName() : user.getUsername());
-            replacementInstrumentActivity.setMobileNo(user.getPhone());
             String subjectIdList = student.getSubjectIdList();
             if (StringUtils.isNotEmpty(subjectIdList)) {
                 replacementInstrumentActivity.setSubjectId(Integer.parseInt(subjectIdList.split(",")[0]));
             }
         }
+        replacementInstrumentActivity.setMobileNo(user.getPhone());
         CooperationOrgan cooperationOrgan = cooperationOrganService.get(cooperationOrganId);
         if (cooperationOrgan != null) {
             replacementInstrumentActivity.setCooperationOrganName(cooperationOrgan.getName());
         }
+        ReplacementInstrumentCooperation replacementInstrumentCooperation = replacementInstrumentCooperationService.getByCooperationId(cooperationOrganId);
+        replacementInstrumentActivity.setShowQuestion(replacementInstrumentCooperation.getShowQuestion());
         return succeed(replacementInstrumentActivity);
     }
 
@@ -96,10 +104,45 @@ public class ReplacementInstrumentActivityController extends BaseController {
         return succeed(replacementInstrumentActivityService.get(id));
     }
 
+    @ApiOperation(value = "获取置换的详情")
+    @GetMapping("/getInfo")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "置换id", required = true, dataType = "int")})
+    public HttpResponseResult<ReplacementInstrumentActivityStatDto> getInfo(Integer id) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败,请重新登陆");
+        }
+        return succeed(replacementInstrumentActivityService.getInfo(id));
+    }
+
     @ApiOperation(value = "置换支付")
     @PostMapping("/pay")
     @ApiImplicitParams({@ApiImplicitParam(name = "replacementPayDto", value = "支付参数", required = true, dataType = "ReplacementPayDto")})
     public HttpResponseResult pay(ReplacementPayDto replacementPayDto) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败,请重新登陆");
+        }
+        ReplacementInstrumentActivity replacementInstrumentActivity = replacementInstrumentActivityService.get(replacementPayDto.getId());
+        if (replacementInstrumentActivity == null) {
+            throw new BizException("乐器置换不存在,请核查");
+        }
+        if (!sysUser.getId().equals(replacementInstrumentActivity.getUserId())) {
+            throw new BizException("该乐器置换不属于您,请核查");
+        }
+
+        if (replacementInstrumentActivity.getInstrumentsId() == null || replacementInstrumentActivity.getInstrumentsId() == 0) {
+            throw new BizException("没有置换的乐器,请核查");
+        }
+
+        //是否已支付
+        if (replacementInstrumentActivity.getPayStatus().equals(2)) {
+            return failed("您已支付成功,请勿重复支付");
+        }
+        //判断用户是否已存在订单
+        if (replacementInstrumentActivity.getPayStatus().equals(1) && !replacementPayDto.getRePay()) {
+            return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+        }
         return succeed(replacementInstrumentActivityService.pay(replacementPayDto));
     }
 }

+ 6 - 2
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -87,6 +87,8 @@ public class StudentOrderController extends BaseController {
     private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
     @Autowired
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+    @Autowired
+    private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
 
 
     @Value("${spring.profiles.active:dev}")
@@ -178,6 +180,8 @@ public class StudentOrderController extends BaseController {
             }
         } else if (orderByOrderNo.getGroupType().equals(GroupType.GOODS_SELL)) {
             orderDetail.put("detail", studentGoodsSellDao.getStudentGoodsSellDto(orderNo));
+        } else if (orderByOrderNo.getGroupType().equals(GroupType.REPLACEMENT)) {
+            orderDetail.put("detail", replacementInstrumentActivityDao.getInfo(Integer.parseInt(orderByOrderNo.getMusicGroupId())));
         }
         return succeed(orderDetail);
     }
@@ -339,7 +343,7 @@ public class StudentOrderController extends BaseController {
     //    @Scheduled(cron = "0/30 * * * * ?")
     @GetMapping("/setSuccessStatus")
     public HttpResponseResult setSuccessStatus(String orderNo) throws Exception {
-        if (!profiles.equals("dev")&&!profiles.equals("test")) {
+        if (!profiles.equals("dev") && !profiles.equals("test")) {
             return failed("非法操作");
         }
         List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "ADAPAY");
@@ -779,7 +783,7 @@ public class StudentOrderController extends BaseController {
     }
 
     @GetMapping("/getMusicGroupApplyCalender")
-    public HttpResponseResult<MusicGroupPaymentCalender> getMusicGroupApplyCalender(String musicGroupId){
+    public HttpResponseResult<MusicGroupPaymentCalender> getMusicGroupApplyCalender(String musicGroupId) {
         MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderDao.getMusicGroupRegCalender(musicGroupId);
         if (musicGroupRegCalender != null) {
             MusicGroup musicGroup = musicGroupService.get(musicGroupId);

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -616,12 +616,12 @@ public class ExportController extends BaseController {
                     "课程分部", "课程组编号", "课程班名称", "乐团模式", "vip活动名称", "Vip课程类型", "阶梯奖励名称", "线上课/线下课", "线上课单价", "线下课单价",
                     "课程类别", "课时时长", "实际上课时长", "上课日期",
                     "上课时间", "教师签到状态", "教师签退状态", "教师签到时间", "教师签退时间", "考勤申诉处理状态", "处理意见",
-                    "主辅", "上课地点", "应到学员", "学员签到时间", "学员签退时间", "课时课酬", "阶梯奖励", "扣款原因"}, new String[]{
+                    "主辅", "上课地点", "应到学员", "学员签到时间", "学员签退时间", "课时课酬", "阶梯奖励", "扣款原因", "收入"}, new String[]{
                     "courseScheduleId", "teacherId", "teacherName", "teacherOrganName", "jobType",
                     "courseScheduleOrganName", "groupId", "groupName", "changeType", "vipActiveName", "vipCategoryName", "activeName", "teachMode", "onlineClassesUnitPrice", "offlineClassesUnitPrice",
                     "courseScheduleType", "signCourseScheduleTime", "currentTime", "classDate", "courseScheduleStartTime", "signInStatus",
                     "signOutStatus", "signInTime", "signOutTime", "complaintsStatus", "disposeContent", "teacherRole", "address", "studentNum",
-                    "studentSignInTime", "studentSignOutTime", "price", "rewards", "deductionReason"}, rows);
+                    "studentSignInTime", "studentSignOutTime", "price", "rewards", "deductionReason", "courseIncome"}, rows);
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");
             response.flushBuffer();

+ 119 - 12
mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentActivityController.java

@@ -4,29 +4,43 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.ReplacementInstrumentActivityDao;
+import com.ym.mec.biz.dal.dao.ReplacementInstrumentDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.ReplacementInstrumentActivityStatDto;
-import com.ym.mec.biz.dal.entity.Employee;
-import com.ym.mec.biz.dal.entity.ReplacementInstrumentActivity;
+import com.ym.mec.biz.dal.dto.StudentInstrumentExportDto;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.ReplacementInstrumentActivityQueryInfo;
 import com.ym.mec.biz.service.ReplacementInstrumentActivityService;
+import com.ym.mec.biz.service.ReplacementInstrumentCooperationService;
+import com.ym.mec.biz.service.SysMessageService;
 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.thirdparty.message.MessageSenderPluginContext;
+import com.ym.mec.util.date.DateUtil;
+import com.ym.mec.util.excel.POIUtil;
+import com.ym.mec.util.http.HttpUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 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.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.*;
 
 @RequestMapping("replacementInstrumentActivity")
-@Api(tags = "收费类型服务")
+@Api(tags = "乐器置换-调查问卷服务")
 @RestController
 public class ReplacementInstrumentActivityController extends BaseController {
 
@@ -38,11 +52,19 @@ public class ReplacementInstrumentActivityController extends BaseController {
     private EmployeeDao employeeDao;
     @Autowired
     private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
+    @Autowired
+    private ReplacementInstrumentCooperationService replacementInstrumentCooperationService;
+    @Autowired
+    private ReplacementInstrumentDao replacementInstrumentDao;
+    @Autowired
+    private SysConfigDao sysConfigDao;
+    @Autowired
+    private SysMessageService sysMessageService;
 
     @ApiOperation(value = "分页查询列表")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/queryPage')")
-    public Object queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
+    public HttpResponseResult<PageInfo<ReplacementInstrumentActivityStatDto>> queryPage(ReplacementInstrumentActivityQueryInfo queryInfo) {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (sysUser == null) {
             return failed("用户信息获取失败");
@@ -58,7 +80,7 @@ public class ReplacementInstrumentActivityController extends BaseController {
                 return failed("非法请求");
             }
         }
-        return succeed(replacementInstrumentActivityService.queryPage(queryInfo));
+        return succeed(replacementInstrumentActivityService.getPageList(queryInfo));
     }
 
     @ApiOperation(value = "统计信息查询")
@@ -68,16 +90,101 @@ public class ReplacementInstrumentActivityController extends BaseController {
     }
 
     @ApiOperation(value = "修改")
-    @GetMapping("/update")
+    @PostMapping("/update")
     @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/update')")
     public HttpResponseResult<ReplacementInstrumentActivity> update(ReplacementInstrumentActivity replacementInstrumentActivity) {
         ReplacementInstrumentActivity oldReplacementInstrumentActivity = replacementInstrumentActivityDao.getLock(replacementInstrumentActivity.getId());
-        if (oldReplacementInstrumentActivity.getInstrumentsId().equals(replacementInstrumentActivity.getInstrumentsId())) {
-            return succeed();
+        if (!oldReplacementInstrumentActivity.getPayStatus().equals(0)) {
+            return failed("支付中、已支付的乐器置换,不能修改");
         }
+
+        ReplacementInstrumentCooperation byCooperationId = replacementInstrumentCooperationService.getByCooperationId(oldReplacementInstrumentActivity.getCooperationOrganId());
+        if (byCooperationId.getOpenPay().equals(YesOrNoEnum.YES) && oldReplacementInstrumentActivity.getInstrumentsId() == null && replacementInstrumentActivity.getInstrumentsId() != null) {
+            ReplacementInstrument replacementInstrument = replacementInstrumentDao.get(replacementInstrumentActivity.getInstrumentsId());
+            Map<Integer, String> userMap = new HashMap<>();
+            Map<Integer, String> userPhoneMap = new HashMap<>();
+            Integer userId = oldReplacementInstrumentActivity.getUserId();
+            String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+            String pushUrl = baseApiUrl + "/#/questionGoodsSale?id=";
+            userMap.put(userId, userId.toString());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
+                    userMap, null, 0, "5?" + pushUrl + replacementInstrumentActivity.getId(), "STUDENT", replacementInstrument.getBrand(), "");
+
+            userPhoneMap.put(userId, oldReplacementInstrumentActivity.getMobileNo());
+            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.REPLACEMENT_PAY_PUSH,
+                    userPhoneMap, null, 0, null, "STUDENT", replacementInstrument.getBrand(), HttpUtil.getSortUrl(pushUrl + replacementInstrumentActivity.getId()));
+        }
+
+        oldReplacementInstrumentActivity.setSubjectId(replacementInstrumentActivity.getSubjectId());
         oldReplacementInstrumentActivity.setInstrumentsId(replacementInstrumentActivity.getInstrumentsId());
         oldReplacementInstrumentActivity.setUpdateTime(new Date());
-        replacementInstrumentActivityService.update(replacementInstrumentActivity);
+        replacementInstrumentActivityService.update(oldReplacementInstrumentActivity);
+
         return succeed(replacementInstrumentActivity);
     }
+
+    @ApiOperation(value = "导出")
+    @RequestMapping("/export")
+    @PreAuthorize("@pcs.hasPermissions('replacementInstrumentActivity/export')")
+    public void export(ReplacementInstrumentActivityQueryInfo queryInfo, HttpServletResponse response) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            throw new BizException("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
+            throw new BizException("用户所在分部异常");
+        } else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
+                throw new BizException("非法请求");
+            }
+        }
+        queryInfo.setRows(99999);
+        PageInfo<ReplacementInstrumentActivityStatDto> pageList = replacementInstrumentActivityService.getPageList(queryInfo);
+
+        if (pageList.getTotal() <= 0) {
+            throw new BizException("没有可导出的记录");
+        }
+        for (ReplacementInstrumentActivityStatDto row : pageList.getRows()) {
+            if (row.getQuestionResult().substring(0, 1).equals("1")) {
+                row.setHasYesFirstAnswer("是");
+            } else {
+                row.setHasYesFirstAnswer("否");
+            }
+            if(row.getInstrumentsId() == null){
+                row.setHasInstrumentsId("否");
+            }else {
+                row.setHasInstrumentsId("是");
+            }
+        }
+
+        OutputStream outputStream = response.getOutputStream();
+        HSSFWorkbook workbook = null;
+        try {
+            String[] header = {"分部", "合作单位编号", "合作单位", "学员编号", "学员姓名", "联系电话", "声部", "品牌", "型号", "是否参与市赛", "是否置换乐器"};
+            String[] body = {"organName", "cooperationOrganId", "cooperationOrganName", "userId", "userName", "mobileNo", "subjectName", "brand", "specification","hasYesFirstAnswer","hasInstrumentsId"};
+            workbook = POIUtil.exportExcel(header, body, pageList.getRows());
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attachment;filename=replacement-" + DateUtil.getDate(new Date()) + ".xls");
+            response.flushBuffer();
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+            outputStream.flush();
+            workbook.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (outputStream != null) {
+                try {
+                    workbook.close();
+                    outputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentController.java

@@ -12,7 +12,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 @RequestMapping("replacementInstrument")
-@Api(tags = "收费类型服务")
+@Api(tags = "乐器置换-乐器服务")
 @RestController
 public class ReplacementInstrumentController extends BaseController {
 

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ReplacementInstrumentCooperationController.java

@@ -25,7 +25,7 @@ import java.util.Date;
 import java.util.List;
 
 @RequestMapping("replacementInstrumentCooperation")
-@Api(tags = "收费类型服务")
+@Api(tags = "乐器置换-生成链接管理服务")
 @RestController
 public class ReplacementInstrumentCooperationController extends BaseController {