he2802 1 年間 前
コミット
9c18bf5fca

+ 26 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/alisms/service/impl/AliSmsServiceImpl.java

@@ -19,7 +19,9 @@ import com.zhongzheng.modules.alisms.vo.ResultBean;
 import com.zhongzheng.modules.base.bo.SmsAddBo;
 import com.zhongzheng.modules.base.service.ISmsService;
 import com.zhongzheng.modules.distribution.service.IDistributionSellerService;
+import com.zhongzheng.modules.system.domain.SysConfig;
 import com.zhongzheng.modules.system.domain.SysTenant;
+import com.zhongzheng.modules.system.service.ISysConfigService;
 import com.zhongzheng.modules.system.service.ISysTenantService;
 import com.zhongzheng.modules.system.service.ISysUserService;
 import com.zhongzheng.modules.user.domain.User;
@@ -74,8 +76,22 @@ public class AliSmsServiceImpl implements IAliSmsService {
     @Autowired
     private ISysTenantService iSysTenantService;
 
+    @Autowired
+    private ISysConfigService configService;
+
+    public void initData(){
+        if(Validator.isNotEmpty(configService.selectConfigByKeyNoCache("sms.signName"))){
+            SIGNNAME = configService.selectConfigByKeyNoCache("sms.signName");
+        }else{
+            SysConfig config = configService.getSysConfigByKeyTenant("sms.signName",867735392558919680L);
+            SIGNNAME = config.getConfigValue();
+        }
+
+    }
+
     @Override
     public ResultBean sendSms(String tel, String param) {
+        initData();
         try{
             SendSmsResponse response = SmsUtils.sendSms(tel,SIGNNAME,REGISTERTEMPLATECODE,param,ACCESSKEYID,ACCESSKEYSECRET);
             System.out.println(response);
@@ -88,6 +104,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public ResultBean sendInformSms(String tel, String param,String code) {
+        initData();
         //发送带指定短信code带参数发送不同短信内容
         try{
             SendSmsResponse response = SmsUtils.sendSms(tel,SIGNNAME,code,param,ACCESSKEYID,ACCESSKEYSECRET);
@@ -110,6 +127,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendRegisterSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }
@@ -143,6 +161,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendForgetSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }
@@ -175,6 +194,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendLoginSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }
@@ -207,6 +227,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendPwdSms(String tel,String code) {
+        initData();
         try{
             Map<String,Object> param = new HashMap<>();
             param.put("name","");
@@ -230,6 +251,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendBindNewTelSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }
@@ -262,6 +284,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendSellerRegisterSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }
@@ -295,6 +318,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendSellerForgetSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }
@@ -327,6 +351,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendSellerLoginSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }
@@ -359,6 +384,7 @@ public class AliSmsServiceImpl implements IAliSmsService {
 
     @Override
     public Boolean sendLiveSms(String tel) {
+        initData();
         if(tel==null){
             throw new CustomException("手机号码不能为空");
         }