Commit f0bce7f4 by xiongjiangtao

Merge remote-tracking branch 'origin/feature-chat-activity' into feature-chat-activity

parents 25b522e2 6fd5a0c7
package com.gic.haoban.manage.api.qdto.combined;
import java.io.Serializable;
public class CombinedQDTO implements Serializable {
private static final long serialVersionUID = -28454620622119889L;
/**
* 主图url
*/
private String imageUrl;
/**
* 小程序码url
*/
private String qrCodeUrl;
/**
* 展示样式
*/
private Integer showStyle;
/**
* 第一行文字
*/
private String lineOne;
/**
* 第二行文字
*/
private String lineTwo;
/**
* 1群发 2朋友圈
*/
private Integer mediaType;
/**
* 导购id(作标识)
*/
private String clerkId;
/**
* 业务id(作标识)
*/
private String businessId;
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getQrCodeUrl() {
return qrCodeUrl;
}
public void setQrCodeUrl(String qrCodeUrl) {
this.qrCodeUrl = qrCodeUrl;
}
public Integer getShowStyle() {
return showStyle;
}
public void setShowStyle(Integer showStyle) {
this.showStyle = showStyle;
}
public String getLineOne() {
return lineOne;
}
public void setLineOne(String lineOne) {
this.lineOne = lineOne;
}
public String getLineTwo() {
return lineTwo;
}
public void setLineTwo(String lineTwo) {
this.lineTwo = lineTwo;
}
public Integer getMediaType() {
return mediaType;
}
public void setMediaType(Integer mediaType) {
this.mediaType = mediaType;
}
public String getUnionString() {
return this.getImageUrl() + this.getQrCodeUrl() + this.getShowStyle() + this.getLineOne() + this.getLineTwo() + this.getMediaType();
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getBusinessId() {
return businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
}
...@@ -7,6 +7,7 @@ import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO; ...@@ -7,6 +7,7 @@ import com.gic.haoban.manage.api.dto.BatchAddMaterialDTO;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO; import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
import com.gic.haoban.manage.api.dto.MaterialCategoryDTO; import com.gic.haoban.manage.api.dto.MaterialCategoryDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO; import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import java.util.List; import java.util.List;
...@@ -85,4 +86,6 @@ public interface MaterialApiService { ...@@ -85,4 +86,6 @@ public interface MaterialApiService {
com.gic.api.base.commons.ServiceResponse<String> getMaterialIdByUrl(String wxEnterpriseId, ContentMaterialDTO dto) ; com.gic.api.base.commons.ServiceResponse<String> getMaterialIdByUrl(String wxEnterpriseId, ContentMaterialDTO dto) ;
com.gic.api.base.commons.ServiceResponse<String> getMaterialIdByCombined(String wxEnterpriseId, CombinedQDTO combinedQDTO);
} }
...@@ -229,6 +229,18 @@ ...@@ -229,6 +229,18 @@
<artifactId>gic-member-ext-api</artifactId> <artifactId>gic-member-ext-api</artifactId>
<version>${gic-member-ext-api}</version> <version>${gic-member-ext-api}</version>
</dependency> </dependency>
<dependency>
<groupId>net.coobird</groupId>
<artifactId>thumbnailator</artifactId>
<version>0.4.8</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.6.2</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -189,6 +189,9 @@ public class JoinRuleManager { ...@@ -189,6 +189,9 @@ public class JoinRuleManager {
FunctionWithException<GroupChatActivityHmQDTO, List<GroupChatHmBO>> handler = ruleHandlers.get(ruleEnum); FunctionWithException<GroupChatActivityHmQDTO, List<GroupChatHmBO>> handler = ruleHandlers.get(ruleEnum);
if (handler != null) { if (handler != null) {
List<GroupChatHmBO> apply = handler.apply(activityHmQDTO); List<GroupChatHmBO> apply = handler.apply(activityHmQDTO);
if (apply == null) {
apply = new ArrayList<>();
}
logger.info("规则:{},获取活码数:{}", ruleEnum.desc, apply.size()); logger.info("规则:{},获取活码数:{}", ruleEnum.desc, apply.size());
return apply; return apply;
} }
......
package com.gic.haoban.manage.service.context.combined;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigChangeListener;
import com.ctrip.framework.apollo.ConfigService;
import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.gic.commons.util.TraceIdUtil;
import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import com.gic.haoban.manage.service.util.ApolloUtils;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.Iterator;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* Created by wangzubo on 2024/10/27.
*/
public class ImageCombined {
private static final String APPLICATION = "application";
private static final Logger logger = LoggerFactory.getLogger(ImageCombined.class);
private static final Cache<String, BufferedImage> imageCache = Caffeine.newBuilder()
.maximumWeight(50 * 1024 * 1024) // 50MB
.weigher((String key, BufferedImage image) -> image.getWidth() * image.getHeight() / 4)
.expireAfterAccess(30, TimeUnit.MINUTES) // 可设置失效时间
.build();
public static final ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(
ApolloUtils.combinedCorePoolSize(),
ApolloUtils.combinedMaximumPoolSize(),
60L,
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(40),
new ThreadPoolExecutor.AbortPolicy()
);
private static void refreshThreadPool(ConfigChangeEvent changeEvent) {
if (!StringUtils.equals(changeEvent.getNamespace(), APPLICATION)) {
return;
}
TraceIdUtil.traceBegin(TraceIdUtil.EntranceType.QUARTZ);
ConfigChange combinedCorePoolSizeChange = changeEvent.getChange("combinedCorePoolSize");
ConfigChange combinedMaximumPoolSizeChange = changeEvent.getChange("combinedMaximumPoolSize");
if ((combinedCorePoolSizeChange != null && combinedCorePoolSizeChange.getNewValue() != null)
|| (combinedMaximumPoolSizeChange != null && combinedMaximumPoolSizeChange.getNewValue() != null)) {
Integer corePoolSize = ApolloUtils.combinedCorePoolSize();
Integer maximumPoolSize = ApolloUtils.combinedMaximumPoolSize();
logger.info("动态调整线程池corePoolSize:{},maximumPoolSize:{}", corePoolSize, maximumPoolSize);
EXECUTOR.setCorePoolSize(corePoolSize);
EXECUTOR.setMaximumPoolSize(maximumPoolSize);
}
TraceIdUtil.traceEnd();
}
public static final String IMAGE_REDIS_KEY = "haoban-manage3-service:combined_image:";
private static final int MAX_HEIGHT_NO_WHITE_SPACE = 1500;
private static final int MAX_HEIGHT_WITH_WHITE_SPACE = 1340;
private static final int MIN_WIDTH = 500;
private static final int WHITE_SPACE_HEIGHT = 160;
private static final int QR_WIDTH_REFERENCE = 136;
private static final String LARGE_IMAGE_URL = "https://revan-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-29dd73e4f9fb4a9eaf38ae1a3158bc91.jpg?imageView2/2/w/1080/h/10800/format/jpg";
private static final String QR_CODE_URL = "https://gicinner-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-4ffc77073ca1476fb264bf1be9f11383.png";
private static final String STORE_NAME = "杭州大厦";
private static final String GUIDE_NAME = "翁坚鹏为您推荐";
private static final String OUTPUT_PATH = "/Users/wang/Downloads/output_image6.jpg";
static {
ImageIO.scanForPlugins(); // 初始化图像插件
Config config = ConfigService.getAppConfig();
config.addChangeListener(ImageCombined::refreshThreadPool);
}
public static void main(String[] args) throws Exception{
BufferedImage largeImage = loadImageWithCache(LARGE_IMAGE_URL);
BufferedImage qrCodeImage = ImageIO.read(new URL(QR_CODE_URL));
int showStyle = 0;
BufferedImage combinedImage = generateImage(largeImage, qrCodeImage, showStyle,STORE_NAME, GUIDE_NAME);
ImageIO.write(combinedImage, "jpg", new File(OUTPUT_PATH));
}
public static byte[] getCombinedImage(CombinedQDTO combinedQDTO) throws Exception{
String imageUrl = combinedQDTO.getImageUrl();
String qrCodeUrl = combinedQDTO.getQrCodeUrl();
Integer showStyle = combinedQDTO.getShowStyle();
String lineOne = combinedQDTO.getLineOne();
String lineTwo = combinedQDTO.getLineTwo();
if(imageUrl.contains("?")) {
logger.info("url有参数={}",imageUrl);
imageUrl = imageUrl.split("\\?")[0] ;
}
//压缩图片的参数
imageUrl = imageUrl + "?imageView2/2/w/1080/h/10800/format/jpg";
logger.info("加载要合成的图片开始1");
BufferedImage largeImage = loadImageWithCache(imageUrl);
logger.info("加载要合成的图片开始2");
BufferedImage qrCodeImage = loadImageWithReader(qrCodeUrl);
logger.info("加载要合成的图片结束");
if (largeImage == null || qrCodeImage == null) {
return null;
}
BufferedImage combinedImage = generateImage(largeImage, qrCodeImage, showStyle, lineOne, lineTwo);
if (combinedImage == null) {
return null;
}
// ImageIO.write(combinedImage, "jpg", new File(OUTPUT_PATH));
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
ImageIO.write(combinedImage, "jpg", baos);
// 返回字节数组
return baos.toByteArray();
}finally {
qrCodeImage.flush();
combinedImage.flush();
}
}
private static BufferedImage loadImageWithReader(String url) {
try {
URL imageUrl = new URL(url);
try (InputStream inputStream = imageUrl.openStream();
ImageInputStream imageInputStream = ImageIO.createImageInputStream(inputStream)) {
Iterator<ImageReader> readers = ImageIO.getImageReaders(imageInputStream);
if (readers.hasNext()) {
ImageReader reader = readers.next();
reader.setInput(imageInputStream, true);
return reader.read(0);
}
}
} catch (IOException e) {
logger.error("读取异常: {}", url, e);
}
return null;
}
/**
* 从缓存中加载图像
*/
private static BufferedImage loadImageWithCache(String url) {
return imageCache.get(url, key -> {
try {
logger.info("加载图片buffered:{},key:{}", url, key);
return loadImageWithReader(key); // 使用读取器方法
} catch (Exception e) {
logger.error("获取图片异常", e);
return null;
}
});
}
private static BufferedImage generateImage(BufferedImage image, BufferedImage qrCode, int showStyle,String lineOne,String lineTwo){
logger.info("合成图片开始");
int width = image.getWidth();
int height = image.getHeight();
int qrWidth = QR_WIDTH_REFERENCE;
if (showStyle == 1) {
if (height > MAX_HEIGHT_NO_WHITE_SPACE) {
width = width * MAX_HEIGHT_NO_WHITE_SPACE / height;
height = MAX_HEIGHT_NO_WHITE_SPACE;
}
} else {
if (height > MAX_HEIGHT_WITH_WHITE_SPACE) {
width = width * MAX_HEIGHT_WITH_WHITE_SPACE / height;
height = MAX_HEIGHT_WITH_WHITE_SPACE;
}
width = Math.max(width, MIN_WIDTH);
}
int finalHeight = height + (showStyle == 1 ? 0 : WHITE_SPACE_HEIGHT);
BufferedImage resizedQRCode = null;
BufferedImage resizedImage = null;
try {
BufferedImage combinedImage = new BufferedImage(width, finalHeight, BufferedImage.TYPE_INT_RGB);
if (showStyle == 1) {
qrWidth = width * QR_WIDTH_REFERENCE / 750;
}
resizedQRCode = Thumbnails.of(qrCode).size(qrWidth, qrWidth).asBufferedImage();
resizedImage = Thumbnails.of(image).size(width, height).asBufferedImage();
Graphics2D g = combinedImage.createGraphics();
g.setColor(Color.WHITE);
g.drawImage(resizedImage, 0, 1, null);
if (showStyle == 1) {
// 不需要留白时,QR码距离底部20px
g.drawImage(resizedQRCode, width - qrWidth - 20, finalHeight - qrWidth - 20, null);
} else {
// 需要留白时
addWhiteSpace(g, width, finalHeight, resizedQRCode, qrWidth, lineOne, lineTwo);
}
g.dispose();
logger.info("合成图片结束");
return combinedImage;
} catch (Exception e) {
logger.error("生成合成图像时发生异常:", e);
return null;
} finally {
if (resizedQRCode != null) {
resizedQRCode.flush();
}
if (resizedImage != null) {
resizedImage.flush();
}
}
}
private static void addWhiteSpace(Graphics2D g, int width, int finalHeight, BufferedImage qrCode, int qrWidth,String lineOne,String lineTwo) {
// 添加白色背景
g.setColor(Color.WHITE);
g.fillRect(0, finalHeight - WHITE_SPACE_HEIGHT, width, WHITE_SPACE_HEIGHT);
// 添加门店名称,距底部88px
g.setColor(new Color(36, 40, 53));
g.setFont(new Font("Arial", Font.PLAIN, 30));
drawSingleLineText(g, lineOne, 30, finalHeight - WHITE_SPACE_HEIGHT + 72, width - 196); // 留出左右边距
// 添加推荐人信息,距底部40px
g.setColor(new Color(151, 155, 165));
g.setFont(new Font("Arial", Font.PLAIN, 26));
drawSingleLineText(g, lineTwo, 30, finalHeight - WHITE_SPACE_HEIGHT + 120, width - 196); // 留出左右边距
// 添加二维码,距底部12px
int qrBottomPadding = 12;
g.drawImage(qrCode, width - qrWidth - qrBottomPadding, finalHeight - qrWidth - qrBottomPadding, null);
}
private static void drawSingleLineText(Graphics2D g, String text, int x, int y, int maxWidth) {
FontMetrics metrics = g.getFontMetrics(g.getFont());
String truncatedText = text;
// 计算文本宽度并进行截断
if (metrics.stringWidth(text) > maxWidth) {
while (metrics.stringWidth(truncatedText + "...") > maxWidth && !truncatedText.isEmpty()) {
truncatedText = truncatedText.substring(0, truncatedText.length() - 2);
}
truncatedText += "..."; // 添加省略号
}
g.drawString(truncatedText, x, y);
}
}
package com.gic.haoban.manage.service.pojo.bo.chat; package com.gic.haoban.manage.service.pojo.bo.chat;
import com.gic.haoban.manage.api.dto.chat.GroupChatActivityDTO; import java.util.Date;
import com.gic.haoban.manage.service.entity.chat.TabGroupChatUser;
/** /**
* Created by wangzubo on 2024/10/9. * Created by wangzubo on 2024/10/9.
...@@ -33,6 +32,11 @@ public class GroupChatActivityBaseContext { ...@@ -33,6 +32,11 @@ public class GroupChatActivityBaseContext {
*/ */
private String uniqueId; private String uniqueId;
/**
* 最后一次访问邀请页时间
*/
private Date lastShareTime;
public Long getChatUserId() { public Long getChatUserId() {
return chatUserId; return chatUserId;
} }
...@@ -72,4 +76,12 @@ public class GroupChatActivityBaseContext { ...@@ -72,4 +76,12 @@ public class GroupChatActivityBaseContext {
public void setUniqueId(String uniqueId) { public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId; this.uniqueId = uniqueId;
} }
public Date getLastShareTime() {
return lastShareTime;
}
public void setLastShareTime(Date lastShareTime) {
this.lastShareTime = lastShareTime;
}
} }
...@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service; ...@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service;
import com.gic.api.base.commons.JSONResponse; import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.dto.ContentMaterialDTO; import com.gic.haoban.manage.api.dto.ContentMaterialDTO;
import com.gic.haoban.manage.api.dto.MaterialDTO; import com.gic.haoban.manage.api.dto.MaterialDTO;
import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import java.util.List; import java.util.List;
...@@ -59,4 +60,7 @@ public interface MaterialService { ...@@ -59,4 +60,7 @@ public interface MaterialService {
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) ; public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) ;
List<MaterialDTO> listContentMaterialByIds(List<String> materialIds,Integer mediaType); List<MaterialDTO> listContentMaterialByIds(List<String> materialIds,Integer mediaType);
JSONResponse getMaterialIdByCombined(String wxEnterpriseId, CombinedQDTO combinedQDTO);
} }
...@@ -110,7 +110,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -110,7 +110,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
return; return;
} }
List<String> unionIdList = chatUserList.stream().map(TabGroupChatUser::getUnionid).collect(Collectors.toList()); List<String> unionIdList = chatUserList.stream().map(TabGroupChatUser::getUnionid).collect(Collectors.toList());
List<List<String>> partition = Lists.partition(unionIdList, 1000); List<List<String>> partition = Lists.partition(unionIdList, 100);
for (List<String> unionIds : partition) { for (List<String> unionIds : partition) {
List<TabGroupChatActivityShareBind> shareBindList = groupChatActivityShareBindService.query24Record(unionIds); List<TabGroupChatActivityShareBind> shareBindList = groupChatActivityShareBindService.query24Record(unionIds);
if (CollectionUtils.isEmpty(shareBindList)) { if (CollectionUtils.isEmpty(shareBindList)) {
...@@ -120,6 +120,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -120,6 +120,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
Map<String, List<TabGroupChatActivityShareBind>> map = shareBindList.stream().collect(Collectors.groupingBy(TabGroupChatActivityShareBind::getInviteeUnionId)); Map<String, List<TabGroupChatActivityShareBind>> map = shareBindList.stream().collect(Collectors.groupingBy(TabGroupChatActivityShareBind::getInviteeUnionId));
for (TabGroupChatUser groupChatUser : chatUserList) { for (TabGroupChatUser groupChatUser : chatUserList) {
Long chatUserId = groupChatUser.getChatUserId(); Long chatUserId = groupChatUser.getChatUserId();
Date joinTime = groupChatUser.getJoinTime();
String unionid = groupChatUser.getUnionid(); String unionid = groupChatUser.getUnionid();
List<TabGroupChatActivityShareBind> list = map.get(unionid); List<TabGroupChatActivityShareBind> list = map.get(unionid);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
...@@ -128,6 +129,10 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -128,6 +129,10 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
Set<Long> chatActivityIdSet = new HashSet<>(); Set<Long> chatActivityIdSet = new HashSet<>();
//同个活动取最近一条绑定信息 //同个活动取最近一条绑定信息
for (TabGroupChatActivityShareBind shareBind : list) { for (TabGroupChatActivityShareBind shareBind : list) {
if (DateUtil.compare(shareBind.getCreateTime(),joinTime) >= 0) {
logger.info("分享绑定时间大于入群时间 过滤");
continue;
}
Long chatActivityId = shareBind.getChatActivityId(); Long chatActivityId = shareBind.getChatActivityId();
if (chatActivityIdSet.add(chatActivityId)) { if (chatActivityIdSet.add(chatActivityId)) {
GroupChatActivityBaseContext chatActivityContext = new GroupChatActivityBaseContext(); GroupChatActivityBaseContext chatActivityContext = new GroupChatActivityBaseContext();
...@@ -136,7 +141,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -136,7 +141,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
chatActivityContext.setInviterMemberId(shareBind.getInviterMemberId()); chatActivityContext.setInviterMemberId(shareBind.getInviterMemberId());
chatActivityContext.setEnterpriseId(shareBind.getEnterpriseId()); chatActivityContext.setEnterpriseId(shareBind.getEnterpriseId());
chatActivityContext.setUniqueId(shareBind.getInviteeUnionId()); chatActivityContext.setUniqueId(shareBind.getInviteeUnionId());
// todo 社群邀请-mq异步 chatActivityContext.setLastShareTime(shareBind.getCreateTime());
// groupChatInvite(chatActivityContext); // groupChatInvite(chatActivityContext);
try { try {
GICMQClientUtil.getClientInstance().sendMessage("shareGroupChatInviteMQ",JSON.toJSONString(chatActivityContext)); GICMQClientUtil.getClientInstance().sendMessage("shareGroupChatInviteMQ",JSON.toJSONString(chatActivityContext));
...@@ -179,7 +184,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -179,7 +184,7 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
Integer inviteType = Constant.FLAG_FALSE; Integer inviteType = Constant.FLAG_FALSE;
int batchNumber = -1; int batchNumber = -1;
Integer invalidInviteType = getActivityEffective(context); Integer invalidInviteType = getActivityEffective(context);
logger.info("获取本次入群有效状态:{}", invalidInviteType); logger.info("获取本次入群有效状态:{},{}", invalidInviteType,ChatActivityInvalidInviteTypeEnum.getDescByValue(invalidInviteType));
if (invalidInviteType == null) { if (invalidInviteType == null) {
inviteType = Constant.FLAG_TRUE; inviteType = Constant.FLAG_TRUE;
//获取奖励批次 //获取奖励批次
...@@ -249,6 +254,11 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -249,6 +254,11 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
return false; return false;
} }
} }
String memberId = chatUser.getMemberId();
if (Objects.equals(memberId, context.getInviterMemberId())) {
logger.info("无法邀请自己");
return false;
}
TabGroupChatActivityInviteLog inviteLog = new TabGroupChatActivityInviteLog(); TabGroupChatActivityInviteLog inviteLog = new TabGroupChatActivityInviteLog();
inviteLog.setChatActivityId(context.getChatActivityId()); inviteLog.setChatActivityId(context.getChatActivityId());
inviteLog.setInviteeUserId(chatUser.getUserId()); inviteLog.setInviteeUserId(chatUser.getUserId());
...@@ -271,8 +281,10 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -271,8 +281,10 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
private Integer getActivityEffective(GroupChatActivityContext context) { private Integer getActivityEffective(GroupChatActivityContext context) {
GroupChatActivityDTO activity = context.getChatActivityDTO(); GroupChatActivityDTO activity = context.getChatActivityDTO();
String enterpriseId = activity.getEnterpriseId(); String enterpriseId = activity.getEnterpriseId();
String userId = context.getChatUser().getUserId(); TabGroupChatUser chatUser = context.getChatUser();
String userId = chatUser.getUserId();
Long chatActivityId = context.getChatActivityId(); Long chatActivityId = context.getChatActivityId();
Date lastShareTime = context.getLastShareTime();
Integer inviteType = activity.getInviteType(); Integer inviteType = activity.getInviteType();
TabGroupChatActivityInviteLog inviteLog = new TabGroupChatActivityInviteLog(); TabGroupChatActivityInviteLog inviteLog = new TabGroupChatActivityInviteLog();
inviteLog.setChatActivityId(chatActivityId); inviteLog.setChatActivityId(chatActivityId);
...@@ -285,11 +297,17 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI ...@@ -285,11 +297,17 @@ public class GroupChatActivityInviteLogServiceImpl implements GroupChatActivityI
if (Objects.equals(ChatActivityInviteTypeEnum.NONE_GROUP_CHAT.value, inviteType)) { if (Objects.equals(ChatActivityInviteTypeEnum.NONE_GROUP_CHAT.value, inviteType)) {
List<TabGroupChatUser> chatUserList = groupChatUserMapper.listByUserId(enterpriseId, userId, 1); List<TabGroupChatUser> chatUserList = groupChatUserMapper.listByUserId(enterpriseId, userId, 1);
if (CollectionUtils.isNotEmpty(chatUserList)) { if (CollectionUtils.isNotEmpty(chatUserList)) {
// 入群时间在访问分享页之前的才算无效入群
chatUserList = chatUserList.stream().filter(u -> DateUtil.compare(lastShareTime, u.getJoinTime()) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(chatUserList)) {
return ChatActivityInvalidInviteTypeEnum.TWO.value; return ChatActivityInvalidInviteTypeEnum.TWO.value;
} }
} }
}
if (Objects.equals(ChatActivityInviteTypeEnum.FIRST_GROUP_CHAT.value, inviteType)) { if (Objects.equals(ChatActivityInviteTypeEnum.FIRST_GROUP_CHAT.value, inviteType)) {
List<TabGroupChatUser> chatUserList2 = groupChatUserMapper.listByUserId(enterpriseId, userId, null); List<TabGroupChatUser> chatUserList2 = groupChatUserMapper.listByUserId(enterpriseId, userId, null);
// 入群时间在访问分享页之前的才算无效入群
chatUserList2 = chatUserList2.stream().filter(u -> DateUtil.compare(lastShareTime, u.getJoinTime()) >= 0).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(chatUserList2)) { if (CollectionUtils.isNotEmpty(chatUserList2)) {
return ChatActivityInvalidInviteTypeEnum.THREE.value; return ChatActivityInvalidInviteTypeEnum.THREE.value;
} }
......
...@@ -6,9 +6,10 @@ import java.util.*; ...@@ -6,9 +6,10 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.HttpClient; import com.gic.commons.util.HttpClient;
import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import com.gic.haoban.manage.service.context.combined.ImageCombined;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
...@@ -345,4 +346,38 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -345,4 +346,38 @@ public class MaterialServiceImpl implements MaterialService {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return materialDTOS; return materialDTOS;
} }
@Override
public JSONResponse getMaterialIdByCombined(String wxEnterpriseId, CombinedQDTO combinedQDTO) {
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
JSONResponse jsonResponse = new JSONResponse();
jsonResponse.setErrorCode(9999);
jsonResponse.setErrorMessage("获取媒体id失败");
try {
String[] arr = null ;
String imageUrl = combinedQDTO.getImageUrl();
//合成图片
byte[] combinedImageData = ImageCombined.getCombinedImage(combinedQDTO);
if (combinedImageData == null) {
logger.info("合成图片的数据为空");
return jsonResponse;
}
if(imageUrl.contains("?")) {
arr = imageUrl.split("\\?")[0].split("/") ;
}else {
arr = imageUrl.split("/");
}
JSONResponse json = null;
Integer mediaType = combinedQDTO.getMediaType();
if (Objects.equals(1,mediaType)) {
json = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), combinedImageData, arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(), qwDTO.isSelf(), qwDTO.getUrlHost());
}else if (Objects.equals(2,mediaType)) {
json = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), qwDTO.getSelf3thSecret(), combinedImageData, arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(), qwDTO.isSelf(), qwDTO.getUrlHost());
}
return json;
} catch (Exception e) {
logger.info("合成图片获取媒体id异常",e);
return jsonResponse;
}
}
} }
package com.gic.haoban.manage.service.service.out.impl; package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList; import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.*;
import java.util.Collections; import java.util.concurrent.Callable;
import java.util.Date; import java.util.concurrent.Future;
import java.util.List; import java.util.concurrent.TimeUnit;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import cn.hutool.core.collection.ListUtil; import com.gic.commons.util.TraceIdUtil;
import com.gic.dubbo.entity.ProviderLocalTag;
import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import com.gic.haoban.manage.service.context.combined.ImageCombined;
import com.gic.redis.data.util.RedisUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.bouncycastle.crypto.MacDerivationFunction;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -41,7 +45,6 @@ import com.gic.haoban.manage.service.service.MaterialCategoryService; ...@@ -41,7 +45,6 @@ import com.gic.haoban.manage.service.service.MaterialCategoryService;
import com.gic.haoban.manage.service.service.MaterialService; import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.MiniprogramSettingService; import com.gic.haoban.manage.service.service.MiniprogramSettingService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.wechat.api.enums.QywxMediaTypeEnum; import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -516,4 +519,46 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -516,4 +519,46 @@ public class MaterialApiServiceImpl implements MaterialApiService {
String materialId = materialIdList.get(0) ; String materialId = materialIdList.get(0) ;
return com.gic.api.base.commons.ServiceResponse.success(materialId) ; return com.gic.api.base.commons.ServiceResponse.success(materialId) ;
} }
@Override
public com.gic.api.base.commons.ServiceResponse<String> getMaterialIdByCombined(String wxEnterpriseId, CombinedQDTO combinedQDTO) {
if (StringUtils.isAnyBlank(combinedQDTO.getImageUrl(), combinedQDTO.getQrCodeUrl())) {
return com.gic.api.base.commons.ServiceResponse.failure("9999","参数异常") ;
}
logger.info("请求合成图片并上传企微:{}",JSON.toJSONString(combinedQDTO));
String unionString = combinedQDTO.getUnionString();
String key = ImageCombined.IMAGE_REDIS_KEY + wxEnterpriseId + ":" + UUID.nameUUIDFromBytes(unionString.getBytes(StandardCharsets.UTF_8));
String cache = (String)RedisUtil.getCache(key);
if (StringUtils.isNotBlank(cache)) {
return com.gic.api.base.commons.ServiceResponse.success(cache);
}
ProviderLocalTag localTag = ProviderLocalTag.tag.get();
String traceId = localTag.traceId;
Future<JSONResponse> future = null;
JSONResponse json = null;
try {
future = ImageCombined.EXECUTOR.submit(() -> {
TraceIdUtil.traceBegin(TraceIdUtil.EntranceType.THREAD_POOL);
logger.info("线程池合成图片clerkId:{},businessId:{},traceId:{}", combinedQDTO.getClerkId(), combinedQDTO.getBusinessId(), traceId);
JSONResponse jr = materialService.getMaterialIdByCombined(wxEnterpriseId, combinedQDTO);
TraceIdUtil.traceEnd();
return jr;
});
json = future.get();
if (json == null) {
return com.gic.api.base.commons.ServiceResponse.failure("9999", "获取图片失败,请稍后再试");
}
if (json.getErrorCode() == 0) {
String mediaId= json.getResult().toString() ;
logger.info("设置缓存key:{},value:{}", key, mediaId);
RedisUtil.setCache(key, mediaId, 1L, TimeUnit.DAYS);
return com.gic.api.base.commons.ServiceResponse.success(mediaId) ;
}else {
return com.gic.api.base.commons.ServiceResponse.failure("9999",json.getErrorMessage()) ;
}
} catch (Exception e) {
logger.info("获取素材id失败", e);
return com.gic.api.base.commons.ServiceResponse.failure("9999", "获取图片失败,请稍后再试");
}
}
} }
...@@ -56,9 +56,6 @@ public class GroupChatActivityShareApiServiceImpl implements GroupChatActivitySh ...@@ -56,9 +56,6 @@ public class GroupChatActivityShareApiServiceImpl implements GroupChatActivitySh
activityHmQDTO.getInviterMemberId()) || activityHmQDTO.getChatActivityId() == null) { activityHmQDTO.getInviterMemberId()) || activityHmQDTO.getChatActivityId() == null) {
return ServiceResponse.failure("500", "参数异常"); return ServiceResponse.failure("500", "参数异常");
} }
if (Objects.equals(activityHmQDTO.getInviterMemberId(), activityHmQDTO.getInviteeMemberId())) {
return ServiceResponse.failure("500", "无法邀请自己");
}
try { try {
List<GroupChatHmBO> hmBOList = groupChatActivityService.listGroupChatHm(activityHmQDTO); List<GroupChatHmBO> hmBOList = groupChatActivityService.listGroupChatHm(activityHmQDTO);
return ServiceResponse.success(EntityUtil.changeEntityListNew(GroupChatHmDTO.class,hmBOList)); return ServiceResponse.success(EntityUtil.changeEntityListNew(GroupChatHmDTO.class,hmBOList));
......
...@@ -3,6 +3,8 @@ package com.gic.haoban.manage.service.util; ...@@ -3,6 +3,8 @@ package com.gic.haoban.manage.service.util;
import com.ctrip.framework.apollo.Config; import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService; import com.ctrip.framework.apollo.ConfigService;
import java.util.Map;
public class ApolloUtils { public class ApolloUtils {
/** /**
...@@ -14,4 +16,24 @@ public class ApolloUtils { ...@@ -14,4 +16,24 @@ public class ApolloUtils {
String messageCenterSwitch = config.getProperty("messageCenterSwitch", "0"); String messageCenterSwitch = config.getProperty("messageCenterSwitch", "0");
return "1".equals(messageCenterSwitch); return "1".equals(messageCenterSwitch);
} }
/**
* 线程池核心线程数
* @return
*/
public static Integer combinedCorePoolSize() {
Config config = ConfigService.getAppConfig();
String corePoolSize = config.getProperty("combinedCorePoolSize", "20");
return Integer.parseInt(corePoolSize);
}
/**
* 线程池最大线程数
* @return
*/
public static Integer combinedMaximumPoolSize() {
Config config = ConfigService.getAppConfig();
String maximumPoolSize = config.getProperty("combinedMaximumPoolSize", "40");
return Integer.parseInt(maximumPoolSize);
}
} }
...@@ -216,6 +216,7 @@ ...@@ -216,6 +216,7 @@
and status_flag = #{statusFlag} and status_flag = #{statusFlag}
</if> </if>
and delete_flag = 0 and delete_flag = 0
order by join_time asc,chat_user_id asc
</select> </select>
<select id="listByExternalUseridForMatch" resultMap="result-map-tabHaobanGroupChatUser"> <select id="listByExternalUseridForMatch" resultMap="result-map-tabHaobanGroupChatUser">
......
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.dto.WxEnterpriseQwDTO;
import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import com.gic.haoban.manage.service.context.combined.ImageCombined;
import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class QWmediaTest {
private static Logger logger = LoggerFactory.getLogger(QWmediaTest.class);
@Autowired
private QywxSuiteApiService qywxSuiteApiService ;
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private MaterialService materialService;
private static final String LARGE_IMAGE_URL = "https://jhdm-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-4582434f589b494aa4f27df6e3aa3770.png?imageView2/2/w/1080/h/10800/format/jpg";
private static final String QR_CODE_URL = "https://gicinner-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-4ffc77073ca1476fb264bf1be9f11383.png";
private static final String STORE_NAME = "门店CCA";
private static final String GUIDE_NAME = "宇智222";
@Test
public void test() throws Exception{
CombinedQDTO combinedQDTO = new CombinedQDTO();
combinedQDTO.setImageUrl(LARGE_IMAGE_URL);
combinedQDTO.setQrCodeUrl(QR_CODE_URL);
combinedQDTO.setShowStyle(1);
combinedQDTO.setLineOne(STORE_NAME);
combinedQDTO.setLineTwo(GUIDE_NAME);
JSONResponse json = materialService.getMaterialIdByCombined("b18ffdc9d0644912865a248859914d80", combinedQDTO);
System.out.println(JSON.toJSONString(json));
}
public static void main(String[] args) {
int TOTAL_REQUESTS = 1800; // 总请求数
List<String> list = FileUtil.readLines("/Users/wang/Downloads/image.txt", "UTF-8");
List<String> qrList = FileUtil.readLines("/Users/wang/Downloads/qrcode.txt", "UTF-8");
ExecutorService executorService = Executors.newFixedThreadPool(30); // 创建线程池
Semaphore semaphore = new Semaphore(30); // 限制并发请求数为30
// 用于统计请求耗时
AtomicLong totalTime = new AtomicLong(0);
AtomicLong maxTime = new AtomicLong(0);
AtomicLong minTime = new AtomicLong(Long.MAX_VALUE);
for (int i = 0; i < TOTAL_REQUESTS; i++) {
final int imageId = i % 9;
final int qrId = i / 9;
executorService.submit(() -> {
long startTime = System.currentTimeMillis();
try {
semaphore.acquire(); // 获取许可,控制并发请求
JSONObject jo = new JSONObject();
jo.put("wxEnterpriseId", "b18ffdc9d0644912865a248859914d80");
jo.put("qrCodeUrl", "https://gicinner-1251519181.cos.ap-shanghai.myqcloud.com/image/material_content-4ffc77073ca1476fb264bf1be9f11383.png");
jo.put("showStyle", "0");
jo.put("lineOne", "门店CCA");
jo.put("lineTwo", "宇智222为您推荐");
jo.put("mediaType", 1);
jo.put("imageUrl", list.get(imageId));
jo.put("qrCodeUrl", qrList.get(qrId));
HttpResponse execute = HttpRequest.post("https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json").timeout(-1).body(jo.toJSONString()).execute();
String body = execute.body();
String headerValue = execute.header("x-request-id");
// String post = HttpUtil.post("https://www.gicdev.com/haoban-manage3-wx/combined-qw-materialid.json", jo.toJSONString());
System.out.println(body);
System.out.println(headerValue);
} catch (Exception e) {
System.out.println("异常: " + e.getMessage());
} finally {
long duration = System.currentTimeMillis() - startTime;
System.out.println(duration);
totalTime.addAndGet(duration);
maxTime.updateAndGet(x -> Math.max(x, duration));
minTime.updateAndGet(x -> Math.min(x, duration));
semaphore.release(); // 释放许可
}
});
}
executorService.shutdown(); // 关闭线程池
// 打印统计信息
try {
if (!executorService.awaitTermination(1, TimeUnit.MINUTES)) {
executorService.shutdownNow(); // 强制关闭
}
} catch (InterruptedException e) {
executorService.shutdownNow();
}
long averageTime = totalTime.get() / TOTAL_REQUESTS;
System.out.println("完成所有请求");
System.out.println("平均耗时: " + averageTime + " ms");
System.out.println("最大耗时: " + maxTime.get() + " ms");
System.out.println("最小耗时: " + (minTime.get() == Long.MAX_VALUE ? 0 : minTime.get()) + " ms");
}
}
...@@ -5,6 +5,7 @@ import com.gic.commons.util.EntityUtil; ...@@ -5,6 +5,7 @@ import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.setting.ContentSettingDTO; import com.gic.content.api.dto.setting.ContentSettingDTO;
import com.gic.content.api.service.ContentSettingApiService; import com.gic.content.api.service.ContentSettingApiService;
import com.gic.haoban.manage.web.utils.ApolloUtils;
import com.gic.haoban.manage.web.vo.content.ContentSettingVO; import com.gic.haoban.manage.web.vo.content.ContentSettingVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -39,6 +40,7 @@ public class ContentSettingController { ...@@ -39,6 +40,7 @@ public class ContentSettingController {
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
ContentSettingVO contentSettingVO = EntityUtil.changeEntityByJSON(ContentSettingVO.class, serviceResponse.getResult()); ContentSettingVO contentSettingVO = EntityUtil.changeEntityByJSON(ContentSettingVO.class, serviceResponse.getResult());
contentSettingVO.setCombinedType(ApolloUtils.combinedType(enterpriseId));
return RestResponse.successResult(contentSettingVO); return RestResponse.successResult(contentSettingVO);
} }
} }
...@@ -3,11 +3,15 @@ package com.gic.haoban.manage.web.controller.content; ...@@ -3,11 +3,15 @@ package com.gic.haoban.manage.web.controller.content;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.gic.haoban.manage.api.qdto.combined.CombinedQDTO;
import com.gic.haoban.manage.web.qo.combined.CombinedQO;
import com.gic.haoban.manage.web.qo.combined.CombinedsQO;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -171,4 +175,16 @@ public class QwMessageController extends WebBaseController { ...@@ -171,4 +175,16 @@ public class QwMessageController extends WebBaseController {
} }
return RestResponse.failure("-1", resp.getMessage()) ; return RestResponse.failure("-1", resp.getMessage()) ;
} }
@RequestMapping("combined-qw-materialid")
public RestResponse<Object> combinedMaterialId(@RequestBody CombinedQO combinedQO) {
String wxEnterpriseId = combinedQO.getWxEnterpriseId();
CombinedQDTO combinedQDTO = com.gic.commons.util.EntityUtil.changeEntityNew(CombinedQDTO.class, combinedQO);
ServiceResponse<String> resp = this.materialApiService.getMaterialIdByCombined(wxEnterpriseId, combinedQDTO) ;
if(resp.isSuccess()) {
return RestResponse.successResult(resp.getResult()) ;
}
return RestResponse.failure("-1", resp.getMessage()) ;
}
} }
package com.gic.haoban.manage.web.qo.combined;
import java.io.Serializable;
public class CombinedQO implements Serializable {
private static final long serialVersionUID = -28454620622119889L;
private String wxEnterpriseId;
/**
* 主图url
*/
private String imageUrl;
/**
* 小程序码url
*/
private String qrCodeUrl;
/**
* 展示样式
*/
private Integer showStyle;
/**
* 第一行文字
*/
private String lineOne;
/**
* 第二行文字
*/
private String lineTwo;
/**
* 1群发 2朋友圈
*/
private Integer mediaType ;
/**
* 导购id(作标识)
*/
private String clerkId;
/**
* 业务id(作标识)
*/
private String businessId;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getQrCodeUrl() {
return qrCodeUrl;
}
public void setQrCodeUrl(String qrCodeUrl) {
this.qrCodeUrl = qrCodeUrl;
}
public Integer getShowStyle() {
return showStyle;
}
public void setShowStyle(Integer showStyle) {
this.showStyle = showStyle;
}
public String getLineOne() {
return lineOne;
}
public void setLineOne(String lineOne) {
this.lineOne = lineOne;
}
public String getLineTwo() {
return lineTwo;
}
public void setLineTwo(String lineTwo) {
this.lineTwo = lineTwo;
}
public Integer getMediaType() {
return mediaType;
}
public void setMediaType(Integer mediaType) {
this.mediaType = mediaType;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getBusinessId() {
return businessId;
}
public void setBusinessId(String businessId) {
this.businessId = businessId;
}
}
package com.gic.haoban.manage.web.qo.combined;
import java.io.Serializable;
import java.util.List;
public class CombinedsQO implements Serializable {
private static final long serialVersionUID = -28454620622119889L;
private String wxEnterpriseId;
/**
* 主图url
*/
private List<String> imageUrlList;
/**
* 小程序码url
*/
private String qrCodeUrl;
/**
* 展示样式
*/
private Integer showStyle;
/**
* 第一行文字
*/
private String lineOne;
/**
* 第二行文字
*/
private String lineTwo;
/**
* 1群发 2朋友圈
*/
private Integer mediaType ;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public List<String> getImageUrlList() {
return imageUrlList;
}
public void setImageUrlList(List<String> imageUrlList) {
this.imageUrlList = imageUrlList;
}
public String getQrCodeUrl() {
return qrCodeUrl;
}
public void setQrCodeUrl(String qrCodeUrl) {
this.qrCodeUrl = qrCodeUrl;
}
public Integer getShowStyle() {
return showStyle;
}
public void setShowStyle(Integer showStyle) {
this.showStyle = showStyle;
}
public String getLineOne() {
return lineOne;
}
public void setLineOne(String lineOne) {
this.lineOne = lineOne;
}
public String getLineTwo() {
return lineTwo;
}
public void setLineTwo(String lineTwo) {
this.lineTwo = lineTwo;
}
public Integer getMediaType() {
return mediaType;
}
public void setMediaType(Integer mediaType) {
this.mediaType = mediaType;
}
}
package com.gic.haoban.manage.web.utils;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.api.base.commons.Constant;
import org.apache.commons.lang3.StringUtils;
public class ApolloUtils {
/**
* 内容分享企微素材使用老的前端合成还是新的后端合成 0老1新
* @return
*/
public static Integer combinedType(String eid) {
Config config = ConfigService.getAppConfig();
String combinedEid = config.getProperty("combinedEid", "");
if (StringUtils.isBlank(combinedEid)) {
return Constant.FLAG_TRUE;
}
return combinedEid.contains(eid) ? Constant.FLAG_TRUE : Constant.FLAG_FALSE;
}
}
...@@ -75,6 +75,11 @@ public class ContentSettingVO implements Serializable { ...@@ -75,6 +75,11 @@ public class ContentSettingVO implements Serializable {
*/ */
private Integer showStyle; private Integer showStyle;
/**
* 0老模式1新模式
*/
private Integer combinedType;
public Long getContentSettingId() { public Long getContentSettingId() {
return contentSettingId; return contentSettingId;
} }
...@@ -170,4 +175,12 @@ public class ContentSettingVO implements Serializable { ...@@ -170,4 +175,12 @@ public class ContentSettingVO implements Serializable {
public void setShowStyle(Integer showStyle) { public void setShowStyle(Integer showStyle) {
this.showStyle = showStyle; this.showStyle = showStyle;
} }
public Integer getCombinedType() {
return combinedType;
}
public void setCombinedType(Integer combinedType) {
this.combinedType = combinedType;
}
} }
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