Commit 020019e0 by 阮思源

Merge branch 'feat-1002439' into 'master'

feat-1002439: 需求定制单

See merge request rays/pcloud-book!472
parents 0c54786a 5cb92089
...@@ -45,4 +45,7 @@ public interface PcloudRobotService { ...@@ -45,4 +45,7 @@ public interface PcloudRobotService {
@PostMapping("getPcloudRobotByRobotIds") @PostMapping("getPcloudRobotByRobotIds")
public ResponseEntity<ResponseDto<Map<String,PcloudRobotDTO>>> getPcloudRobotByRobotIds(@RequestBody List<String> robotIds); public ResponseEntity<ResponseDto<Map<String,PcloudRobotDTO>>> getPcloudRobotByRobotIds(@RequestBody List<String> robotIds);
@ApiOperation("表单提交后进行用户阶段跳转")
@GetMapping("changePersonalStage")
void changePersonalStage(@RequestParam("robotId") String robotId, @RequestParam("wxUserId") String wxUserId, @RequestParam("paperId") Long paperId);
} }
...@@ -5,9 +5,11 @@ import com.pcloud.book.pcloudKeyword.dto.RobotClassifyDTO; ...@@ -5,9 +5,11 @@ import com.pcloud.book.pcloudKeyword.dto.RobotClassifyDTO;
import com.pcloud.book.pcloudKeyword.service.PcloudRobotService; import com.pcloud.book.pcloudKeyword.service.PcloudRobotService;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz; import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot; import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.personalstage.biz.PersonalStageJumpBiz;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.utils.BeanUtils; import com.pcloud.common.utils.BeanUtils;
import com.pcloud.common.utils.ResponseHandleUtil; import com.pcloud.common.utils.ResponseHandleUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -24,6 +26,9 @@ public class PcloudRobotServiceImpl implements PcloudRobotService { ...@@ -24,6 +26,9 @@ public class PcloudRobotServiceImpl implements PcloudRobotService {
@Autowired @Autowired
private PcloudRobotBiz pcloudRobotBiz; private PcloudRobotBiz pcloudRobotBiz;
@Autowired
private PersonalStageJumpBiz personalStageJumpBiz;
@Override @Override
@PostMapping("getRobotClassifyBatch") @PostMapping("getRobotClassifyBatch")
public ResponseEntity<ResponseDto<Map<String, RobotClassifyDTO>>> getRobotClassifyBatch(@RequestBody List<String> robotIds) { public ResponseEntity<ResponseDto<Map<String, RobotClassifyDTO>>> getRobotClassifyBatch(@RequestBody List<String> robotIds) {
...@@ -75,4 +80,12 @@ public class PcloudRobotServiceImpl implements PcloudRobotService { ...@@ -75,4 +80,12 @@ public class PcloudRobotServiceImpl implements PcloudRobotService {
return ResponseHandleUtil.toResponse(map); return ResponseHandleUtil.toResponse(map);
} }
@Override
@GetMapping("changePersonalStage")
public void changePersonalStage(@RequestParam("robotId") String robotId, @RequestParam("wxUserId") String wxUserId, @RequestParam("paperId") Long paperId) {
if (!personalStageJumpBiz.handlePersonalStagePaperJump(wxUserId, robotId, paperId)){
//如果没有进行跳转,则发送需求单反馈邮件
personalStageJumpBiz.sendPaperEmail(wxUserId, robotId);
}
}
} }
...@@ -37,4 +37,15 @@ public interface PersonalStageJumpBiz { ...@@ -37,4 +37,15 @@ public interface PersonalStageJumpBiz {
Boolean handlePersonalStageJump(String userWxId, String robotWxId, String content, JumpTypeEnum jumpTypeEnum); Boolean handlePersonalStageJump(String userWxId, String robotWxId, String content, JumpTypeEnum jumpTypeEnum);
void dealDelayLinkup(DelayQueueDTO dto); void dealDelayLinkup(DelayQueueDTO dto);
/**
* 处理用户提交表单阶段跳转
* @param userWxId
* @param robotWxId
* @param paperId
* @return
*/
boolean handlePersonalStagePaperJump(String userWxId, String robotWxId, Long paperId);
void sendPaperEmail(String userWxId, String robotWxId);
} }
...@@ -104,6 +104,15 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -104,6 +104,15 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@Value("${wechat.group.link.prefix}") @Value("${wechat.group.link.prefix}")
private String wechatLinkPrefix; private String wechatLinkPrefix;
private final static String PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE = "${PROGRESS_URL}";
private final static String PERSONAL_STAGE_PAPER_TEMPLATE = "${PROGRESS_URL&ProgressId}";
// 项目进度路由
private final static String PERSONAL_STAGE_PROJECT_PROGRESS = "/personalCenter/projectProgress";
//需求定制单路由 https://wechat666.raysgo.com/personalCenter/questionNaire?paperId=679
private final static String PERSONAL_STAGE_PAPER = "/personalCenter/questionNaire?paperId=";
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ParamLog("新增阶段") @ParamLog("新增阶段")
...@@ -516,11 +525,16 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -516,11 +525,16 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
} }
Random random = new Random(); Random random = new Random();
Long replyId=ids.get(random.nextInt(ids.size())); Long replyId=ids.get(random.nextInt(ids.size()));
PersonalStageReply personalStageReply = personalStageReplyDao.getById(replyId);
List<PersonalStageReplyItem> items = personalStageReplyItemDao.getListByReplyIds(Arrays.asList(replyId)); List<PersonalStageReplyItem> items = personalStageReplyItemDao.getListByReplyIds(Arrays.asList(replyId));
if (ListUtils.isEmpty(items)){ if (ListUtils.isEmpty(items)){
return; return;
} }
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId); sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
//替换需求定制单链接
if (null != personalStageReply.getPaperId()) {
this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId());
}
} }
@ParamLog("尝试插入单号") @ParamLog("尝试插入单号")
...@@ -540,6 +554,19 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -540,6 +554,19 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
return content; return content;
} }
@ParamLog("替换需求定制单链接")
private void replacePaperUrl(List<PersonalStageReplyItem> items, String robotId, String userWxId, Long paperId){
if (null == paperId){
return;
}
for (PersonalStageReplyItem item : items){
if(ReplyTypeEnum.TEXT.value.equals(item.getReplyType())){
String longUrl = wechatLinkPrefix.concat(PERSONAL_STAGE_PAPER).concat(paperId.toString()).concat("&wxId=" + userWxId + "&robotWxId=" + robotId);
item.setContent(item.getContent().replace(PERSONAL_STAGE_PAPER_TEMPLATE, UrlUtils.getShortUrl4Own(longUrl)));
}
}
}
@ParamLog("非关键词熔断回复") @ParamLog("非关键词熔断回复")
@Override @Override
public void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId, Long personalStageUserId) { public void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId, Long personalStageUserId) {
......
...@@ -3,6 +3,7 @@ package com.pcloud.book.personalstage.biz.impl; ...@@ -3,6 +3,7 @@ package com.pcloud.book.personalstage.biz.impl;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.pcloud.book.book.entity.Book;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr; import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.group.biz.WeixinQrcodeBiz; import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.guide.biz.PcloudGuideBiz; import com.pcloud.book.guide.biz.PcloudGuideBiz;
...@@ -14,11 +15,7 @@ import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify; ...@@ -14,11 +15,7 @@ import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.personalstage.biz.PersonalStageBiz; import com.pcloud.book.personalstage.biz.PersonalStageBiz;
import com.pcloud.book.personalstage.biz.PersonalStageJumpBiz; import com.pcloud.book.personalstage.biz.PersonalStageJumpBiz;
import com.pcloud.book.personalstage.constant.PersonalStageConstant; import com.pcloud.book.personalstage.constant.PersonalStageConstant;
import com.pcloud.book.personalstage.dao.PersonalStageJumpDao; import com.pcloud.book.personalstage.dao.*;
import com.pcloud.book.personalstage.dao.PersonalStageJumpEmailDao;
import com.pcloud.book.personalstage.dao.PersonalStageJumpKeywordDao;
import com.pcloud.book.personalstage.dao.PersonalStageJumpLinkupDao;
import com.pcloud.book.personalstage.dao.PersonalStageUserDao;
import com.pcloud.book.personalstage.dto.LinkupDelayDTO; import com.pcloud.book.personalstage.dto.LinkupDelayDTO;
import com.pcloud.book.personalstage.dto.PersonalStageJumpDto; import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.dto.PersonalStageJumpKeywordDto; import com.pcloud.book.personalstage.dto.PersonalStageJumpKeywordDto;
...@@ -53,17 +50,14 @@ import com.sdk.wxgroup.WxGroupSDK; ...@@ -53,17 +50,14 @@ import com.sdk.wxgroup.WxGroupSDK;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.HashMap;
import java.util.Map;
@Component("personalStageJumpBiz") @Component("personalStageJumpBiz")
public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
...@@ -95,15 +89,24 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -95,15 +89,24 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
private PcloudGuideBiz pcloudGuideBiz; private PcloudGuideBiz pcloudGuideBiz;
@Autowired @Autowired
private DelayMessageSender delayMessageSender; private DelayMessageSender delayMessageSender;
@Autowired
private PersonalStageDao personalStageDao;
@Autowired
private PersonalStageReplyDao personalStageReplyDao;
@Value("${system.env}")
private String envStr;
@Override @Override
@ParamLog("新增阶段跳转") @ParamLog("新增阶段跳转")
@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())){ if (!JumpTypeEnum.PAY_TRIGGER.key.equals(vo.getJumpType()) && !JumpTypeEnum.PAPER_TRIGGER.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())){
this.checkPaper(vo.getPersonalStageId(), null);
}
if (vo.getOpenEmail()){ if (vo.getOpenEmail()){
this.checkEmail(vo.getEmails()); this.checkEmail(vo.getEmails());
} }
...@@ -191,7 +194,15 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -191,7 +194,15 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
@ParamLog("修改跳转阶段") @ParamLog("修改跳转阶段")
public void updatePersonalStageJump(UpdateStageJumpRequestVO vo) { public void updatePersonalStageJump(UpdateStageJumpRequestVO vo) {
//校验关键词是否重复 //校验关键词是否重复
this.checkKeywords(vo.getKeywords(), vo.getPersonalStageId(), vo.getPersonalStageJumpId()); if (!JumpTypeEnum.PAY_TRIGGER.key.equals(vo.getJumpType()) && !JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){
this.checkKeywords(vo.getKeywords(), vo.getPersonalStageId(), vo.getPersonalStageJumpId());
}
if (JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){
this.checkPaper(vo.getPersonalStageId(), vo.getPersonalStageJumpId());
}
if (vo.getOpenEmail()){
this.checkEmail(vo.getEmails());
}
PersonalStageJump personalStageJump = UpdateStageJumpRequestVO.valueToJumpEntity(vo); PersonalStageJump personalStageJump = UpdateStageJumpRequestVO.valueToJumpEntity(vo);
personalStageJumpDao.update(personalStageJump); personalStageJumpDao.update(personalStageJump);
//删除原有的关键词 //删除原有的关键词
...@@ -244,6 +255,24 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -244,6 +255,24 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
} }
} }
@ParamLog("校验需求单跳转是否唯一")
private void checkPaper(Long personalStageId, Long personalStageJumpId){
//获取阶段信息
PersonalStage personalStage = personalStageDao.getById(personalStageId);
if (null == personalStage || null == personalStage.getPaperId()){
throw new BookBizException(BookBizException.ERROR, "阶段未配置需求定制单");
}
//获取阶段的需求单跳转
List<PersonalStageJump> personalStageJumps = personalStageJumpDao.getByJumpType(personalStageId, JumpTypeEnum.PAPER_TRIGGER.key);
if (ListUtils.isEmpty(personalStageJumps)){
return;
}
if (null == personalStageJumpId || personalStageJumpId.equals(personalStageJumps.get(0).getId())){
return;
}
throw new BookBizException(BookBizException.ERROR, "已有其他阶段跳转配置了需求单跳转");
}
@Override @Override
@ParamLog("根据id获取跳转对象") @ParamLog("根据id获取跳转对象")
public PersonalStageJumpDto getJump(Long jumpId) { public PersonalStageJumpDto getJump(Long jumpId) {
...@@ -353,6 +382,90 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -353,6 +382,90 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
WxGroupSDK.sendTextMessage(sendTextMessageVO); WxGroupSDK.sendTextMessage(sendTextMessageVO);
} }
@ParamLog("处理用户提交表单阶段跳转")
public boolean handlePersonalStagePaperJump(String userWxId, String robotWxId, Long paperId){
if (null == paperId){
return false;
}
// 查询用户的当前状态信息
PersonalStageUser currentStageUser = personalStageUserDao.getLast(userWxId, robotWxId, null);
// 如果用户没有阶段状态,则不处理
if(currentStageUser == null || currentStageUser.getId() <= 0) {
return false;
}
Long stageId = currentStageUser.getPersonalStageId();
PersonalStage personalStage = personalStageDao.getById(stageId);
Long jumpPaperId = personalStage.getPaperId();
if (paperId.equals(jumpPaperId)){
//如果不是当前阶段的需求单id,则不处理
return false;
}
//获取当前阶段的表单跳转
List<PersonalStageJump> personalStageJump = personalStageJumpDao.getByJumpType(stageId, JumpTypeEnum.PAPER_TRIGGER.key);
if (ListUtils.isEmpty(personalStageJump)){
return false;
}
PersonalStageJump paperJump = personalStageJump.get(0);
// 如果下一个阶段是空,则已完成
if(null == paperJump.getAfterPersonalStageId() || paperJump.getAfterPersonalStageId() <=0){
// 更新到完成状态
updateStageToComplete(currentStageUser);
return true;
}
GroupRobotDTO groupRobotDTO = wechatGroupConsr.getGroupRobotByWxId(robotWxId);
String ip = weixinQrcodeBiz.getRobotIpByGeneration(groupRobotDTO.getVersion());
// 发送邮件
String content = "读者提交了反馈意见,请到“个人号管理——需求定制单”中查看该读者的需求并出相应方案";
PersonalStageJumpKeywordDto jumpKeywordDto = new PersonalStageJumpKeywordDto();
jumpKeywordDto.setAfterPersonalStageId(paperJump.getAfterPersonalStageId());
jumpKeywordDto.setPersonalStageJumpId(paperJump.getId());
sendEmail(userWxId, robotWxId, content, jumpKeywordDto);
// 将用户置为下个阶段
PersonalStageUser nextPersonalStageUser = personalStageBiz.nextStageAddStageUserAndWakeupDelay(robotWxId, userWxId, ip, paperJump.getAfterPersonalStageId());
// 发送内容衔接语
sendJumpLinkups(userWxId, robotWxId, ip, paperJump.getId(), nextPersonalStageUser.getId());
// 停止发送引导语
pcloudGuideBiz.stopPcloudGuidePush(robotWxId, userWxId);
return true;
}
@Override
public void sendPaperEmail(String userWxId, String robotWxId) {
GroupUserDTO wxUserInfo = wechatGroupConsr.getWxUserInfoByWxUserId(userWxId);
if(wxUserInfo==null){
LOGGER.info("未找到用户信息,无法发送阶段跳转邮件");
}
PcloudRobot pcloudRobot = pcloudRobotDao.getByWxId(robotWxId);
PcloudRobotClassify robotClassify = pcloudRobotClassifyDao.getById(pcloudRobot.getRobotType().longValue());
if (robotClassify == null|| robotClassify.getKeywordClassifyId() == null){
LOGGER.info("小号分类id为空,无法发送阶段跳转邮件");
return;
}
List<String> emailList = new ArrayList<>();
if ("pro".equalsIgnoreCase(envStr)){
emailList.add("leibin@dcrays.cn");
emailList.add("zhoulei@dcrays.cn");
}else {
emailList.add("hyy_8062@163.com");
emailList.add("zhoulei@dcrays.cn");
emailList.add("312949619@qq.com");
}
SendEmailDto sendEmailDto = new SendEmailDto();
sendEmailDto.setTypeCode("feedback_notice_email");
Map<String, Object> content = new HashMap<>();
content.put("nickname", wxUserInfo.getNickName());
content.put("wxUserId", userWxId);
content.put("robotClassifyName", robotClassify.getClassifyName());
content.put("robotNumber", pcloudRobot.getUniqueNumber());
content.put("robotId", robotWxId);
content.put("time", DateNewUtils.getLongDateStr());
sendEmailDto.setContent(content);
for (String email: emailList){
sendEmailDto.setToEmail(email);
messageBiz.sendEmail(sendEmailDto);
}
}
@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 {
......
...@@ -36,7 +36,9 @@ public class PersonalStageCheck { ...@@ -36,7 +36,9 @@ public class PersonalStageCheck {
if (ListUtils.isEmpty(personalStage.getStageNotKeywordReplies())){ if (ListUtils.isEmpty(personalStage.getStageNotKeywordReplies())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"阶段非关键词回复集合不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR,"阶段非关键词回复集合不能为空!");
} }
checkReplies(personalStage.getStageNotKeywordReplies()); //获取需求定制单id
Long paperId = checkReplies(personalStage.getStageNotKeywordReplies());
personalStage.setPaperId(paperId);
if (ListUtils.isEmpty(personalStage.getFusingNotKeywordReplies())){ if (ListUtils.isEmpty(personalStage.getFusingNotKeywordReplies())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"熔断非关键词恢复集合不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR,"熔断非关键词恢复集合不能为空!");
} }
...@@ -63,7 +65,8 @@ public class PersonalStageCheck { ...@@ -63,7 +65,8 @@ public class PersonalStageCheck {
} }
@ParamLog("校验回复") @ParamLog("校验回复")
private void checkReplies(List<PersonalStageReply> list) { private Long checkReplies(List<PersonalStageReply> list) {
Long paperId = null;
for (PersonalStageReply reply:list){ for (PersonalStageReply reply:list){
if (reply==null){ if (reply==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复不能为空!");
...@@ -71,8 +74,18 @@ public class PersonalStageCheck { ...@@ -71,8 +74,18 @@ public class PersonalStageCheck {
if (ListUtils.isEmpty(reply.getPersonalStageReplyItems())){ if (ListUtils.isEmpty(reply.getPersonalStageReplyItems())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项集合不能为空!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复项集合不能为空!");
} }
if (null != reply.getPaperId()){
if (null != paperId){
if (!reply.getPaperId().equals(paperId)){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "非关键词回复存在不一样的需求定制单");
}
}else{
paperId = reply.getPaperId();
}
}
checkReplayItems(reply.getPersonalStageReplyItems()); checkReplayItems(reply.getPersonalStageReplyItems());
} }
return paperId;
} }
@ParamLog("校验回复项") @ParamLog("校验回复项")
......
...@@ -4,9 +4,16 @@ import com.pcloud.book.personalstage.dto.PersonalStageJumpDto; ...@@ -4,9 +4,16 @@ import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.entity.PersonalStageJump; import com.pcloud.book.personalstage.entity.PersonalStageJump;
import com.pcloud.common.core.dao.BaseDao; import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageJumpDao extends BaseDao<PersonalStageJump> { public interface PersonalStageJumpDao extends BaseDao<PersonalStageJump> {
Integer getCountByPersonalStageId(Long personalStageId); Integer getCountByPersonalStageId(Long personalStageId);
PersonalStageJumpDto getDtoById(Long jumpId); PersonalStageJumpDto getDtoById(Long jumpId);
/**
* 根据跳转类型获取阶段跳转
* @return
*/
List<PersonalStageJump> getByJumpType(Long personalStageId, Integer jumpType);
} }
\ No newline at end of file
...@@ -6,6 +6,10 @@ import com.pcloud.book.personalstage.entity.PersonalStageJump; ...@@ -6,6 +6,10 @@ import com.pcloud.book.personalstage.entity.PersonalStageJump;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component("personalStageJump") @Component("personalStageJump")
public class PersonalStageJumpDaoImpl extends BaseDaoImpl<PersonalStageJump> implements PersonalStageJumpDao { public class PersonalStageJumpDaoImpl extends BaseDaoImpl<PersonalStageJump> implements PersonalStageJumpDao {
@Override @Override
...@@ -16,4 +20,12 @@ public class PersonalStageJumpDaoImpl extends BaseDaoImpl<PersonalStageJump> imp ...@@ -16,4 +20,12 @@ public class PersonalStageJumpDaoImpl extends BaseDaoImpl<PersonalStageJump> imp
public PersonalStageJumpDto getDtoById(Long jumpId) { public PersonalStageJumpDto getDtoById(Long jumpId) {
return super.getSqlSession().selectOne(getStatement("getDtoById"), jumpId); return super.getSqlSession().selectOne(getStatement("getDtoById"), jumpId);
} }
@Override
public List<PersonalStageJump> getByJumpType(Long personalStageId, Integer jumpType) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("personalStageId", personalStageId);
paramMap.put("jumpType", jumpType);
return super.getSqlSession().selectList(getStatement("getByJumpType"), paramMap);
}
} }
...@@ -31,6 +31,9 @@ public class PersonalStageDTO extends BaseDto { ...@@ -31,6 +31,9 @@ public class PersonalStageDTO extends BaseDto {
@ApiModelProperty("机器人分类id") @ApiModelProperty("机器人分类id")
private Long robotClassifyId; private Long robotClassifyId;
@ApiModelProperty("需求定制单id")
private Long paperId;
@ApiModelProperty("排序值") @ApiModelProperty("排序值")
private Integer seqNum; private Integer seqNum;
......
...@@ -24,6 +24,9 @@ public class PersonalStage extends BaseEntity { ...@@ -24,6 +24,9 @@ public class PersonalStage extends BaseEntity {
@ApiModelProperty("机器人分类id") @ApiModelProperty("机器人分类id")
private Long robotClassifyId; private Long robotClassifyId;
@ApiModelProperty("需求定制单id")
private Long paperId;
@ApiModelProperty("排序值") @ApiModelProperty("排序值")
private Integer seqNum; private Integer seqNum;
......
...@@ -12,7 +12,7 @@ public class PersonalStageJump extends BaseEntity { ...@@ -12,7 +12,7 @@ public class PersonalStageJump extends BaseEntity {
@ApiModelProperty("定制化阶段id") @ApiModelProperty("定制化阶段id")
private Long personalStageId; private Long personalStageId;
@ApiModelProperty("跳转类型:1读者输入关键词触发,2小睿发送关键词触发,3转账触发") @ApiModelProperty("跳转类型:1读者输入关键词触发,2小睿发送关键词触发,3转账触发,4需求定制单触发")
private Integer jumpType; private Integer jumpType;
@ApiModelProperty("跳转后阶段id") @ApiModelProperty("跳转后阶段id")
......
package com.pcloud.book.personalstage.entity; package com.pcloud.book.personalstage.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.pcloud.common.entity.BaseEntity; import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
...@@ -10,6 +11,7 @@ import java.util.List; ...@@ -10,6 +11,7 @@ import java.util.List;
@ApiModel("定制化回复") @ApiModel("定制化回复")
@Data @Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PersonalStageReply extends BaseEntity { public class PersonalStageReply extends BaseEntity {
@ApiModelProperty("名称") @ApiModelProperty("名称")
...@@ -21,6 +23,12 @@ public class PersonalStageReply extends BaseEntity { ...@@ -21,6 +23,12 @@ public class PersonalStageReply extends BaseEntity {
@ApiModelProperty("关联id") @ApiModelProperty("关联id")
private Long relevanceId; private Long relevanceId;
@ApiModelProperty("需求定制单id")
private Long paperId;
@ApiModelProperty("需求定制单标题")
private String paperTitle;
@ApiModelProperty("关联类型:1阶段非关键词回复,2非关键词熔断回复,3唤醒") @ApiModelProperty("关联类型:1阶段非关键词回复,2非关键词熔断回复,3唤醒")
private Integer relevanceType; private Integer relevanceType;
......
...@@ -4,7 +4,8 @@ public enum JumpTypeEnum { ...@@ -4,7 +4,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, "需求定制单触发");
public final Integer key; public final Integer key;
public final String desc; public final String desc;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<result property="notKeywordFusingCount" column="not_keyword_fusing_count" jdbcType="INTEGER"/> <result property="notKeywordFusingCount" column="not_keyword_fusing_count" jdbcType="INTEGER"/>
<result property="notKeywordFusingTime" column="not_keyword_fusing_time" jdbcType="BIGINT"/> <result property="notKeywordFusingTime" column="not_keyword_fusing_time" jdbcType="BIGINT"/>
<result property="robotClassifyId" column="robot_classify_id" jdbcType="BIGINT"/> <result property="robotClassifyId" column="robot_classify_id" jdbcType="BIGINT"/>
<result property="paperId" column="paper_id" jdbcType="BIGINT"/>
<result property="seqNum" column="seq_num" jdbcType="INTEGER"/> <result property="seqNum" column="seq_num" jdbcType="INTEGER"/>
<result property="showProgress" column="show_progress" jdbcType="INTEGER"/> <result property="showProgress" column="show_progress" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
not_keyword_fusing_count, not_keyword_fusing_count,
not_keyword_fusing_time, not_keyword_fusing_time,
robot_classify_id, robot_classify_id,
paper_id,
seq_num, seq_num,
show_progress, show_progress,
create_time create_time
...@@ -45,6 +47,7 @@ ...@@ -45,6 +47,7 @@
#{notKeywordFusingCount,jdbcType=INTEGER}, #{notKeywordFusingCount,jdbcType=INTEGER},
#{notKeywordFusingTime,jdbcType=BIGINT}, #{notKeywordFusingTime,jdbcType=BIGINT},
#{robotClassifyId,jdbcType=BIGINT}, #{robotClassifyId,jdbcType=BIGINT},
#{paperId},
#{seqNum,jdbcType=INTEGER}, #{seqNum,jdbcType=INTEGER},
#{showProgress,jdbcType=INTEGER}, #{showProgress,jdbcType=INTEGER},
NOW() NOW()
...@@ -66,6 +69,7 @@ ...@@ -66,6 +69,7 @@
<if test="robotClassifyId != null"> <if test="robotClassifyId != null">
robot_classify_id = #{robotClassifyId,jdbcType=BIGINT}, robot_classify_id = #{robotClassifyId,jdbcType=BIGINT},
</if> </if>
paper_id = #{paperId},
<if test="seqNum != null"> <if test="seqNum != null">
seq_num = #{seqNum,jdbcType=INTEGER}, seq_num = #{seqNum,jdbcType=INTEGER},
</if> </if>
...@@ -88,6 +92,7 @@ ...@@ -88,6 +92,7 @@
s.`name`, s.`name`,
sum(IF(r.relevance_type = 1, 1, 0)) notKeywordReplyCount, sum(IF(r.relevance_type = 1, 1, 0)) notKeywordReplyCount,
sum(IF(r.relevance_type = 2, 1, 0)) notKeywordFusingReplyCount, sum(IF(r.relevance_type = 2, 1, 0)) notKeywordFusingReplyCount,
s.paper_id paperId,
s.seq_num seqNum, s.seq_num seqNum,
s.create_time createTime s.create_time createTime
FROM FROM
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</delete> </delete>
<insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStage" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.pcloud.book.personalstage.entity.PersonalStageJump" useGeneratedKeys="true" keyProperty="id">
insert into personal_stage_jump insert into personal_stage_jump
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_id, personal_stage_id,
...@@ -109,4 +109,9 @@ ...@@ -109,4 +109,9 @@
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<select id="getByJumpType" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from personal_stage_jump
where personal_stage_id = #{personalStageId} and jump_type = #{jumpType}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
<result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/> <result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/>
<result property="relevanceId" column="relevance_id" jdbcType="BIGINT"/> <result property="relevanceId" column="relevance_id" jdbcType="BIGINT"/>
<result property="relevanceType" column="relevance_type" jdbcType="INTEGER"/> <result property="relevanceType" column="relevance_type" jdbcType="INTEGER"/>
<result property="paperId" column="paper_id" jdbcType="BIGINT"/>
<result property="paperTitle" column="paper_title" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, name, personal_stage_id, relevance_id, relevance_type, create_time id, name, personal_stage_id, relevance_id, relevance_type, paper_id, paper_title, create_time
</sql> </sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long"> <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
...@@ -34,6 +36,8 @@ ...@@ -34,6 +36,8 @@
personal_stage_id, personal_stage_id,
relevance_id, relevance_id,
relevance_type, relevance_type,
paper_id,
paper_title,
create_time create_time
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
...@@ -41,6 +45,8 @@ ...@@ -41,6 +45,8 @@
#{personalStageId,jdbcType=BIGINT}, #{personalStageId,jdbcType=BIGINT},
#{relevanceId,jdbcType=BIGINT}, #{relevanceId,jdbcType=BIGINT},
#{relevanceType,jdbcType=INTEGER}, #{relevanceType,jdbcType=INTEGER},
#{paperId},
#{paperTitle},
NOW() NOW()
</trim> </trim>
</insert> </insert>
...@@ -51,6 +57,8 @@ ...@@ -51,6 +57,8 @@
personal_stage_id, personal_stage_id,
relevance_id, relevance_id,
relevance_type, relevance_type,
paper_id,
paper_title,
create_time create_time
) values ) values
<foreach collection="list" item="item" index="index" separator=","> <foreach collection="list" item="item" index="index" separator=",">
...@@ -59,6 +67,8 @@ ...@@ -59,6 +67,8 @@
#{item.personalStageId,jdbcType=BIGINT}, #{item.personalStageId,jdbcType=BIGINT},
#{item.relevanceId,jdbcType=BIGINT}, #{item.relevanceId,jdbcType=BIGINT},
#{item.relevanceType,jdbcType=INTEGER}, #{item.relevanceType,jdbcType=INTEGER},
#{item.paperId},
#{item.paperTitle},
NOW() NOW()
) )
</foreach> </foreach>
......
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