Commit 90ed7c9f by fanjiaxin

推客分佣单阿波罗配置调整

parent f47ed44b
Pipeline #75525 passed with stages
in 1 minute 3 seconds
...@@ -71,16 +71,20 @@ public class SmsServiceImpl implements ISmsService { ...@@ -71,16 +71,20 @@ public class SmsServiceImpl implements ISmsService {
*/ */
private Boolean sendCode(String scenes, String mobilePhone) { private Boolean sendCode(String scenes, String mobilePhone) {
log.error("[op:sendSmsCode] sendCode..."); log.error("[op:sendSmsCode] sendCode...");
SmsCodeScenesConfigBO scenesConfigBO = smsConfig.getScenesConfig(scenes);
if(null == scenesConfigBO){
throw new BizException("短信配置错误");
}
// 生成6位随机数字 // 生成6位随机数字
String code = RandomUtils.randomNumber(6); String code = RandomUtils.randomNumber(6);
// uas发送验证码 // uas发送验证码
boolean success = iUasClient.sendSmsCode(LoginUserContextHolder.get().getOpenId(), mobilePhone, code, scenes); boolean success = iUasClient.sendSmsCode(LoginUserContextHolder.get().getOpenId(),
mobilePhone, code, scenes, scenesConfigBO);
if (!success) { if (!success) {
return false; return false;
} }
SmsCodeScenesConfigBO smsCodeScenesConfigBO = smsConfig.getScenesConfig(scenes); int sendIntervalSeconds = scenesConfigBO.getSendIntervalSeconds();
int sendIntervalSeconds = smsCodeScenesConfigBO.getSendIntervalSeconds(); int codeValidMinutes = scenesConfigBO.getCodeValidMinutes();
int codeValidMinutes = smsCodeScenesConfigBO.getCodeValidMinutes();
// 标记验证码已发送 // 标记验证码已发送
String sendCodeKey = String.format(SmsConstant.SMS_SEND_INTERVAL_KEY, scenes, mobilePhone); String sendCodeKey = String.format(SmsConstant.SMS_SEND_INTERVAL_KEY, scenes, mobilePhone);
redisClient.setStr(sendCodeKey, String.valueOf(System.currentTimeMillis()), sendIntervalSeconds); redisClient.setStr(sendCodeKey, String.valueOf(System.currentTimeMillis()), sendIntervalSeconds);
......
package com.netease.yanxuan.wx.store.sharer.integration.client; package com.netease.yanxuan.wx.store.sharer.integration.client;
import com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO;
/** /**
* @Description Uas服务 * @Description Uas服务
* @Author fanjiaxin * @Author fanjiaxin
...@@ -10,5 +12,6 @@ public interface IUasClient { ...@@ -10,5 +12,6 @@ public interface IUasClient {
/** /**
* 发送短信 * 发送短信
*/ */
boolean sendSmsCode(String uid, String phone, String code, String scenes); boolean sendSmsCode(String uid, String phone, String code,
String scenes, SmsCodeScenesConfigBO scenesConfigBO);
} }
...@@ -9,7 +9,6 @@ package com.netease.yanxuan.wx.store.sharer.integration.client.impl; ...@@ -9,7 +9,6 @@ package com.netease.yanxuan.wx.store.sharer.integration.client.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.netease.yanxuan.wx.store.sharer.integration.client.IUasClient; import com.netease.yanxuan.wx.store.sharer.integration.client.IUasClient;
import com.netease.yanxuan.wx.store.sharer.integration.config.RpcConfig; import com.netease.yanxuan.wx.store.sharer.integration.config.RpcConfig;
import com.netease.yanxuan.wx.store.sharer.integration.config.SmsConfig;
import com.netease.yanxuan.wx.store.sharer.integration.handler.RestTemplateHandler; import com.netease.yanxuan.wx.store.sharer.integration.handler.RestTemplateHandler;
import com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO; import com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
...@@ -26,7 +25,6 @@ import java.util.Map; ...@@ -26,7 +25,6 @@ import java.util.Map;
@Service @Service
public class UasClientImpl implements IUasClient { public class UasClientImpl implements IUasClient {
private final SmsConfig smsConfig;
private final RpcConfig rpcConfig; private final RpcConfig rpcConfig;
private final RestTemplateHandler restTemplateHandler; private final RestTemplateHandler restTemplateHandler;
...@@ -44,8 +42,9 @@ public class UasClientImpl implements IUasClient { ...@@ -44,8 +42,9 @@ public class UasClientImpl implements IUasClient {
* @return * @return
*/ */
@Override @Override
public boolean sendSmsCode(String uid, String phone, String code, String scenes) { public boolean sendSmsCode(String uid, String phone, String code,
Map<String, Object> params = assembleSmsArg(uid, phone, code, scenes); String scenes, SmsCodeScenesConfigBO scenesConfigBO) {
Map<String, Object> params = assembleSmsArg(uid, phone, code, scenes, scenesConfigBO);
String httpUrl = rpcConfig.getUasUrl() + SMS_SEND_PATH + PRODUCT; String httpUrl = rpcConfig.getUasUrl() + SMS_SEND_PATH + PRODUCT;
try { try {
JSONObject rpcResult = restTemplateHandler.execute(httpUrl, HttpMethod.POST, params, JSONObject.class); JSONObject rpcResult = restTemplateHandler.execute(httpUrl, HttpMethod.POST, params, JSONObject.class);
...@@ -57,11 +56,12 @@ public class UasClientImpl implements IUasClient { ...@@ -57,11 +56,12 @@ public class UasClientImpl implements IUasClient {
} }
private Map<String, Object> assembleSmsArg(String uid, String phone, String code, String scenes) { private Map<String, Object> assembleSmsArg(String uid, String phone,
String code, String scenes,
SmsCodeScenesConfigBO scenesConfigBO) {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("phone", phone); params.put("phone", phone);
SmsCodeScenesConfigBO scenesConfig = smsConfig.getScenesConfig(scenes); params.put("message", String.format(scenesConfigBO.getMessageFormat(), code, scenesConfigBO.getCodeValidMinutes()));
params.put("message", String.format(scenesConfig.getMessageFormat(), code, scenesConfig.getCodeValidMinutes()));
params.put("level", 1); params.put("level", 1);
params.put("uid", uid); params.put("uid", uid);
params.put("topic", String.format(TOPIC_FORMAT, scenes)); params.put("topic", String.format(TOPIC_FORMAT, scenes));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment