From 82ea85d8714462e23e598f4563c758ebf2b764ca Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期四, 20 二月 2025 18:08:47 +0800
Subject: [PATCH] 合同新增审批
---
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java | 73 ++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
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 2c1bc20..88b06ed 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
@@ -7,9 +7,11 @@
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SmsUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.system.dto.OfflinePayCheckDto;
+import com.ruoyi.system.dto.SmsByBillDto;
import com.ruoyi.system.dto.TBillDto;
import com.ruoyi.system.dto.TbillSaveDto;
import com.ruoyi.system.mapper.TBillMapper;
@@ -18,6 +20,8 @@
import com.ruoyi.system.query.TInvoiceToBillQuery;
import com.ruoyi.system.service.*;
import com.taxi591.bankapi.dto.ChargeBillRequest;
+import com.tencentcloudapi.sms.v20190711.SmsClient;
+import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.BeanUtils;
@@ -25,6 +29,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import java.math.BigDecimal;
@@ -70,6 +75,10 @@
@Autowired
TInvoiceToBillService tInvoiceToBillService;
+
+
+ @Resource
+ SmsUtil smsUtil;
public PageInfo<TBillDto> queryPage(TBillQuery query){
PageInfo<TBill> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
@@ -345,4 +354,68 @@
}
+
+ @Override
+ public Integer sendSmsByBillIds(SmsByBillDto dto) {
+ int failNum = 0;
+ for (String billId : dto.getBillIds()) {
+ TBillDto bill = getTenentByBillId(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()));
+ }
+ if (StringUtils.isEmpty(bill.getPhone())){
+ failNum++;
+ continue;
+ }
+ TBill save = new TBill();
+ save.setId(bill.getId());
+ try {
+ smsUtil.sendSms(bill.getPhone(), "", new String[]{""});
+ save.setSmsStatus(1);
+ }catch (ServiceException e){
+ failNum++;
+ save.setSmsStatus(2);
+ }
+ save.setSmsLastTime(new Date());
+ save.setSmsSendUserid(dto.getSendUserId());
+ lockAndUpdateInfo(save,1);
+ }
+ return failNum;
+ }
+
+ @Override
+ public Integer sendMailBatchByBillIds(SmsByBillDto dto) {
+ int failNum = 0;
+ for (String billId : dto.getBillIds()) {
+ TBillDto bill = getTenentByBillId(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()));
+ }
+ if (StringUtils.isEmpty(bill.getEmail())){
+ failNum++;
+ continue;
+ }
+ TBill save = new TBill();
+ save.setId(bill.getId());
+ try {
+ //todo 发送邮件
+ save.setMailStatus(1);
+ }catch (ServiceException e){
+ failNum++;
+ save.setMailStatus(2);
+ }
+ save.setMailLastTime(new Date());
+ save.setMailSendUserid(dto.getSendUserId());
+ lockAndUpdateInfo(save,1);
+ }
+ return failNum;
+ }
+
+ private TBillDto getTenentByBillId(String billId) {
+ return getBaseMapper().selectTenentByBillId(billId);
+ }
+
+
}
--
Gitblit v1.7.1