|  | @@ -1,5 +1,6 @@
 | 
	
		
			
				|  |  |  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;
 | 
	
	
		
			
				|  | @@ -14,7 +15,8 @@ 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 {
 | 
	
	
		
			
				|  | @@ -22,78 +24,50 @@ public class TenantInfoSendMsgServiceImpl implements TenantInfoSendMsgService {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SysMessageService sysMessageService;
 | 
	
		
			
				|  |  | +    @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<>();
 | 
	
		
			
				|  |  | -    //init
 | 
	
		
			
				|  |  | -    private static final Map<String, Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum>> sendMsgTypeEn = new HashMap<>();
 | 
	
		
			
				|  |  | +    //平台向机构发送信息,目前有 机构开通、机构续费、机构即将到期提醒、云教室余额不足
 | 
	
		
			
				|  |  | +    public static final String PLATFORM_SEND = "PLATFORM_SEND";
 | 
	
		
			
				|  |  | +    //平台向机构发送信息 开通、续费、即将到期提醒、云教室余额不足
 | 
	
		
			
				|  |  | +    private static final Map<MessageSenderPluginContext.MessageSender, MessageTypeEnum> PLATFORM_ALL_MSG_ENUM = 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);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        //init
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(OPEN, openMsgEnum);
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(RENEW, renewMsgEnum);
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(EXPIRATION, expirationMsgEnum);
 | 
	
		
			
				|  |  | -        sendMsgTypeEn.put(INSUFFICIENT, insufficientMsgEnum);
 | 
	
		
			
				|  |  | +        //开通、续费、即将到期提醒、云教室余额不足 以上都是平台向机构发信息
 | 
	
		
			
				|  |  | +        PLATFORM_ALL_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.EMAIL, EMAIL_TENANT_ACTIVATION_SUCCESSFUL);
 | 
	
		
			
				|  |  | +        PLATFORM_ALL_MSG_ENUM.put(MessageSenderPluginContext.MessageSender.AWSMS, SMS_TENANT_ACTIVATION_SUCCESSFUL);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * 发送邮件及短信提醒
 | 
	
		
			
				|  |  | +     * 以平台的名义发送邮件及短信
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param type   OPEN/RENEW/EXPIRATION之类的
 | 
	
		
			
				|  |  | -     * @param userId 机构用户id
 | 
	
		
			
				|  |  | -     * @param email  发送的地址 电话或者邮件
 | 
	
		
			
				|  |  | -     * @param objs   发送的信息
 | 
	
		
			
				|  |  | +     * @param email 发送的地址 电话或者邮件
 | 
	
		
			
				|  |  | +     * @param objs  发送的信息
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public void sendToAll(String type, Integer userId, String email, String phone, Object[] objs) {
 | 
	
		
			
				|  |  | +    public void platformSendToAll(String email, String phone, Object[] objs) {
 | 
	
		
			
				|  |  |          Map<Integer, String> sendPar = new HashMap<>();
 | 
	
		
			
				|  |  | +        Integer userId = tenantInfoDao.queryUserByTenantId(-1);
 | 
	
		
			
				|  |  |          if (Objects.isNull(userId)) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        log.info("platformSendToAll>>> email {} phone {} objs {} sendPar {}", email, phone, objs, sendPar);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          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,
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.EMAIL,
 | 
	
		
			
				|  |  | +                    PLATFORM_ALL_MSG_ENUM.get(MessageSenderPluginContext.MessageSender.EMAIL),
 | 
	
		
			
				|  |  | +                    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,
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS,
 | 
	
		
			
				|  |  | +                    PLATFORM_ALL_MSG_ENUM.get(MessageSenderPluginContext.MessageSender.AWSMS),
 | 
	
		
			
				|  |  | +                    sendPar, null, 0, null,
 | 
	
		
			
				|  |  |                      "SYSTEM", objs);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  }
 |