From 1c7e22837254781947366d09282d48a45347d0e5 Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期三, 06 八月 2025 10:20:45 +0800
Subject: [PATCH] 发送小程序订单数量
---
pt-errand/src/main/java/com/ruoyi/errand/service/impl/EvaluationServiceImpl.java | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/pt-errand/src/main/java/com/ruoyi/errand/service/impl/EvaluationServiceImpl.java b/pt-errand/src/main/java/com/ruoyi/errand/service/impl/EvaluationServiceImpl.java
index 5deedf4..917dbee 100644
--- a/pt-errand/src/main/java/com/ruoyi/errand/service/impl/EvaluationServiceImpl.java
+++ b/pt-errand/src/main/java/com/ruoyi/errand/service/impl/EvaluationServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.errand.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.errand.constant.DelFlagConstant;
@@ -10,6 +11,7 @@
import com.ruoyi.errand.mapper.OrderMapper;
import com.ruoyi.errand.object.dto.app.AddEvaluationDTO;
import com.ruoyi.errand.service.EvaluationService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
@@ -19,6 +21,7 @@
@Service
public class EvaluationServiceImpl extends ServiceImpl<EvaluationMapper, Evaluation> implements EvaluationService {
+ @Autowired
private OrderMapper orderMapper;
@Override
@@ -47,12 +50,34 @@
}else {
throw new ServiceException("评价类型错误");
}
+ //查看订单是否评价过
+ LambdaQueryWrapper<Evaluation> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.eq(Evaluation::getType, addEvaluationDTO.getType());
+ lambdaQueryWrapper.eq(Evaluation::getOrderId,addEvaluationDTO.getOrderId());
+ Evaluation one = this.getOne(lambdaQueryWrapper);
+ if (one!=null){
+ throw new ServiceException("该订单已评价过,请去修改");
+ }
Evaluation evaluation = new Evaluation();
evaluation.setOrderId(addEvaluationDTO.getOrderId());
evaluation.setType(addEvaluationDTO.getType());
evaluation.setRating(addEvaluationDTO.getRating());
evaluation.setContent(addEvaluationDTO.getContent());
evaluation.setCreateTime(LocalDateTime.now());
+ evaluation.setImgUrl(addEvaluationDTO.getImgUrl());
this.save(evaluation);
}
+
+ @Override
+ public void edit(AddEvaluationDTO addEvaluationDTO) {
+ Evaluation evaluation = this.getById(addEvaluationDTO.getEvaluationId());
+ if (evaluation==null){
+ throw new ServiceException("该评价不存在");
+ }
+ evaluation.setRating(addEvaluationDTO.getRating());
+ evaluation.setContent(addEvaluationDTO.getContent());
+ evaluation.setUpdateTime(LocalDateTime.now());
+ evaluation.setImgUrl(addEvaluationDTO.getImgUrl());
+ this.updateById(evaluation);
+ }
}
\ No newline at end of file
--
Gitblit v1.7.1