puzhibing
2023-03-15 79962435853baf5a28e08461f46a831fffa1a4b0
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
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.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.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.Date;
import java.util.List;
import java.util.Map;
 
 
@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;
 
 
 
 
 
    /**
     * 添加评价数据
     * @param orderId
     * @param orderType
     * @param fraction
     * @param content
     * @throws Exception
     */
    @Override
    public ResultUtil saveData(Integer orderId, Integer orderType, Integer fraction, String content) throws Exception {
        if(ToolUtil.isNotEmpty(content)){
            if(null != content && content.length() > 500){
                return ResultUtil.error("评价内容过长");
            }
            List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null);
            for(SensitiveWords s : sensitiveWords){
                content = content.replaceAll(s.getContent(), "***");
            }
        }
        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;
        }
 
        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, "您已成功添加订单评价,谢谢使用!", uid, 1);
        return ResultUtil.success(orderEvaluate.getId());
    }
 
 
    /**
     * 获取司机的历史评价数据
     * @param driverId
     * @return
     * @throws Exception
     */
    @Override
    public List<Map<String, Object>> queryOrderEvaluate(Integer driverId, Integer pageNum, Integer size) throws Exception {
        pageNum = (pageNum - 1) * size;
        return orderEvaluateMapper.queryOrderEvaluate(driverId, pageNum, size);
    }
}