|  | @@ -11,11 +11,13 @@ import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.util.Arrays;
 | 
	
		
			
				|  |  |  import java.util.HashMap;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  import java.util.Objects;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import static com.ym.mec.biz.dal.enums.MessageTypeEnum.*;
 | 
	
		
			
				|  |  | +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;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
 | 
	
	
		
			
				|  | @@ -26,45 +28,21 @@ public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TenantInfoDao tenantInfoDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    //开通
 | 
	
		
			
				|  |  | -    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> openMsgEnum = new HashMap<>();
 | 
	
		
			
				|  |  | -    //续费
 | 
	
		
			
				|  |  | -    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> renewMsgEnum = new HashMap<>();
 | 
	
		
			
				|  |  | -    //即将到期提醒
 | 
	
		
			
				|  |  | -    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> expirationMsgEnum = new HashMap<>();
 | 
	
		
			
				|  |  | -    //云教室余额不足
 | 
	
		
			
				|  |  | -    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> insufficientMsgEnum = new HashMap<>();
 | 
	
		
			
				|  |  | +    //平台向机构发送信息,目前有 机构开通、机构续费、机构即将到期提醒、云教室余额不足
 | 
	
		
			
				|  |  | +    public static final String PLATFORM_SEND = "PLATFORM_SEND";
 | 
	
		
			
				|  |  | +    //邮件 和 短信
 | 
	
		
			
				|  |  | +    public static final MessageSenderPluginContext.MessageSender[] SENDER_ALL_ENUM = {MessageSenderPluginContext.MessageSender.EMAIL, MessageSenderPluginContext.MessageSender.AWSMS};
 | 
	
		
			
				|  |  | +    //平台向机构发送信息 开通、续费、即将到期提醒、云教室余额不足
 | 
	
		
			
				|  |  | +    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> PLATFORM_ALL_MSG_ENUM = new HashMap<>();
 | 
	
		
			
				|  |  |      //init
 | 
	
		
			
				|  |  | -    private static final Map<String, Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum>> sendMsgTypeEn = new HashMap<>();
 | 
	
		
			
				|  |  | +    private static final Map<String, Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum>> SEND_MSG_TYPE = new HashMap<>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      static {
 | 
	
		
			
				|  |  | -        //开通
 | 
	
		
			
				|  |  | -        openMsgEnum.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_ACTIVATION_SUCCESSFUL);
 | 
	
		
			
				|  |  | -        openMsgEnum.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_ACTIVATION_SUCCESSFUL);
 | 
	
		
			
				|  |  | -        //续费
 | 
	
		
			
				|  |  | -        renewMsgEnum.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_RENEWAL_SUCCESSFUL);
 | 
	
		
			
				|  |  | -        renewMsgEnum.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_RENEWAL_SUCCESSFUL);
 | 
	
		
			
				|  |  | -        //即将到期提醒
 | 
	
		
			
				|  |  | -        expirationMsgEnum.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_EXPIRATION_REMINDERS);
 | 
	
		
			
				|  |  | -        expirationMsgEnum.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_EXPIRATION_REMINDERS);
 | 
	
		
			
				|  |  | -        //云教室余额不足
 | 
	
		
			
				|  |  | -        insufficientMsgEnum.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_INSUFFICIENT_BALANCE);
 | 
	
		
			
				|  |  | -        insufficientMsgEnum.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_INSUFFICIENT_BALANCE);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        //开通、续费、即将到期提醒、云教室余额不足 以上都是平台向机构发信息
 | 
	
		
			
				|  |  | +        PLATFORM_ALL_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_ACTIVATION_SUCCESSFUL);
 | 
	
		
			
				|  |  | +        PLATFORM_ALL_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_ACTIVATION_SUCCESSFUL);
 | 
	
		
			
				|  |  |          //init
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(OPEN, openMsgEnum);
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(RENEW, renewMsgEnum);
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(EXPIRATION, expirationMsgEnum);
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(INSUFFICIENT, insufficientMsgEnum);
 | 
	
		
			
				|  |  | +        SEND_MSG_TYPE.put(PLATFORM_SEND, PLATFORM_ALL_MSG_ENUM);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -81,22 +59,13 @@ public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
 | 
	
		
			
				|  |  |          if (Objects.isNull(userId)) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (StringUtils.isNotBlank(email)) {
 | 
	
		
			
				|  |  | -            sendPar.put(userId, email);
 | 
	
		
			
				|  |  | -            MessageSenderPluginContext.MessageSender emailEn = MessageSenderPluginContext.MessageSender.EMAIL;
 | 
	
		
			
				|  |  | -            sysMessageService.batchSendMessage(emailEn,
 | 
	
		
			
				|  |  | -                    sendMsgTypeEn.get(type).get(emailEn), sendPar, null, 0, null,
 | 
	
		
			
				|  |  | -                    "SYSTEM", objs);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        sendPar.put(userId, email);
 | 
	
		
			
				|  |  | +        if (StringUtils.isNotBlank(email) && StringUtils.isNotBlank(phone)) {
 | 
	
		
			
				|  |  | +            Arrays.stream(SENDER_ALL_ENUM).forEach(en -> sysMessageService.batchSendMessage(en,
 | 
	
		
			
				|  |  | +                    SEND_MSG_TYPE.get(type).get(en), sendPar, null, 0, null,
 | 
	
		
			
				|  |  | +                    "SYSTEM", objs));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if (StringUtils.isNotBlank(phone)) {
 | 
	
		
			
				|  |  | -            MessageSenderPluginContext.MessageSender smsEn = MessageSenderPluginContext.MessageSender.AWSMS;
 | 
	
		
			
				|  |  | -            sendPar.put(userId, phone);
 | 
	
		
			
				|  |  | -            sysMessageService.batchSendMessage(smsEn,
 | 
	
		
			
				|  |  | -                    sendMsgTypeEn.get(type).get(smsEn), sendPar, null, 0, null,
 | 
	
		
			
				|  |  | -                    "SYSTEM", objs);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |