Commit 33f37fa2 by 阮思源

Merge branch 'feat-1002652' into 'master'

1002652 图书服务等级判断与0级图书服务推送

See merge request rays/pcloud-book!597
parents 7c40ddd5 9d93379c
...@@ -216,6 +216,12 @@ ...@@ -216,6 +216,12 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.pcloud.facade</groupId>
<artifactId>pcloud-facade-erp</artifactId>
<version>${pcloud-facade.version}</version>
</dependency>
<dependency>
<groupId>fakepath</groupId> <groupId>fakepath</groupId>
<artifactId>jbarcode</artifactId> <artifactId>jbarcode</artifactId>
<version>0.2.8</version> <version>0.2.8</version>
......
package com.pcloud.book.consumer.erp;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.erp.project.service.ProjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository("erpConsr")
public class ErpConsr {
/**
* logger
*/
private static final Logger LOGGER = LoggerFactory.getLogger(ErpConsr.class);
@Autowired
private ProjectService projectService;
@ParamLog("根据书名获取等级")
public Integer getBookServiceLevel(String bookName) throws BizException {
try {
return ResponseHandleUtil.parseResponse(projectService.getBookServiceLevel(bookName), Integer.class);
} catch (Exception e) {
LOGGER.error("获取资源基本信息[resourceService.mapByPass]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "获取资源基本信息失败~!");
}
}
}
...@@ -6,6 +6,7 @@ import com.google.common.collect.Maps; ...@@ -6,6 +6,7 @@ import com.google.common.collect.Maps;
import com.pcloud.book.base.exception.BookBizException; import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.constant.BookConstant; import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.consumer.content.ResourceConsr; import com.pcloud.book.consumer.content.ResourceConsr;
import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr; import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.custom.mapper.CustomPlanModuleSuggestionMapper; import com.pcloud.book.custom.mapper.CustomPlanModuleSuggestionMapper;
import com.pcloud.book.custom.vo.AddBookNameVO; import com.pcloud.book.custom.vo.AddBookNameVO;
...@@ -63,6 +64,7 @@ import com.pcloud.common.utils.cache.redis.JedisClusterUtils; ...@@ -63,6 +64,7 @@ import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.httpclient.UrlUtils; import com.pcloud.common.utils.httpclient.UrlUtils;
import com.pcloud.common.utils.string.StringUtil; import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.contentcenter.resource.dto.ResourceDTO; import com.pcloud.contentcenter.resource.dto.ResourceDTO;
import com.pcloud.erp.project.enums.ServiceLevelEnum;
import com.pcloud.wechatgroup.group.dto.GroupRobotDTO; import com.pcloud.wechatgroup.group.dto.GroupRobotDTO;
import com.pcloud.wechatgroup.group.dto.GroupUserDTO; import com.pcloud.wechatgroup.group.dto.GroupUserDTO;
import com.sdk.wxgroup.RobotProcessTypeEnum; import com.sdk.wxgroup.RobotProcessTypeEnum;
...@@ -140,6 +142,9 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -140,6 +142,9 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
@Autowired @Autowired
private PersonalAppletsDao personalAppletsDao; private PersonalAppletsDao personalAppletsDao;
@Autowired
private ErpConsr erpConsr;
@Value("${wechat.group.link.prefix}") @Value("${wechat.group.link.prefix}")
private String wechatLinkPrefix; private String wechatLinkPrefix;
...@@ -384,6 +389,15 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -384,6 +389,15 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
PersonalStageUser last = personalStageUserDao.getLast(userWxId, robotId, null); PersonalStageUser last = personalStageUserDao.getLast(userWxId, robotId, null);
PersonalStage personalStage; PersonalStage personalStage;
if (last!=null){ if (last!=null){
//如果之前有书的时候判断这个阶段的跳转方式是否踩中有0级和非0级的跳转关键词
//先判断0级
if (dealZeroBook(userWxId, robotId, content,last,JumpTypeEnum.ZERO_BOOK)){
return;
}
//再判断非0级
if (dealZeroBook(userWxId, robotId, content,last,JumpTypeEnum.NO_ZERO_BOOK)){
return;
}
hasRecord=true; hasRecord=true;
personalStage=personalStageDao.getById(last.getPersonalStageId()); personalStage=personalStageDao.getById(last.getPersonalStageId());
}else { }else {
...@@ -464,6 +478,37 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -464,6 +478,37 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
} }
} }
@ParamLog("处理0级书和非0级书")
private Boolean dealZeroBook(String userWxId, String robotId, String content, PersonalStageUser last,JumpTypeEnum jumpTypeEnum) {
PersonalStageJumpKeywordDto dto=personalStageJumpKeywordDao.getByKeyword(last.getPersonalStageId(),content, jumpTypeEnum.key);
if (dto==null){
return false;
}
List<ReplaceCode> all = replaceCodeDao.getAll();
Long replaceCodeId = null;
for (ReplaceCode replaceCode:all){
if ("${bookName}".equals(replaceCode.getReplaceCode())){
replaceCodeId = replaceCode.getId();
break;
}
}
UserReplaceCode record = userReplaceCodeDao.getLastUserReplaceByCodeId(userWxId, robotId, replaceCodeId);
if (record==null){
return false;
}
//查询书名等级,阶段跳转
Integer level = erpConsr.getBookServiceLevel(record.getContent());
if (jumpTypeEnum.key.equals(JumpTypeEnum.ZERO_BOOK.key)&& ServiceLevelEnum.ZERO_BOOK.value.equals(level)){
personalStageJumpBiz.handlePersonalStageJump(userWxId,robotId,content,jumpTypeEnum);
return true;
}
if (jumpTypeEnum.key.equals(JumpTypeEnum.NO_ZERO_BOOK.key)&& ServiceLevelEnum.NOT_ZERO_BOOK.value.equals(level)){
personalStageJumpBiz.handlePersonalStageJump(userWxId,robotId,content,jumpTypeEnum);
return true;
}
return false;
}
@ParamLog("从缓存中获取发送非关键词次数") @ParamLog("从缓存中获取发送非关键词次数")
private synchronized Integer getSendNKeywordCountFromCache(Long personalStageId, String wxId, String robotId) { private synchronized Integer getSendNKeywordCountFromCache(Long personalStageId, String wxId, String robotId) {
......
...@@ -131,8 +131,7 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -131,8 +131,7 @@ 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.READER_TRIGGER.key.equals(vo.getJumpType())||JumpTypeEnum.ROBOT_TRIGGER.key.equals(vo.getJumpType())){
&&!JumpTypeEnum.END_SERVICE.key.equals(vo.getJumpType())&&!JumpTypeEnum.PLAN_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())){ if (JumpTypeEnum.PAPER_TRIGGER.key.equals(vo.getJumpType())){
...@@ -313,8 +312,7 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz { ...@@ -313,8 +312,7 @@ 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.READER_TRIGGER.key.equals(vo.getJumpType())||JumpTypeEnum.ROBOT_TRIGGER.key.equals(vo.getJumpType())){
&&!JumpTypeEnum.END_SERVICE.key.equals(vo.getJumpType()) &&!JumpTypeEnum.PLAN_TRIGGER.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())){
......
...@@ -10,4 +10,6 @@ public interface UserReplaceCodeDao extends BaseDao<UserReplaceCode> { ...@@ -10,4 +10,6 @@ public interface UserReplaceCodeDao extends BaseDao<UserReplaceCode> {
List<UserReplaceCode> getLastUserReplace(String wxId, String robotId); List<UserReplaceCode> getLastUserReplace(String wxId, String robotId);
List<String> getUserReplaceRecordByCodeId(String wxId, String robotId, Long codeId); List<String> getUserReplaceRecordByCodeId(String wxId, String robotId, Long codeId);
UserReplaceCode getLastUserReplaceByCodeId(String wxId, String robotId, Long replaceCodeId);
} }
\ No newline at end of file
...@@ -28,4 +28,13 @@ public class UserReplaceCodeDaoImpl extends BaseDaoImpl<UserReplaceCode> impleme ...@@ -28,4 +28,13 @@ public class UserReplaceCodeDaoImpl extends BaseDaoImpl<UserReplaceCode> impleme
map.put("replaceCodeId",codeId); map.put("replaceCodeId",codeId);
return super.getSqlSession().selectList(getStatement("getUserReplaceRecordByCodeId"),map); return super.getSqlSession().selectList(getStatement("getUserReplaceRecordByCodeId"),map);
} }
@Override
public UserReplaceCode getLastUserReplaceByCodeId(String wxId, String robotId, Long replaceCodeId) {
Map<String,Object> map=new HashMap<>();
map.put("wxId",wxId);
map.put("robotId",robotId);
map.put("replaceCodeId",replaceCodeId);
return super.getSqlSession().selectOne(getStatement("getLastUserReplaceByCodeId"),map);
}
} }
...@@ -7,7 +7,9 @@ public enum JumpTypeEnum { ...@@ -7,7 +7,9 @@ public enum JumpTypeEnum {
PAY_TRIGGER(3,"转账触发"), PAY_TRIGGER(3,"转账触发"),
PAPER_TRIGGER(4, "需求定制单触发"), PAPER_TRIGGER(4, "需求定制单触发"),
END_SERVICE(5,"人工客服结束触发"), END_SERVICE(5,"人工客服结束触发"),
PLAN_TRIGGER(6,"方案定制单触发"); PLAN_TRIGGER(6,"方案定制单触发"),
ZERO_BOOK(8,"0级书跳转"),
NO_ZERO_BOOK(9,"非0级书跳转");
public final Integer key; public final Integer key;
public final String desc; public final String desc;
......
...@@ -83,4 +83,17 @@ ...@@ -83,4 +83,17 @@
create_time DESC create_time DESC
</select> </select>
<select id="getLastUserReplaceByCodeId" parameterType="map" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
user_replace_code
WHERE robot_id = #{robotId}
AND wx_id = #{wxId}
AND replace_code_id = #{replaceCodeId}
ORDER BY
create_time DESC
limit 1
</select>
</mapper> </mapper>
\ No newline at end of file
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