|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
@@ -11,10 +12,20 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.google.zxing.BarcodeFormat;
|
|
|
+import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
+import com.google.zxing.common.BitMatrix;
|
|
|
+import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
+import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
+import com.zhongzheng.common.type.EncryptHandler;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.modules.base.domain.UserProfile;
|
|
|
+import com.zhongzheng.modules.base.service.IUserProfileService;
|
|
|
import com.zhongzheng.modules.course.bo.CourseAddBo;
|
|
|
import com.zhongzheng.modules.course.bo.CourseEditBo;
|
|
|
import com.zhongzheng.modules.course.bo.CourseQueryBo;
|
|
@@ -30,44 +41,50 @@ import com.zhongzheng.modules.exam.domain.*;
|
|
|
import com.zhongzheng.modules.exam.service.*;
|
|
|
import com.zhongzheng.modules.exam.vo.ExamApplyGoodsVo;
|
|
|
import com.zhongzheng.modules.goods.bo.GoodsBatchDelBo;
|
|
|
+import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsCourse;
|
|
|
+import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
|
|
|
+import com.zhongzheng.modules.goods.domain.QuestionMerchant;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsCourseService;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
+import com.zhongzheng.modules.goods.service.IQuestionMerchantService;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsPeriodStatusVo;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsPeriodVo;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsSectionNumVo;
|
|
|
import com.zhongzheng.modules.goods.vo.GoodsUserVo;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
|
import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
|
|
|
import com.zhongzheng.modules.grade.bo.UserPeriodStatusAddBo;
|
|
|
+import com.zhongzheng.modules.grade.domain.UserPeriod;
|
|
|
import com.zhongzheng.modules.grade.domain.UserPeriodStatus;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodService;
|
|
|
import com.zhongzheng.modules.grade.service.IUserPeriodStatusService;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeVo;
|
|
|
import com.zhongzheng.modules.grade.vo.UserPeriodVo;
|
|
|
+import com.zhongzheng.modules.order.bo.SpecialQuestionBo;
|
|
|
+import com.zhongzheng.modules.order.vo.SpecialQuestionVo;
|
|
|
import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
+import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
+import com.zhongzheng.modules.user.bo.UserPhoneBo;
|
|
|
import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
|
|
|
-import com.zhongzheng.modules.user.domain.UserBankRecord;
|
|
|
-import com.zhongzheng.modules.user.domain.UserStudyRecord;
|
|
|
-import com.zhongzheng.modules.user.domain.UserStudyRecordPhoto;
|
|
|
-import com.zhongzheng.modules.user.domain.UserSubscribe;
|
|
|
-import com.zhongzheng.modules.user.service.IUserBankRecordService;
|
|
|
-import com.zhongzheng.modules.user.service.IUserStudyRecordPhotoService;
|
|
|
-import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
-import com.zhongzheng.modules.user.service.IUserSubscribeService;
|
|
|
+import com.zhongzheng.modules.user.domain.*;
|
|
|
+import com.zhongzheng.modules.user.service.*;
|
|
|
import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
|
|
|
import com.zhongzheng.modules.user.vo.UserStudyRecordPhotoVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -128,8 +145,24 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
@Autowired
|
|
|
private IUserSubscribeService iUserSubscribeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserProfileService iUserProfileService;
|
|
|
+ @Autowired
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
+ @Autowired
|
|
|
+ private IGoodsQuestionRelService iGoodsQuestionRelService;
|
|
|
+ @Autowired
|
|
|
+ private IQuestionMerchantService iQuestionMerchantService;
|
|
|
+ @Autowired
|
|
|
+ private ISysTenantService iSysTenantService;
|
|
|
+ @Autowired
|
|
|
+ private IUserService iUserService;
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
+ @Value("${liveGotoURL}")
|
|
|
+ private String URL_PREFIX;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public CourseVo queryById(Long courseId){
|
|
@@ -469,9 +502,21 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
}
|
|
|
String fullName = goodsUserVo.getEducationName()+goodsUserVo.getBusinessName()+goodsUserVo.getProjectName();
|
|
|
goodsUserVo.setErJianErZao(false);
|
|
|
+ goodsUserVo.setUserProfile(0);
|
|
|
if(Validator.isNotEmpty(fullName)){
|
|
|
if(fullName.equals("继续教育二级建造师")||fullName.equals("继续教育二级造价师")){
|
|
|
goodsUserVo.setErJianErZao(true);
|
|
|
+ }else if (goodsUserVo.getEducationName().equals("考前培训") && goodsUserVo.getProjectName().equals("施工现场专业人员")){
|
|
|
+ //七大员新考 判断是否提交学员资料
|
|
|
+ int count = iUserProfileService.count(new LambdaQueryWrapper<UserProfile>()
|
|
|
+ .notIn(UserProfile::getStatus, Arrays.asList(3, -1))
|
|
|
+ .eq(UserProfile::getUserId, goodsUserVo.getUserId())
|
|
|
+ .eq(UserProfile::getGoodsId, goodsUserVo.getGoodsId())
|
|
|
+// .eq(UserProfile::getCurrentStatus, 1)
|
|
|
+ );
|
|
|
+ if (count > 0){
|
|
|
+ goodsUserVo.setUserProfile(1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -493,6 +538,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
goodsUserVo.setPeriodPlush(classGradeVo.getPeriodPlush());
|
|
|
goodsUserVo.setOfficialName(classGradeVo.getOfficialName());
|
|
|
goodsUserVo.setPeriodWaitTime(classGradeVo.getPeriodWaitTime());
|
|
|
+ goodsUserVo.setOpenQuestion(0);
|
|
|
Long secLong = 0L;
|
|
|
Long studyLong = 0L;
|
|
|
SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
|
|
@@ -500,10 +546,15 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
subjectStudyRecordQueryBo.setUserId(bo.getUserId());
|
|
|
subjectStudyRecordQueryBo.setGradeId(goodsUserVo.getGradeId());
|
|
|
subjectStudyRecordQueryBo.setOrderGoodsId(goodsUserVo.getOrderGoodsId());
|
|
|
- List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
|
|
|
- for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
|
|
|
- secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
|
|
|
- studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
|
|
|
+// List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
|
|
|
+// for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
|
|
|
+// secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
|
|
|
+// studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
|
|
|
+// }
|
|
|
+ GoodsSectionNumVo vo = iUserStudyRecordService.getGoodsSectionNum(subjectStudyRecordQueryBo);
|
|
|
+ if (ObjectUtils.isNotNull(vo)){
|
|
|
+ secLong = vo.getSectionNum();
|
|
|
+ studyLong = vo.getRecordNum();
|
|
|
}
|
|
|
goodsUserVo.setSecAllNum(secLong);
|
|
|
goodsUserVo.setStuAllNum(studyLong);
|
|
@@ -519,13 +570,15 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
&& (DateUtils.getNowTime() >= goodsUserVo.getServiceStartTime() && DateUtils.getNowTime() <= goodsUserVo.getServiceEndTime())){
|
|
|
UserSubscribe userSubscribe = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
.eq(UserSubscribe::getUserId, bo.getUserId())
|
|
|
- .eq(UserSubscribe::getGoodsId, goodsUserVo.getGoodsId())
|
|
|
+ .eq(UserSubscribe::getOrderGoodsId, goodsUserVo.getOrderGoodsId())
|
|
|
.eq(UserSubscribe::getSubscribeStatus, 1)
|
|
|
.orderByDesc(UserSubscribe::getCreateTime)
|
|
|
.last("limit 1"));
|
|
|
if (ObjectUtils.isNull(userSubscribe)){
|
|
|
goodsUserVo.setSubscribeSign(1);
|
|
|
- }else if (ObjectUtils.isNotNull(userSubscribe.getResult()) && userSubscribe.getResult() == 0){
|
|
|
+ }else if (userSubscribe.getSubscribeStatus() == 1 && userSubscribe.getExamStatus() == 0){
|
|
|
+ goodsUserVo.setSubscribeSign(4);
|
|
|
+ } else if (ObjectUtils.isNotNull(userSubscribe.getResult()) && userSubscribe.getResult() == 0){
|
|
|
goodsUserVo.setSubscribeSign(3);
|
|
|
}
|
|
|
}
|
|
@@ -545,6 +598,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
String format = String.format("%s-%s", twoAddBo.getStartTime(), twoAddBo.getEndTime());
|
|
|
examApplyGoodsVo.setApplyTime(time);
|
|
|
examApplyGoodsVo.setApplyMoment(format);
|
|
|
+ examApplyGoodsVo.setApplyNum(twoAddBo.getNum().intValue());
|
|
|
+ //预约人数
|
|
|
+ int count = iUserSubscribeService.count(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus, 1)
|
|
|
+ .eq(UserSubscribe::getExamStatus, 0)
|
|
|
+ .eq(UserSubscribe::getApplyId, examApplyGoodsVo.getApplyId()));
|
|
|
+ examApplyGoodsVo.setSubscribeNum(count);
|
|
|
}
|
|
|
}
|
|
|
switch (examApply.getApplyNature()){
|
|
@@ -599,10 +659,261 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //预约考试是否可以购买题库(该商品没有关联题库且预约考试的时间提前8天)
|
|
|
+ UserSubscribe userSubscribeTwo = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getOrderGoodsId,goodsUserVo.getOrderGoodsId())
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus,1)
|
|
|
+ .eq(UserSubscribe::getExamStatus,0)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(userSubscribeTwo)){
|
|
|
+ Goods goods = iGoodsService.getById(goodsUserVo.getGoodsId());
|
|
|
+ if (ObjectUtils.isNull(goods.getQuestionGoodsId())){
|
|
|
+ //没有关联题库 是否购买过题库
|
|
|
+ int count = iGoodsQuestionRelService.count(new LambdaQueryWrapper<GoodsQuestionRel>()
|
|
|
+ .eq(GoodsQuestionRel::getOrderGoodsId, userSubscribeTwo.getOrderGoodsId())
|
|
|
+ .gt(GoodsQuestionRel::getQuestionDoNum, 0));
|
|
|
+ if (count <= 0){
|
|
|
+ //考试时间往前推8天
|
|
|
+ Long appointTime = DateUtils.getDayBefore(userSubscribeTwo.getApplySiteExamTime(), 8);
|
|
|
+ if (DateUtils.getNowTime() < appointTime){
|
|
|
+ goodsUserVo.setOpenQuestion(1);
|
|
|
+ //获取默认题库商家商品
|
|
|
+ QuestionMerchant one = iQuestionMerchantService.getOne(new LambdaQueryWrapper<QuestionMerchant>()
|
|
|
+ .eq(QuestionMerchant::getSign, 1)
|
|
|
+ .eq(QuestionMerchant::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(one)){
|
|
|
+ Goods goodsOne = iGoodsService.getOne(new LambdaQueryWrapper<Goods>()
|
|
|
+ .eq(Goods::getQuestionMerchantId, one.getMerchantId())
|
|
|
+ .eq(Goods::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(goodsOne)){
|
|
|
+ goodsUserVo.setQuestionGoodsId(goodsOne.getGoodsId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return goodsUserVos;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<GoodsUserVo> goodsListPage(CourseQueryBo bo) {
|
|
|
+ TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
+ PageHelper.startPage(bo.getPageNum(), bo.getPageSize());
|
|
|
+ List<Long> page = baseMapper.getOrderGoodsIds(bo);
|
|
|
+ PageInfo<Long> pageInfo = new PageInfo<Long>(page);
|
|
|
+ if (CollectionUtils.isEmpty(pageInfo.getList())){
|
|
|
+ tableDataInfo.setTotal(0L);
|
|
|
+ tableDataInfo.setRows(new ArrayList());
|
|
|
+ return tableDataInfo;
|
|
|
+ }
|
|
|
+ tableDataInfo.setTotal(pageInfo.getTotal());
|
|
|
+ bo.setOrderGoodsIds(pageInfo.getList());
|
|
|
+ List<GoodsUserVo> goodsUserVos = baseMapper.goodsList(bo);
|
|
|
+ //用户课程得详细信息
|
|
|
+ for (GoodsUserVo goodsUserVo : goodsUserVos) {
|
|
|
+ //获得当前所在班级
|
|
|
+ ClassGradeVo classGradeVo = baseMapper.gradeIdSelect(goodsUserVo.getUserId(),goodsUserVo.getGoodsId(),goodsUserVo.getGradeId(),goodsUserVo.getOrderGoodsId());
|
|
|
+ if(Validator.isEmpty(classGradeVo)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String fullName = goodsUserVo.getEducationName()+goodsUserVo.getBusinessName()+goodsUserVo.getProjectName();
|
|
|
+ goodsUserVo.setErJianErZao(false);
|
|
|
+ goodsUserVo.setUserProfile(0);
|
|
|
+ if(Validator.isNotEmpty(fullName)){
|
|
|
+ if(fullName.equals("继续教育二级建造师")||fullName.equals("继续教育二级造价师")){
|
|
|
+ goodsUserVo.setErJianErZao(true);
|
|
|
+ }else if (goodsUserVo.getEducationName().equals("考前培训") && goodsUserVo.getProjectName().equals("施工现场专业人员")){
|
|
|
+ int count = iUserProfileService.count(new LambdaQueryWrapper<UserProfile>()
|
|
|
+ .ne(UserProfile::getStatus,-1)
|
|
|
+ .eq(UserProfile::getUserId, goodsUserVo.getUserId())
|
|
|
+ .eq(UserProfile::getOrderGoodsId, goodsUserVo.getOrderGoodsId())
|
|
|
+ .eq(UserProfile::getCurrentStatus, 1)
|
|
|
+ );
|
|
|
+ if (count > 0){
|
|
|
+ goodsUserVo.setUserProfile(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsUserVo.setGradeId(classGradeVo.getGradeId());
|
|
|
+ goodsUserVo.setLearningStatus(classGradeVo.getLearningStatus());
|
|
|
+ goodsUserVo.setLearningTimeStart(classGradeVo.getLearningTimeStart());
|
|
|
+ goodsUserVo.setGradeStatus(classGradeVo.getStatus());
|
|
|
+ goodsUserVo.setClassStartTime(classGradeVo.getClassStartTime());
|
|
|
+ goodsUserVo.setClassEndTime(classGradeVo.getClassEndTime());
|
|
|
+ goodsUserVo.setPeriodStatus(classGradeVo.getPeriodStatus());
|
|
|
+ goodsUserVo.setClassStatus(classGradeVo.getClassStatus());
|
|
|
+ goodsUserVo.setRecordNum(classGradeVo.getRecordNum());
|
|
|
+ goodsUserVo.setExamNum(classGradeVo.getExamNum());
|
|
|
+ goodsUserVo.setInterfaceAccountId(classGradeVo.getInterfaceAccountId());
|
|
|
+ goodsUserVo.setInterfacePushId(classGradeVo.getInterfacePushId());
|
|
|
+ goodsUserVo.setOfficialLearningUrl(classGradeVo.getOfficialLearningUrl());
|
|
|
+ goodsUserVo.setOfficialStatus(classGradeVo.getOfficialStatus());
|
|
|
+ goodsUserVo.setLearnStatus(classGradeVo.getLearnStatus());
|
|
|
+ goodsUserVo.setPeriodPlush(classGradeVo.getPeriodPlush());
|
|
|
+ goodsUserVo.setOfficialName(classGradeVo.getOfficialName());
|
|
|
+ goodsUserVo.setPeriodWaitTime(classGradeVo.getPeriodWaitTime());
|
|
|
+ goodsUserVo.setOpenQuestion(0);
|
|
|
+ Long secLong = 0L;
|
|
|
+ Long studyLong = 0L;
|
|
|
+ SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
|
|
|
+ subjectStudyRecordQueryBo.setGoodsId(goodsUserVo.getGoodsId());
|
|
|
+ subjectStudyRecordQueryBo.setUserId(bo.getUserId());
|
|
|
+ subjectStudyRecordQueryBo.setGradeId(goodsUserVo.getGradeId());
|
|
|
+ subjectStudyRecordQueryBo.setOrderGoodsId(goodsUserVo.getOrderGoodsId());
|
|
|
+// List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listSubject(subjectStudyRecordQueryBo);
|
|
|
+// for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
|
|
|
+// secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
|
|
|
+// studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
|
|
|
+// }
|
|
|
+ GoodsSectionNumVo vo = iUserStudyRecordService.getGoodsSectionNum(subjectStudyRecordQueryBo);
|
|
|
+ if (ObjectUtils.isNotNull(vo)){
|
|
|
+ secLong = vo.getSectionNum();
|
|
|
+ studyLong = vo.getRecordNum();
|
|
|
+ }
|
|
|
+ goodsUserVo.setSecAllNum(secLong);
|
|
|
+ goodsUserVo.setStuAllNum(studyLong);
|
|
|
+ goodsUserVo.setSubscribeSign(2);
|
|
|
+
|
|
|
+
|
|
|
+ //查询对应考试安排
|
|
|
+ List<ExamApplyGoodsVo> examApplyGoodsVoList = iExamApplyGoodsService.listByGoodsId(goodsUserVo.getGoodsId());
|
|
|
+ if (examApplyGoodsVoList != null && examApplyGoodsVoList.size() > 0) {
|
|
|
+ //是否满足预约考试条件
|
|
|
+ if (ObjectUtils.isNotNull(classGradeVo.getPeriodStatus())
|
|
|
+ && classGradeVo.getPeriodStatus() == 1
|
|
|
+ && (DateUtils.getNowTime() >= goodsUserVo.getServiceStartTime() && DateUtils.getNowTime() <= goodsUserVo.getServiceEndTime())){
|
|
|
+ UserSubscribe userSubscribe = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getUserId, bo.getUserId())
|
|
|
+ .eq(UserSubscribe::getGoodsId, goodsUserVo.getGoodsId())
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus, 1)
|
|
|
+ .orderByDesc(UserSubscribe::getCreateTime)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNull(userSubscribe)){
|
|
|
+ goodsUserVo.setSubscribeSign(1);
|
|
|
+ }else if (ObjectUtils.isNotNull(userSubscribe.getResult()) && userSubscribe.getResult() == 0){
|
|
|
+ goodsUserVo.setSubscribeSign(3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ExamApplyGoodsVo> examApplyGoodsVos = new ArrayList<>();
|
|
|
+ List<ExamApplyGoodsVo> examApplyGoodsVos2 = new ArrayList<>();
|
|
|
+ examApplyGoodsVoList.forEach(examApplyGoodsVo -> {
|
|
|
+ ExamApply examApply = iExamApplyService.getById(examApplyGoodsVo.getApplyId());
|
|
|
+ List<ExamApplySiteTime> siteTimes = iExamApplySiteTimeService.list(new LambdaQueryWrapper<ExamApplySiteTime>()
|
|
|
+ .eq(ExamApplySiteTime::getApplyId, examApplyGoodsVo.getApplyId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(siteTimes)){
|
|
|
+ ExamApplySiteTime timeTime = siteTimes.get(0);
|
|
|
+ List<ExamApplySiteTimeTwoAddBo> siteTimeTwoAddBos = JSONArray.parseArray(timeTime.getSiteTime(), ExamApplySiteTimeTwoAddBo.class);
|
|
|
+ ExamApplySiteTimeTwoAddBo twoAddBo = siteTimeTwoAddBos.get(0);
|
|
|
+ if (ObjectUtils.isNotNull(twoAddBo)){
|
|
|
+ Long time = timeTime.getExamTime()+28800L;
|
|
|
+ String format = String.format("%s-%s", twoAddBo.getStartTime(), twoAddBo.getEndTime());
|
|
|
+ examApplyGoodsVo.setApplyTime(time);
|
|
|
+ examApplyGoodsVo.setApplyMoment(format);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ switch (examApply.getApplyNature()){
|
|
|
+ case 1: //普通场
|
|
|
+ LambdaQueryWrapper<ExamApplyUser> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(ExamApplyUser::getApplyId, examApplyGoodsVo.getApplyId());
|
|
|
+ List<ExamApplyUser> examApplyUserList = iExamApplyUserService.list(lqw);
|
|
|
+ if (examApplyUserList != null && examApplyUserList.size() > 0) {
|
|
|
+ ArrayList<Long> userIds = new ArrayList<>();
|
|
|
+ examApplyUserList.forEach(examApplyUser -> {
|
|
|
+ userIds.add(examApplyUser.getUserId());
|
|
|
+ });
|
|
|
+ if (userIds.contains(bo.getUserId())) {
|
|
|
+ examApplyGoodsVos.add(examApplyGoodsVo);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ examApplyGoodsVos2.add(examApplyGoodsVo);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2://专场
|
|
|
+ List<ExamApplyUser> applyUsers = iExamApplyUserService
|
|
|
+ .list(new LambdaQueryWrapper<ExamApplyUser>().eq(ExamApplyUser::getApplyId, examApply.getApplyId()));
|
|
|
+ if (CollectionUtils.isNotEmpty(applyUsers) &&
|
|
|
+ applyUsers.stream().anyMatch(x -> x.getUserId().equals(bo.getUserId()))){
|
|
|
+ examApplyGoodsVos.add(examApplyGoodsVo);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ examApplyGoodsVos.addAll(examApplyGoodsVos2);
|
|
|
+ goodsUserVo.setExamApplyGoodsList(examApplyGoodsVos);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<UserSubscribe> lq = Wrappers.lambdaQuery();
|
|
|
+ lq.eq(UserSubscribe::getOrderGoodsId, goodsUserVo.getOrderGoodsId());
|
|
|
+ lq.eq(UserSubscribe::getSubscribeStatus, 1);
|
|
|
+ lq.eq(UserSubscribe::getBeforeStatus, 1);
|
|
|
+ lq.last("limit 1");
|
|
|
+ UserSubscribe userSubscribe = iUserSubscribeService.getOne(lq);
|
|
|
+ if (userSubscribe != null) {
|
|
|
+ LambdaQueryWrapper<ExamBefore> lqw1 = Wrappers.lambdaQuery();
|
|
|
+ lqw1.eq(ExamBefore::getBeforeId, userSubscribe.getBeforeId());
|
|
|
+ lqw1.eq(ExamBefore::getStatus, 1);
|
|
|
+ ExamBefore examBefore = iExamBeforeService.getOne(lqw1);
|
|
|
+ if (examBefore != null) {
|
|
|
+ if ((System.currentTimeMillis()/1000) > examBefore.getBeforeStartTime().longValue() && (System.currentTimeMillis()/1000) < examBefore.getBeforeEndTime().longValue()) {
|
|
|
+ goodsUserVo.setBeforeStatus(1L);
|
|
|
+ goodsUserVo.setBeforeName(examBefore.getBeforeName());
|
|
|
+ goodsUserVo.setBeforeStartTime(examBefore.getBeforeStartTime());
|
|
|
+ goodsUserVo.setBeforeEndTime(examBefore.getBeforeEndTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //预约考试是否可以购买题库(该商品没有关联题库且预约考试的时间提前8天)
|
|
|
+ UserSubscribe userSubscribeTwo = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
|
|
|
+ .eq(UserSubscribe::getOrderGoodsId,goodsUserVo.getOrderGoodsId())
|
|
|
+ .eq(UserSubscribe::getSubscribeStatus,1)
|
|
|
+ .eq(UserSubscribe::getExamStatus,0)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(userSubscribeTwo)){
|
|
|
+ Goods goods = iGoodsService.getById(goodsUserVo.getGoodsId());
|
|
|
+ if (ObjectUtils.isNull(goods.getQuestionGoodsId())){
|
|
|
+ //没有关联题库 是否购买过题库
|
|
|
+ int count = iGoodsQuestionRelService.count(new LambdaQueryWrapper<GoodsQuestionRel>()
|
|
|
+ .eq(GoodsQuestionRel::getOrderGoodsId, userSubscribeTwo.getOrderGoodsId())
|
|
|
+ .gt(GoodsQuestionRel::getQuestionDoNum, 0));
|
|
|
+ if (count <= 0){
|
|
|
+ //考试时间往前推8天
|
|
|
+ Long appointTime = DateUtils.getDayBefore(userSubscribeTwo.getApplySiteExamTime(), 8);
|
|
|
+ if (DateUtils.getNowTime() < appointTime){
|
|
|
+ goodsUserVo.setOpenQuestion(1);
|
|
|
+ //获取默认题库商家商品
|
|
|
+ QuestionMerchant one = iQuestionMerchantService.getOne(new LambdaQueryWrapper<QuestionMerchant>()
|
|
|
+ .eq(QuestionMerchant::getSign, 1)
|
|
|
+ .eq(QuestionMerchant::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(one)){
|
|
|
+ Goods goodsOne = iGoodsService.getOne(new LambdaQueryWrapper<Goods>()
|
|
|
+ .eq(Goods::getQuestionMerchantId, one.getMerchantId())
|
|
|
+ .eq(Goods::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(goodsOne)){
|
|
|
+ goodsUserVo.setQuestionGoodsId(goodsOne.getGoodsId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ tableDataInfo.setRows(goodsUserVos.stream().sorted(Comparator.comparing(GoodsUserVo::getOgCreateTime).reversed()).collect(Collectors.toList()));
|
|
|
+ return tableDataInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public List<GoodsUserVo> goodsStudyProgressList(CourseQueryBo bo) {
|
|
|
List<GoodsUserVo> goodsUserVos = baseMapper.goodsStudyProgressList(bo);
|
|
@@ -719,6 +1030,68 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
|
|
|
return aLong;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<SpecialQuestionVo> getSpecialQuestionList(SpecialQuestionBo bo) {
|
|
|
+ List<SpecialQuestionVo> specialQuestionList = baseMapper.getSpecialQuestionList(bo);
|
|
|
+ if (CollectionUtils.isEmpty(specialQuestionList)){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ specialQuestionList.forEach(item -> {
|
|
|
+ GoodsQuestionRel questionRel = iGoodsQuestionRelService
|
|
|
+ .getOne(new LambdaQueryWrapper<GoodsQuestionRel>()
|
|
|
+ .eq(GoodsQuestionRel::getQuestionGoodsId, item.getGoodsId())
|
|
|
+ .eq(GoodsQuestionRel::getQsOrderGoodsId, item.getOrderGoodsId())
|
|
|
+ .gt(GoodsQuestionRel::getQuestionDoNum, 0)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(questionRel)){
|
|
|
+ item.setSubscribeStatus(questionRel.getStatus());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return specialQuestionList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long getSpecialQuestionCount(SpecialQuestionBo bo) {
|
|
|
+ return baseMapper.getSpecialQuestionCount(bo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getSpecialQuestionSkipCode(Long userId) {
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ //缓存用户信息key
|
|
|
+ String key = String.format("KQTZ%s",userId);
|
|
|
+ User user = iUserService.getById(userId);
|
|
|
+ Long tenantId = user.getTenantId();
|
|
|
+ SysTenant sysTenant = iSysTenantService.getById(tenantId);
|
|
|
+ //课程
|
|
|
+ String h5Url = String.format("%s%s/pages/questionBank/index?skipPort=%s&sign=1", URL_PREFIX, sysTenant.getHostH5(),key);
|
|
|
+
|
|
|
+ //跳转H5码
|
|
|
+ try {
|
|
|
+ QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
|
+ BitMatrix bitMatrix = qrCodeWriter.encode(h5Url, BarcodeFormat.QR_CODE, 120, 120);
|
|
|
+ // 写到输出流
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ MatrixToImageWriter.writeToStream(bitMatrix, "jpg", outputStream);
|
|
|
+ //转换为base64
|
|
|
+ Base64.Encoder encoder1 = Base64.getEncoder();
|
|
|
+ String urlBase64 = "data:image/jpeg;base64,"
|
|
|
+ + encoder1.encodeToString(outputStream.toByteArray());
|
|
|
+ map.put("h5Base64",urlBase64);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ UserPhoneBo phoneBo = new UserPhoneBo();
|
|
|
+ phoneBo.setTelphone(EncryptHandler.decrypt(user.getTelphone()));
|
|
|
+ phoneBo.setTenantId(tenantId);
|
|
|
+ phoneBo.setIdNum(EncryptHandler.decrypt(user.getIdCard()));
|
|
|
+
|
|
|
+ //缓存用户信息
|
|
|
+ redisCache.setCacheObjectTenant(tenantId+":"+key, JSONObject.toJSONString(phoneBo), 12, TimeUnit.HOURS);
|
|
|
+
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
private Long liveTime(Long nowTime, Integer day) {
|
|
|
for (Integer i = 0; i < day; i++) {
|
|
|
Long dayAfter = DateUtils.getDayAfter(nowTime, 1);
|