瀏覽代碼

修改发送的模版选择

hgw 3 年之前
父節點
當前提交
005a2ccdb6

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/TenantInfoSendMsgService.java

@@ -10,5 +10,5 @@ public interface TenantInfoSendMsgService {
      * @param phone         接收短信的电话
      * @param objs          发送的信息
      */
-    void platformSendToAll(Integer receiveUserId, String email, String phone, Object[] objs);
+    void platformSendToAll(String type, Integer receiveUserId, String email, String phone, Object[] objs);
 }

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantAssetsInfoServiceImpl.java

@@ -26,6 +26,8 @@ import java.util.*;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
+import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.INSUFFICIENT;
+
 /**
  * 机构资产信息(TenantAssetsInfo)表服务实现类
  *
@@ -153,7 +155,7 @@ public class TenantAssetsInfoServiceImpl extends ServiceImpl<TenantAssetsInfoDao
                 //当前余额大于300 并且 本次扣除后剩余额度小于300 就发信息提醒
                 if (balance.compareTo(new BigDecimal(300)) > -1 && balance.compareTo(after) < 0) {
                     TenantInfo t = tenantInfoService.getById(course.getTenantId());
-                    tenantInfoSendMsgService.platformSendToAll(t.getUserId(), t.getEmail(), t.getPhone(), new Object[]{t.getName()});
+                    tenantInfoSendMsgService.platformSendToAll(INSUFFICIENT,t.getUserId(), t.getEmail(), t.getPhone(), new Object[]{t.getName()});
                 }
             }
         });

+ 40 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoSendMsgServiceImpl.java

@@ -1,6 +1,5 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.dao.TenantInfoDao;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.biz.service.TenantInfoSendMsgService;
@@ -15,8 +14,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 
-import static com.ym.mec.biz.dal.enums.MessageTypeEnum.EMAIL_TENANT_ACTIVATION_SUCCESSFUL;
-import static com.ym.mec.biz.dal.enums.MessageTypeEnum.SMS_TENANT_ACTIVATION_SUCCESSFUL;
+import static com.ym.mec.biz.dal.enums.MessageTypeEnum.*;
 
 @Service
 public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
@@ -24,18 +22,45 @@ public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
 
     @Autowired
     private SysMessageService sysMessageService;
-    @Autowired
-    private TenantInfoDao tenantInfoDao;
 
-    //平台向机构发送信息,目前有 机构开通、机构续费、机构即将到期提醒、云教室余额不足
-    public static final String PLATFORM_SEND = "PLATFORM_SEND";
-    //平台向机构发送信息 开通、续费、即将到期提醒、云教室余额不足
-    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> PLATFORM_ALL_MSG_ENUM = new HashMap<>();
+    //开通
+    public static final String OPEN = "open";
+    //续费
+    public static final String RENEW = "renew";
+    //即将到期提醒
+    public static final String EXPIRATION = "expiration";
+    //云教室余额不足
+    public static final String INSUFFICIENT = "insufficient";
+
+    //开通
+    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> OPEN_MSG_ENUM = new HashMap<>();
+    //续费
+    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> RENEW_MSG_ENUM = new HashMap<>();
+    //即将到期提醒
+    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> EXPIRATION_MSG_ENUM = new HashMap<>();
+    //云教室余额不足
+    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> INSUFFICIENT_MSG_ENUM = new HashMap<>();
+    //init
+    private static final Map<String, Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum>> PLATFORM_ALL_MSG_ENUM = new HashMap<>();
 
     static {
-        //开通、续费、即将到期提醒、云教室余额不足 以上都是平台向机构发信息
-        PLATFORM_ALL_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_ACTIVATION_SUCCESSFUL);
-        PLATFORM_ALL_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_ACTIVATION_SUCCESSFUL);
+        OPEN_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_ACTIVATION_SUCCESSFUL);
+        OPEN_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_ACTIVATION_SUCCESSFUL);
+        //续费
+        RENEW_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_RENEWAL_SUCCESSFUL);
+        RENEW_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_RENEWAL_SUCCESSFUL);
+        //即将到期提醒
+        EXPIRATION_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_EXPIRATION_REMINDERS);
+        EXPIRATION_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_EXPIRATION_REMINDERS);
+        //云教室余额不足
+        INSUFFICIENT_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_INSUFFICIENT_BALANCE);
+        INSUFFICIENT_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_INSUFFICIENT_BALANCE);
+
+        //init
+        PLATFORM_ALL_MSG_ENUM.put(OPEN, OPEN_MSG_ENUM);
+        PLATFORM_ALL_MSG_ENUM.put(RENEW, RENEW_MSG_ENUM);
+        PLATFORM_ALL_MSG_ENUM.put(EXPIRATION, EXPIRATION_MSG_ENUM);
+        PLATFORM_ALL_MSG_ENUM.put(INSUFFICIENT, INSUFFICIENT_MSG_ENUM);
     }
 
     /**
@@ -47,8 +72,7 @@ public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
      * @param objs          发送的信息
      */
     @Override
