新版仿ok交易所-后端
1
zj
2025-10-02 ad597f433afb0e4ead989aa8a30133fe40d3b98c
trading-order-service/src/main/java/com/yami/trading/service/impl/IdentifyingCodeServiceImpl.java
@@ -5,6 +5,8 @@
import com.yami.trading.common.http.HttpHelper;
import com.yami.trading.common.manager.BlacklistIpTimeWindow;
import com.yami.trading.common.manager.SendCountTimeWindow;
import com.yami.trading.common.manager.sms.BUKASmsUtils;
import com.yami.trading.common.manager.sms.GoToneSmsUtils;
import com.yami.trading.service.EmailSendService;
import com.yami.trading.service.IdentifyingCodeService;
import com.yami.trading.service.IdentifyingCodeTimeWindowService;
@@ -12,11 +14,13 @@
import com.yami.trading.service.syspara.SysparaService;
import com.yami.trading.service.system.CodeLogService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -55,8 +59,14 @@
    private Map<String, Integer> ipCache = new ConcurrentHashMap<String, Integer>();
    @Autowired
    GoToneSmsUtils goToneSmsUtils;
    @Autowired
    BUKASmsUtils bukasmsUtils;
    @Override
    public void send(String target, String ip) {
    public void send(String target, String ip) throws IOException {
        String code = null;
        if (chcekIp(ip)) {// 被封的ip直接返回 不操作
            return;
@@ -67,11 +77,7 @@
//      String smsbao_sign = sysparaService.find("smsbao_sign").getValue();
        // 短信发送文本[TEST]code is :{0}
        String send_code_text = this.sysparaService.find("send_code_text").getSvalue();
        if (StringUtils.isNullOrEmpty(send_code_text)) {
            logger.error("send_code_text 未配置");
            return;
        }
        String send_code_text;
        /**
         * 是否每次发送的code都不一样
@@ -87,9 +93,14 @@
        }
//      log.info(MessageFormat.format("target:{0},code:{1},ip:{2}", target, code, ip));
        String content = MessageFormat.format("code is :{0}", new Object[] { code });
        String content = "[MetaEquityEX]";
        if (target.indexOf("@") == -1) {
            send_code_text = this.sysparaService.find("send_code_text").getSvalue();
            if (StringUtils.isNullOrEmpty(send_code_text)) {
                logger.error("send_code_text 未配置");
                return;
            }
            /**
             * 发送的短信接口类型 tiantian---天天---smsSendService--->>>>--
             * moduyun---摩杜云---smsSingleSender
@@ -99,6 +110,19 @@
                logger.error("send_code_type 未配置");
                return;
            }
            if ("buka".equals(send_code_type)) {
                bukasmsUtils.sendSms(target, MessageFormat.format(send_code_text, new Object[] { code }));
                logger.info(MessageFormat.format("buka--target:{0},code:{1},ip:{2}", target, code, ip));
            }
            if ("GoTone".equals(send_code_type)) {
                String response = goToneSmsUtils.sendSms(target, MessageFormat.format(send_code_text, new Object[] { code }));
                logger.info(MessageFormat.format("GoTone--target:{0},code:{1},ip:{2}", target, code, ip));
                String responseWithChinese = StringEscapeUtils.unescapeJava(response);
                System.out.println("中文发送结果: " + responseWithChinese);
            }
            if ("tiantian".equals(send_code_type)) {
                smsSendService.send(target, MessageFormat.format(send_code_text, new Object[] { code }));
@@ -146,10 +170,19 @@
            }
        } else {
            send_code_text = this.sysparaService.find("email_send_code_text").getSvalue();
            if (StringUtils.isNullOrEmpty(send_code_text)) {
                logger.error("email_send_code_text 未配置");
                return;
            }
            /**
             * 邮件
             */
            emailSendService.sendEmail(target, MessageFormat.format(send_code_text, new Object[] { code }), content);
            //emailSendService.sendEmail(target, content, MessageFormat.format(send_code_text, new Object[] { code }));
            // 调用示例
            Map<String, Object> model = new HashMap<>();
            model.put("code", code);
            emailSendService.sendEmail(target, content, "verification_email.ftl", model);
            logger.info(MessageFormat.format("email--target:{0},code:{1},ip:{2}", target, code, ip));
        }