yupeng
2025-02-28 8f236a170f6693d3fc7a87646e52e29ec9bbe299
feat: 短信改成工具类内部创建SMSclient
8个文件已修改
2个文件已删除
126 ■■■■■ 已修改文件
ruoyi-common/src/main/java/com/ruoyi/common/config/MailProperties.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/config/SmsConfig.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/config/SmsProperties.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtil.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/resources/META-INF/spring.factories 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/CachPayDto.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayCheckDto.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/config/MailProperties.java
@@ -2,8 +2,10 @@
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "mail")
public class MailProperties {
ruoyi-common/src/main/java/com/ruoyi/common/config/SmsConfig.java
File was deleted
ruoyi-common/src/main/java/com/ruoyi/common/config/SmsProperties.java
@@ -2,8 +2,10 @@
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "sms")
public class SmsProperties {
ruoyi-common/src/main/java/com/ruoyi/common/utils/SmsUtil.java
@@ -13,6 +13,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
@@ -30,14 +31,15 @@
        return smsProperties;
    }
    public SmsClient createSmsClient(SmsProperties properties) {
    @PostConstruct
    public void createSmsClient() {
        // 实例化一个认证对象,入参需要传入腾讯云账户 SecretId,SecretKey。
        // 为了保护密钥安全,建议将密钥设置在环境变量中或者配置文件中,请参考凭证管理 https://github.com/TencentCloud/tencentcloud-sdk-java?tab=readme-ov-file#%E5%87%AD%E8%AF%81%E7%AE%A1%E7%90%86。
        // 硬编码密钥到代码中有可能随代码泄露而暴露,有安全隐患,并不推荐。
        // SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi
        // Credential cred = new Credential("SecretId", "SecretKey");
        Credential cred = new Credential(properties.getSecretid(), properties.getSecretkey());
        Credential cred = new Credential(smsProperties.getSecretid(), smsProperties.getSecretkey());
        // 实例化一个http选项,可选的,没有特殊需求可以跳过
        HttpProfile httpProfile = new HttpProfile();
        // 指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com ,也支持指定地域域名访问,例如广州地域的域名为 sms.ap-guangzhou.tencentcloudapi.com
@@ -46,7 +48,7 @@
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        // 实例化要请求产品(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);
        smsClient =  new SmsClient(cred, "ap-guangzhou", clientProfile);
    }
    public boolean sendSms(String phone,String templateId,String[] param){
@@ -73,17 +75,5 @@
        }
    }
    public static void main(String[] args) {
        SmsProperties properties = new SmsProperties();
        properties.setAppId("1400957506");
        properties.setSign("畅云出行");
        properties.setSecretid("AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x");
        properties.setSecretkey("lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU");
        SmsUtil smsUtil = new SmsUtil();
        smsUtil.smsProperties = properties;
        smsUtil.smsClient = smsUtil.createSmsClient(properties);
        boolean isok = smsUtil.sendSms("15826040006", "2369926", new String[]{"526584"});
        System.out.println(isok);
    }
}
ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java
@@ -2,17 +2,15 @@
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;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
@Component
@Slf4j
ruoyi-common/src/main/resources/META-INF/spring.factories
File was deleted
ruoyi-system/src/main/java/com/ruoyi/system/dto/CachPayDto.java
@@ -4,6 +4,8 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -14,12 +16,15 @@
public class CachPayDto implements Serializable {
    @ApiModelProperty(value = "支付类型:1.银行、2.现金")
    @NotNull(message = "支付类型不能为空")
    private Integer payType;
    @ApiModelProperty(value = "账单ID")
    @NotEmpty(message = "账单ID不能为空")
    private String billId;
    @ApiModelProperty(value = "金额")
    @ApiModelProperty(value = "实付金额")
    @NotNull(message = "实付金额不能为空")
    private BigDecimal amount;
    @ApiModelProperty(value = "付款人姓名")
@@ -28,6 +33,6 @@
    @ApiModelProperty(value = "银行支付的付款凭证")
    private String voucher;
    @ApiModelProperty("银行支付的银行流水")
    private TBankFlow tBankFlow;
    @ApiModelProperty(value = "银行流水ID")
    private String flowId;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayCheckDto.java
@@ -17,9 +17,6 @@
    /**
     * 账单ID列表
     */
    @ApiModelProperty("账单ID列表,管理员处理后的")
    @NotEmpty(message = "账单列表不能为空")
    private List<String> billIds;
    @ApiModelProperty(value = "账单ID")
    @NotEmpty(message = "账单ID不能为空")
@@ -40,8 +37,8 @@
    private LocalDateTime payTime;
    @ApiModelProperty("支付凭证")
    private String voucher;
    @ApiModelProperty("银行流水")
    private TBankFlow tBankFlow;
    @ApiModelProperty("银行流水ID")
    @NotEmpty(message = "银行流水ID不能为空")
    private String flowId;
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -17,10 +17,7 @@
import com.ruoyi.system.query.TBillQuery;
import com.ruoyi.system.query.TInvoiceToBillQuery;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.TBillVO;
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;
@@ -30,12 +27,15 @@
import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.util.*;
import java.util.stream.Collectors;
import java.math.BigDecimal;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/**
 * <p>
@@ -170,7 +170,7 @@
                            BigDecimal result = presist.getPayFeesMoney().add(tBill.getPayFeesMoney());
                            save.setPayFeesMoney(result);
                            //缴费后的欠费 =(应缴费+违约金)-已缴费金额
                            BigDecimal outstand = save.getPayableFeesMoney()
                            BigDecimal outstand = presist.getPayableFeesMoney()
                                    .add(presist.getPayableFeesPenalty())
                                    .subtract(save.getPayFeesMoney());
                            save.setOutstandingMoney(outstand);
@@ -242,7 +242,7 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean checkOfflinePay(OfflinePayCheckDto dto) {
        TBankFlow bankflow = tBankFlowService.getById(dto.getTBankFlow().getId());
        TBankFlow bankflow = tBankFlowService.getById(dto.getFlowId());
        TBillDto bill = getDetailByBillId(dto.getBillId());
        if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
            throw new ServiceException("该流水已无可抵扣剩余金额");
@@ -258,8 +258,8 @@
        TBill billSave = new TBill();
        billSave.setId(bill.getId());
        billSave.setPayFeesMoney(dto.getAmount());
        billSave.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
        billSave.setPayFeesTime(dto.getTBankFlow().getPayTime());
        billSave.setBankSerialNumber(bankflow.getBankSerialNumber());
        billSave.setPayFeesTime(bankflow.getPayTime());
        billSave.setVoucher(dto.getVoucher());
        billSave.setPayFeesType(2);
        TBill back = lockAndUpdateInfo(billSave, 2);
@@ -274,8 +274,8 @@
        TFlowManagement save = new TFlowManagement();
        save.setPayType(3);
        save.setPayer(dto.getPayer());
        save.setPayTime(dto.getTBankFlow().getPayTime());
        save.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
        save.setPayTime(bankflow.getPayTime());
        save.setBankSerialNumber(bankflow.getBankSerialNumber());
        save.setFlowType(2);
        save.setPaymentBillId(back.getId());
        save.setDeductionMoney(back.getDeductionMoney());
@@ -451,7 +451,10 @@
        TBill back = null;
        TBankFlow bankflow = null;
        if (dto.getPayType()==1){
            bankflow = tBankFlowService.getById(dto.getTBankFlow().getId());
            if (StringUtils.isEmpty(dto.getFlowId())){
                throw new ServiceException("银行流水不能为空");
            }
            bankflow = tBankFlowService.getById(dto.getFlowId());
            TBillDto bill = getDetailByBillId(dto.getBillId());
            if (bankflow.getRemainingMoney().compareTo(BigDecimal.ZERO)<=0){
                throw new ServiceException("该流水已无可抵扣剩余金额");
@@ -468,8 +471,8 @@
        TBill billSave = new TBill();
        billSave.setId(bill.getId());
        billSave.setPayFeesMoney(dto.getAmount());
        billSave.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
        billSave.setPayFeesTime(dto.getTBankFlow().getPayTime());
        billSave.setBankSerialNumber(bankflow!=null?bankflow.getBankSerialNumber():null);
        billSave.setPayFeesTime(bankflow!=null?bankflow.getPayTime():DateUtils.dateToLocalDateTime(new Date()));
        billSave.setVoucher(dto.getVoucher());
        billSave.setPayFeesType(2);
        back = lockAndUpdateInfo(billSave, 2);
@@ -485,8 +488,8 @@
        TFlowManagement save = new TFlowManagement();
        save.setPayType(3);
        save.setPayer(dto.getPayer());
        save.setPayTime(dto.getTBankFlow().getPayTime());
        save.setBankSerialNumber(dto.getTBankFlow().getBankSerialNumber());
        save.setPayTime(bankflow!=null?bankflow.getPayTime():DateUtils.dateToLocalDateTime(new Date()));
        save.setBankSerialNumber(bankflow!=null?bankflow.getBankSerialNumber():null);
        save.setFlowType(dto.getPayType()==1?2:1);
        save.setPaymentBillId(back.getId());
        save.setDeductionMoney(back.getDeductionMoney());
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml
@@ -63,7 +63,7 @@
                and t.id = #{query.userId}
            </if>
        </where>
        order by b.payable_fees_time desc
        order by b.create_time desc
    </select>
    <select id="getBillList" resultType="com.ruoyi.system.dto.TBillDto">
        SELECT