luodangjia
2024-10-15 a41e23347029bf69a3f59438749658252de81d2e
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java
@@ -2,6 +2,8 @@
import cn.hutool.db.DaoTemplate;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -17,6 +19,7 @@
import com.ruoyi.chargingPile.api.model.Site;
import com.ruoyi.chargingPile.api.vo.TAccountingStrategyVO;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.HttpUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
@@ -120,12 +123,18 @@
        List<Integer> tagIds = tagList.stream().map(TEvaluationTagVO::getId).collect(Collectors.toList());
        // 统计标签使用数量
        List<TEvaluationTagVO> counts = orderEvaluateTagMapper.getCountByTagIds(tagIds);
        List<Integer> ids = counts.stream().map(TEvaluationTagVO::getId).collect(Collectors.toList());
        tagList.forEach(tag -> {
            counts.forEach(count -> {
                if (tag.getId().equals(count.getId())) {
                    tag.setTagCount(count.getTagCount());
                }
            });
            if(ids.contains(tag.getId())){
                counts.forEach(count -> {
                    if (tag.getId().equals(count.getId())) {
                        tag.setTagCount(count.getTagCount());
                    }
                });
            }else{
                tag.setTagCount(0);
            }
        });
        tagList = tagList.stream().sorted(Comparator.comparing(TEvaluationTagVO::getTagCount).reversed()).collect(Collectors.toList());
        // 统计有图,好评,中差评数量
@@ -221,9 +230,11 @@
        List<GetOrderEvaluatePageListDTO> list = this.baseMapper.getPageList(pageList, evaluationTagIds, pageInfo);
        for (GetOrderEvaluatePageListDTO dto : list) {
            TAppUser appUser = appUserClient.getUserById(dto.getAppUserId()).getData();
            dto.setAvatar(appUser.getAvatar());
            String phone = appUser.getPhone();
            dto.setPhone(phone.substring(0, 3) + "****" + phone.substring(6));
            if(null != appUser){
                dto.setAvatar(appUser.getAvatar());
                String phone = appUser.getPhone();
                dto.setPhone(phone.substring(0, 3) + "****" + phone.substring(6));
            }
            Site site = siteClient.getSiteByIds(Arrays.asList(dto.getSiteId())).getData().get(0);
            dto.setSiteName(site.getName());
            List<TOrderEvaluateTag> tOrderEvaluateTags = orderEvaluateTagMapper.selectList(new LambdaQueryWrapper<TOrderEvaluateTag>().eq(TOrderEvaluateTag::getOrderEvaluateId, dto.getId()));
@@ -259,6 +270,37 @@
            TChargingOrder chargingOrder = chargingOrderService.getById(query.getOrderId());
            orderEvaluate.setAppUserCarId(chargingOrder.getAppUserCarId());
        }
        TAppUser appUser = appUserClient.getUserById(userid).getData();
        //检测敏感词
        String content = orderEvaluate.getContent();
        String token = appUserClient.getWXToken().getData();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("content", content);
        jsonObject.put("version", 2);
        jsonObject.put("scene", 2);
        jsonObject.put("openid", appUser.getWxOpenid());
        String post = HttpUtils.post("https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + token, jsonObject.toString());
        JSONObject object = JSONObject.parseObject(post);
        Integer errcode = object.getInteger("errcode");
        if(0 != errcode){
            throw new RuntimeException(object.getString("errmsg"));
        }
        JSONArray detail = object.getJSONArray("detail");
        for (int i = 0; i < detail.size(); i++) {
            JSONObject jsonObject1 = detail.getJSONObject(i);
            Integer errcode1 = jsonObject1.getInteger("errcode");
            if(0 == errcode1){
                String suggest = jsonObject1.getString("suggest");
                Integer label = jsonObject1.getInteger("label");
                String keyword = jsonObject1.getString("keyword");
                Integer prob = jsonObject1.getInteger("prob");
                if(("risky".equals(suggest) || "review".equals(suggest)) && 100 != label && StringUtils.isNotEmpty(keyword) && 80 <= prob){
                    content = content.replaceAll(keyword, "***");
                }
            }
        }
        orderEvaluate.setContent(content);
        this.save(orderEvaluate);
    
        List<Integer> tagIds = query.getTagIds();
@@ -276,7 +318,6 @@
            //积分
            Integer num1 = JSON.parseObject(credit).getInteger("num1");
            if(null != num1 && 0 < num1){
                TAppUser appUser = appUserClient.getUserById(userid).getData();
                if(null != appUser.getVipId()){
                    TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                    Integer doubleIntegration = vip.getDoubleIntegration();
@@ -296,6 +337,7 @@
                appUserIntegralChange.setHistoricalIntegral(points);
                appUserIntegralChange.setCurrentIntegral(points + num1);
                appUserIntegralChange.setCreateTime(LocalDateTime.now());
                appUserIntegralChange.setOrderCode(orderEvaluate.getId().toString());
                appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange);
            }
        }