puzhibing
2023-10-08 798a7751d63f4566375ffb018f49b4bc4507ccb3
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReportLossServiceImpl.java
@@ -1,6 +1,7 @@
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;
@@ -9,12 +10,20 @@
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.dao.ReportLossMapper;
import com.stylefeng.guns.modular.system.model.ReportLoss;
import com.stylefeng.guns.modular.system.model.UserInfo;
import com.stylefeng.guns.modular.system.service.IReportLossService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.util.EmailUtil;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.util.Date;
@Service
@@ -32,8 +41,16 @@
    @Autowired
    private IOrderLogisticsService orderLogisticsService;
    @Autowired
    private IUserInfoService userInfoService;
    @Value("${spring.mail.template-path}")
    private String templatePath;
    @Override
    public void addReportLoss(Integer orderType, Integer orderId, String remark, String image) throws Exception {
    public void addReportLoss(Integer orderType, Integer orderId, String remark, String image, Integer language) throws Exception {
        ReportLoss reportLoss = new ReportLoss();
        reportLoss.setImage(image);
        reportLoss.setInsertTime(new Date());
@@ -65,5 +82,43 @@
                break;
        }
        this.insert(reportLoss);
        UserInfo userInfo = userInfoService.selectById(reportLoss.getUserId());
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                        String path = templatePath + "user/reportLoss.html";
                        Document document = Jsoup.parse(new File(path), "UTF-8");
                        if(language == 1){
                            document.getElementById("english").remove();
                            document.getElementById("french").remove();
                            Element english_user = document.getElementById("chinese_user");
                            english_user.text("您好 " + userInfo.getNickName() + ",");
                            EmailUtil.send(userInfo.getEmail(), "物品报失",  document.html());
                        }
                        if(language == 2){
                            document.getElementById("chinese").remove();
                            document.getElementById("french").remove();
                            Element english_user = document.getElementById("english_user");
                            english_user.text("Hello " + userInfo.getNickName() + ",");
                            EmailUtil.send(userInfo.getEmail(), "Report loss of goods",  document.html());
                        }
                        if(language == 3){
                            document.getElementById("chinese").remove();
                            document.getElementById("english").remove();
                            Element english_user = document.getElementById("french_user");
                            english_user.text("Bonjour! " + userInfo.getNickName() + ",");
                            EmailUtil.send(userInfo.getEmail(), "Signaler une perte de marchandises",  document.html());
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }).start();
    }
}