yangdamao 2 年之前
父节点
当前提交
c46be7121d

+ 4 - 3
zhongzheng-api/src/main/java/com/zhongzheng/controller/course/CourseController.java

@@ -69,9 +69,10 @@ public class CourseController extends BaseController {
     public TableDataInfo<GoodsUserVo> goodsList(CourseQueryBo bo) {
         ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
         bo.setUserId(loginUser.getUser().getUserId());
-        startPage();
-        List<GoodsUserVo> list = iCourseService.goodsList(bo);
-        return getDataTable(list);
+//        startPage();
+//        List<GoodsUserVo> list = iCourseService.goodsList(bo);
+//        return getDataTable(list);
+        return iCourseService.goodsListPage(bo);
     }
 
     /**

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/bo/CourseQueryBo.java

@@ -138,5 +138,7 @@ public class CourseQueryBo extends BaseEntity {
 	private String realname;
 
 	@ApiModelProperty("查询标识:1 PC学习列表")
-		private Integer querySign;
+	private Integer querySign;
+
+	private List<Long> orderGoodsIds;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMapper.java

@@ -3,6 +3,7 @@ package com.zhongzheng.modules.course.mapper;
 
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.github.pagehelper.Page;
 import com.zhongzheng.modules.course.bo.CourseQueryBo;
 import com.zhongzheng.modules.course.domain.Course;
 import com.zhongzheng.modules.course.vo.CourseUserVo;
@@ -73,4 +74,5 @@ public interface CourseMapper extends BaseMapper<Course> {
 
     Long getSpecialQuestionCount(SpecialQuestionBo bo);
 
+    List<Long> getOrderGoodsIds(CourseQueryBo bo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseService.java

@@ -76,6 +76,8 @@ public interface ICourseService extends IService<Course> {
 
     List<GoodsUserVo> goodsList(CourseQueryBo bo);
 
+	TableDataInfo<GoodsUserVo> goodsListPage(CourseQueryBo bo);
+
 	List<GoodsUserVo> goodsStudyProgressList(CourseQueryBo bo);
 
 	List<GoodsUserVo> goodsHandoutsList(CourseQueryBo bo);

+ 216 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -11,6 +11,9 @@ 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.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
@@ -668,6 +671,219 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
         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())){
+            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>()
+                                    .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);
+                    }
+                }
+            }
+
+            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);

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/vo/GoodsUserVo.java

@@ -139,6 +139,7 @@ public class GoodsUserVo {
 	private String code;
 	@ApiModelProperty("创建时间")
 	private Long createTime;
+	private Long ogCreateTime;
 	@ApiModelProperty("更新试卷")
 	private Long updateTime;
 	@ApiModelProperty("供应方名称")

+ 56 - 28
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -200,6 +200,7 @@
         <result property="profileTpStatus" column="profile_tp_status"/>
         <result property="sevenYear" column="seven_year"/>
         <result property="orderYear" column="order_year"/>
+        <result property="ogCreateTime" column="og_create_time"/>
 
         <result property="subExamStatus" column="sub_exam_status"/>
         <result property="subPerformance" column="sub_performance"/>
@@ -531,6 +532,7 @@
         og.grade_id,
         og.service_start_time,
         og.service_end_time,
+        og.create_time as og_create_time,
         og.seven_year as order_year,
         cb.goods_learning_order,
         (SELECT cet.education_name FROM  course_education_type cet  where cet.id = g.education_type_id) as education_name,
@@ -574,35 +576,12 @@
         AND og.refund_status in (0,3)
         AND og.pay_status in (2,3,4)
         AND g.goods_type =1
-        <if test="pageNum == null">
-            and (SELECT count(*) from class_grade cg where (cg.class_end_time >  unix_timestamp(now()) or ISNULL(cg.class_end_time)) and cg.grade_id = og.grade_id ) >0
-        </if>
-        <if test="userId != null and userId != ''">
-            and o.user_id = #{userId}
-        </if>
-        <if test="educationTypeId != null and educationTypeId != ''">
-            AND g.education_type_id = #{educationTypeId}
-        </if>
-        <if test="businessId != null and businessId != ''">
-            AND g.business_id = #{businessId}
-        </if>
-        <if test="orderGoodsId != null and orderGoodsId != ''">
-            AND og.order_goods_id = #{orderGoodsId}
-        </if>
-        <if test="goodsId != null and goodsId != ''">
-            AND og.goods_id = #{goodsId}
-        </if>
-        <if test="studyStatus != null and studyStatus == 3">
-            and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status != -1) >0
-        </if>
-        <if test="studyStatus != null and studyStatus == 2">
-            and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status = -1) >0
-            and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) >0
-        </if>
-        <if test="studyStatus != null and studyStatus == 1">
-            and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) =0
+        <if test="orderGoodsIds != null and orderGoodsIds.size()!=0 ">
+            AND og.order_goods_id in
+            <foreach collection="orderGoodsIds" item="item" index="index" open="(" close=")" separator=",">
+                #{item}
+            </foreach>
         </if>
-        order by og.create_time desc
     </select>
 
     <select id="goodsStudyProgressList" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo"  resultMap="GoodsUserVo">
@@ -965,4 +944,53 @@
             AND g.question_merchant_id = #{questionMerchantId}
         </if>
     </select>
+
+    <select id="getOrderGoodsIds" parameterType="com.zhongzheng.modules.course.bo.CourseQueryBo" resultType="java.lang.Long">
+        SELECT
+            og.order_goods_id
+        FROM
+        `order` o
+        LEFT JOIN order_goods og ON og.order_sn = o.order_sn
+        LEFT JOIN goods g on og.goods_id = g.goods_id
+        LEFT JOIN course_business cb on g.business_id = cb.id
+        <if test="userId != null and userId != ''">
+            LEFT JOIN (SELECT * from  user_subscribe where subscribe_id in (SELECT MAX(subscribe_id) from user_subscribe where user_id = #{userId} and  subscribe_status = 1 GROUP BY order_goods_id)) us on us.order_goods_id = og.order_goods_id
+        </if>
+        where 1=1
+        AND og.`status` = 1
+        --         AND og.refund_status in (0,1,3)
+        AND og.refund_status in (0,3)
+        AND og.pay_status in (2,3,4)
+        AND g.goods_type =1
+        <if test="pageNum == null">
+            and (SELECT count(*) from class_grade cg where (cg.class_end_time >  unix_timestamp(now()) or ISNULL(cg.class_end_time)) and cg.grade_id = og.grade_id ) >0
+        </if>
+        <if test="userId != null and userId != ''">
+            and o.user_id = #{userId}
+        </if>
+        <if test="educationTypeId != null and educationTypeId != ''">
+            AND g.education_type_id = #{educationTypeId}
+        </if>
+        <if test="businessId != null and businessId != ''">
+            AND g.business_id = #{businessId}
+        </if>
+        <if test="orderGoodsId != null and orderGoodsId != ''">
+            AND og.order_goods_id = #{orderGoodsId}
+        </if>
+        <if test="goodsId != null and goodsId != ''">
+            AND og.goods_id = #{goodsId}
+        </if>
+        <if test="studyStatus != null and studyStatus == 3">
+            and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status != -1) >0
+        </if>
+        <if test="studyStatus != null and studyStatus == 2">
+            and (SELECT count(*) from class_grade_user cgu where cgu.user_id = o.user_id and cgu.grade_id = og.grade_id and cgu.period_status = -1) >0
+            and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) >0
+        </if>
+        <if test="studyStatus != null and studyStatus == 1">
+            and (SELECT count(*) from user_study_record usr where usr.user_id = o.user_id and usr.order_goods_id = og.order_goods_id ) =0
+        </if>
+        order by og.create_time desc
+    </select>
+
 </mapper>