Commit 50d93b7e by 高鹏

Merge branch 'feat-1001684' into 'master'

1001684平台端社群统计新增统计数据、1V1入群码优化

See merge request rays/pcloud-book!168
parents 864fcd01 36e807d6
......@@ -93,6 +93,21 @@ public class GroupQrcodeInfo4Advertising extends BaseDto {
*/
private Integer advertisingSpaceNum;
/**
* 分类id
*/
private Long classifyId;
/**
* 社群码id
*/
private Long bookGroupId;
/**
* 进群方式:1群二维码,2客服机器人
*/
private Integer joinGroupType;
public String getWxGroupId() {
return wxGroupId;
}
......@@ -245,6 +260,30 @@ public class GroupQrcodeInfo4Advertising extends BaseDto {
this.purLabelName = purLabelName;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public Integer getJoinGroupType() {
return joinGroupType;
}
public void setJoinGroupType(Integer joinGroupType) {
this.joinGroupType = joinGroupType;
}
@Override
public String toString() {
return "GroupQrcodeInfo4Advertising{" +
......@@ -267,6 +306,9 @@ public class GroupQrcodeInfo4Advertising extends BaseDto {
", agentName='" + agentName + '\'' +
", isOpen=" + isOpen +
", advertisingSpaceNum=" + advertisingSpaceNum +
'}';
", classifyId=" + classifyId +
", bookGroupId=" + bookGroupId +
", joinGroupType=" + joinGroupType +
"} " + super.toString();
}
}
......@@ -24,6 +24,7 @@ import com.pcloud.book.group.biz.BookGroupClassifyBiz;
import com.pcloud.book.group.dao.BookGroupDao;
import com.pcloud.book.group.dao.GroupQrcodeDao;
import com.pcloud.book.group.vo.ClassifyVO;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.biz.MessageBiz;
import com.pcloud.common.core.constant.SystemCode;
import com.pcloud.common.core.dto.SendNotifyDto;
......@@ -35,6 +36,8 @@ import com.pcloud.common.page.PageBeanNew;
import com.pcloud.common.page.PageParam;
import com.pcloud.common.utils.DateUtils;
import com.pcloud.common.utils.ListUtils;
import com.pcloud.common.utils.QrcodeUtils;
import com.pcloud.common.utils.cache.redis.JedisClusterUtils;
import com.pcloud.common.utils.SessionUtil;
import com.pcloud.common.utils.string.StringUtil;
import com.pcloud.common.utils.zip.CompressUtils;
......@@ -43,6 +46,7 @@ import com.pcloud.usercenter.user.entity.UserLogin;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
......@@ -87,6 +91,12 @@ public class GroupTagBizImpl implements GroupTagBiz {
private MessageBiz messageBiz;
@Autowired
private BookGroupClassifyBiz bookGroupClassifyBiz;
@Value("${wechat.group.link.prefix}")
private String wechatLinkPrefix;
/**
* 品牌方扫码进入指定群链接缓存
*/
private static final String BRAND_QRCODE_URL_REDIS = "BRAND_QRCODE_URL_REDIS";
@Autowired
private AdvertisingBrandDao advertisingBrandDao;
@Autowired
......@@ -185,9 +195,24 @@ public class GroupTagBizImpl implements GroupTagBiz {
if (!ListUtils.isEmpty(brandList)) {
groupTagDTO.setBrandList(brandList);
}
if (new Integer(2).equals(groupTagDTO.getJoinGroupType())) {
groupTagDTO.setCodeUrl(findCodeUrl(groupTagDTO.getBookGroupId(), groupTagDTO.getClassifyId(), groupTagDTO.getGroupQrcodeId()));
}
}
}
@ParamLog("获取品牌方进指定群链接")
private String findCodeUrl(Long bookGroupId, Long classifyId, Long groupQrcodeId){
//获取连接
String codeUrl = JedisClusterUtils.hget(BRAND_QRCODE_URL_REDIS, groupQrcodeId.toString());
if (codeUrl == null) {
String link = wechatLinkPrefix + "/group/info?classify_id=" + classifyId + "&book_group_id=" + bookGroupId + "&group_qrcode_id=" + groupQrcodeId;
codeUrl = QrcodeUtils.create(link);
JedisClusterUtils.hset(BRAND_QRCODE_URL_REDIS, groupQrcodeId.toString(), codeUrl);
}
return codeUrl;
}
@Override
public List<AdvertisingBrandDTO> getAllBrand() throws BizException {
List<AdvertisingBrandDTO> list = advertisingBrandDao.getAllBrand();
......@@ -365,6 +390,9 @@ public class GroupTagBizImpl implements GroupTagBiz {
groupTagDTO.setPurLabelName(labelMap.get(groupTagDTO.getPurLabelId()));
}
}
if (new Integer(2).equals(groupTagDTO.getJoinGroupType())) {
groupTagDTO.setCodeUrl(findCodeUrl(groupTagDTO.getBookGroupId(), groupTagDTO.getClassifyId(), groupTagDTO.getGroupQrcodeId()));
}
}
}
......
......@@ -109,6 +109,23 @@ public class GroupTagDTO extends BaseDto{
* isbn
*/
private String isbn;
/**
* 分类id
*/
private Long classifyId;
/**
* 社群书id
*/
private Long bookGroupId;
/**
* 进群方式:1群二维码,2客服机器人
*/
private Integer joinGroupType;
private String codeUrl;
public String getWxGroupId() {
return wxGroupId;
}
......@@ -285,6 +302,38 @@ public class GroupTagDTO extends BaseDto{
this.isbn = isbn;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public Long getBookGroupId() {
return bookGroupId;
}
public void setBookGroupId(Long bookGroupId) {
this.bookGroupId = bookGroupId;
}
public Integer getJoinGroupType() {
return joinGroupType;
}
public void setJoinGroupType(Integer joinGroupType) {
this.joinGroupType = joinGroupType;
}
public String getCodeUrl() {
return codeUrl;
}
public void setCodeUrl(String codeUrl) {
this.codeUrl = codeUrl;
}
@Override
public String toString() {
return "GroupTagDTO{" +
......
......@@ -281,6 +281,11 @@ public interface BookGroupBiz {
OwnAltQrcodeInfoDTO getOwnAltQrcodeInfoDTOByClassifyId(Long wechatUserId, Long classifyId);
/**
* 根据群二维码id获取个人二维码信息
*/
OwnAltQrcodeInfoDTO getOwnAltQrcodeInfoDTOByQrcodeId(Long wechatUserId, Long qrcodeId);
/**
* 获取暗号状态
*/
Integer getCipherState(String cipher);
......
......@@ -28,8 +28,10 @@ import com.pcloud.book.group.biz.BookGroupClassifyBiz;
import com.pcloud.book.group.dao.*;
import com.pcloud.book.group.dto.*;
import com.pcloud.book.group.entity.BookGroup;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.entity.JoinGroupCipher;
import com.pcloud.book.group.entity.TempletRelevance;
import com.pcloud.book.group.enums.CipherTypeEnum;
import com.pcloud.book.group.enums.LargTempletEnum;
import com.pcloud.book.group.vo.StatisticVO;
......@@ -192,6 +194,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
private BookConsr bookConsr;
@Autowired
private GroupQrcodeBiz groupQrcodeBiz;
@Autowired
private GroupQrcodeDao groupQrcodeDao;
......@@ -1251,6 +1255,67 @@ public class BookGroupBizImpl implements BookGroupBiz {
joinGroupCipherNew.setWechatUserId(wechatUserId);
joinGroupCipherNew.setClassifyId(classifyId);
joinGroupCipherNew.setAltId(selfRobotDTO.getWxId());
joinGroupCipherNew.setType(CipherTypeEnum.CLASSIFY_CIPHER.code);
joinGroupCipherDao.insert(joinGroupCipherNew);
}
ownAltQrcodeInfoDTO.setCipher(cipher);
return ownAltQrcodeInfoDTO;
}
@Transactional(rollbackFor = Exception.class)
@ParamLog("根据分类id获取个人二维码信息")
@Override
public OwnAltQrcodeInfoDTO getOwnAltQrcodeInfoDTOByQrcodeId(Long wechatUserId, Long qrcodeId) {
OwnAltQrcodeInfoDTO ownAltQrcodeInfoDTO = new OwnAltQrcodeInfoDTO();
GroupQrcode groupQrcode = groupQrcodeDao.getById(qrcodeId);
Long classifyId = groupQrcode.getClassifyId();
//根据分类id查询社群码信息
ClassifyDTO classifyDTO = bookGroupClassifyDao.getById(classifyId);
if (classifyDTO == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "没有该分类");
}
Long bookId = classifyDTO.getBookId();
Map<String, Object> paramMap = Maps.newHashMap();
paramMap.put("bookId", bookId);
paramMap.put("adviserId", classifyDTO.getCreateUser());
paramMap.put("channelId", classifyDTO.getChannelId());
BookDto bookDto = bookDao.getById(paramMap);
Long templetId = bookDto.getTempletId();
//根据分类id获取大类
TempletRelevance templetRelevance = templetRelevanceDao.getByTempletId(templetId);
LOGGER.info("根据分类id获取大类templetRelevance" + templetRelevance.toString());
Integer largeTemplet = templetRelevance.getLargeTemplet();
SelfRobotDTO selfRobotDTO = wechatGroupConsr.getAvailableRobot(wechatUserId, largeTemplet, classifyId);
if (selfRobotDTO == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "未找到机器人!");
}
ownAltQrcodeInfoDTO.setAltHeadUrl(selfRobotDTO.getHeadPic());
ownAltQrcodeInfoDTO.setAltId(selfRobotDTO.getWxId());
ownAltQrcodeInfoDTO.setAltNickName(selfRobotDTO.getNickName());
ownAltQrcodeInfoDTO.setAltQrcodeUrl(selfRobotDTO.getQrcodeUrl());
ownAltQrcodeInfoDTO.setAltHeadUrl(selfRobotDTO.getHeadPic());
//获取之前是否有没有使用的暗号
JoinGroupCipher joinGroupCipher = joinGroupCipherDao.getByWechatUserIdAndQrcodeId(wechatUserId, qrcodeId, CipherTypeEnum.QRCODE_CIPHER.code);
String cipher;
if (joinGroupCipher != null) {
cipher = joinGroupCipher.getCipher();
} else {
//新增暗号
cipher = UUIDUitl.generateShort();
//查重,如果有重复,再次生成
JoinGroupCipher joinGroupCipherHas = joinGroupCipherDao.getByCipher(cipher);
if (joinGroupCipherHas != null) {
cipher = UUIDUitl.generateShort();
}
cipher = "RAYS_" + cipher;
JoinGroupCipher joinGroupCipherNew = new JoinGroupCipher();
joinGroupCipherNew.setCipher(cipher);
joinGroupCipherNew.setWechatUserId(wechatUserId);
joinGroupCipherNew.setClassifyId(classifyId);
joinGroupCipherNew.setAltId(selfRobotDTO.getWxId());
joinGroupCipherNew.setQrcodeId(qrcodeId);
joinGroupCipherNew.setType(CipherTypeEnum.QRCODE_CIPHER.code);
joinGroupCipherDao.insert(joinGroupCipherNew);
}
ownAltQrcodeInfoDTO.setCipher(cipher);
......
......@@ -27,4 +27,8 @@ public interface JoinGroupCipherDao extends BaseDao<JoinGroupCipher> {
* @return
*/
BigDecimal getPayPrice(String wxId, Long qrcodeId);
JoinGroupCipher getByWechatUserIdAndQrcodeId(Long wechatUserId, Long qrcodeId, Integer type);
void updateCipher(Long id, String cipher);
}
......@@ -69,4 +69,21 @@ public class JoinGroupCipherDaoImpl extends BaseDaoImpl<JoinGroupCipher> impleme
map.put("qrcodeId", qrcodeId);
return getSessionTemplate().selectOne(getStatement("getPayPrice"), map);
}
@Override
public JoinGroupCipher getByWechatUserIdAndQrcodeId(Long wechatUserId, Long qrcodeId, Integer type) {
Map<String,Object> map=new HashMap<>();
map.put("wechatUserId",wechatUserId);
map.put("qrcodeId",qrcodeId);
map.put("type",type);
return this.getSqlSession().selectOne(this.getStatement("getByWechatUserIdAndQrcodeId"), map);
}
@Override
public void updateCipher(Long id, String cipher) {
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("cipher", cipher);
getSessionTemplate().update(getStatement("updateCipher"), map);
}
}
......@@ -32,6 +32,9 @@ public class JoinGroupCipher extends BaseEntity {
@ApiModelProperty("机器人id")
private String altId;
@ApiModelProperty("暗号类型:1群,2分类,3社群码")
private Integer type;
public String getCipher() {
return cipher;
}
......@@ -88,6 +91,14 @@ public class JoinGroupCipher extends BaseEntity {
this.altId = altId;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
@Override
public String toString() {
return "JoinGroupCipher{" +
......@@ -98,6 +109,7 @@ public class JoinGroupCipher extends BaseEntity {
", wxId='" + wxId + '\'' +
", hasUsed=" + hasUsed +
", altId='" + altId + '\'' +
", type=" + type +
"} " + super.toString();
}
}
package com.pcloud.book.group.enums;
public enum CipherTypeEnum {
/**
* 群暗号
*/
QRCODE_CIPHER(1, "群暗号"),
/**
* 分类暗号
*/
CLASSIFY_CIPHER(2, "分类暗号"),
/**
* 社群码暗号
*/
BOOK_GROUP_CIPHER(3, "社群码暗号");
public final Integer code;
public final String name;
CipherTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
}
......@@ -295,6 +295,13 @@ public interface BookGroupFacade {
@RequestParam("classifyId") Long classifyId
) throws BizException, PermissionException, JsonParseException;
@ApiOperation("根据分类id获取个人二维码")
@GetMapping("getOwnAltQrcodeInfoDTOByQrcodeId")
ResponseDto<?> getOwnAltQrcodeInfoDTOByQrcodeId(
@CookieValue("userInfo") String userInfo,
@RequestParam("qrcodeId") Long qrcodeId
) throws BizException, PermissionException, JsonParseException;
@ApiOperation("获取所有的大类")
@GetMapping("getAllLargeTemplet")
ResponseDto<?> getAllLargeTemplet(
......
......@@ -424,6 +424,20 @@ public class BookGroupFacadeImpl implements BookGroupFacade {
return new ResponseDto<>(bookGroupBiz.getOwnAltQrcodeInfoDTOByClassifyId(wechatUserId, classifyId));
}
@ApiOperation("根据群二维码id获取个人二维码")
@GetMapping("getOwnAltQrcodeInfoDTOByQrcodeId")
@Override
public ResponseDto<?> getOwnAltQrcodeInfoDTOByQrcodeId(
@CookieValue("userInfo") String userInfo,
@RequestParam("qrcodeId") Long qrcodeId
) throws BizException, PermissionException, JsonParseException {
Long wechatUserId = Cookie.getId(userInfo, Cookie._WECHAT_USER_ID);
if (qrcodeId == null) {
throw new BookBizException(BookBizException.PARAM_IS_ERROR, "分类不能为空!");
}
return new ResponseDto<>(bookGroupBiz.getOwnAltQrcodeInfoDTOByQrcodeId(wechatUserId, qrcodeId));
}
@ApiOperation("获取所有的大类")
@GetMapping("getAllLargeTemplet")
@Override
......
......@@ -21,6 +21,8 @@ import com.pcloud.book.group.dto.SendDefaultGuideMessageDTO;
import com.pcloud.book.group.dto.SendGuideMessageDTO;
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;
......@@ -122,7 +124,14 @@ public class BookGuideBizImpl implements BookGuideBiz {
}
final JoinGroupCipherDTO dto = joinGroupCipherDao.getDTOByCipher(cipher);
//获取群
final GroupQrcodeBaseInfoVO wxGroup = bookGroupClassifyBiz.getWxGroupIdByClassifyIdAndWechatId(dto.getClassifyId(), dto.getWechatUserId());
GroupQrcodeBaseInfoVO wxGroup = bookGroupClassifyBiz.getWxGroupIdByClassifyIdAndWechatId(dto.getClassifyId(), dto.getWechatUserId());
//判断是否是品牌方进具体群,如果是,从暗号表获取已经定好的群
if ((!StringUtil.isEmpty(agreeAddUserDTO.getCipher())) && agreeAddUserDTO.getCipher().contains("RAYS_")) {
JoinGroupCipher jgc = joinGroupCipherDao.getByCipher(agreeAddUserDTO.getCipher());
if (CipherTypeEnum.QRCODE_CIPHER.code.equals(jgc.getType())) {
wxGroup = groupQrcodeDao.getBaseById(jgc.getQrcodeId());
}
}
if (null == wxGroup) {
log.error("[同意加好友发送欢迎语] : bookGroupClassifyBiz.getWxGroupIdByClassifyIdAndWechatId dto:{}");
throw new BookBizException(BookBizException.ID_NOT_EXIST, "群不存在");
......
......@@ -378,11 +378,14 @@
c.create_user adviserId,
b.BOOK_NAME bookName,
c.classify classify,
c.id classifyId,
g.user_number userNumber,
g.qrcode_url qrcodeUrl,
bg.dep_label_id depLabelId,
bg.pro_label_id proLabelId,
bg.pur_label_id purLabelId,
bg.id bookGroupId,
bg.join_group_type joinGroupType,
IF (adp.is_open = 0, 0, 1) isOpen
FROM
book_group_qrcode g
......@@ -567,8 +570,11 @@
c.create_user adviserId,
b.BOOK_NAME bookName,
c.classify classify,
c.id classifyId,
q.user_number userNumber,
q.qrcode_url qrcodeUrl,
bg.id bookGroupId,
bg.join_group_type joinGroupType,
bg.dep_label_id depLabelId,
bg.pro_label_id proLabelId,
bg.pur_label_id purLabelId,
......
......@@ -12,10 +12,11 @@
<result column="wx_id" property="wxId" jdbcType="VARCHAR"/>
<result column="has_used" property="hasUsed" jdbcType="BOOLEAN"/>
<result column="alt_id" property="altId" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, cipher, classify_id, qrcode_id, create_time, wechat_user_id, update_time, wx_id, has_used, alt_id
id, cipher, classify_id, qrcode_id, create_time, wechat_user_id, update_time, wx_id, has_used, alt_id, type
</sql>
<insert id="insert" parameterType="com.pcloud.book.group.entity.JoinGroupCipher" useGeneratedKeys="true"
......@@ -28,7 +29,8 @@
create_time,
wechat_user_id,
has_used,
alt_id
alt_id,
type
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{cipher,jdbcType=VARCHAR},
......@@ -37,7 +39,8 @@
now(),
#{wechatUserId,jdbcType=BIGINT},
0,
#{altId,jdbcType=VARCHAR}
#{altId,jdbcType=VARCHAR},
#{type,jdbcType=INTEGER}
</trim>
</insert>
......@@ -102,4 +105,19 @@
AND c.wx_id = #{wxId}
</select>
<!--根据用户id和群id获取基本信息-->
<select id="getByWechatUserIdAndQrcodeId" parameterType="map" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/> from join_group_cipher
where wechat_user_id=#{wechatUserId} and
qrcode_id=#{qrcodeId} and
type=#{type} limit 1
</select>
<!--更新暗号-->
<update id="updateCipher" parameterType="map" >
update join_group_cipher set
cipher=#{cipher}
where id=#{id}
</update>
</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