| | |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; |
| | | import com.stylefeng.guns.modular.system.warpper.*; |
| | | import com.stylefeng.guns.modular.taxi.model.TransactionDetails; |
| | | import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; |
| | | import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.MediaType; |
| | |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class UserInfoController { |
| | | |
| | | Logger log = LoggerFactory.getLogger(UserInfoController.class); |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | @Autowired |
| | | private ITransactionDetailsService transactionDetailsService; |
| | | @Autowired |
| | | private IPaymentRecordService paymentRecordService; |
| | | |
| | | @Autowired |
| | | private FleetEngineUtil fleetEngineUtil; |
| | | |
| | | |
| | | |
| | |
| | | return ResultUtil.paranErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 短信回调通知 |
| | | * @param request |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/sendCellulantMessageCallback") |
| | | public void sendCellulantMessageCallback(HttpServletRequest request){ |
| | | try { |
| | | StringBuilder sb = new StringBuilder(); |
| | | InputStream inputStream = request.getInputStream(); |
| | | String s; |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); |
| | | while ((s = in.readLine()) != null) { |
| | | sb.append(s); |
| | | } |
| | | in.close(); |
| | | inputStream.close(); |
| | | log.info("短信通知回调:" + sb.toString()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/sedEmail") |
| | | @ApiOperation(value = "获取邮箱验证码【1.0】", tags = {"用户端-登录"}, notes = "") |
| | |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Verification email"); |
| | | document.getElementsByTag("title").get(0).text("Verification code"); |
| | | Element user_chinese = document.getElementById("user_english"); |
| | | user_chinese.text("Hello " + nickName + ","); |
| | | Element content_english = document.getElementById("content_english"); |
| | |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | document.getElementsByTag("title").get(0).text("Courriel de vérification"); |
| | | document.getElementsByTag("title").get(0).text("Code de validation"); |
| | | Element user_french = document.getElementById("user_french"); |
| | | user_french.text("Bonjour " + nickName + ","); |
| | | Element content_french = document.getElementById("content_french"); |
| | | content_french.text(authCode); |
| | | } |
| | | EmailUtil.send(email, language == 1 ? "邮箱验证" : language == 2 ? "Verification mailbox" : "Courriel de vérification", document.html()); |
| | | EmailUtil.send(email, language == 1 ? "邮箱验证" : language == 2 ? "Verification code" : "Code de validation", document.html()); |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | File file = new File("/home/igotechgh/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | String randomString = ToolUtil.getRandomString(10); |
| | | file = new File("/usr/local/nginx/html/files/html/mainbox_" + randomString + ".html"); |
| | | file = new File("/home/igotechgh/nginx/html/files/html/mainbox_" + randomString + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | |
| | | 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/mainbox_" + 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/mainbox_" + randomString + ".html"; |
| | | String link ="https://igo.i-go.group/files/html/mainbox_" + randomString + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(uid); |
| | | tEmail.setType(1); |
| | | tEmail.setName(language == 1 ? "邮箱验证" : language == 2 ? "Verification email" : "Courriel de vérification"); |
| | | tEmail.setName(language == 1 ? "邮箱验证" : language == 2 ? "Verification code" : "Code de validation"); |
| | | 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?"AM":"Dans la matinée"); |
| | | tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin"); |
| | | }else { |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"PM":"après-midi"); |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | } |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<?> getEmailList(HttpServletRequest request){ |
| | | public ResultUtil<List<EmailWarpper>> getEmailList(Integer language, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(emailService.selectList(new EntityWrapper<TEmail>().eq("userId",uid).eq("type",1).orderBy("createTime",false))); |
| | | List<TEmail> tEmails = emailService.selectList(new EntityWrapper<TEmail>().eq("userId", uid).eq("type", 1).orderBy("createTime", false)); |
| | | List<EmailWarpper> list = new ArrayList<>(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | for (TEmail tEmail : tEmails) { |
| | | EmailWarpper warpper = new EmailWarpper(); |
| | | BeanUtils.copyProperties(tEmail, warpper); |
| | | warpper.setCreateTime(DateUtil.conversionFormat(language, sdf.format(tEmail.getCreateTime()))); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(tEmail.getCreateTime())-1; |
| | | warpper.setWeek(EmailUtil.getWeek(language,i)); |
| | | list.add(warpper); |
| | | } |
| | | return ResultUtil.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | Map<String, Object> map = userInfoService.queryUser(language, phone); |
| | | if(null != map){ |
| | | return ResultUtil.success(UserInfoWarpper.getUserInfoWarpper(map)); |
| | | }else{ |
| | | return ResultUtil.error(language == 1 ? "此账号不存在" : language == 2 ? "The account does not exist" : "Ce compte n’existe pas"); |
| | | } |
| | | return ResultUtil.success(new JSONObject()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("/base/user/image") |
| | | public String image(@RequestPart("file") MultipartFile file) { |
| | | public ResultUtil image(@RequestPart("file") MultipartFile file) { |
| | | try { |
| | | String pictureName = OBSUploadUtil.inputStreamUpload(file); |
| | | return pictureName; |
| | | } catch (IOException e1) { |
| | | return null; |
| | | String pictureName = GoogleCloudStorageUtil.upload(file); |
| | | return ResultUtil.success(pictureName); |
| | | } catch (Exception e1) { |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 用户查询充值记录 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/user/queryRechargeRecord") |
| | | @ApiOperation(value = "用户查询充值记录", tags = {"用户端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "页条数", name = "size", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "语言", name = "language", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil queryRechargeRecord(Integer pageNum, Integer size,Integer language,HttpServletRequest request){ |
| | | try { |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | RechargeRecordWarpper rechargeRecordWarpper = new RechargeRecordWarpper(); |
| | | List<Map<String,Object>> paymentRecord = paymentRecordService.queryRechargeRecord(uid, pageNum, size); |
| | | for (Map<String, Object> map : paymentRecord) { |
| | | if(null != map.get("insertTime")){ |
| | | String time = map.get("insertTime").toString(); |
| | | map.put("insertTime", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | // 分装返回充值记录实体 |
| | | List<TransactionDetailsWarpper> transactionDetailsWarpper = TransactionDetailsWarpper.getTransactionDetailsWarpper(paymentRecord); |
| | | |
| | | // 查询充值金额总和 |
| | | double sum = paymentRecordService.queryRechargeMoneySum(uid); |
| | | rechargeRecordWarpper.setSum(sum); |
| | | rechargeRecordWarpper.setTransactionDetailsWarpper(transactionDetailsWarpper); |
| | | return ResultUtil.success(rechargeRecordWarpper); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 下载pdf |
| | | * @param orderId |
| | | * @param orderType |
| | |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | if(orderType == 1){ |
| | | fileInputStream = new FileInputStream(new File("/usr/local/nginx/html/files/pdf/ride_receipt_" + orderId + ".pdf")); |
| | | fileInputStream = new FileInputStream(new File("/home/igotechgh/nginx/html/files/pdf/ride_receipt_" + orderId + ".pdf")); |
| | | } |
| | | if(orderType == 4){ |
| | | fileInputStream = new FileInputStream(new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf")); |
| | | fileInputStream = new FileInputStream(new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf")); |
| | | } |
| | | BufferedInputStream bf = new BufferedInputStream(fileInputStream); |
| | | outputStream = response.getOutputStream(); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/user/getFleetEngineAuth") |
| | | @ApiOperation(value = "获取google地图授权token", tags = {"用户端-个人中心"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "行程id", name = "tripId", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<Map<String, Object>> getFleetEngineAuth(String tripId, HttpServletRequest request){ |
| | | try { |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | Map<String, Object> s = fleetEngineUtil.fleetEngineAuth(1, tripId); |
| | | return ResultUtil.success(s); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/user/textToSpeech") |
| | | public String textToSpeech(String languageCode, String text, String fileName){ |
| | | try { |
| | | String s = TextToSpeechUtil.create(languageCode, text, fileName + ".mp3"); |
| | | //定时任务删除语音文件 |
| | | new Timer().schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | // 使用Runtime执行命令 |
| | | Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName + ".mp3"); |
| | | // 读取命令的输出 |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | System.out.println(line); |
| | | } |
| | | // 等待命令执行完成 |
| | | process.waitFor(); |
| | | // 关闭流 |
| | | reader.close(); |
| | | } catch (IOException | InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }, 30000); |
| | | return s; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |