Commit 60197661 by 阮思源

1002509客服介入结束控制用户跨过当前阶段

parent 1e777734
package com.pcloud.book.personalstage.biz; package com.pcloud.book.personalstage.biz;
import com.pcloud.book.personalstage.dto.LinkClickRecordDTO; import com.pcloud.book.personalstage.dto.LinkClickRecordDTO;
import com.pcloud.book.personalstage.dto.EndServiceJumpNextDTO;
import com.pcloud.book.personalstage.dto.PersonalStageJumpDto; import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.enums.JumpTypeEnum; import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.personalstage.vo.request.CreateStageJumpRequestVO; import com.pcloud.book.personalstage.vo.request.CreateStageJumpRequestVO;
...@@ -92,4 +93,8 @@ public interface PersonalStageJumpBiz { ...@@ -92,4 +93,8 @@ public interface PersonalStageJumpBiz {
* @param dto * @param dto
*/ */
void delayPaper(DelayQueueDTO dto); void delayPaper(DelayQueueDTO dto);
Boolean getHasEndServiceJump(Long personalStageId);
void endServiceJumpNext(EndServiceJumpNextDTO endServiceJumpNextDTO);
} }
...@@ -115,12 +115,16 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -115,12 +115,16 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void createPersonalStageJump(CreateStageJumpRequestVO vo) { public void createPersonalStageJump(CreateStageJumpRequestVO vo) {
//校验关键词是否重复 //校验关键词是否重复
if (!JumpTypeEnum.PAY_TRIGGER.key.equals(vo.getJumpType()) && !JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){ if (!JumpTypeEnum.PAY_TRIGGER.key.equals(vo.getJumpType()) && !JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())
&&!JumpTypeEnum.END_SERVICE.key.equals(vo.getJumpType())){
this.checkKeywords(vo.getKeywords(), vo.getPersonalStageId(), null); this.checkKeywords(vo.getKeywords(), vo.getPersonalStageId(), null);
} }
if (JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){ if (JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){
this.checkPaper(vo.getPersonalStageId(), null); this.checkPaper(vo.getPersonalStageId(), null);
} }
if (JumpTypeEnum.END_SERVICE.key.equals(vo.getJumpType())){
checkOnlyOneEndServiceJump(vo.getPersonalStageId(),null);
}
if (vo.getOpenEmail()){ if (vo.getOpenEmail()){
this.checkEmail(vo.getEmails()); this.checkEmail(vo.getEmails());
} }
...@@ -141,6 +145,22 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -141,6 +145,22 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
} }
} }
@ParamLog("人工客服结束阶段跳转配置唯一性")
private void checkOnlyOneEndServiceJump(Long personalStageId,Long personalStageJumpId) {
List<PersonalStageJump> stageJumps = personalStageJumpDao.getByJumpType(personalStageId, JumpTypeEnum.END_SERVICE.key);
if (!ListUtils.isEmpty(stageJumps)){
if (personalStageJumpId==null){
throw new BookBizException(BookBizException.ERROR, "已有其他阶段跳转配置了人工客服结束跳转");
}else {
//判断是不是旧的已有的修改
List<Long> jumpIds=stageJumps.stream().filter(s->s.getId()!=null).map(PersonalStageJump::getId).collect(Collectors.toList());
if (!jumpIds.contains(personalStageJumpId)){
throw new BookBizException(BookBizException.ERROR, "已有其他阶段跳转配置了人工客服结束跳转");
}
}
}
}
@Override @Override
@ParamLog("获取跳转设置列表") @ParamLog("获取跳转设置列表")
public PageBeanNew getJumpList(Long personalStageId, Integer currentPage, Integer numPerPage) { public PageBeanNew getJumpList(Long personalStageId, Integer currentPage, Integer numPerPage) {
...@@ -209,12 +229,16 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -209,12 +229,16 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
@ParamLog("修改跳转阶段") @ParamLog("修改跳转阶段")
public void updatePersonalStageJump(UpdateStageJumpRequestVO vo) { public void updatePersonalStageJump(UpdateStageJumpRequestVO vo) {
//校验关键词是否重复 //校验关键词是否重复
if (!JumpTypeEnum.PAY_TRIGGER.key.equals(vo.getJumpType()) && !JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){ if (!JumpTypeEnum.PAY_TRIGGER.key.equals(vo.getJumpType()) && !JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())
&&!JumpTypeEnum.END_SERVICE.key.equals(vo.getJumpType())){
this.checkKeywords(vo.getKeywords(), vo.getPersonalStageId(), vo.getPersonalStageJumpId()); this.checkKeywords(vo.getKeywords(), vo.getPersonalStageId(), vo.getPersonalStageJumpId());
} }
if (JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){ if (JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){
this.checkPaper(vo.getPersonalStageId(), vo.getPersonalStageJumpId()); this.checkPaper(vo.getPersonalStageId(), vo.getPersonalStageJumpId());
} }
if (JumpTypeEnum.END_SERVICE.key.equals(vo.getJumpType())){
checkOnlyOneEndServiceJump(vo.getPersonalStageId(),vo.getPersonalStageJumpId());
}
if (vo.getOpenEmail()){ if (vo.getOpenEmail()){
this.checkEmail(vo.getEmails()); this.checkEmail(vo.getEmails());
} }
...@@ -496,6 +520,73 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -496,6 +520,73 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
} }
} }
@ParamLog("获取定制化阶段是否含有人工客服结束跳转")
@Override
public Boolean getHasEndServiceJump(Long personalStageId) {
if (personalStageId==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数为空!");
}
List<PersonalStageJump> jumps = personalStageJumpDao.getByJumpType(personalStageId, JumpTypeEnum.END_SERVICE.key);
if (ListUtils.isEmpty(jumps)){
return false;
}
return true;
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("获取定制化阶段是否含有人工客服结束跳转")
@Override
public void endServiceJumpNext(EndServiceJumpNextDTO endServiceJumpNextDTO) {
if (endServiceJumpNextDTO==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数为空!");
}
if (endServiceJumpNextDTO.getPersonalStageId()==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"阶段id参数为空!");
}
if (StringUtil.isEmpty(endServiceJumpNextDTO.getRobotId())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"机器人id参数为空!");
}
if (StringUtil.isEmpty(endServiceJumpNextDTO.getWxId())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"用户id参数为空!");
}
String wxId=endServiceJumpNextDTO.getWxId();
String robotId=endServiceJumpNextDTO.getRobotId();
Long personalStageId=endServiceJumpNextDTO.getPersonalStageId();
PersonalStageUser last = personalStageUserDao.getLast(wxId, robotId, personalStageId);
if (last==null){
throw new BookBizException(BookBizException.ERROR,"用户无阶段!");
}
if (!last.getPersonalStageId().equals(personalStageId)){
throw new BookBizException(BookBizException.ERROR,"用户已不在当前阶段!");
}
//查询跳转
List<PersonalStageJump> jumps = personalStageJumpDao.getByJumpType(personalStageId, JumpTypeEnum.END_SERVICE.key);
if (ListUtils.isEmpty(jumps)){
throw new BookBizException(BookBizException.ERROR,"没有该类型的跳转的阶段!");
}
PersonalStageJump personalStageJump=jumps.get(0);
Long afterStageId=personalStageJump.getAfterPersonalStageId();
Long stageJumpId=personalStageJump.getId();
if (afterStageId==null){
throw new BookBizException(BookBizException.ERROR,"没有下一阶段!");
}
if (personalStageJump.getOpenEmail()!=null&&personalStageJump.getOpenEmail()){
PersonalStageJumpKeywordDto jumpKeywordDto = new PersonalStageJumpKeywordDto();
jumpKeywordDto.setAfterPersonalStageId(afterStageId);
jumpKeywordDto.setPersonalStageJumpId(stageJumpId);
String content = "如果读者提交了对方案的反馈意见,请到“定制服务”中查看。";
sendEmail(wxId, robotId, content, jumpKeywordDto);
}
GroupRobotDTO groupRobotDTO = wechatGroupConsr.getGroupRobotByWxId(robotId);
String ip = weixinQrcodeBiz.getRobotIpByGeneration(groupRobotDTO.getVersion());
// 将用户置为下个阶段
PersonalStageUser nextPersonalStageUser = personalStageBiz.nextStageAddStageUserAndWakeupDelay(robotId, wxId, ip, afterStageId);
// 发送内容衔接语
sendJumpLinkups(wxId, robotId, ip, stageJumpId, nextPersonalStageUser.getId());
// 停止发送引导语
pcloudGuideBiz.stopPcloudGuidePush(robotId, wxId);
}
@ParamLog("发送阶段跳转邮件") @ParamLog("发送阶段跳转邮件")
private void sendEmail(String userWxId, String robotWxId, String content, PersonalStageJumpKeywordDto jumpKeywordDto) { private void sendEmail(String userWxId, String robotWxId, String content, PersonalStageJumpKeywordDto jumpKeywordDto) {
try { try {
......
package com.pcloud.book.personalstage.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class EndServiceJumpNextDTO implements Serializable {
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("微信Id")
private String wxId;
@ApiModelProperty("阶段id")
private Long personalStageId;
}
...@@ -5,7 +5,8 @@ public enum JumpTypeEnum { ...@@ -5,7 +5,8 @@ public enum JumpTypeEnum {
READER_TRIGGER(1,"读者输入关键词触发"), READER_TRIGGER(1,"读者输入关键词触发"),
ROBOT_TRIGGER(2,"小睿发送关键词触发"), ROBOT_TRIGGER(2,"小睿发送关键词触发"),
PAY_TRIGGER(3,"转账触发"), PAY_TRIGGER(3,"转账触发"),
PAPER_TRIGGER(4, "需求定制单触发"); PAPER_TRIGGER(4, "需求定制单触发"),
END_SERVICE(5,"人工客服结束触发");
public final Integer key; public final Integer key;
public final String desc; public final String desc;
......
...@@ -3,6 +3,7 @@ package com.pcloud.book.personalstage.facade; ...@@ -3,6 +3,7 @@ package com.pcloud.book.personalstage.facade;
import com.pcloud.book.personalstage.biz.PersonalStageBiz; import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.book.personalstage.biz.PersonalStageProgressMessageBiz; import com.pcloud.book.personalstage.biz.PersonalStageProgressMessageBiz;
import com.pcloud.book.personalstage.dto.LinkClickRecordDTO; import com.pcloud.book.personalstage.dto.LinkClickRecordDTO;
import com.pcloud.book.personalstage.dto.EndServiceJumpNextDTO;
import com.pcloud.book.personalstage.dto.PersonalStageProgressDTO; import com.pcloud.book.personalstage.dto.PersonalStageProgressDTO;
import com.pcloud.book.personalstage.entity.PersonalStage; import com.pcloud.book.personalstage.entity.PersonalStage;
import com.pcloud.book.personalstage.entity.PersonalStageProgressMessage; import com.pcloud.book.personalstage.entity.PersonalStageProgressMessage;
...@@ -267,4 +268,25 @@ public class PersonalStageFacade { ...@@ -267,4 +268,25 @@ public class PersonalStageFacade {
personalStageJumpBiz.addLinkClickRecord(linkClickRecordDTO); personalStageJumpBiz.addLinkClickRecord(linkClickRecordDTO);
return new ResponseDto<>(); return new ResponseDto<>();
} }
@ApiOperation("获取定制化阶段是否含有人工客服结束跳转")
@GetMapping("/getHasEndServiceJump")
public ResponseDto<?> getEndServiceJump(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestParam("personalStageId") @ApiParam("阶段id") Long personalStageId
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
return new ResponseDto<>(personalStageJumpBiz.getHasEndServiceJump(personalStageId));
}
@ApiOperation("人工客服阶段跳转")
@PostMapping("/endServiceJumpNext")
public ResponseDto<?> endServiceJumpNext(
@RequestHeader("token") @ApiParam("token信息") String token,
@RequestBody @ApiParam("人工客服阶段跳转") EndServiceJumpNextDTO endServiceJumpNextDTO
) throws BizException, PermissionException {
SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
personalStageJumpBiz.endServiceJumpNext(endServiceJumpNextDTO);
return new ResponseDto<>();
}
} }
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