Commit c9f41961 authored by liuyang's avatar liuyang

修改企业课程领取的BUG

parent ac0fca55
...@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
...@@ -36,6 +37,8 @@ public class OrgUserReceiveRecordService extends ServiceImpl<OrgUserReceiveRecor ...@@ -36,6 +37,8 @@ public class OrgUserReceiveRecordService extends ServiceImpl<OrgUserReceiveRecor
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired @Autowired
private OrgSurplusService orgSurplusService; private OrgSurplusService orgSurplusService;
@Autowired
private UserCourseAuthService userCourseAuthService;
public PageResult<OrgUserReceiveRecordModel> queryPageList(QueryReceiveHistoryModel model) { public PageResult<OrgUserReceiveRecordModel> queryPageList(QueryReceiveHistoryModel model) {
Page page = new Page(model.getPageIndex(),model.getPageSize()); Page page = new Page(model.getPageIndex(),model.getPageSize());
...@@ -62,7 +65,21 @@ public class OrgUserReceiveRecordService extends ServiceImpl<OrgUserReceiveRecor ...@@ -62,7 +65,21 @@ public class OrgUserReceiveRecordService extends ServiceImpl<OrgUserReceiveRecor
} }
saveBatch(poList); saveBatch(poList);
validateAndSave(poList); validateAndSave(poList);
addUserCourseAuth(poList);
} }
/**
* 分配企业课程时,添加用户课程授权记录
* @param poList
*/
private void addUserCourseAuth(List<OrgUserReceiveRecordPO> poList) {
for (OrgUserReceiveRecordPO po : poList){
if (po.getProductType() == ProductTypeEnum.ENTERPRISE_COURSE_BUY){
userCourseAuthService.updateAuth(po.getUserId(),po.getCourseId(), LocalDateTime.now());
}
}
}
public synchronized void validateAndSave(List<OrgUserReceiveRecordPO> poList){ public synchronized void validateAndSave(List<OrgUserReceiveRecordPO> poList){
for (OrgUserReceiveRecordPO po : poList){ for (OrgUserReceiveRecordPO po : poList){
OrgSurplusPO orgSurplusPO = null; OrgSurplusPO orgSurplusPO = null;
......
...@@ -285,6 +285,8 @@ public class SysUserService extends BaseServiceImpl<SysUserMapper, SysUserPO> { ...@@ -285,6 +285,8 @@ public class SysUserService extends BaseServiceImpl<SysUserMapper, SysUserPO> {
orgUserReceiveRecordPO.setCount(1); orgUserReceiveRecordPO.setCount(1);
orgUserReceiveRecordPO.setProductType(ProductTypeEnum.ENTERPRISE_COURSE_BUY); orgUserReceiveRecordPO.setProductType(ProductTypeEnum.ENTERPRISE_COURSE_BUY);
orgUserReceiveRecordService.validateAndSave(Lists.newArrayList(orgUserReceiveRecordPO)); orgUserReceiveRecordService.validateAndSave(Lists.newArrayList(orgUserReceiveRecordPO));
//添加课程授权
userCourseAuthService.updateAuth(userInfo.getId(),courseId,LocalDateTime.now());
} }
/** /**
......
...@@ -91,7 +91,7 @@ public class UserCenterService { ...@@ -91,7 +91,7 @@ public class UserCenterService {
}else if (course.getChargeModel() == CourseChargeModelEnum.PAY){ }else if (course.getChargeModel() == CourseChargeModelEnum.PAY){
UserCourseAuthPO authPO = userCourseAuthService.getOne(Wrappers.<UserCourseAuthPO>lambdaQuery().eq(UserCourseAuthPO::getUserId,userId).eq(UserCourseAuthPO::getCourseId,courseId)); UserCourseAuthPO authPO = userCourseAuthService.getByUserIdAndCourseId(userId,courseId);
if (authPO == null){ if (authPO == null){
throw new BusinessException("当前课程为付费课程,请购买后再观看"); throw new BusinessException("当前课程为付费课程,请购买后再观看");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment