| | |
| | | @Resource |
| | | private RemoteUserService remoteUserService; |
| | | public static void main(String[] args) { |
| | | // LocalDateTime dateTime = LocalDateTime.now(); |
| | | // DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | // String formattedDateTime = dateTime.format(formatter); |
| | | // System.err.println(formattedDateTime); |
| | | // 收件人电子邮箱,TODO 换成自己的收件箱 |
| | | String to = "443237572@qq.com"; |
| | | |
| | | // 发件人电子邮箱,TODO 换成自己的发件箱 |
| | | String from = "13281306557@163.com"; |
| | | |
| | | // 指定发送邮件的主机为 |
| | | String host = "smtp.163.com"; |
| | | |
| | | // 获取系统属性 |
| | | //Properties properties = System.getProperties(); |
| | | Properties properties = new Properties(); |
| | | // 设置邮件服务器 |
| | | properties.setProperty("mail.smtp.host", host); |
| | |
| | | InternetAddress toMail2 = new InternetAddress("443237572@qq.com"); |
| | | //发一个邮箱 |
| | | // message.setRecipient(Message.RecipientType.TO, toMail); |
| | | |
| | | //发多个邮箱 |
| | | Address[] allRecipients = {toMail, toMail2}; |
| | | message.setRecipients(Message.RecipientType.TO, allRecipients); |
| | | |
| | | // Set Subject: 邮件主体 |
| | | message.setSubject("明星电力"); |
| | | |
| | | // 设置消息体 |
| | | message.setSentDate(new Date()); |
| | | |
| | | // 指定为混合关系 |
| | | MimeMultipart msgMultipart = new MimeMultipart("mixed"); |
| | | message.setContent(msgMultipart); |
| | | |
| | | // 邮件信息组装 |
| | | //组装的顺序非常重要,一定要先组装文本域,再组装文件 |
| | | MimeBodyPart htmlPart = new MimeBodyPart(); |
| | | // 组装内容 |
| | | htmlPart.setContent("This is message content", "text/html;charset=UTF-8"); |
| | | msgMultipart.addBodyPart(htmlPart); |
| | | |
| | | // 组装附件 |
| | | MimeBodyPart filePart = new MimeBodyPart(); |
| | | String imageUrl = "http://221.182.45.100:8090/2024-10-10/04-18-09-0466d831fc6365571080.pdf"; |
| | | String imageUrl = "https://xqgwzh.obs.cn-south-1.myhuaweicloud.com/xinquan/b176cf9af35d4773a276e55b7afe3b63.mp4"; |
| | | try { |
| | | // 下载数据 |
| | | URL url = new URL(imageUrl); |
| | | InputStream inputStream = url.openStream(); |
| | | byte[] imageBytes = IOUtils.toByteArray(inputStream); |
| | | |
| | | // 创建临时文件 |
| | | // 截取imageUrl后缀名 |
| | | String fileExtension = imageUrl.substring(imageUrl.lastIndexOf(".")); |
| | |
| | | try (FileOutputStream fos = new FileOutputStream(tempFile)) { |
| | | fos.write(imageBytes); |
| | | } |
| | | |
| | | // 创建 FileDataSource |
| | | FileDataSource fileDataSource = new FileDataSource(tempFile); |
| | | System.out.println("FileDataSource created: " + fileDataSource.getName()); |
| | |
| | | // 查询登录用户邀请了哪些人 |
| | | List<Long> collect = page.getRecords().stream().map(AppUser::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty())return R.ok(PageDTO.empty(page)); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | collect.forEach(id -> stringBuilder.append(id).append(",")); |
| | | // 去除最后一位 |
| | | StringBuilder stringBuilder1 = stringBuilder.deleteCharAt(stringBuilder.length() - 1); |
| | | String[] split = stringBuilder1.toString().split(","); |
| | | for (int i = 0; i < page.getRecords().size(); i++) { |
| | | AppUser appUser = page.getRecords().get(i); |
| | | appUser.setMoney(new BigDecimal(split[i])); |
| | | // 查询该给用户带来收益 |
| | | List<AppUserWalletRecord> list = appUserWalletRecordService.lambdaQuery().eq(AppUserWalletRecord::getAppUserId, userId) |
| | | .eq(AppUserWalletRecord::getChildAppUserId,appUser.getUserId()).list(); |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | for (AppUserWalletRecord appUserWalletRecord : list) { |
| | | if (appUserWalletRecord.getAmount()!=null && appUserWalletRecord.getChangeType() == 1){ |
| | | bigDecimal = bigDecimal.add(appUserWalletRecord.getAmount()); |
| | | } |
| | | } |
| | | appUser.setMoney(bigDecimal); |
| | | |
| | | } |
| | | // 根据佣金金额 从大到小排序 |
| | | page.getRecords().sort((o1, o2) -> o2.getMoney().compareTo(o1.getMoney())); |
| | | return R.ok(PageDTO.of(page, InviteRankListVO.class)); |
| | | } |
| | | @Resource |
| | | private AppUserWalletRecordService appUserWalletRecordService; |
| | | /** |
| | | * 爱心助力榜单-分页 |
| | | * |