新版仿ok交易所-后端
1
zyy
2026-03-09 4164ba59cb88d33b191f42d3bef122f6f7af6312
trading-order-service/src/main/java/com/yami/trading/service/impl/IdentifyingCodeServiceImpl.java
@@ -5,6 +5,7 @@
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;
@@ -13,6 +14,7 @@
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;
@@ -60,6 +62,9 @@
    @Autowired
    GoToneSmsUtils goToneSmsUtils;
    @Autowired
    BUKASmsUtils bukasmsUtils;
    @Override
    public void send(String target, String ip) throws IOException {
        String code = null;
@@ -72,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都不一样
@@ -92,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 = "[BingX]";
        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
@@ -105,9 +111,16 @@
                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)) {
                goToneSmsUtils.sendSms(target, MessageFormat.format(send_code_text, new Object[] { code }));
                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);
            }
@@ -157,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));
        }