Browse Source

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

zouxuan 3 years ago
parent
commit
727360fe56
35 changed files with 1048 additions and 582 deletions
  1. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/GoodsDao.java
  2. 0 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ImLiveBroadcastRoomDao.java
  3. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ImLiveRoomPurviewDao.java
  4. 1 55
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ImLiveBroadcastRoomDto.java
  5. 2 41
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImLiveBroadcastRoom.java
  6. 7 7
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImLiveRoomPurview.java
  7. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrderDetail.java
  8. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java
  9. 1 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TemplateTypeEnum.java
  10. 1 34
      mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ImLiveBroadcastRoomVo.java
  11. 8 7
      mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java
  12. 2 2
      mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveBroadcastRoomService.java
  13. 20 12
      mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveRoomPurviewService.java
  14. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java
  15. 16 105
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java
  16. 125 45
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomPurviewServiceImpl.java
  17. 1 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomReservationServiceImpl.java
  18. 35 10
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java
  19. 2 13
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PlatformProductServiceImpl.java
  20. 54 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java
  21. 22 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  22. 216 22
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  23. 121 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java
  24. 7 59
      mec-biz/src/main/resources/config/mybatis/ImLiveBroadcastRoomMapper.xml
  25. 77 55
      mec-biz/src/main/resources/config/mybatis/ImLiveRoomPurviewMapper.xml
  26. 4 38
      mec-biz/src/main/resources/config/mybatis/ImLiveRoomReservationMapper.xml
  27. 11 4
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml
  28. 19 1
      mec-common/common-core/src/main/java/com/ym/mec/common/page/WrapperUtil.java
  29. 10 0
      mec-im/src/main/java/com/ym/controller/LiveRoomController.java
  30. 52 3
      mec-student/src/main/java/com/ym/mec/student/controller/ImLiveBroadcastRoomController.java
  31. 1 1
      mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java
  32. 156 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveBroadcastRoomController.java
  33. 8 7
      mec-web/src/main/java/com/ym/mec/web/controller/ImLiveBroadcastRoomController.java
  34. 38 18
      mec-web/src/main/java/com/ym/mec/web/controller/ImLiveRoomPurviewController.java
  35. 4 0
      mec-web/src/main/resources/columnMapper.ini

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

@@ -59,7 +59,7 @@ public interface GoodsDao extends BaseDAO<Integer, Goods> {
      * @author Joburgess
      * @date 2020.09.28
      */
-    void batchUpdate(@Param("goodsList") List<Goods> goodsList);
+    int batchUpdate(@Param("goodsList") List<Goods> goodsList);
 
     /**
      * 获取商品列表

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

@@ -29,8 +29,6 @@ public interface ImLiveBroadcastRoomDao extends BaseMapper<ImLiveBroadcastRoom>
 
     int insertBatch(@Param("entities") List<ImLiveBroadcastRoom> entities);
 
-    IPage<Map<Integer, Object>> queryUserPageByTenantId(Page<Map<Integer, Object>> page);
-
     List<BaseRoomUserVo> queryBaseUserInfo(@Param("list") List<Integer> list);
 
     /**

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

@@ -19,10 +19,10 @@ public interface ImLiveRoomPurviewDao extends BaseMapper<ImLiveRoomPurview> {
 
     int insertBatch(@Param("entities") List<ImLiveRoomPurview> entities);
 
-    <T> IPage<T> queryStudent(Page<T> page, @Param("param") Map<String, Object> param);
-
     <T> IPage<T> selectRoomPurviewStudent(Page<T> page, @Param("param") Map<String, Object> param);
 
+    <T> List<T> selectRoomPurviewStudent(@Param("param") Map<String, Object> param);
+
     <T> IPage<T> selectRoomPurviewGroup(Page<T> page, @Param("param") Map<String, Object> param);
 
 }

+ 1 - 55
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ImLiveBroadcastRoomDto.java

@@ -49,24 +49,9 @@ public class ImLiveBroadcastRoomDto implements Serializable {
     private RoomConfig roomConfig;
 
     @NotBlank(message = "直播间类型不能为空")
-    @ApiModelProperty(value = "直播间可见类型-全部可见ALL / 分部可见ORGAN / 学校可见SCHOOL / 乐团可见TEAM / 群组可见GROUP / 学生可见STUDENT")
+    @ApiModelProperty(value = "直播间可见类型-全部可见 ALL / 部分可见 PRIVATE")
     private String popularizeType;
 
-    @ApiModelProperty(value = "分部id-多个id逗号分割")
-    private String popularizeOrgIds;
-
-    @ApiModelProperty(value = "学校id-合作单位id,多个id逗号分割")
-    private String popularizeSchoolIds;
-
-    @ApiModelProperty(value = "乐团id,多个id逗号分割")
-    private String popularizeTeamIds;
-
-    @ApiModelProperty(value = "群组id,多个id逗号分割")
-    private String popularizeGroupIds;
-
-    @ApiModelProperty(value = "学生id,多个id逗号分割")
-    private String popularizeStudentIds;
-
     @ApiModel(value = "房间配置")
     public static class RoomConfig implements Serializable {
 
@@ -198,44 +183,5 @@ public class ImLiveBroadcastRoomDto implements Serializable {
         this.popularizeType = popularizeType;
     }
 
-    public String getPopularizeOrgIds() {
-        return popularizeOrgIds;
-    }
-
-    public void setPopularizeOrgIds(String popularizeOrgIds) {
-        this.popularizeOrgIds = popularizeOrgIds;
-    }
-
-    public String getPopularizeSchoolIds() {
-        return popularizeSchoolIds;
-    }
-
-    public void setPopularizeSchoolIds(String popularizeSchoolIds) {
-        this.popularizeSchoolIds = popularizeSchoolIds;
-    }
-
-    public String getPopularizeTeamIds() {
-        return popularizeTeamIds;
-    }
-
-    public void setPopularizeTeamIds(String popularizeTeamIds) {
-        this.popularizeTeamIds = popularizeTeamIds;
-    }
-
-    public String getPopularizeGroupIds() {
-        return popularizeGroupIds;
-    }
-
-    public void setPopularizeGroupIds(String popularizeGroupIds) {
-        this.popularizeGroupIds = popularizeGroupIds;
-    }
-
-    public String getPopularizeStudentIds() {
-        return popularizeStudentIds;
-    }
-
-    public void setPopularizeStudentIds(String popularizeStudentIds) {
-        this.popularizeStudentIds = popularizeStudentIds;
-    }
 }
 

+ 2 - 41
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImLiveBroadcastRoom.java

@@ -20,11 +20,7 @@ import java.io.Serializable;
 public class ImLiveBroadcastRoom implements Serializable {
 
     public static final String ALL = "ALL";
-    public static final String ORGAN = "ORGAN";
-    public static final String SCHOOL = "SCHOOL";
-    public static final String TEAM = "TEAM";
-    public static final String GROUP = "GROUP";
-    public static final String STUDENT = "STUDENT";
+    public static final String PRIVATE = "PRIVATE";
 
     @TableId(value = "id_", type = IdType.AUTO)
     @ApiModelProperty(value = "主键")
@@ -79,21 +75,9 @@ public class ImLiveBroadcastRoom implements Serializable {
     private Integer popularize;
 
     @TableField("popularize_type_")
-    @ApiModelProperty(value = "直播间可见类型-全部可见ALL / 部分分部可见ORGAN / 部分合作单位可见SCHOOL / 乐团可见TEAM / 群组可见GROUP / 学生可见STUDENT")
+    @ApiModelProperty(value = "直播间可见类型-全部可见 ALL / 部分可见 PRIVATE")
     private String popularizeType;
 
-    @TableField("popularize_org_ids_")
-    @ApiModelProperty(value = "分部id-多个id逗号分割")
-    private String popularizeOrgIds;
-
-    @ApiModelProperty(value = "学校id-合作单位id,多个id逗号分割")
-    @TableField("popularize_school_ids_")
-    private String popularizeSchoolIds;
-
-    @ApiModelProperty(value = "乐团id,多个id逗号分割")
-    @TableField("popularize_team_ids_")
-    private String popularizeTeamIds;
-
     @TableField("created_by_")
     @ApiModelProperty(value = "创建人")
     private Integer createdBy;
@@ -274,28 +258,5 @@ public class ImLiveBroadcastRoom implements Serializable {
         this.popularizeType = popularizeType;
     }
 
-    public String getPopularizeOrgIds() {
-        return popularizeOrgIds;
-    }
-
-    public void setPopularizeOrgIds(String popularizeOrgIds) {
-        this.popularizeOrgIds = popularizeOrgIds;
-    }
-
-    public String getPopularizeSchoolIds() {
-        return popularizeSchoolIds;
-    }
-
-    public void setPopularizeSchoolIds(String popularizeSchoolIds) {
-        this.popularizeSchoolIds = popularizeSchoolIds;
-    }
-
-    public String getPopularizeTeamIds() {
-        return popularizeTeamIds;
-    }
-
-    public void setPopularizeTeamIds(String popularizeTeamIds) {
-        this.popularizeTeamIds = popularizeTeamIds;
-    }
 }
 

+ 7 - 7
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/ImLiveRoomPurview.java

@@ -27,12 +27,12 @@ public class ImLiveRoomPurview implements Serializable {
     @ApiModelProperty(value = "房间编号")
     private String roomUid;
 
-    @TableField("biz_id_")
+    @TableField("user_id_")
     @ApiModelProperty(value = "业务id,如果类型是用户则是需要将VARCHAR类型转换为int再关联查询会更好")
-    private String bizId;
+    private Integer userId;
 
     @TableField("type_")
-    @ApiModelProperty(value = "类型-STUDENT 学员  GROUP-群组")
+    @ApiModelProperty(value = "保留字段-类型-STUDENT 学员  老师TEACHER  管理员ADMIN")
     private String type;
 
     @TableField("created_by_")
@@ -61,12 +61,12 @@ public class ImLiveRoomPurview implements Serializable {
         this.roomUid = roomUid;
     }
 
-    public String getBizId() {
-        return bizId;
+    public Integer getUserId() {
+        return userId;
     }
 
-    public void setBizId(String bizId) {
-        this.bizId = bizId;
+    public void setUserId(Integer userId) {
+        this.userId = userId;
     }
 
     public String getType() {

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

@@ -64,6 +64,8 @@ public class StudentPaymentOrderDetail extends BaseEntity {
 	private String incomeItem;
 	
 	private BigDecimal income;
+	
+	private String minuendStockGoodsIdList;
 
 	@ApiModelProperty(value = "子商品列表",required = false)
 	private List<Goods> childGoodsList;
@@ -228,4 +230,12 @@ public class StudentPaymentOrderDetail extends BaseEntity {
 	public void setIncome(BigDecimal income) {
 		this.income = income;
 	}
+
+	public String getMinuendStockGoodsIdList() {
+		return minuendStockGoodsIdList;
+	}
+
+	public void setMinuendStockGoodsIdList(String minuendStockGoodsIdList) {
+		this.minuendStockGoodsIdList = minuendStockGoodsIdList;
+	}
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java

@@ -29,7 +29,8 @@ public enum OrderDetailTypeEnum implements BaseEnum<String, OrderDetailTypeEnum>
     MAINTENANCE("MAINTENANCE","乐保服务"),
     CLOUD_TEACHER("CLOUD_TEACHER","云教练"),
     CLOUD_TEACHER_PLUS("CLOUD_TEACHER_PLUS","云教练"),
-    THEORY_COURSE("THEORY_COURSE", "乐理课");
+    THEORY_COURSE("THEORY_COURSE", "乐理课"),
+    REPAIR("REPAIR", "乐器维修");
 
     private String code;
 

+ 1 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/TemplateTypeEnum.java

@@ -9,11 +9,9 @@ public enum TemplateTypeEnum implements BaseEnum<String, TemplateTypeEnum> {
     REDEMPTIONCODE("REDEMPTION_CODE", "兑换码分配模板表"),
     OA_QUIT_MUSIC_GROUP("OA_QUIT_MUSIC_GROUP", "乐团退费模板"),
     EXTERNAL_STUDENT_IMPORT_MUSIC_GROUP("EXTERNAL_STUDENT_IMPORT_MUSIC_GROUP", "外部学生入团导入模板"),
-
     BUY_FREE_LIVE_THEORY_COURSE("BUY_FREE_LIVE_THEORY_COURSE", "直播临时活动学员购买导入模板"),
     LIVE_TEACHER_CARD("LIVE_TEACHER_CARD","直播临时活动上课老师名片导入模板"),
-    ;
-
+    LIVE_ROOM_PURVIEW_USER("LIVE_ROOM_PURVIEW_USER", "直播间用户观看权限表");
 
     private String code;
 

+ 1 - 34
mec-biz/src/main/java/com/ym/mec/biz/dal/vo/ImLiveBroadcastRoomVo.java

@@ -79,18 +79,9 @@ public class ImLiveBroadcastRoomVo implements Serializable {
     @ApiModelProperty(value = "当前登录人是否是黑名单用户 0否 1是")
     private Integer blacklistFlag = 0;
 
-    @ApiModelProperty(value = "推广的直播间可见类型-全部可见ALL、部分分部可见ORGAN、部分合作单位可见SCHOOL")
+    @ApiModelProperty(value = "直播间可见类型-全部可见 ALL / 部分可见 PRIVATE")
     private String popularizeType;
 
-    @ApiModelProperty(value = "分部id-多个id逗号分割")
-    private String popularizeOrgIds;
-
-    @ApiModelProperty(value = "学校id-合作单位id,多个id逗号分割")
-    private String popularizeSchoolIds;
-
-    @ApiModelProperty(value = "乐团id,多个id逗号分割")
-    private String popularizeTeamIds;
-
     @ApiModelProperty(value = "点赞数")
     private Integer likeNum;
     @ApiModelProperty(value = "当前观看人数")
@@ -314,29 +305,5 @@ public class ImLiveBroadcastRoomVo implements Serializable {
     public void setPopularizeType(String popularizeType) {
         this.popularizeType = popularizeType;
     }
-
-    public String getPopularizeOrgIds() {
-        return popularizeOrgIds;
-    }
-
-    public void setPopularizeOrgIds(String popularizeOrgIds) {
-        this.popularizeOrgIds = popularizeOrgIds;
-    }
-
-    public String getPopularizeSchoolIds() {
-        return popularizeSchoolIds;
-    }
-
-    public void setPopularizeSchoolIds(String popularizeSchoolIds) {
-        this.popularizeSchoolIds = popularizeSchoolIds;
-    }
-
-    public String getPopularizeTeamIds() {
-        return popularizeTeamIds;
-    }
-
-    public void setPopularizeTeamIds(String popularizeTeamIds) {
-        this.popularizeTeamIds = popularizeTeamIds;
-    }
 }
 

+ 8 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/GoodsService.java

@@ -1,20 +1,17 @@
 package com.ym.mec.biz.service;
 
+import java.util.List;
+
+import org.springframework.web.multipart.MultipartFile;
+
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.entity.SellOrder;
 import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.dal.page.GoodsQuery;
-import com.ym.mec.biz.dal.page.GoodsQueryInfo;
-import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
-import org.apache.ibatis.annotations.Param;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.util.List;
-
 public interface GoodsService extends BaseService<Integer, Goods> {
 
     void addGoods(Goods goods, Integer operatorId);
@@ -126,4 +123,8 @@ public interface GoodsService extends BaseService<Integer, Goods> {
      * @return
      */
     Goods getDetail(Integer goodsId);
+    
+    List<Goods> getGoodsWithLocked(String goodsIds);
+    
+    int batchUpdate(List<Goods> goodsList);
 }

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

@@ -31,9 +31,9 @@ public interface ImLiveBroadcastRoomService extends IService<ImLiveBroadcastRoom
 
     ImLiveBroadcastRoomVo queryRoomInfo(String roomUid);
 
-    ImLiveBroadcastRoomVo add(ImLiveBroadcastRoomDto dto);
+    void add(ImLiveBroadcastRoomDto dto);
 
-    ImLiveBroadcastRoomVo update(ImLiveBroadcastRoomDto dto);
+    void update(ImLiveBroadcastRoomDto dto);
 
     void whetherChat(Integer id, Integer whetherChat);
 

+ 20 - 12
mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveRoomPurviewService.java

@@ -5,8 +5,8 @@ import com.ym.mec.biz.dal.dao.ImLiveRoomPurviewDao;
 import com.ym.mec.biz.dal.dto.SysUserDto;
 import com.ym.mec.biz.dal.entity.ImGroup;
 import com.ym.mec.biz.dal.entity.ImLiveRoomPurview;
-import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo;
 import com.ym.mec.common.page.PageInfo;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.Map;
 
@@ -21,7 +21,21 @@ public interface ImLiveRoomPurviewService extends IService<ImLiveRoomPurview> {
     ImLiveRoomPurviewDao getDao();
 
     /**
-     * 添加观看权限数据
+     * 批量添加/根据查询条件添加房间观看权限
+     *
+     * @param param 参数
+     *              <p> - search 搜索关键字
+     *              <p> - subjectId 声部ID
+     *              <p> - organIds 分部ID
+     *              <p> - groupIds 群聊ID
+     *              <p> - teamIds 乐团ID
+     *              <p> - schoolIds 学校id/合作单位id
+     *              <p> - roomUid 直播间UID
+     */
+    void addByCondition(Map<String, Object> param);
+
+    /**
+     * 指定多个学员id添加观看权限数据
      *
      * @param ids     bizId
      * @param roomUid 直播间UID
@@ -49,16 +63,6 @@ public interface ImLiveRoomPurviewService extends IService<ImLiveRoomPurview> {
     PageInfo<SysUserDto> queryStudent(Map<String, Object> param);
 
     /**
-     * 查询群聊列表-观看权限
-     *
-     * @param param 参数
-     *              <p> - search 搜索关键字
-     *              <p> - roomUid 直播间UID
-     *              <p> - groupType 群类型
-     */
-    PageInfo<ImGroup> queryGroup(Map<String, Object> param);
-
-    /**
      * 选择列表-观看权限-查询学员列表
      *
      * @param param 参数
@@ -82,5 +86,9 @@ public interface ImLiveRoomPurviewService extends IService<ImLiveRoomPurview> {
      */
     PageInfo<ImGroup> selectRoomPurviewGroup(Map<String, Object> param);
 
+    /**
+     * 导入观看权限-人员
+     */
+    String importPurviewUser(MultipartFile file, String roomUid) throws Exception;
 }
 

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -20,6 +20,7 @@ import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.excel.POIUtil;
 import com.ym.mec.util.ini.IniFileUtil;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.PictureData;
 import org.slf4j.Logger;
@@ -634,4 +635,15 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		}
 		return goods;
 	}
+
+	@Override
+	public List<Goods> getGoodsWithLocked(String goodsIds) {
+		List<Integer> list = Arrays.stream(goodsIds.split(",")).map(Integer :: valueOf).collect(Collectors.toList());
+		return goodsDao.lockGoods(list);
+	}
+
+	@Override
+	public int batchUpdate(List<Goods> goodsList) {
+		return goodsDao.batchUpdate(goodsList);
+	}
 }

+ 16 - 105
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -2,7 +2,6 @@ package com.ym.mec.biz.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -17,6 +16,7 @@ import com.ym.mec.biz.dal.dao.LiveGoodsMapperDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.ImLiveBroadcastRoomDto;
 import com.ym.mec.biz.dal.dto.RoomReservationUserSearch;
+import com.ym.mec.biz.dal.dto.SysUserDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.page.LiveRoomGoodsOrderQueryInfo;
@@ -92,8 +92,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
     private ImLiveRoomBlackService imLiveRoomBlackService;
     @Autowired
     private EmployeeService employeeService;
-    @Autowired
-    private ImLiveRoomPurviewService imLiveRoomPurviewService;
 
     //待替换的变量
     public static final String USER_ID = "${userId}";
@@ -125,7 +123,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      *
      * @param roomUid 房间uid
      * @param userId  用户id
-     * @param osType  1:学生端
+     * @param osType  1:学生端 2:老师端
      */
     @Override
     public ImLiveBroadcastRoomVo queryRoomAndCheck(String roomUid, Integer userId, Integer osType) {
@@ -217,25 +215,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         Page<ImLiveBroadcastRoomVo> pageInfo = PageUtil.concatTimePage(param, "startTime", "endTime");
         pageInfo.setDesc("a.created_time_");
         param.put("tenantId", TenantContextHolder.getTenantId());
-        //查询该人员分部  及 分部下包含的学校(合作单位)
-        SysUser sysUser = getSysUser();
-        //分部
-        String organIds;
-        //如果是超管就查询当前机构所有的直播间
-        if (sysUser.getTenantId() == -1 || sysUser.getIsSuperAdmin()) {
-            param.put("allRoom", 1);
-        } else {
-            Employee employee = employeeService.get(sysUser.getId());
-            if (Objects.nonNull(employee) && Objects.nonNull(employee.getOrganIdList())) {
-                organIds = employee.getOrganIdList();
-                param.put("organIds", organIds);
-                String schoolIds = baseMapper.querySchoolIds(organIds);
-                if (StringUtils.isNotBlank(schoolIds)) {
-                    param.put("schoolIds", schoolIds);
-                }
-            }
-        }
-        param.put("userId", sysUser.getId());
         IPage<ImLiveBroadcastRoomVo> page = baseMapper.queryPage(pageInfo, param);
 
         // 查询预约人数
@@ -267,7 +246,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public ImLiveBroadcastRoomVo add(ImLiveBroadcastRoomDto dto) {
+    public void add(ImLiveBroadcastRoomDto dto) {
         SysUser sysUser = getSysUser(dto.getSpeakerId());
         Date now = new Date();
         if (now.getTime() > dto.getLiveStartTime().getTime()) {
@@ -284,7 +263,6 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         obj.setCreatedBy(getSysUser().getId());
         obj.setCreatedTime(now);
         this.save(obj);
-        return getImLiveBroadcastRoomVo(roomUid);
     }
 
     /**
@@ -294,7 +272,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public ImLiveBroadcastRoomVo update(ImLiveBroadcastRoomDto dto) {
+    public void update(ImLiveBroadcastRoomDto dto) {
         Date now = new Date();
         Integer userId = getSysUser().getId();
         ImLiveBroadcastRoom obj = this.getById(dto.getId());
@@ -304,94 +282,16 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         if (obj.getLiveState() == 1) {
             obj.setRoomConfig(JSONObject.toJSONString(dto.getRoomConfig()));
             this.updateById(obj);
-            return getImLiveBroadcastRoomVo(obj.getRoomUid());
+            return;
         }
         if (now.getTime() > dto.getLiveStartTime().getTime()) {
             throw new BizException("设置的直播开始时间不能小于当前时间");
         }
         //本次修改后的类型
-        String popularizeType = dto.getPopularizeType();
         BeanUtils.copyProperties(dto, obj);
-        //修改-删除直播可见权限部分数据
-        deleteRoomPurview(obj, popularizeType);
-        //添加直播间可见权限-只处理了群组和学生可是权限-其他的走原来的方式
-        insertGroupStudentPurview(dto, userId, obj.getRoomUid());
-
         obj.setRoomConfig(JSONObject.toJSONString(dto.getRoomConfig()));
         log.info("update room  >>>  :{}", JSONObject.toJSONString(obj));
         this.updateById(obj);
-        return getImLiveBroadcastRoomVo(obj.getRoomUid());
-    }
-
-    //添加直播间可见权限-只处理了群组和学生可是权限
-    private void insertGroupStudentPurview(ImLiveBroadcastRoomDto dto, Integer userId, String roomUid) {
-        Date now = new Date();
-        if (WrapperUtil.checkStr(dto.getPopularizeType(), ImLiveBroadcastRoom.GROUP, ImLiveBroadcastRoom.STUDENT)) {
-            List<String> bizIdList = new ArrayList<>();
-            if (ImLiveBroadcastRoom.GROUP.equals(dto.getPopularizeType())) {
-                bizIdList = WrapperUtil.toList(dto.getPopularizeGroupIds());
-            }
-            if (ImLiveBroadcastRoom.STUDENT.equals(dto.getPopularizeType())) {
-                bizIdList = WrapperUtil.toList(dto.getPopularizeStudentIds());
-            }
-            if (CollectionUtils.isEmpty(bizIdList)) {
-                return;
-            }
-            List<ImLiveRoomPurview> collect = bizIdList.stream().map((id) -> {
-                ImLiveRoomPurview imLiveRoomPurview = new ImLiveRoomPurview();
-                imLiveRoomPurview.setRoomUid(roomUid);
-                imLiveRoomPurview.setBizId(id);
-                imLiveRoomPurview.setType(dto.getPopularizeType());
-                imLiveRoomPurview.setCreatedBy(userId);
-                imLiveRoomPurview.setCreatedTime(now);
-                return imLiveRoomPurview;
-            }).collect(Collectors.toList());
-            Lists.partition(collect, 50).forEach(list -> imLiveRoomPurviewService.saveBatch(list));
-        }
-    }
-
-    private void deleteRoomPurview(ImLiveBroadcastRoom obj, String popularizeType) {
-        LambdaQueryWrapper<ImLiveRoomPurview> queryWrapper = null;
-        switch (popularizeType) {
-            case ImLiveBroadcastRoom.ALL:
-                obj.setPopularizeOrgIds(null);
-                obj.setPopularizeSchoolIds(null);
-                obj.setPopularizeTeamIds(null);
-                //删除purview表的数据
-                queryWrapper = Wrappers.lambdaQuery();
-                break;
-            case ImLiveBroadcastRoom.ORGAN:
-                obj.setPopularizeSchoolIds(null);
-                obj.setPopularizeTeamIds(null);
-                //删除purview表中不等于分部的数据
-                queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
-                        .ne(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.ORGAN);
-                break;
-            case ImLiveBroadcastRoom.SCHOOL:
-                obj.setPopularizeTeamIds(null);
-                //删除purview表中对应的数据
-                queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
-                        .in(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.TEAM, ImLiveBroadcastRoom.GROUP,
-                                ImLiveBroadcastRoom.STUDENT);
-                break;
-            case ImLiveBroadcastRoom.TEAM:
-                queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
-                        .in(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.SCHOOL, ImLiveBroadcastRoom.GROUP,
-                                ImLiveBroadcastRoom.STUDENT);
-                break;
-            case ImLiveBroadcastRoom.GROUP:
-                queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
-                        .ne(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.GROUP);
-                break;
-            case ImLiveBroadcastRoom.STUDENT:
-                queryWrapper = Wrappers.<ImLiveRoomPurview>lambdaQuery()
-                        .ne(ImLiveRoomPurview::getType, ImLiveBroadcastRoom.STUDENT);
-            default:
-                break;
-        }
-        if (Objects.nonNull(queryWrapper)) {
-            imLiveRoomPurviewService.remove(queryWrapper.eq(ImLiveRoomPurview::getRoomUid, obj.getRoomUid()));
-        }
     }
 
     /**
@@ -1220,10 +1120,21 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
                 .orElseThrow(() -> new BizException("用户不存在."));
     }
 
+    @Autowired
+    private ImLiveRoomPurviewService imLiveRoomPurviewService;
+
     /**
      * 测试
      */
     public Map<String, Object> test(String roomUid) {
+//        Map<String, Object> map = new HashMap<>();
+//        TenantContextHolder.setTenantId(1);
+//        map.put("roomUid", roomUid);
+//        map.put("groupIds", "22053019304300001,1141,1");
+//        map.put("subjectIds", "2,5,4");
+//        PageInfo<SysUserDto> sysUserDtoPageInfo = imLiveRoomPurviewService.selectRoomPurviewStudent(map);
+//        System.out.println(sysUserDtoPageInfo);
+
         //test
         Map<String, Object> result = new HashMap<>();
         //校验房间心跳是否过期没续租

+ 125 - 45
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomPurviewServiceImpl.java

@@ -8,24 +8,34 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.ImLiveRoomPurviewDao;
 import com.ym.mec.biz.dal.dto.SysUserDto;
-import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.ImGroup;
 import com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom;
 import com.ym.mec.biz.dal.entity.ImLiveRoomPurview;
-import com.ym.mec.biz.service.EmployeeService;
+import com.ym.mec.biz.dal.enums.TemplateTypeEnum;
 import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
 import com.ym.mec.biz.service.ImLiveRoomPurviewService;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.page.WrapperUtil;
+import com.ym.mec.common.tenant.TenantContextHolder;
+import com.ym.mec.util.excel.POIUtil;
+import com.ym.mec.util.ini.IniFileUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * 直播间的观看权限表(ImLiveRoomPurview)表服务实现类
@@ -39,8 +49,6 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
     private final static Logger log = LoggerFactory.getLogger(ImLiveRoomPurviewServiceImpl.class);
 
     @Autowired
-    private EmployeeService employeeService;
-    @Autowired
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
@@ -50,7 +58,32 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
     }
 
     /**
-     * 添加观看权限数据
+     * 批量添加/根据查询条件添加房间观看权限
+     *
+     * @param param 参数
+     *              <p> - search 搜索关键字
+     *              <p> - subjectId 声部ID
+     *              <p> - organIds 分部ID
+     *              <p> - groupIds 群聊ID
+     *              <p> - teamIds 乐团ID
+     *              <p> - schoolIds 学校id/合作单位id
+     *              <p> - roomUid 直播间UID
+     */
+    public void addByCondition(Map<String, Object> param) {
+        String roomUid = WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
+        param.put("tenantId", TenantContextHolder.getTenantId());
+        //根据条件查询学员
+        List<SysUserDto> studentList = baseMapper.selectRoomPurviewStudent(param);
+        if (CollectionUtils.isEmpty(studentList)) {
+            throw new BizException("没有查询到人员信息");
+        }
+        Stream<Integer> userIdList = studentList.stream().map(SysUserDto::getUserId).map(Long::intValue);
+        //添加学员
+        batchStudentInsert(userIdList, roomUid);
+    }
+
+    /**
+     * 指定多个学员id添加观看权限数据
      *
      * @param ids     bizId
      * @param roomUid 直播间UID
@@ -58,18 +91,37 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
     @Override
     public void add(String ids, String roomUid) {
         Optional.ofNullable(roomUid).orElseThrow(() -> new BizException("房间uid不能为空"));
-        Optional.ofNullable(ids).orElseThrow(() -> new BizException("请选择要删除的数据"));
+        Optional.ofNullable(ids)
+                .filter(WrapperUtil.StrPredicate)
+                .orElseThrow(() -> new BizException("请选择要删除的数据"));
         //查询房间类型
         ImLiveBroadcastRoom room = imLiveBroadcastRoomService.getOne(Wrappers.<ImLiveBroadcastRoom>lambdaQuery()
                 .eq(ImLiveBroadcastRoom::getRoomUid, roomUid));
+        if (Objects.isNull(room)) {
+            throw new BizException("房间不存在");
+        }
+        if (Objects.nonNull(room.getPopularizeType()) && Objects.equals(room.getPopularizeType(), ImLiveBroadcastRoom.ALL)) {
+            throw new BizException("该直播间为公开类型的直播间,不能添加观看权限");
+        }
+        //添加学员
+        List<Integer> userIdList = WrapperUtil.splitToIntList(ids);
+        if (CollectionUtils.isEmpty(userIdList)) {
+            return;
+        }
+        batchStudentInsert(userIdList.stream(), roomUid);
+    }
+
+    private void batchStudentInsert(Stream<Integer> stream, String roomUid) {
+        if (Objects.isNull(stream)) {
+            return;
+        }
         Date date = new Date();
         Integer userId = getSysUser().getId();
-        List<String> strings = WrapperUtil.toList(ids);
-        List<ImLiveRoomPurview> collect = strings.stream().map(id -> {
+        List<ImLiveRoomPurview> collect = stream.map(id -> {
             ImLiveRoomPurview imLiveRoomPurview = new ImLiveRoomPurview();
             imLiveRoomPurview.setRoomUid(roomUid);
-            imLiveRoomPurview.setBizId(id);
-            imLiveRoomPurview.setType(room.getPopularizeType());
+            imLiveRoomPurview.setUserId(id);
+            imLiveRoomPurview.setType("STUDENT");
             imLiveRoomPurview.setCreatedBy(userId);
             imLiveRoomPurview.setCreatedTime(date);
             return imLiveRoomPurview;
@@ -87,9 +139,9 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
     public void delete(String ids, String roomUid) {
         Optional.ofNullable(roomUid).orElseThrow(() -> new BizException("房间uid不能为空"));
         Optional.ofNullable(ids).orElseThrow(() -> new BizException("请选择要删除的数据"));
-        List<String> strings = WrapperUtil.toList(ids);
+        List<Integer> userIdList = WrapperUtil.splitToIntList(ids);
         this.remove(Wrappers.<ImLiveRoomPurview>lambdaQuery()
-                .in(ImLiveRoomPurview::getBizId, strings)
+                .in(ImLiveRoomPurview::getUserId, userIdList)
                 .eq(ImLiveRoomPurview::getRoomUid, roomUid));
     }
 
@@ -99,6 +151,10 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
      * @param param 参数
      *              <p> - search 搜索关键字
      *              <p> - subjectId 声部ID
+     *              <p> - organIds 分部ID
+     *              <p> - groupIds 群聊ID
+     *              <p> - teamIds 乐团ID
+     *              <p> - schoolIds 学校id/合作单位id
      *              <p> - roomUid 直播间UID
      *              <p> -page 页数
      *              <p> -rows 每页数量
@@ -106,23 +162,10 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
     @Override
     public PageInfo<SysUserDto> queryStudent(Map<String, Object> param) {
         WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
+        param.put("inExist", 1);
+        param.put("tenantId", TenantContextHolder.getTenantId());
         Page<SysUserDto> pageInfo = PageUtil.getPageInfo(param);
-        return PageUtil.pageInfo(baseMapper.queryStudent(pageInfo, param));
-    }
-
-    /**
-     * 查询群聊列表-观看权限
-     *
-     * @param param 参数
-     *              <p> - search 搜索关键字
-     *              <p> - roomUid 直播间UID
-     *              <p> - groupType 群类型
-     */
-    @Override
-    public PageInfo<ImGroup> queryGroup(Map<String, Object> param) {
-        WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
-        param.put("in", 1);
-        return getImGroupPageInfo(param);
+        return PageUtil.pageInfo(baseMapper.selectRoomPurviewStudent(pageInfo, param));
     }
 
     /**
@@ -131,6 +174,10 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
      * @param param 参数
      *              <p> - search 搜索关键字
      *              <p> - subjectId 声部ID
+     *              <p> - organIds 分部ID
+     *              <p> - groupIds 群聊ID
+     *              <p> - teamIds 乐团ID
+     *              <p> - schoolIds 学校id/合作单位id
      *              <p> - roomUid 直播间UID
      *              <p> -page 页数
      *              <p> -rows 每页数量
@@ -138,17 +185,8 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
     @Override
     public PageInfo<SysUserDto> selectRoomPurviewStudent(Map<String, Object> param) {
         WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
+        param.put("tenantId", TenantContextHolder.getTenantId());
         Page<SysUserDto> pageInfo = PageUtil.getPageInfo(param);
-        //查询当前登录人分部
-        SysUser sysUser = getSysUser();
-        //分部id
-        String organIds = null;
-        Employee employee = employeeService.get(sysUser.getId());
-        if (Objects.nonNull(employee) && Objects.nonNull(employee.getOrganIdList())) {
-            organIds = employee.getOrganIdList();
-        }
-        param.put("organId", organIds);
-        param.put("type", ImLiveBroadcastRoom.STUDENT);
         return PageUtil.pageInfo(baseMapper.selectRoomPurviewStudent(pageInfo, param));
     }
 
@@ -162,20 +200,62 @@ public class ImLiveRoomPurviewServiceImpl extends ServiceImpl<ImLiveRoomPurviewD
      */
     @Override
     public PageInfo<ImGroup> selectRoomPurviewGroup(Map<String, Object> param) {
-        WrapperUtil.toStr(param, "roomUid", "房间uid不能为空");
-        param.put("notIn", 1);
-        return getImGroupPageInfo(param);
-    }
-
-    private PageInfo<ImGroup> getImGroupPageInfo(Map<String, Object> param) {
         //查询当前登录人分部
         SysUser sysUser = getSysUser();
         param.put("userId", sysUser.getId());
-        param.put("type", ImLiveBroadcastRoom.GROUP);
         Page<ImGroup> pageInfo = PageUtil.getPageInfo(param);
         return PageUtil.pageInfo(baseMapper.selectRoomPurviewGroup(pageInfo, param));
     }
 
+    /**
+     * 导入观看权限-人员n
+     */
+    @Override
+    public String importPurviewUser(MultipartFile file, String roomUid) throws Exception {
+        Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(
+                new ByteArrayInputStream(file.getBytes()), 0, file.getOriginalFilename());
+        InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
+        Map<String, String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.LIVE_ROOM_PURVIEW_USER.getMsg());
+        List<ImLiveRoomPurview> purviewList = new ArrayList<>();
+        Integer id = getSysUser().getId();
+        Date now = new Date();
+        for (String e : sheetsListMap.keySet()) {
+            List<Map<String, Object>> sheet = sheetsListMap.get(e);
+            for (Map<String, Object> row : sheet) {
+                if (row.size() == 0) {
+                    continue;
+                }
+                ImLiveRoomPurview obj = new ImLiveRoomPurview();
+                obj.setRoomUid(roomUid);
+                obj.setType("STUDENT");
+                obj.setCreatedBy(id);
+                obj.setCreatedTime(now);
+                for (String s : row.keySet()) {
+                    if (!columns.containsKey(s)) {
+                        continue;
+                    }
+                    if (columns.get(s).equals("userId")) {
+                        if (null == row.get(s) || StringUtils.isBlank(row.get(s).toString())) {
+                            log.error("导入异常:{}不可为空", s);
+                            continue;
+                        }
+                        obj.setUserId(Integer.valueOf(row.get(s).toString()));
+                    }
+                }
+                purviewList.add(obj);
+            }
+        }
+        try {
+            baseMapper.insertBatch(purviewList);
+        } catch (DuplicateKeyException dupKeyEx) {
+            log.error("数据导入重复: " + dupKeyEx.getCause());
+            throw new BizException("数据重复:" + dupKeyEx.getCause());
+        } catch (Exception ex) {
+            throw new BizException("导入数据出错:" + ex, ex);
+        }
+        return "成功导入 " + purviewList.size() + "条";
+    }
+
     private SysUser getSysUser() {
         //修改机构基础信息
         return Optional.ofNullable(sysUserFeignService.queryUserInfo())

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

@@ -88,23 +88,7 @@ public class ImLiveRoomReservationServiceImpl extends ServiceImpl<ImLiveRoomRese
         pageInfo.setDesc("a.created_time_");
         param.put("userId", user.getId());
         param.put("tenantId", TenantContextHolder.getTenantId());
-        //查询该学员 所属分部
-        Integer organId = user.getOrganId();
-        if (Objects.nonNull(organId)) {
-            param.put("organId", organId);
-        }
-        //合作单位
-        Student student = studentService.get(user.getId());
-        if (Objects.nonNull(student) && Objects.nonNull(student.getCooperationOrganId())) {
-            param.put("schoolId", student.getCooperationOrganId());
-        }
-        //乐团
-        String teamIds = baseMapper.queryMusicGroupIds(user.getId());
-        if (StringUtils.isNotBlank(teamIds)) {
-            param.put("teamIds", teamIds);
-        }
-        IPage<ImLiveBroadcastRoomVo> page = baseMapper.queryPageStudent(pageInfo, param);
-        return PageUtil.pageInfo(page);
+        return PageUtil.pageInfo(baseMapper.queryPageStudent(pageInfo, param));
     }
 
     /**

+ 35 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -10,6 +11,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.StringUtils;
@@ -187,6 +189,7 @@ public class PayServiceImpl implements PayService {
         	if(sysPaymentConfig != null){
 
     			List<StudentPaymentOrderDetail> batchUpdateList = new ArrayList<StudentPaymentOrderDetail>();
+    			List<Goods> batchUpdateGoodsList = new ArrayList<Goods>();
         		
         		// 如果买了商品或组合商品,商品有内部库存,则将钱转入指定账户已云教练的方式作为收费项目(杭州、齐齐哈尔除外)
         		// 1.查询商品订单明细
@@ -195,11 +198,12 @@ public class PayServiceImpl implements PayService {
         			
         			String goodIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getGoodsIdList())).map(StudentPaymentOrderDetail :: getGoodsIdList).collect(Collectors.joining(","));
         			if(StringUtils.isNotBlank(goodIds)){
-        				List<Goods> goodsList = goodsService.findGoodsByIds(goodIds);
+        				List<Goods> goodsList = goodsService.getGoodsWithLocked(goodIds);
         				
         				Map<Integer,Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods :: getId, t -> t));
         				Goods goods = null;
         				BigDecimal totalAmout = studentPaymentOrder.getExpectAmount();
+        				List<Integer> minuendStockGoodsIdList = null;
         				
         				for(StudentPaymentOrderDetail spod : studentPaymentOrderDetailList){
         					
@@ -214,6 +218,8 @@ public class PayServiceImpl implements PayService {
         					
         					BigDecimal groupPurchaseAmount = BigDecimal.ZERO;
         					
+        					minuendStockGoodsIdList = new ArrayList<Integer>();
+        					
         					for(String goodsIdStr : spod.getGoodsIdList().split(",")){
         						if(StringUtils.isBlank(goodsIdStr)){
         							continue;
@@ -223,13 +229,18 @@ public class PayServiceImpl implements PayService {
         						if(goods != null){
         							// 是否是组合商品
         							if(StringUtils.isNotBlank(goods.getComplementGoodsIdList())){
-        								goodsList = goodsService.findGoodsByIds(goods.getComplementGoodsIdList());
+        								goodsList = goodsService.getGoodsWithLocked(goods.getComplementGoodsIdList());
         								totalGroupPurchaseAmount =  totalGroupPurchaseAmount.add(goodsList.stream().map(Goods :: getGroupPurchasePrice).reduce(BigDecimal.ZERO,BigDecimal :: add));
         								
         								for(Goods subGoods : goodsList){
         									//判断是否有内部库存
         									if(subGoods.getStockCount() > 0){
         										groupPurchaseAmount = groupPurchaseAmount.add(subGoods.getGroupPurchasePrice());
+        										subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).decrementAndGet());
+        										subGoods.setUpdateTime(date);
+        										batchUpdateGoodsList.add(subGoods);
+        										
+        										minuendStockGoodsIdList.add(subGoods.getId());
         									}
         								}
         							}else{
@@ -237,6 +248,11 @@ public class PayServiceImpl implements PayService {
         								//判断是否有内部库存
         								if(goods.getStockCount() > 0){
     										groupPurchaseAmount = groupPurchaseAmount.add(goods.getGroupPurchasePrice());
+    										goods.setStockCount(new AtomicInteger(goods.getStockCount()).decrementAndGet());
+    										goods.setUpdateTime(date);
+    										batchUpdateGoodsList.add(goods);
+    										
+    										minuendStockGoodsIdList.add(goods.getId());
         								}
         							}
         						}
@@ -245,14 +261,19 @@ public class PayServiceImpl implements PayService {
 							if (groupPurchaseAmount.doubleValue() > 0) {
 	        					// 3.是否使用余额
 								if (balanceAmount.doubleValue() > 0) {
-									tempBalance = balanceAmount.multiply(spod.getPrice()).divide(totalAmout).multiply(groupPurchaseAmount)
-											.divide(totalGroupPurchaseAmount);
+									/*tempBalance = balanceAmount.multiply(spod.getPrice()).divide(totalAmout).multiply(groupPurchaseAmount)
+											.divide(totalGroupPurchaseAmount);*/
+									tempBalance = balanceAmount.multiply(spod.getPrice()).multiply(groupPurchaseAmount)
+											.divide(totalGroupPurchaseAmount.multiply(totalAmout), RoundingMode.HALF_UP);
 									subBalance = subBalance.add(tempBalance);
 								}
-								tempCashAmount = spod.getPrice().subtract(tempBalance).multiply(groupPurchaseAmount).divide(totalGroupPurchaseAmount);
+								tempCashAmount = spod.getPrice().subtract(tempBalance).multiply(groupPurchaseAmount).divide(totalGroupPurchaseAmount, RoundingMode.HALF_UP);
 								subCashAmount = subCashAmount.add(tempCashAmount);
 								spod.setIncomeItem(OrderDetailTypeEnum.CLOUD_TEACHER.name());
 								spod.setIncome(tempCashAmount);
+								if(minuendStockGoodsIdList.size() > 0){
+									spod.setMinuendStockGoodsIdList(minuendStockGoodsIdList.stream().map(t -> t.toString()).collect(Collectors.joining(",")));
+								}
 								batchUpdateList.add(spod);
 							}
         				}