-    public void platformSendToAll(Integer receiveUserId, String email, String phone, Object[] objs) {
-
+    public void platformSendToAll(String type, Integer receiveUserId, String email, String phone, Object[] objs) {
         if (Objects.isNull(receiveUserId)) {
             return;
         }
@@ -58,7 +82,7 @@ public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
             sendPar.put(receiveUserId, email);
             log.info("platformSendToAll>>> receiveUserId {} email {} objs {} sendPar {}", receiveUserId, email, objs, sendPar);
             sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.EMAIL,
-                    PLATFORM_ALL_MSG_ENUM.get(MessageSenderPluginContext.MessageSender.EMAIL),
+                    PLATFORM_ALL_MSG_ENUM.get(type).get(MessageSenderPluginContext.MessageSender.EMAIL),
                     sendPar, null, 0, null,
                     "SYSTEM", objs);
         }
@@ -68,7 +92,7 @@ public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
             sendPar2.put(receiveUserId, phone);
             log.info("platformSendToAll>>> receiveUserId {} phone {} objs {} sendPar {}", receiveUserId, phone, objs, sendPar2);
             sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.AWSMS,
-                    PLATFORM_ALL_MSG_ENUM.get(MessageSenderPluginContext.MessageSender.AWSMS),
+                    PLATFORM_ALL_MSG_ENUM.get(type).get(MessageSenderPluginContext.MessageSender.AWSMS),
                     sendPar2, null, 0, null,
                     "SYSTEM", objs);
         }

+ 5 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java

@@ -49,6 +49,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
 
+import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.*;
+
 @Service
 public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo> implements TenantInfoService {
     private static final Logger log = LoggerFactory.getLogger(TenantInfoServiceImpl.class);
@@ -295,7 +297,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
             //在执行了修改机构信息之后,并且有返回密码(第一次开通机构会生成登录密码并返回)就发送邮件及短信提醒
             if (StringUtils.isNotBlank(pw)) {
                 Object[] msg = {tenantInfo.getName(), tenantInfo.getPhone(), pw, "https://online.dayaedu.com"};
-                tenantInfoSendMsgService.platformSendToAll(tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
+                tenantInfoSendMsgService.platformSendToAll(OPEN, tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
             }
             return;
         }
@@ -584,7 +586,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         TenantInfo tenantInfo = this.getById(tenantId);
         //发送邮件及短信提醒
         Object[] msg = {tenantInfo.getName()};
-        tenantInfoSendMsgService.platformSendToAll(tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
+        tenantInfoSendMsgService.platformSendToAll(RENEW, tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
         //释放锁
         bucket.delete();
     }
@@ -851,7 +853,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
     private void send(List<TenantInfo> infoList, String dateStr) {
         infoList.forEach(t -> {
             Object[] objects = {t.getName(), dateStr};
-            tenantInfoSendMsgService.platformSendToAll(t.getUserId(), t.getEmail(), t.getPhone(), objects);
+            tenantInfoSendMsgService.platformSendToAll(EXPIRATION, t.getUserId(), t.getEmail(), t.getPhone(), objects);
         });
     }