wuxw
2022-11-11 6e439e8cc4f3832b9ed2e8a45920d02539e180ae
java110-core/src/main/java/com/java110/core/factory/SendSmsFactory.java
old mode 100644 new mode 100755
@@ -1,6 +1,9 @@
package com.java110.core.factory;
import com.java110.dto.smsConfig.SmsConfigDto;
import com.java110.utils.cache.MappingCache;
import com.java110.vo.ResultVo;
import org.apache.commons.lang3.StringUtils;
import java.util.Random;
@@ -20,16 +23,35 @@
    private static final String SMS_COMPANY_TENCENT = "TENCENT";
    public static final String VALIDATE_CODE = "_validateTel";
    /**
     * 短信开关
     */
    public static final String SMS_SEND_SWITCH = "SMS_SEND_SWITCH";
    public static void sendSms(String tel, String code) {
        String smsCompany = MappingCache.getValue(SMS_DOMAIN, SMS_COMPANY);
        if (SMS_COMPANY_ALI.equals(smsCompany)) {
        if (!StringUtils.isEmpty(smsCompany) && SMS_COMPANY_ALI.equals(smsCompany.trim())) {
            AliSendMessageFactory.sendMessage(tel, code);
        } else {
            TencentSendMessageFactory.sendMessage(tel, code);
        }
    }
    public static ResultVo sendOweFeeSms(String tel, SmsConfigDto smsConfigDto, Object param){
        ResultVo resultVo = null;
        if (SMS_COMPANY_ALI.equals(smsConfigDto.getSmsType().trim())) {
            resultVo = AliSendMessageFactory.sendOweFeeSms(tel, param,smsConfigDto);
        } else {
            resultVo = TencentSendMessageFactory.sendOweFeeSms(tel, param,smsConfigDto);
        }
        return resultVo;
    }
    /**
     * 生成验证码
@@ -41,7 +63,7 @@
        Random random = new Random();
        String result = "";
        for (int i = 0; i < limit; i++) {
            result += random.nextInt(10);
            result += (random.nextInt(9) + 1);
        }
        return result;
    }