| | |
| | | @Override |
| | | public void sendActivityEmail() { |
| | | try { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | List<UserActivityDiscount1> lis = this.selectList(new EntityWrapper<UserActivityDiscount1>().eq("enable", 2).last(" and DATE_FORMAT(startTime, '%Y-%m-%d') = '" + sdf.format(new Date()) + "'")); |
| | | List<UserActivityDiscount1> lis = this.selectList(new EntityWrapper<UserActivityDiscount1>().eq("enable", 2) |
| | | .last(" and now() >= startTime and now() < ADDDATE(startTime,INTERVAL 1 MINUTE)")); |
| | | if(lis.size() > 0){ |
| | | List<TUser> tUsers = userService.selectList(new EntityWrapper<TUser>().ne("flag", 3).eq("state", 1)); |
| | | for (UserActivityDiscount1 uad : lis) { |
| | |
| | | Document document1 = Jsoup.parse(new File(path1), "UTF-8"); |
| | | document1.getElementById("chinese").remove(); |
| | | document1.getElementById("french").remove(); |
| | | document1.getElementsByTag("title").get(0).text("I-GO Discount activity"); |
| | | document1.getElementsByTag("title").get(0).text("Discount activities"); |
| | | Element english_user = document1.getElementById("english_user"); |
| | | english_user.text("Hello " + user.getNickName() + ","); |
| | | Element english_ride = document1.getElementById("english_ride"); |
| | | english_ride.text("Discount for I-GO " + key); |
| | | Element english_discount = document1.getElementById("english_discount"); |
| | | english_discount.text(" Enjoy " + aDouble + "% off your trip fare."); |
| | | EmailUtil.send(user.getEmail(), "I-GO Discount activity", document1.html()); |
| | | EmailUtil.send(user.getEmail(), "Discount activities", document1.html()); |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | |
| | | fileWriter.write(document1.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/discount_" + randomString + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf(fileInputStream, "IGO", fileOutputStream); |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/discount_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(user.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName("I-GO Discount activity"); |
| | | tEmail.setName("Discount activities"); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(2,i)); |