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 {
@PostMapping("getPcloudRobotByRobotIds")
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;
import com.pcloud.book.pcloudKeyword.service.PcloudRobotService;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.personalstage.biz.PersonalStageJumpBiz;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.utils.BeanUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
......@@ -24,6 +26,9 @@ public class PcloudRobotServiceImpl implements PcloudRobotService {
@Autowired
private PcloudRobotBiz pcloudRobotBiz;
@Autowired
private PersonalStageJumpBiz personalStageJumpBiz;
@Override
@PostMapping("getRobotClassifyBatch")
public ResponseEntity<ResponseDto<Map<String, RobotClassifyDTO>>> getRobotClassifyBatch(@RequestBody List<String> robotIds) {
......@@ -75,4 +80,12 @@ public class PcloudRobotServiceImpl implements PcloudRobotService {
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 {
Boolean handlePersonalStageJump(String userWxId, String robotWxId, String content, JumpTypeEnum jumpTypeEnum);
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 {
@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_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)
@ParamLog("新增阶段")
......@@ -516,11 +525,16 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
}
Random random = new Random();
Long replyId=ids.get(random.nextInt(ids.size()));
PersonalStageReply personalStageReply = personalStageReplyDao.getById(replyId);
List<PersonalStageReplyItem> items = personalStageReplyItemDao.getListByReplyIds(Arrays.asList(replyId));
if (ListUtils.isEmpty(items)){
return;
}
sendReplyItems(items,robotId,userWxId,ip,personalStageUserId);
//替换需求定制单链接
if (null != personalStageReply.getPaperId()) {
this.replacePaperUrl(items, robotId, userWxId, personalStageReply.getPaperId());
}
}
@ParamLog("尝试插入单号")
......@@ -540,6 +554,19 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
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("非关键词熔断回复")
@Override
public void sendNotKeywordFusingReply(String robotId, String userWxId, String ip, Long personalStageId, Long personalStageUserId) {
......
......@@ -36,7 +36,9 @@ public class PersonalStageCheck {
if (ListUtils.isEmpty(personalStage.getStageNotKeywordReplies())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"阶段非关键词回复集合不能为空!");
}
checkReplies(personalStage.getStageNotKeywordReplies());
//获取需求定制单id
Long paperId = checkReplies(personalStage.getStageNotKeywordReplies());
personalStage.setPaperId(paperId);
if (ListUtils.isEmpty(personalStage.getFusingNotKeywordReplies())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"熔断非关键词恢复集合不能为空!");
}
......@@ -63,7 +65,8 @@ public class PersonalStageCheck {
}
@ParamLog("校验回复")
private void checkReplies(List<PersonalStageReply> list) {
private Long checkReplies(List<PersonalStageReply> list) {
Long paperId = null;
for (PersonalStageReply reply:list){
if (reply==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"回复不能为空!");
......@@ -71,8 +74,18 @@ public class PersonalStageCheck {
if (ListUtils.isEmpty(reply.getPersonalStageReplyItems())){
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());
}
return paperId;
}
@ParamLog("校验回复项")
......
......@@ -4,9 +4,16 @@ import com.pcloud.book.personalstage.dto.PersonalStageJumpDto;
import com.pcloud.book.personalstage.entity.PersonalStageJump;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
public interface PersonalStageJumpDao extends BaseDao<PersonalStageJump> {
Integer getCountByPersonalStageId(Long personalStageId);
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;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component("personalStageJump")
public class PersonalStageJumpDaoImpl extends BaseDaoImpl<PersonalStageJump> implements PersonalStageJumpDao {
@Override
......@@ -16,4 +20,12 @@ public class PersonalStageJumpDaoImpl extends BaseDaoImpl<PersonalStageJump> imp
public PersonalStageJumpDto getDtoById(Long 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 {
@ApiModelProperty("机器人分类id")
private Long robotClassifyId;
@ApiModelProperty("需求定制单id")
private Long paperId;
@ApiModelProperty("排序值")
private Integer seqNum;
......
......@@ -24,6 +24,9 @@ public class PersonalStage extends BaseEntity {
@ApiModelProperty("机器人分类id")
private Long robotClassifyId;
@ApiModelProperty("需求定制单id")
private Long paperId;
@ApiModelProperty("排序值")
private Integer seqNum;
......
......@@ -12,7 +12,7 @@ public class PersonalStageJump extends BaseEntity {
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("跳转类型:1读者输入关键词触发,2小睿发送关键词触发,3转账触发")
@ApiModelProperty("跳转类型:1读者输入关键词触发,2小睿发送关键词触发,3转账触发,4需求定制单触发")
private Integer jumpType;
@ApiModelProperty("跳转后阶段id")
......
package com.pcloud.book.personalstage.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -10,6 +11,7 @@ import java.util.List;
@ApiModel("定制化回复")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PersonalStageReply extends BaseEntity {
@ApiModelProperty("名称")
......@@ -21,6 +23,12 @@ public class PersonalStageReply extends BaseEntity {
@ApiModelProperty("关联id")
private Long relevanceId;
@ApiModelProperty("需求定制单id")
private Long paperId;
@ApiModelProperty("需求定制单标题")
private String paperTitle;
@ApiModelProperty("关联类型:1阶段非关键词回复,2非关键词熔断回复,3唤醒")
private Integer relevanceType;
......
......@@ -4,7 +4,8 @@ public enum JumpTypeEnum {
READER_TRIGGER(1,"读者输入关键词触发"),
ROBOT_TRIGGER(2,"小睿发送关键词触发"),
PAY_TRIGGER(3,"转账触发");
PAY_TRIGGER(3,"转账触发"),
PAPER_TRIGGER(4, "需求定制单触发");
public final Integer key;
public final String desc;
......
......@@ -8,6 +8,7 @@
<result property="notKeywordFusingCount" column="not_keyword_fusing_count" jdbcType="INTEGER"/>
<result property="notKeywordFusingTime" column="not_keyword_fusing_time" 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="showProgress" column="show_progress" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
......@@ -36,6 +37,7 @@
not_keyword_fusing_count,
not_keyword_fusing_time,
robot_classify_id,
paper_id,
seq_num,
show_progress,
create_time
......@@ -45,6 +47,7 @@
#{notKeywordFusingCount,jdbcType=INTEGER},
#{notKeywordFusingTime,jdbcType=BIGINT},
#{robotClassifyId,jdbcType=BIGINT},
#{paperId},
#{seqNum,jdbcType=INTEGER},
#{showProgress,jdbcType=INTEGER},
NOW()
......@@ -66,6 +69,7 @@
<if test="robotClassifyId != null">
robot_classify_id = #{robotClassifyId,jdbcType=BIGINT},
</if>
paper_id = #{paperId},
<if test="seqNum != null">
seq_num = #{seqNum,jdbcType=INTEGER},
</if>
......@@ -88,6 +92,7 @@
s.`name`,
sum(IF(r.relevance_type = 1, 1, 0)) notKeywordReplyCount,
sum(IF(r.relevance_type = 2, 1, 0)) notKeywordFusingReplyCount,
s.paper_id paperId,
s.seq_num seqNum,
s.create_time createTime
FROM
......
......@@ -57,7 +57,7 @@
where id = #{id,jdbcType=BIGINT}
</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
<trim prefix="(" suffix=")" suffixOverrides=",">
personal_stage_id,
......@@ -109,4 +109,9 @@
where id = #{id,jdbcType=INTEGER}
</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>
\ No newline at end of file
......@@ -8,11 +8,13 @@
<result property="personalStageId" column="personal_stage_id" jdbcType="BIGINT"/>
<result property="relevanceId" column="relevance_id" jdbcType="BIGINT"/>
<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"/>
</resultMap>
<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>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -34,6 +36,8 @@
personal_stage_id,
relevance_id,
relevance_type,
paper_id,
paper_title,
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
......@@ -41,6 +45,8 @@
#{personalStageId,jdbcType=BIGINT},
#{relevanceId,jdbcType=BIGINT},
#{relevanceType,jdbcType=INTEGER},
#{paperId},
#{paperTitle},
NOW()
</trim>
</insert>
......@@ -51,6 +57,8 @@
personal_stage_id,
relevance_id,
relevance_type,
paper_id,
paper_title,
create_time
) values
<foreach collection="list" item="item" index="index" separator=",">
......@@ -59,6 +67,8 @@
#{item.personalStageId,jdbcType=BIGINT},
#{item.relevanceId,jdbcType=BIGINT},
#{item.relevanceType,jdbcType=INTEGER},
#{item.paperId},
#{item.paperTitle},
NOW()
)
</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