Commit 0907a226 by 田超

Merge branch 'feature/1003892' into 'master'

feat: [1003944] 社群书二维码样式优化

See merge request rays/pcloud-book!1083
parents 2edbf97e 85296d64
......@@ -66,6 +66,7 @@ import com.pcloud.book.group.dao.BookGroupFriendGuideDao;
import com.pcloud.book.group.dao.BookGroupServeDao;
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.dao.PushBookGroupUpdateDao;
import com.pcloud.book.group.dao.TempletRelevanceDao;
......@@ -127,6 +128,7 @@ import com.pcloud.book.group.entity.BookGroupFriendGuide;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.GroupMaterialAccount;
import com.pcloud.book.group.entity.GroupQrcode;
import com.pcloud.book.group.entity.GroupQrcodeStyle;
import com.pcloud.book.group.entity.JoinGroupCipher;
import com.pcloud.book.group.entity.PushBookGroupUpdate;
import com.pcloud.book.group.entity.QrChangeRecord;
......@@ -191,11 +193,13 @@ 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;
import com.pcloud.channelcenter.wechat.vo.BookServeVO;
import com.pcloud.common.constant.CacheConstant;
import com.pcloud.common.constant.QrcodeStyleConstant;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.core.constant.ProductTypeConstant;
import com.pcloud.common.core.constant.SystemCode;
......@@ -277,6 +281,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.awt.*;
import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
......@@ -447,6 +452,8 @@ public class BookGroupBizImpl implements BookGroupBiz {
private ChannelConsr channelConsr;
@Autowired
private ServeCollectBiz serveCollectBiz;
@Autowired
private GroupQrcodeStyleDao groupQrcodeStyleDao;
private static final ThreadPoolExecutor PLATFORM_STATISTICS_EXPORT_THREAD = new ThreadPoolExecutor(2, 2,
0, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
......@@ -818,6 +825,9 @@ public class BookGroupBizImpl implements BookGroupBiz {
if (!ListUtils.isEmpty(friendGuides)) {
bookGroupDTO.setFriendGuideList(friendGuides);
}
//设置样式
GroupQrcodeStyle groupQrcodeStyle = groupQrcodeStyleDao.getQrcodeStyleByBookGroupId(bookGroupDTO.getId());
bookGroupDTO.setGroupQrcodeStyle(groupQrcodeStyle);
return bookGroupDTO;
}
......@@ -940,6 +950,23 @@ public class BookGroupBizImpl implements BookGroupBiz {
updateAppProductParamDTO.setAppProName(bookGroup.getGroupQrcodeName());
ResponseHandleUtil.parseResponse(productService.postUpdateBookGroupProduct(updateAppProductParamDTO), Product.class);
}
//设置社群码样式
//每次更新之前都重新生成
String qrcode=QrcodeUtils.createWithMargin(group.getGroupQrcodeLink(), 1);
groupQrcodeStyleDao.delQrcodeStyle(bookGroup.getId());
if(null!=bookGroup.getGroupQrcodeStyle()){
GroupQrcodeStyle groupQrcodeStyle = bookGroup.getGroupQrcodeStyle();
groupQrcodeStyle.setBookGroupId(bookGroup.getId());
groupQrcodeStyleDao.insert(groupQrcodeStyle);
//如果有颜色样式
qrcode = createQrcode(groupQrcodeStyle, group.getGroupQrcodeLink());
}
//如果有图片样式
if(null!=bookGroup.getBackgroundType() && bookGroup.getBackgroundType()>0){
qrcode= QrcodeUtils.getStyleQr(qrcode, bookGroup.getBackgroundType(), null);
}
bookGroup.setGroupQrcodeUrl(qrcode);
bookGroup.setBackgroundType(bookGroup.getBackgroundType());
bookGroupDao.update(bookGroup);
//上架
if (null != productId) {
......@@ -952,6 +979,43 @@ public class BookGroupBizImpl implements BookGroupBiz {
}
/**
* 根据二维码样式生成二维码
*
* @param qrcodeStyle
* @param qrUrl
* @return
*/
public String createQrcode(GroupQrcodeStyle qrcodeStyle, String qrUrl) {
String qrcodeUrl = "";
// 调用common 生成带图案的二维码
if (qrcodeStyle == null) {// 若未设置样式类型 ,则使用默认二维码
qrcodeUrl = QrcodeUtils.createWithMargin(qrUrl,1);
} else if (QrcodeStyleConstant.COLOR_QR.equals(qrcodeStyle.getStyleType())) {// 若为纯色二维码
qrcodeUrl = QrcodeUtils.createColorWithMargin(qrUrl, Integer.parseInt(qrcodeStyle.getOnColor().replaceAll("#", ""), 16),1);
} else if (QrcodeStyleConstant.GRADIENT_LOGO_QR.equals(qrcodeStyle.getStyleType())) {// 渐变色带logo
Color newColor = new Color(qrcodeStyle.getNewRedColor(), qrcodeStyle.getNewGreenColor(),
qrcodeStyle.getNewBlueColor());
Color oldColor = new Color(qrcodeStyle.getOldRedColor(), qrcodeStyle.getOldGreenColor(),
qrcodeStyle.getOldBlueColor());
qrcodeUrl = QrcodeUtils.createGradientColorLogoQr(qrUrl, qrcodeStyle.getLogoUrl(), newColor, oldColor,1);
} else if (QrcodeStyleConstant.COLOR_LOGO_QR.equals(qrcodeStyle.getStyleType())) {// 纯色logo
qrcodeUrl = QrcodeUtils.createLogoQr(qrUrl, qrcodeStyle.getLogoUrl(),
Integer.parseInt(qrcodeStyle.getOnColor().replaceAll("#", ""), 16),1);
} else if (QrcodeStyleConstant.GRADIENT_QR.equals(qrcodeStyle.getStyleType())) {// 渐变色二维码
Color newColor = new Color(qrcodeStyle.getNewRedColor(), qrcodeStyle.getNewGreenColor(),
qrcodeStyle.getNewBlueColor());
Color oldColor = new Color(qrcodeStyle.getOldRedColor(), qrcodeStyle.getOldGreenColor(),
qrcodeStyle.getOldBlueColor());
qrcodeUrl = QrcodeUtils.createGradientColorQr(qrUrl, newColor, oldColor,1);
} else if (QrcodeStyleConstant.LOGO_QR.equals(qrcodeStyle.getStyleType())) {// 黑白logo
qrcodeUrl = QrcodeUtils.createLogoQr(qrUrl, qrcodeStyle.getLogoUrl(), 0xFF000000,1);
} else {
qrcodeUrl = QrcodeUtils.createWithMargin(qrUrl,1);
}
return qrcodeUrl;
}
/**
* 更新群引导语
*
* @param bookGroupId
......
package com.pcloud.book.group.dao;
import com.pcloud.book.group.entity.GroupQrcodeStyle;
import com.pcloud.channelcenter.qrcode.entity.QrcodeStyle;
import com.pcloud.common.core.dao.BaseDao;
/**
* 描述 :二维码样式
*
* @author 作者: lili
* @version 1.0
* @date 创建时间:2017年6月30日 上午11:43:58
*/
public interface GroupQrcodeStyleDao extends BaseDao<GroupQrcodeStyle> {
/**
* 删除二维码样式
*
* @param bookGroupId
* 社群码id
*/
void delQrcodeStyle(Long bookGroupId);
GroupQrcodeStyle getQrcodeStyleByBookGroupId(Long bookGroupId);
}
package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.GroupQrcodeStyleDao;
import com.pcloud.book.group.entity.GroupQrcodeStyle;
import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component;
/**
* 描述 :二维码样式
*
* @author 作者: lili
* @version 1.0
* @date 创建时间:2017年6月30日 上午11:44:22
*/
@Component("groupQrcodeStyleDao")
public class GroupQrcodeStyleDaoImpl extends BaseDaoImpl<GroupQrcodeStyle> implements GroupQrcodeStyleDao {
/**
* 二维码样式
*/
@Override
public void delQrcodeStyle(Long bookGroupId) {
this.getSqlSession().delete(this.getStatement("delQrcodeStyle"), bookGroupId);
}
@Override
public GroupQrcodeStyle getQrcodeStyleByBookGroupId(Long bookGroupId) {
return this.getSqlSession().selectOne(this.getStatement("getQrcodeStyleByBookGroupId"), bookGroupId);
}
}
......@@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.pcloud.book.book.dto.BookDto;
import com.pcloud.book.group.entity.BookGroupFriendGuide;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.GroupQrcodeStyle;
import com.pcloud.common.dto.BaseDto;
import lombok.Data;
......@@ -301,6 +302,32 @@ public class BookGroupDTO extends BaseDto {
// 读者量、扫码人数
private Integer userCount;
/**
* 社群码样式
*/
private Integer backgroundType;
/**
* 二维码样色样式
*/
private GroupQrcodeStyle groupQrcodeStyle;
public GroupQrcodeStyle getGroupQrcodeStyle() {
return groupQrcodeStyle;
}
public void setGroupQrcodeStyle(GroupQrcodeStyle groupQrcodeStyle) {
this.groupQrcodeStyle = groupQrcodeStyle;
}
public Integer getBackgroundType() {
return backgroundType;
}
public void setBackgroundType(Integer backgroundType) {
this.backgroundType = backgroundType;
}
public Integer getScanCount() {
return scanCount;
}
......
......@@ -185,6 +185,32 @@ public class BookGroup extends BaseEntity {
*/
private String groupQrcodeLink;
/**
* 社群码样式
*/
private Integer backgroundType;
/**
* 二维码样色样式
*/
private GroupQrcodeStyle groupQrcodeStyle;
public GroupQrcodeStyle getGroupQrcodeStyle() {
return groupQrcodeStyle;
}
public void setGroupQrcodeStyle(GroupQrcodeStyle groupQrcodeStyle) {
this.groupQrcodeStyle = groupQrcodeStyle;
}
public Integer getBackgroundType() {
return backgroundType;
}
public void setBackgroundType(Integer backgroundType) {
this.backgroundType = backgroundType;
}
public String getGroupQrcodeLink() {
return groupQrcodeLink;
}
......
package com.pcloud.book.group.entity;
import com.pcloud.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 描述 :二维码样式
*
* @author 作者: lili
* @version 1.0
* @date 创建时间:2017年6月27日 下午2:21:52
*/
@ApiModel(description = "二维码样式实体")
@Data
public class GroupQrcodeStyle extends BaseEntity {
/**
*
*/
private static final long serialVersionUID = 295177552508858505L;
/**
* 二维码样式标识
*/
@ApiModelProperty(value = "二维码样式标识", dataType = "Long")
private Long qrcodeStyleId;
/**
* logo图
*/
@ApiModelProperty(value = "logo图", dataType = "String")
private String logoUrl;
/**
* 颜色红(原)
*/
@ApiModelProperty(value = "颜色红(原)", dataType = "Integer")
private Integer oldRedColor;
/**
* 颜色绿(原)
*/
@ApiModelProperty(value = "颜色绿(原)", dataType = "Integer")
private Integer oldGreenColor;
/**
* 颜色蓝(原)
*/
@ApiModelProperty(value = "颜色蓝(原)", dataType = "Integer")
private Integer oldBlueColor;
/**
* 颜色红
*/
@ApiModelProperty(value = "颜色红", dataType = "Integer")
private Integer newRedColor;
/**
* 颜色绿
*/
@ApiModelProperty(value = "颜色绿", dataType = "Integer")
private Integer newGreenColor;
/**
* 颜色蓝
*/
@ApiModelProperty(value = "颜色蓝", dataType = "Integer")
private Integer newBlueColor;
/**
* 前景色
*/
@ApiModelProperty(value = "前景色", dataType = "String")
private String onColor;
/**
* 样式类型
*/
@ApiModelProperty(value = "样式类型", dataType = "Integer")
private Integer styleType;
/**
* 社群码id
*/
@ApiModelProperty(value = "社群码id", dataType = "Long")
private Long bookGroupId;
}
......@@ -1553,6 +1553,7 @@
<if test="serialNumber != null">
SERIAL_NUMBER = #{serialNumber, jdbcType=VARCHAR},
</if>
edition = #{edition},
LAST_MODIFIED_DATE = NOW(),
VERSION = VERSION + 1
WHERE
......
......@@ -142,23 +142,25 @@
<select id="projectEditionAnalysis" parameterType="Long" resultType="com.pcloud.book.book.dto.EditionAnalysisListVO">
select
edition edition,
edition_year editionDate,
a.edition edition,
a.edition_year editionDate,
ifnull(count(1),0) projectCount
from book_edition
where update_user=#{adviserId}
GROUP BY edition,edition_year
ORDER BY edition_year
from book_edition a inner join book_adviser b
on a.book_id=b.book_id and a.update_user=b.adviser_id
where a.update_user=#{adviserId} and b.IS_DELETE=0
GROUP BY a.edition,a.edition_year
ORDER BY a.edition_year
</select>
<select id="projectCountSorted" parameterType="Long" resultType="com.pcloud.book.book.dto.EditionAnalysisListVO">
select
edition edition,
edition_year editionDate,
a.edition edition,
a.edition_year editionDate,
ifnull(count(1),0) projectCount
from book_edition
where update_user=#{adviserId}
GROUP BY edition_year
from book_edition a inner join book_adviser b
on a.book_id=b.book_id and a.update_user=b.adviser_id
where a.update_user=#{adviserId} and b.IS_DELETE=0
GROUP BY a.edition_year
ORDER BY projectCount desc
</select>
......
......@@ -36,6 +36,7 @@
<result column="group_qrcode_location_id" property="groupQrcodeLocationId" jdbcType="BIGINT"/>
<result column="group_qrcode_remark" property="groupQrcodeRemark" jdbcType="VARCHAR"/>
<result column="group_qrcode_link" property="groupQrcodeLink" jdbcType="VARCHAR"/>
<result column="back_ground_type" property="backgroundType" jdbcType="INTEGER" />
</resultMap>
<resultMap id="BookGroupDTO" type="com.pcloud.book.group.dto.BookGroupDTO">
......@@ -78,6 +79,7 @@
<result column="group_qrcode_location_id" property="groupQrcodeLocationId" jdbcType="BIGINT"/>
<result column="group_qrcode_remark" property="groupQrcodeRemark" jdbcType="VARCHAR"/>
<result column="group_qrcode_link" property="groupQrcodeLink" jdbcType="VARCHAR"/>
<result column="back_ground_type" property="backgroundType" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List">
......@@ -87,7 +89,7 @@
update_time, is_delete, is_show_book_name,join_group_type,add_friend_guide,customer_service_name,
is_invite_group,book_group_cipher, last_push_update_time, is_some_update, agent_id, belong_special_agent,
short_book_name, open_weapp, single_group, related_book_group_id,group_qrcode_page_num,group_qrcode_location_id,group_qrcode_remark,
group_qrcode_link
group_qrcode_link,back_ground_type
</sql>
<select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long">
......@@ -381,6 +383,9 @@
<if test="groupQrcodeLink != null">
group_qrcode_link = #{groupQrcodeLink},
</if>
<if test="backgroundType != null">
back_ground_type = #{backgroundType},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.GroupQrcodeStyleDaoImpl" >
<resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.GroupQrcodeStyle" >
<id column="QRCODE_STYLE_ID" property="qrcodeStyleId" jdbcType="BIGINT" />
<result column="book_group_id" property="bookGroupId" jdbcType="BIGINT" />
<result column="LOGO_URL" property="logoUrl" jdbcType="BIGINT" />
<result column="OLD_RED_COLOR" property="oldRedColor" jdbcType="BIGINT" />
<result column="OLD_GREEN_COLOR" property="oldGreenColor" jdbcType="BIGINT" />
<result column="OLD_BLUE_COLOR" property="oldBlueColor" jdbcType="BIGINT" />
<result column="NEW_RED_COLOR" property="newRedColor" jdbcType="BIGINT" />
<result column="NEW_GREEN_COLOR" property="newGreenColor" jdbcType="BIGINT" />
<result column="NEW_BLUE_COLOR" property="newBlueColor" jdbcType="BIGINT" />
<result column="ON_COLOR" property="onColor" jdbcType="VARCHAR" />
<result column="STYLE_TYPE" property="styleType" jdbcType="BIGINT" />
</resultMap>
<sql id="Base_Column_List" >
QRCODE_STYLE_ID, book_group_id, LOGO_URL, OLD_RED_COLOR, OLD_GREEN_COLOR,OLD_BLUE_COLOR,
NEW_RED_COLOR, NEW_GREEN_COLOR, NEW_BLUE_COLOR, ON_COLOR,STYLE_TYPE
</sql>
<!-- 删除二维码关联的样式 -->
<delete id="delQrcodeStyle" parameterType="Long">
delete from
group_qrcode_style
where book_group_id=#{bookGroupId}
</delete>
<!-- 添加二维码标签关联 -->
<insert id="insert" parameterType="com.pcloud.book.group.entity.GroupQrcodeStyle" useGeneratedKeys="true" keyProperty="qrcodeStyleId" >
insert into group_qrcode_style (book_group_id, LOGO_URL, OLD_RED_COLOR, OLD_GREEN_COLOR,
OLD_BLUE_COLOR, NEW_RED_COLOR, NEW_GREEN_COLOR,
NEW_BLUE_COLOR, ON_COLOR,STYLE_TYPE)
values (#{bookGroupId,jdbcType=BIGINT}, #{logoUrl,jdbcType=BIGINT}, #{oldRedColor,jdbcType=BIGINT},
#{oldGreenColor,jdbcType=BIGINT}, #{oldBlueColor,jdbcType=BIGINT},
#{newRedColor,jdbcType=BIGINT}, #{newGreenColor,jdbcType=BIGINT},
#{newBlueColor,jdbcType=BIGINT}, #{onColor,jdbcType=VARCHAR},#{styleType,jdbcType=BIGINT}
)
</insert>
<!-- 获取二维码关联标签 -->
<select id="getQrcodeStyleByBookGroupId" resultMap="BaseResultMap" parameterType="java.lang.Long" >
SELECT
QRCODE_STYLE_ID,
book_group_id,
LOGO_URL,
OLD_RED_COLOR,
OLD_GREEN_COLOR,
OLD_BLUE_COLOR,
NEW_RED_COLOR,
NEW_GREEN_COLOR,
NEW_BLUE_COLOR,
ON_COLOR,
STYLE_TYPE
FROM
group_qrcode_style
WHERE
book_group_id = #{bookGroupId,jdbcType=BIGINT}
limit 1
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment