yangdamao 2 жил өмнө
parent
commit
141f8213a5
14 өөрчлөгдсөн 375 нэмэгдсэн , 54 устгасан
  1. 15 0
      zhongzheng-api/src/main/java/com/zhongzheng/controller/course/CourseController.java
  2. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/mapper/CourseMapper.java
  3. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/ICourseService.java
  4. 26 7
      zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java
  5. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/GoodsQuestionRel.java
  6. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/bo/OrderGoodsAddBo.java
  7. 28 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/bo/SpecialQuestionBo.java
  8. 3 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/domain/OrderGoods.java
  9. 52 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderInputServiceImpl.java
  10. 59 8
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java
  11. 59 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/SpecialQuestionVo.java
  12. 40 38
      zhongzheng-system/src/main/java/com/zhongzheng/modules/top/goods/service/impl/TopOldOrderServiceImpl.java
  13. 45 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java
  14. 34 0
      zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

+ 15 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/course/CourseController.java

@@ -9,6 +9,8 @@ import com.zhongzheng.modules.course.bo.*;
 import com.zhongzheng.modules.course.service.*;
 import com.zhongzheng.modules.course.vo.*;
 import com.zhongzheng.modules.goods.vo.GoodsUserVo;
+import com.zhongzheng.modules.order.bo.SpecialQuestionBo;
+import com.zhongzheng.modules.order.vo.SpecialQuestionVo;
 import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -75,6 +77,19 @@ public class CourseController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 查询课程列表
+     */
+    @ApiOperation("查询用户拥有的题库列表(山东题库)")
+    @GetMapping("/special/question/list")
+    public TableDataInfo<SpecialQuestionVo> getSpecialQuestionList(SpecialQuestionBo bo) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        startPage();
+        List<SpecialQuestionVo> list = iCourseService.getSpecialQuestionList(bo);
+        return getDataTable(list);
+    }
+
     @ApiOperation("查询用户拥有的讲义商品")
     @GetMapping("/goodsHandoutsList")
     public TableDataInfo<GoodsUserVo> goodsHandoutsList(CourseQueryBo bo) {

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

@@ -12,6 +12,8 @@ import com.zhongzheng.modules.goods.vo.GoodsPeriodVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
+import com.zhongzheng.modules.order.bo.SpecialQuestionBo;
+import com.zhongzheng.modules.order.vo.SpecialQuestionVo;
 import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
 import org.apache.ibatis.annotations.Param;
 
@@ -66,4 +68,6 @@ public interface CourseMapper extends BaseMapper<Course> {
 
     @InterceptorIgnore(tenantLine = "true")
     Long getCourseByTenantTwo(@Param("courseName") String courseName,@Param("code") String code,@Param("tenantId") Long tenantId);
+
+    List<SpecialQuestionVo> getSpecialQuestionList(SpecialQuestionBo bo);
 }

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

@@ -14,6 +14,8 @@ import com.zhongzheng.modules.goods.vo.GoodsUserVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
 import com.zhongzheng.modules.grade.vo.ClassGradeVo;
+import com.zhongzheng.modules.order.bo.SpecialQuestionBo;
+import com.zhongzheng.modules.order.vo.SpecialQuestionVo;
 import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
 import org.apache.ibatis.annotations.Param;
 
@@ -100,4 +102,6 @@ public interface ICourseService extends IService<Course> {
 
 	Long getLiveTime();
 
+    List<SpecialQuestionVo> getSpecialQuestionList(SpecialQuestionBo bo);
+
 }

+ 26 - 7
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseServiceImpl.java

@@ -33,7 +33,9 @@ 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.service.IGoodsCourseService;
+import com.zhongzheng.modules.goods.service.IGoodsQuestionRelService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsPeriodStatusVo;
 import com.zhongzheng.modules.goods.vo.GoodsPeriodVo;
@@ -48,6 +50,8 @@ 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.user.bo.SubjectStudyRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserPlanQueryBo;
 import com.zhongzheng.modules.user.domain.UserBankRecord;
@@ -131,6 +135,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
     private IUserProfileService iUserProfileService;
     @Autowired
     private IGoodsService iGoodsService;
+    @Autowired
+    private IGoodsQuestionRelService iGoodsQuestionRelService;
+
 
 
 
@@ -603,15 +610,22 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
                     }
                 }
 
