Commit 83192758 by 阮思源 Committed by 郑永强

加字段

parent 19d947c2
......@@ -257,4 +257,10 @@ public interface BookService {
ResponseEntity<ResponseDto<List<Long>>> getBookIdsByBookName(
@RequestParam(value = "bookName") String bookName
) throws BizException;
@ApiOperation("根据isbn模糊匹配,获得所有book_id")
@RequestMapping(value = "/getBookIdsByIsbn", method = RequestMethod.GET)
ResponseEntity<ResponseDto<List<Long>>> getBookIdsByIsbn(
@RequestParam(value = "isbn") String isbn
) throws BizException;
}
......@@ -216,12 +216,6 @@
</dependency>
<dependency>
<groupId>com.pcloud.facade</groupId>
<artifactId>pcloud-facade-erp</artifactId>
<version>${pcloud-facade.version}</version>
</dependency>
<dependency>
<groupId>fakepath</groupId>
<artifactId>jbarcode</artifactId>
<version>0.2.8</version>
......
......@@ -627,4 +627,9 @@ public interface BookBiz {
*/
PageBeanNew<BookDto> getBookAndServeList4Channel(Integer currentPage, Integer numPerPage, Long channelId,String name,
Integer isFundSupport, String startDate, String endDate);
/**
* 根据isbn模糊匹配,获得所有book_id
*/
List<Long> getBookIdsByIsbn(String isbn);
}
......@@ -2025,4 +2025,9 @@ public class BookBizImpl implements BookBiz {
});
}
@Override
public List<Long> getBookIdsByIsbn(String isbn) {
return bookDao.getBookIdsByIsbn(isbn);
}
}
......@@ -3,8 +3,6 @@
*/
package com.pcloud.book.book.dao;
import java.util.List;
import java.util.Map;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.dto.BookInfo4AnlysicsDTO;
import com.pcloud.book.book.dto.BookInfoAnalysicsDTO;
......@@ -12,6 +10,9 @@ import com.pcloud.book.book.entity.Book;
import com.pcloud.book.book.vo.BookSaleVO;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* @描述:书籍数据访问层接口
* @作者:songx
......@@ -329,4 +330,6 @@ public interface BookDao extends BaseDao<Book> {
List<Long> getBookIdsByBookName(String bookName);
BookDto getAdviserBookByName(String bookName);
List<Long> getBookIdsByIsbn(String isbn);
}
......@@ -3,21 +3,19 @@
*/
package com.pcloud.book.book.dao.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.google.common.collect.Lists;
import com.pcloud.book.book.vo.BookSaleVO;
import org.springframework.stereotype.Repository;
import com.google.common.collect.Maps;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.book.dto.BookInfo4AnlysicsDTO;
import com.pcloud.book.book.dto.BookInfoAnalysicsDTO;
import com.pcloud.book.book.entity.Book;
import com.pcloud.book.book.vo.BookSaleVO;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @描述:书籍数据访问层实现类
......@@ -328,4 +326,11 @@ public class BookDaoImpl extends BaseDaoImpl<Book> implements BookDao {
paramMap.put("bookName", bookName);
return super.getSqlSession().selectOne(getStatement("getAdviserBookByName"),paramMap);
}
@Override
public List<Long> getBookIdsByIsbn(String isbn) {
Map<String, Object> paramMap = Maps.newHashMap();
paramMap.put("isbn", isbn);
return super.getSqlSession().selectOne(getStatement("getBookIdsByIsbn"),paramMap);
}
}
......@@ -210,4 +210,12 @@ public class BookServiceImpl implements BookService {
) throws BizException {
return ResponseHandleUtil.toResponse(bookBiz.getBookIdsByBookName(bookName));
}
@ApiOperation("根据isbn模糊匹配,获得所有book_id")
@RequestMapping(value = "/getBookIdsByIsbn", method = RequestMethod.GET)
@Override
public ResponseEntity<ResponseDto<List<Long>>> getBookIdsByIsbn(
@RequestParam(value = "isbn") String isbn) throws BizException {
return ResponseHandleUtil.toResponse(bookBiz.getBookIdsByIsbn(isbn));
}
}
......@@ -3,13 +3,19 @@ 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.ListUtils;
import com.pcloud.common.utils.ResponseHandleUtil;
import com.pcloud.common.utils.string.StringUtil;
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Repository("erpConsr")
public class ErpConsr {
/**
......@@ -19,7 +25,7 @@ public class ErpConsr {
@Autowired
private ProjectService projectService;
@ParamLog("根据书名获取等级")
public Integer getBookServiceLevel(String bookName) throws BizException {
try {
......@@ -29,6 +35,31 @@ public class ErpConsr {
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "获取资源基本信息失败~!");
}
}
@ParamLog("批量获取项目名称")
public Map<Long, String> getBookNames(List<Long> bookIds) throws BizException {
if(ListUtils.isEmpty(bookIds)){
return new HashMap<>();
}
try {
return ResponseHandleUtil.parseMap(projectService.getBookNames(bookIds), Long.class,String.class);
} catch (Exception e) {
LOGGER.error("批量获取项目名称[projectService.getBookNames]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "批量获取项目名称~!");
}
}
@ParamLog("通过书名获取ERP端的bookId")
public List<Long> getIdByBookName(String bookName) throws BizException {
if(StringUtil.isEmpty(bookName)){
return null;
}
try {
return ResponseHandleUtil.parseListResponse(projectService.getIdByBookName(bookName), Long.class);
} catch (Exception e) {
LOGGER.error("通过书名获取ERP端的bookId[projectService.getIdByBookName]:" + e.getMessage(), e);
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "通过书名获取ERP端的bookId错误");
}
}
}
package com.pcloud.book.custom.biz;
import com.pcloud.book.custom.dto.PlanReadTypeDto;
import com.pcloud.book.custom.entity.CustomPlan;
import com.pcloud.book.custom.vo.*;
import com.pcloud.common.page.PageBeanNew;
......@@ -47,4 +48,6 @@ public interface CustomPlanBiz {
AddBookNameVO getUserBookAdnServiceType(String wxId, String robotWxId, Integer type);
UserBookServiceVO getUserBookServiceById(Long userBookServiceId);
List<PlanReadTypeDto> getPlanReadTypesByBookId(Long bookId);
}
......@@ -5,12 +5,16 @@ import com.dcg.coolq.sdk.message.MessageBuilder;
import com.dcg.coolq.sdk.message.vos.send.PrivateMsgSendVO;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.biz.BookBiz;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.consumer.app.AppConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.book.consumer.feedback.FeedbackConsr;
import com.pcloud.book.consumer.shareimage.ShareImageConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.custom.biz.CustomPlanBiz;
import com.pcloud.book.custom.dto.PlanReadTypeDto;
import com.pcloud.book.custom.entity.CustomPlan;
import com.pcloud.book.custom.entity.CustomPlanModule;
import com.pcloud.book.custom.entity.CustomPlanModuleSuggestion;
......@@ -19,7 +23,17 @@ import com.pcloud.book.custom.enums.PlanUseStateEnum;
import com.pcloud.book.custom.mapper.CustomPlanMapper;
import com.pcloud.book.custom.mapper.CustomPlanModuleMapper;
import com.pcloud.book.custom.mapper.CustomPlanModuleSuggestionMapper;
import com.pcloud.book.custom.vo.*;
import com.pcloud.book.custom.vo.AddBookNameVO;
import com.pcloud.book.custom.vo.AddCustomPlan4UserVO;
import com.pcloud.book.custom.vo.AddSuggestionListVO;
import com.pcloud.book.custom.vo.AddSuggestionVO;
import com.pcloud.book.custom.vo.CustomPlanModuleVO;
import com.pcloud.book.custom.vo.CustomPlanPaperVO;
import com.pcloud.book.custom.vo.EditCustomPlanModuleVO;
import com.pcloud.book.custom.vo.ModuleSuggestionVO;
import com.pcloud.book.custom.vo.SuggestionListVO;
import com.pcloud.book.custom.vo.ToPdfVO;
import com.pcloud.book.custom.vo.UserBookServiceVO;
import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.group.tools.Kit;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
......@@ -50,6 +64,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -82,6 +97,10 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
private WechatGroupConsr wechatGroupConsr;
@Autowired
private WeixinQrcodeBiz weixinQrcodeBiz;
@Autowired
private BookBiz bookBiz;
@Autowired
private ErpConsr erpConsr;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -124,7 +143,13 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
@Override
public CustomPlan getCustomPlanById(Integer planId) {
return customPlanMapper.getById(planId);
CustomPlan customPlan = customPlanMapper.getById(planId);
if(null!=customPlan && null!=customPlan.getBookId()){
Map<Long, String> bookNames = erpConsr.getBookNames(Arrays.asList(customPlan.getBookId()));
if(MapUtils.isNotEmpty(bookNames) && bookNames.containsKey(customPlan.getBookId()))
customPlan.setBookName(bookNames.get(customPlan.getBookId()));
}
return customPlan;
}
@Override
......@@ -142,6 +167,17 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
}
List<CustomPlan> customPlanList = customPlanMapper.listCustomPlanByPage(currentPage * numPerPage,
numPerPage, content, useState, hasPdf, robotType, readType);
List<Long> bookIds = customPlanList.stream().filter(a -> null != a.getBookId()).map(a -> a.getBookId()).distinct().collect(Collectors.toList());
Map<Long, String> bookNameMap = new HashMap<>();
if(!ListUtils.isEmpty(bookIds)){
bookNameMap=erpConsr.getBookNames(bookIds);
}
for (CustomPlan customPlan : customPlanList) {
if(null!=customPlan.getBookId() && MapUtils.isNotEmpty(bookNameMap) && bookNameMap.containsKey(customPlan.getBookId())){
String bookName = bookNameMap.get(customPlan.getBookId());
customPlan.setBookName(bookName);
}
}
return new PageBeanNew<>(currentPage, numPerPage, count, customPlanList);
}
......@@ -221,6 +257,7 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
@Override
public List<CustomPlanModuleVO> getCustomPlanModule(Integer planId) {
List<CustomPlanModuleVO> parentPlanModuleVOList = customPlanModuleMapper.getCustomPlanModuleByPlanId(planId, 0);
CustomPlan customPlan = customPlanMapper.getById(planId);
for(CustomPlanModuleVO planModuleVO : parentPlanModuleVOList) {
if(PlanModuleTypeEnum.GROUP.value.equals(planModuleVO.getModuleType())) {
List<CustomPlanModuleVO> planModuleVOList = customPlanModuleMapper.getCustomPlanModuleByPlanId(planId, planModuleVO.getId());
......@@ -228,6 +265,14 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
planModuleVO.setCustomPlanModuleVOList(planModuleVOList);
}
}
if(PlanModuleTypeEnum.TOP.value.equals(planModuleVO.getModuleType())){
planModuleVO.setReadType(null != customPlan ? customPlan.getReadType() : null);
planModuleVO.setBookName(null);
if (null != customPlan && null != customPlan.getBookId()) {
BookDto bookDto = bookBiz.getBaseById(customPlan.getBookId());
planModuleVO.setBookName(null != bookDto ? bookDto.getBookName() : null);
}
}
}
return parentPlanModuleVOList;
}
......@@ -445,4 +490,14 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
public UserBookServiceVO getUserBookServiceById(Long userBookServiceId) {
return customPlanModuleSuggestionMapper.getUserBookServiceById(userBookServiceId);
}
@ParamLog("根据书Id获取定制计划")
@Override
public List<PlanReadTypeDto> getPlanReadTypesByBookId(Long bookId) {
if (bookId==null){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"书id为空!");
}
List<PlanReadTypeDto> list=customPlanMapper.getPlanReadTypesByBookId(bookId);
return list;
}
}
package com.pcloud.book.custom.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PlanReadTypeDto implements Serializable {
@ApiModelProperty("定制服务id")
private Long customPlanId;
@ApiModelProperty("阅读类型1轻松2高效3深度")
private Integer readType;
}
......@@ -54,4 +54,16 @@ public class CustomPlan {
@ApiModelProperty("阅读类型1轻松2高效3深度")
private Integer readType;
@ApiModelProperty("书Id")
private Long bookId;
@ApiModelProperty("权益图片")
private String rightsPic;
@ApiModelProperty("按钮名称")
private String buttonName;
@ApiModelProperty("书籍名称")
private String bookName;
}
\ No newline at end of file
package com.pcloud.book.custom.enums;
import java.util.Arrays;
public enum PlanReadTypeEnum {
RELAX(1, "轻松阅读"),
EFFICIENT(2,"高效阅读"),
DEPTH(3,"深度阅读");
public final Integer id;
public final String desc;
PlanReadTypeEnum(Integer id, String desc){
this.id = id;
this.desc = desc;
}
public static Integer getIdByDesc(String desc){
return Arrays.stream(PlanReadTypeEnum.values()).filter(x->x.desc.equals(desc)).map(x->x.id).findFirst().orElse(null);
}
public static String getDescById(Integer id){
return Arrays.stream(PlanReadTypeEnum.values()).filter(x->x.id.equals(id)).map(x->x.desc).findFirst().orElse(null);
}
}
......@@ -266,5 +266,13 @@ public class CustomPlanFacade {
return new ResponseDto<>(customReadPlanBiz.copyCustomReadPlanById(customReadPlanId));
}
@ApiOperation("根据书Id获取定制计划类型")
@GetMapping("getPlanReadTypesByBookId")
ResponseDto<?> getPlanReadTypesByBookId(
@RequestParam("bookId") Long bookId
)throws BizException, PermissionException{
return new ResponseDto<>(customPlanBiz.getPlanReadTypesByBookId(bookId));
}
}
package com.pcloud.book.custom.mapper;
import com.pcloud.book.custom.dto.PlanReadTypeDto;
import com.pcloud.book.custom.entity.CustomPlan;
import com.pcloud.book.custom.vo.CustomPlanPaperVO;
import org.apache.ibatis.annotations.Param;
......@@ -32,4 +33,8 @@ public interface CustomPlanMapper {
List<CustomPlanPaperVO> listPlanPaperByPage(Map<String, Object> paramMap);
void updatePdfUrl(CustomPlan customPlan);
List<PlanReadTypeDto> getPlanReadTypesByBookId(@Param("bookId") Long bookId);
CustomPlan getLastCustomPlan(@Param("bookIds") List<Long> bookIds,@Param("readType") Integer readType);
}
\ No newline at end of file
......@@ -54,6 +54,8 @@ public class DelayReceiver {
personalStageJumpBiz.delayPaper(dto);
} else if (CultivateConstant.ENERGY_CONSUMPTION_DELAY.equals(dto.getType())) {
cultivateBiz.dealDelayEnergyConsumption(dto);
} else if (PersonalStageConstant.PERSONALSTAGE_DELAY_TIME_JUMP.equals(dto.getType())){
personalStageJumpBiz.dealDelayTimeJump(dto);
}
}
......
......@@ -4,6 +4,7 @@ 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.PlanJumpNextDTO;
import com.pcloud.book.personalstage.dto.TimeJumpNextDTO;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.personalstage.vo.request.CreateStageJumpRequestVO;
import com.pcloud.book.personalstage.vo.request.UpdateStageJumpRequestVO;
......@@ -109,6 +110,10 @@ public interface PersonalStageJumpBiz {
void planJumpNext(PlanJumpNextDTO planJumpNextDTO);
void setDelayTimeJump(TimeJumpNextDTO timeJumpNextDTO);
void dealDelayTimeJump(DelayQueueDTO dto);
/**
* 删除用户的需求单记录
* @param robotId
......
......@@ -8,6 +8,9 @@ import com.pcloud.book.book.constant.BookConstant;
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.custom.entity.CustomPlan;
import com.pcloud.book.custom.enums.PlanReadTypeEnum;
import com.pcloud.book.custom.mapper.CustomPlanMapper;
import com.pcloud.book.custom.mapper.CustomPlanModuleSuggestionMapper;
import com.pcloud.book.custom.vo.AddBookNameVO;
import com.pcloud.book.custom.vo.UserBookServiceVO;
......@@ -138,10 +141,10 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
private UserReplaceCodeDao userReplaceCodeDao;
@Autowired
private ReplaceCodeDao replaceCodeDao;
@Autowired
private PersonalAppletsDao personalAppletsDao;
@Autowired
private CustomPlanMapper customPlanMapper;
@Autowired
private ErpConsr erpConsr;
......@@ -671,22 +674,31 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
personalStageUser.setRobotClassifyId(robotClassifyId);
personalStageUser.setPersonalStageId(personalStageId);
personalStageUserDao.insert(personalStageUser);
// 设置定时跳转
TimeJumpNextDTO timeJumpNextDTO = new TimeJumpNextDTO();
timeJumpNextDTO.setRobotWxId(robotId);
timeJumpNextDTO.setWxId(userWxId);
timeJumpNextDTO.setPersonalStageId(personalStageId);
timeJumpNextDTO.setPersonalStageUserId(personalStageUser.getId());
timeJumpNextDTO.setIp(ip);
personalStageJumpBiz.setDelayTimeJump(timeJumpNextDTO);
//同时插入唤醒队列
//查询第一个唤醒时长
if (wakeup==null){
return personalStageUser;
}
Integer toStageStartTime=wakeup.getToStageStartTime();
WakeupDelayDTO wakeupDelayDTO=new WakeupDelayDTO();
wakeupDelayDTO.setPersonalStageWakeupId(wakeup.getId());
wakeupDelayDTO.setRobotId(robotId);
wakeupDelayDTO.setWxId(userWxId);
wakeupDelayDTO.setIp(ip);
wakeupDelayDTO.setPersonalStageId(personalStageId);
wakeupDelayDTO.setPersonalStageUserId(personalStageUser.getId());
wakeupDelayDTO.setPersonalStageCreateTime(DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
DelayQueueDTO delayQueueDTO = DelayQueueDTO.builder().key(userWxId).type(PersonalStageConstant.PERSONALSTAGE_DELAY_WAKEUP).msg(wakeupDelayDTO).timeout(toStageStartTime*1000).build();
delayMessageSender.send(delayQueueDTO);
if (wakeup!=null){
Integer toStageStartTime=wakeup.getToStageStartTime();
WakeupDelayDTO wakeupDelayDTO=new WakeupDelayDTO();
wakeupDelayDTO.setPersonalStageWakeupId(wakeup.getId());
wakeupDelayDTO.setRobotId(robotId);
wakeupDelayDTO.setWxId(userWxId);
wakeupDelayDTO.setIp(ip);
wakeupDelayDTO.setPersonalStageId(personalStageId);
wakeupDelayDTO.setPersonalStageUserId(personalStageUser.getId());
wakeupDelayDTO.setPersonalStageCreateTime(DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
DelayQueueDTO delayQueueDTO = DelayQueueDTO.builder().key(userWxId).type(PersonalStageConstant.PERSONALSTAGE_DELAY_WAKEUP).msg(wakeupDelayDTO).timeout(toStageStartTime*1000).build();
delayMessageSender.send(delayQueueDTO);
}
return personalStageUser;
}
......@@ -870,6 +882,58 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
content = replaceUserSendContent(content, robotId, userWxId);
content = replaceReadingStyle(content, robotId, userWxId);
content = replaceBookSearch(content, robotId, userWxId);
content = replaceRights(content, robotId, userWxId);
return content;
}
/**
* 替换权益链接
* @param content
* @param robotId
* @param userWxId
* @return
*/
private String replaceRights(String content, String robotId, String userWxId) {
if(content.indexOf(PersonalStageConstant.PLAN_RIGHTS) > -1) {
// 查询用户最近搜索的书
UserReplaceCode userReplaceCodeBookName = userReplaceCodeDao.getLastOneUserReplace(userWxId, robotId, 1);
UserReplaceCode userReplaceCodeReadType = userReplaceCodeDao.getLastOneUserReplace(userWxId, robotId, 2);
if (userReplaceCodeBookName == null || userReplaceCodeReadType == null) {
LOGGER.info("未找到用户输入的书名或阅读类型,无法进行跳转");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
}
String bookName = userReplaceCodeBookName.getContent();
if (StringUtil.isEmpty(bookName)) {
LOGGER.info("图书名称为空,无法替换链接");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
}
// content 有可能是数字,也有可能是文字
Integer readType = null;
if(NumberUtil.isNumber(userReplaceCodeReadType.getContent())){
readType = Integer.parseInt(userReplaceCodeReadType.getContent());
} else {
readType = PlanReadTypeEnum.getIdByDesc(userReplaceCodeReadType.getContent());
}
if (readType == null) {
LOGGER.info("阅读类型不正确,无法替换链接; userReplaceCodeReadType.getContent: " + userReplaceCodeReadType.getContent());
return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
}
// 根据书名查询用户对应的权益(方案)
List<Long> bookIds = erpConsr.getIdByBookName(bookName);
if(ListUtils.isEmpty(bookIds)){
LOGGER.info("在ERP中未找到对应的书,无法替换链接");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
}
CustomPlan customPlan = customPlanMapper.getLastCustomPlan(bookIds, readType);
if (customPlan == null) {
LOGGER.info("未找到对应的权益,无法替换链接");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
}
//查询该用户最后的阶段
PersonalStageUser last = personalStageUserDao.getLast(userWxId, robotId, null);
String h5link = wechatLinkPrefix + "/personalCenter/madeProject?planId=" + customPlan.getId() + "&wxId=" + userWxId + "&robotWxId=" + robotId +(last != null && NumberUtil.isNumber(last.getPersonalStageId()) && last.getPersonalStageId() > 0 ? "&personalStageId=" + last.getPersonalStageId() : "");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, UrlUtils.getShortUrl4Own(h5link));
}
return content;
}
......
......@@ -8,6 +8,8 @@ import com.pcloud.book.consumer.content.ResourceConsr;
import com.pcloud.book.consumer.feedback.FeedbackConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.custom.biz.CustomPlanBiz;
import com.pcloud.book.custom.mapper.CustomPlanModuleSuggestionMapper;
import com.pcloud.book.custom.vo.UserBookServiceVO;
import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.guide.biz.PcloudGuideBiz;
import com.pcloud.book.keywords.enums.ReplyTypeEnum;
......@@ -39,6 +41,7 @@ import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateNewUtils;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.NumberUtil;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
......@@ -114,6 +117,10 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
@Autowired
private PersonalAppletsDao personalAppletsDao;
@Autowired
private CustomPlanModuleSuggestionMapper customPlanModuleSuggestionMapper;
@Autowired
private UserReplaceCodeDao userReplaceCodeDao;
......@@ -143,6 +150,12 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
if (JumpTypeEnum.PLAN_TRIGGER.key.equals(vo.getJumpType())){
checkOnlyOnePlanJump(vo.getPersonalStageId(),null);
}
if(JumpTypeEnum.TIME_TRIGGER.key.equals(vo.getJumpType())){
if(!NumberUtil.isNumber(vo.getToStageStartTime())){
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "定时时长不能为空");
}
checkOnlyOneTimeJump(vo.getPersonalStageId(), null);
}
if (vo.getOpenEmail()){
this.checkEmail(vo.getEmails());
}
......@@ -205,6 +218,26 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
}
}
/**
* 定时跳转配置唯一性
* @param personalStageId
* @param personalStageJumpId
*/
private void checkOnlyOneTimeJump(Long personalStageId, Long personalStageJumpId) {
List<PersonalStageJump> stageJumps = personalStageJumpDao.getByJumpType(personalStageId, JumpTypeEnum.TIME_TRIGGER.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
@ParamLog("获取跳转设置列表")
public PageBeanNew getJumpList(Long personalStageId, Integer currentPage, Integer numPerPage) {
......@@ -825,6 +858,104 @@ public class PersonalStageJumpBizImpl implements PersonalStageJumpBiz {
pcloudGuideBiz.stopPcloudGuidePush(robotId, wxId);
}
@ParamLog("设置延迟定时跳转")
public void setDelayTimeJump(TimeJumpNextDTO timeJumpNextDTO){
if (timeJumpNextDTO==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数为空!");
}
if (timeJumpNextDTO.getPersonalStageId()==null){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"阶段id参数为空!");
}
if (StringUtil.isEmpty(timeJumpNextDTO.getRobotWxId())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"机器人id参数为空!");
}
if (StringUtil.isEmpty(timeJumpNextDTO.getWxId())){
throw new BookBizException(BookBizException.PARAM_IS_NULL,"用户id参数为空!");
}
//查询跳转
List<PersonalStageJump> jumps = personalStageJumpDao.getByJumpType(timeJumpNextDTO.getPersonalStageId(), JumpTypeEnum.TIME_TRIGGER.key);
if (ListUtils.isEmpty(jumps)){
LOGGER.info("没有该类型的跳转的阶段,无法设置定时跳转!");
return;
}
PersonalStageJump personalStageJump=jumps.get(0);
Long afterStageId=personalStageJump.getAfterPersonalStageId();
if (afterStageId==null){
LOGGER.info("没有下一阶段,无法设置定时跳转!");
return;
}
Integer toStageStartTime=personalStageJump.getToStageStartTime();
TimeJumpDelayDTO delayDTO = new TimeJumpDelayDTO();
delayDTO.setRobotId(timeJumpNextDTO.getRobotWxId());
delayDTO.setWxId(timeJumpNextDTO.getWxId());
delayDTO.setIp(timeJumpNextDTO.getIp());
delayDTO.setPersonalStageId(timeJumpNextDTO.getPersonalStageId());
delayDTO.setPersonalStageUserId(timeJumpNextDTO.getPersonalStageUserId());
delayDTO.setPersonalStageCreateTime(DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"));
DelayQueueDTO delayQueueDTO = DelayQueueDTO.builder().key(timeJumpNextDTO.getWxId()).type(PersonalStageConstant.PERSONALSTAGE_DELAY_TIME_JUMP).msg(delayDTO).timeout(toStageStartTime*60*1000).build();
delayMessageSender.send(delayQueueDTO);
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("处理延迟定时跳转")
@Override
public void dealDelayTimeJump(DelayQueueDTO dto) {
TimeJumpDelayDTO delayDTO = (TimeJumpDelayDTO) dto.getMsg();
String wxId = delayDTO.getWxId();
String robotId = delayDTO.getRobotId();
Long personalStageId = delayDTO.getPersonalStageId();
PersonalStageUser last = personalStageUserDao.getLast(wxId, robotId, personalStageId);
if (last==null){
LOGGER.info("用户无阶段,无法进行定时跳转!");
return;
}
if (!last.getPersonalStageId().equals(personalStageId)){
LOGGER.info("用户已不在当前阶段,无法进行定时跳转!");
return;
}
//查询跳转
List<PersonalStageJump> jumps = personalStageJumpDao.getByJumpType(personalStageId, JumpTypeEnum.TIME_TRIGGER.key);
if (ListUtils.isEmpty(jumps)){
LOGGER.info("没有该类型的跳转的阶段,无法进行定时跳转!");
return;
}
PersonalStageJump personalStageJump=jumps.get(0);
Long afterStageId=personalStageJump.getAfterPersonalStageId();
Long stageJumpId=personalStageJump.getId();
if (afterStageId==null){
LOGGER.info("没有下一阶段,无法进行定时跳转!");
return;
}
// 查询用户最后一次输入书名对应的权益(方案)
// 查询用户最近搜索的书
UserReplaceCode lastOneUserReplace = userReplaceCodeDao.getLastOneUserReplace(wxId, robotId, 1);
if (lastOneUserReplace == null){
LOGGER.info("未找到用户输入的书名,无法进行跳转");
return;
}
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());
//处理需求单记录
dealPaperRecord(personalStageId,afterStageId,wxId, robotId);
// 将用户置为下个阶段
PersonalStageUser nextPersonalStageUser = personalStageBiz.nextStageAddStageUserAndWakeupDelay(robotId, wxId, ip, afterStageId);
// 发送内容衔接语
sendJumpLinkups(wxId, robotId, ip, stageJumpId, nextPersonalStageUser.getId());
// 停止发送引导语
pcloudGuideBiz.stopPcloudGuidePush(robotId, wxId);
}
@ParamLog("发送阶段跳转邮件")
private void sendEmail(String userWxId, String robotWxId, String content, PersonalStageJumpKeywordDto jumpKeywordDto) {
try {
......
......@@ -10,6 +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 PERSONALSTAGE_DELAY_TIME_JUMP="PERSONALSTAGE_DELAY_TIME_JUMP";
// 进度模板字符串
public static final String PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE = "${PROGRESS_URL}";
public static final String PERSONAL_STAGE_PROJECT_PROGRESS_TEMPLATE_1 = "${PROGRESS_URL_1}";
......@@ -40,6 +43,11 @@ public class PersonalStageConstant {
public static final String BOOK_SEARCH = "${BOOK_SEARCH}";
/**
* 方案权益
*/
public static final String PLAN_RIGHTS = "${PLAN_RIGHTS}";
/**
* 跳转之前的最后一次非关键词
*/
public static final String LAST_NOT_KEYWORD_CONTENT_BEFORE_JUMP_STAGE_CACHE = "BOOK:LAST_NOT_KEYWORD_CONTENT_BEFORE_JUMP_STAGE_CACHE";
......
......@@ -12,4 +12,6 @@ public interface UserReplaceCodeDao extends BaseDao<UserReplaceCode> {
List<String> getUserReplaceRecordByCodeId(String wxId, String robotId, Long codeId);
UserReplaceCode getLastUserReplaceByCodeId(String wxId, String robotId, Long replaceCodeId);
UserReplaceCode getLastOneUserReplace(String wxId, String robotId, Integer replaceCodeId);
}
\ No newline at end of file
......@@ -37,4 +37,14 @@ public class UserReplaceCodeDaoImpl extends BaseDaoImpl<UserReplaceCode> impleme
map.put("replaceCodeId",replaceCodeId);
return super.getSqlSession().selectOne(getStatement("getLastUserReplaceByCodeId"),map);
}
@Override
public UserReplaceCode getLastOneUserReplace(String wxId, String robotId, Integer replaceCodeId) {
Map<String,Object> map=new HashMap<>();
map.put("wxId",wxId);
map.put("robotId",robotId);
map.put("replaceCodeId",replaceCodeId);
return super.getSqlSession().selectOne(getStatement("getLastOneUserReplace"),map);
}
}
......@@ -43,6 +43,9 @@ public class PersonalStageJumpDto implements Serializable {
@ApiModelProperty("定制化阶段名称")
private String personalStageName;
@ApiModelProperty("距离阶段开始时间")
private Integer toStageStartTime;
@ApiModelProperty("跳转关键词文案列表")
private List<PersonalStageJumpKeyword> jumpKeywords;
......
package com.pcloud.book.personalstage.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("定时跳转延时dto")
public class TimeJumpDelayDTO implements Serializable {
@ApiModelProperty("定制化阶段id")
private Long personalStageId;
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("用户wxId")
private String wxId;
@ApiModelProperty("ip地址")
private String ip;
@ApiModelProperty("用户阶段记录id")
private Long personalStageUserId;
@ApiModelProperty("用户阶段创建时间")
private String personalStageCreateTime;
}
package com.pcloud.book.personalstage.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class TimeJumpNextDTO implements Serializable {
@ApiModelProperty("机器人id")
private String robotWxId;
@ApiModelProperty("微信Id")
private String wxId;
@ApiModelProperty("阶段id")
private Long personalStageId;
private Long personalStageUserId;
private String ip;
}
......@@ -27,5 +27,7 @@ public class PersonalStageJump extends BaseEntity {
@ApiModelProperty("转账金额")
private Double transferMoney;
@ApiModelProperty("距离阶段开始时间")
private Integer toStageStartTime;
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ public enum JumpTypeEnum {
PAPER_TRIGGER(4, "需求定制单触发"),
END_SERVICE(5,"人工客服结束触发"),
PLAN_TRIGGER(6,"方案定制单触发"),
TIME_TRIGGER(7,"定时跳转"),
ZERO_BOOK(8,"0级书跳转"),
NO_ZERO_BOOK(9,"非0级书跳转");
......
......@@ -331,4 +331,14 @@ public class PersonalStageFacade {
return new ResponseDto<>(personalStageBiz.getUserReplaceMap4CustomerService(wxId,robotId));
}
@ApiOperation("replaceProjectProgressUrl")
@GetMapping("replaceProjectProgressUrl")
public ResponseDto<?> replaceProjectProgressUrl(
@RequestParam("content") @ApiParam("content") String content,
@RequestParam("userWxId") @ApiParam("用户id") String userWxId,
@RequestParam("personalStageUserId") @ApiParam("personalStageUserId") Long personalStageUserId,
@RequestParam("ip") @ApiParam("用户id") String ip,
@RequestParam("robotId") @ApiParam("机器人id") String robotId){
return new ResponseDto<>(personalStageBiz.replaceProjectProgressUrl(content,robotId,userWxId,personalStageUserId,ip));
}
}
......@@ -5,6 +5,7 @@ import com.pcloud.book.personalstage.entity.PersonalStageJumpKeyword;
import com.pcloud.book.personalstage.entity.PersonalStageJumpLinkup;
import com.pcloud.common.entity.BaseRequestVO;
import com.pcloud.common.utils.ListUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
......@@ -30,6 +31,9 @@ public abstract class BaseStageJumpRequestVO extends BaseRequestVO {
private Double transferMoney;
@ApiModelProperty("距离阶段开始时间")
private Integer toStageStartTime;
@NotNull(message = "跳转关键词不能为空")
@Size(max = 5, message = "跳转关键词不能超过5个")
private List<String> keywords;
......
......@@ -2176,4 +2176,10 @@
ORDER BY
A.LAST_MODIFIED_DATE DESC
</select>
<select id="getBookIdsByIsbn" parameterType="map" resultType="long">
select DISTINCT book_id
from BOOK
where isbn like concat('%', #{isbn},'%')
</select>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.custom.mapper.CustomPlanMapper" >
<resultMap id="BaseResultMap" type="CustomPlan" >
<resultMap id="BaseResultMap" type="com.pcloud.book.custom.entity.CustomPlan" >
<id column="id" jdbcType="INTEGER" property="id" />
<result column="plan_number" jdbcType="VARCHAR" property="planNumber" />
<result column="plan_name" jdbcType="VARCHAR" property="planName" />
......@@ -20,12 +20,16 @@
<result column="suggestion_count" jdbcType="INTEGER" property="suggestionCount" />
<result column="confirm_feedback_reply" jdbcType="VARCHAR" property="confirmFeedbackReply" />
<result column="robot_type" jdbcType="TINYINT" property="robotType" />
<result column="book_id" jdbcType="BIGINT" property="bookId" />
<result column="read_type" jdbcType="INTEGER" property="readType" />
<result column="rights_pic" jdbcType="VARCHAR" property="rightsPic" />
<result column="button_name" jdbcType="VARCHAR" property="buttonName" />
</resultMap>
<sql id="Base_Column_List">
id, plan_number, plan_name, create_user_name, description, open_feedback, paper_id,
paper_title, paper_desc, use_state, pdf_url, h5_url, preview_qrcode_url, create_time,
update_time, confirm_feedback_reply,robot_type
update_time, confirm_feedback_reply,robot_type,book_id,read_type,rights_pic,button_name
</sql>
<insert id="insert" parameterType="CustomPlan" useGeneratedKeys="true" keyProperty="id">
......@@ -33,12 +37,13 @@
description, open_feedback, paper_id,
paper_title, paper_desc, use_state,
pdf_url, h5_url, preview_qrcode_url,
create_time, update_time, confirm_feedback_reply,robot_type)
create_time, update_time, confirm_feedback_reply,robot_type,
book_id,read_type,rights_pic,button_name)
values (#{planNumber,jdbcType=VARCHAR}, #{planName,jdbcType=VARCHAR}, #{createUserName,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{openFeedback,jdbcType=INTEGER}, #{paperId,jdbcType=INTEGER},
#{paperTitle,jdbcType=VARCHAR}, #{paperDesc,jdbcType=VARCHAR}, #{useState,jdbcType=INTEGER},
#{pdfUrl,jdbcType=VARCHAR}, #{h5Url,jdbcType=VARCHAR}, #{previewQrcodeUrl,jdbcType=VARCHAR},
NOW(), NOW(), #{confirmFeedbackReply},#{robotType})
NOW(), NOW(), #{confirmFeedbackReply},#{robotType},#{bookId},#{readType},#{rightsPic},#{buttonName})
</insert>
<update id="update" parameterType="CustomPlan">
......@@ -83,6 +88,18 @@
<if test="robotType != null">
robot_type = #{robotType},
</if>
<if test="bookId != null">
book_id = #{bookId},
</if>
<if test="readType != null">
read_type = #{readType},
</if>
<if test="rightsPic != null">
rights_pic = #{rightsPic},
</if>
<if test="buttonName != null">
button_name = #{buttonName},
</if>
update_time = NOW(),confirm_feedback_reply = #{confirmFeedbackReply}
</set>
where id = #{id,jdbcType=INTEGER}
......@@ -129,11 +146,10 @@
select
a.id, plan_number, plan_name, create_user_name, description, a.open_feedback,
use_state, pdf_url, h5_url, preview_qrcode_url, a.create_time, COUNT(DISTINCT b.batch_id) suggestion_count,
a.robot_type,t.classify_name robotTypeName, m.read_type readType
a.robot_type,t.classify_name robotTypeName, a.read_type,a.book_id ,a.rights_pic ,a.button_name
from custom_plan a left join custom_plan_module_suggestion b
on a.id = b.plan_id
left join pcloud_robot_classify t on a.robot_type = t.id
LEFT JOIN custom_plan_module m ON a.id=m.plan_id AND m.module_type=6
where 1= 1
<if test="content != null">
and (plan_number like concat('%', #{content}, '%')
......@@ -204,4 +220,25 @@
update custom_plan set pdf_url =#{pdfUrl}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getPlanReadTypesByBookId" parameterType="long" resultType="com.pcloud.book.custom.dto.PlanReadTypeDto">
select
id customPlanId,
read_type readType
from custom_plan
where book_id = #{bookId}
</select>
<select id="getLastCustomPlan" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from custom_plan
where read_type = #{readType}
AND book_id IN
<foreach collection="bookIds" item="item" separator="," open="(" close=")">
${item}
</foreach>
ORDER BY id DESC
LIMIT 1
</select>
</mapper>
\ No newline at end of file
......@@ -11,10 +11,11 @@
<result property="transferMessage" column="transfer_message" jdbcType="VARCHAR"/>
<result property="transferMoney" column="transfer_money" jdbcType="DOUBLE"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="toStageStartTime" column="to_stage_start_time" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, personal_stage_id, jump_type, after_personal_stage_id, open_email, transfer_message, transfer_money, create_time
id, personal_stage_id, jump_type, after_personal_stage_id, open_email, transfer_message, transfer_money, create_time, to_stage_start_time
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -29,6 +30,7 @@
a.id,
a.personal_stage_id personalStageId,
a.jump_type jumpType,
a.to_stage_start_time toStageStartTime,
a.after_personal_stage_id afterPersonalStageId,
a.open_email openEmail,
a.transfer_message transferMessage,
......@@ -43,6 +45,7 @@
a.id,
a.personal_stage_id personalStageId,
a.jump_type jumpType,
a.to_stage_start_time toStageStartTime,
a.after_personal_stage_id afterPersonalStageId,
a.open_email openEmail,
a.transfer_message transferMessage,
......@@ -66,7 +69,8 @@
open_email,
transfer_message,
transfer_money,
create_time
create_time,
to_stage_start_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{personalStageId,jdbcType=BIGINT},
......@@ -75,7 +79,8 @@
#{openEmail,jdbcType=BOOLEAN},
#{transferMessage,jdbcType=VARCHAR},
#{transferMoney,jdbcType=DOUBLE},
NOW()
NOW(),
#{toStageStartTime,jdbcType=INTEGER}
</trim>
</insert>
......@@ -105,6 +110,9 @@
<if test="transferMoney != null">
transfer_money = #{transferMoney},
</if>
<if test="toStageStartTime != null">
to_stage_start_time = #{toStageStartTime},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......
......@@ -96,4 +96,16 @@
limit 1
</select>
<select id="getLastOneUserReplace" 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>
\ 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