Commit 9ff5e365 by 裴大威

Merge branch 'feat-1002732' into 'master'

1002732 小睿1.1根据书刊名称展示权益页,确定权益与方案内容后自动订阅服务推送计划

See merge request rays/pcloud-book!623
parents f4953546 a5bd8143
...@@ -14,4 +14,8 @@ public interface CustomTimeControlBiz { ...@@ -14,4 +14,8 @@ public interface CustomTimeControlBiz {
CustomTimeControlDTO getCustomTimeControlById(Integer id); CustomTimeControlDTO getCustomTimeControlById(Integer id);
void deleteCustomTimeControlById(Integer id); void deleteCustomTimeControlById(Integer id);
void subCustomTimeControlById(Integer id,String wxUserId,String robotWxId);
Boolean getUserSub(Integer customTimeControlId, String wxUserId);
} }
...@@ -14,6 +14,8 @@ import com.pcloud.book.consumer.feedback.FeedbackConsr; ...@@ -14,6 +14,8 @@ import com.pcloud.book.consumer.feedback.FeedbackConsr;
import com.pcloud.book.consumer.shareimage.ShareImageConsr; import com.pcloud.book.consumer.shareimage.ShareImageConsr;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr; import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.custom.biz.CustomPlanBiz; import com.pcloud.book.custom.biz.CustomPlanBiz;
import com.pcloud.book.custom.dao.CustomTimeControlDao;
import com.pcloud.book.custom.dto.CustomTimeControlDTO;
import com.pcloud.book.custom.dto.PlanReadTypeDto; import com.pcloud.book.custom.dto.PlanReadTypeDto;
import com.pcloud.book.custom.entity.CustomPlan; import com.pcloud.book.custom.entity.CustomPlan;
import com.pcloud.book.custom.entity.CustomPlanModule; import com.pcloud.book.custom.entity.CustomPlanModule;
...@@ -38,6 +40,8 @@ import com.pcloud.book.group.biz.WeixinQrcodeBiz; ...@@ -38,6 +40,8 @@ import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.group.tools.Kit; import com.pcloud.book.group.tools.Kit;
import com.pcloud.book.group.tools.SendWeixinRequestTools; import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.pcloudkeyword.enums.PcloudGroupRobotTypeEnum; import com.pcloud.book.pcloudkeyword.enums.PcloudGroupRobotTypeEnum;
import com.pcloud.book.timecontrol.entity.TimeControlTask;
import com.pcloud.book.timecontrol.mapper.TimeControlTaskMapper;
import com.pcloud.book.util.common.ThreadPoolUtils; import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto; import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
...@@ -101,6 +105,10 @@ public class CustomPlanBizImpl implements CustomPlanBiz { ...@@ -101,6 +105,10 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
private BookBiz bookBiz; private BookBiz bookBiz;
@Autowired @Autowired
private ErpConsr erpConsr; private ErpConsr erpConsr;
@Autowired
private CustomTimeControlDao customTimeControlDao;
@Autowired
private TimeControlTaskMapper timeControlTaskMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
...@@ -149,6 +157,16 @@ public class CustomPlanBizImpl implements CustomPlanBiz { ...@@ -149,6 +157,16 @@ public class CustomPlanBizImpl implements CustomPlanBiz {
if(MapUtils.isNotEmpty(bookNames) && bookNames.containsKey(customPlan.getBookId())) if(MapUtils.isNotEmpty(bookNames) && bookNames.containsKey(customPlan.getBookId()))
customPlan.setBookName(bookNames.get(customPlan.getBookId())); customPlan.setBookName(bookNames.get(customPlan.getBookId()));
} }
if (null!=customPlan.getCustomTimeControlId()){
CustomTimeControlDTO control = customTimeControlDao.getCustomTimeControlById(customPlan.getCustomTimeControlId());
if (control!=null){
TimeControlTask timeControlTask = timeControlTaskMapper.selectByPrimaryKey(control.getTimeControlTaskId());
if (customPlan!=null){
customPlan.setTaskName(timeControlTask.getTaskName());
}
}
}
return customPlan; return customPlan;
} }
......
...@@ -66,4 +66,10 @@ public class CustomPlan { ...@@ -66,4 +66,10 @@ public class CustomPlan {
@ApiModelProperty("书籍名称") @ApiModelProperty("书籍名称")
private String bookName; private String bookName;
@ApiModelProperty("读书计划id")
private Integer customTimeControlId;
@ApiModelProperty("计划名称")
private String taskName;
} }
\ No newline at end of file
package com.pcloud.book.custom.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ApiModel("读书计划用户订阅表")
@Data
public class CustomTimeControlUser extends BaseEntity {
@ApiModelProperty("读书计划id")
private Integer customTimeControlId;
@ApiModelProperty("机器人id")
private String robotId;
@ApiModelProperty("用户微信id")
private String wxId;
}
...@@ -6,6 +6,7 @@ import com.pcloud.book.custom.dto.CustomTimeControlPageDTO; ...@@ -6,6 +6,7 @@ import com.pcloud.book.custom.dto.CustomTimeControlPageDTO;
import com.pcloud.common.dto.ResponseDto; import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew; import com.pcloud.common.page.PageBeanNew;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -53,4 +54,24 @@ public class CustomTimeControlFacade { ...@@ -53,4 +54,24 @@ public class CustomTimeControlFacade {
return new ResponseDto<>(); return new ResponseDto<>();
} }
@ApiOperation("订阅读书计划")
@GetMapping("subCustomTimeControlById")
ResponseDto<?> getCustomTimeControlById(
@RequestParam("id") Integer id,
@RequestParam("wxUserId") String wxUserId,
@RequestParam("robotWxId") String robotWxId
){
customTimeControlBiz.subCustomTimeControlById(id,wxUserId,robotWxId);
return new ResponseDto<>();
}
@ApiOperation("获取用户是否订阅过读书计划")
@GetMapping("getUserSub")
ResponseDto<?> getUserSub(
@RequestParam("customTimeControlId") Integer customTimeControlId,
@RequestParam("wxUserId") String wxUserId
){
return new ResponseDto<>(customTimeControlBiz.getUserSub(customTimeControlId,wxUserId));
}
} }
...@@ -37,4 +37,6 @@ public interface CustomPlanMapper { ...@@ -37,4 +37,6 @@ public interface CustomPlanMapper {
List<PlanReadTypeDto> getPlanReadTypesByBookId(@Param("bookId") Long bookId); List<PlanReadTypeDto> getPlanReadTypesByBookId(@Param("bookId") Long bookId);
CustomPlan getLastCustomPlan(@Param("bookIds") List<Long> bookIds,@Param("readType") Integer readType); CustomPlan getLastCustomPlan(@Param("bookIds") List<Long> bookIds,@Param("readType") Integer readType);
CustomPlan getLastCustomPlanByBookIds(@Param("bookIds") List<Long> bookIds);
} }
\ No newline at end of file
...@@ -24,4 +24,6 @@ public interface CustomTimeControlReplyMapper { ...@@ -24,4 +24,6 @@ public interface CustomTimeControlReplyMapper {
void batchInsert(List<CustomTimeControlReply> customTimeControlReplies); void batchInsert(List<CustomTimeControlReply> customTimeControlReplies);
void deleteByCustomTimeControlId(Integer id); void deleteByCustomTimeControlId(Integer id);
List<CustomTimeControlReply> getSubscribeReplyList(Integer customTimeControlId);
} }
\ No newline at end of file
package com.pcloud.book.custom.mapper;
import com.pcloud.book.custom.entity.CustomTimeControlUser;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@Component
public interface CustomTimeControlUserMapper {
int deleteByPrimaryKey(Long id);
int insert(CustomTimeControlUser record);
CustomTimeControlUser selectByPrimaryKey(Long id);
CustomTimeControlUser getByWxIdAndControlId(@Param("wxId") String wxId, @Param("customTimeControlId") Integer customTimeControlId);
}
\ No newline at end of file
...@@ -934,9 +934,8 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -934,9 +934,8 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
if(content.indexOf(PersonalStageConstant.PLAN_RIGHTS) > -1) { if(content.indexOf(PersonalStageConstant.PLAN_RIGHTS) > -1) {
// 查询用户最近搜索的书 // 查询用户最近搜索的书
UserReplaceCode userReplaceCodeBookName = userReplaceCodeDao.getLastOneUserReplace(userWxId, robotId, 1); UserReplaceCode userReplaceCodeBookName = userReplaceCodeDao.getLastOneUserReplace(userWxId, robotId, 1);
UserReplaceCode userReplaceCodeReadType = userReplaceCodeDao.getLastOneUserReplace(userWxId, robotId, 2); if (userReplaceCodeBookName == null) {
if (userReplaceCodeBookName == null || userReplaceCodeReadType == null) { LOGGER.info("未找到用户输入的书名,无法进行跳转");
LOGGER.info("未找到用户输入的书名或阅读类型,无法进行跳转");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, ""); return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
} }
String bookName = userReplaceCodeBookName.getContent(); String bookName = userReplaceCodeBookName.getContent();
...@@ -944,24 +943,13 @@ public class PersonalStageBizImpl implements PersonalStageBiz { ...@@ -944,24 +943,13 @@ public class PersonalStageBizImpl implements PersonalStageBiz {
LOGGER.info("图书名称为空,无法替换链接"); LOGGER.info("图书名称为空,无法替换链接");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, ""); 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); List<Long> bookIds = erpConsr.getIdByBookName(bookName);
if(ListUtils.isEmpty(bookIds)){ if(ListUtils.isEmpty(bookIds)){
LOGGER.info("在ERP中未找到对应的书,无法替换链接"); LOGGER.info("在ERP中未找到对应的书,无法替换链接");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, ""); return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
} }
CustomPlan customPlan = customPlanMapper.getLastCustomPlan(bookIds, readType); CustomPlan customPlan = customPlanMapper.getLastCustomPlanByBookIds(bookIds);
if (customPlan == null) { if (customPlan == null) {
LOGGER.info("未找到对应的权益,无法替换链接"); LOGGER.info("未找到对应的权益,无法替换链接");
return content.replace(PersonalStageConstant.PLAN_RIGHTS, ""); return content.replace(PersonalStageConstant.PLAN_RIGHTS, "");
......
...@@ -33,4 +33,9 @@ public interface TaskSubscribeBiz { ...@@ -33,4 +33,9 @@ public interface TaskSubscribeBiz {
void sendTimeTaskMessage(); void sendTimeTaskMessage();
TimeControlTaskSubscribe getSubscribeState(String wxUserId, Integer taskId); TimeControlTaskSubscribe getSubscribeState(String wxUserId, Integer taskId);
/**
* 时间管理订阅
*/
void subscribeTimeControlTask(String wxUserId, Long bookId, Integer taskId, String robotWxId);
} }
...@@ -457,6 +457,54 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz { ...@@ -457,6 +457,54 @@ public class TaskSubscribeBizImpl implements TaskSubscribeBiz {
return timeControlTaskSubscribe; return timeControlTaskSubscribe;
} }
@ParamLog("时间管理订阅")
@Override
public void subscribeTimeControlTask(String wxUserId, Long bookId, Integer taskId, String robotWxId) {
TimeControlTask timeControlTask = taskMapper.selectByPrimaryKey(taskId);
if (null == timeControlTask) {
return;
}
TimeControlTaskSubscribe taskSubscribe = taskSubscribeMapper.getSubscribe(wxUserId, bookId, taskId);
if (null != taskSubscribe) {
if (TaskSubscribeStateEnum.FINISH.getState().equals(taskSubscribe.getState())) {
LOGGER.info("任务已完成,直接返回");
return;
} else if (TaskSubscribeStateEnum.SUBSCRIBE.getState().equals(taskSubscribe.getState())) {
LOGGER.info("任务已订阅,直接返回");
return;
} else {
//1.改状态
taskSubscribeMapper.subscribeTaskExist(taskSubscribe);
}
} else {
taskSubscribe = new TimeControlTaskSubscribe();
taskSubscribe.setWxUserId(wxUserId);
taskSubscribe.setBookId(bookId);
taskSubscribe.setTaskId(taskId);
taskSubscribe.setState(TaskSubscribeStateEnum.SUBSCRIBE.getState());
taskSubscribe.setRobotWxId(robotWxId);
taskSubscribeMapper.subscribeTask(taskSubscribe);
}
//插入待发送记录
List<ReplyMessageBaseDto> dayList = taskItemMapper.listTaskItemDay(taskId);
List<TimeControlTaskSend> taskSendList = new ArrayList<>();
if (!ListUtils.isEmpty(dayList)) {
for (ReplyMessageBaseDto item : dayList) {
TimeControlTaskSend taskSend = new TimeControlTaskSend();
taskSend.setWxUserId(wxUserId);
taskSend.setBookId(bookId);
taskSend.setTaskId(taskId);
taskSend.setSubscribeId(taskSubscribe.getId());
taskSend.setSendState(TaskSendStateEnum.WAIT_SEND.state);
taskSend.setTaskItemId(item.getId());
taskSend.setSendDay(DateUtils.getShortDateStr(DateUtils.addDay(new Date(), item.getStartDay())));
taskSend.setSendHour(item.getSendHour());
taskSendList.add(taskSend);
}
timeControlTaskSendMapper.batchInsert(taskSendList);
}
}
private String splitUrl(AccountSettingDto accountSettingDto, String url) { private String splitUrl(AccountSettingDto accountSettingDto, String url) {
String protocol = accountSettingDto.getProtocol(); String protocol = accountSettingDto.getProtocol();
if (StringUtils.isEmpty(protocol)) { if (StringUtils.isEmpty(protocol)) {
......
...@@ -39,9 +39,4 @@ public class ThreadPoolUtils { ...@@ -39,9 +39,4 @@ public class ThreadPoolUtils {
public static final ExecutorService SIGN_OUT_THREAD_POOL = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.SECONDS, public static final ExecutorService SIGN_OUT_THREAD_POOL = new ThreadPoolExecutor(5, 5, 0L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("sign-out-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy()); new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("sign-out-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
/**
* 其他线程池
*/
public static final ExecutorService OTHER_POOL = new ThreadPoolExecutor(8, 8, 0L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setNameFormat("other-pool-%d").build(), new ThreadPoolExecutor.CallerRunsPolicy());
} }
...@@ -24,12 +24,14 @@ ...@@ -24,12 +24,14 @@
<result column="read_type" jdbcType="INTEGER" property="readType" /> <result column="read_type" jdbcType="INTEGER" property="readType" />
<result column="rights_pic" jdbcType="VARCHAR" property="rightsPic" /> <result column="rights_pic" jdbcType="VARCHAR" property="rightsPic" />
<result column="button_name" jdbcType="VARCHAR" property="buttonName" /> <result column="button_name" jdbcType="VARCHAR" property="buttonName" />
<result column="custom_time_control_id" jdbcType="INTEGER" property="customTimeControlId" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, plan_number, plan_name, create_user_name, description, open_feedback, paper_id, 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, paper_title, paper_desc, use_state, pdf_url, h5_url, preview_qrcode_url, create_time,
update_time, confirm_feedback_reply,robot_type,book_id,read_type,rights_pic,button_name update_time, confirm_feedback_reply,robot_type,book_id,read_type,rights_pic,button_name,
custom_time_control_id
</sql> </sql>
<insert id="insert" parameterType="CustomPlan" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="CustomPlan" useGeneratedKeys="true" keyProperty="id">
...@@ -38,12 +40,12 @@ ...@@ -38,12 +40,12 @@
paper_title, paper_desc, use_state, paper_title, paper_desc, use_state,
pdf_url, h5_url, preview_qrcode_url, 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) book_id,read_type,rights_pic,button_name,custom_time_control_id)
values (#{planNumber,jdbcType=VARCHAR}, #{planName,jdbcType=VARCHAR}, #{createUserName,jdbcType=VARCHAR}, values (#{planNumber,jdbcType=VARCHAR}, #{planName,jdbcType=VARCHAR}, #{createUserName,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{openFeedback,jdbcType=INTEGER}, #{paperId,jdbcType=INTEGER}, #{description,jdbcType=VARCHAR}, #{openFeedback,jdbcType=INTEGER}, #{paperId,jdbcType=INTEGER},
#{paperTitle,jdbcType=VARCHAR}, #{paperDesc,jdbcType=VARCHAR}, #{useState,jdbcType=INTEGER}, #{paperTitle,jdbcType=VARCHAR}, #{paperDesc,jdbcType=VARCHAR}, #{useState,jdbcType=INTEGER},
#{pdfUrl,jdbcType=VARCHAR}, #{h5Url,jdbcType=VARCHAR}, #{previewQrcodeUrl,jdbcType=VARCHAR}, #{pdfUrl,jdbcType=VARCHAR}, #{h5Url,jdbcType=VARCHAR}, #{previewQrcodeUrl,jdbcType=VARCHAR},
NOW(), NOW(), #{confirmFeedbackReply},#{robotType},#{bookId},#{readType},#{rightsPic},#{buttonName}) NOW(), NOW(), #{confirmFeedbackReply},#{robotType},#{bookId},#{readType},#{rightsPic},#{buttonName},#{customTimeControlId})
</insert> </insert>
<update id="update" parameterType="CustomPlan"> <update id="update" parameterType="CustomPlan">
...@@ -100,6 +102,9 @@ ...@@ -100,6 +102,9 @@
<if test="buttonName != null"> <if test="buttonName != null">
button_name = #{buttonName}, button_name = #{buttonName},
</if> </if>
<if test="customTimeControlId != null">
custom_time_control_id = #{customTimeControlId},
</if>
update_time = NOW(),confirm_feedback_reply = #{confirmFeedbackReply} update_time = NOW(),confirm_feedback_reply = #{confirmFeedbackReply}
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
...@@ -241,4 +246,16 @@ ...@@ -241,4 +246,16 @@
ORDER BY id DESC ORDER BY id DESC
LIMIT 1 LIMIT 1
</select> </select>
<select id="getLastCustomPlanByBookIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from custom_plan
where book_id IN
<foreach collection="bookIds" item="item" separator="," open="(" close=")">
${item}
</foreach>
ORDER BY id DESC
LIMIT 1
</select>
</mapper> </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.CustomTimeControlUserMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.custom.entity.CustomTimeControlUser" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="custom_time_control_id" property="customTimeControlId" jdbcType="INTEGER" />
<result column="robot_id" property="robotId" jdbcType="VARCHAR" />
<result column="wx_id" property="wxId" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, custom_time_control_id, robot_id, wx_id, create_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from custom_time_control_user
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from custom_time_control_user
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pcloud.book.custom.entity.CustomTimeControlUser" >
insert into custom_time_control_user (
id, custom_time_control_id, robot_id, wx_id, create_time
)
values (#{id,jdbcType=BIGINT}, #{customTimeControlId,jdbcType=INTEGER}, #{robotId,jdbcType=VARCHAR},
#{wxId,jdbcType=VARCHAR}, now()
)
</insert>
<select id="getByWxIdAndControlId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from custom_time_control_user
where wx_id = #{wxId}
and custom_time_control_id = #{customTimeControlId}
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