Commit 9e74db3f by 张富康

feat(notification): 增加有效引荐数复核相关企微通知功能

- 根据配置T1时间,每天早晚7点触发区域经理提醒
- 调整通知总部运营逻辑,T1时间内多时段推送提醒
- 新增区域经理提交异常有效引荐数时通知线上运营功能
- 实现线上运营修正有效引荐数后通知区域运营机制
- 优化企微消息发送流程,增加异常捕获与日志记录
- 统一配置获取方式,提升推送通知的灵活性和可维护性
1 parent 7c591f27
...@@ -35,6 +35,8 @@ public class EffectiveReferralReviewQwService { ...@@ -35,6 +35,8 @@ public class EffectiveReferralReviewQwService {
/** /**
* 通知区域经理 * 通知区域经理
* 备注1:根据晓凯配置T1时间,在有效时间内,每天早上7:00 和 每晚7:00,都触发提醒
* 备注2:复核门店有效引荐数,区域经理管辖内的门店,均已提交后,未到T1时间,不在触发企微通知
*/ */
public void qwManagerNotification() { public void qwManagerNotification() {
// 判断当前时间是否在T1范围内 如果不在则return // 判断当前时间是否在T1范围内 如果不在则return
...@@ -96,7 +98,7 @@ public class EffectiveReferralReviewQwService { ...@@ -96,7 +98,7 @@ public class EffectiveReferralReviewQwService {
/** /**
* 通知总部运营 * 通知总部运营 如在T1时间配置内,都有未复核的门店有效引荐数,需每晚6:30和7点30在推送一次,早上7点半在推送一次
*/ */
public void qwOnLineNotification() { public void qwOnLineNotification() {
// 判断当前时间是否在T1范围内 如果不在则return // 判断当前时间是否在T1范围内 如果不在则return
...@@ -114,12 +116,12 @@ public class EffectiveReferralReviewQwService { ...@@ -114,12 +116,12 @@ public class EffectiveReferralReviewQwService {
// 上个月 // 上个月
DateTime lastMonthDate = DateUtil.offsetMonth(new Date(), -1); DateTime lastMonthDate = DateUtil.offsetMonth(new Date(), -1);
String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN); String lastMonth = DateUtil.format(lastMonthDate, DatePattern.NORM_MONTH_PATTERN);
// 查询是否有需要待复核的数据
int count = effectiveReferralReviewMapper.queryOnlineNoHandlerCount(lastMonth); int count = effectiveReferralReviewMapper.queryOnlineNoHandlerCount(lastMonth);
if (count <= 0) { if (count <= 0) {
log.info("没有需要符合的有效引荐数据"); log.info("没有需要符合的有效引荐数据");
return; return;
} }
// 查询是否有需要待复核的数据
String mobilePhonesStr = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.onLine.mobilePhone", String.class, "15622765546"); String mobilePhonesStr = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.onLine.mobilePhone", String.class, "15622765546");
List<String> mobilePhoneList = StrUtil.split(mobilePhonesStr, ","); List<String> mobilePhoneList = StrUtil.split(mobilePhonesStr, ",");
if (CollUtil.isEmpty(mobilePhoneList)) { if (CollUtil.isEmpty(mobilePhoneList)) {
...@@ -154,6 +156,107 @@ public class EffectiveReferralReviewQwService { ...@@ -154,6 +156,107 @@ public class EffectiveReferralReviewQwService {
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO(); WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title); textCard.setTitle(title);
textCard.setDescription(description); textCard.setDescription(description);
// textCard.setBtnTxt(btnTxt);
// textCard.setUrl(url);
requestDTO.setTextCard(textCard);
try {
qWManager.sendMessage(requestDTO);
} catch (Exception e) {
log.error("发送企微应用消息异常:", e);
}
}
/**
* 当区域经理有提交【有效引荐数小于或大于XX品牌交车数】时即时通知提醒线上运营
*/
public void qwOnlineNotification() {
String mobilePhonesStr = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.onLine.mobilePhone", String.class, "15622765546");
List<String> mobilePhoneList = StrUtil.split(mobilePhonesStr, ",");
if (CollUtil.isEmpty(mobilePhoneList)) {
log.info("没有未处理有效引荐数对应的区域运营手机号");
return;
}
Map<String, String> sendUserIds = qWManager.getSendUserIds();
String joinedUserIds = qWManager.getJoinedUserIds(sendUserIds, mobilePhoneList);
log.info("发送给的企微用户id:{}", joinedUserIds);
if (StrUtil.isBlank(joinedUserIds)) {
log.info("未符合有效引荐数对应的总部运营企微id为空");
return;
}
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
// dev = 44209813 test = 44209813
// 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id", Integer.class, 44202977);
// todz 带确认
String title = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.title", String.class, "有效引荐数复核提醒通知");
String btnTxt = OrePropertyConfigurer.getProperty("dj.send.work.wechat.btnTxt", String.class, "去处理");
String url = OrePropertyConfigurer.getProperty("dj.send.work.wechat.perf.url", String.class, "");
String descriptionEvn = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.description", String.class,
"你好,本月的门店复核有效引荐数存在未复核的,请尽快去完成~ \n" +
"亲,超过总部配置的每月{}号,就无法复核门店有效引荐数了哦");
// 获取endDate的日期数
// Integer dayDate = DateUtil.dayOfMonth(endDate);
requestDTO.setMerchantId(merchantId);
requestDTO.setToUser(joinedUserIds);
requestDTO.setMsgType(WorkWechatAppMessageTypeEnum.TEXTCARD.getValue());
// String description = StrUtil.format(descriptionEvn, dayDate);
String description = StrUtil.format(descriptionEvn);
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
// textCard.setBtnTxt(btnTxt);
// textCard.setUrl(url);
requestDTO.setTextCard(textCard);
try {
qWManager.sendMessage(requestDTO);
} catch (Exception e) {
log.error("发送企微应用消息异常:", e);
}
}
/**
* 线上运营【修正实际有效引荐数】,且确认后,及时触发通知给到区域运营,根据修正实际有效引荐数,所属的门店,以及区域运营管辖门店推送到对应的区域经理,
* 只推送1次,点击“查看”调整转到,区域运营小程序该门店该月复核有效有引荐数页面
* @param changedMerchantId 修改有效引荐数的商户id
* @param changedMerchantName 修改有效引荐数的商户名称
* @param mobilePhone 需要通知的区域运营手机号
* @param oldCount 修正前的有效引荐数
* @param newCount 修正后的有效引荐数
*/
public void changeCountManagerQwNotification(Integer changedMerchantId, String changedMerchantName, String mobilePhone, Integer oldCount, Integer newCount) {
List<String> mobilePhoneList = StrUtil.split(mobilePhone, ",");
if (CollUtil.isEmpty(mobilePhoneList)) {
log.info("没有未处理有效引荐数对应的区域运营手机号");
return;
}
Map<String, String> sendUserIds = qWManager.getSendUserIds();
String joinedUserIds = qWManager.getJoinedUserIds(sendUserIds, mobilePhoneList);
log.info("发送给的企微用户id:{}", joinedUserIds);
if (StrUtil.isBlank(joinedUserIds)) {
log.info("未符合有效引荐数对应的总部运营企微id为空");
return;
}
SendWorkWechatMessageRequestDTO requestDTO = new SendWorkWechatMessageRequestDTO();
// dev = 44209813 test = 44209813
// 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id", Integer.class, 44202977);
// todz 带确认
String title = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.title", String.class, "有效引荐数复核提醒通知");
String btnTxt = OrePropertyConfigurer.getProperty("dj.send.work.wechat.btnTxt", String.class, "查看");
String url = OrePropertyConfigurer.getProperty("dj.send.work.wechat.perf.url", String.class, "");
String descriptionEvn = OrePropertyConfigurer.getProperty("dj.send.work.wechat.effectiveReferralReview.description", String.class,
"你好,本月的门店复核有效引荐数存在未复核的,请尽快去完成~ \n" +
"亲,超过总部配置的每月{}号,就无法复核门店有效引荐数了哦");
requestDTO.setMerchantId(merchantId);
requestDTO.setToUser(joinedUserIds);
requestDTO.setMsgType(WorkWechatAppMessageTypeEnum.TEXTCARD.getValue());
String description = StrUtil.format(descriptionEvn);
WorkWechatTextCardMessageDTO textCard = new WorkWechatTextCardMessageDTO();
textCard.setTitle(title);
textCard.setDescription(description);
textCard.setBtnTxt(btnTxt); textCard.setBtnTxt(btnTxt);
textCard.setUrl(url); textCard.setUrl(url);
requestDTO.setTextCard(textCard); requestDTO.setTextCard(textCard);
...@@ -163,4 +266,6 @@ public class EffectiveReferralReviewQwService { ...@@ -163,4 +266,6 @@ public class EffectiveReferralReviewQwService {
log.error("发送企微应用消息异常:", e); log.error("发送企微应用消息异常:", e);
} }
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!