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, Integer language) throws Exception {
|
if(ToolUtil.isNotEmpty(content)){
|
if(null != content && content.length() > 500){
|
return ResultUtil.error(language == 1 ? "评价内容过长" : language == 2 ? "The evaluation is too long" : "Contenu trop long de l’évaluation");
|
}
|
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, language == 1 ? "您已成功添加订单评价,谢谢使用!" : language == 2 ? "You have successfully added the order evaluation, thank you for using!" : "Vous avez ajouté une évaluation de commande avec succès. Merci d’utiliser!", 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);
|
}
|
|
|
@Override
|
public Double queryDriverScore(Integer driverId) throws Exception {
|
return this.baseMapper.queryDriverScore(driverId);
|
}
|
}
|