ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TReportLossController.java
@@ -182,17 +182,6 @@ fileWriter.write(document.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/reportLossResult_" + 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/reportLossResult_" + randomString + ".html"; TEmail tEmail = new TEmail(); ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/SysCouponActivityController.java
@@ -13,11 +13,16 @@ import com.stylefeng.guns.core.util.DateUtil; import com.stylefeng.guns.core.util.SinataUtil; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.system.model.SysCouponRecord; import com.stylefeng.guns.modular.system.model.TUser; import com.stylefeng.guns.modular.system.model.UserCouponRecord; import com.stylefeng.guns.modular.system.model.*; import com.stylefeng.guns.modular.system.service.ISysCouponRecordService; import com.stylefeng.guns.modular.system.service.ITUserService; 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.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -26,9 +31,13 @@ import org.springframework.beans.factory.annotation.Autowired; import com.stylefeng.guns.core.log.LogObjectHolder; import org.springframework.web.bind.annotation.RequestParam; import com.stylefeng.guns.modular.system.model.SysCouponActivity; import com.stylefeng.guns.modular.system.service.ISysCouponActivityService; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.text.SimpleDateFormat; import java.util.*; /** @@ -51,6 +60,12 @@ @Autowired private ISysCouponRecordService couponRecordService; @Value("${spring.mail.template-path}") private String templatePath; @Autowired private TEmailService emailService; /** * 跳转到首页 @@ -204,6 +219,7 @@ userCouponRecord.setCouponActivityId(sysCouponActivity.getId()); userCouponRecord.setActivityType(1); //判断发送类型1=全部用户,2=选择用户 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); if(sysCouponActivity.getSendType()==1){ Wrapper wrapper = new EntityWrapper<TUser>(); if(sysCouponActivity.getCompanyType()!=1){ @@ -215,6 +231,15 @@ for (int i=0;i<sysCouponActivity.getNumber();i++){ userCouponRecord.insert(); } String email = user.getEmail(); if(ToolUtil.isNotEmpty(email)){ Date expirationTime = userCouponRecord.getExpirationTime(); String e = com.stylefeng.guns.modular.system.util.DateUtil.conversionFormat(2, sdf.format(expirationTime)); String s = com.stylefeng.guns.modular.system.util.DateUtil.conversionFormat(2, sdf.format(new Date())); sendEmail(user, sysCouponActivity.getNumber(), s, e, userCouponRecord.getFullMoney().doubleValue()); } } sysCouponActivity.setSendUserNum(list.size()); sysCouponActivity.updateById(); @@ -225,7 +250,11 @@ TUser tUser = userService.selectById(userId.getJSONObject(j).getInteger("userId")); String email = tUser.getEmail(); if(ToolUtil.isNotEmpty(email)){ // TODO 发送邮件 Date expirationTime = userCouponRecord.getExpirationTime(); String e = com.stylefeng.guns.modular.system.util.DateUtil.conversionFormat(2, sdf.format(expirationTime)); String s = com.stylefeng.guns.modular.system.util.DateUtil.conversionFormat(2, sdf.format(new Date())); sendEmail(tUser, sysCouponActivity.getNumber(), s, e, userCouponRecord.getFullMoney().doubleValue()); } userCouponRecord.setUserId(userId.getJSONObject(j).getInteger("userId")); for (int i=0;i<sysCouponActivity.getNumber();i++){ @@ -239,6 +268,65 @@ } } public void sendEmail(TUser userInfo1, Integer num, String startTime, String endTime, Double fullMoney){ try { if(ToolUtil.isNotEmpty(userInfo1.getEmail())){ String path1 = templatePath + "user/coupon.html"; Document document1 = Jsoup.parse(new File(path1), "UTF-8"); document1.getElementById("chinese").remove(); document1.getElementById("french").remove(); document1.getElementsByTag("title").get(0).text("Coupon is in"); Element english_user = document1.getElementById("english_user"); english_user.text("Hello " + userInfo1.getNickName() + ","); Element english_number = document1.getElementById("english_number"); english_number.text("You have received " + num + " coupons"); Element english_date = document1.getElementById("english_date"); english_date.text("You could use them from " + startTime + " to " + endTime); Element english_remark = document1.getElementById("english_remark"); english_remark.text("NB! Coupon is valid only for the trip fare not less than GHS " + fullMoney + " per ride."); EmailUtil.send(userInfo1.getEmail(), "Coupon is in", document1.html()); //开始生成pdf收据和html收据 File file = new File("/usr/local/nginx/html/files/html/"); if(!file.exists()){ file.mkdirs(); } String randomString = ToolUtil.getRandomString(10); file = new File("/usr/local/nginx/html/files/html/coupon_" + randomString + ".html"); if(!file.exists()){ file.createNewFile(); } FileWriter fileWriter = new FileWriter(file); fileWriter.write(document1.html()); fileWriter.flush(); fileWriter.close(); String link ="http://182.160.16.251:81/files/html/coupon_" + randomString + ".html"; TEmail tEmail = new TEmail(); tEmail.setLink(link); tEmail.setUserId(userInfo1.getId()); tEmail.setType(1); tEmail.setName("Coupon is in"); tEmail.setCreateTime(new Date()); int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; tEmail.setWeek(EmailUtil.getWeek(2,i)); boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); if(am){ tEmail.setAmOrPm("AM"); }else { tEmail.setAmOrPm("PM"); } emailService.insert(tEmail); } }catch (Exception e){ e.printStackTrace(); } } /** * 删除 */ ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TCarController.java
@@ -634,7 +634,7 @@ document.getElementById("rewardToday1").remove(); document.getElementById("driverAudit1").remove(); document.getElementsByTag("title").get(0).text("Vehicle audit notice"); document.getElementsByTag("title").get(0).text(2 == finalTCar.getAuthState() ? "Vehicle is verified and qualified" : "Vehicle is not verified and qualified"); Element car_audit1_user = document.getElementById("car_audit1_user"); car_audit1_user.text("Hello " + tDriver.getFirstName() + " " + tDriver.getLastName() + ","); Element car_audit1_content = document.getElementById("car_audit1_content"); @@ -643,7 +643,7 @@ }else{ car_audit1_content.text("Sorry, your vehicle application was not approved. The reason for the failure is: incomplete filling of vehicle information."); } EmailUtil.send(tDriver.getEmail(), "Vehicle audit notice", document.html()); EmailUtil.send(tDriver.getEmail(), 2 == finalTCar.getAuthState() ? "Vehicle is verified and qualified" : "Vehicle is not verified and qualified", document.html()); }catch (Exception e){ e.printStackTrace(); } ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TComplaintController.java
@@ -154,12 +154,12 @@ Document document = Jsoup.parse(new File(path), "UTF-8"); document.getElementById("chinese").remove(); document.getElementById("french").remove(); document.getElementsByTag("title").get(0).text("Complain against driver"); document.getElementsByTag("title").get(0).text("Solutions for complaints"); Element english_user = document.getElementById("english_user"); english_user.text("Hello " + tUser.getNickName() + ","); Element english_content = document.getElementById("english_content"); english_content.text(handleResult); EmailUtil.send(tUser.getEmail(), "Complain against driver feedback", document.html()); EmailUtil.send(tUser.getEmail(), "Solutions for complaints", document.html()); //开始生成pdf收据和html收据 File file = new File("/usr/local/nginx/html/files/html/"); if(!file.exists()){ @@ -174,24 +174,13 @@ fileWriter.write(document.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/complaintResult_" + 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/complaintResult_" + randomString + ".html"; TEmail tEmail = new TEmail(); tEmail.setLink(link); tEmail.setUserId(tUser.getId()); tEmail.setType(1); tEmail.setName("Complain against driver feedback"); tEmail.setName("Solutions for complaints"); tEmail.setCreateTime(new Date()); int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; tEmail.setWeek(EmailUtil.getWeek(2,i)); ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -608,7 +608,7 @@ document.getElementById("rewardToday1").remove(); document.getElementById("carAudit1").remove(); document.getElementsByTag("title").get(0).text("Notice of driver registration application"); document.getElementsByTag("title").get(0).text(1 == authState ? "Driver is verified and qualified" : "Driver is not verified and qualified"); Element driver_audit1_user = document.getElementById("driver_audit1_user"); driver_audit1_user.text("Hello " + tDriver.getFirstName() + " " + tDriver.getLastName() + ","); Element driver_audit1_content = document.getElementById("driver_audit1_content"); @@ -617,7 +617,7 @@ }else{ driver_audit1_content.text("I'm sorry, your application was rejected. Reason for rejection: Incomplete filling in personal information."); } EmailUtil.send(tDriver.getEmail(), "Notice of driver registration application", document.html()); EmailUtil.send(tDriver.getEmail(), 1 == authState ? "Driver is verified and qualified" : "Driver is not verified and qualified", document.html()); }catch (Exception e){ e.printStackTrace(); } ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TFeedbackController.java
@@ -184,7 +184,7 @@ Document document = Jsoup.parse(new File(path), "UTF-8"); document.getElementById("chinese").remove(); document.getElementById("french").remove(); document.getElementsByTag("title").get(0).text("Feedback Processing Results"); document.getElementsByTag("title").get(0).text("Solutions for feedback"); Element english_user = document.getElementById("english_user"); english_user.text("Hello " + userInfo.getNickName() + ","); Element english_content = document.getElementById("english_content"); @@ -205,24 +205,13 @@ fileWriter.write(document.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/feedbackResult_" + 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/feedbackResult_" + randomString + ".html"; TEmail tEmail = new TEmail(); tEmail.setLink(link); tEmail.setUserId(userInfo.getId()); tEmail.setType(1); tEmail.setName("Feedback Processing Results"); tEmail.setName("Solutions for feedback"); tEmail.setCreateTime(new Date()); int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; tEmail.setWeek(EmailUtil.getWeek(2,i)); ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TOrderLogisticsController.java
@@ -105,9 +105,11 @@ TOrderLogistics tOrderLogistics = tOrderLogisticsService.selectById(tOrderLogisticsId); //修改之前司机状态 -- 空闲 TDriver driver = itDriverService.selectById(tOrderLogistics.getDriverId()); driver.setState(2); itDriverService.updateById(driver); if(null != tOrderLogistics.getDriverId()){ TDriver driver = itDriverService.selectById(tOrderLogistics.getDriverId()); driver.setState(2); itDriverService.updateById(driver); } tOrderLogistics.setState(10); tOrderLogisticsService.updateById(tOrderLogistics); ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserActivityDiscount1ServiceImpl.java
@@ -296,8 +296,8 @@ @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) { @@ -320,14 +320,14 @@ 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()){ @@ -342,24 +342,13 @@ 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)); ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/UserActivityServiceImpl.java
@@ -137,7 +137,7 @@ } //添加打折活动 if(SinataUtil.isNotEmpty(discountSpecial) && SinataUtil.isNotEmpty(discountTaxi) && /*SinataUtil.isNotEmpty(discountTaxi) &&*/ SinataUtil.isNotEmpty(discountLogistics)){ UserActivityDiscount1 userActivityDiscount1 = new UserActivityDiscount1(); userActivityDiscount1.setUserActivityId(userActivity.getId()); ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/DateUtil.java
@@ -1120,7 +1120,170 @@ return defaultStartDate + "," + defaultEndDate; } /** * 多语言时间日期格式转换 * @param language 语言编号 * @param datetime 标准格式化时间 yyyy-MM-dd * @return */ public static String conversionFormat(Integer language, String datetime){ String time = ""; String date = datetime; int index = datetime.indexOf(" "); if(index != -1){ time = datetime.substring(datetime.indexOf(" ") + 1); date = datetime.substring(0, datetime.indexOf(" ")); } String[] split = date.split("-"); switch (language){ case 2: split[1] = englishMonth(Integer.valueOf(split[1])); datetime = split[1] + " " + split[2] + ", " + split[0]; if(index != -1){ datetime += " " + time; } break; case 3: split[1] = frenchMonth(Integer.valueOf(split[1])); datetime = split[2] + " " + split[1] + " " + split[0]; if(index != -1){ datetime += " " + time; } break; } return datetime; } public static String conversionFormat1(Integer language, String datetime){ String time = ""; String date = datetime; int index = datetime.indexOf(" "); if(index != -1){ time = datetime.substring(datetime.indexOf(" ") + 1); date = datetime.substring(0, datetime.indexOf(" ")); } String[] split = date.split("-"); switch (language){ case 2: split[1] = englishMonth(Integer.valueOf(split[0])); datetime = split[0] + " " + split[1]; if(index != -1){ datetime += " " + time; } break; case 3: split[1] = frenchMonth(Integer.valueOf(split[0])); datetime = split[1] + " " + split[0]; if(index != -1){ datetime += " " + time; } break; } return datetime; } public static String frenchMonth(Integer month){ String m = ""; switch (month){ case 1: m = "Janvier"; break; case 2: m = "Février"; break; case 3: m = "Mars"; break; case 4: m = "Avril"; break; case 5: m = "Mai"; break; case 6: m = "Juin"; break; case 7: m = "Juillet"; break; case 8: m = "Août"; break; case 9: m = "Septembre"; break; case 10: m = "Octobre"; break; case 11: m = "Novembre"; break; case 12: m = "Décembre"; break; default: m = ""; break; } return m; } public static String englishMonth(Integer month){ String m = ""; switch (month){ case 1: m = "January"; break; case 2: m = "February"; break; case 3: m = "March"; break; case 4: m = "April"; break; case 5: m = "May"; break; case 6: m = "June"; break; case 7: m = "July"; break; case 8: m = "August"; break; case 9: m = "September"; break; case 10: m = "October"; break; case 11: m = "November"; break; case 12: m = "December"; break; default: m = ""; break; } return m; } public static void main(String[] args) throws ParseException { ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
@@ -38,6 +38,7 @@ @Scheduled(fixedRate = 1000 * 60) public void taskMinute(){ try { userActivityDiscount1Service.sendActivityEmail(); } catch (Exception e) { e.printStackTrace(); } @@ -50,7 +51,6 @@ @Scheduled(cron = "0 0 0 * * *") public void taskDay(){ try { userActivityDiscount1Service.sendActivityEmail(); }catch (Exception e){ e.printStackTrace(); }