|
|
@@ -1370,6 +1370,132 @@ public class UserStudyRecordServiceImpl extends ServiceImpl<UserStudyRecordMappe
|
|
|
return 2;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public Integer syncSevenModulePublicClass(Long orderGoodsId, Long userId) {
|
|
|
+ if(Validator.isEmpty(orderGoodsId)||Validator.isEmpty(userId)){
|
|
|
+ throw new CustomException("参数错误");
|
|
|
+ }
|
|
|
+ OrderGoods newOrderGoods = iOrderGoodsService.getOne(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderGoodsId, orderGoodsId));
|
|
|
+ if(newOrderGoods.getSevenClassStatus()==1||newOrderGoods.getSevenClassStatus()==2||newOrderGoods.getSevenClassStatus()==3){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ Goods goods = iGoodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getGoodsId, newOrderGoods.getGoodsId()));
|
|
|
+ String fullName;
|
|
|
+ CourseBusinessQueryBo queryBusinessBo = new CourseBusinessQueryBo();
|
|
|
+ queryBusinessBo.setId(goods.getBusinessId());
|
|
|
+ fullName = iCourseBusinessService.queryFullName(queryBusinessBo);
|
|
|
+ if(!fullName.contains("继续教育")||!fullName.contains("施工现场专业人员")){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(newOrderGoods.getSevenYear())){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ OrderGoods oldOrderGoods = iOrderGoodsService.getSevenLastOne(goods.getProjectId(),newOrderGoods.getSevenYear(),userId);
|
|
|
+ if(Validator.isEmpty(oldOrderGoods)){
|
|
|
+ newOrderGoods.setSevenClassVersion(newOrderGoods.getSevenClassVersion()+1);
|
|
|
+ newOrderGoods.setSevenClassStatus(1);
|
|
|
+ newOrderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iOrderGoodsService.updateById(newOrderGoods);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if(newOrderGoods.getSevenClassStatus()==4){
|
|
|
+ newOrderGoods.setSevenClassVersion(oldOrderGoods.getSevenClassVersion()+1);
|
|
|
+ newOrderGoods.setSevenClassStatus(1);
|
|
|
+ newOrderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iOrderGoodsService.updateById(newOrderGoods);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ UserStudyRecord userStudyRecord = baseMapper.getSevenModuleStudyRecord(oldOrderGoods.getOrderGoodsId(),oldOrderGoods.getGradeId());
|
|
|
+ if(Validator.isEmpty(userStudyRecord)){
|
|
|
+ throw new CustomException("公共学习数据错误");
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<GoodsCourse> lqwCourse = Wrappers.lambdaQuery();
|
|
|
+ lqwCourse.eq(GoodsCourse::getGoodsId, goods.getGoodsId());
|
|
|
+ List<GoodsCourse> courseList = iGoodsCourseService.list(lqwCourse);
|
|
|
+ Long courseId = null;
|
|
|
+ for(GoodsCourse course : courseList){
|
|
|
+ CourseMenu courseMenu = iCourseMenuService.getOne(new LambdaQueryWrapper<CourseMenu>().eq(CourseMenu::getCourseId, course.getCourseId())
|
|
|
+ .eq(CourseMenu::getType, 1).eq(CourseMenu::getMenuId, userStudyRecord.getModuleId()).eq(CourseMenu::getParentId, 0));
|
|
|
+ if(Validator.isNotEmpty(courseMenu)){
|
|
|
+ courseId = course.getCourseId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(courseId)){
|
|
|
+ throw new CustomException("课程定位错误");
|
|
|
+ }
|
|
|
+ String key = "SYNC_SEVEN_Record:"+orderGoodsId;
|
|
|
+ Long keyStatus = redisCache.getCacheObject(key);
|
|
|
+ if(Validator.isNotEmpty(keyStatus)&&keyStatus==100L){
|
|
|
+ return 100;
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(key, 100L,5, TimeUnit.SECONDS);
|
|
|
+ LambdaQueryWrapper<UserStudyRecord> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(UserStudyRecord::getOrderGoodsId, userStudyRecord.getOrderGoodsId());
|
|
|
+ lqw.eq(UserStudyRecord::getGradeId, userStudyRecord.getGradeId());
|
|
|
+ lqw.eq(UserStudyRecord::getModuleId, userStudyRecord.getModuleId());
|
|
|
+ lqw.eq(UserStudyRecord::getCurrentStatus, 1);
|
|
|
+ List<UserStudyRecord> list = this.list(lqw);
|
|
|
+ for(UserStudyRecord vo : list){
|
|
|
+ UserStudyRecord copyVo = BeanUtil.toBean(vo, UserStudyRecord.class);
|
|
|
+ copyVo.setOrderGoodsId(newOrderGoods.getOrderGoodsId());
|
|
|
+ copyVo.setGradeId(newOrderGoods.getGradeId());
|
|
|
+ copyVo.setGoodsId(newOrderGoods.getGoodsId());
|
|
|
+ copyVo.setCourseId(courseId);
|
|
|
+ copyVo.setRecordId(null);
|
|
|
+ this.save(copyVo);
|
|
|
+ Long periodId = null;
|
|
|
+ UserPeriod copyUserPeriod = baseMapper.selectSevenUserPeriod(copyVo);
|
|
|
+ UserPeriodStatus copyUserPeriodStatus;
|
|
|
+ UserPeriod userPeriod = baseMapper.selectSevenUserPeriod(vo);
|
|
|
+ if(Validator.isEmpty(userPeriod)){
|
|
|
+ throw new CustomException("学时数据错误");
|
|
|
+ }
|
|
|
+ UserPeriodStatus userPeriodStatus = iUserPeriodStatusService.getOne(new LambdaQueryWrapper<UserPeriodStatus>()
|
|
|
+ .eq(UserPeriodStatus::getPeriodId, userPeriod.getId())
|
|
|
+ .eq(UserPeriodStatus::getStatus, 1)
|
|
|
+ .eq(UserPeriodStatus::getPeriodStatus, 1));
|
|
|
+ if(Validator.isEmpty(copyUserPeriod)){
|
|
|
+ copyUserPeriod = BeanUtil.toBean(userPeriod, UserPeriod.class);
|
|
|
+ copyUserPeriod.setOrderGoodsId(newOrderGoods.getOrderGoodsId());
|
|
|
+ copyUserPeriod.setGradeId(newOrderGoods.getGradeId());
|
|
|
+ copyUserPeriod.setGoodsId(newOrderGoods.getGoodsId());
|
|
|
+ copyUserPeriod.setCourseId(courseId);
|
|
|
+ copyUserPeriod.setId(null);
|
|
|
+ iUserPeriodService.save(copyUserPeriod);
|
|
|
+
|
|
|
+ copyUserPeriodStatus = BeanUtil.toBean(userPeriodStatus, UserPeriodStatus.class);
|
|
|
+ copyUserPeriodStatus.setPeriodId(copyUserPeriod.getId());
|
|
|
+ copyUserPeriodStatus.setId(null);
|
|
|
+ iUserPeriodStatusService.save(copyUserPeriodStatus);
|
|
|
+ }else{
|
|
|
+ copyUserPeriodStatus = iUserPeriodStatusService.getOne(new LambdaQueryWrapper<UserPeriodStatus>()
|
|
|
+ .eq(UserPeriodStatus::getPeriodId, copyUserPeriod.getId())
|
|
|
+ .eq(UserPeriodStatus::getStatus, 1)
|
|
|
+ .eq(UserPeriodStatus::getPeriodStatus, 1));
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<UserStudyRecordPhoto> lqwPhoto = Wrappers.lambdaQuery();
|
|
|
+ lqwPhoto.eq(UserStudyRecordPhoto::getPeriodId, userPeriodStatus.getId());
|
|
|
+ lqwPhoto.eq(UserStudyRecordPhoto::getRecordId, vo.getRecordId());
|
|
|
+ lqwPhoto.eq(UserStudyRecordPhoto::getStatus, 1);
|
|
|
+ List<UserStudyRecordPhoto> listPhoto = userStudyRecordPhotoService.list(lqwPhoto);
|
|
|
+ for(UserStudyRecordPhoto photo : listPhoto){
|
|
|
+ UserStudyRecordPhoto copyPhoto = BeanUtil.toBean(photo, UserStudyRecordPhoto.class);
|
|
|
+ copyPhoto.setRecordId(copyVo.getRecordId());
|
|
|
+ copyPhoto.setPeriodId(copyUserPeriodStatus.getId());
|
|
|
+ copyPhoto.setId(null);
|
|
|
+ userStudyRecordPhotoService.save(copyPhoto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newOrderGoods.setSevenClassVersion(oldOrderGoods.getSevenClassVersion());
|
|
|
+ newOrderGoods.setSevenClassStatus(2);
|
|
|
+ newOrderGoods.setSevenClassCopy(oldOrderGoods.getOrderGoodsId());
|
|
|
+ newOrderGoods.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iOrderGoodsService.updateById(newOrderGoods);
|
|
|
+ redisCache.deleteObject(key);
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public GoodsSectionNumVo getGoodsSectionNum(SubjectStudyRecordQueryBo queryBo) {
|
|
|
String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|