短信和飞书通知

This commit is contained in:
俞扬
2023-07-20 19:18:38 +08:00
parent dbad9b74f3
commit 4e97ea41e8
7 changed files with 151 additions and 9 deletions

View File

@@ -121,4 +121,9 @@ public class CommonConstants {
public static final String TRANSFER = "transfer"; public static final String TRANSFER = "transfer";
// 短信模版-意向申请审批通过
public static final String SMS_TEMPLATE_CODE_INTENT = "SMS_461990823";
// 短信模版-资质审核通过
public static final String SMS_TEMPLATE_CODE_VERIFY = "SMS_461980876";
} }

View File

@@ -0,0 +1,40 @@
package com.cool.store.enums;
/**
* @Author: young.yu
* @Date: 2023-07-19 16:49
* @Description:
*/
public enum FeiShuNoticeMsgEnum {
//分配招商经理
ALLOCATION_INVESTMENT_MANAGER("分配招商经理", "有新的线索 于 {0} 分配给您,线索信息{1}手机号{2},请及时跟进"),
//转让招商经理
TRANS_INVESTMENT_MANAGER("转让招商经理", "有新的线索 于 {0} 转让给您,线索信息{1}手机号{2},请及时跟进"),
//意向申请通知
INTENTION_APPLY("加盟意向申请", "您有一个【加盟意向申请】待审核,申请人{0}手机号{1}于 {2} 提交加盟意向申请,请及时处理");
private String title;
private String content;
FeiShuNoticeMsgEnum(String title, String content) {
this.title = title;
this.content = content;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}

View File

@@ -0,0 +1,13 @@
package com.cool.store.request;
import lombok.Data;
/**
* @Author: young.yu
* @Date: 2023-06-21 11:17
* @Description:
*/
@Data
public class IntentSmsReq {
private String deadLine;
}

View File

@@ -5,10 +5,12 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.cool.store.constants.CommonConstants;
import com.cool.store.context.CurrentUserHolder; import com.cool.store.context.CurrentUserHolder;
import com.cool.store.context.LoginUserInfo; import com.cool.store.context.LoginUserInfo;
import com.cool.store.dao.EnterpriseUserDAO; import com.cool.store.dao.EnterpriseUserDAO;
import com.cool.store.dao.HyInterviewDAO; import com.cool.store.dao.HyInterviewDAO;
import com.cool.store.dao.HyPartnerBaseInfoDAO;
import com.cool.store.dto.log.CreateQualifyVerifyDTO; import com.cool.store.dto.log.CreateQualifyVerifyDTO;
import com.cool.store.dto.log.LogBasicDTO; import com.cool.store.dto.log.LogBasicDTO;
import com.cool.store.dto.mdm.AccessTokenDTO; import com.cool.store.dto.mdm.AccessTokenDTO;
@@ -30,6 +32,7 @@ import com.cool.store.request.data.flow.SkrRelshipProve;
import com.cool.store.service.FlowService; import com.cool.store.service.FlowService;
import com.cool.store.service.HyPartnerLineInfoService; import com.cool.store.service.HyPartnerLineInfoService;
import com.cool.store.service.LogService; import com.cool.store.service.LogService;
import com.cool.store.service.SmsService;
import com.cool.store.utils.*; import com.cool.store.utils.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -94,6 +97,11 @@ public class FlowServiceImpl implements FlowService {
@Autowired @Autowired
private HyPartnerLineInfoService hyPartnerLineInfoService; private HyPartnerLineInfoService hyPartnerLineInfoService;
@Autowired
private SmsService smsService;
@Autowired
private HyPartnerBaseInfoDAO hyPartnerBaseInfoDAO;
@Override @Override
@Transactional @Transactional
public void createQualifyVerify(CreateQualifyVerifyReq request) throws ApiException, IOException { public void createQualifyVerify(CreateQualifyVerifyReq request) throws ApiException, IOException {
@@ -260,6 +268,9 @@ public class FlowServiceImpl implements FlowService {
//3. 生成通过函并修改数据库相关信息 //3. 生成通过函并修改数据库相关信息
//TODO 问题:如果因为 pdf 生成失败或者其他原因导致异常,但是由于 MDM 只是做回调,不对回调是否成功负责,会导致流程信息缺失 //TODO 问题:如果因为 pdf 生成失败或者其他原因导致异常,但是由于 MDM 只是做回调,不对回调是否成功负责,会导致流程信息缺失
genPassLetterAndUpdateDB(partnerName, verifyCity, passDate, interviewId); genPassLetterAndUpdateDB(partnerName, verifyCity, passDate, interviewId);
//发送加盟商资质审核通过短信
HyPartnerBaseInfoDO hyPartnerBaseInfoDO = hyPartnerBaseInfoDAO.getByPartnerLineId(partnerLineId);
smsService.sendSms(null, CommonConstants.SMS_TEMPLATE_CODE_VERIFY, hyPartnerBaseInfoDO.getMobile());
//记录日志 //记录日志
LogBasicDTO log = LogBasicDTO.builder().operateTime(DateUtil.format(new Date(), CoolDateUtils.DATE_FORMAT_SEC)) LogBasicDTO log = LogBasicDTO.builder().operateTime(DateUtil.format(new Date(), CoolDateUtils.DATE_FORMAT_SEC))
.build(); .build();

View File

@@ -8,15 +8,11 @@ import com.cool.store.constants.RedisConstant;
import com.cool.store.context.LoginUserInfo; import com.cool.store.context.LoginUserInfo;
import com.cool.store.context.PartnerUserHolder; import com.cool.store.context.PartnerUserHolder;
import com.cool.store.dao.*; import com.cool.store.dao.*;
import com.cool.store.dto.log.AddTagsDTO;
import com.cool.store.dto.log.LineLogInfo; import com.cool.store.dto.log.LineLogInfo;
import com.cool.store.dto.log.UserInfoUpdateDTO; import com.cool.store.dto.log.UserInfoUpdateDTO;
import com.cool.store.dto.log.WantInfoUpdateDTO; import com.cool.store.dto.log.WantInfoUpdateDTO;
import com.cool.store.dto.partner.PartnerIntentApplyInfoDTO; import com.cool.store.dto.partner.PartnerIntentApplyInfoDTO;
import com.cool.store.entity.HyOpenAreaInfoDO; import com.cool.store.entity.*;
import com.cool.store.entity.HyPartnerIntentInfoDO;
import com.cool.store.entity.HyPartnerLineInfoDO;
import com.cool.store.entity.HyPartnerUserInfoDO;
import com.cool.store.enums.*; import com.cool.store.enums.*;
import com.cool.store.exception.ServiceException; import com.cool.store.exception.ServiceException;
import com.cool.store.request.BaseUserInfoRequest; import com.cool.store.request.BaseUserInfoRequest;
@@ -78,6 +74,9 @@ public class HyPartnerIntentInfoServiceImpl implements HyPartnerIntentInfoServic
@Autowired @Autowired
private LogService logService; private LogService logService;
@Autowired
private NoticeService noticeService;
@Override @Override
public PageInfo<PartnerIntentApplyInfoVO> getPartnerIntentApplyList(String userId, String type, Integer pageSize, Integer pageNumber) { public PageInfo<PartnerIntentApplyInfoVO> getPartnerIntentApplyList(String userId, String type, Integer pageSize, Integer pageNumber) {
PartnerIntentApplyInfoVO partnerIntentApplyInfoVO = new PartnerIntentApplyInfoVO(); PartnerIntentApplyInfoVO partnerIntentApplyInfoVO = new PartnerIntentApplyInfoVO();
@@ -181,6 +180,7 @@ public class HyPartnerIntentInfoServiceImpl implements HyPartnerIntentInfoServic
@Override @Override
public Integer submitPartnerIntentInfo(PartnerIntentInfoRequest request) { public Integer submitPartnerIntentInfo(PartnerIntentInfoRequest request) {
boolean isUpdateIntentInfo = true;
log.info("HyPartnerClerkServiceImpl#submitPartnerIntentInfo request:{}", JSONObject.toJSONString(request)); log.info("HyPartnerClerkServiceImpl#submitPartnerIntentInfo request:{}", JSONObject.toJSONString(request));
if (StringUtil.isBlank(request.getPartnerId()) || Objects.isNull(request.getPartnerLineId())){ if (StringUtil.isBlank(request.getPartnerId()) || Objects.isNull(request.getPartnerLineId())){
throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED); throw new ServiceException(ErrorCodeEnum.PARAMS_REQUIRED);
@@ -196,6 +196,7 @@ public class HyPartnerIntentInfoServiceImpl implements HyPartnerIntentInfoServic
OperateTypeEnum operateTypeEnum = OperateTypeEnum.INTENT_INFO_UPDATE; OperateTypeEnum operateTypeEnum = OperateTypeEnum.INTENT_INFO_UPDATE;
HyPartnerIntentInfoDO intentInfoDO = hyPartnerIntentInfoDAO.getByPartnerIdAndLineId(request.getPartnerId(), request.getPartnerLineId()); HyPartnerIntentInfoDO intentInfoDO = hyPartnerIntentInfoDAO.getByPartnerIdAndLineId(request.getPartnerId(), request.getPartnerLineId());
if(intentInfoDO == null){ if(intentInfoDO == null){
isUpdateIntentInfo = false;
intentInfoDO = new HyPartnerIntentInfoDO(); intentInfoDO = new HyPartnerIntentInfoDO();
fillIntentInfo(intentInfoDO, request); fillIntentInfo(intentInfoDO, request);
hyPartnerIntentInfoDAO.insertSelective(intentInfoDO); hyPartnerIntentInfoDAO.insertSelective(intentInfoDO);
@@ -220,11 +221,19 @@ public class HyPartnerIntentInfoServiceImpl implements HyPartnerIntentInfoServic
if (LineStatusEnum.PUBLIC_SEAS.getCode().equals(hyPartnerLineInfoDO.getLineStatus())){ if (LineStatusEnum.PUBLIC_SEAS.getCode().equals(hyPartnerLineInfoDO.getLineStatus())){
Boolean flag = hyPartnerLineInfoService.assignFollowUser(request.getPartnerId(), request.getWantShopArea(), request.getAcceptAdjustType()); Boolean flag = hyPartnerLineInfoService.assignFollowUser(request.getPartnerId(), request.getWantShopArea(), request.getAcceptAdjustType());
hyPartnerLineInfoDO.setLineStatus(flag ? LineStatusEnum.PRIVATE_SEAS.getCode() : LineStatusEnum.PUBLIC_SEAS.getCode()); hyPartnerLineInfoDO.setLineStatus(flag ? LineStatusEnum.PRIVATE_SEAS.getCode() : LineStatusEnum.PUBLIC_SEAS.getCode());
List<String> userIdList = new ArrayList<>();
if (flag){ if (flag){
String investmentManager = hyPartnerLineInfoService.getAssignFollowUser(request.getPartnerId(), "intent"); String investmentManager = hyPartnerLineInfoService.getAssignFollowUser(request.getPartnerId(), "intent");
hyPartnerLineInfoDO.setInvestmentManager(investmentManager); hyPartnerLineInfoDO.setInvestmentManager(investmentManager);
userIdList.add(investmentManager);
} }
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(hyPartnerLineInfoDO); hyPartnerLineInfoDAO.updateByPrimaryKeySelective(hyPartnerLineInfoDO);
if(!isUpdateIntentInfo){
noticeService.sendFeiShuNotice(FeiShuNoticeMsgEnum.INTENTION_APPLY,userIdList,hyPartnerUserInfoDO.getUsername(),hyPartnerUserInfoDO.getMobile(),DateUtil.formatDateTime(new Date()));
}
if(flag){//分配招商经理成功才发送分配招商经理的飞书工作通知
noticeService.sendFeiShuNotice(FeiShuNoticeMsgEnum.ALLOCATION_INVESTMENT_MANAGER,userIdList,DateUtil.formatDateTime(new Date()),hyPartnerUserInfoDO.getUsername(),hyPartnerUserInfoDO.getMobile());
}
} }
} }
//记录日志 //记录日志

View File

@@ -2,6 +2,7 @@ package com.cool.store.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cool.store.constants.CommonConstants; import com.cool.store.constants.CommonConstants;
import com.cool.store.constants.RedisConstant; import com.cool.store.constants.RedisConstant;
@@ -26,12 +27,11 @@ import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.sql.Array;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -78,6 +78,11 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
@Resource @Resource
HyPhoneLocationService hyPhoneLocationService; HyPhoneLocationService hyPhoneLocationService;
@Autowired
private NoticeService noticeService;
@Autowired
private SmsService smsService;
@Override @Override
public StageCountVO selectStagePendingCount(String userId) { public StageCountVO selectStagePendingCount(String userId) {
@@ -161,6 +166,9 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
&& WorkflowStatusEnum.INTERVIEW_2.getCode().equals(hyPartnerLineInfoDO.getWorkflowStatus())){ && WorkflowStatusEnum.INTERVIEW_2.getCode().equals(hyPartnerLineInfoDO.getWorkflowStatus())){
workFlowService.transferInvestmentManager(WorkflowStageEnum.getWorkflowStageByCode(hyPartnerLineInfoDO.getWorkflowStage()),request); workFlowService.transferInvestmentManager(WorkflowStageEnum.getWorkflowStageByCode(hyPartnerLineInfoDO.getWorkflowStage()),request);
} }
//发送飞书工作通知
HyPartnerBaseInfoDO hyPartnerBaseInfoDO = hyPartnerBaseInfoDAO.getByPartnerLineId(request.getLineId());
noticeService.sendFeiShuNotice(FeiShuNoticeMsgEnum.TRANS_INVESTMENT_MANAGER,userIdList,DateUtil.formatDateTime(new Date()),hyPartnerBaseInfoDO.getUsername(),hyPartnerBaseInfoDO.getMobile());
//添加日志 //添加日志
LineLogInfo lineLogInfo = new LineLogInfo(hyPartnerLineInfoDO.getPartnerId(), hyPartnerLineInfoDO.getId(), user.getUserId(), LineLogInfo lineLogInfo = new LineLogInfo(hyPartnerLineInfoDO.getPartnerId(), hyPartnerLineInfoDO.getId(), user.getUserId(),
@@ -215,9 +223,15 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
List<HyPartnerLineInfoDO> otherLineList = partnerLineInfoList.stream().filter(x -> x.getCloseTime() == null).collect(Collectors.toList()); List<HyPartnerLineInfoDO> otherLineList = partnerLineInfoList.stream().filter(x -> x.getCloseTime() == null).collect(Collectors.toList());
List<Long> otherLineIdList = otherLineList.stream().map(HyPartnerLineInfoDO::getId).collect(Collectors.toList()); List<Long> otherLineIdList = otherLineList.stream().map(HyPartnerLineInfoDO::getId).collect(Collectors.toList());
hyPartnerLineInfoDAO.updateInvestmentManager(user.getUserId(), otherLineIdList); hyPartnerLineInfoDAO.updateInvestmentManager(user.getUserId(), otherLineIdList);
//添加日志 //添加日志
partnerLineInfoList.forEach(x->{ partnerLineInfoList.forEach(x->{
//给招商经理发送飞书工作通知
List<String> userIdList = new ArrayList<>();
userIdList.add(user.getUserId());
HyPartnerBaseInfoDO hyPartnerBaseInfoDO = hyPartnerBaseInfoDAO.getByPartnerLineId(x.getId());
noticeService.sendFeiShuNotice(FeiShuNoticeMsgEnum.ALLOCATION_INVESTMENT_MANAGER,userIdList,DateUtil.formatDateTime(new Date()),hyPartnerBaseInfoDO.getUsername(),hyPartnerBaseInfoDO.getMobile());
LineLogInfo lineLogInfo = new LineLogInfo(x.getPartnerId(), x.getId(), user.getUserId(), LineLogInfo lineLogInfo = new LineLogInfo(x.getPartnerId(), x.getId(), user.getUserId(),
user.getName(), OperateTypeEnum.ALLOCATION_INVESTMENT_MANAGER, user.getName(), OperateTypeEnum.ALLOCATION_INVESTMENT_MANAGER,
WorkflowStageEnum.getWorkflowStageByCode(x.getWorkflowStage()), WorkflowStageEnum.getWorkflowStageByCode(x.getWorkflowStage()),
@@ -362,6 +376,9 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
hy.setCertifyFile(JSONObject.toJSONString(closeFollowRequest.getCertifyFile())); hy.setCertifyFile(JSONObject.toJSONString(closeFollowRequest.getCertifyFile()));
} }
hyPartnerBaseInfoDAO.updateByPrimaryKeySelective(hy); hyPartnerBaseInfoDAO.updateByPrimaryKeySelective(hy);
IntentSmsReq intentSmsReq = new IntentSmsReq();
intentSmsReq.setDeadLine(DateUtil.formatDateTime(hyPartnerLineInfoDO.getDeadline()));
smsService.sendSms(JSON.toJSONString(intentSmsReq),CommonConstants.SMS_TEMPLATE_CODE_INTENT, hy.getMobile());
} }
//拒绝 //拒绝
@@ -711,6 +728,13 @@ public class HyPartnerLineInfoServiceImpl implements HyPartnerLineInfoService {
hyPartnerLineInfoDAO.updateByPrimaryKeySelective(hyPartnerLineInfoDO); hyPartnerLineInfoDAO.updateByPrimaryKeySelective(hyPartnerLineInfoDO);
} }
} }
//发送飞书工作通知
if(flag){
List<String> userIdList = new ArrayList<>();
userIdList.add(investmentManager);
HyPartnerUserInfoDO hyPartnerUserInfoDO = hyPartnerUserInfoDAO.selectByPartnerId(partnerId);
noticeService.sendFeiShuNotice(FeiShuNoticeMsgEnum.ALLOCATION_INVESTMENT_MANAGER,userIdList,DateUtil.formatDateTime(new Date()),hyPartnerUserInfoDO.getUsername(),hyPartnerUserInfoDO.getMobile());
}
return hyPartnerLineInfoDO; return hyPartnerLineInfoDO;
} }

View File

@@ -0,0 +1,40 @@
package com.cool.store.service.impl;
import com.cool.store.dto.message.SendCardMessageDTO;
import com.cool.store.enums.FeiShuNoticeMsgEnum;
import com.cool.store.enums.MessageTypeEnum;
import com.cool.store.http.ISVHttpRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.text.MessageFormat;
import java.util.List;
/**
* @Author: young.yu
* @Date: 2023-07-19 17:06
* @Description:
*/
@Slf4j
@Service
public class NoticeService {
@Value("${feishu.notice.link.url:null}")
private String linkUrl;
@Autowired
private ISVHttpRequest isvHttpRequest;
public void sendFeiShuNotice(FeiShuNoticeMsgEnum feiShuNoticeMsgEnum, List<String> userIds,Object... objects) {
try{
SendCardMessageDTO sendCardMessageDTO = new SendCardMessageDTO();
sendCardMessageDTO.setUserIds(userIds);
sendCardMessageDTO.setMessageType(MessageTypeEnum.SCHEDULE_REMINDER);
sendCardMessageDTO.setMessageUrl(linkUrl);
sendCardMessageDTO.setTitle(feiShuNoticeMsgEnum.getTitle());
sendCardMessageDTO.setContent(MessageFormat.format(feiShuNoticeMsgEnum.getContent(),objects));
isvHttpRequest.sendFeiShuCardMessage(sendCardMessageDTO);
}catch (Exception e){
log.info("发送飞书通知失败");
}
}
}