Parcourir la source

Merge branch 'saas_2022_05_17_activity' of http://git.dayaedu.com/yonge/mec into master_saas

zouxuan il y a 3 ans
Parent
commit
a65d45091f

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

@@ -11,4 +11,6 @@ public interface LiveGoodsDao extends BaseDAO<Integer, LiveGoods> {
     int reduceStock(@Param("liveGoodsId") Integer liveGoodsId);
 
     void addStock(@Param("liveGoodsId") Integer liveGoodsId);
+
+    LiveGoods getByName(@Param("goodsName") String goodsName);
 }

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/LiveGoodsMapperService.java

@@ -19,6 +19,9 @@ public interface LiveGoodsMapperService extends BaseService<Integer, LiveGoodsMa
     //商品下架
     void downGoods(Integer liveGoodsId, String liveId);
 
+    //商品下架
+    void downGoods(String liveId);
+
     //商品上架
     void upGoods(Integer liveGoodsId, String liveId);
 

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

@@ -26,4 +26,6 @@ public interface LiveGoodsService extends BaseService<Integer, LiveGoods> {
     void reduceGoodsFreezeStock(Integer liveGoodsId, String liveId);
 
     Object queryGoodsPage(LiveGoodsQueryInfo queryInfo);
+
+    void add(LiveGoods liveGoods);
 }

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ActivityUserMapperServiceImpl.java

@@ -17,6 +17,7 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -282,13 +283,13 @@ public class ActivityUserMapperServiceImpl extends BaseServiceImpl<Integer, Acti
 		}
 		String activeConfig = sysConfigDao.findConfigValue("cloud_teacher_active_config");
 		List<Cloud2022ActivityDto> cloud2022ActivityDtos = JSONArray.parseArray(activeConfig, Cloud2022ActivityDto.class);
-		Cloud2022ActivityDto activityDto = cloud2022ActivityDtos.stream().filter(e -> e.getOrganId().contains(sysUser.getOrganId().toString())).findFirst().get();
-		if(Objects.isNull(activityDto)){
+		List<Cloud2022ActivityDto> activityDtos = cloud2022ActivityDtos.stream().filter(e -> e.getOrganId().contains(sysUser.getOrganId().toString())).collect(Collectors.toList());
+		if(CollectionUtils.isEmpty(activityDtos)){
 			map.put("courseNum",0);
 			return map;
 		}
 		//是否还有购买资格
-		Integer activityId = Integer.parseInt(activityDto.getActivityId());
+		Integer activityId = Integer.parseInt(activityDtos.get(0).getActivityId());
 		Integer noCourseNum = activityUserMapperDao.getStudentNoMapperInfo(sysUser.getId(), activityId);
 		map.put("courseNum",noCourseNum == null?0:noCourseNum);
 		return map;

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveBroadcastRoomServiceImpl.java

@@ -79,6 +79,8 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
     private ImLiveBroadcastRoomMemberService liveBroadcastRoomMemberService;
     @Autowired
     private ImLiveBroadcastRoomDataService liveBroadcastRoomDataService;
+    @Autowired
+    private LiveGoodsMapperService liveGoodsMapperService;
 
     //待替换的变量
     public static final String USER_ID = "${userId}";
@@ -437,9 +439,13 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
         room.setPopularize(0);//销毁直播间后要关闭推广
         this.updateById(room);
 
+        //下架商品
+        liveGoodsMapperService.downGoods(room.getRoomUid());
+
         //向聊天室发自定义消息踢出所有人
         try {
             ImRoomMessage message = new ImRoomMessage();
+            message.setIsIncludeSender(1);
             message.setFromUserId(speakerId.toString());
             message.setToChatroomId(roomUid);
             message.setObjectName(ImRoomMessage.FORCED_OFFLINE);

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

@@ -17,12 +17,14 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
 import com.ym.mec.util.collection.MapUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoodsMapper>  implements LiveGoodsMapperService {
@@ -113,6 +115,20 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
+	public void downGoods(String liveId){
+		ImLiveBroadcastRoom imLiveBroadcastRoom = Optional
+				.of(imLiveBroadcastRoomService.getBaseMapper().selectOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_",liveId))).
+				orElseThrow(() -> new RuntimeException("直播间不存在"));
+		List<LiveGoodsMapperDto> liveGoodsList = liveGoodsMapperDao.getLiveGoodsList(liveId, null, true);
+		if (CollectionUtils.isEmpty(liveGoodsList)) {
+			return;
+		}
+		for (LiveGoodsMapperDto liveGoodsMapperDto : liveGoodsList) {
+			this.down(liveGoodsMapperDto.getId(), liveId,imLiveBroadcastRoom);
+		}
+	}
+	@Override
+	@Transactional(rollbackFor = Exception.class)
 	public void downGoods(Integer liveGoodsId, String liveId){
 		ImLiveBroadcastRoom imLiveBroadcastRoom = Optional
 				.of(imLiveBroadcastRoomService.getBaseMapper().selectOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_",liveId))).
@@ -122,7 +138,10 @@ public class LiveGoodsMapperServiceImpl extends BaseServiceImpl<Integer, LiveGoo
 		if(!liveGoodsMapper.getStatus()){
 			throw new BizException("该商品已下架");
 		}
-		//下架直播间商品
+		this.down(liveGoodsId, liveId,imLiveBroadcastRoom);
+	}
+
+	private void down(Integer liveGoodsId, String liveId,ImLiveBroadcastRoom imLiveBroadcastRoom){
 		int i = liveGoodsMapperDao.updateStatus(liveId, liveGoodsId, false);
 		if (i == 0) {
 			return;

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

@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
@@ -153,7 +154,16 @@ public class LiveGoodsServiceImpl extends BaseServiceImpl<Integer, LiveGoods>  i
 		return queryPage(queryInfo);
 	}
 
-	public void stockLock(String lockKey, BiConsumer<Integer,String> consumer, Integer liveGoodsId, String liveId) {
+    @Override
+	@Transactional(rollbackFor = Exception.class)
+    public void add(LiveGoods liveGoods) {
+		//商品名称不能重复
+		LiveGoods goods = liveGoodsDao.getByName(liveGoods.getName());
+		if (goods != null) throw new BizException("商品名称已存在");
+		liveGoodsDao.insert(liveGoods);
+    }
+
+    public void stockLock(String lockKey, BiConsumer<Integer,String> consumer, Integer liveGoodsId, String liveId) {
 		RLock lock = redissonClient.getLock(lockKey);
 		try{
 			lock.lock();

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

@@ -252,12 +252,12 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
         if(memberPayParamDto.getLiveGoodsId() == 1){
             String activeConfig = sysConfigDao.findConfigValue("cloud_teacher_active_config");
             List<Cloud2022ActivityDto> cloud2022ActivityDtos = JSONArray.parseArray(activeConfig, Cloud2022ActivityDto.class);
-            Cloud2022ActivityDto activityDto = cloud2022ActivityDtos.stream().filter(e -> e.getOrganId().contains(sysUser.getOrganId().toString())).findFirst().get();
-            if(Objects.isNull(activityDto)){
+            List<Cloud2022ActivityDto> activityDtos = cloud2022ActivityDtos.stream().filter(e -> e.getOrganId().contains(sysUser.getOrganId().toString())).collect(Collectors.toList());
+            if(CollectionUtils.isEmpty(activityDtos)){
                 throw new BizException("当前分部暂未开通活动");
             }
             //是否还有购买资格
-            activityId = Integer.parseInt(activityDto.getActivityId());
+            activityId = Integer.parseInt(activityDtos.get(0).getActivityId());
             VipGroupActivity vipGroupActivity = Optional.of(vipGroupActivityDao.get(activityId)).orElseThrow(()-> new BizException("活动不存在"));
             if(vipGroupActivity.getStudentMaxUsedTimes() != -1){
                 //获取活动购买次数

+ 17 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TempLittleArtistTrainingCampServiceImpl.java

@@ -231,12 +231,27 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
      */
     @Override
     public PageInfo<TempCampUserTrainingDetailVo> queryUserTrainingDetail(Map<String, Object> param) {
+        //训练营详情-查询条件时间设置
+        queryUserTrainingDetailOpsParam(param);
         Page<TempCampUserTrainingDetailVo> page = PageUtil.getPageInfo(param);
         page.setDesc("b.playDay");
         return PageUtil.pageInfo(baseMapper.queryUserTrainingDetail(page, param));
     }
 
     /**
+     * 训练营详情-查询条件时间设置
+     */
+    private void queryUserTrainingDetailOpsParam(Map<String, Object> param) {
+        Integer campId = WrapperUtil.toInt(param, "campId", "训练营id不能为空");
+        TempLittleArtistTrainingCamp camp = this.getOne(Wrappers.<TempLittleArtistTrainingCamp>lambdaQuery()
+                .eq(TempLittleArtistTrainingCamp::getId, campId)
+                .eq(TempLittleArtistTrainingCamp::getDelFlag, 0));
+        param.put("startTime", camp.getTrainStartDate());
+        param.put("endTime", camp.getTrainEndDate());
+        param.put("state", TempLittleArtistTrainingCampUserRelation.APPLY);
+    }
+
+    /**
      * 根据群组Id查询群组信息
      *
      * @param imGroupIds 群组id,多个用逗号隔开
@@ -262,9 +277,6 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
         //查询该学员是否购买过该训练营
         TempLittleArtistTrainingCampUserRelation userRelation = tempLittleArtistTrainingCampUserRelationService.getOne(Wrappers.<TempLittleArtistTrainingCampUserRelation>lambdaQuery()
                 .eq(TempLittleArtistTrainingCampUserRelation::getUserId, user.getId()));
-        if (Objects.isNull(userRelation)) {
-            throw new BizException("没有参与资格!");
-        }
         Map<String, Object> result = new HashMap<>();
         result.put("user", userRelation);
         if (CollectionUtils.isNotEmpty(campList)) {
@@ -359,6 +371,8 @@ public class TempLittleArtistTrainingCampServiceImpl extends ServiceImpl<TempLit
      * 导出小小训练营想详情
      */
     public void exportUserTrainingDetail(Map<String, Object> param, HttpServletResponse response) throws IOException {
+        //训练营详情-查询条件时间设置
+        queryUserTrainingDetailOpsParam(param);
         List<TempCampUserTrainingDetailVo> list = baseMapper.queryUserTrainingDetail(param);
         OutputStream outputStream = response.getOutputStream();
         HSSFWorkbook workbook = null;

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

@@ -115,4 +115,7 @@
 	<select id="getLock" resultMap="LiveGoods">
 		SELECT * FROM live_goods WHERE id_ = #{id} LIMIT 1 FOR UPDATE
 	</select>
+	<select id="getByName" resultMap="LiveGoods">
+		SELECT * FROM live_goods WHERE name_ = #{name} LIMIT 1
+	</select>
 </mapper>

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

@@ -78,7 +78,7 @@
 				AND lgm.live_id_ = #{liveId}
 			</if>
 			<if test="search != null and search != ''">
-				AND (lg.name_ LIKE '%${search}%' OR lg.id_ = ${search})
+				AND (lg.name_ LIKE CONCAT('%',#{search},'%') OR lg.id_ = #{search})
 			</if>
 			<if test="status != null">
 				AND lgm.status_ = #{status}

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

@@ -124,6 +124,7 @@
         left join sys_user as d on d.id_ = a.user_id_
         left join im_group as e on a.im_group_id_ = e.id_
         <where>
+            a.activity_id_ = #{param.campId} and a.state_ = #{param.state}
             <if test="param.imGroupId != null">
                 AND e.im_group_id_ = #{param.imGroupId}
             </if>

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

@@ -35,27 +35,6 @@ public class TempLittleArtistTrainingCampController extends BaseController {
     @Resource
     private TempLittleArtistTrainingCampUserRelationService tempLittleArtistTrainingCampUserRelationService;
 
-    @ApiOperation("添加训练营")
-    @PostMapping(value = "/add")
-    public HttpResponseResult<Object> add(@Valid @RequestBody TempLittleArtistTrainingCampDto dto) {
-        tempLittleArtistTrainingCampService.add(dto);
-        return succeed();
-    }
-
-    @ApiOperation("修改训练营")
-    @PostMapping(value = "/update")
-    public HttpResponseResult<Object> update(@Valid @RequestBody TempLittleArtistTrainingCampDto dto) {
-        tempLittleArtistTrainingCampService.update(dto);
-        return succeed();
-    }
-
-    @ApiOperation("修改机构启用停用状态")
-    @GetMapping(value = "/delete/{id}")
-    public HttpResponseResult<Object> opsState(@ApiParam(value = "训练营ID", required = true) @PathVariable("id") Integer id) {
-        tempLittleArtistTrainingCampService.delete(id);
-        return succeed();
-    }
-
     @ApiImplicitParams({
             @ApiImplicitParam(name = "name", dataType = "String", value = "训练营标题-模糊搜索"),
             @ApiImplicitParam(name = "state", dataType = "String", value = "筹备中 READY,报名中 APPLY,未开始 NOT_START,进行中 ING,已结束 END"),
@@ -73,18 +52,6 @@ public class TempLittleArtistTrainingCampController extends BaseController {
     }
 
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "search", dataType = "String", value = "学员姓名/手机号/编号-模糊搜索"),
-            @ApiImplicitParam(name = "state", dataType = "String", value = "状态:未报名NOT_APPLY ,已报名 APPLY"),
-            @ApiImplicitParam(name = "page", dataType = "Integer", required = true, value = "页数"),
-            @ApiImplicitParam(name = "rows", dataType = "Integer", required = true, value = "每页数量"),
-    })
-    @ApiOperation("分页查询-参与名单")
-    @PostMapping(value = "/queryPageTrainingCampUser")
-    public HttpResponseResult<PageInfo<TempCampUserVo>> queryPageTrainingCampUser(@RequestBody Map<String, Object> param) {
-        return succeed(tempLittleArtistTrainingCampService.queryPageTrainingCampUser(param));
-    }
-
-    @ApiImplicitParams({
             @ApiImplicitParam(name = "userId", dataType = "Integer", required = true, value = "用户id"),
     })
     @ApiOperation("查询指定学生-训练营每日训练时长")
@@ -96,6 +63,7 @@ public class TempLittleArtistTrainingCampController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "学员姓名/手机号/编号-模糊搜索"),
             @ApiImplicitParam(name = "imGroupId", dataType = "Integer", value = "所在群组Id"),
+            @ApiImplicitParam(name = "campId", dataType = "Integer", value = "训练营id"),
             @ApiImplicitParam(name = "page", dataType = "Integer", required = true, value = "页数"),
             @ApiImplicitParam(name = "rows", dataType = "Integer", required = true, value = "每页数量"),
     })
@@ -105,12 +73,6 @@ public class TempLittleArtistTrainingCampController extends BaseController {
         return succeed(tempLittleArtistTrainingCampService.queryUserTrainingDetail(param));
     }
 
-    @ApiOperation("根据群组Id查询群组信息")
-    @GetMapping(value = "/queryCampImGroup")
-    public HttpResponseResult<List<ImGroup>> queryCampImGroup(@ApiParam(value = "群组id,多个用逗号隔开 imGroupIds", required = true) String imGroupIds){
-        return succeed(tempLittleArtistTrainingCampService.queryCampImGroup(imGroupIds));
-    }
-
     /**
      * 查询训练营周期表
      *

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

@@ -37,7 +37,7 @@ public class LiveGoodsController extends BaseController {
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('liveGoods/add')")
     public HttpResponseResult add(@RequestBody LiveGoods liveGoods) {
-        liveGoodsService.insert(liveGoods);
+        liveGoodsService.add(liveGoods);
         return succeed();
     }
 

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

@@ -98,6 +98,7 @@ public class TempLittleArtistTrainingCampController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "学员姓名/手机号/编号-模糊搜索"),
             @ApiImplicitParam(name = "imGroupId", dataType = "Integer", value = "所在群组Id"),
+            @ApiImplicitParam(name = "campId", dataType = "Integer", value = "训练营id"),
             @ApiImplicitParam(name = "page", dataType = "Integer", required = true, value = "页数"),
             @ApiImplicitParam(name = "rows", dataType = "Integer", required = true, value = "每页数量"),
     })
@@ -148,6 +149,7 @@ public class TempLittleArtistTrainingCampController extends BaseController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "search", dataType = "String", value = "学员姓名/手机号/编号-模糊搜索"),
             @ApiImplicitParam(name = "imGroupId", dataType = "Integer", value = "所在群组Id"),
+            @ApiImplicitParam(name = "campId", dataType = "Integer", value = "训练营id"),
     })
     @ApiOperation(value="导出训练营详情")
     @PostMapping(value = "/exportUserTrainingDetail")