Commit b8e0b2a18b00e357012ab86f465597f91108a3b0

Authored by liujun001
1 parent 9b39ddcf

按需修改用户评价

trash-garbage/src/main/java/com/trash/garbage/mapper/GarOrderEvaluateMapper.java
@@ -4,6 +4,7 @@ import com.trash.garbage.pojo.domain.GarOrderEvaluate; @@ -4,6 +4,7 @@ import com.trash.garbage.pojo.domain.GarOrderEvaluate;
4 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5 import org.apache.ibatis.annotations.Param; 5 import org.apache.ibatis.annotations.Param;
6 6
  7 +import java.util.Collection;
7 import java.util.List; 8 import java.util.List;
8 9
9 /** 10 /**
@@ -15,6 +16,8 @@ import java.util.List; @@ -15,6 +16,8 @@ import java.util.List;
15 public interface GarOrderEvaluateMapper extends BaseMapper<GarOrderEvaluate> { 16 public interface GarOrderEvaluateMapper extends BaseMapper<GarOrderEvaluate> {
16 17
17 List<GarOrderEvaluate> queryEvaluateByEnterpriseIds(@Param("list") List<Long> enterpriseIds, @Param("type") Integer value); 18 List<GarOrderEvaluate> queryEvaluateByEnterpriseIds(@Param("list") List<Long> enterpriseIds, @Param("type") Integer value);
  19 +
  20 + List<GarOrderEvaluate> countIdGroupByOrderId(@Param("list") Collection<String> orderIds,@Param("type") Integer type);
18 } 21 }
19 22
20 23
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarOrder.java
1 package com.trash.garbage.pojo.domain; 1 package com.trash.garbage.pojo.domain;
2 2
3 -import com.baomidou.mybatisplus.annotation.*;  
4 -  
5 -import java.io.Serializable;  
6 -import java.util.Date;  
7 - 3 +import com.baomidou.mybatisplus.annotation.FieldFill;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
8 import com.fasterxml.jackson.annotation.JsonFormat; 7 import com.fasterxml.jackson.annotation.JsonFormat;
9 import com.fasterxml.jackson.annotation.JsonIgnore; 8 import com.fasterxml.jackson.annotation.JsonIgnore;
10 import lombok.Data; 9 import lombok.Data;
11 import org.springframework.format.annotation.DateTimeFormat; 10 import org.springframework.format.annotation.DateTimeFormat;
12 11
  12 +import java.io.Serializable;
  13 +import java.util.Date;
  14 +
13 /** 15 /**
14 * 建筑垃圾—订单表 16 * 建筑垃圾—订单表
15 * @TableName gar_order 17 * @TableName gar_order
@@ -167,8 +169,18 @@ public class GarOrder implements Serializable { @@ -167,8 +169,18 @@ public class GarOrder implements Serializable {
167 169
168 private Integer garTimeOutFlag; 170 private Integer garTimeOutFlag;
169 171
  172 + /**
  173 + * 是否有用户的评价,默认值是0,默认没有
  174 + *
  175 + * @author liujun
  176 + * @date 2024/6/20 14:39
  177 + */
  178 + @TableField(exist = false)
  179 + private Integer haveEvaluateOfClient = 0;
  180 +
  181 +
170 182
171 - @TableField(exist = false) 183 + @TableField(exist = false)
172 private static final long serialVersionUID = 1L; 184 private static final long serialVersionUID = 1L;
173 185
174 186
@@ -450,4 +462,13 @@ public class GarOrder implements Serializable { @@ -450,4 +462,13 @@ public class GarOrder implements Serializable {
450 public void setGarTimeOutFlag(Integer garTimeOutFlag) { 462 public void setGarTimeOutFlag(Integer garTimeOutFlag) {
451 this.garTimeOutFlag = garTimeOutFlag; 463 this.garTimeOutFlag = garTimeOutFlag;
452 } 464 }
  465 +
  466 +
  467 + public Integer getHaveEvaluateOfClient() {
  468 + return haveEvaluateOfClient;
  469 + }
  470 +
  471 + public void setHaveEvaluateOfClient(Integer haveEvaluateOfClient) {
  472 + this.haveEvaluateOfClient = haveEvaluateOfClient;
  473 + }
453 } 474 }
454 \ No newline at end of file 475 \ No newline at end of file
trash-garbage/src/main/java/com/trash/garbage/pojo/domain/GarOrderEvaluate.java
@@ -4,9 +4,10 @@ import com.baomidou.mybatisplus.annotation.FieldFill; @@ -4,9 +4,10 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
4 import com.baomidou.mybatisplus.annotation.TableField; 4 import com.baomidou.mybatisplus.annotation.TableField;
5 import com.baomidou.mybatisplus.annotation.TableId; 5 import com.baomidou.mybatisplus.annotation.TableId;
6 import com.baomidou.mybatisplus.annotation.TableName; 6 import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.Data;
  8 +