@@ -263,6 +284,10 @@ public class PayServiceImpl implements PayService {
         			studentPaymentOrderDetailService.batchUpdate(batchUpdateList);
         		}
         		
+        		if(batchUpdateGoodsList.size() > 0){
+        			goodsService.batchUpdate(batchUpdateGoodsList);
+        		}
+        		
         		if(subCashAmount.doubleValue() > 0){
         			StudentPaymentRouteOrder studentPaymentRouteOrder = new StudentPaymentRouteOrder();
     	            studentPaymentRouteOrder.setOrderNo(orderNo);
@@ -272,7 +297,7 @@ public class PayServiceImpl implements PayService {
     	            studentPaymentRouteOrder.setRouteBalanceAmount(subBalance);
     	            studentPaymentRouteOrder.setMerNo(goodsSellReceiptMerNo);
     	            studentPaymentRouteOrder.setSaleAmount(BigDecimal.ZERO);
-    	            studentPaymentRouteOrder.setServiceAmount(amount);
+    	            studentPaymentRouteOrder.setServiceAmount(subCashAmount);
     	            studentPaymentRouteOrder.setCreateTime(date);
     	            studentPaymentRouteOrder.setUpdateTime(date);
     	            studentPaymentRouteOrderDao.insert(studentPaymentRouteOrder);
@@ -313,7 +338,7 @@ public class PayServiceImpl implements PayService {
             checkMaxReceipt(routeScaleDto, routeScaleDto.getMerNo());
         }
 
-        return getPayRoute(amount, balanceAmount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routeScaleDtos);
+        return getPayRoute(amount, balanceAmount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, routeScaleDtos, subCashAmount);
     }
 
     @Override
@@ -569,7 +594,7 @@ public class PayServiceImpl implements PayService {
         return amount.add(totalHasReceipt).compareTo(totalMaxReceipt) >= 0;
     }
 
-    private Map<String, Object> getPayRoute(BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, List<RouteScaleDto> routeScaleDtos) throws Exception {
+    private Map<String, Object> getPayRoute(BigDecimal amount, BigDecimal balanceAmount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody, List<RouteScaleDto> routeScaleDtos, BigDecimal shareAmount) throws Exception {
         Map<String, List<RouteScaleDto>> routeScaleDtosMap = routeScaleDtos.stream().collect(Collectors.groupingBy(RouteScaleDto::getMerNo));
 
         //合并同账号的数据
@@ -671,9 +696,9 @@ public class PayServiceImpl implements PayService {
             if (tempRoutingList.size() == 1 && YqPayUtil.merNo.equals(tempRoutingList.get(0).get("routingMerNo").toString())) {
                 tempRoutingList = null;
             }
-            payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody, YqPayUtil.merNo, tempRoutingList);
+            payMap = YqPayUtil.getPayMap(amount.add(shareAmount), orderNo, notifyUrl, returnUrl, orderSubject, orderBody, YqPayUtil.merNo, tempRoutingList);
         } else {
-            payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
+            payMap = Payment.getPayMap(amount.add(shareAmount), orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
         }
         String routingMerNos = String.join(",", routingMerNoSet);
 

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

@@ -93,9 +93,9 @@ public class PlatformProductServiceImpl extends ServiceImpl<PlatformProductDao,
     @Transactional(rollbackFor = Exception.class)
     public void checkUpdateRole(String newMenuIds, String oldMenuIds, Map<Integer, Integer> map) {
         //需要添加的菜单id
-        List<Integer> newList = getList(newMenuIds);
+        List<Integer> newList = WrapperUtil.splitToIntList(newMenuIds);
         //需要删除的菜单id
-        List<Integer> oldList = getList(oldMenuIds);
+        List<Integer> oldList = WrapperUtil.splitToIntList(oldMenuIds);
         //合并修改权限
         opsRoleMenu(map, newList, oldList);
     }
@@ -125,17 +125,6 @@ public class PlatformProductServiceImpl extends ServiceImpl<PlatformProductDao,
         });
     }
 
