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 {
*/
private Boolean sendCode(String scenes, String mobilePhone) {
log.error("[op:sendSmsCode] sendCode...");
SmsCodeScenesConfigBO scenesConfigBO = smsConfig.getScenesConfig(scenes);
if(null == scenesConfigBO){
throw new BizException("短信配置错误");
}
// 生成6位随机数字
String code = RandomUtils.randomNumber(6);
// uas发送验证码
boolean success = iUasClient.sendSmsCode(LoginUserContextHolder.get().getOpenId(), mobilePhone, code, scenes);
boolean success = iUasClient.sendSmsCode(LoginUserContextHolder.get().getOpenId(),
mobilePhone, code, scenes, scenesConfigBO);
if (!success) {
return false;
}
SmsCodeScenesConfigBO smsCodeScenesConfigBO = smsConfig.getScenesConfig(scenes);
int sendIntervalSeconds = smsCodeScenesConfigBO.getSendIntervalSeconds();
int codeValidMinutes = smsCodeScenesConfigBO.getCodeValidMinutes();
int sendIntervalSeconds = scenesConfigBO.getSendIntervalSeconds();
int codeValidMinutes = scenesConfigBO.getCodeValidMinutes();
// 标记验证码已发送
String sendCodeKey = String.format(SmsConstant.SMS_SEND_INTERVAL_KEY, scenes, mobilePhone);
redisClient.setStr(sendCodeKey, String.valueOf(System.currentTimeMillis()), sendIntervalSeconds);
......
package com.netease.yanxuan.wx.store.sharer.integration.client;
import com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO;
/**
* @Description Uas服务
* @Author fanjiaxin
......@@ -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;
import com.alibaba.fastjson.JSONObject;
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.SmsConfig;
import com.netease.yanxuan.wx.store.sharer.integration.handler.RestTemplateHandler;
import com.netease.yanxuan.wx.store.sharer.integration.meta.model.bo.SmsCodeScenesConfigBO;
import lombok.RequiredArgsConstructor;
......@@ -26,7 +25,6 @@ import java.util.Map;
@Service
public class UasClientImpl implements IUasClient {
private final SmsConfig smsConfig;
private final RpcConfig rpcConfig;
private final RestTemplateHandler restTemplateHandler;
......@@ -44,8 +42,9 @@ public class UasClientImpl implements IUasClient {
* @return
*/
@Override
public boolean sendSmsCode(String uid, String phone, String code, String scenes) {
Map<String, Object> params = assembleSmsArg(uid, phone, code, scenes);
public boolean sendSmsCode(String uid, String phone, String code,
String scenes, SmsCodeScenesConfigBO scenesConfigBO) {
Map<String, Object> params = assembleSmsArg(uid, phone, code, scenes, scenesConfigBO);
String httpUrl = rpcConfig.getUasUrl() + SMS_SEND_PATH + PRODUCT;
try {
JSONObject rpcResult = restTemplateHandler.execute(httpUrl, HttpMethod.POST, params, JSONObject.class);
......@@ -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<>();
params.put("phone", phone);
SmsCodeScenesConfigBO scenesConfig = smsConfig.getScenesConfig(scenes);
params.put("message", String.format(scenesConfig.getMessageFormat(), code, scenesConfig.getCodeValidMinutes()));
params.put("message", String.format(scenesConfigBO.getMessageFormat(), code, scenesConfigBO.getCodeValidMinutes()));
params.put("level", 1);
params.put("uid", uid);
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