获取指定餐品的评价列表 api/v1/applet/menuevaluaorder/page/meal

This commit is contained in:
tqzhang 2025-02-07 16:56:21 +08:00
parent 04041627f5
commit fca5072fac
15 changed files with 752 additions and 0 deletions

View File

@ -35,4 +35,6 @@ public class CustInfoAppIdLoginVO implements Serializable {
private Long expireIn;
@ApiModelProperty("是否登录")
private boolean isLogin;
@ApiModelProperty("人员id")
private String custIdStr;
}

View File

@ -0,0 +1,11 @@
package com.bonus.framework.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface RequiresGuest {
}

View File

@ -138,6 +138,7 @@ public class TokenController {
custInfo.setIdCard(SM4EncryptUtils.sm4Encryptbyconfig(content.getIdCard()));
}
CustInfoAppIdLoginVO result = this.custInfoMapper.selectLoginInfo(custInfo);
result.setCustIdStr(result.getCustId().toString());
if (Objects.isNull(result)) {
throw new ServiceException("未找到用户");
} else {

View File

@ -0,0 +1,59 @@
package com.bonus.core.menu.controller;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.core.menu.service.MenuEvaluaOrderService;
import com.bonus.core.menu.vo.MenuEvaluaOrderPageMealDTO;
import com.bonus.framework.annotation.RequiresGuest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
@RestController
@RequestMapping({"/api/v1/applet/menuevaluaorder"})
@Api(
value = "menuevaluaorder",
tags = {"pfy_订单评价"}
)
public class MenuEvaluaOrderController {
private static final Logger log = LoggerFactory.getLogger(MenuEvaluaOrderController.class);
@Lazy
@Resource
private MenuEvaluaOrderService menuEvaluaOrderService;
@PostMapping({"/page/meal"})
@RequiresGuest
@ApiOperation("获取指定餐品的评价列表")
public AjaxResult getMenuEvaluaOrderPageByMeal(@RequestBody @Valid MenuEvaluaOrderPageMealDTO dto) {
try {
if (StringUtils.isBlank(String.valueOf(dto.getMealId()))) {
return AjaxResult.error("餐品ID不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getCurrent()))) {
return AjaxResult.error("页码不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getSize()))) {
return AjaxResult.error("每页数量不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getShopstallId()))) {
return AjaxResult.error("档口ID不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getMealType()))){
return AjaxResult.error("餐品类型不能为空");
}
return AjaxResult.success(this.menuEvaluaOrderService.getMenuEvaluaOrderPageByMeal(dto));
} catch (Exception e) {
log.error(e.toString(), e);
return AjaxResult.error("获取指定餐品的评价列表失败");
}
}
}

View File

@ -0,0 +1,174 @@
package com.bonus.core.menu.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
@TableName("menu_evalua_order")
public class MenuEvaluaOrder extends Model<MenuEvaluaOrder> {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("评价id")
private Long evaluaId;
@ApiModelProperty("评价订单类型1食堂订单2商超订单")
private Integer orderEvaluaType;
@ApiModelProperty("订单编号")
private Long ordId;
@ApiModelProperty("星级")
private Integer starLevel;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("评价回复")
private String reply;
@ApiModelProperty("评价回复时间")
private LocalDateTime replyTime;
@ApiModelProperty("档口或店铺id")
private Long shopstallId;
@ApiModelProperty("是否显示(1-显示,2-不显示)")
private Integer showFlag;
@ApiModelProperty("删除标识(1删除,2正常)")
private Integer delFlag;
@ApiModelProperty("乐观锁")
private Integer revision;
@ApiModelProperty("创建人")
private String crby;
@ApiModelProperty("创建时间")
private LocalDateTime crtime;
@ApiModelProperty("更新人")
private String upby;
@ApiModelProperty("更新时间")
private LocalDateTime uptime;
public Long getId() {
return this.id;
}
public Long getEvaluaId() {
return this.evaluaId;
}
public Integer getOrderEvaluaType() {
return this.orderEvaluaType;
}
public Long getOrdId() {
return this.ordId;
}
public Integer getStarLevel() {
return this.starLevel;
}
public String getDescription() {
return this.description;
}
public String getReply() {
return this.reply;
}
public LocalDateTime getReplyTime() {
return this.replyTime;
}
public Long getShopstallId() {
return this.shopstallId;
}
public Integer getShowFlag() {
return this.showFlag;
}
public Integer getDelFlag() {
return this.delFlag;
}
public Integer getRevision() {
return this.revision;
}
public String getCrby() {
return this.crby;
}
public LocalDateTime getCrtime() {
return this.crtime;
}
public String getUpby() {
return this.upby;
}
public LocalDateTime getUptime() {
return this.uptime;
}
public void setId(final Long id) {
this.id = id;
}
public void setEvaluaId(final Long evaluaId) {
this.evaluaId = evaluaId;
}
public void setOrderEvaluaType(final Integer orderEvaluaType) {
this.orderEvaluaType = orderEvaluaType;
}
public void setOrdId(final Long ordId) {
this.ordId = ordId;
}
public void setStarLevel(final Integer starLevel) {
this.starLevel = starLevel;
}
public void setDescription(final String description) {
this.description = description;
}
public void setReply(final String reply) {
this.reply = reply;
}
public void setReplyTime(final LocalDateTime replyTime) {
this.replyTime = replyTime;
}
public void setShopstallId(final Long shopstallId) {
this.shopstallId = shopstallId;
}
public void setShowFlag(final Integer showFlag) {
this.showFlag = showFlag;
}
public void setDelFlag(final Integer delFlag) {
this.delFlag = delFlag;
}
public void setRevision(final Integer revision) {
this.revision = revision;
}
public void setCrby(final String crby) {
this.crby = crby;
}
public void setCrtime(final LocalDateTime crtime) {
this.crtime = crtime;
}
public void setUpby(final String upby) {
this.upby = upby;
}
public void setUptime(final LocalDateTime uptime) {
this.uptime = uptime;
}
}

View File

@ -0,0 +1,94 @@
package com.bonus.core.menu.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
@TableName("menu_evalua_picture")
public class MenuEvaluaPicture extends Model<MenuEvaluaPicture> {
private static final long serialVersionUID = 1L;
@TableId
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("评价id")
private Long evaluaId;
@ApiModelProperty("图片路径")
private String pictureUrl;
@ApiModelProperty("乐观锁")
private Integer revision;
@ApiModelProperty("创建人")
private String crby;
@ApiModelProperty("创建时间")
private LocalDateTime crtime;
@ApiModelProperty("更新人")
private String upby;
@ApiModelProperty("更新时间")
private LocalDateTime uptime;
public Long getId() {
return this.id;
}
public Long getEvaluaId() {
return this.evaluaId;
}
public String getPictureUrl() {
return this.pictureUrl;
}
public Integer getRevision() {
return this.revision;
}
public String getCrby() {
return this.crby;
}
public LocalDateTime getCrtime() {
return this.crtime;
}
public String getUpby() {
return this.upby;
}
public LocalDateTime getUptime() {
return this.uptime;
}
public void setId(final Long id) {
this.id = id;
}
public void setEvaluaId(final Long evaluaId) {
this.evaluaId = evaluaId;
}
public void setPictureUrl(final String pictureUrl) {
this.pictureUrl = pictureUrl;
}
public void setRevision(final Integer revision) {
this.revision = revision;
}
public void setCrby(final String crby) {
this.crby = crby;
}
public void setCrtime(final LocalDateTime crtime) {
this.crtime = crtime;
}
public void setUpby(final String upby) {
this.upby = upby;
}
public void setUptime(final LocalDateTime uptime) {
this.uptime = uptime;
}
}

View File

@ -0,0 +1,18 @@
package com.bonus.core.menu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.core.menu.entity.MenuEvaluaOrder;
import com.bonus.core.menu.vo.MenuEvaluaMealVO;
import com.bonus.core.menu.vo.MenuEvaluaOrderPageMealVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface MenuEvaluaOrderMapper extends BaseMapper<MenuEvaluaOrder> {
Page<MenuEvaluaOrderPageMealVO> selectAllListByMeal(Page<MenuEvaluaOrderPageMealVO> page, @Param("mealId") Long mealId, @Param("shopstallId") Long shopstallId, @Param("searchType") Integer searchType);
MenuEvaluaMealVO selectAvgByMealAndShop(@Param("mealId") Long mealId, @Param("mealType") Integer mealType, @Param("shopstallId") Long shopstallId, @Param("delFlag") Integer delFlag);
}

View File

@ -0,0 +1,15 @@
package com.bonus.core.menu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.core.menu.entity.MenuEvaluaPicture;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface MenuEvaluaPictureMapper extends BaseMapper<MenuEvaluaPicture> {
@Select({"select picture_url from menu_evalua_picture where evalua_id = #{evaluaId}"})
List<String> selectPictureByEvaluaId(@Param("evaluaId") Long evaluaId);
}

View File

@ -0,0 +1,12 @@
package com.bonus.core.menu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bonus.core.menu.entity.MenuEvaluaOrder;
import com.bonus.core.menu.vo.MenuEvaluaMealVO;
import com.bonus.core.menu.vo.MenuEvaluaOrderPageMealDTO;
public interface MenuEvaluaOrderService extends IService<MenuEvaluaOrder> {
MenuEvaluaMealVO getMenuEvaluaOrderPageByMeal(MenuEvaluaOrderPageMealDTO content);
}

View File

@ -0,0 +1,59 @@
package com.bonus.core.menu.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.constant.DelFlagEnum;
import com.bonus.core.menu.entity.MenuEvaluaOrder;
import com.bonus.core.menu.mapper.MenuEvaluaOrderMapper;
import com.bonus.core.menu.mapper.MenuEvaluaPictureMapper;
import com.bonus.core.menu.service.MenuEvaluaOrderService;
import com.bonus.core.menu.vo.MenuEvaluaMealVO;
import com.bonus.core.menu.vo.MenuEvaluaOrderPageMealDTO;
import com.bonus.core.menu.vo.MenuEvaluaOrderPageMealVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.RoundingMode;
import java.util.*;
@Service
public class MenuEvaluaOrderServiceImpl extends ServiceImpl<MenuEvaluaOrderMapper, MenuEvaluaOrder> implements MenuEvaluaOrderService {
private static final Logger log = LoggerFactory.getLogger(MenuEvaluaOrderServiceImpl.class);
@Lazy
@Resource
private MenuEvaluaPictureMapper menuEvaluaPictureMapper;
@Override
public MenuEvaluaMealVO getMenuEvaluaOrderPageByMeal(MenuEvaluaOrderPageMealDTO content) {
Page<MenuEvaluaOrderPageMealVO> page = new Page(content.getCurrent(), content.getSize());
Page<MenuEvaluaOrderPageMealVO> evaluaList = ((MenuEvaluaOrderMapper)this.baseMapper).selectAllListByMeal(page, content.getMealId(), content.getShopstallId(), content.getSearchType());
List<MenuEvaluaOrderPageMealVO> records = evaluaList.getRecords();
if (CollUtil.isNotEmpty(records)) {
Iterator var5 = records.iterator();
while(var5.hasNext()) {
MenuEvaluaOrderPageMealVO item = (MenuEvaluaOrderPageMealVO)var5.next();
Long evaluaId = item.getEvaluaId();
List<String> pictureList = this.menuEvaluaPictureMapper.selectPictureByEvaluaId(evaluaId);
item.setPictureList(pictureList);
}
}
MenuEvaluaMealVO result = ((MenuEvaluaOrderMapper)this.baseMapper).selectAvgByMealAndShop(content.getMealId(), content.getMealType(), content.getShopstallId(), DelFlagEnum.DEL_FALSE.key());
if (result == null) {
log.info("***[小程序_获取餐品的评价列表]_没有记录,直接返回空**************");
return new MenuEvaluaMealVO();
} else {
if (result.getAvgStarLevel() != null) {
result.setAvgStarLevel(result.getAvgStarLevel().setScale(1, RoundingMode.HALF_UP));
}
result.setEvaluaList(evaluaList);
return result;
}
}
}

View File

@ -0,0 +1,42 @@
package com.bonus.core.menu.vo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
@ApiModel("获取指定餐品的评价列表")
public class MenuEvaluaMealVO implements Serializable {
@ApiModelProperty("餐品id")
private Long mealId;
@ApiModelProperty("平均评分")
private BigDecimal avgStarLevel;
@ApiModelProperty("评价列表")
private Page<MenuEvaluaOrderPageMealVO> evaluaList;
public Long getMealId() {
return this.mealId;
}
public BigDecimal getAvgStarLevel() {
return this.avgStarLevel;
}
public Page<MenuEvaluaOrderPageMealVO> getEvaluaList() {
return this.evaluaList;
}
public void setMealId(final Long mealId) {
this.mealId = mealId;
}
public void setAvgStarLevel(final BigDecimal avgStarLevel) {
this.avgStarLevel = avgStarLevel;
}
public void setEvaluaList(final Page<MenuEvaluaOrderPageMealVO> evaluaList) {
this.evaluaList = evaluaList;
}
}

View File

@ -0,0 +1,69 @@
package com.bonus.core.menu.vo;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Optional;
public class MenuEvaluaOrderPageMealDTO implements Serializable {
@ApiModelProperty("当前页")
private Long current;
@ApiModelProperty("每页显示条数")
private Long size;
@ApiModelProperty("档口id")
private Long shopstallId;
@ApiModelProperty("餐品id")
private Long mealId;
@ApiModelProperty("餐品类型(1-菜品,2-套餐,3-商品)")
private Integer mealType;
@ApiModelProperty("检索类型(1-全部,2-有图,3-最新)")
private Integer searchType;
public Integer getSearchType() {
return (Integer)Optional.ofNullable(this.searchType).orElse(1);
}
public Long getCurrent() {
return this.current;
}
public Long getSize() {
return this.size;
}
public Long getShopstallId() {
return this.shopstallId;
}
public Long getMealId() {
return this.mealId;
}
public Integer getMealType() {
return this.mealType;
}
public void setCurrent(final Long current) {
this.current = current;
}
public void setSize(final Long size) {
this.size = size;
}
public void setShopstallId(final Long shopstallId) {
this.shopstallId = shopstallId;
}
public void setMealId(final Long mealId) {
this.mealId = mealId;
}
public void setMealType(final Integer mealType) {
this.mealType = mealType;
}
public void setSearchType(final Integer searchType) {
this.searchType = searchType;
}
}

View File

@ -0,0 +1,119 @@
package com.bonus.core.menu.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.bonus.core.common.encrypt.LeNiuDecryptDataProcess;
import com.bonus.core.common.encrypt.LeNiuDecryptField;
import com.bonus.core.common.utils.SysUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
@ApiModel("评价列表")
@LeNiuDecryptDataProcess
public class MenuEvaluaOrderPageMealVO implements Serializable {
@ApiModelProperty("人员头像地址")
private String custPhotoUrl;
@ApiModelProperty("人员姓名")
@LeNiuDecryptField
private String custName;
@ApiModelProperty("评价id")
private Long evaluaId;
@ApiModelProperty("订单编号")
private Long ordId;
@ApiModelProperty("星级")
private Integer starLevel;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("评价图片")
private List<String> pictureList;
@ApiModelProperty("评价时间")
private LocalDateTime evaluaTime;
@ApiModelProperty("评价回复")
private String reply;
@ExcelIgnore
@ApiModelProperty("评价回复时间")
private LocalDateTime replyTime;
public String getCustPhotoUrl() {
return SysUtil.getCutFileUrl(this.custPhotoUrl);
}
public String getCustName() {
return this.custName;
}
public Long getEvaluaId() {
return this.evaluaId;
}
public Long getOrdId() {
return this.ordId;
}
public Integer getStarLevel() {
return this.starLevel;
}
public String getDescription() {
return this.description;
}
public List<String> getPictureList() {
return this.pictureList;
}
public LocalDateTime getEvaluaTime() {
return this.evaluaTime;
}
public String getReply() {
return this.reply;
}
public LocalDateTime getReplyTime() {
return this.replyTime;
}
public void setCustPhotoUrl(final String custPhotoUrl) {
this.custPhotoUrl = custPhotoUrl;
}
public void setCustName(final String custName) {
this.custName = custName;
}
public void setEvaluaId(final Long evaluaId) {
this.evaluaId = evaluaId;
}
public void setOrdId(final Long ordId) {
this.ordId = ordId;
}
public void setStarLevel(final Integer starLevel) {
this.starLevel = starLevel;
}
public void setDescription(final String description) {
this.description = description;
}
public void setPictureList(final List<String> pictureList) {
this.pictureList = pictureList;
}
public void setEvaluaTime(final LocalDateTime evaluaTime) {
this.evaluaTime = evaluaTime;
}
public void setReply(final String reply) {
this.reply = reply;
}
public void setReplyTime(final LocalDateTime replyTime) {
this.replyTime = replyTime;
}
}

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.core.menu.mapper.MenuEvaluaOrderMapper">
<!-- 分页获取指定餐品的评价列表 -->
<select id="selectAllListByMeal" resultType="com.bonus.core.menu.vo.MenuEvaluaOrderPageMealVO">
select
ci.cust_photo_url,
ci.cust_name,
meo.evalua_id,
meo.ord_id,
med.star_level,
meo.description,
meo.reply,
meo.reply_time,
meo.crtime as evalua_time
from
menu_evalua_detail med
left join menu_dishes md on med.meal_id = md.dishes_id
left join menu_evalua_order meo on med.evalua_id = meo.evalua_id
left join order_info oai on meo.ord_id = oai.order_id
left join cust_info ci on oai.cust_id = ci.cust_id
left join menu_evalua_picture mep on meo.evalua_id = mep.evalua_id
left join menu_material mm on mm.material_id=med.meal_id
where
meo.del_flag = 2
and meo.show_flag = 1
and (md.base_dishes_id = #{mealId} or mm.material_id=#{mealId})
and meo.shopstall_id = #{shopstallId}
<if test="searchType == 3">
and meo.crtime between date_sub(now(), interval 30 day) and now()
</if>
group by
ci.cust_photo_url,
ci.cust_name,
meo.evalua_id,
meo.ord_id,
med.star_level,
meo.description,
meo.reply,
meo.reply_time,
meo.crtime
<trim prefix="having" prefixOverrides="and" >
<if test='searchType == 2'>
and count(mep.id) > 0
</if>
</trim>
order by
meo.crtime desc
</select>
<select id="selectAvgByMealAndShop" resultType="com.bonus.core.menu.vo.MenuEvaluaMealVO">
select
md.base_dishes_id as meal_id,
avg(med.star_level) as avg_star_level
from
menu_evalua_detail med
left join menu_evalua_order meo on med.evalua_id = meo.evalua_id
left join menu_dishes md on med.meal_id = md.dishes_id
left join menu_material mm on mm.material_id=med.meal_id
where
meo.del_flag = #{delFlag}
and meo.show_flag = 1
and (md.base_dishes_id = #{mealId} or mm.material_id=#{mealId})
and med.meal_type = #{mealType}
and meo.shopstall_id = #{shopstallId}
group by
md.base_dishes_id
</select>
</mapper>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.core.menu.mapper.MenuEvaluaPictureMapper">
</mapper>