From 823b3791ea60888168b277110cfce607e5eed3e4 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期三, 26 二月 2025 17:50:41 +0800 Subject: [PATCH] Merge branch 'xizang-changyun' of https://gitee.com/xiaochen991015/xizang --- ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java | 104 ++++++++++++++++++++++++++ ruoyi-system/src/main/java/com/ruoyi/system/service/TBillDetailService.java | 6 + ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java | 32 ++++++- ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java | 2 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java | 9 +- ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml | 5 ruoyi-common/src/main/java/com/ruoyi/common/config/MailProperties.java | 20 +++++ ruoyi-common/src/main/java/com/ruoyi/common/config/SmsConfig.java | 3 ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java | 3 ruoyi-common/pom.xml | 6 + ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java | 22 +++++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillDetailServiceImpl.java | 9 ++ 12 files changed, 206 insertions(+), 15 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java index 7ecc704..443cedc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java @@ -6,17 +6,19 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.system.dto.*; import com.ruoyi.system.model.TBill; +import com.ruoyi.system.model.TBillDetail; import com.ruoyi.system.query.TBillQuery; +import com.ruoyi.system.service.TBillDetailService; import com.ruoyi.system.service.TBillService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotEmpty; +import java.util.List; /** * <p> @@ -34,7 +36,8 @@ @Autowired TBillService tBillService; - + @Autowired + TBillDetailService tBillDetailService; @PreAuthorize("@ss.hasPermi('system:bill:list')") @@ -52,6 +55,22 @@ tBillService.saveBill(bill); return R.ok(); } + + @ApiOperation("通过ID查找详情") + @GetMapping("getDetailById") + public R<TBillDto> getDetailById(@Validated @NotEmpty String id){ + TBillDto dto = tBillService.getDetailByBillId(id); + if (dto.getBillType().equals("3")){ + List<TBillDetail> details = tBillDetailService.getByBillId(id); + for (TBillDetail detail : details) { + if (detail.getLiveType()==1)dto.setWater(detail); //水费 + else dto.setElect(detail); //电费 + } + } + return R.ok(dto); + } + + @PreAuthorize("@ss.hasPermi('system:bill:checkOfflinePay')") @ApiOperation("确认线下缴费") @PostMapping("checkOfflinePay") @@ -85,5 +104,8 @@ } + + + } diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 33e2a27..16aa070 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -200,7 +200,11 @@ <artifactId>hutool-all</artifactId> <version>5.8.4</version> </dependency> - + <dependency> + <groupId>com.sun.mail</groupId> + <artifactId>javax.mail</artifactId> + <version>1.6.2</version> <!-- 请检查是否有更新的版本 --> + </dependency> </dependencies> </project> \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/MailProperties.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/MailProperties.java new file mode 100644 index 0000000..2e525c6 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/MailProperties.java @@ -0,0 +1,20 @@ +package com.ruoyi.common.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@Data +@ConfigurationProperties(prefix = "mail") +public class MailProperties { + + private String smtpHost="gz-smtp.qcloudmail.com"; + + private Integer smtpPort = 465; + + private String userAddr = "test@xzgtmail.591taxi.cn"; + + private String password = "CY20250226pass"; + + private String userName = "测试"; + +} diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/SmsConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/SmsConfig.java index f689f45..efc3c79 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/SmsConfig.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/SmsConfig.java @@ -10,7 +10,7 @@ import org.springframework.context.annotation.Configuration; @Configuration -@EnableConfigurationProperties(SmsProperties.class) +@EnableConfigurationProperties({SmsProperties.class, MailProperties.class}) @ConditionalOnProperty(value = SmsProperties.ENABLE_KEY,matchIfMissing = true) public class SmsConfig { @@ -33,6 +33,5 @@ // 实例化要请求产品(sms)的client对象,第二个参数是地域信息,可以直接填写字符串ap-guangzhou,支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 return new SmsClient(cred, "ap-guangzhou", clientProfile); } - } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java new file mode 100644 index 0000000..1c9c887 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java @@ -0,0 +1,104 @@ +package com.ruoyi.common.utils; + +import com.ruoyi.common.config.MailProperties; +import com.ruoyi.common.exception.ServiceException; +import com.sun.xml.internal.org.jvnet.mimepull.MIMEMessage; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; +import java.util.Properties; +import javax.mail.*; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; + +@Component +@Slf4j +public class TencentMailUtil { + + @Autowired + MailProperties properties; + + /** + * + * @param emailAddress 邮件接收者email地址 + * @param param 用户房屋地址参数 + */ + public void send(String emailAddress,String param){ + // 配置发送邮件的环境属性 + final Properties props = new Properties(); + // 表示SMTP发送邮件,需要进行身份验证 + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.host", properties.getSmtpHost()); + // 如果使用ssl,则去掉使用25端口的配置,进行如下配置, + props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); + props.put("mail.smtp.socketFactory.port", properties.getSmtpPort()); + props.put("mail.smtp.port", properties.getSmtpPort()); + // 发件人的账号,填写控制台配置的发信地址,比如xxx@xxx.com + props.put("mail.user", properties.getUserAddr()); + // 访问SMTP服务时需要提供的密码(在控制台选择发信地址进行设置) + props.put("mail.password", properties.getPassword()); + props.setProperty("mail.smtp.socketFactory.fallback", "false"); + props.put("mail.smtp.ssl.enable", "false"); + // 构建授权信息,用于进行SMTP进行身份验证 + Authenticator authenticator = new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + // 用户名、密码 + String userName = props.getProperty("mail.user"); + String password = props.getProperty("mail.password"); + return new PasswordAuthentication(userName, password); + } + }; + // 使用环境属性和授权信息,创建邮件会话 + Session mailSession = Session.getInstance(props, authenticator); +// mailSession.setDebug(true); + //UUID uuid = UUID.randomUUID(); + //final String messageIDValue = "<" + uuid.toString() + ">"; + // 创建邮件消息 + MimeMessage message = new MimeMessage(mailSession) { + //@Override + //protected void updateMessageID() throws MessagingException { + //设置自定义Message-ID值 + //setHeader("Message-ID", messageIDValue); + //} + }; + try { + // 设置发件人邮件地址和名称。填写控制台配置的发信地址,比如xxx@xxx.com。和上面的mail.user保持一致。名称用户可以自定义填写。 + InternetAddress from = new InternetAddress(properties.getUserAddr(), properties.getUserName()); + message.setFrom(from); + //可选。设置回信地址 +// Address[] a = new Address[1]; +// a[0] = new InternetAddress("***"); +// message.setReplyTo(a); + // 设置收件人邮件地址,比如yyy@yyy.com + InternetAddress to = new InternetAddress(emailAddress); + message.setRecipient(MimeMessage.RecipientType.TO, to); + //如果同时发给多人,才将上面两行替换为如下(因为部分收信系统的一些限制,尽量每次投递给一个人;同时我们限制单次允许发送的人数是50人): + // 设置邮件标题 + message.setSubject("您的"+param+"账单提醒"); + message.setHeader("Content-Transfer-Encoding", "base64"); + // 设置邮件的内容体 type: text/plain(纯文本)text/html(HTML 文档) + message.setContent("邻居您好!您"+param+",提醒您有账单需要处理,如已处理请忽略此短信,感谢您的支持!如有疑问请详询:4008888888。", "text/html;charset=UTF-8"); + //发送邮件 + Transport.send(message); + } catch (MessagingException | UnsupportedEncodingException e) { + log.error("发送邮件发生异常",e); + throw new ServiceException("发送邮件失败,请检查"); + } + + } + +// public static void main(String[] args) { +// TencentMailUtil tencentMailUtil = new TencentMailUtil(); +// MailProperties properties = new MailProperties(); +// tencentMailUtil.properties = properties; +// tencentMailUtil.send("214491528@qq.com","大学城揽院24栋"); +// +// } + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java index 45c2e41..6619889 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java @@ -1,8 +1,10 @@ package com.ruoyi.system.dto; import com.ruoyi.system.model.TBill; +import com.ruoyi.system.model.TBillDetail; import lombok.Data; +import java.math.BigDecimal; import java.util.List; @Data @@ -17,6 +19,26 @@ private String account; private String houseName; + /** + * 合同信息 + */ + private String contractName; + private String partyTwoName; + + private BigDecimal totalYear; + + private String payType; + + private BigDecimal deposit; + + /** + * 水费 + */ + private TBillDetail water; + /** + * 电费 + */ + private TBillDetail elect; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java index 6a447fb..45735ef 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java @@ -34,5 +34,5 @@ */ List<TBillDto> invoiceList(@Param("query")TBillQuery query, @Param("pageInfo")PageInfo<TBillDto> pageInfo); - TBillDto selectTenentByBillId(@Param("billId") String billId); + TBillDto selectDetailByBillId(@Param("billId") String billId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillDetailService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillDetailService.java index 36d0bed..f5fdf98 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillDetailService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillDetailService.java @@ -3,6 +3,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.model.TBillDetail; +import javax.validation.constraints.NotEmpty; +import java.util.List; + /** * <p> * 账单水电费子表 服务类 @@ -13,4 +16,7 @@ */ public interface TBillDetailService extends IService<TBillDetail> { + List<TBillDetail> getByBillId(@NotEmpty String billId); + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java index b561ecd..1a08a95 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java @@ -10,6 +10,7 @@ import com.ruoyi.system.query.TBillQuery; import com.taxi591.bankapi.dto.ChargeBillRequest; +import javax.validation.constraints.NotEmpty; import java.math.BigDecimal; import java.util.List; import java.util.function.Consumer; @@ -81,4 +82,6 @@ Integer sendSmsByBillIds(SmsByBillDto dto); Integer sendMailBatchByBillIds(SmsByBillDto dto); + + TBillDto getDetailByBillId(@NotEmpty String id); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillDetailServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillDetailServiceImpl.java index 44e6404..905e81b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillDetailServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillDetailServiceImpl.java @@ -1,10 +1,15 @@ package com.ruoyi.system.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.mapper.TBillDetailMapper; import com.ruoyi.system.model.TBillDetail; +import com.ruoyi.system.model.TOrderBill; import com.ruoyi.system.service.TBillDetailService; import org.springframework.stereotype.Service; + +import javax.validation.constraints.NotEmpty; +import java.util.List; /** * <p> @@ -17,4 +22,8 @@ @Service public class TBillDetailServiceImpl extends ServiceImpl<TBillDetailMapper, TBillDetail> implements TBillDetailService { + @Override + public List<TBillDetail> getByBillId(@NotEmpty String billId) { + return list(new LambdaQueryWrapper<TBillDetail>().eq(TBillDetail::getBillId,billId)); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java index 88b06ed..a694c73 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java @@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import javax.validation.constraints.NotEmpty; import java.util.*; import java.util.stream.Collectors; import java.math.BigDecimal; @@ -359,7 +360,7 @@ public Integer sendSmsByBillIds(SmsByBillDto dto) { int failNum = 0; for (String billId : dto.getBillIds()) { - TBillDto bill = getTenentByBillId(billId); + TBillDto bill = getDetailByBillId(billId); if (bill.getSmsLastTime()!=null && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<smsUtil.getPro().getBillSmsDelayPeriod()*60*1000L)){ throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getSmsLastTime())); @@ -388,7 +389,7 @@ public Integer sendMailBatchByBillIds(SmsByBillDto dto) { int failNum = 0; for (String billId : dto.getBillIds()) { - TBillDto bill = getTenentByBillId(billId); + TBillDto bill = getDetailByBillId(billId); if (bill.getSmsLastTime()!=null && (System.currentTimeMillis()-bill.getSmsLastTime().getTime()<smsUtil.getPro().getBillMailDelayPeriod()*60*1000L)){ throw new ServiceException("有账单最近一次发送的时间是:"+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,bill.getSmsLastTime())); @@ -413,8 +414,8 @@ return failNum; } - private TBillDto getTenentByBillId(String billId) { - return getBaseMapper().selectTenentByBillId(billId); + public TBillDto getDetailByBillId(@NotEmpty String billId) { + return getBaseMapper().selectDetailByBillId(billId); } diff --git a/ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml index 76763fd..5c90e07 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml @@ -130,14 +130,15 @@ order by b.pay_fees_time </select> - <select id="selectTenentByBillId" resultType="com.ruoyi.system.dto.TBillDto"> + <select id="selectDetailByBillId" resultType="com.ruoyi.system.dto.TBillDto"> SELECT b.*, t.resident_name as residentName, t.email, t.phone, t.account, - h.house_name as houseName + h.house_name as houseName, + c.contract_name,c.pay_type,c.party_two_name,c.total_year,c.deposit FROM t_bill b LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0 -- Gitblit v1.7.1