浏览代码

提交:商品推荐列表

yangdamao 3 年之前
父节点
当前提交
f4f46de861

+ 3 - 2
zhongzheng-api/src/main/java/com/zhongzheng/controller/cmmon/CommonController.java

@@ -132,9 +132,10 @@ public class CommonController extends BaseController {
      */
     @ApiOperation("获取考试活动商品")
     @GetMapping("/activity/goodsList/{activityId}")
-    public AjaxResult<List<GoodsVo>> getActivityGoodsList(@PathVariable("activityId") Long activityId) {
+    public TableDataInfo<GoodsVo> getActivityGoodsList(@PathVariable("activityId") Long activityId) {
+        startPage();
         List<GoodsVo> voList = iExamActivityService.getActivityGoodsList(activityId);
-        return AjaxResult.success(voList);
+        return getDataTable(voList);
     }
 
     @ApiOperation("小程序配置")

+ 11 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/exam/ExamApplyController.java

@@ -14,6 +14,7 @@ import com.zhongzheng.modules.exam.service.IExamApplyGoodsService;
 import com.zhongzheng.modules.exam.service.IExamApplyService;
 import com.zhongzheng.modules.exam.service.IExamApplySiteService;
 import com.zhongzheng.modules.exam.vo.*;
+import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.user.bo.*;
 import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import com.zhongzheng.modules.user.service.IUserSubscribeService;
@@ -165,4 +166,14 @@ public class ExamApplyController extends BaseController {
         return toAjax(iUserSubscribeService.updateByEditSingleBo(bo) ? 1 : 0);
     }
 
+
+    /**
+     * 获取试卷对应的推荐商品列表
+     */
+    @ApiOperation("获取试卷对应的推荐商品列表")
+    @PostMapping("/recommend/goodsList")
+    public TableDataInfo<GoodsVo> getRecommendGoodsList(@RequestBody ExamRecommendGoodsQueryBo bo) {
+        return iExamApplyService.getRecommendGoodsList(bo);
+    }
+
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/mapper/ActivityRecommendMapper.java

@@ -16,7 +16,7 @@ import java.util.List;
  * @date 2022-04-13
  */
 public interface ActivityRecommendMapper extends BaseMapper<ActivityRecommend> {
-    List<ActivityRecommendVo> selectList(ActivityRecommendQueryBo bo);
+    List<ActivityRecommendVo> selectListByBo(ActivityRecommendQueryBo bo);
 
     ActivityRecommendVo getDetail(ActivityRecommendQueryBo bo);
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/activity/service/impl/ActivityRecommendServiceImpl.java

@@ -107,7 +107,7 @@ public class ActivityRecommendServiceImpl extends ServiceImpl<ActivityRecommendM
 
     @Override
     public List<ActivityRecommendVo> selectList(ActivityRecommendQueryBo bo) {
-        return baseMapper.selectList(bo);
+        return baseMapper.selectListByBo(bo);
     }
 
     @Override

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/course/service/impl/CourseTopicServiceImpl.java

@@ -159,7 +159,6 @@ public class CourseTopicServiceImpl extends ServiceImpl<CourseTopicMapper, Cours
             CourseTopicGoods tbTopic = new CourseTopicGoods();
             BeanUtil.copyProperties(item, tbTopic);
             Goods goods = iGoodsService.getById(item.getGoodsId());
-            tbTopic.setGoodsName(goods.getGoodsName());
             tbTopic.setStandPrice(goods.getStandPrice());
             tbTopic.setLowestPrice(goods.getLowestPrice());
             tbTopic.setLinePrice(goods.getLinePrice());

+ 30 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/ExamRecommendGoodsQueryBo.java

@@ -0,0 +1,30 @@
+package com.zhongzheng.modules.exam.bo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 试卷推荐位商品查询 exam_activity
+ *
+ * @author yangdamao
+ * @date 2021-12-07
+ */
+@Data
+@ApiModel("试卷推荐位商品查询")
+public class ExamRecommendGoodsQueryBo implements Serializable {
+
+    @ApiModelProperty("试卷ID")
+    private Long examId;
+
+    @ApiModelProperty("分页参数")
+    private Integer pageSize;
+
+    @ApiModelProperty("分页参数")
+    private Integer pageNum;
+
+
+
+}

+ 12 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/IExamApplyService.java

@@ -1,12 +1,11 @@
 package com.zhongzheng.modules.exam.service;
 
-import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
+import com.zhongzheng.common.core.page.TableDataInfo;
+import com.zhongzheng.modules.exam.bo.*;
 import com.zhongzheng.modules.exam.domain.ExamApply;
 import com.zhongzheng.modules.exam.vo.*;
-import com.zhongzheng.modules.exam.bo.ExamApplyQueryBo;
-import com.zhongzheng.modules.exam.bo.ExamApplyAddBo;
-import com.zhongzheng.modules.exam.bo.ExamApplyEditBo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhongzheng.modules.goods.vo.GoodsVo;
 
 import java.util.Collection;
 import java.util.List;
@@ -66,4 +65,13 @@ public interface IExamApplyService extends IService<ExamApply> {
 	List<ExamUserApplySiteVo> subscribeApplySiteTrain(ExamApplyQueryBo bo);
 
 	Integer countApplySubscribe(ExamApplyQueryBo bo);
+
+	/**
+	 * 获取试卷对应的推荐商品列表
+	 * @author change
+	 * @date 2022/9/16 9:13
+	 * @param bo
+	 * @return java.util.List<com.zhongzheng.modules.goods.vo.GoodsVo>
+	 */
+	TableDataInfo<GoodsVo> getRecommendGoodsList(ExamRecommendGoodsQueryBo bo);
 }

+ 70 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -6,15 +6,29 @@ import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+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;
+import com.zhongzheng.modules.activity.domain.ActivityRecommend;
+import com.zhongzheng.modules.activity.domain.ActivityRecommendGoods;
+import com.zhongzheng.modules.activity.service.IActivityRecommendGoodsService;
+import com.zhongzheng.modules.activity.service.IActivityRecommendService;
+import com.zhongzheng.modules.bank.domain.Exam;
+import com.zhongzheng.modules.bank.domain.QuestionBusiness;
+import com.zhongzheng.modules.bank.service.IExamService;
+import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
 import com.zhongzheng.modules.course.domain.Course;
 import com.zhongzheng.modules.exam.bo.*;
 import com.zhongzheng.modules.exam.domain.ExamBefore;
 import com.zhongzheng.modules.exam.vo.*;
+import com.zhongzheng.modules.goods.domain.Goods;
+import com.zhongzheng.modules.goods.service.IGoodsService;
+import com.zhongzheng.modules.goods.vo.GoodsVo;
 import com.zhongzheng.modules.user.vo.CalendarStudyVo;
 import io.swagger.annotations.ApiModelProperty;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -36,6 +50,17 @@ import java.util.stream.Collectors;
 @Service
 public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply> implements IExamApplyService {
 
+    @Autowired
+    private IQuestionBusinessService iQuestionBusinessService;
+    @Autowired
+    private IExamService iExamService;
+    @Autowired
+    private IActivityRecommendService iActivityRecommendService;
+    @Autowired
+    private IActivityRecommendGoodsService iActivityRecommendGoodsService;
+    @Autowired
+    private IGoodsService iGoodsService;
+
     @Override
     public ExamApplyVo queryById(Long applyId){
         ExamApplyVo examApplyVo = baseMapper.selectByApply(applyId);
@@ -295,6 +320,51 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         return baseMapper.countApplySubscribe(bo);
     }
 
+    @Override
+    public TableDataInfo<GoodsVo> getRecommendGoodsList(ExamRecommendGoodsQueryBo bo) {
+        TableDataInfo tableDataInfo = new TableDataInfo();
+        Exam exam = iExamService.getById(bo.getExamId());
+        if (ObjectUtils.isNull(exam)){
+            throw new CustomException("获取试卷信息失败");
+        }
+        //获取试卷业务层次信息
+        QuestionBusiness business = iQuestionBusinessService.getOne(new LambdaQueryWrapper<QuestionBusiness>()
+                .eq(QuestionBusiness::getMajorId, bo.getExamId())
+                .eq(QuestionBusiness::getType, 2));
+        if (ObjectUtils.isNull(business)){
+            throw new CustomException("获取试卷业务层次信息失败");
+        }
+        //获取推荐位信息
+        List<ActivityRecommend> list = iActivityRecommendService.list(new LambdaQueryWrapper<ActivityRecommend>()
+                .eq(ActivityRecommend::getEducationTypeId, business.getEducationTypeId())
+                .eq(ActivityRecommend::getBusinessId, business.getBusinessId())
+                .eq(ActivityRecommend::getType, 1)
+                .eq(ActivityRecommend::getStatus,1));
+        if (CollectionUtils.isEmpty(list)){
+            return tableDataInfo;
+        }
+        ActivityRecommend activityRecommend = list.stream().findFirst().get();
+        com.baomidou.mybatisplus.extension.plugins.pagination.Page<ActivityRecommendGoods> page =
+                iActivityRecommendGoodsService.page(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(bo.getPageNum(), bo.getPageSize()),
+                                                        new LambdaQueryWrapper<ActivityRecommendGoods>()
+                                                        .eq(ActivityRecommendGoods::getRecommendId, activityRecommend.getRecommendId())
+                                                                .orderByAsc(ActivityRecommendGoods::getSort));
+        if (CollectionUtils.isEmpty(page.getRecords())){
+            return tableDataInfo;
+        }
+        List<GoodsVo> result = page.getRecords().stream().map(item -> {
+            Goods goods = iGoodsService.getById(item.getGoodsId());
+            GoodsVo goodsVo = new GoodsVo();
+            BeanUtil.copyProperties(goods, goodsVo);
+            return goodsVo;
+        }).collect(Collectors.toList());
+
+        tableDataInfo.setTotal(page.getTotal());
+        tableDataInfo.setRows(result);
+
+        return tableDataInfo;
+    }
+
     private boolean checkNameUnique(ExamApply entity) {
         ExamApply info = getOne(new LambdaQueryWrapper<ExamApply>()
                 .eq(ExamApply::getApplyName,entity.getApplyName()).ne(ExamApply::getStatus,-1).last("limit 1"));

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/activity/ActivityRecommendMapper.xml

@@ -64,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by rg.sort asc
     </select>
 
-    <select id="selectList" parameterType="com.zhongzheng.modules.activity.bo.ActivityRecommendQueryBo" resultMap="ActivityRecommendVoResult">
+    <select id="selectListByBo" parameterType="com.zhongzheng.modules.activity.bo.ActivityRecommendQueryBo" resultMap="ActivityRecommendVoResult">
         SELECT ar.*, cet.education_name,
                cpt.project_name,
                cb.business_name from activity_recommend ar