Commit dfee59f3 by 章春雨

Merge branch 'feat-1002422' into 'master'

1002422小睿定制化方案与内容(平台端设置与客户端展示)

See merge request rays/pcloud-book!469
parents 5fac8580 05a79f8e
...@@ -42,4 +42,6 @@ public class CreateTaskItemDto implements Serializable { ...@@ -42,4 +42,6 @@ public class CreateTaskItemDto implements Serializable {
private Integer progressGuidance; private Integer progressGuidance;
private String itemIntroduce;
} }
package com.pcloud.book.timecontrol.dto;
import lombok.Data;
@Data
public class SelfPlanUserDto {
private String wxUserId;
private String nickName;
private String headPic;
private Integer sex;
private Integer slefPlanCount;
private Integer orderCount;
}
...@@ -43,4 +43,6 @@ public class UpdateTaskItemDto implements Serializable { ...@@ -43,4 +43,6 @@ public class UpdateTaskItemDto implements Serializable {
private Integer progressGuidance; private Integer progressGuidance;
private String itemIntroduce;
} }
package com.pcloud.book.timecontrol.enums;
public enum ServiceStateEnum {
DEFAULT(0, "默认状态"),
FINISH_BUY(1, "购买完成"),
FINISH_SUBSCRIBE(2, "订阅完成");
private Integer value;
private String code;
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
ServiceStateEnum(Integer value, String code) {
this.value = value;
this.code = code;
}
ServiceStateEnum() {
}
}
...@@ -7,7 +7,6 @@ import com.pcloud.common.core.constant.MQTopicProducer; ...@@ -7,7 +7,6 @@ import com.pcloud.common.core.constant.MQTopicProducer;
import com.pcloud.common.core.mq.MQExchangeConstants; import com.pcloud.common.core.mq.MQExchangeConstants;
import com.pcloud.common.core.mq.MQQueueConstants; import com.pcloud.common.core.mq.MQQueueConstants;
import com.pcloud.common.core.mq.RabbitMQFactory; import com.pcloud.common.core.mq.RabbitMQFactory;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder; import org.springframework.amqp.core.BindingBuilder;
...@@ -22,13 +21,6 @@ import org.springframework.context.annotation.Bean; ...@@ -22,13 +21,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
...@@ -37,6 +29,11 @@ import springfox.documentation.spi.DocumentationType; ...@@ -37,6 +29,11 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2; import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@SpringBootApplication @SpringBootApplication
@ComponentScan("com.pcloud") @ComponentScan("com.pcloud")
@EnableEurekaClient @EnableEurekaClient
...@@ -294,4 +291,14 @@ public class BookApplication { ...@@ -294,4 +291,14 @@ public class BookApplication {
public Binding selfRobotSendTextBind() { public Binding selfRobotSendTextBind() {
return RabbitMQFactory.bindingExchange(selfRobotSendTextQueue(),MQTopicProducer.SELF_ROBOT_SEND_TEXT); return RabbitMQFactory.bindingExchange(selfRobotSendTextQueue(),MQTopicProducer.SELF_ROBOT_SEND_TEXT);
} }
@Bean
public Queue tipQueue() {
return RabbitMQFactory.queueBuilder(MQTopicConumer.TIP_FOR_WECHAT_USER);
}
@Bean
public Binding tipBind() {
return RabbitMQFactory.bindingExchange(tipQueue(), MQTopicProducer.TIP_FOR_WECHAT_USER);
}
} }
...@@ -34,6 +34,7 @@ import com.pcloud.book.keywords.dao.BookKeywordDao; ...@@ -34,6 +34,7 @@ import com.pcloud.book.keywords.dao.BookKeywordDao;
import com.pcloud.book.keywords.dto.KeywordResourceDTO; import com.pcloud.book.keywords.dto.KeywordResourceDTO;
import com.pcloud.book.keywords.enums.ReplyTypeEnum; import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.keywords.vo.ListKeywordVO; import com.pcloud.book.keywords.vo.ListKeywordVO;
import com.pcloud.book.timecontrol.dto.SelfPlanUserDto;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.MQTopicProducer; import com.pcloud.common.core.constant.MQTopicProducer;
import com.pcloud.common.enums.AppTypeEnum; import com.pcloud.common.enums.AppTypeEnum;
...@@ -816,4 +817,33 @@ public class GroupSet { ...@@ -816,4 +817,33 @@ public class GroupSet {
} }
return userBookInfoVOS; return userBookInfoVOS;
} }
public List<SelfPlanUserDto> setUserInfo4SelfPlan4XIAORUI(List<String> wechatUserIds, Map<String, SelfPlanUserDto> selfPlanUserDtoMap) {
List<SelfPlanUserDto> selfPlanUserDtos = new ArrayList<>();
if (!ListUtils.isEmpty(wechatUserIds)){
Map<String, GroupUserDTO> userDTOMap = wechatGroupConsr.mapWxUserInfoByWxIdList(wechatUserIds);
List<Long> labelIds = new ArrayList<>();
for (String wechatUserId : wechatUserIds) {
//用户信息
if (!MapUtils.isEmpty(userDTOMap) && userDTOMap.containsKey(wechatUserId)) {
SelfPlanUserDto selfPlanUserDto = new SelfPlanUserDto();
GroupUserDTO userDTO = userDTOMap.get(wechatUserId);
selfPlanUserDto.setHeadPic(userDTO.getHeadPic());
selfPlanUserDto.setWxUserId(wechatUserId);
selfPlanUserDto.setNickName(userDTO.getNickName());
selfPlanUserDto.setSex(userDTO.getSex());
if (MapUtils.isEmpty(selfPlanUserDtoMap) && selfPlanUserDtoMap.containsKey(wechatUserId) &&
null != selfPlanUserDtoMap.get(wechatUserId)){
selfPlanUserDto.setSlefPlanCount(selfPlanUserDtoMap.get(wechatUserId).getSlefPlanCount());
selfPlanUserDto.setOrderCount(selfPlanUserDtoMap.get(wechatUserId).getOrderCount());
}else {
selfPlanUserDto.setSlefPlanCount(0);
selfPlanUserDto.setOrderCount(0);
}
selfPlanUserDtos.add(selfPlanUserDto);
}
}
}
return selfPlanUserDtos;
}
} }
...@@ -99,4 +99,9 @@ public class MQTopicConumer { ...@@ -99,4 +99,9 @@ public class MQTopicConumer {
* 个人号发送文本消息 * 个人号发送文本消息
*/ */
public static final String SELF_ROBOT_SEND_TEXT = PREFIX + MQTopicProducer.SELF_ROBOT_SEND_TEXT; public static final String SELF_ROBOT_SEND_TEXT = PREFIX + MQTopicProducer.SELF_ROBOT_SEND_TEXT;
/**
* 个人号发送文本消息
*/
public static final String TIP_FOR_WECHAT_USER = PREFIX + MQTopicProducer.TIP_FOR_WECHAT_USER;
} }
/**
*
*/
package com.pcloud.book.mq.topic;
import com.pcloud.book.mq.config.MQTopicConumer;
import com.pcloud.book.timecontrol.biz.SelfPlanBiz;
import com.pcloud.facade.tradecenter.dto.TipTopicDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("tipListener")
@RabbitListener(queues = MQTopicConumer.TIP_FOR_WECHAT_USER)
public class TipListener {
private final static Logger LOGGER = LoggerFactory.getLogger(TipListener.class);
@Autowired
private SelfPlanBiz selfPlanBiz;
/**
* 处理个性化定制服务
*/
@RabbitHandler
public void onMessage(TipTopicDto tipTopicDto) {
if (tipTopicDto == null) {
return;
}
// 如果不是文章赞赏直接返回
if (!"SELF_PLAN".equals(tipTopicDto.getTargetType())) {
return;
}
LOGGER.info("处理个性化定制服务");
// 存储赞赏支付记录
long wechatUserId = tipTopicDto.getWechatUserId();
long planId = tipTopicDto.getTargetId();
selfPlanBiz.payBack((int) planId);
}
}
package com.pcloud.book.timecontrol.biz;
import com.pcloud.book.group.dto.UserSelectParamDTO;
import com.pcloud.book.timecontrol.dto.SelfPlanUserDto;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlan;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanFeedback;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanItem;
import com.pcloud.book.timecontrol.vo.AddTask4SelfPlan;
import com.pcloud.book.timecontrol.vo.CreateSelfPlanVO;
import com.pcloud.book.timecontrol.vo.SelfPlanVO;
import com.pcloud.book.timecontrol.vo.UpdateSelfPlanVO;
import com.pcloud.common.page.PageBeanNew;
import java.util.List;
public interface SelfPlanBiz {
Integer createSelfPlan(CreateSelfPlanVO createSelfPlanVO);
void addTask4SelfPlan(AddTask4SelfPlan addTask4SelfPlan);
PageBeanNew<SelfPlanVO> listSelfPlan(Integer currentPage, Integer numPerPage, Integer serviceState);
void deleteSelfPlan(Integer planId);
void editSelfPlanItems(List<TimeControlSelfPlanItem> selfPlanItemList);
List<TimeControlSelfPlanItem> getSelfPlanItems(Integer planId);
void commitFeedback(List<TimeControlSelfPlanFeedback> selfPlanFeedbackList);
List<TimeControlSelfPlanFeedback> getFeedbackByPlan(Integer planId);
void commitEvaluate(TimeControlSelfPlanFeedback selfPlanFeedback);
PageBeanNew<SelfPlanUserDto> listUser4SelfPlan(UserSelectParamDTO userSelectParamDTO);
void payBack(Integer planId);
void advancedSetting(TimeControlSelfPlan timeControlSelfPlan);
void updateSelfPlan(UpdateSelfPlanVO updateSelfPlanVO);
TimeControlSelfPlan getSelfPlanById(Integer planId);
PageBeanNew<TimeControlSelfPlanFeedback> getFeedbackPage(Integer planId, Integer currentPage, Integer numPerPage);
TimeControlSelfPlan getLatestPlan(String wxId, Integer planId);
}
package com.pcloud.book.timecontrol.biz.impl;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.consumer.wechatgroup.WechatGroupConsr;
import com.pcloud.book.group.biz.WeixinQrcodeBiz;
import com.pcloud.book.group.dto.UserSelectParamDTO;
import com.pcloud.book.group.set.GroupSet;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotClassifyBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobotClassify;
import com.pcloud.book.timecontrol.biz.SelfPlanBiz;
import com.pcloud.book.timecontrol.dto.SelfPlanUserDto;
import com.pcloud.book.timecontrol.entity.TimeControlReplyMessage;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlan;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanFeedback;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanItem;
import com.pcloud.book.timecontrol.entity.TimeControlTask;
import com.pcloud.book.timecontrol.entity.TimeControlTaskItem;
import com.pcloud.book.timecontrol.enums.FeedbackTypeEnum;
import com.pcloud.book.timecontrol.enums.ServiceStateEnum;
import com.pcloud.book.timecontrol.mapper.TimeControlReplyMessageMapper;
import com.pcloud.book.timecontrol.mapper.TimeControlSelfPlanFeedbackMapper;
import com.pcloud.book.timecontrol.mapper.TimeControlSelfPlanItemMapper;
import com.pcloud.book.timecontrol.mapper.TimeControlSelfPlanMapper;
import com.pcloud.book.timecontrol.mapper.TimeControlTaskItemMapper;
import com.pcloud.book.timecontrol.mapper.TimeControlTaskMapper;
import com.pcloud.book.timecontrol.vo.AddTask4SelfPlan;
import com.pcloud.book.timecontrol.vo.CreateSelfPlanVO;
import com.pcloud.book.timecontrol.vo.SelfPlanVO;
import com.pcloud.book.timecontrol.vo.UpdateSelfPlanVO;
import com.pcloud.book.util.common.ThreadPoolUtils;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.biz.MessageBiz;
import com.pcloud.common.core.dto.SendEmailDto;
import com.pcloud.common.exceptions.BizException;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.wechatgroup.group.dto.GroupRobotDTO;
import com.pcloud.wechatgroup.group.dto.GroupUserDTO;
import com.sdk.wxgroup.SendMessageTypeEnum;
import com.sdk.wxgroup.SendTextMessageVO;
import com.sdk.wxgroup.WxGroupSDK;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class SelfPlanBizImpl implements SelfPlanBiz {
@Autowired
private TimeControlSelfPlanItemMapper selfPlanItemMapper;
@Autowired
private TimeControlSelfPlanFeedbackMapper selfPlanFeedbackMapper;
@Autowired
private TimeControlSelfPlanFeedbackMapper timeControlSelfPlanFeedbackMapper;
private final static Logger LOGGER = LoggerFactory.getLogger(SelfPlanBizImpl.class);
@Autowired
private TimeControlSelfPlanMapper timeControlSelfPlanMapper;
@Autowired
private TimeControlTaskMapper taskMapper;
@Autowired
private TimeControlTaskItemMapper taskItemMapper;
@Autowired
private TimeControlReplyMessageMapper replyMessageMapper;
@Autowired
private PcloudRobotBiz pcloudRobotBiz;
@Autowired
private WechatGroupConsr wechatGroupConsr;
@Autowired
private GroupSet groupSet;
@Autowired
private WeixinQrcodeBiz weixinQrcodeBiz;
@Autowired
private PcloudRobotClassifyBiz pcloudRobotClassifyBiz;
@Autowired
private MessageBiz messageBiz;
@Value("${self.plan.feedback.email}")
private String selfPlanFeedbackEmail;
@Override
@ParamLog
public Integer createSelfPlan(CreateSelfPlanVO createSelfPlanVO) {
TimeControlSelfPlan timeControlSelfPlan = new TimeControlSelfPlan();
timeControlSelfPlan.setWxId(createSelfPlanVO.getWxId());
timeControlSelfPlan.setRobotWxId(createSelfPlanVO.getRobotWxId());
timeControlSelfPlanMapper.insert(timeControlSelfPlan);
//更新单号
String id = String.valueOf(timeControlSelfPlan.getId());
String s = StringUtils.leftPad(id, 6, "0");
String date = DateUtils.formatDate(new Date(), "yyyyMMdd");
timeControlSelfPlanMapper.updatePlanOrder(timeControlSelfPlan.getId(), date + s);
return timeControlSelfPlan.getId();
}
@Override
public void addTask4SelfPlan(AddTask4SelfPlan addTask4SelfPlan) {
Integer taskId = addTask4SelfPlan.getTaskId();
Integer planId = addTask4SelfPlan.getPlanId();
TimeControlSelfPlan timeControlSelfPlan = timeControlSelfPlanMapper.getById(planId);
if (null == timeControlSelfPlan) {
throw new BookBizException(BookBizException.ERROR, "服务不存在!");
}
TimeControlTask timeControlTask = taskMapper.selectByPrimaryKey(taskId);
timeControlTask.setTaskId(null);
//新增任务
taskMapper.insert(timeControlTask);
Integer newTaskId = timeControlTask.getTaskId();
//新增任务item
List<TimeControlTaskItem> list = taskItemMapper.listByTaskId(taskId);
if (!ListUtils.isEmpty(list)) {
list.forEach(item -> {
Integer oldItemId = item.getId();
List<TimeControlReplyMessage> timeControlReplyMessages = replyMessageMapper.list4TaskItem(oldItemId, null);
item.setTaskId(newTaskId);
taskItemMapper.insert(item);
Integer newItemId = item.getId();
if (!ListUtils.isEmpty(timeControlReplyMessages)) {
timeControlReplyMessages.forEach(replyMessage -> {
replyMessage.setTaskId(newTaskId);
replyMessage.setTaskItemId(newItemId);
});
replyMessageMapper.batchInsert(timeControlReplyMessages);
}
});
}
timeControlSelfPlanMapper.bindTask(planId, newTaskId);
}
@Override
public PageBeanNew<SelfPlanVO> listSelfPlan(Integer currentPage, Integer numPerPage, Integer serviceState) {
int count = timeControlSelfPlanMapper.getSelfPlanCount(serviceState);
if (count <= 0) {
return new PageBeanNew<>(currentPage, numPerPage, new ArrayList<>());
}
List<SelfPlanVO> list = timeControlSelfPlanMapper.listSelfPlan(currentPage * numPerPage, numPerPage, serviceState);
if (!ListUtils.isEmpty(list)) {
List<String> collect = list.stream().map(SelfPlanVO::getWxId).distinct().collect(Collectors.toList());
Map<String, GroupUserDTO> stringGroupUserDTOMap = wechatGroupConsr.mapWxUserInfoByWxIdList(collect);
list.forEach(selfPlanVO -> {
//封装数据
String robotWxId = selfPlanVO.getRobotWxId();
PcloudRobot pcloudRobotByWxId = pcloudRobotBiz.getPcloudRobotByWxId(robotWxId);
if (null != pcloudRobotByWxId) {
selfPlanVO.setRobotType(pcloudRobotByWxId.getRobotType());
selfPlanVO.setUniqueNumber(pcloudRobotByWxId.getUniqueNumber());
PcloudRobotClassify classifyById = pcloudRobotClassifyBiz.getClassifyById(Long.valueOf(pcloudRobotByWxId.getRobotType()));
selfPlanVO.setClassifyName(classifyById.getClassifyName());
}
String wxId = selfPlanVO.getWxId();
if (stringGroupUserDTOMap != null) {
GroupUserDTO groupUserDTO = stringGroupUserDTOMap.get(wxId);
if (groupUserDTO != null){
selfPlanVO.setHeadUrl(groupUserDTO.getHeadPic());
selfPlanVO.setNickName(groupUserDTO.getNickName());
}
}
List<TimeControlSelfPlanFeedback> timeControlSelfPlanFeedbacks =timeControlSelfPlanFeedbackMapper.getFeedbackByPlan(selfPlanVO.getPlanId(),FeedbackTypeEnum.FEEDBACK.value);
if (ListUtils.isEmpty(timeControlSelfPlanFeedbacks)){
selfPlanVO.setFeedbackState(0);
}else {
selfPlanVO.setFeedbackState(1);
}
List<TimeControlSelfPlanFeedback> feedbacks4Evaluate = timeControlSelfPlanFeedbackMapper.getFeedbackByPlan(selfPlanVO.getPlanId(),FeedbackTypeEnum.SERVICE_EVALUATE.value);
if (!ListUtils.isEmpty(feedbacks4Evaluate)){
selfPlanVO.setTimeControlSelfPlanFeedback4Evaluate(feedbacks4Evaluate.get(0));
}
});
}
return new PageBeanNew<>(currentPage, numPerPage, count, list);
}
@Override
public void deleteSelfPlan(Integer planId) {
TimeControlSelfPlan plan = timeControlSelfPlanMapper.getById(planId);
if (null != plan){
if (ServiceStateEnum.FINISH_BUY.getValue().equals(plan.getServiceState())) {
throw new BookBizException(BookBizException.ERROR, "已购买无法删除!");
}
if (ServiceStateEnum.FINISH_SUBSCRIBE.getValue().equals(plan.getServiceState())) {
throw new BookBizException(BookBizException.ERROR, "已订阅无法删除!");
}
timeControlSelfPlanMapper.deleteById(planId);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void editSelfPlanItems(List<TimeControlSelfPlanItem> selfPlanItemList) {
Integer planId = selfPlanItemList.get(0).getSelfPlanId();
selfPlanItemMapper.deleteByPlanId(planId);
selfPlanItemMapper.batchInsert(selfPlanItemList);
TimeControlSelfPlan plan = timeControlSelfPlanMapper.getById(planId);
if(plan != null && !StringUtil.isEmpty(plan.getChangeReply())) {
String robotWxId = plan.getRobotWxId();
String userWxId = plan.getWxId();
GroupRobotDTO groupRobotDTO = wechatGroupConsr.getGroupRobotByWxId(robotWxId);
String ip = weixinQrcodeBiz.getRobotIpByGeneration(groupRobotDTO.getVersion());
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(plan.getChangeReply());
sendTextMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendTextMessageVO.setWxId(robotWxId);
sendTextMessageVO.setAltId(robotWxId);
sendTextMessageVO.setWxGroupId(userWxId);
sendTextMessageVO.setIp(ip);
WxGroupSDK.sendTextMessage(sendTextMessageVO);
}
}
@Override
public List<TimeControlSelfPlanItem> getSelfPlanItems(Integer planId) {
return selfPlanItemMapper.getByPlanId(planId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void commitFeedback(List<TimeControlSelfPlanFeedback> selfPlanFeedbackList) {
if(CollectionUtils.isEmpty(selfPlanFeedbackList)) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数缺失!");
}
String feedbackContent = "<br/>";
Integer planId = selfPlanFeedbackList.get(0).getSelfPlanId();
if(planId == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "方案ID缺失!");
}
TimeControlSelfPlan plan = timeControlSelfPlanMapper.getById(planId);
if(plan == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "该服务不存在!");
}
int index = 1;
for(TimeControlSelfPlanFeedback planFeedback : selfPlanFeedbackList) {
planFeedback.setRobotWxId(plan.getRobotWxId());
planFeedback.setWxId(plan.getWxId());
planFeedback.setFeedbackType(FeedbackTypeEnum.FEEDBACK.value);
feedbackContent = feedbackContent + index++ + "、" + planFeedback.getContent() + "<br/>";
}
selfPlanFeedbackMapper.batchInsert(selfPlanFeedbackList);
//发邮件
String finalFeedbackContent = feedbackContent;
ThreadPoolUtils.OTHER_THREAD_POOL.execute(() -> {
String robotWxId = plan.getRobotWxId();
String userWxId = plan.getWxId();
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("robotWxId", robotWxId);
paramMap.put("userWxId", userWxId);
paramMap.put("content", finalFeedbackContent);
paramMap.put("time", DateUtils.getLongDateStr());
PcloudRobot pcloudRobot = pcloudRobotBiz.getPcloudRobotByWxId(robotWxId);
if(pcloudRobot != null) {
paramMap.put("number", StringUtil.isEmpty(pcloudRobot.getUniqueNumber()) ? "未知" : pcloudRobot.getUniqueNumber());
PcloudRobotClassify classify = pcloudRobotClassifyBiz.getClassifyById(pcloudRobot.getRobotType().longValue());
paramMap.put("classifyName", classify == null ? "未知" : classify.getClassifyName());
}
GroupUserDTO userDTO = wechatGroupConsr.getWxUserInfoByWxUserId(userWxId);
paramMap.put("nickName", userDTO == null ? "未知" : userDTO.getNickName());
SendEmailDto sendEmailDto = new SendEmailDto();
sendEmailDto.setToEmail(selfPlanFeedbackEmail);
sendEmailDto.setTypeCode("self_plan_feedback_email");
sendEmailDto.setContent(paramMap);
messageBiz.sendEmail(sendEmailDto);
});
}
@Override
public List<TimeControlSelfPlanFeedback> getFeedbackByPlan(Integer planId) {
return selfPlanFeedbackMapper.getFeedbackByPlan(planId, FeedbackTypeEnum.FEEDBACK.value);
}
@Override
public void commitEvaluate(TimeControlSelfPlanFeedback selfPlanFeedback) {
Integer planId = selfPlanFeedback.getSelfPlanId();
if(planId == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "参数缺失!");
}
TimeControlSelfPlan plan = timeControlSelfPlanMapper.getById(planId);
if(plan == null) {
throw new BookBizException(BookBizException.PARAM_IS_NULL, "该服务不存在!");
}
selfPlanFeedback.setRobotWxId(plan.getRobotWxId());
selfPlanFeedback.setWxId(plan.getWxId());
selfPlanFeedback.setFeedbackType(FeedbackTypeEnum.SERVICE_EVALUATE.value);
selfPlanFeedbackMapper.insert(selfPlanFeedback);
}
@Override
@ParamLog(value = "个性化定制-用户列表查询",isAfterReturn = false)
public PageBeanNew<SelfPlanUserDto> listUser4SelfPlan(UserSelectParamDTO userSelectParamDTO) {
Integer currentPage = userSelectParamDTO.getCurrentPage();
Integer numPerPage = userSelectParamDTO.getNumPerPage();
Map<String, Object> map = new HashMap<>();
//判断robotid是否是小睿
String robotId = userSelectParamDTO.getRobotId();
List<SelfPlanUserDto> list = new ArrayList<>();
Integer totalCount = 0;
if (StringUtil.isEmpty(robotId)) {
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "robotId为空");
}
PcloudRobot pcloudRobot = pcloudRobotBiz.getPcloudRobotByWxId(robotId);
if (null != pcloudRobot) {
PageBeanNew<String> wechatUserIdPage = wechatGroupConsr.listPageFriend(currentPage, numPerPage,
robotId, userSelectParamDTO.getUserQuery());
if (!ListUtils.isEmpty(wechatUserIdPage.getRecordList())) {
List<String> wechatUserIds = wechatUserIdPage.getRecordList();
Map<String, SelfPlanUserDto> selfPlanUserDtoMap = timeControlSelfPlanMapper.getSelfPlanUserDtoMap(wechatUserIds);
list = groupSet.setUserInfo4SelfPlan4XIAORUI(wechatUserIds, selfPlanUserDtoMap);
totalCount = wechatUserIdPage.getTotalCount();
}
}
return new PageBeanNew<>(currentPage, numPerPage, totalCount, list);
}
@Override
@ParamLog
public void payBack(Integer planId) {
TimeControlSelfPlan timeControlSelfPlan = timeControlSelfPlanMapper.getById(planId);
if (null == timeControlSelfPlan) {
LOGGER.info("计划不存在,直接返回!");
return;
}
if (ServiceStateEnum.FINISH_BUY.getValue().equals(timeControlSelfPlan.getServiceState())){
LOGGER.info("以购买,直接返回");
return;
}
timeControlSelfPlan.setServiceState(ServiceStateEnum.FINISH_BUY.getValue());
timeControlSelfPlanMapper.updateServiceState(timeControlSelfPlan);
if (null != timeControlSelfPlan.getBuyReply()) {
//发送购买return
String wxId = timeControlSelfPlan.getWxId();
String robotWxId = timeControlSelfPlan.getRobotWxId();
GroupRobotDTO groupRobotDTO = wechatGroupConsr.getGroupRobotByWxId(robotWxId);
String ip = weixinQrcodeBiz.getRobotIpByGeneration(groupRobotDTO.getVersion());
SendTextMessageVO sendTextMessageVO = new SendTextMessageVO();
sendTextMessageVO.setContent(timeControlSelfPlan.getBuyReply());
sendTextMessageVO.setCode(SendMessageTypeEnum.SELF.getCode());
sendTextMessageVO.setWxId(robotWxId);
sendTextMessageVO.setAltId(robotWxId);
sendTextMessageVO.setWxGroupId(wxId);
sendTextMessageVO.setIp(ip);
WxGroupSDK.sendTextMessage(sendTextMessageVO);
}
}
@Override
public void advancedSetting(TimeControlSelfPlan timeControlSelfPlan) {
checkParam4AdvancedSetting(timeControlSelfPlan);
timeControlSelfPlanMapper.advancedSetting(timeControlSelfPlan);
}
@Override
public void updateSelfPlan(UpdateSelfPlanVO updateSelfPlanVO) {
timeControlSelfPlanMapper.updateSelfPlan(updateSelfPlanVO);
}
@Override
public TimeControlSelfPlan getSelfPlanById(Integer planId) {
TimeControlSelfPlan timeControlSelfPlan = timeControlSelfPlanMapper.getById(planId);
String robotId = timeControlSelfPlan.getRobotWxId();
PcloudRobot pcloudRobot = pcloudRobotBiz.getPcloudRobotByWxId(robotId);
if (null != pcloudRobot){
timeControlSelfPlan.setClassifyId(pcloudRobot.getRobotType());
PcloudRobotClassify pcloudRobotClassify = pcloudRobotClassifyBiz.getClassifyById(Long.valueOf(pcloudRobot.getRobotType().toString()));
if (null != pcloudRobotClassify){
timeControlSelfPlan.setClassifyName(pcloudRobotClassify.getClassifyName());
}
}
return timeControlSelfPlan;
}
@Override
public PageBeanNew<TimeControlSelfPlanFeedback> getFeedbackPage(Integer planId, Integer currentPage, Integer numPerPage) {
Integer totalCount = timeControlSelfPlanFeedbackMapper.listFeedbackCount(planId);
if (totalCount <= 0) {
return new PageBeanNew<>(currentPage, numPerPage, new ArrayList<>());
}
List<TimeControlSelfPlanFeedback> timeControlSelfPlanFeedbacks = timeControlSelfPlanFeedbackMapper.listFeedback(planId,
currentPage * numPerPage,numPerPage);
return new PageBeanNew<>(currentPage, numPerPage, totalCount, timeControlSelfPlanFeedbacks);
}
@Override
public TimeControlSelfPlan getLatestPlan(String wxId, Integer planId) {
if (null != planId) {
return timeControlSelfPlanMapper.getById(planId);
}
TimeControlSelfPlan timeControlSelfPlan = timeControlSelfPlanMapper.getLatestPlan(wxId);
return timeControlSelfPlan;
}
private void checkParam4AdvancedSetting(TimeControlSelfPlan timeControlSelfPlan) {
if (null == timeControlSelfPlan){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "timeControlSelfPlan为空");
}
if (null == timeControlSelfPlan.getTotalPrice()){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "总价不能为空");
}
if (StringUtil.isEmpty(timeControlSelfPlan.getBuyReply())){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "购买后返回方案不能为空");
}
if (StringUtil.isEmpty(timeControlSelfPlan.getChangeReply())){
throw new BizException(BizException.PARAM_IS_NULL.getCode(), "订阅后返回方案不能为空");
}
}
}
...@@ -368,7 +368,7 @@ public class TaskBizImpl implements TaskBiz { ...@@ -368,7 +368,7 @@ public class TaskBizImpl implements TaskBiz {
if (null == timeControlTaskItem.getProgressGuidance()) { if (null == timeControlTaskItem.getProgressGuidance()) {
timeControlTaskItem.setProgressGuidance(0); timeControlTaskItem.setProgressGuidance(0);
} }
taskItemMapper.updateTtaskItem(timeControlTaskItem); taskItemMapper.updateTaskItem(timeControlTaskItem);
//删除原item下的配置 //删除原item下的配置
replyMessageMapper.deleteByItemId(taskItemId); replyMessageMapper.deleteByItemId(taskItemId);
//重新插入 //重新插入
......
package com.pcloud.book.timecontrol.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.Date;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TimeControlSelfPlan {
private Integer id;
private String robotWxId;
private Integer classifyId;
private String classifyName;
private String wxId;
private Integer taskId;
private Double totalPrice;
private String buyReply;
private String subscribeReply;
private String changeReply;
private Integer evaluateOpen;
private Integer serviceState;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
private String evaluateGuide;
private String planOrder;
}
\ No newline at end of file
package com.pcloud.book.timecontrol.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.Date;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TimeControlSelfPlanFeedback {
private Integer id;
private Integer feedbackType;
private Integer selfPlanId;
private String robotWxId;
private String wxId;
private Integer planType;
private String content;
private Integer planScore;
private Integer contentScore;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.timecontrol.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.util.Date;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TimeControlSelfPlanItem {
private Integer id;
private Integer selfPlanId;
private Integer type;
private String title;
private String content;
private String description;
private String picUrl;
private Integer openFeedback;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
...@@ -32,6 +32,8 @@ public class TimeControlTaskItem { ...@@ -32,6 +32,8 @@ public class TimeControlTaskItem {
private Integer progressGuidance; private Integer progressGuidance;
private String itemIntroduce;
public Integer getAddSendTime() { public Integer getAddSendTime() {
return addSendTime; return addSendTime;
} }
...@@ -135,4 +137,12 @@ public class TimeControlTaskItem { ...@@ -135,4 +137,12 @@ public class TimeControlTaskItem {
public void setProgressGuidance(Integer progressGuidance) { public void setProgressGuidance(Integer progressGuidance) {
this.progressGuidance = progressGuidance; this.progressGuidance = progressGuidance;
} }
public String getItemIntroduce() {
return itemIntroduce;
}
public void setItemIntroduce(String itemIntroduce) {
this.itemIntroduce = itemIntroduce;
}
} }
\ No newline at end of file
package com.pcloud.book.timecontrol.enums;
public enum FeedbackTypeEnum {
/**
* 1意见反馈
*/
FEEDBACK(1),
/**
* 2服务评价
*/
SERVICE_EVALUATE(2);
/**
* 值
*/
public final Integer value;
FeedbackTypeEnum(Integer value) {
this.value = value;
}
}
package com.pcloud.book.timecontrol.facade.impl;
import com.pcloud.book.group.dto.UserSelectParamDTO;
import com.pcloud.book.timecontrol.biz.SelfPlanBiz;
import com.pcloud.book.timecontrol.dto.SelfPlanUserDto;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlan;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanFeedback;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanItem;
import com.pcloud.book.timecontrol.vo.AddTask4SelfPlan;
import com.pcloud.book.timecontrol.vo.CreateSelfPlanVO;
import com.pcloud.book.timecontrol.vo.SelfPlanVO;
import com.pcloud.book.timecontrol.vo.UpdateSelfPlanVO;
import com.pcloud.common.dto.ResponseDto;
import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.permission.PermissionException;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.wechatgroup.base.exception.WechatGroupBizException;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RequestMapping("selfPlan")
@RestController("selfPlanFacade")
public class SelfPlanFacadeImpl {
@Autowired
private SelfPlanBiz selfPlanBiz;
@ApiOperation("定制个性化服务-第一步")
@PostMapping("createSelfPlan")
ResponseDto<?> createSelfPlan(@RequestHeader String token, @RequestBody @Validated CreateSelfPlanVO createSelfPlanVO) {
Integer id = selfPlanBiz.createSelfPlan(createSelfPlanVO);
return new ResponseDto<>(id);
}
@ApiOperation("修改定制个性化服务-第一步")
@PostMapping("updateSelfPlan")
ResponseDto<?> updateSelfPlan(@RequestHeader String token, @RequestBody @Validated UpdateSelfPlanVO updateSelfPlanVO) {
selfPlanBiz.updateSelfPlan(updateSelfPlanVO);
return new ResponseDto<>();
}
@PostMapping("addTask4SelfPlan")
@ApiOperation("定制个性化服务-添加服务内容")
ResponseDto<?> addTask4SelfPlan(@RequestHeader String token, @RequestBody @Validated AddTask4SelfPlan addTask4SelfPlan) {
selfPlanBiz.addTask4SelfPlan(addTask4SelfPlan);
return new ResponseDto<>();
}
@ApiOperation("服务记录")
@GetMapping("listSelfPlan")
ResponseDto<?> listSelfPlan(@RequestHeader String token, @RequestParam Integer currentPage, @RequestParam Integer numPerPage,
@RequestParam(value = "serviceState", required = false) Integer serviceState) {
PageBeanNew<SelfPlanVO> pageBeanNew = selfPlanBiz.listSelfPlan(currentPage, numPerPage, serviceState);
return new ResponseDto<>(pageBeanNew);
}
@ApiOperation(value = "删除服务", httpMethod = "GET")
@GetMapping("deleteSelfPlan")
ResponseDto<?> deleteSelfPlan(@RequestHeader String token, @RequestParam Integer planId) {
selfPlanBiz.deleteSelfPlan(planId);
return new ResponseDto<>();
}
@ApiOperation(value = "编辑方案内容", httpMethod = "POST")
@PostMapping("editSelfPlanItems")
ResponseDto<?> editSelfPlanItems(@RequestHeader String token, @RequestBody List<TimeControlSelfPlanItem> selfPlanItemList) {
selfPlanBiz.editSelfPlanItems(selfPlanItemList);
return new ResponseDto<>();
}
@ApiOperation(value = "获取方案内容(平台端)", httpMethod = "GET")
@GetMapping("getSelfPlanItems4Pcloud")
ResponseDto<?> getSelfPlanItems4Pcloud(@RequestHeader String token, @RequestParam Integer planId) {
return new ResponseDto<>( selfPlanBiz.getSelfPlanItems(planId));
}
@ApiOperation(value = "获取方案内容(客户端)", httpMethod = "GET")
@GetMapping("getSelfPlanItems4Wechat")
ResponseDto<?> getSelfPlanItems4Wechat(@RequestParam Integer planId) {
return new ResponseDto<>( selfPlanBiz.getSelfPlanItems(planId));
}
@ApiOperation(value = "新增反馈", httpMethod = "POST")
@PostMapping("commitFeedback")
ResponseDto<?> commitFeedback(@RequestBody List<TimeControlSelfPlanFeedback> selfPlanFeedbackList) {
selfPlanBiz.commitFeedback(selfPlanFeedbackList);
return new ResponseDto<>();
}
@ApiOperation(value = "获取反馈", httpMethod = "GET")
@GetMapping("getFeedbackByPlan")
ResponseDto<?> getFeedbackByPlan(@RequestHeader String token, @RequestParam Integer planId) {
return new ResponseDto<>(selfPlanBiz.getFeedbackByPlan(planId));
}
@ApiOperation(value = "个性化定制-用户列表查询", httpMethod = "POST")
@PostMapping("listUser4SelfPlan")
public ResponseDto<PageBeanNew<SelfPlanUserDto>> listUser4SelfPlan(
@RequestHeader("token") String token, @RequestBody @ApiParam UserSelectParamDTO userSelectParamDTO) throws PermissionException {
SessionUtil.getToken4Redis(token);
if (null == userSelectParamDTO || null == userSelectParamDTO.getCurrentPage() || null == userSelectParamDTO.getNumPerPage()) {
throw new WechatGroupBizException(WechatGroupBizException.PARAM_IS_NULL, "缺少参数");
}
if (StringUtil.isEmpty(userSelectParamDTO.getRobotId())){
throw new WechatGroupBizException(WechatGroupBizException.PARAM_IS_NULL, "请选择个人号");
}
PageBeanNew<SelfPlanUserDto> pageBeanNew = selfPlanBiz.listUser4SelfPlan(userSelectParamDTO);
return new ResponseDto<>(pageBeanNew);
}
@ApiOperation(value = "提交评价", httpMethod = "POST")
@PostMapping("commitEvaluate")
ResponseDto<?> commitEvaluate(@RequestBody TimeControlSelfPlanFeedback selfPlanFeedback) {
selfPlanBiz.commitEvaluate(selfPlanFeedback);
return new ResponseDto<>();
}
@ApiOperation(value = "设置高级设置", httpMethod = "POST")
@PostMapping("advancedSetting")
ResponseDto<?> advancedSetting(@RequestHeader String token, @RequestBody TimeControlSelfPlan timeControlSelfPlan) {
selfPlanBiz.advancedSetting(timeControlSelfPlan);
return new ResponseDto<>();
}
@ApiOperation(value = "获取高级设置", httpMethod = "GET")
@GetMapping("getSelfPlanById")
ResponseDto<?> getSelfPlanById(@RequestHeader String token, @RequestParam("planId") Integer planId) {
TimeControlSelfPlan timeControlSelfPlan = selfPlanBiz.getSelfPlanById(planId);
return new ResponseDto<>(timeControlSelfPlan);
}
@ApiOperation(value = "获取反馈意见", httpMethod = "GET")
@GetMapping("getFeedbackPage")
ResponseDto<PageBeanNew<TimeControlSelfPlanFeedback>> getFeedbackPage(@RequestHeader String token, @RequestParam("planId") Integer planId,
@RequestParam Integer currentPage, @RequestParam Integer numPerPage) {
PageBeanNew<TimeControlSelfPlanFeedback> timeControlSelfPlanPage = selfPlanBiz.getFeedbackPage(planId,currentPage,numPerPage);
return new ResponseDto<>(timeControlSelfPlanPage);
}
@ApiOperation(value = "获取最近一个计划", httpMethod = "GET")
@GetMapping(value = "getLatestPlan")
ResponseDto<?> getLatestPlan(@RequestParam String wxId, @RequestParam(value = "planId", required = false) Integer planId){
TimeControlSelfPlan selfPlan = selfPlanBiz.getLatestPlan(wxId, planId);
return new ResponseDto<>(selfPlan);
}
}
package com.pcloud.book.timecontrol.mapper;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanFeedback;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("selfPlanFeedBackMapper")
public interface TimeControlSelfPlanFeedbackMapper {
void insert(TimeControlSelfPlanFeedback selfPlanFeedback);
void batchInsert(List<TimeControlSelfPlanFeedback> selfPlanFeedbackList);
void update(TimeControlSelfPlanFeedback selfPlanFeedback);
List<TimeControlSelfPlanFeedback> getFeedbackByPlan(@Param("planId")Integer planId, @Param("feedbackType")Integer feedbackType);
void deleteById(@Param("id")Integer id);
void deleteByPlanId(@Param("planId") Integer planId, @Param("feedbackType")Integer feedbackType);
List<TimeControlSelfPlanFeedback> listFeedback(@Param("planId") Integer planId, @Param("pageNum") int pageNum, @Param("numPerPage") int numPerPage);
Integer listFeedbackCount(Integer planId);
}
\ No newline at end of file
package com.pcloud.book.timecontrol.mapper;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanItem;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
@Component("selfPlanItemMapper")
public interface TimeControlSelfPlanItemMapper {
int batchInsert(List<TimeControlSelfPlanItem> selfPlanItemList);
int deleteByPlanId(@Param("planId")Integer planId);
List<TimeControlSelfPlanItem> getByPlanId(@Param("planId")Integer planId);
}
\ No newline at end of file
package com.pcloud.book.timecontrol.mapper;
import com.pcloud.book.timecontrol.dto.SelfPlanUserDto;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlan;
import com.pcloud.book.timecontrol.vo.SelfPlanVO;
import com.pcloud.book.timecontrol.vo.UpdateSelfPlanVO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component("selfPlanMapper")
public interface TimeControlSelfPlanMapper {
int insert(TimeControlSelfPlan selfPlan);
int update(TimeControlSelfPlan selfPlan);
TimeControlSelfPlan getById(@Param("id")Integer id);
int deleteById(@Param("id")Integer id);
int getSelfPlanCount(@Param("serviceState") Integer serviceState);
List<SelfPlanVO> listSelfPlan(@Param("pageNum") int pageNum, @Param("numPerPage") int numPerPage, @Param("serviceState") Integer serviceState);
void bindTask(@Param("planId") Integer planId, @Param("taskId") Integer taskId);
@MapKey("wxUserId")
Map<String, SelfPlanUserDto> getSelfPlanUserDtoMap(List<String> wechatUserIds);
void updateServiceState(TimeControlSelfPlan timeControlSelfPlan);
void updatePlanOrder(@Param("id") Integer id, @Param("planOrder") String planOrder);
void advancedSetting(TimeControlSelfPlan timeControlSelfPlan);
void updateSelfPlan(UpdateSelfPlanVO updateSelfPlanVO);
TimeControlSelfPlan getLatestPlan(String wxId);
}
\ No newline at end of file
...@@ -19,11 +19,13 @@ public interface TimeControlTaskItemMapper { ...@@ -19,11 +19,13 @@ public interface TimeControlTaskItemMapper {
TimeControlTaskItem getByTaskIdAndDay(@Param("taskId") Integer taskId, @Param("startDay") Integer startDay); TimeControlTaskItem getByTaskIdAndDay(@Param("taskId") Integer taskId, @Param("startDay") Integer startDay);
void updateTtaskItem(TimeControlTaskItem timeControlTaskItem); void updateTaskItem(TimeControlTaskItem timeControlTaskItem);
List<ReplyMessageBaseDto> listTaskItemDay(Integer taskId); List<ReplyMessageBaseDto> listTaskItemDay(Integer taskId);
List<TimeControlTaskItem> getByItemIdList(@Param("taskItemIds") List<Integer> taskItemIds); List<TimeControlTaskItem> getByItemIdList(@Param("taskItemIds") List<Integer> taskItemIds);
Integer getTaskItemCount(@Param("taskId") Integer taskId); Integer getTaskItemCount(@Param("taskId") Integer taskId);
List<TimeControlTaskItem> listByTaskId(Integer taskId);
} }
\ No newline at end of file
package com.pcloud.book.timecontrol.vo;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
public class AddTask4SelfPlan implements Serializable {
@NotNull
private Integer planId;
@NotNull
private Integer taskId;
}
package com.pcloud.book.timecontrol.vo;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
public class CreateSelfPlanVO implements Serializable {
@NotNull
private String wxId;
@NotNull
private String robotWxId;
}
package com.pcloud.book.timecontrol.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.book.timecontrol.entity.TimeControlSelfPlanFeedback;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
public class SelfPlanVO implements Serializable {
private Integer planId;
private String robotWxId;
@ApiModelProperty("个人号类型")
private Integer robotType;
@ApiModelProperty("分类名称")
private String classifyName;
private String wxId;
private String nickName;
private String headUrl;
private Integer taskId;
private BigDecimal totalPrice;
private Integer evaluateOpen;
private Integer serviceState;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
private String linkUrl;
private Integer feedbackState;
//意见反馈
private List<TimeControlSelfPlanFeedback> timeControlSelfPlanFeedback4Suggestion;
//评分
private TimeControlSelfPlanFeedback timeControlSelfPlanFeedback4Evaluate;
@ApiModelProperty("编号")
private String uniqueNumber;
}
package com.pcloud.book.timecontrol.vo;
import javax.validation.constraints.NotNull;
import lombok.Data;
@Data
public class UpdateSelfPlanVO {
@NotNull
private String wxId;
@NotNull
private String robotWxId;
@NotNull
private Integer planId;
}
<?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.timecontrol.mapper.TimeControlSelfPlanFeedbackMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.timecontrol.entity.TimeControlSelfPlanFeedback" >
<id column="id" jdbcType="INTEGER" property="id" />
<result column="feedback_type" property="feedbackType" jdbcType="INTEGER" />
<result column="self_plan_id" property="selfPlanId" jdbcType="INTEGER" />
<result column="robot_wx_id" property="robotWxId" jdbcType="VARCHAR" />
<result column="wx_id" property="wxId" jdbcType="VARCHAR" />
<result column="plan_type" property="planType" jdbcType="INTEGER" />
<result column="content" property="content" jdbcType="VARCHAR" />
<result column="plan_score" property="planScore" jdbcType="INTEGER" />
<result column="content_score" property="contentScore" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List">
id, feedback_type, self_plan_id, robot_wx_id, wx_id, plan_type, content, plan_score, content_score, create_time, update_time
</sql>
<insert id="insert" parameterType="TimeControlSelfPlanFeedback" useGeneratedKeys="true" keyProperty="id">
insert into time_control_self_plan_feedback (feedback_type, self_plan_id, robot_wx_id, wx_id,
plan_type, content, plan_score, content_score, create_time, update_time)
values (#{feedbackType,jdbcType=INTEGER}, #{selfPlanId,jdbcType=INTEGER}, #{robotWxId,jdbcType=VARCHAR}, #{wxId,jdbcType=VARCHAR},
#{planType,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, #{planScore,jdbcType=INTEGER},
#{contentScore,jdbcType=INTEGER}, NOW(), NOW())
</insert>
<insert id="batchInsert" useGeneratedKeys="true" keyProperty="id">
insert into time_control_self_plan_feedback (feedback_type, self_plan_id, robot_wx_id, wx_id,
plan_type, content, plan_score, content_score, create_time, update_time)
values
<foreach collection="list" separator="," item="item">
(#{item.feedbackType,jdbcType=INTEGER}, #{item.selfPlanId,jdbcType=INTEGER}, #{item.robotWxId,jdbcType=VARCHAR}, #{item.wxId,jdbcType=VARCHAR},
#{item.planType,jdbcType=INTEGER}, #{item.content,jdbcType=VARCHAR}, #{item.planScore,jdbcType=INTEGER},
#{item.contentScore,jdbcType=INTEGER}, NOW(), NOW())
</foreach>
</insert>
<update id="update" parameterType="TimeControlSelfPlanFeedback">
update time_control_self_plan_feedback
<set>
<if test="selfPlanId != null">
self_plan_id = #{selfPlanId,jdbcType=INTEGER},
</if>
<if test="robotWxId != null">
robot_wx_id = #{robotWxId,jdbcType=VARCHAR},
</if>
<if test="wxId != null">
wx_id = #{wxId,jdbcType=VARCHAR},
</if>
<if test="planType != null">
plan_type = #{planType,jdbcType=INTEGER},
</if>
<if test="content != null">
content = #{content,jdbcType=VARCHAR},
</if>
update_time = NOW(),
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteByPlanId">
delete from time_control_self_plan_feedback
where self_plan_id = #{planId,jdbcType=INTEGER}
and feedback_type = #{feedbackType,jdbcType=INTEGER}
</delete>
<select id="getFeedbackByPlan" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from time_control_self_plan_feedback
where self_plan_id = #{planId,jdbcType=INTEGER}
and feedback_type = #{feedbackType,jdbcType=INTEGER}
</select>
<select id="listFeedback" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from time_control_self_plan_feedback
where self_plan_id = #{planId,jdbcType=INTEGER}
and feedback_type = 1
ORDER BY
create_time DESC
LIMIT #{pageNum}, #{numPerPage}
</select>
<select id="listFeedbackCount" parameterType="integer" resultType="integer">
select
count(*)
from
time_control_self_plan_feedback
where self_plan_id = #{planId,jdbcType=INTEGER}
and feedback_type = 1
</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.timecontrol.mapper.TimeControlSelfPlanItemMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.timecontrol.entity.TimeControlSelfPlanItem" >
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="self_plan_id" property="selfPlanId" jdbcType="INTEGER" />
<result column="type" property="type" jdbcType="INTEGER" />
<result column="title" property="title" jdbcType="VARCHAR" />
<result column="content" property="content" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="pic_url" property="picUrl" jdbcType="VARCHAR" />
<result column="open_feedback" property="openFeedback" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List">
id, self_plan_id, type, title, content, description, pic_url, open_feedback, create_time, update_time
</sql>
<insert id="batchInsert">
insert into time_control_self_plan_item (self_plan_id, type, title,
content, description, pic_url, open_feedback, create_time, update_time)
values
<foreach collection="list" separator="," item="item">
(#{item.selfPlanId,jdbcType=INTEGER}, #{item.type,jdbcType=INTEGER}, #{item.title,jdbcType=VARCHAR},
#{item.content,jdbcType=VARCHAR}, #{item.description,jdbcType=VARCHAR},#{item.picUrl,jdbcType=VARCHAR},
#{item.openFeedback,jdbcType=INTEGER}, NOW(), NOW())
</foreach>
</insert>
<update id="update" parameterType="TimeControlSelfPlanItem">
update time_control_self_plan_item
<set>
<if test="selfPlanId != null">
self_plan_id = #{selfPlanId,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getByPlanId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from time_control_self_plan_item
where self_plan_id = #{planId,jdbcType=INTEGER}
</select>
<delete id="deleteByPlanId" parameterType="java.lang.Integer">
delete from time_control_self_plan_item
where self_plan_id = #{planId,jdbcType=INTEGER}
</delete>
</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.timecontrol.mapper.TimeControlSelfPlanMapper" >
<resultMap id="BaseResultMap" type="com.pcloud.book.timecontrol.entity.TimeControlSelfPlan" >
<id column="id" jdbcType="INTEGER" property="id" />
<result column="robot_wx_id" property="robotWxId" jdbcType="VARCHAR" />
<result column="wx_id" property="wxId" jdbcType="VARCHAR" />
<result column="task_id" property="taskId" jdbcType="INTEGER" />
<result column="total_price" property="totalPrice" jdbcType="DECIMAL" />
<result column="buy_reply" property="buyReply" jdbcType="VARCHAR" />
<result column="subscribe_reply" property="subscribeReply" jdbcType="VARCHAR" />
<result column="evaluate_open" property="evaluateOpen" jdbcType="INTEGER" />
<result column="service_state" property="serviceState" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
<result column="evaluate_guide" property="evaluateGuide" jdbcType="VARCHAR" />
<result column="change_reply" property="changeReply" jdbcType="VARCHAR" />
<result column="plan_order" property="planOrder" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id, robot_wx_id, wx_id, task_id, total_price, buy_reply, subscribe_reply, evaluate_open,
service_state, create_time, update_time,evaluate_guide,change_reply, plan_order
</sql>
<insert id="insert" parameterType="TimeControlSelfPlan" useGeneratedKeys="true" keyProperty="id">
insert into time_control_self_plan (robot_wx_id, wx_id, task_id,
total_price, buy_reply, subscribe_reply,
evaluate_open, service_state, create_time, update_time)
values (#{robotWxId,jdbcType=VARCHAR}, #{wxId,jdbcType=VARCHAR}, #{taskId,jdbcType=INTEGER},
#{totalPrice,jdbcType=DECIMAL}, #{buyReply,jdbcType=VARCHAR}, #{subscribeReply,jdbcType=VARCHAR},
0, 0, NOW(), NOW())
</insert>
<update id="update" parameterType="TimeControlSelfPlan">
update time_control_self_plan
<set>
<if test="robotWxId != null">
robot_wx_id = #{robotWxId,jdbcType=VARCHAR},
</if>
<if test="wxId != null">
wx_id = #{wxId,jdbcType=VARCHAR},
</if>
<if test="taskId != null">
task_id = #{taskId,jdbcType=INTEGER},
</if>
<if test="totalPrice != null">
total_price = #{totalPrice,jdbcType=DECIMAL},
</if>
<if test="buyReply != null">
buy_reply = #{buyReply,jdbcType=VARCHAR},
</if>
<if test="subscribeReply != null">
subscribe_reply = #{subscribeReply,jdbcType=VARCHAR},
</if>
<if test="evaluateOpen != null">
evaluate_open = #{evaluateOpen,jdbcType=INTEGER},
</if>
<if test="serviceState != null">
service_state = #{serviceState,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<delete id="deleteById" parameterType="java.lang.Integer">
delete from time_control_self_plan
where id = #{id,jdbcType=INTEGER}
</delete>
<select id="getById" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from time_control_self_plan
where id = #{id,jdbcType=INTEGER}
</select>
<select id="getSelfPlanCount" parameterType="integer" resultType="java.lang.Integer">
SELECT
ifnull(COUNT(1), 0)
FROM
`time_control_self_plan`
where 1=1
<if test="serviceState != null">
and service_state = #{serviceState}
</if>
</select>
<select id="listSelfPlan" resultType="com.pcloud.book.timecontrol.vo.SelfPlanVO">
SELECT
id planId,
robot_wx_id robotWxId,
wx_id wxId,
task_id taskId,
total_price totalPrice,
buy_reply buyReply,
subscribe_reply subscribeReply,
evaluate_open evaluateOpen,
service_state serviceState,
create_time createTime
FROM
time_control_self_plan
where 1=1
<if test="serviceState != null">
and service_State = #{serviceState}
</if>
ORDER BY
create_time DESC
LIMIT #{pageNum}, #{numPerPage}
</select>
<update id="bindTask">
update time_control_self_plan set task_id = #{taskId}, update_time = now()
where id = #{planId}
</update>
<select id="getSelfPlanUserDtoMap" parameterType="list" resultType="java.util.Map">
SELECT
wx_id wxUserId,
count(id) slefPlanCount,
sum(service_state = 2) orderCount
FROM
time_control_self_plan
<where>
<if test="list != null">
wx_id in
<foreach collection="list" index="index" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</where>
</select>
<update id="updateServiceState" parameterType="com.pcloud.book.timecontrol.entity.TimeControlSelfPlan">
update time_control_self_plan set service_state = #{serviceState}
where id = #{id}
</update>
<update id="updatePlanOrder">
update time_control_self_plan set plan_order = #{planOrder}
where id = #{id}
</update>
<update id="advancedSetting" parameterType="com.pcloud.book.timecontrol.entity.TimeControlSelfPlan">
update
time_control_self_plan
set
total_price = #{totalPrice} ,
buy_reply = #{buyReply} ,
change_reply = #{changeReply}
<if test="evaluateOpen != null">
,evaluate_open = #{evaluateOpen}
</if>
<if test="evaluateGuide != null">
, evaluate_guide = #{evaluateGuide}
</if>
where id = #{id}
</update>
<update id="updateSelfPlan" parameterType="com.pcloud.book.timecontrol.vo.UpdateSelfPlanVO">
update
time_control_self_plan
set
robot_wx_id = #{robotWxId},
wx_id = #{wxId}
where
id = #{planId}
</update>
<select id="getLatestPlan" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from time_control_self_plan
where wx_id = #{wxId}
order by create_time desc
limit 1
</select>
</mapper>
\ No newline at end of file
...@@ -15,20 +15,21 @@ ...@@ -15,20 +15,21 @@
<result column="add_send_time" property="addSendTime" jdbcType="INTEGER" /> <result column="add_send_time" property="addSendTime" jdbcType="INTEGER" />
<result column="send_hour" property="sendHour" jdbcType="VARCHAR" /> <result column="send_hour" property="sendHour" jdbcType="VARCHAR" />
<result column="progress_guidance" property="progressGuidance" jdbcType="INTEGER" /> <result column="progress_guidance" property="progressGuidance" jdbcType="INTEGER" />
<result column="item_introduce" property="itemIntroduce" jdbcType="VARCHAR" />
</resultMap> </resultMap>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
id, task_id, start_day, finish_confirm, finish_key_word, create_time, update_time,td_confirm,finish_link_introduce,finish_link_url id, task_id, start_day, finish_confirm, finish_key_word, create_time, update_time,td_confirm,finish_link_introduce,finish_link_url
,add_send_time,send_hour,progress_guidance ,add_send_time,send_hour,progress_guidance, item_introduce
</sql> </sql>
<insert id="insert" parameterType="com.pcloud.book.timecontrol.entity.TimeControlTaskItem" useGeneratedKeys="true" keyProperty="id"> <insert id="insert" parameterType="com.pcloud.book.timecontrol.entity.TimeControlTaskItem" useGeneratedKeys="true" keyProperty="id">
insert into time_control_task_item(task_id, start_day, finish_confirm, finish_key_word, create_time, update_time insert into time_control_task_item(task_id, start_day, finish_confirm, finish_key_word, create_time, update_time
,td_confirm,finish_link_introduce,finish_link_url,add_send_time,send_hour,progress_guidance) ,td_confirm,finish_link_introduce,finish_link_url,add_send_time,send_hour,progress_guidance, item_introduce)
values (#{taskId}, #{startDay}, #{finishConfirm}, #{finishKeyWord}, now(), now(),#{tdConfirm},#{finishLinkIntroduce},#{finishLinkUrl} values (#{taskId}, #{startDay}, #{finishConfirm}, #{finishKeyWord}, now(), now(),#{tdConfirm},#{finishLinkIntroduce},#{finishLinkUrl}
,#{addSendTime},#{sendHour},#{progressGuidance}) ,#{addSendTime},#{sendHour},#{progressGuidance}, #{itemIntroduce})
</insert> </insert>
<update id="updateTtaskItem" parameterType="com.pcloud.book.timecontrol.entity.TimeControlTaskItem"> <update id="updateTaskItem" parameterType="com.pcloud.book.timecontrol.entity.TimeControlTaskItem">
update time_control_task_item set start_day = #{startDay}, finish_confirm = #{finishConfirm}, finish_key_word = #{finishKeyWord}, update time_control_task_item set start_day = #{startDay}, finish_confirm = #{finishConfirm}, finish_key_word = #{finishKeyWord},
td_confirm=#{tdConfirm}, td_confirm=#{tdConfirm},
<if test="finishLinkIntroduce !=null"> <if test="finishLinkIntroduce !=null">
...@@ -40,7 +41,7 @@ ...@@ -40,7 +41,7 @@
add_send_time=#{addSendTime}, add_send_time=#{addSendTime},
send_hour=#{sendHour}, send_hour=#{sendHour},
progress_guidance=#{progressGuidance}, progress_guidance=#{progressGuidance},
update_time = now() update_time = now(), item_introduce = #{itemIntroduce}
where id = #{id} where id = #{id}
</update> </update>
...@@ -88,4 +89,13 @@ ...@@ -88,4 +89,13 @@
WHERE WHERE
task_id = #{taskId} task_id = #{taskId}
</select> </select>
<select id="listByTaskId" parameterType="Integer" resultMap="BaseResultMap">
SELECT id, task_id, start_day, finish_confirm, finish_key_word, td_confirm,finish_link_introduce,finish_link_url
,add_send_time,send_hour,progress_guidance, item_introduce
FROM
time_control_task_item
WHERE
task_id = #{taskId}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
FROM FROM
time_control_task a time_control_task a
LEFT JOIN time_control_task_item b ON a.task_id = b.task_id LEFT JOIN time_control_task_item b ON a.task_id = b.task_id
where 1=1 where 1=1 and a.type = 0
<if test="search != null"> <if test="search != null">
and task_name like concat('%', #{search}, '%') and task_name like concat('%', #{search}, '%')
</if> </if>
......
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