puzhibing
2023-08-04 d61812d87aa8ffc54eca9a8bfae078a1349e45d4
新增加国外短信
4个文件已修改
83 ■■■■■ 已修改文件
DriverIGOTravel/guns-admin/pom.xml 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/pom.xml
@@ -240,6 +240,34 @@
            <artifactId>CheckoutEncryption</artifactId>
            <version>0.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.twilio.sdk</groupId>
            <artifactId>twilio</artifactId>
            <version>9.9.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.13</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.13</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.20</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/DriverServiceImpl.java
@@ -168,23 +168,22 @@
            sb.append((int) (random.nextDouble() * 10));
        }
        String authCode = sb.toString();
        String sms = "短信验证码【" + authCode + "】已发到您的手机,验证码将在5分钟后失效.";
        String sms = "";
        //发送验证码短信
        redisUtil.setStrValue(phone, authCode, 5 * 60);//设置五分钟过期
        String templateId = "";
        switch (language){
            case 1:
                templateId = "b793ae3d41a049059197bfe92cf8bc83";
                sms = "您的验证码为:" + authCode + ",该验证码5分钟内有效,请勿泄漏于他人!";
                break;
            case 2:
                templateId = "058c7d11ce594d668841cceb49fb5c9a";
                sms = "Your verification code is: " + authCode + ", the verification code is valid within 5 minutes, do not leak to others!";
                break;
            case 3:
                templateId = "4edbe604da6546808ffda582085b3c83";
                sms = "Votre code de vérification est: " + authCode + ". Ce code est valide pendant 5 minutes. Ne le divulguez pas aux autres!";
                break;
        }
        SMSUtil.send_huawei_sms(templateId, "+" + phone, "[\"" + authCode + "\"]");
        SMSUtil.sendTwilioMessage("+" + phone, sms);
        System.out.println(sms);
        return ResultUtil.success();
    }
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java
@@ -1076,7 +1076,7 @@
            if(orderPrivateCar.getDriverPay() == 2){
                return ResultUtil.error(language == 1 ? "不能重复支付" : language == 2 ? "Non-repeatable payment" : "Aucun paiement en double");
            }
            if(payType == 2){//余额支付
            if(payType == 3){//余额支付
                if(driver.getBalance().compareTo(money) < 0){
                    return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient account balance" : "Solde insuffisant du compte");
                }
@@ -1091,7 +1091,7 @@
            if(orderLogistics.getDriverPay() == 2){
                return ResultUtil.error(language == 1 ? "不能重复支付" : language == 2 ? "Non-repeatable payment" : "Aucun paiement en double");
            }
            if(payType == 2){//余额支付
            if(payType == 3){//余额支付
                if(driver.getBalance().compareTo(money) < 0){
                    return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient account balance" : "Solde insuffisant du compte");
                }
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/SMSUtil.java
@@ -1,6 +1,10 @@
package com.stylefeng.guns.modular.system.util;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import javax.net.ssl.*;
import java.io.*;
import java.net.URL;
@@ -226,4 +230,40 @@
        sc.init(null, trustAllCerts, null);
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    }
    /**
     * 发送Twilio短信
     * @param toPhone
     * @param msg
     * @return
     */
    public static boolean sendTwilioMessage(String toPhone, String msg){
        String ACCOUNT_SID = "AC1fd05e898bd59d17ba72db621afca537";
        String AUTH_TOKEN = "7cee1a6cb0e2936a9037be577b1ffe57";
        String formPhone = "+16672740015";
        try {
            Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
            Message message = Message.creator(
                    new PhoneNumber(toPhone),
                    new PhoneNumber(formPhone),
                    msg
            ).create();
            System.out.println(message.getSid());
            Message.Status status = message.getStatus();
            switch (status.toString()){
                case "canceled":
                    return false;
                case "undelivered":
                    return false;
                case "failed":
                    return false;
            }
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }
}