|
@@ -1,6 +1,5 @@
|
|
|
package com.caimei365.user.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.caimei365.user.components.CommonService;
|
|
|
import com.caimei365.user.components.RedisService;
|
|
|
import com.caimei365.user.components.WeChatService;
|
|
@@ -11,8 +10,11 @@ import com.caimei365.user.model.dto.*;
|
|
|
import com.caimei365.user.model.po.*;
|
|
|
import com.caimei365.user.model.vo.*;
|
|
|
import com.caimei365.user.service.RegisterService;
|
|
|
-import com.caimei365.user.utils.*;
|
|
|
-
|
|
|
+import com.caimei365.user.service.RemoteCallService;
|
|
|
+import com.caimei365.user.utils.CodeUtil;
|
|
|
+import com.caimei365.user.utils.Md5Util;
|
|
|
+import com.caimei365.user.utils.RandomCodeGenerator;
|
|
|
+import com.caimei365.user.utils.ValidateUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -21,13 +23,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
-import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
-import java.util.regex.Matcher;
|
|
|
-import java.util.regex.Pattern;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Description
|
|
@@ -59,6 +59,8 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
private ToolsFeign smsFeign;
|
|
|
@Resource
|
|
|
private MessagePushMapper messagePushMapper;
|
|
|
+ @Resource
|
|
|
+ private RemoteCallService remoteCallService;
|
|
|
|
|
|
/**
|
|
|
* 检查账号可以注册
|
|
@@ -213,10 +215,11 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
user.setClubId(club.getClubId());
|
|
|
registerMapper.updateUserClubId(user.getUserId(), club.getClubId());
|
|
|
// 注册成功短信
|
|
|
- boolean smsFlag = AliyunSmsUtil.sendSms(clubRegisterDto.getBindMobile(), 10, "{name:" + clubRegisterDto.getBindMobile() + "}");
|
|
|
+ String content = "注册成功!您可以通过手机号"+clubRegisterDto.getBindMobile()+"登录。";
|
|
|
+ boolean smsFlag = remoteCallService.remoteSendSms(0, clubRegisterDto.getBindMobile(), content);
|
|
|
if (!smsFlag) {
|
|
|
// 短信发送失败重试一次
|
|
|
- AliyunSmsUtil.sendSms(clubRegisterDto.getBindMobile(), 10, "{name:" + clubRegisterDto.getBindMobile() + "}");
|
|
|
+ remoteCallService.remoteSendSms(0, clubRegisterDto.getBindMobile(), content);
|
|
|
}
|
|
|
/*
|
|
|
绑定微信,成为机构运营人员
|
|
@@ -661,10 +664,11 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
logTxt = String.format(logTxt, "普通机构", mobile, initPassword);
|
|
|
}
|
|
|
// 发送短信
|
|
|
- boolean smsFlag = AliyunSmsUtil.sendSms(mobile, 6, "{name:" + mobile + ",content:" + randomCode + "}");
|
|
|
+ String content = "欢迎成为采美机构用户,您的登录账号为:"+mobile+",初始密码为:cm"+randomCode+",您可使用该账号密码登录采美365网和“采美采购商城”小程序。";
|
|
|
+ boolean smsFlag = remoteCallService.remoteSendSms(0, mobile, content);
|
|
|
if (!smsFlag) {
|
|
|
// 短信发送失败重试一次
|
|
|
- AliyunSmsUtil.sendSms(mobile, 6, "{name:" + mobile + ",content:" + randomCode + "}");
|
|
|
+ remoteCallService.remoteSendSms(0, mobile, content);
|
|
|
}
|
|
|
// 打印短信内容
|
|
|
log.info(logTxt);
|
|
@@ -1108,11 +1112,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
message = "恭喜您成功开通采美平台超级会员,为期" + userPackageTime + "个月,快戳采美网站链接 www.caimei365.com/t/" + shortLink + "或微信搜索“采美采购商城”小程序登录采美平台畅享会员特权吧。关注公众号“采美365网”可获取更多优惠和精彩资讯。退订回T";
|
|
|
String mobile = vipMapper.findMobile(userId);
|
|
|
if (mobile != null && mobile != "") {
|
|
|
- try {
|
|
|
- sendSms(2, mobile, message);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短信发送异常" + e);
|
|
|
- }
|
|
|
+ remoteCallService.remoteSendSms(2, mobile, message);
|
|
|
}
|
|
|
} else if (repayFlag == 1) {
|
|
|
//有效期内续费
|
|
@@ -1137,11 +1137,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
message = "恭喜您成功续费采美平台超级会员,为期" + userPackageTime + "个月,快戳采美网站链接 www-b.caimei365.com/t/" + shortLink + "或微信搜索“采美采购商城”小程序登录采美平台畅享会员特权吧。关注公众号“采美365网”可获取更多优惠和精彩资讯。退订回T";
|
|
|
String mobile = vipMapper.findMobile(userId);
|
|
|
if (mobile != null && mobile != "") {
|
|
|
- try {
|
|
|
- sendSms(2, mobile, message);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短信发送异常" + e);
|
|
|
- }
|
|
|
+ remoteCallService.remoteSendSms(2, mobile, message);
|
|
|
}
|
|
|
} else if (repayFlag == -1) {
|
|
|
//过期续费
|
|
@@ -1169,11 +1165,7 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
message = "恭喜您成功续费采美平台超级会员,为期" + userPackageTime + "个月,快戳采美网站链接 www.caimei365.com/t/" + shortLink + "或微信搜索“采美采购商城”小程序登录采美平台畅享会员特权吧。关注公众号“采美365网”可获取更多优惠和精彩资讯。退订回T";
|
|
|
String mobile = vipMapper.findMobile(userId);
|
|
|
if (mobile != null && mobile != "") {
|
|
|
- try {
|
|
|
- sendSms(2, mobile, message);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短信发送异常" + e);
|
|
|
- }
|
|
|
+ remoteCallService.remoteSendSms(2, mobile, message);
|
|
|
}
|
|
|
}
|
|
|
log.info(userId + "消费采美豆" + multiply + "会员到期时间至" + cal.getTime());
|
|
@@ -1201,38 +1193,38 @@ public class RegisterServiceImpl implements RegisterService {
|
|
|
vipMapper.addPayHistory(payHistory);
|
|
|
}
|
|
|
|
|
|
- public boolean sendSms(int markId, String mobile, String message) {
|
|
|
- AtomicBoolean returnValue = new AtomicBoolean(false);
|
|
|
- try {
|
|
|
- //测试环境手机号允许发短信
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
- list.add("15917362709");
|
|
|
- list.add("15814011616");
|
|
|
- list.add("13100721916");
|
|
|
- list.add("15113936829");
|
|
|
- list.add("15827317748");
|
|
|
- if ("prod".equals(profile) || list.contains(mobile)) {
|
|
|
- if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
|
|
|
- String regex = "^(1[3-9]\\d{9}$)";
|
|
|
- Pattern pattern = Pattern.compile(regex);
|
|
|
- Matcher matcher = pattern.matcher(mobile);
|
|
|
- if (matcher.matches()) {
|
|
|
- // 调用 ToolsFeign 发送短信
|
|
|
- String jsonStr = smsFeign.getSendSms(mobile, message);
|
|
|
- JSONObject parseObject = JSONObject.parseObject(jsonStr);
|
|
|
- if (0 == parseObject.getInteger("code")) {
|
|
|
- // 保存短信发送条数+count
|
|
|
- messagePushMapper.updateSmsSendCount(markId, 1);
|
|
|
- returnValue.set(true);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("短信推送异常:", e);
|
|
|
- }
|
|
|
- return returnValue.get();
|
|
|
- }
|
|
|
+// public boolean sendSms(int markId, String mobile, String message) {
|
|
|
+// AtomicBoolean returnValue = new AtomicBoolean(false);
|
|
|
+// try {
|
|
|
+// //测试环境手机号允许发短信
|
|
|
+// List<String> list = new ArrayList<>();
|
|
|
+// list.add("15917362709");
|
|
|
+// list.add("15814011616");
|
|
|
+// list.add("13100721916");
|
|
|
+// list.add("15113936829");
|
|
|
+// list.add("15827317748");
|
|
|
+// if ("prod".equals(profile) || list.contains(mobile)) {
|
|
|
+// if (StringUtils.isNotBlank(mobile) && mobile.length() == 11) {
|
|
|
+// String regex = "^(1[3-9]\\d{9}$)";
|
|
|
+// Pattern pattern = Pattern.compile(regex);
|
|
|
+// Matcher matcher = pattern.matcher(mobile);
|
|
|
+// if (matcher.matches()) {
|
|
|
+// // 调用 ToolsFeign 发送短信
|
|
|
+// String jsonStr = smsFeign.getSendSms(mobile, message);
|
|
|
+// JSONObject parseObject = JSONObject.parseObject(jsonStr);
|
|
|
+// if (0 == parseObject.getInteger("code")) {
|
|
|
+// // 保存短信发送条数+count
|
|
|
+// messagePushMapper.updateSmsSendCount(markId, 1);
|
|
|
+// returnValue.set(true);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("短信推送异常:", e);
|
|
|
+// }
|
|
|
+// return returnValue.get();
|
|
|
+// }
|
|
|
|
|
|
private static String strs(String str) {
|
|
|
if (str.indexOf(".") > 0) {
|