Helius
2020-07-14 ffa2e056169ff43dcc1d4167d5f64e3f524b8feb
modify
1 files added
3 files modified
113 ■■■■■ changed files
src/main/java/com/xcong/excoin/common/system/controller/CommonController.java 3 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java 10 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/utils/mail/Sms106Send.java 75 ●●●●● patch | view | raw | blame | history
src/test/java/com/xcong/excoin/SmsTest.java 25 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/common/system/controller/CommonController.java
@@ -11,6 +11,7 @@
import com.xcong.excoin.utils.OssUtils;
import com.xcong.excoin.utils.RedisUtils;
import com.xcong.excoin.utils.SmsUtils;
import com.xcong.excoin.utils.mail.Sms106Send;
import com.xcong.excoin.utils.mail.SmsSend;
import com.xcong.excoin.utils.mail.SubMailSend;
import io.swagger.annotations.Api;
@@ -60,7 +61,7 @@
        // 发送手机验证码
        if (AppContants.ACCOUNT_TYPE_MOBILE.equals(type)) {
            boolean result = SmsSend.sendVerifyCode(account, code.toString(), 2);
            boolean result = Sms106Send.sendVerifyCode(account, code.toString(), 2);
            if (result) {
                Map<String, Object> map = new HashMap<>();
                boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120);
src/main/java/com/xcong/excoin/modules/coin/service/impl/BlockCoinServiceImpl.java
@@ -20,7 +20,7 @@
import com.xcong.excoin.utils.LogRecordUtils;
import com.xcong.excoin.utils.ThreadPoolUtils;
import com.xcong.excoin.utils.dingtalk.DingTalkUtils;
import com.xcong.excoin.utils.mail.SmsSend;
import com.xcong.excoin.utils.mail.Sms106Send;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -92,7 +92,7 @@
                        MemberEntity member = memberDao.selectById(memberId);
                        if (StrUtil.isNotBlank(member.getPhone())) {
                            String amount = newBalance.toPlainString() + "USDT-ERC20";
                            SmsSend.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), amount, orderNo);
                            Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo);
                        }
                    }
                }
@@ -141,7 +141,7 @@
                        MemberEntity member = memberDao.selectById(memberId);
                        if (StrUtil.isNotBlank(member.getPhone())) {
                            String amount = newBalance.toPlainString() + "ETH";
                            SmsSend.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), amount, orderNo);
                            Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo);
                        }
                    }
                }
@@ -186,7 +186,7 @@
                        MemberEntity member = memberDao.selectById(memberId);
                        if (StrUtil.isNotBlank(member.getPhone())) {
                            String amount = newBalance.toPlainString() + "USDT-OMNI";
                            SmsSend.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), amount, orderNo);
                            Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo);
                        }
                    }
                }
@@ -233,7 +233,7 @@
                        MemberEntity member = memberDao.selectById(memberId);
                        if (StrUtil.isNotBlank(member.getPhone())) {
                            String amount = newBalance.toPlainString() + "BTC";
                            SmsSend.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), amount, orderNo);
                            Sms106Send.sendRechargeMsg(member.getPhone(), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MINUTE_PATTERN), orderNo);
                        }
                    }
                }
src/main/java/com/xcong/excoin/utils/mail/Sms106Send.java
New file
@@ -0,0 +1,75 @@
package com.xcong.excoin.utils.mail;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.XmlUtil;
import cn.hutool.http.HttpUtil;
import com.xcong.excoin.common.exception.GlobalException;
import java.util.Date;
import java.util.HashMap;
/**
 * @author wzy
 * @date 2020-07-14
 **/
public class Sms106Send {
    private static final String URL = "http://www.qf106.com/sms.aspx";
    private static final String ID = "16580";
    private static final String ACCOUNT = "Biue";
    private static final String PASSWORD = "123456";
    /**
     * @param phone 手机号
     * @param code  验证码
     * @param time  失效时间
     * @return
     */
    public static boolean sendVerifyCode(String phone, String code, int time) {
        String msg = "您的验证码是{},请在{}分钟内输入,请勿泄露给他人,如非本人操作,请及时修改密码。";
        String content = StrUtil.format(msg, code, time);
        return request(phone, content, "验证码");
    }
    public static boolean sendRechargeMsg(String phone, String time, String orderNo) {
        String msg = "尊敬的用户,您的帐号于{}有一笔成功充值订单,如有疑问请联系客服,订单编号为{}";
        String content = StrUtil.format(msg, time, orderNo);
        return request(phone, content, "充值");
    }
    public static boolean sendWithdrawalMsg(String phone, String time, String orderNo) {
        String msg = "尊敬的用户,您的帐号于{}有一笔成功提现订单,如有疑问请联系客服,订单编号为{}";
        String content = StrUtil.format(msg, time, orderNo);
        return request(phone, content, "提现");
    }
    private static boolean request(String phone, String content, String tagName) {
        HashMap<String, Object> param = new HashMap<>();
        param.put("userid", ID);
        param.put("account", ACCOUNT);
        param.put("password", PASSWORD);
        param.put("mobile", phone);
        param.put("content", content);
        param.put("sendTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
        param.put("action", "send");
        param.put("checkcontent", 0);
        param.put("taskName", tagName);
        param.put("countnumber", 1);
        param.put("mobilenumber", 1);
        param.put("telephonenumber", 0);
        String response = HttpUtil.post(URL, param);
        if ("Success".equals(XmlUtil.xmlToMap(response).get("returnstatus"))) {
            return true;
        } else {
            throw new GlobalException((String) XmlUtil.xmlToMap(response).get("message"));
        }
    }
    public static void main(String[] args) {
        System.out.println(sendVerifyCode("15773002834", "123456", 2));
    }
}
src/test/java/com/xcong/excoin/SmsTest.java
@@ -1,9 +1,15 @@
package com.xcong.excoin;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.UnicodeUtil;
import cn.hutool.core.util.XmlUtil;
import cn.hutool.http.HttpUtil;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.Date;
import java.util.HashMap;
/**
 * @author wzy
@@ -13,9 +19,24 @@
public class SmsTest {
    public static void main(String[] args) {
        long time = 1594363341988L;
        String url = "http://www.qf106.com/sms.aspx";
        HashMap<String,Object> param = new HashMap<>();
        param.put("userid", "16580");
        param.put("account", "Biue");
        param.put("password", "123456");
        param.put("mobile", "15773002834");
        param.put("content", "这是测试");
        param.put("sendTime", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN));
        param.put("action", "send");
        param.put("checkcontent", 0);
        param.put("taskName", "验证码");
        param.put("countnumber", 1);
        param.put("mobilenumber", 1);
        param.put("telephonenumber", 0);
        System.out.println(DateUtil.date(time));
        String response = HttpUtil.post(url, param);
        System.out.println(response);
        System.out.println(XmlUtil.xmlToMap(response).get("returnstatus"));
    }
}