| | |
| | | import com.stylefeng.guns.modular.system.dao.SensitiveWordsMapper; |
| | | import com.stylefeng.guns.modular.system.model.Complaint; |
| | | import com.stylefeng.guns.modular.system.model.SensitiveWords; |
| | | import com.stylefeng.guns.modular.system.model.TEmail; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.service.IComplaintService; |
| | | import com.stylefeng.guns.modular.system.service.ISystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.service.IUserInfoService; |
| | | import com.stylefeng.guns.modular.system.service.TEmailService; |
| | | import com.stylefeng.guns.modular.system.util.EmailUtil; |
| | | import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; |
| | | 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 javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @Service |
| | |
| | | |
| | | @Autowired |
| | | private ISystemNoticeService systemNoticeService; |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void saveData(Integer driverId, String reason, String description, Integer uid) throws Exception { |
| | | public void saveData(Integer orderId, Integer orderType, Integer driverId, String reason, String description, Integer uid, Integer language) throws Exception { |
| | | if(ToolUtil.isNotEmpty(description)){ |
| | | description = description.toLowerCase(); |
| | | List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null); |
| | | for(SensitiveWords s : sensitiveWords){ |
| | | description = description.replaceAll(s.getContent(), "***"); |
| | | for(SensitiveWords s : sensitiveWords) { |
| | | description = description.replaceAll(s.getContent().toLowerCase(), "***"); |
| | | } |
| | | } |
| | | Complaint complaint = new Complaint(); |
| | | complaint.setInsertTime(new Date()); |
| | | complaint.setDriverId(driverId); |
| | | complaint.setReason(reason); |
| | | complaint.setOrderId(orderId); |
| | | complaint.setOrderType(orderType); |
| | | complaint.setDescription(description); |
| | | complaint.setUserId(uid); |
| | | complaint.setIsHandle(0); |
| | | this.insert(complaint); |
| | | |
| | | systemNoticeService.addSystemNotice(1, "您的投诉已提交成功,我们会尽快处理!", uid, 1); |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/complaint.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(language == 1){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("投诉司机"); |
| | | Element chinese_user = document.getElementById("chinese_user"); |
| | | chinese_user.text("您好 " + userInfo.getNickName() + ","); |
| | | } |
| | | if(language == 2){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Complain against driver"); |
| | | Element english_user = document.getElementById("english_user"); |
| | | english_user.text("Hello " + userInfo.getNickName() + ","); |
| | | } |
| | | if(language == 3){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | document.getElementsByTag("title").get(0).text("Porter plainte contre le chauffeur"); |
| | | Element french_user = document.getElementById("french_user"); |
| | | french_user.text("Bonjour " + userInfo.getNickName() + ","); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "投诉司机" : language == 2 ? "Complain against driver" : "Porter plainte contre le chauffeur", document.html()); |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/home/igotechgh/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | String randomString = ToolUtil.getRandomString(10); |
| | | file = new File("/home/igotechgh/nginx/html/files/html/complain_" + randomString + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | String link ="https://igo.i-go.group/files/html/complain_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(uid); |
| | | tEmail.setType(1); |
| | | tEmail.setName(language == 1 ? "投诉司机" : language == 2 ? "Complain against driver" : "Porter plainte contre le chauffeur"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(language,i)); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin"); |
| | | }else { |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | |
| | | } |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您的投诉已提交成功,我们会尽快处理!" : language == 2 ? "Your complaints were submitted successfully, we shall handle it as soon as possible." : "Vos réclamations ont été déposées avec succès, nous les traiterons dans les plus brefs délais.", uid, 1); |
| | | } |
| | | } |