-    private List<Integer> getList(String str) {
-        List<String> strings = Optional.ofNullable(str).map(WrapperUtil::toList).orElse(null);
-        if (CollectionUtils.isEmpty(strings)) {
-            return null;
-        }
-        return strings.stream()
-                .distinct()
-                .map(WrapperUtil::toInt)
-                .collect(Collectors.toList());
-    }
-
     /**
      * 根据多个id 查询出机构的id 和机构管理员id
      *

+ 54 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SellOrderServiceImpl.java

@@ -1,14 +1,15 @@
 package com.ym.mec.biz.service.impl;
 
 
-import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
-import com.ym.mec.biz.service.*;
-import com.ym.mec.common.constant.CommonConstants;
-import com.ym.mec.common.dal.BaseDAO;
-import com.ym.mec.common.service.impl.BaseServiceImpl;
+import static com.ym.mec.biz.dal.enums.GroupType.GOODS_SELL;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,11 +17,39 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static com.ym.mec.biz.dal.enums.GroupType.GOODS_SELL;
+import com.alibaba.fastjson.JSONObject;
+import com.ym.mec.biz.dal.dao.GoodsDao;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+import com.ym.mec.biz.dal.dao.SellOrderDao;
+import com.ym.mec.biz.dal.dao.SporadicChargeInfoDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
+import com.ym.mec.biz.dal.dao.StudentRepairDao;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.SellOrder;
+import com.ym.mec.biz.dal.entity.SporadicChargeInfo;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.entity.StudentRepair;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountLog;
+import com.ym.mec.biz.dal.enums.AccountType;
+import com.ym.mec.biz.dal.enums.GoodsType;
+import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
+import com.ym.mec.biz.dal.enums.ReturnFeeEnum;
+import com.ym.mec.biz.dal.enums.SellStatus;
+import com.ym.mec.biz.dal.enums.SellTypeEnum;
+import com.ym.mec.biz.dal.enums.SporadicChargeTypeEnum;
+import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.SellOrderService;
+import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
+import com.ym.mec.biz.service.SysPaymentConfigService;
+import com.ym.mec.biz.service.SysUserCashAccountLogService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
 
 @Service
 public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> implements SellOrderService {
@@ -44,6 +73,8 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
     private SporadicChargeInfoDao sporadicChargeInfoDao;
     @Autowired
     private StudentRepairDao studentRepairDao;
+    @Autowired
+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
 
     @Override
     public BaseDAO<Integer, SellOrder> getDAO() {
@@ -451,6 +482,12 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         if (order == null) {
             return null;
         }
+        
+        List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(order.getId());
+        BigDecimal cloudIncome = BigDecimal.ZERO;
+        if(studentPaymentOrderDetailList != null) {
+        	cloudIncome = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNoneBlank(t.getMinuendStockGoodsIdList()) && StringUtils.equals(t.getIncomeItem(), OrderDetailTypeEnum.CLOUD_TEACHER.name())).map(t -> t.getIncome()).reduce(BigDecimal.ZERO, BigDecimal::add);
+        }
 
         //零星支付除了充值其他都是服务费用
         if (order.getType().equals(OrderTypeEnum.SPORADIC)) {
@@ -462,13 +499,13 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
         Map<String, BigDecimal> sellAmount = new HashMap<>();
         //乐器销售,声部更改
         if (order.getType().equals(OrderTypeEnum.GOODS_SELL) || order.getType().equals(OrderTypeEnum.SUBJECT_CHANGE)) {
-            sellAmount.put("actualAmount", order.getActualAmount());
+            sellAmount.put("actualAmount", order.getActualAmount().subtract(cloudIncome));
             sellAmount.put("balance", order.getBalancePaymentAmount() == null ? BigDecimal.ZERO : order.getBalancePaymentAmount());
             return sellAmount;
         }
         //乐器置换
         if (order.getType().equals(OrderTypeEnum.REPLACEMENT)) {
-            sellAmount.put("actualAmount", order.getActualAmount());
+            sellAmount.put("actualAmount", order.getActualAmount().subtract(cloudIncome));
             sellAmount.put("balance", order.getBalancePaymentAmount() == null ? BigDecimal.ZERO : order.getBalancePaymentAmount());
             return sellAmount;
         }
@@ -512,7 +549,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
 
             BigDecimal goodsTotalBalance = goodsTotalPrice.multiply(balance).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
             BigDecimal goodsTotalActualAmount = goodsTotalPrice.multiply(order.getActualAmount()).divide(totalAmount, 2, BigDecimal.ROUND_DOWN);
-            sellAmount.put("actualAmount", goodsTotalActualAmount);
+            sellAmount.put("actualAmount", goodsTotalActualAmount.subtract(cloudIncome));
             sellAmount.put("balance", goodsTotalBalance);
             return sellAmount;
         }
@@ -529,7 +566,7 @@ public class SellOrderServiceImpl extends BaseServiceImpl<Integer, SellOrder> im
             //商品销售占的余额
             BigDecimal detailTotalBalance = detailTotalPrice.multiply(totalBalance).divide(totalPrice, 2, BigDecimal.ROUND_DOWN);
 
-            sellAmount.put("actualAmount", detailTotalPrice.subtract(detailTotalBalance));
+            sellAmount.put("actualAmount", detailTotalPrice.subtract(detailTotalBalance).subtract(cloudIncome));
             sellAmount.put("balance", detailTotalBalance);
             return sellAmount;
         }

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

@@ -24,6 +24,7 @@ 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.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -35,9 +36,11 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
@@ -112,6 +115,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private GoodsDao goodsDao;
     @Autowired
+    private GoodsService goodsService;
+    @Autowired
     private MusicGroupPaymentCalenderDetailDao musicGroupPaymentCalenderDetailDao;
     @Autowired
     private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
@@ -1251,6 +1256,23 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             studentRegistrationDao.update(studentRegistration);
             //减去缴费人数(器乐收费,0元时不减缴费人数)
             studentPaymentOrderService.cutSubjectPlan(studentPaymentOrder);
+            
+			List<Goods> batchUpdateGoodsList = new ArrayList<Goods>();
+            //增加商品库存
+            List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.getId());
+            String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
+            if(StringUtils.isNotBlank(goodsIds)){
+            	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
+            	for(Goods subGoods : goodsList){
+					subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).incrementAndGet());
+					subGoods.setUpdateTime(nowDate);
+					batchUpdateGoodsList.add(subGoods);
+            	}
+            }
+            
+            if(batchUpdateGoodsList.size() > 0){
+            	goodsService.batchUpdate(batchUpdateGoodsList);
+            }
 
             //退还优惠券和余额
             studentPaymentOrderService.returnBalanceAndCoupon(studentPaymentOrder,"报名缴费失败");

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

@@ -1,18 +1,86 @@
 package com.ym.mec.biz.service.impl;
 
+import static com.ym.mec.biz.dal.enums.CouponDetailTypeEnum.ACCESSORIES;
+import static com.ym.mec.biz.dal.enums.CouponDetailTypeEnum.MUSICAL;
+import static com.ym.mec.biz.dal.enums.DealStatusEnum.CLOSE;
+import static com.ym.mec.biz.dal.enums.DealStatusEnum.ING;
+import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+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;
+
 import com.alibaba.fastjson.JSON;
 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.*;
+import com.ym.mec.biz.dal.dao.MusicGroupDao;
+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;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
 import com.ym.mec.biz.dal.dto.RepairGoodsDto;
-import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MusicGroup;
+import com.ym.mec.biz.dal.entity.SellOrder;
+import com.ym.mec.biz.dal.entity.StudentGoodsSell;
+import com.ym.mec.biz.dal.entity.StudentInstrument;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
+import com.ym.mec.biz.dal.entity.StudentRepair;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
+import com.ym.mec.biz.dal.enums.AccountType;
+import com.ym.mec.biz.dal.enums.CouponDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GoodsType;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.MessageTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PayStatus;
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.SellTypeEnum;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
-import com.ym.mec.biz.service.*;
+import com.ym.mec.biz.service.ContractService;
+import com.ym.mec.biz.service.GoodsService;
+import com.ym.mec.biz.service.PayService;
+import com.ym.mec.biz.service.SellOrderService;
+import com.ym.mec.biz.service.StudentGoodsSellService;
+import com.ym.mec.biz.service.StudentInstrumentService;
+import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
+import com.ym.mec.biz.service.StudentRepairService;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.service.SysCouponCodeService;
+import com.ym.mec.biz.service.SysMessageService;
+import com.ym.mec.biz.service.SysPaymentConfigService;
+import com.ym.mec.biz.service.SysUserCashAccountDetailService;
+import com.ym.mec.biz.service.SysUserCashAccountService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
@@ -21,22 +89,6 @@ import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-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;
-
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import static com.ym.mec.biz.dal.enums.CouponDetailTypeEnum.*;
-import static com.ym.mec.biz.dal.enums.DealStatusEnum.*;
 
 @Service
 public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRepair> implements StudentRepairService {
@@ -54,6 +106,8 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
+    @Autowired
     private SysPaymentConfigService sysPaymentConfigService;
     @Autowired
     private MusicGroupDao musicGroupDao;
@@ -252,6 +306,51 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         studentPaymentOrder.setRoutingOrganId(student.getOrganId());
         studentPaymentOrder.setTenantId(student.getTenantId());
         studentPaymentOrderService.insert(studentPaymentOrder);
+        
+        Date date = new Date();
+        //添加订单详情
+        List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<StudentPaymentOrderDetail>();
+        // 添加studentPaymentOrderDetail
+        StudentPaymentOrderDetail studentPaymentOrderDetail = null;
+
+        BigDecimal totalPrice = BigDecimal.ZERO;
+        
+        if(goodsSellDtos != null){
+        	String goodsIdsStr = goodsSellDtos.stream().map(t -> t.getGoodsId().toString()).collect(Collectors.joining(","));
+        	List<Goods> goodsList = goodsService.findGoodsByIds(goodsIdsStr);
+        	BigDecimal goodsPrice = goodsList.stream().map(t -> t.getGroupPurchasePrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+        	for(Goods g : goodsList){
+        		studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail.setCreateTime(date);
+                if(g.getType() == GoodsType.INSTRUMENT){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.MUSICAL);
+                }else if(g.getType() == GoodsType.ACCESSORIES){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.ACCESSORIES);
+                }else if(g.getType() == GoodsType.TEACHING || g.getType() == GoodsType.STAFF){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.TEACHING);
+                }else{
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.OTHER);
+                }
+                studentPaymentOrderDetail.setGoodsIdList(g.getId() + "");
+                
+                BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().multiply(g.getGroupPurchasePrice()).divide(goodsPrice, RoundingMode.UP);
+                
+                if(totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0){
+                	studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));
+                }else{
+                	studentPaymentOrderDetail.setPrice(tempPrice);
+                }
+                studentPaymentOrderDetail.setUpdateTime(date);
+                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+                
+                totalPrice = totalPrice.add(studentPaymentOrderDetail.getPrice());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+        	}
+        }
+        
+        if(studentPaymentOrderDetailList.size() > 0){
+        	studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+        }
 
         studentPaymentOrder.setVersion(0);
         BigDecimal balance = BigDecimal.ZERO;
@@ -455,17 +554,23 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         repairInfo.setPayStatus(0);
         repairInfo.setCreateTime(date);
         repairInfo.setUpdateTime(date);
+        
+        List<RepairGoodsDto> repairGoodsDtos = null;
+        String goodIdList = null;
+        		
         String goodsJson = repairInfo.getGoodsJson();
         if (StringUtils.isNotEmpty(goodsJson)) {
-            List<RepairGoodsDto> repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
+            repairGoodsDtos = JSONObject.parseArray(goodsJson, RepairGoodsDto.class);
             List<Integer> goodsIds = repairGoodsDtos.stream().map(e -> e.getId()).collect(Collectors.toList());
             Map<Integer, BigDecimal> map = getMap("goods", "id_", "discount_price_", goodsIds,student.getTenantId(), Integer.class, BigDecimal.class);
             repairGoodsDtos.forEach(e -> {
                 e.setGroupPurchasePrice(map.get(e.getId()));
             });
             repairInfo.setGoodsJson(JSONObject.toJSONString(repairGoodsDtos));
+            goodIdList = repairGoodsDtos.stream().map(t -> t.getId().toString()).collect(Collectors.joining(","));
         }
 
+        BigDecimal goodsPrice = BigDecimal.ZERO;
         if (StringUtils.isNoneBlank(repairInfo.getGoodsJson())) {
             JSONArray goods = JSON.parseArray(repairInfo.getGoodsJson());
             for (Object good : goods) {
@@ -473,6 +578,7 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
                 BigDecimal groupPurchasePrice = goodObject.getBigDecimal("groupPurchasePrice");
                 if (Objects.nonNull(groupPurchasePrice)) {
                     amount = amount.add(groupPurchasePrice);
+                    goodsPrice = goodsPrice.add(groupPurchasePrice);
                 }
             }
         }
@@ -509,6 +615,58 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
 
         studentPaymentOrderService.insert(studentPaymentOrder);
         studentPaymentOrder.setVersion(0);
+  
+        
+        List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<StudentPaymentOrderDetail>();
+        // 添加studentPaymentOrderDetail
+        StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+        studentPaymentOrderDetail.setCreateTime(date);
+        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.REPAIR);
+        studentPaymentOrderDetail.setGoodsIdList(null);
+        studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().multiply(repairInfo.getAmount()).divide(goodsPrice.add(repairInfo.getAmount()), RoundingMode.UP));
+        studentPaymentOrderDetail.setUpdateTime(date);
+        studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+        
+        studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+
+        BigDecimal totalPrice = studentPaymentOrderDetail.getPrice();
+        BigDecimal repairPrice = studentPaymentOrderDetail.getPrice();
+        
+        if(StringUtils.isNotBlank(repairInfo.getGoodsJson()) && repairGoodsDtos != null){
+        	String goodsIds = repairGoodsDtos.stream().map(t -> t.getId().toString()).collect(Collectors.joining(","));
+        	List<Goods> goodsList = goodsService.findGoodsByIds(goodsIds);
+        	for(Goods g : goodsList){
+        		studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail.setCreateTime(date);
+                if(g.getType() == GoodsType.INSTRUMENT){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.MUSICAL);
+                }else if(g.getType() == GoodsType.ACCESSORIES){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.ACCESSORIES);
+                }else if(g.getType() == GoodsType.TEACHING || g.getType() == GoodsType.STAFF){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.TEACHING);
+                }else{
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.OTHER);
+                }
+                studentPaymentOrderDetail.setGoodsIdList(g.getId() + "");
+                
+                BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().subtract(repairPrice).multiply(g.getGroupPurchasePrice()).divide(goodsPrice, RoundingMode.UP);
+                
+                if(totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0){
+                	studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));
+                }else{
+                	studentPaymentOrderDetail.setPrice(tempPrice);
+                }
+                studentPaymentOrderDetail.setUpdateTime(date);
+                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+                
+                totalPrice = totalPrice.add(studentPaymentOrderDetail.getPrice());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+        	}
+        }
+        
+        if(studentPaymentOrderDetailList.size() > 0){
+        	studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+        }
 
         BigDecimal balance = BigDecimal.ZERO;
         if (repairInfo.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
@@ -794,7 +952,25 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             //购买的商品加入销售列表
             saveSellOrder(studentPaymentOrder.getOrderNo());
         } else if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
-            if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
+            
+			List<Goods> batchUpdateGoodsList = new ArrayList<Goods>();
+            //增加商品库存
+            List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.getId());
+            String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
+            if(StringUtils.isNotBlank(goodsIds)){
+            	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
+            	for(Goods subGoods : goodsList){
+					subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).incrementAndGet());
+					subGoods.setUpdateTime(nowDate);
+					batchUpdateGoodsList.add(subGoods);
+            	}
+            }
+            
+            if(batchUpdateGoodsList.size() > 0){
+            	goodsService.batchUpdate(batchUpdateGoodsList);
+            }
+        	
+        	if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                 sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐器购买支付失败");
             }
             sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
@@ -1173,6 +1349,24 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
             if (this.update(repairInfo) <= 0) {
                 throw new BizException("维修单更新失败");
             }
+            
+			List<Goods> batchUpdateGoodsList = new ArrayList<Goods>();
+            //增加商品库存
+            List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.getId());
+            String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
+            if(StringUtils.isNotBlank(goodsIds)){
+            	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
+            	for(Goods subGoods : goodsList){
+					subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).incrementAndGet());
+					subGoods.setUpdateTime(nowDate);
+					batchUpdateGoodsList.add(subGoods);
+            	}
+            }
+            
+            if(batchUpdateGoodsList.size() > 0){
+            	goodsService.batchUpdate(batchUpdateGoodsList);
+            }
+            
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                 sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐器维修支付失败");
             }

+ 121 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SubjectChangeServiceImpl.java

@@ -15,6 +15,8 @@ import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -24,7 +26,9 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
@@ -54,6 +58,8 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
     @Autowired
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
     @Autowired
+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
+    @Autowired
     private MusicGroupDao musicGroupDao;
     @Autowired
     private SellOrderDao sellOrderDao;
@@ -224,6 +230,66 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
         studentPaymentOrderService.update(studentPaymentOrder);
 
         studentPaymentOrder.setVersion(studentPaymentOrder.getVersion() + 1);
+        
+        //添加订单详情
+        List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<StudentPaymentOrderDetail>();
+        // 添加studentPaymentOrderDetail
+        StudentPaymentOrderDetail studentPaymentOrderDetail = null;
+
+        BigDecimal totalPrice = BigDecimal.ZERO;
+        
+        List<String> changeAccessoriesList = null;
+        
+        if(StringUtils.isNotBlank(subjectChange.getChangeAccessories())){
+        	changeAccessoriesList = Arrays.asList(subjectChange.getChangeAccessories().split(","));
+        	
+        	List<String> originalAccessories = new ArrayList<String>();
+        	if(StringUtils.isNotBlank(subjectChange.getOriginalAccessories())){
+        		originalAccessories = Arrays.asList(subjectChange.getOriginalAccessories().split(","));
+        	}
+        	changeAccessoriesList.removeAll(originalAccessories);
+        	
+        	if(subjectChange.getChangeMusical() != subjectChange.getOriginalMusical()){
+        		changeAccessoriesList.add(subjectChange.getChangeMusical()+"");
+        	}
+        }
+        
+        if(changeAccessoriesList != null){
+            String goodsIdsStr = changeAccessoriesList.stream().map(t -> t.toString()).collect(Collectors.joining(","));
+        	List<Goods> goodsList = goodsService.findGoodsByIds(goodsIdsStr);
+        	BigDecimal goodsPrice = goodsList.stream().map(t -> t.getGroupPurchasePrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
+        	for(Goods g : goodsList){
+        		studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail.setCreateTime(date);
+                if(g.getType() == GoodsType.INSTRUMENT){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.MUSICAL);
+                }else if(g.getType() == GoodsType.ACCESSORIES){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.ACCESSORIES);
+                }else if(g.getType() == GoodsType.TEACHING || g.getType() == GoodsType.STAFF){
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.TEACHING);
+                }else{
+                	studentPaymentOrderDetail.setType(OrderDetailTypeEnum.OTHER);
+                }
+                studentPaymentOrderDetail.setGoodsIdList(g.getId() + "");
+                
+                BigDecimal tempPrice = studentPaymentOrder.getExpectAmount().multiply(g.getGroupPurchasePrice()).divide(goodsPrice, RoundingMode.UP);
+                
+                if(totalPrice.add(tempPrice).compareTo(studentPaymentOrder.getExpectAmount()) > 0){
+                	studentPaymentOrderDetail.setPrice(studentPaymentOrder.getExpectAmount().subtract(totalPrice));
+                }else{
+                	studentPaymentOrderDetail.setPrice(tempPrice);
+                }
+                studentPaymentOrderDetail.setUpdateTime(date);
+                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+                
+                totalPrice = totalPrice.add(studentPaymentOrderDetail.getPrice());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+        	}
+            
+            if(studentPaymentOrderDetailList.size() > 0){
+            	studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+            }
+        }
 
         if (amount.compareTo(BigDecimal.ZERO) == 0) {
             studentPaymentRouteOrderService.addRouteOrder(orderNo, subjectChange.getOrganId(), studentPaymentOrder.getExpectAmount());
@@ -697,6 +763,43 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
                 rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
             }
             sysUserCashAccountDetailService.insert(paymentDetail);
+            
+			List<Goods> batchUpdateGoodsList = new ArrayList<Goods>();
+			
+			List<String> changeAccessoriesList = null;
+			List<String> originalAccessories = new ArrayList<String>();
+	        
+	        if(StringUtils.isNotBlank(subjectChange.getOriginalAccessories())){
+	        	changeAccessoriesList = Arrays.asList(subjectChange.getOriginalAccessories().split(","));
+	        	
+	        	if(StringUtils.isNotBlank(subjectChange.getChangeAccessories())){
+	        		originalAccessories = Arrays.asList(subjectChange.getChangeAccessories().split(","));
+	        	}
+	        	changeAccessoriesList.removeAll(originalAccessories);
+	        	
+	        	if(subjectChange.getChangeMusical() != subjectChange.getOriginalMusical()){
+	        		changeAccessoriesList.add(subjectChange.getOriginalMusical()+"");
+	        	}
+	        }
+	        List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(subjectChange.getOriginalOrderId().longValue());
+	        String goodsIdsStr = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
+	        originalAccessories = Arrays.asList(goodsIdsStr.split(","));
+	        originalAccessories.removeAll(changeAccessoriesList);
+	        
+	        goodsIdsStr = originalAccessories.stream().map(t -> t.toString()).collect(Collectors.joining(","));
+            //增加商品库存
+            if(StringUtils.isNotBlank(goodsIdsStr)){
+            	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIdsStr);
+            	for(Goods subGoods : goodsList){
+					subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).incrementAndGet());
+					subGoods.setUpdateTime(nowDate);
+					batchUpdateGoodsList.add(subGoods);
+            	}
+            }
+            
+            if(batchUpdateGoodsList.size() > 0){
+            	goodsService.batchUpdate(batchUpdateGoodsList);
+            }
         }
 
         if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
@@ -704,6 +807,24 @@ public class SubjectChangeServiceImpl extends BaseServiceImpl<Integer, SubjectCh
             if (this.update(subjectChange) <= 0) {
                 throw new BizException("声部更改订单更新失败");
             }
+            
+			List<Goods> batchUpdateGoodsList = new ArrayList<Goods>();
+            //增加商品库存
+            List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.getId());
+            String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
+            if(StringUtils.isNotBlank(goodsIds)){
+            	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
+            	for(Goods subGoods : goodsList){
+					subGoods.setStockCount(new AtomicInteger(subGoods.getStockCount()).incrementAndGet());
+					subGoods.setUpdateTime(nowDate);
+					batchUpdateGoodsList.add(subGoods);
+            	}
+            }
+            
+            if(batchUpdateGoodsList.size() > 0){
+            	goodsService.batchUpdate(batchUpdateGoodsList);
+            }
+            
             if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
                 sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "声部更改支付失败");
             }

+ 7 - 59
mec-biz/src/main/resources/config/mybatis/ImLiveBroadcastRoomMapper.xml

@@ -16,9 +16,6 @@
         <result column="room_state_" jdbcType="INTEGER" property="roomState"/>
         <result column="popularize_" jdbcType="INTEGER" property="popularize"/>
         <result column="popularize_type_" jdbcType="VARCHAR" property="popularizeType"/>
-        <result column="popularize_org_ids_" jdbcType="VARCHAR" property="popularizeOrgIds"/>
-        <result column="popularize_school_ids_" jdbcType="VARCHAR" property="popularizeSchoolIds"/>
-        <result column="popularize_team_ids_" jdbcType="VARCHAR" property="popularizeTeamIds"/>
         <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
         <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
         <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
@@ -29,15 +26,13 @@
             parameterType="com.ym.mec.biz.dal.entity.ImLiveBroadcastRoom">
         insert into im_live_broadcast_room(tenant_id_, speaker_id_, room_uid_, room_title_, live_start_time_,
         live_end_time_, live_remark_, pre_template_, room_config_, live_state_, room_state_,
-        popularize_, popularize_type_,popularize_org_ids_,popularize_school_ids_,popularize_team_ids_,
-        created_by_, created_time_, updated_by_, updated_time_)
+        popularize_, popularize_type_, created_by_, created_time_, updated_by_, updated_time_)
         values
         <foreach collection="entities" item="entity" separator=",">
             (#{entity.tenantId}, #{entity.speakerId}, #{entity.roomUid}, #{entity.roomTitle}, #{entity.liveStartTime},
             #{entity.liveEndTime}, #{entity.liveRemark}, #{entity.preTemplate}, #{entity.roomConfig},
             #{entity.liveState}, #{entity.roomState}, #{entity.popularize},
-            #{entity.popularizeType},#{entity.popularizeOrgIds},#{entity.popularizeSchoolIds},#{entity.popularizeTeamIds},
-            #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},#{entity.updatedTime})
+            #{entity.popularizeType}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},#{entity.updatedTime})
         </foreach>
     </insert>
 
@@ -60,45 +55,8 @@
         a.pre_template_ AS preTemplate,
         a.room_config_ AS roomConfig,
         a.popularize_ AS popularize,
-        a.popularize_type_ AS popularizeType,
-        a.popularize_org_ids_ AS popularizeOrgIds,
-        a.popularize_school_ids_ AS popularizeSchoolIds,
-        a.popularize_team_ids_ AS popularizeTeamIds
-        from (
-        select *
-        from im_live_broadcast_room
-        <if test="param.allRoom == null">
-            where popularize_type_ = 'ALL'
-        </if>
-        <if test="param.organIds != null">
-            union all
-            select *
-            from im_live_broadcast_room as a
-            where popularize_type_ in ( 'ORGAN', 'TEAM')
-            and INTE_ARRAY(a.popularize_org_ids_, #{param.organIds}) = 1
-        </if>
-        <if test="param.schoolIds != null">
-            union all
-            select *
-            from im_live_broadcast_room as a
-            where popularize_type_ = 'SCHOOL'
-            and INTE_ARRAY(a.popularize_school_ids_, #{param.schoolIds}) = 1
-        </if>
-        <if test="param.userId != null">
-            union all
-            select distinct r.* from im_live_broadcast_room as r inner join
-            im_live_room_purview as a on r.room_uid_ = a.room_uid_
-            where
-            r.popularize_type_= 'GROUP'
-            and a.biz_id_ in (
-            select
-            distinct a.id_
-            from
-            im_group a
-            inner join im_group_member b on a.id_=b.im_group_id_
-            where b.user_id_ = #{param.userId})
-        </if>
-        ) as a
+        a.popularize_type_ AS popularizeType
+        from im_live_broadcast_room as a
         left join tenant_info AS t on a.tenant_id_ = t.id_
         left join sys_user AS b on a.speaker_id_ = b.id_
         left join sys_user AS c on a.created_by_ = c.id_
@@ -128,20 +86,10 @@
             <if test="param.popularize != null">
                 and a.popularize_ = #{param.popularize}
             </if>
+            <if test="param.speakerId != null">
+                and  a.speaker_id_ = #{param.speakerId}
+            </if>
         </where>
-
-    </select>
-
-    <select id="queryUserPageByTenantId" resultType="map">
-        SELECT id_, username_
-        FROM sys_user
-        WHERE tenant_id_ = 1
-          and user_type_ = 'STUDENT'
-          and lock_flag_ = 0
-          and del_flag_ = 0
-          and is_super_admin_ = 0
-          and username_ is not null
-          and username_ != ''
     </select>
 
     <select id="queryBaseUserInfo" resultType="com.ym.mec.biz.dal.vo.BaseRoomUserVo">

+ 77 - 55
mec-biz/src/main/resources/config/mybatis/ImLiveRoomPurviewMapper.xml

@@ -4,7 +4,7 @@
     <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.ImLiveRoomPurview">
         <id column="id_" jdbcType="INTEGER" property="id"/>
         <result column="room_uid_" jdbcType="VARCHAR" property="roomUid"/>
-        <result column="biz_id_" jdbcType="VARCHAR" property="bizId"/>
+        <result column="user_id_" jdbcType="VARCHAR" property="userId"/>
         <result column="type_" jdbcType="VARCHAR" property="type"/>
         <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
         <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
@@ -12,71 +12,101 @@
 
     <sql id="Base_Column_List">
         id_
-        , room_uid_, biz_id_, type_, created_by_, created_time_
+        , room_uid_, user_id_, type_, created_by_, created_time_
     </sql>
 
     <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
             parameterType="com.ym.mec.biz.dal.entity.ImLiveRoomPurview">
-        insert into im_live_room_purview(room_uid_, biz_id_, type_, created_by_, created_time_)
+        insert into im_live_room_purview(room_uid_, user_id_, type_, created_by_, created_time_)
         values
         <foreach collection="entities" item="entity" separator=",">
-            (#{entity.roomUid}, #{entity.bizId}, #{entity.type}, #{entity.createdBy}, #{entity.createdTime})
+            (#{entity.roomUid}, #{entity.userId}, #{entity.type}, #{entity.createdBy}, #{entity.createdTime})
         </foreach>
+        ON DUPLICATE KEY UPDATE
+        created_by_ = VALUES(created_by_),
+        created_time_ = VALUES(created_time_)
     </insert>
 
-    <select id="queryStudent" parameterType="map" resultType="com.ym.mec.biz.dal.dto.SysUserDto">
-        SELECT
-            s.user_id_ as userId,
-            su.username_ as username,
-            su.phone_ as phone,
-            o.name_ as organName,
-            sb.name_ as subjectName
-        FROM (select CAST(biz_id_ AS SIGNED) as bizId, room_uid_ from im_live_room_purview where type_ = #{param.type}) a
-                 LEFT JOIN student s on a.bizId = s.user_id_
-                 LEFT JOIN sys_user su ON su.id_ = s.user_id_
-                 LEFT JOIN organization o ON o.id_ = su.organ_id_
-                 LEFT JOIN `subject` sb ON sb.id_ = s.subject_id_list_
-        where a.room_uid_ = #{param.roomUid}
-        <if test="param.subjectId != null">
-            AND s.subject_id_list_ = #{param.subjectId}
-        </if>
-        <if test="param.search != null ">
-            AND (
-            s.`user_id_` LIKE CONCAT('%', #{param.search},'%')
-            or su.phone_ like concat('%',#{query.search},'%')
-            or su.username_ like concat('%',#{query.search},'%')
-            )
-        </if>
-    </select>
-
     <select id="selectRoomPurviewStudent" parameterType="map" resultType="com.ym.mec.biz.dal.dto.SysUserDto">
-        SELECT
+        SELECT distinct
         s.user_id_ userId,
         su.username_ username,
         su.phone_ phone,
         o.name_ organName,
         sb.name_ subjectName
         FROM student s
+        <choose>
+            <when test="param.groupIds != null">
+                INNER JOIN
+            </when>
+            <otherwise>
+                LEFT JOIN
+            </otherwise>
+        </choose>
+                (select
+                     b.user_id_,
+                     replace(group_concat(a.name_,'|'),',','')  imGroupName,
+                     group_concat( a.id_ ) as im_group_id_
+                  from im_group a
+                  left join im_group_member b on a.id_ = b.im_group_id_
+                 <where>
+                     <if test="param.groupIds != null">
+                         and find_in_set(a.id_, #{param.groupIds})
+                     </if>
+                 </where>
+        group by b.user_id_) gm on s.user_id_ = gm.user_id_
         LEFT JOIN sys_user su ON su.id_ = s.user_id_
         LEFT JOIN organization o ON o.id_ = su.organ_id_
         LEFT JOIN `subject` sb ON sb.id_ = s.subject_id_list_
-        where
-        s.user_id_ not in(select CAST(biz_id_ AS SIGNED) from im_live_room_purview where room_uid_ = #{param.roomUid}
-        and type_ = #{param.type})
-        <if test="param.organId != null and param.organId != ''">
-            AND FIND_IN_SET(su.organ_id_,#{organId})
-        </if>
-        <if test="param.subjectId != null">
-            AND s.subject_id_list_ = #{param.subjectId}
-        </if>
-        <if test="param.search != null ">
-            AND (
-            s.`user_id_` LIKE CONCAT('%', #{param.search},'%')
-            or su.phone_ like concat('%',#{query.search},'%')
-            or su.username_ like concat('%',#{query.search},'%')
-            )
-        </if>
-
+        LEFT JOIN cooperation_organ co on co.organ_id_ = o.id_
+        <choose>
+            <when test="param.teamIds != null">
+                INNER JOIN
+            </when>
+            <otherwise>
+                LEFT JOIN
+            </otherwise>
+        </choose>
+            (select
+                user_id_,
+                replace(group_concat(a.name_,'|'),',','')  musicGroupName
+                from
+                music_group a left join
+                student_registration b  on a.id_ = b.music_group_id_
+                where b.music_group_status_ != 'QUIT'
+                <if test="param.teamIds != null">
+                     and find_in_set(a.id_ ,#{param.teamIds})
+                </if>
+        group by b.user_id_) sr on sr.user_id_ = s.user_id_
+        <where>
+            <if test="param.tenantId != null ">
+                AND s.tenant_id_ = #{param.tenantId}
+            </if>
+            <choose>
+                <when test="param.inExist != null ">
+                    AND s.user_id_ in (select user_id_ from im_live_room_purview where room_uid_ = #{param.roomUid})
+                </when>
+                <otherwise>
+                    AND s.user_id_ not in (select user_id_ from im_live_room_purview where room_uid_ = #{param.roomUid})
+                </otherwise>
+            </choose>
+            <if test="param.organIds != null and param.organIds != ''">
+                AND FIND_IN_SET(su.organ_id_,#{param.organIds})
+            </if>
+            <if test="param.subjectIds != null">
+                AND FIND_IN_SET(s.subject_id_list_,#{param.subjectIds})
+            </if>
+            <if test="param.schoolIds != null">
+                AND FIND_IN_SET(s.cooperation_organ_id_ ,#{param.schoolIds})
+            </if>
+            <if test="param.search != null ">
+                AND (
+                s.`user_id_` LIKE CONCAT('%', #{param.search},'%')
+                or su.phone_ like concat('%',#{param.search},'%')
+                or su.username_ like concat('%',#{param.search},'%')
+                )
+            </if>
+        </where>
     </select>
 
     <resultMap type="com.ym.mec.biz.dal.entity.ImGroup" id="ImGroup">
@@ -99,14 +129,6 @@
         from im_group as a
                  inner join im_group_member b on a.id_ = b.im_group_id_
         where b.user_id_ = (param.userId)
-        and a.id_
-        <if test="param.notIn != null">
-          not in
-        </if>
-        <if test="param.in != null">
-            in
-        </if>
-              (select biz_id_ from im_live_room_purview where room_uid_ = #{param.roomUid} and type_ = #{param.type})
         <if test="param.search != null and search != ''">
             AND (a.name_ like concat('%',#{param.search},'%') or a..tags_ like concat('%',#{param.search},'%'))
         </if>

+ 4 - 38
mec-biz/src/main/resources/config/mybatis/ImLiveRoomReservationMapper.xml

@@ -49,44 +49,10 @@
         from im_live_broadcast_room
         where popularize_type_ = 'ALL'
         union all
-        select *
-        from im_live_broadcast_room
-        where popularize_type_ = 'ORGAN'
-        AND FIND_IN_SET(#{param.organId}, popularize_org_ids_)
-        <if test="param.schoolId != null">
-            union all
-            select *
-            from im_live_broadcast_room
-            where popularize_type_ = 'SCHOOL'
-            AND FIND_IN_SET(#{param.schoolId}, popularize_school_ids_)
-        </if>
-        <if test="param.teamIds != null">
-            union all
-            select *
-            from im_live_broadcast_room as a
-            where popularize_type_ = 'TEAM'
-            and INTE_ARRAY(a.popularize_team_ids_, #{param.teamIds}) = 1
-        </if>
-        union all
-        select distinct r.* from im_live_broadcast_room as r inner join
-        im_live_room_purview as a on r.room_uid_ = a.room_uid_
-        where
-        r.popularize_type_= 'GROUP'
-        and a.biz_id_ in (
-        select
-        distinct a.id_
-        from
-        im_group a
-        inner join im_group_member b on a.id_=b.im_group_id_
-        where b.user_id_ = #{param.userId})
-        union all
-        select b.* from
-        (select
-        room_uid_ from im_live_room_purview where
-        CAST(biz_id_ AS SIGNED)  = #{param.userId}
-        and type_ = 'STUDENT') a
-        left join  im_live_broadcast_room b on a.room_uid_ = b.room_uid_
-        where b.popularize_type_ = 'STUDENT'
+        select a.*
+        from im_live_broadcast_room as a
+        inner join im_live_room_purview as b on a.room_uid_ = b.room_uid_
+        where b.user_id_ = #{param.userId}
         ) as a
         left join tenant_info AS t on a.tenant_id_ = t.id_
         left join sys_user AS b on a.speaker_id_ = b.id_

+ 11 - 4
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -21,6 +21,7 @@
         <result column="is_renew_" property="isRenew"/>
         <result column="income_item_" property="incomeItem"/>
         <result column="income_" property="income"/>
+        <result column="minuend_stock_goods_id_list_" property="minuendStockGoodsIdList"/>
         <result column="user_id_" property="userId"/>
         <collection property="goodsList" ofType="com.ym.mec.biz.dal.entity.Goods">
             <result column="goods_id_" property="id"/>
@@ -64,10 +65,10 @@
             keyColumn="id" keyProperty="id">
         INSERT INTO student_payment_order_detail
         (type_,goods_id_list_,price_,create_time_,update_time_,payment_order_id_,kit_group_purchase_type_,
-         student_instrument_id_,is_renew_,income_item_,income_,tenant_id_,remit_fee_)
+         student_instrument_id_,is_renew_,income_item_,income_,minuend_stock_goods_id_list_,tenant_id_,remit_fee_)
         VALUES(#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{goodsIdList},#{price},now(),now(),
         #{paymentOrderId},#{kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-               #{studentInstrumentId},#{isRenew},#{incomeItem},#{income},#{tenantId},#{remitFee})
+               #{studentInstrumentId},#{isRenew},#{incomeItem},#{income},#{minuendStockGoodsIdList},#{tenantId},#{remitFee})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -102,6 +103,9 @@
             <if test="income != null">
                 income_ = #{income},
             </if>
+            <if test="minuendStockGoodsIdList != null">
+                minuend_stock_goods_id_list_ = #{minuendStockGoodsIdList},
+            </if>
         </set>
         WHERE id_ = #{id} and tenant_id_ = #{tenantId}
     </update>
@@ -138,6 +142,9 @@
 	            <if test="item.income != null">
 	                income_ = #{item.income},
 	            </if>
+	            <if test="item.minuendStockGoodsIdList != null">
+	                minuend_stock_goods_id_list_ = #{item.minuendStockGoodsIdList},
+	            </if>
 	        </set>
 	        WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
         </foreach>
@@ -165,13 +172,13 @@
     <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
         INSERT INTO student_payment_order_detail
         (type_,goods_id_list_,price_,remit_fee_,create_time_,update_time_,payment_order_id_,
-         kit_group_purchase_type_,student_instrument_id_,is_renew_,income_item_,income_,tenant_id_)
+         kit_group_purchase_type_,student_instrument_id_,is_renew_,income_item_,income_,minuend_stock_goods_id_list_,tenant_id_)
         VALUE
         <foreach collection="studentPaymentOrderDetailList" item="orderDetail" separator=",">
             (#{orderDetail.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             #{orderDetail.goodsIdList},#{orderDetail.price},#{orderDetail.remitFee},now(),now(),#{orderDetail.paymentOrderId},
             #{orderDetail.kitGroupPurchaseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-            #{orderDetail.studentInstrumentId},#{orderDetail.isRenew},#{orderDetail.incomeItem},#{orderDetail.income},#{orderDetail.tenantId})
+            #{orderDetail.studentInstrumentId},#{orderDetail.isRenew},#{orderDetail.incomeItem},#{orderDetail.income},#{orderDetail.minuendStockGoodsIdList},#{orderDetail.tenantId})
         </foreach>
     </insert>
 

+ 19 - 1
mec-common/common-core/src/main/java/com/ym/mec/common/page/WrapperUtil.java

@@ -146,7 +146,7 @@ public class WrapperUtil<T> {
                 .filter(StrPredicate);
     }
 
-    public static <S, O> boolean strParamIsNull(Map<S, O>  map, S str) {
+    public static <S, O> boolean strParamIsNull(Map<S, O> map, S str) {
         return StrPredicate.test(WrapperUtil.toStr(map, str));
     }
 
@@ -184,6 +184,24 @@ public class WrapperUtil<T> {
                 .collect(Collectors.toList());
     }
 
+    public static List<Integer> splitToIntList(String str) {
+        List<String> strList = WrapperUtil.toList(str);
+        if (CollectionUtils.isEmpty(strList)) {
+            return null;
+        }
+        return strToIntList(strList);
+    }
+
+    public static List<Integer> strToIntList(List<String> strList) {
+        if (CollectionUtils.isEmpty(strList)) {
+            return null;
+        }
+        return strList.stream()
+                .distinct()
+                .map(WrapperUtil::toInt)
+                .collect(Collectors.toList());
+    }
+
     /**
      * 全部有值则为true
      *

+ 10 - 0
mec-im/src/main/java/com/ym/controller/LiveRoomController.java

@@ -74,4 +74,14 @@ public class LiveRoomController {
     public boolean checkOnline(String userId) {
         return liveRoomService.checkOnline(userId);
     }
+
+    /**
+     * https://doc.rongcloud.cn/imserver/server/v1/chatroom/status
+     */
+    @ApiOperation("聊天室状态同步")
+    @RequestMapping(value = "/syncChatRoomStatus")
+    public void syncChatRoomStatus(@RequestBody String body) {
+        log.info("syncChatRoomStatus body:{}", body);
+    }
+    
 }

+ 52 - 3
mec-student/src/main/java/com/ym/mec/student/controller/ImLiveBroadcastRoomController.java

@@ -4,14 +4,14 @@ import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo;
 import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.entity.ImUserState;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * 直播房间管理表(ImLiveBroadcastRoom)表控制层
@@ -29,6 +29,12 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @Resource
     private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
 
+    @ApiOperation("学生端-查询房间信息")
+    @GetMapping("/queryRoomInfo")
+    public HttpResponseResult<ImLiveBroadcastRoomVo> queryRoomInfo(@ApiParam(value = "房间uid", required = true) String roomUid) {
+        return succeed(imLiveBroadcastRoomService.queryRoomInfo(roomUid));
+    }
+
     @ApiOperation("查询该机构目前推广的直播间")
     @GetMapping(value = "/queryPopularizeRoom")
     public HttpResponseResult<ImLiveBroadcastRoomVo> queryPopularizeRoom() {
@@ -42,5 +48,48 @@ public class ImLiveBroadcastRoomController extends BaseController {
         return succeed(imLiveBroadcastRoomService.queryRoomAndCheck(roomUid, userId, 1));
     }
 
+    @ApiOperation("同步点赞数量")
+    @GetMapping("/syncLike")
+    public HttpResponseResult<Object> syncLike(@ApiParam(value = "房间uid", required = true) String roomUid,
+                                               @ApiParam(value = "点赞数", required = true) Integer likeNum) {
+        imLiveBroadcastRoomService.syncLike(roomUid, likeNum);
+        return succeed();
+    }
+
+    @PostMapping("/quitRoom")
+    public HttpResponseResult<Object> quitRoom(@RequestBody List<ImUserState> userState) {
+        imLiveBroadcastRoomService.opsRoom(userState);
+        return succeed();
+    }
+
+    @ApiOperation("主讲人进入房间")
+    @GetMapping("/speakerJoinRoom")
+    public HttpResponseResult<ImLiveBroadcastRoomVo> speakerJoinRoom(String roomUid) {
+        return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid));
+    }
+
+    @ApiOperation("学生-进入房间")
+    @GetMapping("/joinRoom")
+    public HttpResponseResult<Object> joinRoom(String roomUid, Integer userId) {
+        imLiveBroadcastRoomService.joinRoom(roomUid, userId);
+        return succeed();
+    }
+
+    @ApiOperation("开启/关闭直播的录像")
+    @GetMapping("/opsLiveVideo")
+    public HttpResponseResult<Object> opsLiveVideo(@ApiParam(value = "房间uid", required = true) String roomUid,
+                                                   @ApiParam(value = "用户id", required = true) Integer userId,
+                                                   @ApiParam(value = "type 1:开始直播-开始录像     2:关闭直播关闭录像", required = true) Integer type) {
+        if (type == 1) {
+            imLiveBroadcastRoomService.startLive(roomUid, userId);
+        } else if (type == 2) {
+            imLiveBroadcastRoomService.closeLive(roomUid, userId);
+        } else {
+            failed("type参数错误");
+        }
+        return succeed();
+    }
+
+
 }
 

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

