Commit 756a9160 by 郑永强

衔接语增加进度链接

parent 25f4d685
......@@ -4,6 +4,7 @@ import com.pcloud.book.personalstage.dto.PersonalStageDTO;
import com.pcloud.book.personalstage.dto.PersonalStageProgressDTO;
import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.book.personalstage.entity.PersonalStageUser;
import com.pcloud.common.core.mq.DelayQueueDTO;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBean;
......@@ -47,12 +48,14 @@ public interface PersonalStageBiz {
void dealDelayWakeup(DelayQueueDTO dto);
void nextStageAddStageUserAndWakeupDelay(String robotId, String userWxId, String ip, Long personalStageId);
PersonalStageUser nextStageAddStageUserAndWakeupDelay(String robotId, String userWxId, String ip, Long personalStageId);
void sendNotKeywordReply(String robotId, String userWxId, String ip, Long personalStageId, Long personalStageUserId);
void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId,Long personalStageUserId);
String replaceProjectProgressUrl(String content, String robotId, String userWxId, Long personalStageUserId);
void dealDelayFusingFinish(DelayQueueDTO dto);
PersonalStageProgressDTO getPersonalProgress(String wxUserId, Long personalStageUserId);
......
......@@ -104,11 +104,6 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@Value("${wechat.group.link.prefix}")
private String wechatLinkPrefix;
private final static String PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE = "${PROGRESS_URL}";
// 项目进度路由
private final static String PERSONAL_STAGE_PROJECT_PROGRESS = "/personalCenter/projectProgress";
@Transactional(rollbackFor = Exception.class)
@ParamLog("新增阶段")
......@@ -475,7 +470,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@ParamLog("下一阶段新增定制化阶段用户记录和唤醒延时")
@Override
public void nextStageAddStageUserAndWakeupDelay(String robotId, String userWxId, String ip, Long personalStageId) {
public PersonalStageUser nextStageAddStageUserAndWakeupDelay(String robotId, String userWxId, String ip, Long personalStageId) {
PersonalStageWakeup wakeup = personalStageWakeupDao.getFirstWakeup(personalStageId);
PersonalStageUser personalStageUser=new PersonalStageUser();
personalStageUser.setRobotId(robotId);
......@@ -497,7 +492,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
//同时插入唤醒队列
//查询第一个唤醒时长
if (wakeup==null){
return;
return personalStageUser;
}
Integer toStageStartTime=wakeup.getToStageStartTime();
WakeupDelayDTO wakeupDelayDTO=new WakeupDelayDTO();
......@@ -509,6 +504,7 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
wakeupDelayDTO.setPersonalStageUserId(personalStageUser.getId());
DelayQueueDTO delayQueueDTO = DelayQueueDTO.builder().key(userWxId).type(PersonalStageConstant.PERSONALSTAGE_DELAY_WAKEUP).msg(wakeupDelayDTO).timeout(toStageStartTime*60*1000).build();
delayMessageSender.send(delayQueueDTO);
return personalStageUser;
}
@ParamLog("非关键词回复")
......@@ -533,21 +529,15 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
personalStageUserDao.updateRequireNumber(personalStageUserId, requireNumber);
}
@Override
@ParamLog("替换进度链接")
private void replaceProjectProgressUrl(List<PersonalStageReplyItem> items, String robotId, String userWxId, Long personalStageUserId) {
boolean insertNumber = false;
for (PersonalStageReplyItem item : items){
if(ReplyTypeEnum.TEXT.value.equals(item.getReplyType())){
if(!insertNumber && item.getContent().indexOf(PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE) > -1){
insertNumber = true;
}
String longUrl = wechatLinkPrefix.concat(PERSONAL_STAGE_PROJECT_PROGRESS).concat("?wxUserId=" + userWxId + "&robotId=" + robotId + "&personalStageUserId=" + personalStageUserId);
item.setContent(item.getContent().replace(PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE, UrlUtils.getShortUrl4Own(longUrl)));
}
}
if(insertNumber){
public String replaceProjectProgressUrl(String content, String robotId, String userWxId, Long personalStageUserId) {
if(content.indexOf(PersonalStageConstant.PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE) > -1){
tryInsertNumber(personalStageUserId);
String longUrl = wechatLinkPrefix.concat(PersonalStageConstant.PERSONAL_STAGE_PROJECT_PROGRESS).concat("?wxUserId=" + userWxId + "&robotId=" + robotId + "&personalStageUserId=" + personalStageUserId);
return content.replace(PersonalStageConstant.PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE, UrlUtils.getShortUrl4Own(longUrl));
}
return content;
}
@ParamLog("非关键词熔断回复")
......@@ -568,13 +558,11 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@ParamLog("发送回复")
private void sendReplyItems(List<PersonalStageReplyItem> replyItems,String robotId, String userWxId, String ip,Long personalStageUserId){
// 替换进度链接
replaceProjectProgressUrl(replyItems,robotId,userWxId,personalStageUserId);
for (PersonalStageReplyItem item:replyItems){
Integer type=item.getReplyType();
if (ReplyTypeEnum.TEXT.value.equals(type)) {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(item.getContent());
sendTextMessageVO.setContent(replaceProjectProgressUrl(item.getContent(),robotId,userWxId,personalStageUserId));
sendTextMessageVO.setAltId(robotId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
......
......@@ -327,9 +327,9 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
// 发送邮件
sendEmail(userWxId, robotWxId, content, jumpKeywordDto);
// 将用户置为下个阶段
personalStageBiz.nextStageAddStageUserAndWakeupDelay(robotWxId, userWxId, ip, jumpKeywordDto.getAfterPersonalStageId());
PersonalStageUser nextPersonalStageUser = personalStageBiz.nextStageAddStageUserAndWakeupDelay(robotWxId, userWxId, ip, jumpKeywordDto.getAfterPersonalStageId());
// 发送内容衔接语
sendJumpLinkups(userWxId, robotWxId, ip, jumpKeywordDto.getPersonalStageJumpId());
sendJumpLinkups(userWxId, robotWxId, ip, jumpKeywordDto.getPersonalStageJumpId(),nextPersonalStageUser.getId());
// 停止发送引导语
pcloudGuideBiz.stopPcloudGuidePush(robotWxId, userWxId);
return true;
......@@ -345,7 +345,7 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
return;
}
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(jumpLinkup.getLinkupContent());
sendTextMessageVO.setContent(personalStageBiz.replaceProjectProgressUrl(jumpLinkup.getLinkupContent(),linkupDelayDTO.getRobotId(),linkupDelayDTO.getWxId(),linkupDelayDTO.getPersonalStageUserId()));
sendTextMessageVO.setAltId(linkupDelayDTO.getRobotId());
sendTextMessageVO.setWxGroupId(dto.getKey());
sendTextMessageVO.setIp(linkupDelayDTO.getIp());
......@@ -417,7 +417,7 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
}
@ParamLog("发送内容衔接语")
private void sendJumpLinkups(String userWxId, String robotWxId, String ip, Long jumpId) {
private void sendJumpLinkups(String userWxId, String robotWxId, String ip, Long jumpId, Long personalStageUserId) {
List<PersonalStageJumpLinkup> linkups = personalStageJumpLinkupDao.getByJumpId(jumpId);
if(ListUtils.isEmpty(linkups)){
return;
......@@ -429,12 +429,13 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
linkupDelayDTO.setRobotId(robotWxId);
linkupDelayDTO.setWxId(userWxId);
linkupDelayDTO.setIp(ip);
linkupDelayDTO.setPersonalStageUserId(personalStageUserId);
DelayQueueDTO delayQueueDTO = DelayQueueDTO.builder().key(userWxId).type(PersonalStageConstant.PERSONALSTAGE_DELAY_LINKUP).msg(linkupDelayDTO).timeout(jumpLinkup.getToStageStartTime()*60*1000).build();
delayMessageSender.send(delayQueueDTO);
LOGGER.info("增加跳转衔接语延时"+delayQueueDTO.toString());
}else {
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(jumpLinkup.getLinkupContent());
sendTextMessageVO.setContent(personalStageBiz.replaceProjectProgressUrl(jumpLinkup.getLinkupContent(),robotWxId,userWxId,personalStageUserId));
sendTextMessageVO.setAltId(robotWxId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
......
......@@ -10,5 +10,9 @@ public class PersonalStageConstant {
public static final String USER_SEND_KEYWORD_COUNT_LOCK="USER_SEND_KEYWORD_COUNT_LOCK";
public static final String PERSONALSTAGE_DELAY_LINKUP="PERSONALSTAGE_DELAY_LINKUP";
// 进度模板字符串
public static final String PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE = "${PROGRESS_URL}";
// 项目进度页面路由
public static final String PERSONAL_STAGE_PROJECT_PROGRESS = "/personalCenter/projectProgress";
}
......@@ -18,5 +18,7 @@ public class LinkupDelayDTO implements Serializable {
private String wxId;
@ApiModelProperty("ip地址")
private String ip;
@ApiModelProperty("用户阶段记录id")
private Long personalStageUserId;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment