Commit c4fafc09 by 阮思源

1001733 1v1模式优化,缩短路径

parent d53cd7ea
......@@ -361,4 +361,14 @@ public class WechatGroupConsr {
return map;
}
@ParamLog(value = "获取可用机器人")
public SelfRobotDTO getAvailableRobotByBookGroup(Long wechatUserId, Integer largeTemplet, Long bookGroupId) {
SelfRobotDTO selfRobotDTO = null;
try {
selfRobotDTO = ResponseHandleUtil.parseResponse(selfRobotService.getAvailableRobotByBookGroup(wechatUserId, largeTemplet, bookGroupId), SelfRobotDTO.class);
} catch (Exception e) {
log.error("获取可用机器人.[getAvailableRobotByBookGroup]:" + e.getMessage(), e);
}
return selfRobotDTO;
}
}
......@@ -1224,9 +1224,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
TempletRelevance templetRelevance = templetRelevanceDao.getByTempletId(templetId);
LOGGER.info("根据分类id获取大类templetRelevance" + templetRelevance.toString());
Integer largeTemplet = templetRelevance.getLargeTemplet();
//TODO 根据bookGroupId获取机器人
// SelfRobotDTO selfRobotDTO = wechatGroupConsr.getAvailableRobotByBookGroupId(wechatUserId, largeTemplet, bookGroupId);
SelfRobotDTO selfRobotDTO = null;
//根据bookGroupId获取机器人
SelfRobotDTO selfRobotDTO = wechatGroupConsr.getAvailableRobotByBookGroup(wechatUserId, largeTemplet, bookGroupId);
if (selfRobotDTO == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "未找到机器人!");
}
......
......@@ -148,4 +148,11 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
* 删除社群书
*/
void deleteByBookGroupId(Long bookGroupId);
/**
* 根据社群码id获取社群书基本信息(包括书籍封面isbn号)
* @param bookGroupId
* @return
*/
BookGroupDTO getBookBaseInfoById(Long bookGroupId);
}
......@@ -157,4 +157,9 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
paramMap.put("bookGroupId", bookGroupId);
super.getSqlSession().update(getStatement("deleteByBookGroupId"), paramMap);
}
@Override
public BookGroupDTO getBookBaseInfoById(Long bookGroupId) {
return this.getSqlSession().selectOne(this.getStatement("getBookBaseInfoById"), bookGroupId);
}
}
......@@ -125,4 +125,10 @@ public interface BookKeywordBiz {
*/
List<ServiceResourceDTO> getServiceByChannel(QrWeixinParam qrWeixinParam, Long wechatUserId);
/**
* 根据社群码id获取关键词列表
* @param bookGroupId
* @return
*/
List<KeywordDTO> getListByBookGroupId(Long bookGroupId);
}
......@@ -19,9 +19,12 @@ import com.pcloud.book.group.dto.JoinGroupCipherDTO;
import com.pcloud.book.group.dto.PushAddUserMessageDTO;
import com.pcloud.book.group.entity.AppTouchRecord;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.entity.JoinGroupCipher;
import com.pcloud.book.group.enums.CipherTypeEnum;
import com.pcloud.book.group.enums.TouchTypeEnum;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
import com.pcloud.book.group.vo.GroupQrcodeBaseInfoVO;
import com.pcloud.book.group.vo.ListClassifyVO;
import com.pcloud.book.keywords.biz.BookGuideBiz;
import com.pcloud.book.keywords.biz.BookKeywordBiz;
import com.pcloud.book.keywords.dao.BookGuideDao;
......@@ -102,6 +105,10 @@ public class BookGuideBizImpl implements BookGuideBiz {
private KeywordDao keywordDao;
@Autowired
private WeixinClockGroupClassifyDao weixinClockGroupClassifyDao;
/**
* 字符串切割长度
*/
private static final Integer LE = 1000;
@ParamLog("同意加好友发送欢迎语")
@Override
......@@ -118,6 +125,12 @@ public class BookGuideBizImpl implements BookGuideBiz {
log.info("[同意加好友发送欢迎语] 暗号为空 agreeAddUserDTO:{}", agreeAddUserDTO);
return;
}
// 判断是否是书的暗号,如果是,就走书的暗号流程
JoinGroupCipher joinGroupCipher = joinGroupCipherDao.getByCipher(cipher);
if (joinGroupCipher != null && joinGroupCipher.getType().equals(CipherTypeEnum.BOOK_GROUP_CIPHER.code)) {
dealByBookGroup(joinGroupCipher,agreeAddUserDTO);
return;
}
final JoinGroupCipherDTO dto = joinGroupCipherDao.getDTOByCipher(cipher);
//获取群
final GroupQrcodeBaseInfoVO wxGroup = bookGroupClassifyBiz.getWxGroupIdByClassifyIdAndWechatId(dto.getClassifyId(), dto.getWechatUserId());
......@@ -187,6 +200,109 @@ public class BookGuideBizImpl implements BookGuideBiz {
}
}
@ParamLog("按照书处理暗号回复")
private void dealByBookGroup(JoinGroupCipher joinGroupCipher, AgreeAddUserDTO agreeAddUserDTO) {
Long bookGroupId = joinGroupCipher.getBookGroupId();
BookGroupDTO bookGroupDTO = bookGroupDao.getBookBaseInfoById(bookGroupId);
String text = "";
Boolean isInviteGroup = bookGroupDTO.getIsInviteGroup();
String addFriendGuide = bookGroupDTO.getAddFriendGuide();
if (StringUtil.isEmpty(addFriendGuide)) {
text = text + addFriendGuide + "\n";
}
//获取配套关键词
List<KeywordDTO> keywordDTOS = bookKeywordBiz.getListByBookGroupId(bookGroupId);
if (!ListUtils.isEmpty(keywordDTOS)) {
text = text + "回复括号内关键词领取本书配套资源学习资料:\n";
for (KeywordDTO keywordDTO : keywordDTOS) {
if (!StringUtil.isEmpty(keywordDTO.getKeywords())) {
text = text + "【" + keywordDTO.getKeywords() + "】";
}
}
}
//邀请进群
if (isInviteGroup != null && isInviteGroup) {
//获取社群码下的分类
List<ListClassifyVO> listClassifyVOS = bookGroupClassifyBiz.listAllClassify(bookGroupId);
if (!ListUtils.isEmpty(listClassifyVOS)) {
if (listClassifyVOS.size() == 1) {
ListClassifyVO listClassifyVO = listClassifyVOS.get(0);
//如果只有一个分类
text = text + "本书还配有交流群”" + listClassifyVO.getClassify() + "“," + listClassifyVO.getClassifyIntroduce() + ",点击下方邀请链接,即可进群";
//发送欢迎语
if (text.length() > LE) {
sendTextBatch(agreeAddUserDTO, text, LE);
} else {
sendText(agreeAddUserDTO, text);
}
dealGroupInvite(agreeAddUserDTO, listClassifyVO.getId(), joinGroupCipher.getWechatUserId());
} else {
text = text + "本书还配有以下交流群,选择你想加入的微信群,回复群名称,我会拉你入群!\n";
for (ListClassifyVO listClassifyVO : listClassifyVOS) {
text = text + listClassifyVO.getClassify() + ":" + listClassifyVO.getClassifyIntroduce() + "\n";
}
//发送欢迎语
if (text.length() > LE) {
sendTextBatch(agreeAddUserDTO, text, LE);
} else {
sendText(agreeAddUserDTO, text);
}
}
}
}
}
@ParamLog("发送收到暗号后的本书介绍")
private void sendText(AgreeAddUserDTO agreeAddUserDTO, String content) {
SendTextMessageVO vo = new SendTextMessageVO();
vo.setContent(content);
vo.setCode(SendMessageTypeEnum.SELF.getCode());
vo.setWxId(agreeAddUserDTO.getRobotWxId());
vo.setAltId(agreeAddUserDTO.getRobotWxId());
vo.setWxGroupId(agreeAddUserDTO.getUserWxId());
vo.setIp(agreeAddUserDTO.getIp());
WxGroupSDK.sendTextMessage(vo);
log.info("发送收到暗号后的本书介绍 : {}", vo);
}
@ParamLog("发送收到暗号后的本书介绍")
private void sendTextBatch(AgreeAddUserDTO agreeAddUserDTO, String content, Integer le) {
List<String> contents = new ArrayList<>();
String s = content;
while (s.length() > le) {
contents.add(s.substring(0, le));
s = s.substring(le, s.length());
}
contents.add(s);
for (String sin : contents) {
sendText(agreeAddUserDTO, sin);
}
}
@ParamLog("分类群发送邀请入群链接")
private void dealGroupInvite(AgreeAddUserDTO agreeAddUserDTO, Long classifyId, Long wechatUserId) {
//获取群
final GroupQrcodeBaseInfoVO wxGroup = bookGroupClassifyBiz.getWxGroupIdByClassifyIdAndWechatId(classifyId, wechatUserId);
if (null == wxGroup) {
log.error("[同意加好友发送欢迎语] : bookGroupClassifyBiz.getWxGroupIdByClassifyIdAndWechatId dto:{}");
throw new BookBizException(BookBizException.ID_NOT_EXIST, "群不存在");
}
String wxGroupId = wxGroup.getWeixinGroupId();
//发送邀请入群
SendGroupInviteVO sendGroupInviteVO = new SendGroupInviteVO();
sendGroupInviteVO.setAltId(agreeAddUserDTO.getRobotWxId());
sendGroupInviteVO.setWxId(agreeAddUserDTO.getUserWxId());
sendGroupInviteVO.setWxGroupId(wxGroupId);
sendGroupInviteVO.setIp(agreeAddUserDTO.getIp());
WxGroupSDK.sendGroupInvite(sendGroupInviteVO);
log.info("[同意加好友发送欢迎语] 发送进群链接 sendGroupInviteVO:{}", sendGroupInviteVO);
}
@ParamLog("进群之后更新群qrCodeId")
private void updateQrcodeForCipher(String wxGroupId, String cipher, String userWxId){
log.info("根据群id查询群信息wxGroupId", wxGroupId);
......
......@@ -886,6 +886,12 @@ public class BookKeywordBizImpl implements BookKeywordBiz {
return ResponesUtils.list(messageBookVOS, ServiceResourceDTO.class);
}
@ParamLog("根据社群码id获取关键词列表")
@Override
public List<KeywordDTO> getListByBookGroupId(Long bookGroupId) {
return bookKeywordDao.getListByBookGroupId(bookGroupId);
}
@Override
public ReplyKeywordDTO getReplyKeyword(String content, String weixinGroupId, String wexinGroupName) {
ReplyKeywordDTO replyKeywordDTO = null;
......
......@@ -110,4 +110,11 @@ public interface BookKeywordDao extends BaseDao<BookKeyword> {
* @date 2019/9/11 17:24
*/
void updateRank(Long bookGroupId, Integer rank, Long partyId, Long keywordId);
/**
* 根据社群码id获取列表
* @param bookGroupId
* @return
*/
List<KeywordDTO> getListByBookGroupId(Long bookGroupId);
}
......@@ -144,4 +144,9 @@ public class BookKeywordDaoImpl extends BaseDaoImpl<BookKeyword> implements Book
paramMap.put("keywordId", keywordId);
this.getSqlSession().update(this.getStatement("updateRank"), paramMap);
}
@Override
public List<KeywordDTO> getListByBookGroupId(Long bookGroupId) {
return this.getSqlSession().selectList(this.getStatement("getListByBookGroupId"), bookGroupId);
}
}
......@@ -390,4 +390,21 @@
ORDER BY
g.create_time DESC, g.id DESC
</select>
<!--根据id获取社群码基本信息(包括书籍信息)-->
<select id="getBookBaseInfoById" parameterType="list" resultMap="BookGroupDTO">
SELECT
bg.id,
bg.book_id,
bg.group_qrcode_name,
bg.add_friend_guide,
bg.is_invite_group,
b.book_name,
b.cover_img book_img,
b.isbn
FROM
book_group bg
LEFT JOIN book b ON bg.book_id = b.BOOK_ID
where bg.id=#{bookGroupId}
</select>
</mapper>
\ No newline at end of file
......@@ -375,4 +375,23 @@
AND t2.reply_type = 4
order by t.create_time desc
</select>
<!--根据社群码id获取列表-->
<select id="getListByBookGroupId" resultType="com.pcloud.book.keywords.dto.KeywordDTO" parameterType="Long">
SELECT
k.keywords,
k.id keywordId,
bk.is_warehouse as isWarehouse,
bk.warehouse_id as warehouseId,
k.guide
FROM
book_keyword bk
JOIN
keyword k ON bk.keyword_id = k.id
WHERE
bk.is_delete = 0
AND
k.is_delete = 0
AND book_group_id = #{bookGroupId} order by bk.rank, bk.id desc
</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