@@ -154,7 +154,7 @@ public class MusicGroupController extends BaseController {
                 MusicGroupPaymentCalender paymentCalender = musicGroupPaymentCalenderService.getApplyCalenderByMusicId(musicGroupId);
                 HashMap<String, Object> calenderDetail = new HashMap<>(5);
                 musicGroupPaymentCalenderService.getCalenderDetail(calenderDetail,paymentCalender.getId());
-                boolean flag = false;
+                boolean flag = true;
                 //是否购买乐团课
                 if(Objects.nonNull(calenderDetail.get("course"))){
                     if(typeList.contains(OrderDetailTypeEnum.COURSE)

+ 156 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherImLiveBroadcastRoomController.java

@@ -0,0 +1,156 @@
+package com.ym.mec.teacher.controller;
+
+import com.ym.mec.biz.dal.dto.ImLiveBroadcastRoomDto;
+import com.ym.mec.biz.dal.dto.RoomReservationUserSearch;
+import com.ym.mec.biz.dal.page.LiveRoomGoodsOrderQueryInfo;
+import com.ym.mec.biz.dal.vo.BaseRoomUserVo;
+import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo;
+import com.ym.mec.biz.dal.vo.LiveRoomGoodsOrderVo;
+import com.ym.mec.biz.dal.vo.RoomReservationUserVo;
+import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.entity.ImUserState;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.WrapperUtil;
+import io.swagger.annotations.*;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * 直播房间管理表(ImLiveBroadcastRoom)表控制层
+ *
+ * @author hgw
+ * @since 2022-02-17 20:52:04
+ */
+@Api(tags = "直播房间管理表")
+@RestController
+@RequestMapping("/imLiveBroadcastRoom")
+public class TeacherImLiveBroadcastRoomController extends BaseController {
+    /**
+     * 服务对象
+     */
+    @Resource
+    private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
+            @ApiImplicitParam(name = "liveState", dataType = "Integer", value = "直播状态 0未开始 1开始 2结束"),
+            @ApiImplicitParam(name = "startTime", dataType = "String", value = "开始时间"),
+            @ApiImplicitParam(name = "endTime", dataType = "String", value = "结束时间"),
+            @ApiImplicitParam(name = "popularize", dataType = "Integer", value = "是否在首页推广 0否 1是"),
+            @ApiImplicitParam(name = "speakerId", dataType = "Integer", value = "老师ID"),
+            @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
+            @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
+    })
+    @ApiOperation("分页查询直播间列表")
+    @PostMapping("/queryPage")
+    public HttpResponseResult<PageInfo<ImLiveBroadcastRoomVo>> queryPage(@RequestBody Map<String, Object> param) {
+        return succeed(imLiveBroadcastRoomService.queryPage(param));
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
+            @ApiImplicitParam(name = "subjectId", dataType = "Integer", value = "声部id"),
+            @ApiImplicitParam(name = "organId", dataType = "Integer", value = "分部id"),
+            @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
+            @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
+    })
+    @ApiOperation("直播间预约人员信息")
+    @PostMapping("/query/roomUser")
+    public HttpResponseResult<PageInfo<RoomReservationUserVo>> queryRoomUser(@RequestBody @Valid RoomReservationUserSearch query) {
+        return succeed(imLiveBroadcastRoomService.queryRoomUser(query));
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
+            @ApiImplicitParam(name = "subjectId", dataType = "Integer", value = "声部id"),
+            @ApiImplicitParam(name = "organId", dataType = "Integer", value = "分部id"),
+    })
+    @ApiOperation(value = "导出训练营详情")
+    @PostMapping(value = "/exportReservationRoomUser")
+    public void exportReservationRoomUser(@RequestBody RoomReservationUserSearch query, HttpServletResponse response) throws IOException {
+        imLiveBroadcastRoomService.exportReservationRoomUser(query, response);
+    }
+
+    @ApiOperation("查询房间信息并校验房间是否合规")
+    @GetMapping("/queryRoom")
+    public HttpResponseResult<ImLiveBroadcastRoomVo> queryRoomAndCheck(@ApiParam(value = "房间uid", required = true) String roomUid,
+                                                                       @ApiParam(value = "用户id", required = true) Integer userId) {
+        return succeed(imLiveBroadcastRoomService.queryRoomAndCheck(roomUid, userId, 2));
+    }
+
+    /**
+     * 关闭直播间
+     *
+     * @param id 房间表id
+     */
+    @ApiOperation("关闭直播间")
+    @GetMapping(value = "/roomDestroy/{id}")
+    public HttpResponseResult<Object> roomDestroy(@ApiParam(value = "房间表id", required = true) @PathVariable("id") Integer id) {
+        imLiveBroadcastRoomService.roomDestroy(id);
+        return succeed();
+    }
+
+    @ApiOperation("推广直播间-每个机构只能有一个直播间在首页推广")
+    @GetMapping("/opsPopularize")
+    @PreAuthorize("@pcs.hasPermissions('imLiveBroadcastRoom/opsPopularize')")
+    public HttpResponseResult<Object> opsPopularize(@ApiParam(value = "房间id", required = true) Integer id,
+                                                    @ApiParam(value = "是否在首页推广 0否 1是", required = true) Integer popularize) {
+        imLiveBroadcastRoomService.opsPopularize(id, popularize);
+        return succeed();
+    }
+
+    @ApiOperation("同步点赞数量")
+    @GetMapping("/syncLike")
+    public HttpResponseResult<Object> syncLike(@ApiParam(value = "房间uid", required = true) String roomUid,
+                                               @ApiParam(value = "点赞数", required = true) Integer likeNum) {
+        imLiveBroadcastRoomService.syncLike(roomUid, likeNum);
+        return succeed();
+    }
+
+    @PostMapping("/quitRoom")
+    public HttpResponseResult<Object> quitRoom(@RequestBody List<ImUserState> userState) {
+        imLiveBroadcastRoomService.opsRoom(userState);
+        return succeed();
+    }
+
+    @ApiOperation("主讲人进入房间")
+    @GetMapping("/speakerJoinRoom")
+    public HttpResponseResult<ImLiveBroadcastRoomVo> speakerJoinRoom(String roomUid) {
+        return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid));
+    }
+
+    @GetMapping("/test")
+    public Object test(String roomUid) {
+        return imLiveBroadcastRoomService.test(roomUid);
+    }
+
+    @GetMapping("/shareGroup")
+    public HttpResponseResult<Object> shareGroup(@ApiParam(value = "房间uid", required = true) String roomUid,
+                                                 @ApiParam(value = "群编号", required = true) String groupIds) {
+        imLiveBroadcastRoomService.shareGroup(roomUid, groupIds);
+        return succeed();
+    }
+
+    @ApiOperation("获取房间人员")
+    @GetMapping("/queryRoomUserInfo")
+    public HttpResponseResult<List<BaseRoomUserVo>> queryRoomUserInfo(@ApiParam(value = "房间uid", required = true) String roomUid) {
+        return succeed(imLiveBroadcastRoomService.queryRoomLimitOnlineUserInfo(roomUid));
+    }
+
+    @ApiOperation("查询直播间商品订单列表")
+    @GetMapping("/queryLiveRoomGoodsOrderList")
+    public HttpResponseResult<PageInfo<LiveRoomGoodsOrderVo>> queryLiveRoomGoodsOrderList(LiveRoomGoodsOrderQueryInfo queryInfo) {
+        return succeed(imLiveBroadcastRoomService.queryLiveRoomGoodsOrderList(queryInfo));
+    }
+}
+