-                //预约考试是否可以购买题库(该商品没有关联题库且预约考试的时间提前7个工作日)
+                //预约考试是否可以购买题库(该商品没有关联题库且预约考试的时间提前8天)
                 Goods goods = iGoodsService.getById(goodsUserVo.getGoodsId());
                 if (ObjectUtils.isNull(goods.getQuestionGoodsId())){
-                    //没有关联题库
-                    //考试时间往前推7个工作日
-                    Long appointTime = DateUtils.getAppointTime(userSubscribe.getApplySiteExamTime(), 7);
-                    if (DateUtils.getNowTime() < appointTime){
-                        goodsUserVo.setOpenQuestion(1);
-                        goodsUserVo.setQuestionGoodsId(goods.getQuestionGoodsId());
+                    //没有关联题库 是否购买过题库
+                    int count = iGoodsQuestionRelService.count(new LambdaQueryWrapper<GoodsQuestionRel>()
+                            .eq(GoodsQuestionRel::getOrderGoodsId, userSubscribe.getOrderGoodsId())
+                            .eq(GoodsQuestionRel::getQuestionGoodsId, goods.getQuestionGoodsId())
+                            .eq(GoodsQuestionRel::getStatus, 1)
+                            .gt(GoodsQuestionRel::getQuestionDoNum, 0));
+                    if (count <= 0){
+                        //考试时间往前推8天
+                        Long appointTime = DateUtils.getDayBefore(userSubscribe.getApplySiteExamTime(), 8);
+                        if (DateUtils.getNowTime() < appointTime){
+                            goodsUserVo.setOpenQuestion(1);
+                            goodsUserVo.setQuestionGoodsId(goods.getQuestionGoodsId());
+                        }
                     }
                 }
             }
@@ -734,6 +748,11 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
         return aLong;
     }
 
+    @Override
+    public List<SpecialQuestionVo> getSpecialQuestionList(SpecialQuestionBo bo) {
+        return baseMapper.getSpecialQuestionList(bo);
+    }
+
     private Long liveTime(Long nowTime, Integer day) {
         for (Integer i = 0; i < day; i++) {
             Long dayAfter = DateUtils.getDayAfter(nowTime, 1);

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/domain/GoodsQuestionRel.java

@@ -30,6 +30,10 @@ private static final long serialVersionUID=1L;
     private Long orderGoodsId;
     /** 题库商品ID */
     private Long questionGoodsId;
+    /** 题库订单商品ID */
+    private Long qsOrderGoodsId;
+    /** 学员预约ID */
+    private Long userSubscribeId;
     /** 做题次数 */
     private Long questionDoNum;
     /** 1有效 0无效 */

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/bo/OrderGoodsAddBo.java

@@ -89,4 +89,6 @@ public class OrderGoodsAddBo {
     private String distributionLinkCode;
     @ApiModelProperty("关联的订单商品ID")
     private Long relevanceId;
+    @ApiModelProperty("关联的学员预约ID")
+    private Long relevanceSubscribeId;
 }

+ 28 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/bo/SpecialQuestionBo.java

@@ -0,0 +1,28 @@
+package com.zhongzheng.modules.order.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2023年08月10日 14:30
+ */
+@Data
+@ApiModel("山东题库查询列表")
+public class SpecialQuestionBo implements Serializable {
+
+    /** 分页大小 */
+    @ApiModelProperty("分页大小")
+    private Integer pageSize;
+    /** 当前页数 */
+    @ApiModelProperty("当前页数")
+    private Integer pageNum;
+
+    @ApiModelProperty("用户Id")
+    private Long userId;
+    @ApiModelProperty("题库商家ID")
+    private Long questionMerchantId;
+}

+ 3 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/domain/OrderGoods.java

@@ -96,4 +96,7 @@ private static final long serialVersionUID=1L;
     private BigDecimal divideMoney;
 
     private Long tenantId;
+
+    @TableField(exist = false)
+    private Long subscribeId;
 }

+ 52 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderInputServiceImpl.java

@@ -8,7 +8,11 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.domain.GoodsQuestionRel;
+import com.zhongzheng.modules.goods.domain.QuestionMerchant;
+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.order.bo.OrderInputAddBo;
 import com.zhongzheng.modules.order.bo.OrderInputEditBo;
 import com.zhongzheng.modules.order.bo.OrderInputQueryBo;
@@ -26,7 +30,9 @@ import com.zhongzheng.modules.system.service.ISysOldOrgService;
 import com.zhongzheng.modules.top.goods.domain.TopOldOrderGoods;
 import com.zhongzheng.modules.top.goods.service.ITopOldOrderGoodsService;
 import com.zhongzheng.modules.user.domain.User;
+import com.zhongzheng.modules.user.domain.UserSubscribe;
 import com.zhongzheng.modules.user.service.IUserService;
+import com.zhongzheng.modules.user.service.IUserSubscribeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -37,6 +43,7 @@ import com.github.pagehelper.Page;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -60,6 +67,12 @@ public class OrderInputServiceImpl extends ServiceImpl<OrderInputMapper, OrderIn
     private IUserService iUserService;
     @Autowired
     private ISysOldOrgService iSysOldOrgService;
+    @Autowired
+    private IGoodsQuestionRelService iGoodsQuestionRelService;
+    @Autowired
+    private IQuestionMerchantService iQuestionMerchantService;
+    @Autowired
+    private IUserSubscribeService iUserSubscribeService;
 
 
     @Override
@@ -196,6 +209,9 @@ public class OrderInputServiceImpl extends ServiceImpl<OrderInputMapper, OrderIn
             if (ObjectUtils.isNull(user)){
                 throw new CustomException("学员【"+user.getRealname()+"】信息不存在");
             }
+            //学员预约信息
+            UserSubscribe userSubscribe = iUserSubscribeService.getById(orderGoods.getSignId());
+
             order.setUserId(user.getUserId());
             order.setOrderPrice(orderGoods.getGoodsRealPrice());
             order.setOrderStatus(1);
@@ -212,7 +228,7 @@ public class OrderInputServiceImpl extends ServiceImpl<OrderInputMapper, OrderIn
             order.setStatus(1);
             order.setCreateSysUserId(orderInput.getCreateSysUserId());
             order.setOrderBase(1);
-            order.setInputOrderSn(order.getOrderSn());
+            order.setInputOrderSn(orderInput.getInputOrderSn());
             order.setPayStatus(2);
             order.setCheckStatus(1);
             order.setOrderRefundStatus(1);
@@ -237,9 +253,44 @@ public class OrderInputServiceImpl extends ServiceImpl<OrderInputMapper, OrderIn
             add.setGoodsReceived(order.getOrderPrice());
             add.setRefundStatus(0);
             add.setPayStatus(3);
+            add = setQuestionServiceTime(add,userSubscribe.getOrderGoodsId(),order);
             iOrderGoodsService.save(add);
+
+            //题库关联
+            GoodsQuestionRel rel = new GoodsQuestionRel();
+            rel.setOrderGoodsId(userSubscribe.getOrderGoodsId());
+            rel.setUserSubscribeId(userSubscribe.getSubscribeId());
+            rel.setQsOrderGoodsId(add.getOrderGoodsId());
+            rel.setQuestionGoodsId(orderGoods.getGoodsId());
+            rel.setTenantId(tenantId);
+            rel.setUpdateTime(DateUtils.getNowTime());
+            rel.setCreateTime(DateUtils.getNowTime());
+            rel.setStatus(1);
+            QuestionMerchant merchant = iQuestionMerchantService.getById(goods.getQuestionMerchantId());
+            rel.setQuestionDoNum(merchant.getDoNum());
+            iGoodsQuestionRelService.save(rel);
         }
         orderInput.setCheckStauts(2);
         updateById(orderInput);
     }
+
+
+    private OrderGoods setQuestionServiceTime(OrderGoods add,Long orderGoodsId,Order order) {
+        UserSubscribe subscribe = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
+                .eq(UserSubscribe::getUserId, order.getUserId())
+                .eq(UserSubscribe::getOrderGoodsId, orderGoodsId)
+                .eq(UserSubscribe::getSubscribeStatus, 1)
+                .last("limit 1"));
+        if (ObjectUtils.isNull(subscribe)){
+            return add;
+        }
+        //考试日期
+        Long examTime = subscribe.getApplySiteExamTime();
+        //前推8天
+        Long dayBefore = DateUtils.getDayBefore(examTime, 8);
+        add.setServiceStartTime(dayBefore);
+        add.setServiceEndTime(examTime);
+        add.setSubscribeId(subscribe.getSubscribeId());
+        return add;
+    }
 }

+ 59 - 8
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/service/impl/OrderServiceImpl.java

@@ -844,9 +844,28 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //商家不存在
             return;
         }
+        //创建七大员题库商品订单
+        OrderGoods add = new OrderGoods();
+        add.setOrderSn(orderGoods.getOrderSn());
+        add.setGoodsId(questionGoods.getGoodsId());
+        add.setGoodsYear(questionGoods.getYear().toString());
+        add.setGoodsPrice(questionGoods.getStandPrice());
+        add.setGoodsRealPrice(questionGoods.getStandPrice());
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        add.setStatus(1);
+        add.setGoodsReceived(questionGoods.getStandPrice());
+        add.setRefundStatus(0);
+        add.setPayStatus(3);
+        //服务有效期
+        add = setQuestionServiceTime(add,orderGoods);
+        iOrderGoodsService.save(add);
+
         GoodsQuestionRel rel = new GoodsQuestionRel();
         rel.setOrderGoodsId(orderGoods.getOrderGoodsId());
         rel.setQuestionGoodsId(questionGoods.getGoodsId());
+        rel.setQsOrderGoodsId(add.getOrderGoodsId());
+        rel.setUserSubscribeId(add.getSubscribeId());
         rel.setStatus(1);
         rel.setQuestionDoNum(merchant.getDoNum());
         rel.setCreateTime(DateUtils.getNowTime());
@@ -854,8 +873,31 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         iGoodsQuestionRelService.save(rel);
     }
 
+    private OrderGoods setQuestionServiceTime(OrderGoods add,OrderGoods orderGoods) {
+        Order one = getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, orderGoods.getOrderSn()));
+        if (Objects.isNull(one)){
+            return null;
+        }
+        UserSubscribe subscribe = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
+                .eq(UserSubscribe::getUserId, one.getUserId())
+                .eq(UserSubscribe::getOrderGoodsId, orderGoods.getOrderGoodsId())
+                .eq(UserSubscribe::getSubscribeStatus, 1)
+                .last("limit 1"));
+        if (ObjectUtils.isNull(subscribe)){
+            return add;
+        }
+        //考试日期
+        Long examTime = subscribe.getApplySiteExamTime();
+        //前推8天
+        Long dayBefore = DateUtils.getDayBefore(examTime, 8);
+        add.setServiceStartTime(dayBefore);
+        add.setServiceEndTime(examTime);
+        add.setSubscribeId(subscribe.getSubscribeId());
+        return add;
+    }
+
 
