修复评价列表显示问题

This commit is contained in:
hupeng
2019-12-31 17:01:52 +08:00
parent c4fa032be7
commit 6e4cdf0777
4 changed files with 37 additions and 17 deletions

View File

@ -34,15 +34,18 @@ public interface YxStoreProductReplyMapper extends BaseMapper<YxStoreProductRepl
"order by A.add_time DESC limit 1") "order by A.add_time DESC limit 1")
YxStoreProductReplyQueryVo getReply(int productId); YxStoreProductReplyQueryVo getReply(int productId);
@Select("select A.product_score as productScore,A.service_score as serviceScore," + @Select("<script>select A.product_score as productScore,A.service_score as serviceScore," +
"A.comment,A.merchant_reply_content as merchantReplyContent," + "A.comment,A.merchant_reply_content as merchantReplyContent," +
"A.merchant_reply_time as merchantReplyTime,A.pics as pictures,A.add_time as addTime," + "A.merchant_reply_time as merchantReplyTime,A.pics as pictures,A.add_time as addTime," +
"B.nickname,B.avatar,C.cart_info as cartInfo" + "B.nickname,B.avatar,C.cart_info as cartInfo" +
" from yx_store_product_reply A left join yx_user B " + " from yx_store_product_reply A left join yx_user B " +
"on A.uid = B.uid left join yx_store_order_cart_info C on A.unique = C.unique" + "on A.uid = B.uid left join yx_store_order_cart_info C on A.unique = C.unique" +
" where A.product_id=#{productId} and A.is_del=0 and A.reply_type='product' " + " where A.product_id=#{productId} and A.is_del=0 and A.reply_type='product' " +
"order by A.add_time DESC") "<if test='type == 1'>and A.product_score = 5</if>" +
List<YxStoreProductReplyQueryVo> selectReplyList(Page page, @Param("productId") int productId); "<if test='type == 2'>and A.product_score &lt; 5 and A.product_score &gt; 2</if>" +
"<if test='type == 3'>and A.product_score &lt; 2</if>"+
" order by A.add_time DESC</script>")
List<YxStoreProductReplyQueryVo> selectReplyList(Page page, @Param("productId") int productId,int type);
/** /**
* 根据ID获取查询对象 * 根据ID获取查询对象

View File

@ -26,7 +26,7 @@ public interface YxStoreProductReplyService extends BaseService<YxStoreProductRe
YxStoreProductReplyQueryVo getReply(int productId); YxStoreProductReplyQueryVo getReply(int productId);
List<YxStoreProductReplyQueryVo> getReplyList(int productId,int page, int limit); List<YxStoreProductReplyQueryVo> getReplyList(int productId,int type,int page, int limit);
int getInfoCount(Integer oid,String unique); int getInfoCount(Integer oid,String unique);

View File

@ -3,6 +3,8 @@ package co.yixiang.modules.shop.service.impl;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.web.vo.Paging;
import co.yixiang.modules.shop.entity.YxStoreProductReply; import co.yixiang.modules.shop.entity.YxStoreProductReply;
import co.yixiang.modules.shop.mapper.YxStoreProductReplyMapper; import co.yixiang.modules.shop.mapper.YxStoreProductReplyMapper;
import co.yixiang.modules.shop.service.YxStoreProductReplyService; import co.yixiang.modules.shop.service.YxStoreProductReplyService;
@ -10,25 +12,21 @@ import co.yixiang.modules.shop.web.dto.ReplyCountDTO;
import co.yixiang.modules.shop.web.param.YxStoreProductReplyQueryParam; import co.yixiang.modules.shop.web.param.YxStoreProductReplyQueryParam;
import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo; import co.yixiang.modules.shop.web.vo.YxStoreCartQueryVo;
import co.yixiang.modules.shop.web.vo.YxStoreProductReplyQueryVo; import co.yixiang.modules.shop.web.vo.YxStoreProductReplyQueryVo;
import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.common.web.vo.Paging;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -91,6 +89,11 @@ public class YxStoreProductReplyServiceImpl extends BaseServiceImpl<YxStoreProdu
return replyCountDTO; return replyCountDTO;
} }
/**
* 处理评价
* @param replyQueryVo
* @return
*/
@Override @Override
public YxStoreProductReplyQueryVo handleReply(YxStoreProductReplyQueryVo replyQueryVo) { public YxStoreProductReplyQueryVo handleReply(YxStoreProductReplyQueryVo replyQueryVo) {
YxStoreCartQueryVo cartInfo = JSONObject.parseObject(replyQueryVo.getCartInfo() YxStoreCartQueryVo cartInfo = JSONObject.parseObject(replyQueryVo.getCartInfo()
@ -117,6 +120,11 @@ public class YxStoreProductReplyServiceImpl extends BaseServiceImpl<YxStoreProdu
return replyQueryVo; return replyQueryVo;
} }
/**
* 获取单条评价
* @param productId
* @return
*/
@Override @Override
public YxStoreProductReplyQueryVo getReply(int productId) { public YxStoreProductReplyQueryVo getReply(int productId) {
YxStoreProductReplyQueryVo vo = yxStoreProductReplyMapper.getReply(productId); YxStoreProductReplyQueryVo vo = yxStoreProductReplyMapper.getReply(productId);
@ -126,12 +134,21 @@ public class YxStoreProductReplyServiceImpl extends BaseServiceImpl<YxStoreProdu
return null; return null;
} }
/**
* 获取评价列表
* @param productId
* @param type
* @param page
* @param limit
* @return
*/
@Override @Override
public List<YxStoreProductReplyQueryVo> getReplyList(int productId,int page, int limit) { public List<YxStoreProductReplyQueryVo> getReplyList(int productId,int type,int page, int limit) {
List<YxStoreProductReplyQueryVo> newList = new ArrayList<>(); List<YxStoreProductReplyQueryVo> newList = new ArrayList<>();
Page<YxStoreProductReply> pageModel = new Page<>(page, limit); Page<YxStoreProductReply> pageModel = new Page<>(page, limit);
List<YxStoreProductReplyQueryVo> list = yxStoreProductReplyMapper List<YxStoreProductReplyQueryVo> list = yxStoreProductReplyMapper
.selectReplyList(pageModel,productId); .selectReplyList(pageModel,productId,type);
List<YxStoreProductReplyQueryVo> list1 = list.stream().map(i ->{ List<YxStoreProductReplyQueryVo> list1 = list.stream().map(i ->{
YxStoreProductReplyQueryVo vo = new YxStoreProductReplyQueryVo(); YxStoreProductReplyQueryVo vo = new YxStoreProductReplyQueryVo();
BeanUtils.copyProperties(i,vo); BeanUtils.copyProperties(i,vo);

View File

@ -129,7 +129,7 @@ public class StoreProductController extends BaseController {
@RequestParam(value = "type",defaultValue = "0") int type, @RequestParam(value = "type",defaultValue = "0") int type,
@RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "page",defaultValue = "1") int page,
@RequestParam(value = "limit",defaultValue = "10") int limit){ @RequestParam(value = "limit",defaultValue = "10") int limit){
return ApiResult.ok(replyService.getReplyList(id,page,limit)); return ApiResult.ok(replyService.getReplyList(id,type,page,limit));
} }
/** /**