|
@@ -49,7 +49,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.*;
|
|
|
+import static com.ym.mec.biz.dal.enums.MessageTypeEnum.*;
|
|
|
|
|
|
@Service
|
|
|
public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo> implements TenantInfoService {
|
|
@@ -92,15 +92,10 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
@Autowired
|
|
|
private SysMessageService sysMessageService;
|
|
|
@Autowired
|
|
|
- private TenantInfoSendMsgService tenantInfoSendMsgService;
|
|
|
- @Autowired
|
|
|
private SysConfigService sysConfigService;
|
|
|
@Autowired
|
|
|
private ContractService contractService;
|
|
|
|
|
|
- @Value("${spring.profiles.active:dev}")
|
|
|
- private String profiles;
|
|
|
-
|
|
|
/**
|
|
|
* 新增机构
|
|
|
*/
|
|
@@ -271,7 +266,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void opsTenantState(Integer id, Integer state) {
|
|
|
+ public Map<String, Object> opsTenantState(Integer id, Integer state) {
|
|
|
if (Objects.nonNull(state) && state == 1 || state == 2) {
|
|
|
TenantInfo tenantInfo = baseMapper.selectById(id);
|
|
|
if (Objects.isNull(tenantInfo)) {
|
|
@@ -294,12 +289,10 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
}
|
|
|
}
|
|
|
baseMapper.updateById(tenantInfo);
|
|
|
- //在执行了修改机构信息之后,并且有返回密码(第一次开通机构会生成登录密码并返回)就发送邮件及短信提醒
|
|
|
- if (StringUtils.isNotBlank(pw)) {
|
|
|
- Object[] msg = {tenantInfo.getName(), tenantInfo.getPhone(), pw, "https://online.dayaedu.com"};
|
|
|
- tenantInfoSendMsgService.platformSendToAll(OPEN, tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
|
|
|
- }
|
|
|
- return;
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("pw", pw);
|
|
|
+ result.put("tenantInfo", tenantInfo);
|
|
|
+ return result;
|
|
|
}
|
|
|
throw new BizException("传入机构状态参数异常!");
|
|
|
}
|
|
@@ -579,10 +572,37 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
productInfo.setExpiryCount(productInfo.getExpiryCount() + val);
|
|
|
tenantProductInfoService.updateById(productInfo);
|
|
|
|
|
|
- TenantInfo tenantInfo = this.getById(tenantId);
|
|
|
- //发送邮件及短信提醒
|
|
|
- Object[] msg = {tenantInfo.getName()};
|
|
|
- tenantInfoSendMsgService.platformSendToAll(RENEW, tenantInfo.getUserId(), tenantInfo.getEmail(), tenantInfo.getPhone(), msg);
|
|
|
+ Map<String, Object> par = new HashMap<>();
|
|
|
+ par.put("tenantId", tenantId);
|
|
|
+ List<TenantInfoInfoPageVo> tenantInfos = baseMapper.queryPage(par);
|
|
|
+ if(CollectionUtils.isNotEmpty(tenantInfos)){
|
|
|
+ TenantInfoInfoPageVo tenantInfo = tenantInfos.get(0);
|
|
|
+ //邮件
|
|
|
+ if (StringUtils.isNotBlank(tenantInfo.getEmail())) {
|
|
|
+ //机构名称 服务名称 学员上限 有效期
|
|
|
+ Object[] emailMsg = {tenantInfo.getName(), tenantInfo.getServeName(), tenantInfo.getStudentUpLimit(), DateUtils.formatDate(expiryDate, "yyyy年MM月dd日")};
|
|
|
+ Map<Integer, String> sendPar = new HashMap<>();
|
|
|
+ sendPar.put(tenantInfo.getUserId(), tenantInfo.getEmail());
|
|
|
+ log.info("platformSendToAll>>> 续费 receiveUserId {} email {} objs {} sendPar {}", tenantInfo.getUserId(), tenantInfo.getEmail(), emailMsg, sendPar);
|
|
|
+ sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.EMAIL,
|
|
|
+ EMAIL_TENANT_RENEWAL_SUCCESSFUL,
|
|
|
+ sendPar, null, 0, null,
|
|
|
+ "SYSTEM", emailMsg);
|
|
|
+ }
|
|
|
+ //短信
|
|
|
+ if (StringUtils.isNotBlank(tenantInfo.getPhone())) {
|
|
|
+ //机构名称
|
|
|
+ Object[] phoneMsg = {tenantInfo.getName()};
|
|
|
+ Map<Integer, String> sendPar2 = new HashMap<>();
|
|
|
+ sendPar2.put(tenantInfo.getUserId(), tenantInfo.getPhone());
|
|
|
+ log.info("platformSendToAll>>> 续费 receiveUserId {} phone {} objs {} sendPar {}", tenantInfo.getUserId(), tenantInfo.getPhone(), phoneMsg, sendPar2);
|
|
|
+ sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.AWSMS,
|
|
|
+ SMS_TENANT_RENEWAL_SUCCESSFUL,
|
|
|
+ sendPar2, null, 0, null,
|
|
|
+ "SYSTEM", phoneMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//释放锁
|
|
|
bucket.delete();
|
|
|
}
|
|
@@ -806,7 +826,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
if (tenantInfo != null) {
|
|
|
request.setAttribute("datasourceId", tenantInfo.getDataSource());
|
|
|
} else {
|
|
|
- throw new BizException("机构信息异常,请联系管理员");
|
|
|
+ throw new BizException("机构服务已停用,请联系机构管理员");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -823,16 +843,16 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
*/
|
|
|
@Override
|
|
|
public void checkTenantState() {
|
|
|
- Date now = LocalDate.now().toDate();
|
|
|
-
|
|
|
//查询还差30天和1天过期的机构,并发送邮件和短信
|
|
|
Integer[] days = {30, 1};
|
|
|
- Arrays.stream(days).forEach(d -> checkAndSend(now, d));
|
|
|
+ Arrays.stream(days).forEach(this::checkAndSend);
|
|
|
|
|
|
+ Date now = LocalDate.now().toDate();
|
|
|
//查询过期并且没有停用的机构,将其停用
|
|
|
Date maturity = DateUtils.addDays(now, -1);
|
|
|
Map<String, Object> par = new HashMap<>();
|
|
|
par.put("expiryDate", maturity);
|
|
|
+ par.put("state", 1);
|
|
|
List<TenantInfoInfoPageVo> maturityTenant = baseMapper.queryPage(par);
|
|
|
maturityTenant.forEach(t -> {
|
|
|
TenantInfo tenantInfo = baseMapper.selectById(t.getId());
|
|
@@ -843,9 +863,11 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void checkAndSend(Date now, int i) {
|
|
|
+ private void checkAndSend(int i) {
|
|
|
+ Date now = LocalDate.now().toDate();
|
|
|
Date expiryDate = DateUtils.addDays(now, i);
|
|
|
Map<String, Object> par = new HashMap<>();
|
|
|
+ par.put("state", 1);
|
|
|
par.put("expiryDate", expiryDate);
|
|
|
List<TenantInfoInfoPageVo> oneTenant = baseMapper.queryPage(par);
|
|
|
send(oneTenant, DateUtils.formatDate(expiryDate, "yyyy年MM月dd日"));
|
|
@@ -853,8 +875,31 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
|
|
|
private void send(List<TenantInfoInfoPageVo> infoList, String dateStr) {
|
|
|
infoList.forEach(t -> {
|
|
|
- Object[] objects = {t.getName(), t.getServeName(), dateStr, t.getStudentUpLimit()};
|
|
|
- tenantInfoSendMsgService.platformSendToAll(EXPIRATION, t.getUserId(), t.getEmail(), t.getPhone(), objects);
|
|
|
+ //邮件
|
|
|
+ if (StringUtils.isNotBlank(t.getEmail())) {
|
|
|
+ //机构名称 服务名称 到期时间 学员数量
|
|
|
+ Object[] emailMsg = {t.getName(), t.getServeName(), dateStr, t.getStudentUpLimit()};
|
|
|
+ Map<Integer, String> sendPar = new HashMap<>();
|
|
|
+ sendPar.put(t.getUserId(), t.getEmail());
|
|
|
+ log.info("platformSendToAll>>> 即将到期 receiveUserId {} email {} objs {} sendPar {}", t.getUserId(), t.getEmail(), emailMsg, sendPar);
|
|
|
+ sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.EMAIL,
|
|
|
+ EMAIL_TENANT_EXPIRATION_REMINDERS,
|
|
|
+ sendPar, null, 0, null,
|
|
|
+ "SYSTEM", emailMsg);
|
|
|
+ }
|
|
|
+ //短信
|
|
|
+ if (StringUtils.isNotBlank(t.getPhone())) {
|
|
|
+ //机构名称 到期时间
|
|
|
+ Object[] phoneMsg = {t.getName(), dateStr};
|
|
|
+ Map<Integer, String> sendPar2 = new HashMap<>();
|
|
|
+ sendPar2.put(t.getUserId(), t.getPhone());
|
|
|
+ log.info("platformSendToAll>>> 即将到期 receiveUserId {} phone {} objs {} sendPar {}", t.getUserId(), t.getPhone(), phoneMsg, sendPar2);
|
|
|
+ sysMessageService.batchSendMessage(-1, MessageSenderPluginContext.MessageSender.AWSMS,
|
|
|
+ SMS_TENANT_EXPIRATION_REMINDERS,
|
|
|
+ sendPar2, null, 0, null,
|
|
|
+ "SYSTEM", phoneMsg);
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|