-    private void questionOrderHandle(Long orderGoodsId,Long goodsId) {
+    private void questionOrderHandle(Long orderGoodsId,Long goodsId,Long qsOrderGoodsId,Long subscribeId) {
         //第三方题库商品
         Goods questionGoods = iGoodsService.getById(goodsId);
         if (ObjectUtils.isNull(questionGoods) || questionGoods.getGoodsType() != 9){
@@ -873,6 +915,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         rel.setQuestionGoodsId(questionGoods.getGoodsId());
         rel.setStatus(1);
         rel.setQuestionDoNum(merchant.getDoNum());
+        rel.setQsOrderGoodsId(qsOrderGoodsId);
+        rel.setUserSubscribeId(subscribeId);
         rel.setCreateTime(DateUtils.getNowTime());
         rel.setUpdateTime(DateUtils.getNowTime());
         iGoodsQuestionRelService.save(rel);
@@ -967,9 +1011,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 payPrice = payPrice.add(goods.getStandPrice());
             }
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
-            if (ObjectUtils.isNotNull(g.getRelevanceId())){
+            if (ObjectUtils.isNotNull(g.getRelevanceId()) && ObjectUtils.isNotNull(g.getRelevanceSubscribeId())){
                 //购买关联题库商品
-                questionOrderHandle(g.getRelevanceId(),g.getGoodsId());
+                questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId(),g.getRelevanceSubscribeId());
             }
             boolean canRepeatBuy = false;
             validUserBeforeBuy(goods, bo.getUserId());
@@ -1365,9 +1409,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 payPrice = payPrice.add(goods.getStandPrice());
             }
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
-            if (ObjectUtils.isNotNull(g.getRelevanceId())){
+            if (ObjectUtils.isNotNull(g.getRelevanceId()) && ObjectUtils.isNotNull(g.getRelevanceSubscribeId())){
                 //购买关联题库商品
-                questionOrderHandle(g.getRelevanceId(),g.getGoodsId());
+                questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId(),g.getRelevanceSubscribeId());
             }
             boolean canRepeatBuy = false;
             validUserBeforeBuy(goods, bo.getUserId());
@@ -1526,9 +1570,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             //暂不计算优惠券
             payPrice = payPrice.add(goods.getStandPrice());
             boolean orderGoodsRs = iOrderGoodsService.save(orderGoods);
-            if (ObjectUtils.isNotNull(g.getRelevanceId())){
+            if (ObjectUtils.isNotNull(g.getRelevanceId()) && ObjectUtils.isNotNull(g.getRelevanceSubscribeId())){
                 //购买关联题库商品
-                questionOrderHandle(g.getRelevanceId(),g.getGoodsId());
+                questionOrderHandle(g.getRelevanceId(),g.getGoodsId(),orderGoods.getOrderGoodsId(),g.getRelevanceSubscribeId());
             }
             boolean canRepeatBuy = false;
             validUserBeforeBuy(goods, bo.getUserId());
@@ -2734,6 +2778,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             goodsAddBo.setOrderSn(orderInputSn);
             goodsAddBo.setGoodsId(bo.getGoodsId());
             goodsAddBo.setGoodsPrice(goods.getStandPrice());
+            goodsAddBo.setGoodsYear(goods.getYear().toString());
             goodsAddBo.setGoodsRealPrice(goods.getStandPrice());
             goodsAddBo.setCreateTime(DateUtils.getNowTime());
             goodsAddBo.setUpdateTime(DateUtils.getNowTime());
@@ -2751,6 +2796,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             goodsAddBo.setUserName(user.getRealname());
             goodsAddBo.setUserCard(EncryptHandler.decrypt(user.getIdCard()));
             goodsAddBo.setUserPhone(EncryptHandler.decrypt(user.getTelphone()));
+            goodsAddBo.setSignId(userSubscribe.getSubscribeId());
             return goodsAddBo;
         }).collect(Collectors.toList());
         addBo.setOrderGoodsList(collect);
@@ -2772,7 +2818,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                     .eq(GoodsQuestionRel::getStatus, 1)
                     .gt(GoodsQuestionRel::getQuestionDoNum, 0));
             if (count > 0) {
-                throw new CustomException(String.format("学员【】已购买当前题库商品,请勿重复开通!",user.getRealname()));
+                throw new CustomException(String.format("学员【%s】已购买当前题库商品,请勿重复开通!",user.getRealname()));
+            }
+            //考试时间
+            Long examTime = userSubscribe.getApplySiteExamTime();
+            if (DateUtils.getNowTime() > examTime){
+                throw new CustomException(String.format("学员【%s】预约的考试已过期,请勿开通题库!",user.getRealname()));
             }
         }
     }

+ 59 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/order/vo/SpecialQuestionVo.java

@@ -0,0 +1,59 @@
+package com.zhongzheng.modules.order.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2023年08月10日 14:30
+ */
+@Data
+@ApiModel("山东题库列表")
+public class SpecialQuestionVo implements Serializable {
+
+    @ApiModelProperty("")
+    private Long goodsId;
+
+    @ApiModelProperty("")
+    private Long orderGoodsId;
+
+    @ApiModelProperty("")
+    private String orderSn;
+
+    @ApiModelProperty("年份")
+    private Long year;
+
+    @ApiModelProperty("商品类型 9第三方题库商品")
+    private Integer goodsType;
+
+    @ApiModelProperty("教育类型id")
+    private Long educationTypeId;
+
+    @ApiModelProperty("项目类型ID")
+    private Long projectId;
+
+    @ApiModelProperty("业务层次id")
+    private Long businessId;
+
+    @ApiModelProperty("所属专业")
+    private Long majorId;
+
+    @ApiModelProperty("商品名称")
+    private String goodsName;
+
+    @ApiModelProperty("业务名称")
+    private String businessName;
+
+    @ApiModelProperty("总题数")
+    private Integer questionNum;
+
+    @ApiModelProperty("服务有效期开始")
+    private Long serviceStartTime;
+
+    @ApiModelProperty("服务有效期结束")
+    private Long serviceEndTime;
+
+}

+ 40 - 38
zhongzheng-system/src/main/java/com/zhongzheng/modules/top/goods/service/impl/TopOldOrderServiceImpl.java

@@ -1040,46 +1040,48 @@ public class TopOldOrderServiceImpl extends ServiceImpl<TopOldOrderMapper, TopOl
                 if (CollectionUtils.isNotEmpty(goodsList)) {
                     userCount = goodsList.stream().map(TopOldOrderGoods::getUserCard).collect(Collectors.toSet()).size();
                 }