7 import java.io.Serializable; 9 import java.io.Serializable;
8 import java.util.Date; 10 import java.util.Date;
9 -import lombok.Data;  
10 11
11 /** 12 /**
12 * 建筑垃圾-订单评分 13 * 建筑垃圾-订单评分
@@ -76,6 +77,9 @@ public class GarOrderEvaluate implements Serializable { @@ -76,6 +77,9 @@ public class GarOrderEvaluate implements Serializable {
76 */ 77 */
77 private String garRemark; 78 private String garRemark;
78 79
  80 + @TableField(exist = false)
  81 + private Integer countTheNumber;
  82 +
79 @TableField(exist = false) 83 @TableField(exist = false)
80 private static final long serialVersionUID = 1L; 84 private static final long serialVersionUID = 1L;
81 85
trash-garbage/src/main/java/com/trash/garbage/service/GarOrderEvaluateService.java
@@ -3,6 +3,7 @@ package com.trash.garbage.service; @@ -3,6 +3,7 @@ package com.trash.garbage.service;
3 import com.baomidou.mybatisplus.extension.service.IService; 3 import com.baomidou.mybatisplus.extension.service.IService;
4 import com.trash.garbage.pojo.domain.GarOrderEvaluate; 4 import com.trash.garbage.pojo.domain.GarOrderEvaluate;
5 5
  6 +import java.util.Collection;
6 import java.util.List; 7 import java.util.List;
7 8
8 /** 9 /**
@@ -15,4 +16,13 @@ public interface GarOrderEvaluateService extends IService&lt;GarOrderEvaluate&gt; { @@ -15,4 +16,13 @@ public interface GarOrderEvaluateService extends IService&lt;GarOrderEvaluate&gt; {
15 List<GarOrderEvaluate> queryEvaluateByEnterpriseIds( List<Long> enterpriseIds, Integer value); 16 List<GarOrderEvaluate> queryEvaluateByEnterpriseIds( List<Long> enterpriseIds, Integer value);
16 17
17 Integer countId(GarOrderEvaluate evaluate); 18 Integer countId(GarOrderEvaluate evaluate);
  19 + /***
  20 + *
  21 + * 根据订单 Id分组查询评价条数,
  22 + * @author liujun
  23 + * @date 2024/6/21 9:11
  24 + * @param orderIds
  25 + * @return java.util.List<com.trash.garbage.pojo.domain.GarOrderEvaluate>
  26 + */
  27 + List<GarOrderEvaluate> countIdGroupByOrderId(Collection<String> orderIds,Integer type);
18 } 28 }
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderEvaluateServiceImpl.java
@@ -9,6 +9,8 @@ import com.trash.garbage.service.GarOrderEvaluateService; @@ -9,6 +9,8 @@ import com.trash.garbage.service.GarOrderEvaluateService;
9 import org.springframework.stereotype.Service; 9 import org.springframework.stereotype.Service;
10 10
11 import java.util.ArrayList; 11 import java.util.ArrayList;
  12 +import java.util.Collection;
  13 +import java.util.Collections;
12 import java.util.List; 14 import java.util.List;
13 15
14 /** 16 /**
@@ -35,6 +37,15 @@ public class GarOrderEvaluateServiceImpl extends ServiceImpl&lt;GarOrderEvaluateMap @@ -35,6 +37,15 @@ public class GarOrderEvaluateServiceImpl extends ServiceImpl&lt;GarOrderEvaluateMap
35 return count(wrapper); 37 return count(wrapper);
36 } 38 }
37 39
  40 + @Override
  41 + public List<GarOrderEvaluate> countIdGroupByOrderId(Collection<String> orderIds,Integer type) {
  42 + if(CollectionUtil.isEmpty(orderIds)){
  43 + return Collections.emptyList();
  44 + }
  45 +
  46 + return baseMapper.countIdGroupByOrderId(orderIds,type);
  47 + }
  48 +
38 49
39 } 50 }
40 51
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarOrderServiceImpl.java
@@ -329,12 +329,14 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -329,12 +329,14 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
329 .eq(GarOrder::getGarTimeOutFlag, GlobalStatus.GarOrderStatus.ORDER_TIME_OUT_FLAG_NO.getValue()); 329 .eq(GarOrder::getGarTimeOutFlag, GlobalStatus.GarOrderStatus.ORDER_TIME_OUT_FLAG_NO.getValue());
330 } 330 }
331 List<GarOrder> orderList = list(qw); 331 List<GarOrder> orderList = list(qw);
  332 + orderList=queryHaveEvaluateOfClient(orderList,GlobalStatus.GarOrderStatus.EVALUATE_TYPE_COMPANY.getValue());
332 PageInfo<GarOrder> pageInfo = new PageInfo<GarOrder>(orderList, pageSize); 333 PageInfo<GarOrder> pageInfo = new PageInfo<GarOrder>(orderList, pageSize);
333 return pageInfo; 334 return pageInfo;
334 } 335 }
335 // 全部 336 // 全部
336 if (GlobalStatus.GarOrderStatus.ALL_ORDER.getValue().equals(type)) { 337 if (GlobalStatus.GarOrderStatus.ALL_ORDER.getValue().equals(type)) {
337 List<GarOrder> orderList = baseMapper.selectList(qw); 338 List<GarOrder> orderList = baseMapper.selectList(qw);
  339 + orderList =queryHaveEvaluateOfClient(orderList,GlobalStatus.GarOrderStatus.EVALUATE_TYPE_COMPANY.getValue());
338 PageInfo<GarOrder> pageInfo = new PageInfo<GarOrder>(orderList, pageSize); 340 PageInfo<GarOrder> pageInfo = new PageInfo<GarOrder>(orderList, pageSize);
339 return pageInfo; 341 return pageInfo;
340 } 342 }
@@ -352,6 +354,34 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt; @@ -352,6 +354,34 @@ public class GarOrderServiceImpl extends ServiceImpl&lt;GarOrderMapper, GarOrder&gt;
352 return null; 354 return null;
353 } 355 }
354 356
  357 + /***
  358 + * 查询有无评价信息
  359 + *
  360 + * @author liujun
  361 + * @date 2024/6/21 9:08
  362 + * @param orders 订单数据
  363 + */
  364 + private List<GarOrder> queryHaveEvaluateOfClient(List<GarOrder> orders, Integer type) {
  365 + if (CollectionUtils.isEmpty(orders)) {
  366 + return orders;
  367 + }
  368 + Set<String> orderIds = orders.stream().map(GarOrder::getGarOrderId).collect(Collectors.toSet());
  369 + List<GarOrderEvaluate> garOrderEvaluates = garOrderEvaluateService.countIdGroupByOrderId(orderIds, type);
  370 + if (CollectionUtils.isEmpty(garOrderEvaluates)) {
  371 + return orders;
  372 + }
  373 +
  374 + return orders.stream().map(o -> {
  375 + if(Objects.nonNull(o)){
  376 + Optional<GarOrderEvaluate> optional = garOrderEvaluates.stream().filter(go->Objects.equals(go.getGarOrderId(),o.getGarOrderId())).findFirst();
  377 + if(optional.isPresent()){
  378 + o.setHaveEvaluateOfClient(optional.get().getCountTheNumber()>0?1:0);
  379 + }
  380 + }
  381 + return o;
  382 + }).collect(Collectors.toList());
  383 + }
  384 +
355 @Override 385 @Override
356 @Transactional(rollbackFor = Exception.class) 386 @Transactional(rollbackFor = Exception.class)
357 public String updateOrder(OrderUpdateDto dto) { 387 public String updateOrder(OrderUpdateDto dto) {
trash-garbage/src/main/java/com/trash/garbage/service/impl/GarUserServiceImpl.java
@@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest; @@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
17 17
18 import com.trash.disposalSite.domain.DisposalSite; 18 import com.trash.disposalSite.domain.DisposalSite;
19 import com.trash.disposalSite.service.IDisposalSiteService; 19 import com.trash.disposalSite.service.IDisposalSiteService;
  20 +import com.trash.garbage.utils.SMSUtils;
20 import org.apache.commons.codec.binary.Base64; 21 import org.apache.commons.codec.binary.Base64;
21 import org.springframework.beans.factory.annotation.Autowired; 22 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.security.core.authority.SimpleGrantedAuthority; 23 import org.springframework.security.core.authority.SimpleGrantedAuthority;
@@ -73,6 +74,9 @@ public class GarUserServiceImpl extends ServiceImpl&lt;GarUserMapper, GarUser&gt; @@ -73,6 +74,9 @@ public class GarUserServiceImpl extends ServiceImpl&lt;GarUserMapper, GarUser&gt;
73 @Resource 74 @Resource
74 private WxConfig wxConfig; 75 private WxConfig wxConfig;
75 76
  77 + @Resource
  78 + private SMSUtils smsUtils;
  79 +
76 @Autowired 80 @Autowired
77 private GarAddressService garAddressService; 81 private GarAddressService garAddressService;
78 82
trash-garbage/src/main/resources/mapper/GarOrderEvaluateMapper.xml
@@ -36,4 +36,12 @@ @@ -36,4 +36,12 @@
36 #{item} 36 #{item}
37 </foreach> 37 </foreach>
38 </select> 38 </select>
  39 + <select id="countIdGroupByOrderId" resultType="com.trash.garbage.pojo.domain.GarOrderEvaluate">
  40 + select count(gar_order_id) countTheNumber,gar_order_id from gar_order_evaluate WHERE
  41 + gar_order_id IN
  42 + <foreach collection="list" item="item" separator="," open="(" close=")">
  43 + #{item}
  44 + </foreach>
  45 + AND gar_evaluate_target = #{type} GROUP BY gar_order_id
  46 + </select>
39 </mapper> 47 </mapper>