Commit 186a792e by 桂前礼

feat: [1004082] 自有码进h5关注公众号界面修改

parent a329de13
......@@ -2,7 +2,6 @@ package com.pcloud.book.book.constant;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.pcloud.common.constant.CacheConstant;
import java.util.Arrays;
......
package com.pcloud.book.group.biz.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.RandomUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
......@@ -69,6 +70,7 @@ import com.pcloud.book.group.dao.CopyCipherRecordDao;
import com.pcloud.book.group.dao.GroupQrcodeDao;
import com.pcloud.book.group.dao.GroupQrcodeStyleDao;
import com.pcloud.book.group.dao.JoinGroupCipherDao;
import com.pcloud.book.group.mapper.MpServiceMappingMapper;
import com.pcloud.book.group.dao.PushBookGroupUpdateDao;
import com.pcloud.book.group.dao.TempletRelevanceDao;
import com.pcloud.book.group.dao.WeixinQrcodeDao;
......@@ -180,7 +182,6 @@ import com.pcloud.book.keywords.enums.ReplyTypeEnum;
import com.pcloud.book.keywords.vo.ListKeywordVO;
import com.pcloud.book.pcloudkeyword.biz.PcloudRobotBiz;
import com.pcloud.book.pcloudkeyword.entity.PcloudRobot;
import com.pcloud.book.personalstage.enums.JumpTypeEnum;
import com.pcloud.book.push.enums.AltTypeEnum;
import com.pcloud.book.reading.dao.ReadingUserDao;
import com.pcloud.book.record.biz.BookBrowseRecordBiz;
......@@ -199,7 +200,6 @@ import com.pcloud.channelcenter.base.constants.MessageFromTypeEnum;
import com.pcloud.channelcenter.base.exceptions.ChannelBizException;
import com.pcloud.channelcenter.qrcode.dto.GroupQrcodeVO;
import com.pcloud.channelcenter.qrcode.dto.QrcodeSceneDto;
import com.pcloud.channelcenter.qrcode.entity.QrcodeStyle;
import com.pcloud.channelcenter.wechat.dto.AccountSettingDto;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.dto.MessageDto;
......@@ -299,6 +299,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
......@@ -460,6 +461,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
private ServeCollectBiz serveCollectBiz;
@Autowired
private GroupQrcodeStyleDao groupQrcodeStyleDao;
@Autowired
private MpServiceMappingMapper mpServiceMappingMapper;
private static final ThreadPoolExecutor PLATFORM_STATISTICS_EXPORT_THREAD = new ThreadPoolExecutor(2, 2,
0, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
......@@ -6182,9 +6185,49 @@ public class BookGroupBizImpl implements BookGroupBiz {
bookGroupSceneDTO.setSceneId(bookGroupDTO.getSceneId());
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneConsr.getById(bookGroupDTO.getSceneId());
bookGroupSceneDTO.setQrcodeUrl(null == qrcodeSceneDto?null:qrcodeSceneDto.getQrcodeUrl());
List<BookServeDTO> bookServeDTOS = getBookAndBookGroupServeIds(bookGroupDTO.getCreateUser(), bookGroupDTO.getBookId(), bookGroupDTO.getChannelId());
if (CollUtil.isEmpty(bookServeDTOS)) {
return bookGroupSceneDTO;
}
Map<String, Set<String>> collect = bookServeDTOS.stream().filter(Objects::nonNull).collect(
Collectors.groupingBy(BookServeDTO::getServeType,
Collectors.mapping(BookServeDTO::getFromType, Collectors.toSet()))
);
if (CollUtil.isEmpty(collect)){
return bookGroupSceneDTO;
}
if (CollUtil.isEmpty(collect.get("APP")) && CollUtil.isEmpty(collect.get("PRODUCT"))){
return bookGroupSceneDTO;
}
List<Integer> mpServices = mpServiceMappingMapper.selectMapping(collect.get("APP"),collect.get("PRODUCT"));
if (CollUtil.isEmpty(mpServices)){
mpServices = new ArrayList<>();
}
// 要求少于4个的时候要随机补成4个
fillMpServices(mpServices,0,6);
bookGroupSceneDTO.setMpServices(mpServices);
return bookGroupSceneDTO;
}
/**
* 要求少于4个的时候要随机补成4个
*
* @param mpServices 待填充列表
* @param min 随即填充的最小值 包含
* @param max 随即填充的最大值 不包含
*/
private void fillMpServices(List<Integer> mpServices, int min, int max) {
while (mpServices.size() < 4) {
int randomInt = RandomUtil.randomInt(min, max);
if (!mpServices.contains(randomInt)) {
mpServices.add(randomInt);
}
}
}
@Override
public BackgroundGroupQrcodeDTO getBackgroundGroupQr(BackgroundGroupQrcodeDTO backgroundGroupQrcodeDTO) {
BookGroup group = bookGroupDao.getById(backgroundGroupQrcodeDTO.getBookGroupId());
......
......@@ -5,6 +5,8 @@ import com.pcloud.common.dto.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @ClassName com.pcloud.book.group.dto.BookGroupSceneDTO
* @Author zhuyajie
......@@ -31,4 +33,6 @@ public class BookGroupSceneDTO extends BaseDto {
private String qrcodeUrl;
@ApiModelProperty("书名")
private String bookName;
@ApiModelProperty("公众号服务分类列表")
private List<Integer> mpServices;
}
package com.pcloud.book.group.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 公众号服务类型映射表(MpServiceMapping)实体类
*
* @author guiq
* @since 2020-12-25 10:57:45
*/
@Data
public class MpServiceMapping implements Serializable {
private static final long serialVersionUID = 597987836548361437L;
/**
* 主键ID
*/
private Long id;
/**
* 分类名称
*/
private String name;
/**
* 服务类型 APP | PRODUCT
*/
private String serverType;
/**
* 服务类型CODE
*/
private String typeCode;
/**
* 映射类型
*/
private Integer mapping;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
\ No newline at end of file
package com.pcloud.book.group.mapper;
import com.pcloud.book.group.entity.MpServiceMapping;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Set;
/**
* 公众号服务类型映射表(MpServiceMapping)表数据库访问层
*
* @author guiq
* @since 2020-12-25 10:57:45
*/
@Mapper
@Component
public interface MpServiceMappingMapper {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
MpServiceMapping queryById(Long id);
/**
* 查询指定行数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<MpServiceMapping> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit);
/**
* 通过实体作为筛选条件查询
*
* @param mpServiceMapping 实例对象
* @return 对象列表
*/
List<MpServiceMapping> queryAll(MpServiceMapping mpServiceMapping);
/**
* 新增数据
*
* @param mpServiceMapping 实例对象
* @return 影响行数
*/
int insert(MpServiceMapping mpServiceMapping);
/**
* 批量新增数据(MyBatis原生foreach方法)
*
* @param entities List<MpServiceMapping> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<MpServiceMapping> entities);
/**
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
*
* @param entities List<MpServiceMapping> 实例对象列表
* @return 影响行数
*/
int insertOrUpdateBatch(@Param("entities") List<MpServiceMapping> entities);
/**
* 修改数据
*
* @param mpServiceMapping 实例对象
* @return 影响行数
*/
int update(MpServiceMapping mpServiceMapping);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Long id);
List<Integer> selectMapping(@Param("app") Set<String> app, @Param("product") Set<String> product);
}
\ 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.group.mapper.MpServiceMappingMapper">
<resultMap type="com.pcloud.book.group.entity.MpServiceMapping" id="MpServiceMappingMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="serverType" column="server_type" jdbcType="VARCHAR"/>
<result property="typeCode" column="type_code" jdbcType="VARCHAR"/>
<result property="mapping" column="mapping" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="MpServiceMappingMap">
select id,
name,
server_type,
type_code,
mapping,
create_time,
update_time
from book.mp_service_mapping
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="MpServiceMappingMap">
select id,
name,
server_type,
type_code,
mapping,
create_time,
update_time
from book.mp_service_mapping limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="MpServiceMappingMap">
select
id, name, server_type, type_code, mapping, create_time, update_time
from book.mp_service_mapping
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="name != null and name != ''">
and name = #{name}
</if>
<if test="serverType != null and serverType != ''">
and server_type = #{serverType}
</if>
<if test="typeCode != null and typeCode != ''">
and type_code = #{typeCode}
</if>
<if test="mapping != null">
and mapping = #{mapping}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into book.mp_service_mapping(name, server_type, type_code, mapping, create_time, update_time)
values (#{name}, #{serverType}, #{typeCode}, #{mapping}, #{createTime}, #{updateTime})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into book.mp_service_mapping(name, server_type, type_code, mapping, create_time, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name}, #{entity.serverType}, #{entity.typeCode}, #{entity.mapping}, #{entity.createTime},
#{entity.updateTime})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into book.mp_service_mapping(name, server_type, type_code, mapping, create_time, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.name}, #{entity.serverType}, #{entity.typeCode}, #{entity.mapping}, #{entity.createTime},
#{entity.updateTime})
</foreach>
on duplicate key update
name = values(name) , server_type = values(server_type) , type_code = values(type_code) , mapping =
values(mapping) , create_time = values(create_time) , update_time = values(update_time)
</insert>
<!--通过主键修改数据-->
<update id="update">
update book.mp_service_mapping
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="serverType != null and serverType != ''">
server_type = #{serverType},
</if>
<if test="typeCode != null and typeCode != ''">
type_code = #{typeCode},
</if>
<if test="mapping != null">
mapping = #{mapping},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{id}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from book.mp_service_mapping
where id = #{id}
</delete>
<select id="selectMapping" resultType="java.lang.Integer">
SELECT DISTINCT mapping FROM mp_service_mapping
<where>
<if test="app !=null and app.size()>0">
( server_type = "APP" AND type_code IN
<foreach collection="app" separator="," open="(" close=")" item="item">
#{item}
</foreach>
)
</if>
<if test="product !=null and product.size()>0">OR (
server_type = "PRODUCT" AND type_code IN
<foreach collection="product" separator="," open="(" close=")" item="item">
#{item}
</foreach>
)
</if>
</where>
</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