-                // 老系统查询学习状态
-                TopOldOrder order = getOne(new LambdaQueryWrapper<TopOldOrder>().eq(TopOldOrder::getOrderSn, query.getOrderSn()));
-                Map<String, String> params = new HashMap<>();
-                Long nowTime = DateUtils.getNowTime();
-                String sign = ToolsUtils.EncoderByMd5(query.getOrderSn() + nowTime.toString() + "pubilc2022");
-                params.put("stamp", nowTime.toString());
-                params.put("sign", sign);
-                params.put("orderSn", query.getOrderSn());
-                params.put("type", order.getOrderType().toString());
-                String respone = "";
-                try {
-                    respone = HttpUtils.postFormBody(ORDER_STUDY, params);
-                    if (!respone.contains("\"Status\":true")) {
-                        throw new CustomException("旧系统订单学员学习情况接口请求错误");
-                    }
-                    JSONObject jsonObject = JSONObject.parseObject(respone);
-                    Object data = jsonObject.get("Data");
-                    if (ObjectUtils.isNull(data)) {
-                        //data 为空
-                        list.forEach(x -> x.setStudyStatus("未开始"));
-                    } else {
-                        List<TopOldOrderStudyVo> studyVos = JSONArray.parseArray(JSONObject.toJSONString(data), TopOldOrderStudyVo.class);
-                        list.forEach(item -> {
-                            item.setStudyStatus("未开始");
-                            TopOldOrderStudyVo studyVo = studyVos.stream().filter(x -> x.getUnderOrdeEnrollItemId().equals(item.getSignId())
-                                    && x.getIdNum().equals(item.getUserCard())).findFirst().orElse(null);
-                            if (ObjectUtils.isNotNull(studyVo) && ObjectUtils.isNotNull(studyVo.getStudyHours())) {
-                                if (ObjectUtils.isNull(studyVo.getStudyHours()) && studyVo.getStudyHours() == 0) {
-                                    item.setStudyStatus("未开始");
-                                } else if (studyVo.getStudyHours() < studyVo.getTotalHours()) {
-                                    item.setStudyStatus("学习中");
-                                } else {
-                                    item.setStudyStatus("已结束");
+                if (query.getOrderFrom() != 4){
+                    // 老系统查询学习状态
+                    TopOldOrder order = getOne(new LambdaQueryWrapper<TopOldOrder>().eq(TopOldOrder::getOrderSn, query.getOrderSn()));
+                    Map<String, String> params = new HashMap<>();
+                    Long nowTime = DateUtils.getNowTime();
+                    String sign = ToolsUtils.EncoderByMd5(query.getOrderSn() + nowTime.toString() + "pubilc2022");
+                    params.put("stamp", nowTime.toString());
+                    params.put("sign", sign);
+                    params.put("orderSn", query.getOrderSn());
+                    params.put("type", order.getOrderType().toString());
+                    String respone = "";
+                    try {
+                        respone = HttpUtils.postFormBody(ORDER_STUDY, params);
+                        if (!respone.contains("\"Status\":true")) {
+                            throw new CustomException("旧系统订单学员学习情况接口请求错误");
+                        }
+                        JSONObject jsonObject = JSONObject.parseObject(respone);
+                        Object data = jsonObject.get("Data");
+                        if (ObjectUtils.isNull(data)) {
+                            //data 为空
+                            list.forEach(x -> x.setStudyStatus("未开始"));
+                        } else {
+                            List<TopOldOrderStudyVo> studyVos = JSONArray.parseArray(JSONObject.toJSONString(data), TopOldOrderStudyVo.class);
+                            list.forEach(item -> {
+                                item.setStudyStatus("未开始");
+                                TopOldOrderStudyVo studyVo = studyVos.stream().filter(x -> x.getUnderOrdeEnrollItemId().equals(item.getSignId())
+                                        && x.getIdNum().equals(item.getUserCard())).findFirst().orElse(null);
+                                if (ObjectUtils.isNotNull(studyVo) && ObjectUtils.isNotNull(studyVo.getStudyHours())) {
+                                    if (ObjectUtils.isNull(studyVo.getStudyHours()) && studyVo.getStudyHours() == 0) {
+                                        item.setStudyStatus("未开始");
+                                    } else if (studyVo.getStudyHours() < studyVo.getTotalHours()) {
+                                        item.setStudyStatus("学习中");
+                                    } else {
+                                        item.setStudyStatus("已结束");
+                                    }
                                 }
-                            }
-                        });
+                            });
+                        }
+                    } catch (IOException e) {
+                        log.error("旧系统订单学员学习情况接口请求错误" + respone);
+                        throw new CustomException("旧系统订单学员学习情况接口请求错误");
                     }
-                } catch (IOException e) {
-                    log.error("旧系统订单学员学习情况接口请求错误" + respone);
-                    throw new CustomException("旧系统订单学员学习情况接口请求错误");
                 }
             }
         }

+ 45 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wx/service/impl/WxPayServiceImpl.java

@@ -70,6 +70,7 @@ import com.zhongzheng.modules.top.settle.service.ITopInstSettleService;
 import com.zhongzheng.modules.user.bo.UserExamGoodsQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamGoodsSupplementAddBo;
 import com.zhongzheng.modules.user.domain.UserExamGoods;
+import com.zhongzheng.modules.user.domain.UserSubscribe;
 import com.zhongzheng.modules.user.service.*;
 import com.zhongzheng.modules.user.vo.UserExamGoodsVo;
 import com.zhongzheng.modules.user.vo.UserVo;
@@ -235,6 +236,8 @@ public class WxPayServiceImpl implements IWxPayService {
     private IGoodsQuestionRelService iGoodsQuestionRelService;
     @Autowired
     private IQuestionMerchantService iQuestionMerchantService;
+    @Autowired
+    private IUserSubscribeService iUserSubscribeService;
 
     private String gzh_tokenUrl = "https://api.weixin.qq.com/cgi-bin/token";
 
@@ -563,9 +566,28 @@ public class WxPayServiceImpl implements IWxPayService {
             //商家不存在
             return;
         }
+        //创建七大员题库商品订单
+        OrderGoods add = new OrderGoods();
+        add.setOrderSn(orderGoods.getOrderSn());
+        add.setGoodsId(questionGoods.getGoodsId());
+        add.setGoodsYear(questionGoods.getYear().toString());
+        add.setGoodsPrice(questionGoods.getStandPrice());
+        add.setGoodsRealPrice(questionGoods.getStandPrice());
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        add.setStatus(1);
+        add.setGoodsReceived(questionGoods.getStandPrice());
+        add.setRefundStatus(0);
+        add.setPayStatus(3);
+        //服务有效期
+        add = setQuestionServiceTime(add,orderGoods);
+        iOrderGoodsService.save(add);
+
         GoodsQuestionRel rel = new GoodsQuestionRel();
         rel.setOrderGoodsId(orderGoods.getOrderGoodsId());
         rel.setQuestionGoodsId(questionGoods.getGoodsId());
+        rel.setQsOrderGoodsId(add.getOrderGoodsId());
+        rel.setUserSubscribeId(add.getSubscribeId());
         rel.setStatus(1);
         rel.setQuestionDoNum(merchant.getDoNum());
         rel.setCreateTime(DateUtils.getNowTime());
@@ -573,6 +595,29 @@ public class WxPayServiceImpl implements IWxPayService {
         iGoodsQuestionRelService.save(rel);
     }
 
+    private OrderGoods setQuestionServiceTime(OrderGoods add,OrderGoods orderGoods) {
+        Order one = iOrderService.getOne(new LambdaQueryWrapper<Order>().eq(Order::getOrderSn, orderGoods.getOrderSn()));
+        if (Objects.isNull(one)){
+            return null;
+        }
+        UserSubscribe subscribe = iUserSubscribeService.getOne(new LambdaQueryWrapper<UserSubscribe>()
+                .eq(UserSubscribe::getUserId, one.getUserId())
+                .eq(UserSubscribe::getOrderGoodsId, orderGoods.getOrderGoodsId())
+                .eq(UserSubscribe::getSubscribeStatus, 1)
+                .last("limit 1"));
+        if (ObjectUtils.isNull(subscribe)){
+            return add;
+        }
+        //考试日期
+        Long examTime = subscribe.getApplySiteExamTime();
+        //前推8天
+        Long dayBefore = DateUtils.getDayBefore(examTime, 8);
+        add.setServiceStartTime(dayBefore);
+        add.setServiceEndTime(examTime);
+        add.setSubscribeId(subscribe.getSubscribeId());
+        return add;
+    }
+
     private void instTimeSettleOrder(Order order, Long checkTime) {
         //业务层次
         List<String> fullName = iOrderService.queryBusinessFullNameBySn(order.getOrderSn());

+ 34 - 0
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMapper.xml

@@ -899,4 +899,38 @@
     <select id="getCourseByTenantTwo" parameterType="map" resultType="java.lang.Long">
         select * from course where course_name = #{courseName} and code = #{code} and tenant_id = #{tenantId}
     </select>
+
+    <select id="getSpecialQuestionList" parameterType="com.zhongzheng.modules.order.bo.SpecialQuestionBo" resultType="com.zhongzheng.modules.order.vo.SpecialQuestionVo">
+        SELECT
+            g.goods_id,
+            og.order_goods_id,
+            o.order_sn,
+            g.`year`,
+            g.goods_type,
+            g.education_type_id,
+            g.project_id,
+            g.business_id,
+            g.major_id,
+            g.goods_name,
+            CONCAT( cb.business_name, cpt.project_name ) AS businessName,
+            og.service_start_time,
+            og.service_end_time
+        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_education_type cet ON g.education_type_id = cet.id
+                LEFT JOIN course_project_type cpt ON g.project_id = cpt.id
+                LEFT JOIN course_business cb ON g.business_id = cb.id
+                LEFT JOIN question_merchant qm ON g.question_merchant_id = qm.merchant_id
+        WHERE
+            o.`status` = 1
+            AND og.refund_status != 2
+	        AND og.pay_status IN ( 2, 3, 4 )
+	        AND g.goods_type = 9
+	        AND o.user_id = #{userId}
+            <if test="questionMerchantId != null and questionMerchantId != ''">
+                AND g.question_merchant_id = #{questionMerchantId}
+            </if>
+    </select>
 </mapper>