+ 8 - 7
mec-web/src/main/java/com/ym/mec/web/controller/ImLiveBroadcastRoomController.java

@@ -87,7 +87,7 @@ public class ImLiveBroadcastRoomController extends BaseController {
         return succeed(imLiveBroadcastRoomService.queryRoomAndCheck(roomUid, userId, null));
     }
 
-    @ApiOperation("查询房间信息")
+    @ApiOperation("学生端-查询房间信息")
     @GetMapping("/queryRoomInfo")
     public HttpResponseResult<ImLiveBroadcastRoomVo> queryRoomInfo(@ApiParam(value = "房间uid", required = true) String roomUid) {
         return succeed(imLiveBroadcastRoomService.queryRoomInfo(roomUid));
@@ -96,17 +96,18 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @ApiOperation("创建直播间")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('imLiveBroadcastRoom/add')")
-    public HttpResponseResult<ImLiveBroadcastRoomVo> add(@Valid @RequestBody ImLiveBroadcastRoomDto dto) {
-        ImLiveBroadcastRoomVo add = imLiveBroadcastRoomService.add(dto);
+    public HttpResponseResult<Object> add(@Valid @RequestBody ImLiveBroadcastRoomDto dto) {
+        imLiveBroadcastRoomService.add(dto);
         //看是否需要马上创建房间
         CompletableFuture.runAsync(imLiveBroadcastRoomService::createLiveRoom);
-        return succeed(add);
+        return succeed();
     }
 
     @ApiOperation("修改直播间信息-已开播无法修改")
     @PostMapping("/update")
-    public HttpResponseResult<ImLiveBroadcastRoomVo> update(@Valid @RequestBody ImLiveBroadcastRoomDto dto) {
-        return succeed(imLiveBroadcastRoomService.update(dto));
+    public HttpResponseResult<Object> update(@Valid @RequestBody ImLiveBroadcastRoomDto dto) {
+        imLiveBroadcastRoomService.update(dto);
+        return succeed();
     }
 
     /**
@@ -176,7 +177,7 @@ public class ImLiveBroadcastRoomController extends BaseController {
         return succeed(imLiveBroadcastRoomService.speakerJoinRoom(roomUid));
     }
 
-    @ApiOperation("进入房间")
+    @ApiOperation("学生-进入房间")
     @GetMapping("/joinRoom")
     public HttpResponseResult<Object> joinRoom(String roomUid, Integer userId) {
         imLiveBroadcastRoomService.joinRoom(roomUid, userId);

+ 38 - 18
mec-web/src/main/java/com/ym/mec/web/controller/ImLiveRoomPurviewController.java

@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import java.util.Map;
@@ -31,10 +32,27 @@ public class ImLiveRoomPurviewController extends BaseController {
     private ImLiveRoomPurviewService imLiveRoomPurviewService;
 
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", dataType = "String", value = "删除的id,学员id,群id, 逗号分开", required = true),
+            @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
+            @ApiImplicitParam(name = "subjectId", dataType = "String", value = "声部ID"),
+            @ApiImplicitParam(name = "organIds", dataType = "String", value = "分部ID"),
+            @ApiImplicitParam(name = "groupIds", dataType = "String", value = "群聊ID"),
+            @ApiImplicitParam(name = "teamIds", dataType = "String", value = "乐团ID"),
+            @ApiImplicitParam(name = "schoolIds", dataType = "String", value = "学校id/合作单位id"),
+            @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true)
+    })
+    @ApiOperation("批量添加/根据查询条件添加房间观看权限")
+    @PostMapping("/addByCondition")
+    @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/addByCondition')")
+    public HttpResponseResult<Object> addByCondition(@RequestBody Map<String, Object> param) {
+        imLiveRoomPurviewService.addByCondition(param);
+        return succeed();
+    }
+
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ids", dataType = "String", value = "学员id逗号分开", required = true),
             @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true),
     })
-    @ApiOperation("删除观看权限数据")
+    @ApiOperation("指定多个学员id添加观看权限数据")
     @GetMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/add')")
     public HttpResponseResult<Object> add(String ids, String roomUid) {
@@ -57,11 +75,15 @@ public class ImLiveRoomPurviewController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
             @ApiImplicitParam(name = "subjectId", dataType = "String", value = "声部ID"),
+            @ApiImplicitParam(name = "organIds", dataType = "String", value = "分部ID"),
+            @ApiImplicitParam(name = "groupIds", dataType = "String", value = "群聊ID"),
+            @ApiImplicitParam(name = "teamIds", dataType = "String", value = "乐团ID"),
+            @ApiImplicitParam(name = "schoolIds", dataType = "String", value = "学校id/合作单位id"),
             @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true),
             @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
             @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
     })
-    @ApiOperation("查询当前直播间学员列表-观看权限")
+    @ApiOperation("查询当前直播间观看权限-学员列表")
     @PostMapping("/queryStudent")
     @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/queryStudent')")
     public HttpResponseResult<PageInfo<SysUserDto>> queryStudent(@RequestBody Map<String, Object> param) {
@@ -70,21 +92,11 @@ public class ImLiveRoomPurviewController extends BaseController {
 
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
-            @ApiImplicitParam(name = "groupType", dataType = "String", value = "群类型"),
-            @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true),
-            @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
-            @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
-    })
-    @ApiOperation("查询当前直播间群聊列表-观看权限")
-    @PostMapping("/queryGroup")
-    @PreAuthorize("@pcs.hasPermissions('imLiveRoomPurview/queryGroup')")
-    public HttpResponseResult<PageInfo<ImGroup>> queryGroup(@RequestBody Map<String, Object> param) {
-        return succeed(imLiveRoomPurviewService.queryGroup(param));
-    }
-
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
             @ApiImplicitParam(name = "subjectId", dataType = "String", value = "声部ID"),
+            @ApiImplicitParam(name = "organIds", dataType = "String", value = "分部ID"),
+            @ApiImplicitParam(name = "groupIds", dataType = "String", value = "群聊ID"),
+            @ApiImplicitParam(name = "teamIds", dataType = "String", value = "乐团ID"),
+            @ApiImplicitParam(name = "schoolIds", dataType = "String", value = "学校id/合作单位id"),
             @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true),
             @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
             @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
@@ -99,7 +111,6 @@ public class ImLiveRoomPurviewController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "模糊查询关键字"),
             @ApiImplicitParam(name = "groupType", dataType = "String", value = "群类型"),
-            @ApiImplicitParam(name = "roomUid", dataType = "String", value = "直播间UID", required = true),
             @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
             @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
     })
@@ -110,5 +121,14 @@ public class ImLiveRoomPurviewController extends BaseController {
         return succeed(imLiveRoomPurviewService.selectRoomPurviewGroup(param));
     }
 
+    @ApiOperation(value = "导入观看权限-人员")
+    @PostMapping(value = "/importPurviewUser")
+    public HttpResponseResult<String> importPurviewUser(@RequestParam("file") MultipartFile file, String roomUid) throws Exception {
+        String msg = imLiveRoomPurviewService.importPurviewUser(file, roomUid);
+        HttpResponseResult<String> succeed = succeed();
+        succeed.setMsg(msg);
+        return succeed;
+    }
+
 }
 

+ 4 - 0
mec-web/src/main/resources/columnMapper.ini

@@ -76,3 +76,7 @@ ID = id
 老师介绍 = introduction
 教学曲目 = musicContent
 头像地址 = avatar
+
+[直播间用户观看权限表]
+编号 = userId
+名称 = userName