前端-胡立永 1 month ago
parent
commit
2d6ffe21e8
9 changed files with 198 additions and 32 deletions
  1. +8
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/contains/AppletQuestionContains.java
  2. +20
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiCarController.java
  3. +15
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiOrderController.java
  4. +6
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiPaperController.java
  5. +2
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiOrderService.java
  6. +2
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiPaperService.java
  7. +25
    -2
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiOrderServiceImpl.java
  8. +116
    -30
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiPaperServiceImpl.java
  9. +4
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletPaper/entity/AppletPaper.java

+ 8
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/contains/AppletQuestionContains.java View File

@ -0,0 +1,8 @@
package org.jeecg.modules.applet.contains;
public class AppletQuestionContains {
public static final String CHOOSE = "02";//选择题
public static final String WRITE = "1";//选择题
}

+ 20
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiCarController.java View File

@ -1,5 +1,6 @@
package org.jeecg.modules.applet.controller;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -13,6 +14,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.config.shiro.IgnoreAuth;
import org.jeecg.modules.applet.bo.CreateOrderItemBo;
import org.jeecg.modules.applet.service.AppletApiCarService;
import org.jeecg.modules.demo.appletCar.entity.AppletCar;
@ -21,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
;import java.util.Arrays;
import java.util.List;
/**
* @Description: 购物车
@ -69,6 +72,23 @@ public class AppletApiCarController {
}
/**
* 批量添加
*
* @param list
* @return
*/
@Operation(summary = "购物车-批量添加")
@PostMapping(value = "/addList")
public Result<String> addList(String list) {
List<AppletCar> appletCars = JSON.parseArray(list, AppletCar.class);
for (AppletCar appletCar : appletCars) {
appletApiCarService.save(appletCar);
}
return Result.OK("添加成功!");
}
/**
* 编辑


+ 15
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiOrderController.java View File

@ -145,6 +145,8 @@ public class AppletApiOrderController {
Page<AppletOrderEvaluate> page = new Page<>(pageNo, pageSize);
return Result.OK(appletApiOrderService.myEvaluate(type, page));
}
/**
* 商品评价
*
@ -159,6 +161,19 @@ public class AppletApiOrderController {
Page<AppletOrderEvaluate> page = new Page<>(pageNo, pageSize);
return Result.OK(appletApiOrderService.productEvaluate(productId, page));
}
/**
* 商品评价数量
*
* @param productId 商品评价数量
* @return
*/
@Operation(summary = "商品评价数量")
@PostMapping(value = "/productEvaluateNum")
public Result<Long> productEvaluateNum(String productId) {
return Result.OK(appletApiOrderService.productEvaluateNum(productId));
}
/**
* 删除评价
*


+ 6
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiPaperController.java View File

@ -41,6 +41,12 @@ public class AppletApiPaperController {
return Result.ok(appletApiPaperService.list(page, type));
}
@GetMapping("/recentReport")
@Operation(summary = "近期报告")
public Result<List<AppletPaperReport>> recentReport(){
return Result.ok(appletApiPaperService.recentReport());
}
@GetMapping("/paperDetail")
@Operation(summary = "试卷详情")
public Result<AppletPaper> paperDetail(@Parameter(description = "试卷id") String id){


+ 2
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiOrderService.java View File

@ -48,4 +48,6 @@ public interface AppletApiOrderService {
IPage<AppletOrderEvaluate> productEvaluate(String productId, Page<AppletOrderEvaluate> page);
IPage<AppletOrderEvaluate> myEvaluate(String type, Page<AppletOrderEvaluate> page);
Long productEvaluateNum(String productId);
}

+ 2
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiPaperService.java View File

@ -35,4 +35,6 @@ public interface AppletApiPaperService {
void answer(String id, String questionsId, String answer);
void submit(String id);
List<AppletPaperReport> recentReport();
}

+ 25
- 2
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiOrderServiceImpl.java View File

@ -572,8 +572,17 @@ public class AppletApiOrderServiceImpl implements AppletApiOrderService {
@Override
public IPage<AppletOrderEvaluate> productEvaluate(String productId, Page<AppletOrderEvaluate> page) {
Page<AppletOrderEvaluate> list = appletOrderEvaluateService.lambdaQuery()
.like(AppletOrderEvaluate::getProductId, productId)
if (StringUtils.isBlank(productId)){
throw new JeecgBootException("商品id不能为空");
}
LambdaQueryChainWrapper<AppletOrderEvaluate> qw = appletOrderEvaluateService.lambdaQuery();
for (String s : productId.split(",")) {
qw.like(AppletOrderEvaluate::getProductId, s);
}
Page<AppletOrderEvaluate> list = qw
.orderByDesc(AppletOrderEvaluate::getCreateTime)
.page(page);
@ -601,4 +610,18 @@ public class AppletApiOrderServiceImpl implements AppletApiOrderService {
return list;
}
@Override
public Long productEvaluateNum(String productId) {
if (StringUtils.isBlank(productId)){
throw new JeecgBootException("商品id不能为空");
}
LambdaQueryChainWrapper<AppletOrderEvaluate> qw = appletOrderEvaluateService.lambdaQuery();
for (String s : productId.split(",")) {
qw.like(AppletOrderEvaluate::getProductId, s);
}
return qw.count();
}
}

+ 116
- 30
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiPaperServiceImpl.java View File

@ -1,7 +1,10 @@
package org.jeecg.modules.applet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.system.util.AppletUserUtil;
import org.jeecg.common.system.vo.AppletUser;
import org.jeecg.modules.applet.contains.AppletQuestionContains;
import org.jeecg.modules.applet.service.AppletApiPaperService;
import org.jeecg.modules.demo.appletPaper.entity.AppletPaper;
import org.jeecg.modules.demo.appletPaper.entity.AppletQuestions;
@ -15,6 +18,8 @@ import org.jeecg.modules.demo.appletPaperReport.entity.AppletPaperReport;
import org.jeecg.modules.demo.appletPaperReport.entity.AppletPaperReportItem;
import org.jeecg.modules.demo.appletPaperReport.service.IAppletPaperReportItemService;
import org.jeecg.modules.demo.appletPaperReport.service.IAppletPaperReportService;
import org.jeecg.modules.demo.appletProductSpec.entity.AppletProductSpec;
import org.jeecg.modules.demo.appletProductSpec.service.IAppletProductSpecService;
import org.jeecg.modules.demo.appletScheme.service.IAppletSchemeService;
import org.jeecg.modules.demo.appletSchemeCategory.service.IAppletSchemeCategoryService;
import org.jeecg.modules.demo.appletProduct.entity.AppletProduct;
@ -63,18 +68,32 @@ public class AppletApiPaperServiceImpl implements AppletApiPaperService {
private IAppletProductService appletProductService;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private IAppletProductSpecService appletProductSpecService;
@Override
public IPage<AppletPaper> list(Page<AppletPaper> page, String type) {
String userId = AppletUserUtil.getCurrentAppletUserId();
String userId = null;
AppletUser user = AppletUserUtil.getAppletUserFromRequest();
if (user != null){
userId = user.getId();
}
// 查询当前用户已答题过的试卷ID列表
List<String> answeredPaperIds = appletPaperReportService.lambdaQuery()
.eq(AppletPaperReport::getUserId, userId)
.list()
.stream()
.map(AppletPaperReport::getPaperId)
.collect(Collectors.toList());
List<String> answeredPaperIds = new ArrayList<>();
if(StringUtils.isNotBlank(userId)){
answeredPaperIds = appletPaperReportService.lambdaQuery()
.eq(AppletPaperReport::getUserId, userId)
.eq(AppletPaperReport::getStatus, "1")
.list()
.stream()
.map(AppletPaperReport::getPaperId)
.collect(Collectors.toList());
}
LambdaQueryWrapper<AppletPaper> queryWrapper = new LambdaQueryWrapper<>();
@ -92,8 +111,27 @@ public class AppletApiPaperServiceImpl implements AppletApiPaperService {
}
}
// 如果type为空或其他值查询所有试卷不过滤
return appletPaperService.page(page, queryWrapper);
Page<AppletPaper> page1 = appletPaperService.page(page, queryWrapper);
if (StringUtils.isNotBlank(userId)){
for (AppletPaper record : page1.getRecords()) {
record.setReports(appletPaperReportService
.lambdaQuery()
.last("limit 2")
.orderByDesc(AppletPaperReport::getCreateTime)
.eq(AppletPaperReport::getPaperId, record.getId())
.eq(AppletPaperReport::getUserId, userId)
.select(
AppletPaperReport::getId,
AppletPaperReport::getScore,
AppletPaperReport::getCreateTime
)
.list());
}
}
return page1;
}
@Override
@ -104,6 +142,7 @@ public class AppletApiPaperServiceImpl implements AppletApiPaperService {
.eq(AppletPaperReport::getPaperId, id)
.eq(AppletPaperReport::getUserId, userId)
.eq(AppletPaperReport::getStatus, "1")
.orderByDesc(AppletPaperReport::getCreateTime)
.list();
return list;
}
@ -132,6 +171,9 @@ public class AppletApiPaperServiceImpl implements AppletApiPaperService {
if (!productId.isEmpty()) {
AppletProduct product = appletProductService.getById(productId);
if (product != null) {
product.setSpecs(appletProductSpecService.lambdaQuery()
.eq(AppletProductSpec::getProductId, product.getId())
.last("limit 1").list());
productList.add(product);
}
}
@ -234,32 +276,35 @@ public class AppletApiPaperServiceImpl implements AppletApiPaperService {
// 如果是选择题需要获取选项的商品和方案信息
String productId = null;
String schemeId = null;
if (answer != null && !answer.trim().isEmpty()) {
// 解析答案可能是多个选项ID用逗号分隔
String[] optionIds = answer.split(",");
List<String> productIds = new ArrayList<>();
List<String> schemeIds = new ArrayList<>();
for (String optionId : optionIds) {
optionId = optionId.trim();
if (!optionId.isEmpty()) {
AppletQuestionsOptions option = appletQuestionsOptionsService.getById(optionId);
if (option != null) {
if (option.getProductId() != null && !option.getProductId().trim().isEmpty()) {
productIds.add(option.getProductId());
}
if (option.getSchemeId() != null && !option.getSchemeId().trim().isEmpty()) {
schemeIds.add(option.getSchemeId());
if (answer != null && !answer.trim().isEmpty()){
if (AppletQuestionContains.CHOOSE.contains(questions.getType())) {
// 解析答案可能是多个选项ID用逗号分隔
String[] optionIds = answer.split(",");
List<String> productIds = new ArrayList<>();
List<String> schemeIds = new ArrayList<>();
for (String optionId : optionIds) {
optionId = optionId.trim();
if (!optionId.isEmpty()) {
AppletQuestionsOptions option = appletQuestionsOptionsService.getById(optionId);
if (option != null) {
if (option.getProductId() != null && !option.getProductId().trim().isEmpty()) {
productIds.add(option.getProductId());
}
if (option.getSchemeId() != null && !option.getSchemeId().trim().isEmpty()) {
schemeIds.add(option.getSchemeId());
}
}
}
}
// 合并商品ID和方案ID
productId = productIds.isEmpty() ? null : String.join(",", productIds);
schemeId = schemeIds.isEmpty() ? null : String.join(",", schemeIds);
}
// 合并商品ID和方案ID
productId = productIds.isEmpty() ? null : String.join(",", productIds);
schemeId = schemeIds.isEmpty() ? null : String.join(",", schemeIds);
}
if (existingItem != null) {
// 更新现有记录
@ -358,6 +403,47 @@ public class AppletApiPaperServiceImpl implements AppletApiPaperService {
appletPaperReportService.updateById(report);
}
@Override
public List<AppletPaperReport> recentReport() {
String userId = AppletUserUtil.getCurrentAppletUserId();
List<AppletPaperReport> list = appletPaperReportService
.lambdaQuery()
.orderByDesc(AppletPaperReport::getCreateTime)
.eq(AppletPaperReport::getUserId, userId)
.last("limit 1")
.select(
AppletPaperReport::getId,
AppletPaperReport::getCreateTime,
AppletPaperReport::getPaperId,
AppletPaperReport::getScore
)
.list();
if (list.isEmpty()){
return list;
}
AppletPaperReport one = appletPaperReportService
.lambdaQuery()
.orderByDesc(AppletPaperReport::getCreateTime)
.eq(AppletPaperReport::getUserId, userId)
.eq(AppletPaperReport::getPaperId, list.get(0).getPaperId())
.ne(AppletPaperReport::getId, list.get(0).getId())
.last("limit 1")
.select(
AppletPaperReport::getId,
AppletPaperReport::getCreateTime,
AppletPaperReport::getPaperId,
AppletPaperReport::getScore
)
.one();
list.add(one);
return list;
}
/**
* 组合方案数据
* @param schemeIds 方案ID列表逗号分隔


+ 4
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletPaper/entity/AppletPaper.java View File

@ -10,6 +10,7 @@ import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.jeecg.modules.demo.appletPaperReport.entity.AppletPaperReport;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
@ -71,4 +72,7 @@ public class AppletPaper implements Serializable {
@TableField(exist = false)
@Schema(description = "试卷分类")
private List<AppletQuestionsCategory> category;
@TableField(exist = false)
private List<AppletPaperReport> reports;
}

Loading…
Cancel
Save