Pu Zhibing
2025-02-14 5228e24ff93fae148db40c44d9deb8e93110c6eb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.dao.OrderEvaluateMapper;
import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper;
import com.stylefeng.guns.modular.system.model.OrderEvaluate;
import com.stylefeng.guns.modular.system.model.SensitiveWords;
import com.stylefeng.guns.modular.system.service.IOrderEvaluateService;
import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
import com.stylefeng.guns.modular.system.util.DateUtil;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
 
 
@Service
public class OrderEvaluateServiceImpl extends ServiceImpl<OrderEvaluateMapper, OrderEvaluate> implements IOrderEvaluateService {
 
    @Resource
    private OrderEvaluateMapper orderEvaluateMapper;
 
    @Autowired
    private IOrderTaxiService orderTaxiService;
 
    @Resource
    private SensitiveWordsMapper sensitiveWordsMapper;
 
    @Autowired
    private ISystemNoticeService systemNoticeService;
 
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
 
    @Autowired
    private IOrderCrossCityService orderCrossCityService;
    
    @Autowired
    private IOrderLogisticsService orderLogisticsService;
 
 
 
 
 
    /**
     * 添加评价数据
     * @param orderId
     * @param orderType
     * @param fraction
     * @param content
     * @throws Exception
     */
    @Override
    public ResultUtil saveData(Integer orderId, Integer orderType, Integer fraction, String content, Integer language) throws Exception {
        if(ToolUtil.isNotEmpty(content)){
            if(null != content && content.length() > 500){
                return ResultUtil.error(language == 1 ? "评价内容过长" : language == 2 ? "Rating-content is overlong." : "Le contenu de l’évaluation est trop long.");
            }
            List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null);
            List<String> list = Arrays.asList(content.split(" "));
            for(SensitiveWords s : sensitiveWords){
                List<String> str = new ArrayList<>();
                String lowerCase = s.getContent().toLowerCase();
                for (String s1 : list) {
                    if(lowerCase.equals(s1.toLowerCase())){
                        str.add("***");
                    }else{
                        str.add(s1);
                    }
                }
                list = str;
            }
            content = list.stream().collect(Collectors.joining(" "));
        }
        OrderEvaluate orderEvaluate = new OrderEvaluate();
        Integer driverId = null;
        Integer uid = null;
        switch (orderType){
            case 1:
                OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
                driverId = orderPrivateCar.getDriverId();
                uid = orderPrivateCar.getUserId();
                break;
            case 2:
                OrderTaxi orderTaxi = orderTaxiService.selectById(orderId);
                driverId = orderTaxi.getDriverId();
                uid = orderTaxi.getUserId();
                break;
            case 3:
                OrderCrossCity orderCrossCity = orderCrossCityService.selectById(orderId);
                driverId = orderCrossCity.getDriverId();
                uid = orderCrossCity.getUserId();
                break;
            case 4:
                OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId);
                driverId = orderLogistics.getDriverId();
                uid = orderLogistics.getUserId();
                break;
        }
 
        orderEvaluate.setOrderId(orderId);
        orderEvaluate.setDriverId(driverId);
        orderEvaluate.setOrderType(orderType);
        orderEvaluate.setFraction(fraction);
        orderEvaluate.setContent(content);
        orderEvaluate.setInsertTime(new Date());
        orderEvaluate.setUserId(uid);
        this.insert(orderEvaluate);
 
        systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功添加订单评价,谢谢使用!" : language == 2 ? "You've added the rating successfully, thank you for using I-GO" : "Vous avez ajouté l’évaluation avec succès, merci d’utiliser I-GO", uid, 1);
        return ResultUtil.success(orderEvaluate.getId());
    }
 
 
    /**
     * 获取司机的历史评价数据
     * @param driverId
     * @return
     * @throws Exception
     */
    @Override
    public List<Map<String, Object>> queryOrderEvaluate(Integer language, Integer driverId, Integer pageNum, Integer size) throws Exception {
        pageNum = (pageNum - 1) * size;
        List<Map<String, Object>> list = orderEvaluateMapper.queryOrderEvaluate(driverId, pageNum, size);
        for (Map<String, Object> map : list) {
            if(null != map.get("time")){
                String time = map.get("time").toString();
                map.put("time", DateUtil.conversionFormat(language, time));
            }
        }
        return list;
    }
 
 
    @Override
    public Double queryDriverScore(Integer driverId) throws Exception {
        return this.baseMapper.queryDriverScore(driverId);
    }
}